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
This commit is contained in:
Miguel Pozo
2024-05-15 20:06:31 +02:00
parent 88e76a0667
commit d64544a32f
2 changed files with 5 additions and 3 deletions

View File

@@ -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. */

View File

@@ -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