From 9988739332d9bca0808feff656abe8b8fd465afa Mon Sep 17 00:00:00 2001 From: Omar El Sheikh Date: Sat, 5 Mar 2022 16:33:17 -0500 Subject: [PATCH] Fix shader state caching when blend shapes used Previously, conditionals set on the shader would change outside of the _render_list function when blend shapes were used This is an issue because the function keeps track of the previous shader state to try to minimize state changes Now we keep all this shader state change within the _render_list function to ensure the saved previous state is correct --- drivers/gles3/rasterizer_scene_gles3.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/gles3/rasterizer_scene_gles3.cpp b/drivers/gles3/rasterizer_scene_gles3.cpp index 5be577fd1ac..3fb2b0674dc 100644 --- a/drivers/gles3/rasterizer_scene_gles3.cpp +++ b/drivers/gles3/rasterizer_scene_gles3.cpp @@ -1297,8 +1297,6 @@ void RasterizerSceneGLES3::_setup_geometry(RenderList::Element *e, const Transfo if (s->blend_shapes.size() && e->instance->blend_values.size()) { //blend shapes, use transform feedback storage->mesh_render_blend_shapes(s, e->instance->blend_values.read().ptr()); - //disable octahedral compression as the result of blend shapes is always uncompressed cartesian coordinates - state.scene_shader.set_conditional(SceneShaderGLES3::ENABLE_OCTAHEDRAL_COMPRESSION, false); //rebind shader state.scene_shader.bind(); #ifdef DEBUG_ENABLED @@ -2147,7 +2145,9 @@ void RasterizerSceneGLES3::_render_list(RenderList::Element **p_elements, int p_ state.scene_shader.set_conditional(SceneShaderGLES3::USE_PHYSICAL_LIGHT_ATTENUATION, storage->config.use_physical_light_attenuation); - bool octahedral_compression = e->instance->base_type != VS::INSTANCE_IMMEDIATE && ((RasterizerStorageGLES3::Surface *)e->geometry)->format & VisualServer::ArrayFormat::ARRAY_FLAG_USE_OCTAHEDRAL_COMPRESSION; + bool octahedral_compression = e->instance->base_type != VS::INSTANCE_IMMEDIATE && + ((RasterizerStorageGLES3::Surface *)e->geometry)->format & VisualServer::ArrayFormat::ARRAY_FLAG_USE_OCTAHEDRAL_COMPRESSION && + !(((RasterizerStorageGLES3::Surface *)e->geometry)->blend_shapes.size() && e->instance->blend_values.size()); if (octahedral_compression != prev_octahedral_compression) { state.scene_shader.set_conditional(SceneShaderGLES3::ENABLE_OCTAHEDRAL_COMPRESSION, octahedral_compression); rebind = true;