Enforce calling RenderingDevice code from rendering thread in TextureRD classes
This commit is contained in:
parent
17e7f85c06
commit
83241ab139
2 changed files with 108 additions and 87 deletions
|
@ -74,6 +74,18 @@ void Texture2DRD::set_texture_rd_rid(RID p_texture_rd_rid) {
|
||||||
ERR_FAIL_NULL(RS::get_singleton());
|
ERR_FAIL_NULL(RS::get_singleton());
|
||||||
|
|
||||||
if (p_texture_rd_rid.is_valid()) {
|
if (p_texture_rd_rid.is_valid()) {
|
||||||
|
RS::get_singleton()->call_on_render_thread(callable_mp(this, &Texture2DRD::_set_texture_rd_rid).bind(p_texture_rd_rid));
|
||||||
|
} else if (texture_rid.is_valid()) {
|
||||||
|
RS::get_singleton()->free(texture_rid);
|
||||||
|
texture_rid = RID();
|
||||||
|
size = Size2i();
|
||||||
|
|
||||||
|
notify_property_list_changed();
|
||||||
|
emit_changed();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void Texture2DRD::_set_texture_rd_rid(RID p_texture_rd_rid) {
|
||||||
ERR_FAIL_NULL(RD::get_singleton());
|
ERR_FAIL_NULL(RD::get_singleton());
|
||||||
ERR_FAIL_COND(!RD::get_singleton()->texture_is_valid(p_texture_rd_rid));
|
ERR_FAIL_COND(!RD::get_singleton()->texture_is_valid(p_texture_rd_rid));
|
||||||
|
|
||||||
|
@ -95,14 +107,6 @@ void Texture2DRD::set_texture_rd_rid(RID p_texture_rd_rid) {
|
||||||
|
|
||||||
notify_property_list_changed();
|
notify_property_list_changed();
|
||||||
emit_changed();
|
emit_changed();
|
||||||
} else if (texture_rid.is_valid()) {
|
|
||||||
RS::get_singleton()->free(texture_rid);
|
|
||||||
texture_rid = RID();
|
|
||||||
size = Size2i();
|
|
||||||
|
|
||||||
notify_property_list_changed();
|
|
||||||
emit_changed();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
RID Texture2DRD::get_texture_rd_rid() const {
|
RID Texture2DRD::get_texture_rd_rid() const {
|
||||||
|
@ -173,6 +177,21 @@ void TextureLayeredRD::set_texture_rd_rid(RID p_texture_rd_rid) {
|
||||||
ERR_FAIL_NULL(RS::get_singleton());
|
ERR_FAIL_NULL(RS::get_singleton());
|
||||||
|
|
||||||
if (p_texture_rd_rid.is_valid()) {
|
if (p_texture_rd_rid.is_valid()) {
|
||||||
|
RS::get_singleton()->call_on_render_thread(callable_mp(this, &TextureLayeredRD::_set_texture_rd_rid).bind(p_texture_rd_rid));
|
||||||
|
} else if (texture_rid.is_valid()) {
|
||||||
|
RS::get_singleton()->free(texture_rid);
|
||||||
|
texture_rid = RID();
|
||||||
|
image_format = Image::FORMAT_MAX;
|
||||||
|
size = Size2i();
|
||||||
|
layers = 0;
|
||||||
|
mipmaps = 0;
|
||||||
|
|
||||||
|
notify_property_list_changed();
|
||||||
|
emit_changed();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void TextureLayeredRD::_set_texture_rd_rid(RID p_texture_rd_rid) {
|
||||||
ERR_FAIL_NULL(RD::get_singleton());
|
ERR_FAIL_NULL(RD::get_singleton());
|
||||||
ERR_FAIL_COND(!RD::get_singleton()->texture_is_valid(p_texture_rd_rid));
|
ERR_FAIL_COND(!RD::get_singleton()->texture_is_valid(p_texture_rd_rid));
|
||||||
|
|
||||||
|
@ -215,17 +234,6 @@ void TextureLayeredRD::set_texture_rd_rid(RID p_texture_rd_rid) {
|
||||||
|
|
||||||
notify_property_list_changed();
|
notify_property_list_changed();
|
||||||
emit_changed();
|
emit_changed();
|
||||||
} else if (texture_rid.is_valid()) {
|
|
||||||
RS::get_singleton()->free(texture_rid);
|
|
||||||
texture_rid = RID();
|
|
||||||
image_format = Image::FORMAT_MAX;
|
|
||||||
size = Size2i();
|
|
||||||
layers = 0;
|
|
||||||
mipmaps = 0;
|
|
||||||
|
|
||||||
notify_property_list_changed();
|
|
||||||
emit_changed();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
RID TextureLayeredRD::get_texture_rd_rid() const {
|
RID TextureLayeredRD::get_texture_rd_rid() const {
|
||||||
|
@ -291,6 +299,20 @@ void Texture3DRD::set_texture_rd_rid(RID p_texture_rd_rid) {
|
||||||
ERR_FAIL_NULL(RS::get_singleton());
|
ERR_FAIL_NULL(RS::get_singleton());
|
||||||
|
|
||||||
if (p_texture_rd_rid.is_valid()) {
|
if (p_texture_rd_rid.is_valid()) {
|
||||||
|
RS::get_singleton()->call_on_render_thread(callable_mp(this, &Texture3DRD::_set_texture_rd_rid).bind(p_texture_rd_rid));
|
||||||
|
} else if (texture_rid.is_valid()) {
|
||||||
|
RS::get_singleton()->free(texture_rid);
|
||||||
|
texture_rid = RID();
|
||||||
|
image_format = Image::FORMAT_MAX;
|
||||||
|
size = Vector3i();
|
||||||
|
mipmaps = 0;
|
||||||
|
|
||||||
|
notify_property_list_changed();
|
||||||
|
emit_changed();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void Texture3DRD::_set_texture_rd_rid(RID p_texture_rd_rid) {
|
||||||
ERR_FAIL_NULL(RD::get_singleton());
|
ERR_FAIL_NULL(RD::get_singleton());
|
||||||
ERR_FAIL_COND(!RD::get_singleton()->texture_is_valid(p_texture_rd_rid));
|
ERR_FAIL_COND(!RD::get_singleton()->texture_is_valid(p_texture_rd_rid));
|
||||||
|
|
||||||
|
@ -315,16 +337,6 @@ void Texture3DRD::set_texture_rd_rid(RID p_texture_rd_rid) {
|
||||||
|
|
||||||
notify_property_list_changed();
|
notify_property_list_changed();
|
||||||
emit_changed();
|
emit_changed();
|
||||||
} else if (texture_rid.is_valid()) {
|
|
||||||
RS::get_singleton()->free(texture_rid);
|
|
||||||
texture_rid = RID();
|
|
||||||
image_format = Image::FORMAT_MAX;
|
|
||||||
size = Vector3i();
|
|
||||||
mipmaps = 0;
|
|
||||||
|
|
||||||
notify_property_list_changed();
|
|
||||||
emit_changed();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
RID Texture3DRD::get_texture_rd_rid() const {
|
RID Texture3DRD::get_texture_rd_rid() const {
|
||||||
|
|
|
@ -60,6 +60,9 @@ public:
|
||||||
void set_texture_rd_rid(RID p_texture_rd_rid);
|
void set_texture_rd_rid(RID p_texture_rd_rid);
|
||||||
RID get_texture_rd_rid() const;
|
RID get_texture_rd_rid() const;
|
||||||
|
|
||||||
|
// Internal function that should only be called from the rendering thread.
|
||||||
|
void _set_texture_rd_rid(RID p_texture_rd_rid);
|
||||||
|
|
||||||
Texture2DRD();
|
Texture2DRD();
|
||||||
~Texture2DRD();
|
~Texture2DRD();
|
||||||
};
|
};
|
||||||
|
@ -94,6 +97,9 @@ public:
|
||||||
void set_texture_rd_rid(RID p_texture_rd_rid);
|
void set_texture_rd_rid(RID p_texture_rd_rid);
|
||||||
RID get_texture_rd_rid() const;
|
RID get_texture_rd_rid() const;
|
||||||
|
|
||||||
|
// Internal function that should only be called from the rendering thread.
|
||||||
|
void _set_texture_rd_rid(RID p_texture_rd_rid);
|
||||||
|
|
||||||
TextureLayeredRD(LayeredType p_layer_type);
|
TextureLayeredRD(LayeredType p_layer_type);
|
||||||
~TextureLayeredRD();
|
~TextureLayeredRD();
|
||||||
};
|
};
|
||||||
|
@ -146,6 +152,9 @@ public:
|
||||||
void set_texture_rd_rid(RID p_texture_rd_rid);
|
void set_texture_rd_rid(RID p_texture_rd_rid);
|
||||||
RID get_texture_rd_rid() const;
|
RID get_texture_rd_rid() const;
|
||||||
|
|
||||||
|
// Internal function that should only be called from the rendering thread.
|
||||||
|
void _set_texture_rd_rid(RID p_texture_rd_rid);
|
||||||
|
|
||||||
Texture3DRD();
|
Texture3DRD();
|
||||||
~Texture3DRD();
|
~Texture3DRD();
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in a new issue