Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorClément Foucault <fclem>2022-09-02 14:48:55 +0300
committerClément Foucault <foucault.clem@gmail.com>2022-09-02 14:51:43 +0300
commitde818d81c3f9868ca78399fa7f106bed893e540f (patch)
treef98d9d42e4684ec165a25d82889224f6603ef835 /source/blender/gpu/shaders/material/gpu_shader_material_principled.glsl
parentf366d197db24cf611866a8d847b4022a6a46504e (diff)
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
Diffstat (limited to 'source/blender/gpu/shaders/material/gpu_shader_material_principled.glsl')
-rw-r--r--source/blender/gpu/shaders/material/gpu_shader_material_principled.glsl12
1 files changed, 12 insertions, 0 deletions
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);