@@ -1047,26 +1047,29 @@ Ref<Image> RasterizerSceneGLES3::sky_bake_panorama(RID p_sky, float p_energy, bo
10471047 glDeleteFramebuffers (1 , &rad_fbo);
10481048 // Create a dummy texture so we can use texture_2d_get.
10491049 RID tex_rid = GLES3::TextureStorage::get_singleton ()->texture_allocate ();
1050- GLES3::Texture texture;
1051- texture.width = p_size.width ;
1052- texture.height = p_size.height ;
1053- texture.alloc_width = p_size.width ;
1054- texture.alloc_height = p_size.height ;
1055- texture.format = Image::FORMAT_RGBAF;
1056- texture.real_format = Image::FORMAT_RGBAF;
1057- texture.gl_format_cache = GL_RGBA;
1058- texture.gl_type_cache = GL_FLOAT;
1059- texture.type = GLES3::Texture::TYPE_2D;
1060- texture.target = GL_TEXTURE_2D;
1061- texture.active = true ;
1062- texture.tex_id = rad_tex;
1063- texture.is_render_target = true ;
1050+ {
1051+ GLES3::Texture texture;
1052+ texture.width = p_size.width ;
1053+ texture.height = p_size.height ;
1054+ texture.alloc_width = p_size.width ;
1055+ texture.alloc_height = p_size.height ;
1056+ texture.format = Image::FORMAT_RGBAF;
1057+ texture.real_format = Image::FORMAT_RGBAF;
1058+ texture.gl_format_cache = GL_RGBA;
1059+ texture.gl_type_cache = GL_FLOAT;
1060+ texture.type = GLES3::Texture::TYPE_2D;
1061+ texture.target = GL_TEXTURE_2D;
1062+ texture.active = true ;
1063+ texture.tex_id = rad_tex;
1064+ texture.is_render_target = true ; // HACK: Prevent TextureStorage from retaining a cached copy of the texture.
1065+ GLES3::TextureStorage::get_singleton ()->texture_2d_initialize_from_texture (tex_rid, texture);
1066+ }
10641067
1065- GLES3::TextureStorage::get_singleton ()->texture_2d_initialize_from_texture (tex_rid, texture);
10661068 Ref<Image> img = GLES3::TextureStorage::get_singleton ()->texture_2d_get (tex_rid);
10671069 GLES3::Utilities::get_singleton ()->texture_free_data (rad_tex);
10681070
1069- texture.is_render_target = false ;
1071+ GLES3::Texture &texture = *GLES3::TextureStorage::get_singleton ()->get_texture (tex_rid);
1072+ texture.is_render_target = false ; // HACK: Avoid an error when freeing the texture.
10701073 texture.tex_id = 0 ;
10711074 GLES3::TextureStorage::get_singleton ()->texture_free (tex_rid);
10721075
0 commit comments