While comparing similar programs on both the vulkan driver and i965 GL, like :
varying vec4 tex_coord;
varying vec4 color_in;
uniform sampler2D sampler;
vec4 temp;
void func()
{
temp = texture2D(sampler, tex_coord) * color_in;
}
void main()
{
func();
temp = vec4(gl_PointCoord.x, gl_PointCoord.y, 0.0, 1.0);
gl_FragColor = temp;
}
I noticed that 2 varyings were programmed on the Vulkan driver where the GL
driver only programs one. The difference between the GL driver and the
vulkan one seems to be that other optimization passes are applied before the
glsl_to_nir() transformation.
It seems that dead variables removal passes should be applied after inlining
functions and applying dead code elimination, otherwise variables might
still be used by code that isn't useful.
Signed-off-by: Lionel Landwerlin <[email protected]>
Cc: Jason Ekstrand <[email protected]>
---
src/intel/vulkan/anv_pipeline.c | 10 ++++++----
1 file changed, 6 insertions(+), 4 deletions(-)
diff --git a/src/intel/vulkan/anv_pipeline.c b/src/intel/vulkan/anv_pipeline.c
index 451166e..bc7aa6e 100644
--- a/src/intel/vulkan/anv_pipeline.c
+++ b/src/intel/vulkan/anv_pipeline.c
@@ -157,10 +157,6 @@ anv_shader_compile_to_nir(struct anv_device *device,
assert(exec_list_length(&nir->functions) == 1);
entry_point->name = ralloc_strdup(entry_point, "main");
- NIR_PASS_V(nir, nir_remove_dead_variables, nir_var_shader_in);
- NIR_PASS_V(nir, nir_remove_dead_variables, nir_var_shader_out);
- NIR_PASS_V(nir, nir_remove_dead_variables, nir_var_system_value);
-
NIR_PASS_V(nir, nir_propagate_invariant);
NIR_PASS_V(nir, nir_lower_io_to_temporaries, entry_point->impl,
@@ -174,6 +170,12 @@ anv_shader_compile_to_nir(struct anv_device *device,
nir = brw_preprocess_nir(compiler, nir);
+ if (!module->nir) {
+ NIR_PASS_V(nir, nir_remove_dead_variables, nir_var_shader_in);
+ NIR_PASS_V(nir, nir_remove_dead_variables, nir_var_shader_out);
+ NIR_PASS_V(nir, nir_remove_dead_variables, nir_var_system_value);
+ }
+
NIR_PASS_V(nir, nir_shader_gather_info, entry_point->impl);
nir_variable_mode indirect_mask = 0;
--
2.9.3
_______________________________________________
mesa-dev mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/mesa-dev