radv: set the LayerId output usage mask if FS needs it
authorSamuel Pitoiset <samuel.pitoiset@gmail.com>
Wed, 10 Jul 2019 11:03:49 +0000 (13:03 +0200)
committerSamuel Pitoiset <samuel.pitoiset@gmail.com>
Wed, 10 Jul 2019 13:17:08 +0000 (15:17 +0200)
When the stage preceding FS doesn't export it the fragment shader
might read it, even if it's 0.

Signed-off-by: Samuel Pitoiset <samuel.pitoiset@gmail.com>
Reviewed-by: Bas Nieuwenhuizen <bas@basnieuwenhuizen.nl>
src/amd/vulkan/radv_shader_info.c

index 2756d99e7696cf70548b0b25a37d6563737e29db..946f7aa5f234468152dc3044fcbcfde29136dd70 100644 (file)
@@ -576,4 +576,21 @@ radv_nir_shader_info_pass(const struct nir_shader *nir,
            nir->info.stage == MESA_SHADER_TESS_EVAL ||
            nir->info.stage == MESA_SHADER_GEOMETRY)
                gather_xfb_info(nir, info);
+
+       /* Make sure to export the LayerID if the fragment shader needs it. */
+       if (options->key.vs_common_out.export_layer_id) {
+               switch (nir->info.stage) {
+               case MESA_SHADER_VERTEX:
+                       info->vs.output_usage_mask[VARYING_SLOT_LAYER] |= 0x1;
+                       break;
+               case MESA_SHADER_TESS_EVAL:
+                       info->tes.output_usage_mask[VARYING_SLOT_LAYER] |= 0x1;
+                       break;
+               case MESA_SHADER_GEOMETRY:
+                       info->gs.output_usage_mask[VARYING_SLOT_LAYER] |= 0x1;
+                       break;
+               default:
+                       break;
+               }
+       }
 }