From de818d81c3f9868ca78399fa7f106bed893e540f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20Foucault?= Date: Fri, 2 Sep 2022 13:48:55 +0200 Subject: Fix T98190: EEVEE: Very slow rendering on Intel HD Graphics 4400 This particular GPU driver does not constant fold all the way in order to discard the unused branches. To workaround that, we introduce a series of material flag that generates defines that only keep used branches. Reviewed By: jbakker Differential Revision: https://developer.blender.org/D15852 --- .../gpu/shaders/material/gpu_shader_material_principled.glsl | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'source/blender/gpu/shaders') diff --git a/source/blender/gpu/shaders/material/gpu_shader_material_principled.glsl b/source/blender/gpu/shaders/material/gpu_shader_material_principled.glsl index 2e695fa3e14..0d8f2272c10 100644 --- a/source/blender/gpu/shaders/material/gpu_shader_material_principled.glsl +++ b/source/blender/gpu/shaders/material/gpu_shader_material_principled.glsl @@ -149,25 +149,37 @@ void node_bsdf_principled(vec4 base_color, max(roughness, transmission_roughness); refraction_data.ior = ior; + /* Ref. T98190: Defines are optimizations for old compilers. + * Might become unecessary with EEVEE-Next. */ if (do_diffuse == 0.0 && do_refraction == 0.0 && do_clearcoat != 0.0) { +#ifdef PRINCIPLED_CLEARCOAT /* Metallic & Clearcoat case. */ result = closure_eval(reflection_data, clearcoat_data); +#endif } else if (do_diffuse == 0.0 && do_refraction == 0.0 && do_clearcoat == 0.0) { +#ifdef PRINCIPLED_METALLIC /* Metallic case. */ result = closure_eval(reflection_data); +#endif } else if (do_diffuse != 0.0 && do_refraction == 0.0 && do_clearcoat == 0.0) { +#ifdef PRINCIPLED_DIELECTRIC /* Dielectric case. */ result = closure_eval(diffuse_data, reflection_data); +#endif } else if (do_diffuse == 0.0 && do_refraction != 0.0 && do_clearcoat == 0.0) { +#ifdef PRINCIPLED_GLASS /* Glass case. */ result = closure_eval(reflection_data, refraction_data); +#endif } else { +#ifdef PRINCIPLED_ANY /* Un-optimized case. */ result = closure_eval(diffuse_data, reflection_data, clearcoat_data, refraction_data); +#endif } Closure emission_cl = closure_eval(emission_data); Closure transparency_cl = closure_eval(transparency_data); -- cgit v1.2.3