[Mesa-dev] [PATCH] anv: fix bug when using component qualifier in FS outputs

Samuel Iglesias Gonsálvez siglesias at igalia.com
Thu Nov 2 07:28:11 UTC 2017


We can write to the same output but in different components, like
in this example:

layout(location = 0, component = 0) out ivec2 dEQP_FragColor_0;
layout(location = 0, component = 2) out ivec2 dEQP_FragColor_1;

Therefore, they are not two different outputs but only one.

Fixes:

dEQP-VK.glsl.440.linkage.varying.component.frag_out.*

Signed-off-by: Samuel Iglesias Gonsálvez <siglesias at igalia.com>
---
 src/compiler/shader_enums.h     |  1 +
 src/intel/vulkan/anv_pipeline.c | 10 +++++++++-
 2 files changed, 10 insertions(+), 1 deletion(-)

diff --git a/src/compiler/shader_enums.h b/src/compiler/shader_enums.h
index 9d229d4199e..90729dbfd96 100644
--- a/src/compiler/shader_enums.h
+++ b/src/compiler/shader_enums.h
@@ -603,6 +603,7 @@ typedef enum
    FRAG_RESULT_DATA5,
    FRAG_RESULT_DATA6,
    FRAG_RESULT_DATA7,
+   FRAG_RESULT_MAX, /**< Number of fragment program results */
 } gl_frag_result;
 
 const char *gl_frag_result_name(gl_frag_result result);
diff --git a/src/intel/vulkan/anv_pipeline.c b/src/intel/vulkan/anv_pipeline.c
index 907b24a758d..be007f24e3f 100644
--- a/src/intel/vulkan/anv_pipeline.c
+++ b/src/intel/vulkan/anv_pipeline.c
@@ -872,6 +872,8 @@ anv_pipeline_compile_fs(struct anv_pipeline *pipeline,
       unsigned num_rts = 0;
       struct anv_pipeline_binding rt_bindings[8];
       nir_function_impl *impl = nir_shader_get_entrypoint(nir);
+      int map_old_to_new_loc[FRAG_RESULT_MAX];
+      memset(map_old_to_new_loc, -1, sizeof(int) * FRAG_RESULT_MAX);
       nir_foreach_variable_safe(var, &nir->outputs) {
          if (var->data.location < FRAG_RESULT_DATA0)
             continue;
@@ -886,7 +888,13 @@ anv_pipeline_compile_fs(struct anv_pipeline *pipeline,
          }
 
          /* Give it a new, compacted, location */
-         var->data.location = FRAG_RESULT_DATA0 + num_rts;
+         if (var->data.location != -1) {
+            if (map_old_to_new_loc[var->data.location] == -1)
+               map_old_to_new_loc[var->data.location] = FRAG_RESULT_DATA0 + num_rts;
+            var->data.location = map_old_to_new_loc[var->data.location];
+         } else {
+            var->data.location = FRAG_RESULT_DATA0 + num_rts;
+         }
 
          unsigned array_len =
             glsl_type_is_array(var->type) ? glsl_get_length(var->type) : 1;
-- 
2.14.2



More information about the mesa-dev mailing list