From d64544a32fcb6d593ea0254c8c92d3be62dc7c01 Mon Sep 17 00:00:00 2001 From: Miguel Pozo Date: Wed, 15 May 2024 20:06:31 +0200 Subject: [PATCH] Fix: EEVEE-Next: ShaderKey subpass overlap The same Shader may need to be used by more than one pipeline subpass. Include all relevant properties in ShaderKey to always retrieve the correct subpass. Fix #121667. Pull Request: https://projects.blender.org/blender/blender/pulls/121834 --- source/blender/draw/engines/eevee_next/eevee_material.cc | 2 +- source/blender/draw/engines/eevee_next/eevee_material.hh | 6 ++++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/source/blender/draw/engines/eevee_next/eevee_material.cc b/source/blender/draw/engines/eevee_next/eevee_material.cc index feb72b55d32..7c9332b7eda 100644 --- a/source/blender/draw/engines/eevee_next/eevee_material.cc +++ b/source/blender/draw/engines/eevee_next/eevee_material.cc @@ -229,7 +229,7 @@ MaterialPass MaterialModule::material_pass_get(Object *ob, matpass.sub_pass = nullptr; } else { - ShaderKey shader_key(matpass.gpumat, probe_capture); + ShaderKey shader_key(matpass.gpumat, blender_mat, probe_capture); PassMain::Sub *shader_sub = shader_map_.lookup_or_add_cb(shader_key, [&]() { /* First time encountering this shader. Create a sub that will contain materials using it. */ diff --git a/source/blender/draw/engines/eevee_next/eevee_material.hh b/source/blender/draw/engines/eevee_next/eevee_material.hh index 209bb83006d..4d213935331 100644 --- a/source/blender/draw/engines/eevee_next/eevee_material.hh +++ b/source/blender/draw/engines/eevee_next/eevee_material.hh @@ -256,10 +256,12 @@ struct ShaderKey { GPUShader *shader; uint64_t options; - ShaderKey(GPUMaterial *gpumat, eMaterialProbe probe_capture) + ShaderKey(GPUMaterial *gpumat, ::Material *blender_mat, eMaterialProbe probe_capture) { shader = GPU_material_get_shader(gpumat); - options = uint64_t(probe_capture); + options = uint64_t(shader_closure_bits_from_flag(gpumat)); + options = (options << 8) | blender_mat->blend_flag; + options = (options << 2) | uint64_t(probe_capture); } uint64_t hash() const