Skip to content

Commit

Permalink
Add check to TextureLayered set_flags method to not set the flags on …
Browse files Browse the repository at this point in the history
…the VisualServer if uninitialized. Add error checks on GLES2 and GLES3 rasterizer.
  • Loading branch information
SaracenOne committed Mar 24, 2021
1 parent 94a0fc4 commit f73f862
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 0 deletions.
2 changes: 2 additions & 0 deletions drivers/gles2/rasterizer_storage_gles2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -953,7 +953,9 @@ Ref<Image> RasterizerStorageGLES2::texture_get_data(RID p_texture, int p_layer)
void RasterizerStorageGLES2::texture_set_flags(RID p_texture, uint32_t p_flags) {

Texture *texture = texture_owner.getornull(p_texture);

ERR_FAIL_COND(!texture);
ERR_FAIL_COND(!texture->active);

bool had_mipmaps = texture->flags & VS::TEXTURE_FLAG_MIPMAPS;

Expand Down
3 changes: 3 additions & 0 deletions drivers/gles3/rasterizer_storage_gles3.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1382,7 +1382,10 @@ Ref<Image> RasterizerStorageGLES3::texture_get_data(RID p_texture, int p_layer)
void RasterizerStorageGLES3::texture_set_flags(RID p_texture, uint32_t p_flags) {

Texture *texture = texture_owner.get(p_texture);

ERR_FAIL_COND(!texture);
ERR_FAIL_COND(!texture->active);

if (texture->render_target) {

p_flags &= VS::TEXTURE_FLAG_FILTER; //can change only filter
Expand Down
4 changes: 4 additions & 0 deletions scene/resources/texture.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2228,6 +2228,10 @@ AnimatedTexture::~AnimatedTexture() {
void TextureLayered::set_flags(uint32_t p_flags) {
flags = p_flags;

if (width == 0 || height == 0 || depth == 0) {
return; //uninitialized, do not set to texture
}

if (texture.is_valid()) {
VS::get_singleton()->texture_set_flags(texture, flags);
}
Expand Down

0 comments on commit f73f862

Please sign in to comment.