Skip to content

Rendering: Don't cache texture_2d_get in tool script #105380

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 0 additions & 34 deletions drivers/gles3/storage/texture_storage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -999,10 +999,6 @@ void TextureStorage::texture_2d_update(RID p_texture, const Ref<Image> &p_image,
Texture *tex = texture_owner.get_or_null(p_texture);
ERR_FAIL_NULL(tex);
GLES3::Utilities::get_singleton()->texture_resize_data(tex->tex_id, tex->total_data_size);

#ifdef TOOLS_ENABLED
tex->image_cache_2d.unref();
#endif
}

void TextureStorage::texture_3d_update(RID p_texture, const Vector<Ref<Image>> &p_data) {
Expand Down Expand Up @@ -1079,12 +1075,6 @@ Ref<Image> TextureStorage::texture_2d_get(RID p_texture) const {
Texture *texture = texture_owner.get_or_null(p_texture);
ERR_FAIL_NULL_V(texture, Ref<Image>());

#ifdef TOOLS_ENABLED
if (texture->image_cache_2d.is_valid() && !texture->is_render_target) {
return texture->image_cache_2d;
}
#endif

Ref<Image> image;
#ifdef GL_API_ENABLED
if (RasterizerGLES3::is_gles_over_gl()) {
Expand Down Expand Up @@ -1194,12 +1184,6 @@ Ref<Image> TextureStorage::texture_2d_get(RID p_texture) const {
}
#endif // GLES_API_ENABLED

#ifdef TOOLS_ENABLED
if (Engine::get_singleton()->is_editor_hint() && !texture->is_render_target) {
texture->image_cache_2d = image;
}
#endif

return image;
}

Expand Down Expand Up @@ -1320,12 +1304,6 @@ Vector<Ref<Image>> TextureStorage::texture_3d_get(RID p_texture) const {
ERR_FAIL_NULL_V(texture, Vector<Ref<Image>>());
ERR_FAIL_COND_V(texture->type != Texture::TYPE_3D, Vector<Ref<Image>>());

#ifdef TOOLS_ENABLED
if (!texture->image_cache_3d.is_empty() && !texture->is_render_target) {
return texture->image_cache_3d;
}
#endif

GLuint temp_framebuffer;
glGenFramebuffers(1, &temp_framebuffer);

Expand Down Expand Up @@ -1356,12 +1334,6 @@ Vector<Ref<Image>> TextureStorage::texture_3d_get(RID p_texture) const {
glDeleteTextures(1, &temp_color_texture);
glDeleteFramebuffers(1, &temp_framebuffer);

#ifdef TOOLS_ENABLED
if (Engine::get_singleton()->is_editor_hint() && !texture->is_render_target) {
texture->image_cache_3d = ret;
}
#endif

return ret;
}

Expand Down Expand Up @@ -1718,12 +1690,6 @@ void TextureStorage::_texture_set_3d_data(RID p_texture, const Vector<Ref<Image>

texture->total_data_size = all_data_size;
texture->mipmaps = mipmap_level + 1;

#ifdef TOOLS_ENABLED
if (Engine::get_singleton()->is_editor_hint() && !texture->is_render_target) {
texture->image_cache_3d = images;
}
#endif
}

void TextureStorage::_texture_set_swizzle(GLES3::Texture *p_texture, Image::Format p_real_format) {
Expand Down
3 changes: 0 additions & 3 deletions drivers/gles3/storage/texture_storage.h
Original file line number Diff line number Diff line change
Expand Up @@ -191,9 +191,6 @@ struct Texture {

RenderTarget *render_target = nullptr;

Ref<Image> image_cache_2d;
Vector<Ref<Image>> image_cache_3d;

bool redraw_if_visible = false;

RS::TextureDetectCallback detect_3d_callback = nullptr;
Expand Down
14 changes: 0 additions & 14 deletions servers/rendering/renderer_rd/storage_rd/texture_storage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1317,9 +1317,6 @@ void TextureStorage::_texture_2d_update(RID p_texture, const Ref<Image> &p_image
ERR_FAIL_INDEX(p_layer, tex->layers);
}

#ifdef TOOLS_ENABLED
tex->image_cache_2d.unref();
#endif
TextureToRDFormat f;
Ref<Image> validated = _validate_texture_format(p_image, f);

Expand Down Expand Up @@ -1435,11 +1432,6 @@ Ref<Image> TextureStorage::texture_2d_get(RID p_texture) const {
Texture *tex = texture_owner.get_or_null(p_texture);
ERR_FAIL_NULL_V(tex, Ref<Image>());

#ifdef TOOLS_ENABLED
if (tex->image_cache_2d.is_valid() && !tex->is_render_target) {
return tex->image_cache_2d;
}
#endif
Vector<uint8_t> data = RD::get_singleton()->texture_get_data(tex->rd_texture, 0);
ERR_FAIL_COND_V(data.is_empty(), Ref<Image>());
Ref<Image> image;
Expand Down Expand Up @@ -1480,12 +1472,6 @@ Ref<Image> TextureStorage::texture_2d_get(RID p_texture) const {
image->convert(tex->format);
}

#ifdef TOOLS_ENABLED
if (Engine::get_singleton()->is_editor_hint() && !tex->is_render_target) {
tex->image_cache_2d = image;
}
#endif

return image;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,6 @@ class TextureStorage : public RendererTextureStorage {
bool is_render_target;
bool is_proxy;

Ref<Image> image_cache_2d;
String path;

RID proxy_to;
Expand Down