anv: track what kind of pipeline a fragment shader may be used with
authorIván Briano <ivan.briano@intel.com>
Tue, 5 Sep 2023 04:40:46 +0000 (21:40 -0700)
committerMarge Bot <emma+marge@anholt.net>
Tue, 12 Sep 2023 02:51:31 +0000 (02:51 +0000)
Reviewed-by: Caio Oliveira <caio.oliveira@intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/25047>

src/intel/compiler/brw_compiler.h
src/intel/vulkan/anv_pipeline.c

index c39c8f5..85f8644 100644 (file)
@@ -557,11 +557,14 @@ struct brw_wm_prog_key {
 
    enum brw_sometimes line_aa:2;
 
+   /* Whether the preceding shader stage is mesh */
+   enum brw_sometimes mesh_input:2;
+
    bool coherent_fb_fetch:1;
    bool ignore_sample_mask_out:1;
    bool coarse_pixel:1;
 
-   uint64_t padding:55;
+   uint64_t padding:53;
 };
 
 struct brw_cs_prog_key {
index 5e9ea5e..831a1ab 100644 (file)
@@ -585,7 +585,8 @@ populate_wm_prog_key(struct anv_pipeline_stage *stage,
                      const BITSET_WORD *dynamic,
                      const struct vk_multisample_state *ms,
                      const struct vk_fragment_shading_rate_state *fsr,
-                     const struct vk_render_pass_state *rp)
+                     const struct vk_render_pass_state *rp,
+                     const enum brw_sometimes is_mesh)
 {
    const struct anv_device *device = pipeline->base.device;
 
@@ -651,6 +652,8 @@ populate_wm_prog_key(struct anv_pipeline_stage *stage,
       key->persample_interp = BRW_SOMETIMES;
    }
 
+   key->mesh_input = is_mesh;
+
    /* Vulkan doesn't support fixed-function alpha test */
    key->alpha_test_replicate_alpha = false;
 
@@ -1728,11 +1731,22 @@ anv_graphics_pipeline_init_keys(struct anv_graphics_base_pipeline *pipeline,
             state->rs == NULL ||
             !state->rs->rasterizer_discard_enable ||
             BITSET_TEST(state->dynamic, MESA_VK_DYNAMIC_RS_RASTERIZER_DISCARD_ENABLE);
+         enum brw_sometimes is_mesh = BRW_NEVER;
+         if (device->vk.enabled_extensions.EXT_mesh_shader) {
+            if (anv_pipeline_base_has_stage(pipeline, MESA_SHADER_VERTEX))
+               is_mesh = BRW_NEVER;
+            else if (anv_pipeline_base_has_stage(pipeline, MESA_SHADER_MESH))
+               is_mesh = BRW_ALWAYS;
+            else {
+               assert(pipeline->base.type == ANV_PIPELINE_GRAPHICS_LIB);
+               is_mesh = BRW_SOMETIMES;
+            }
+         }
          populate_wm_prog_key(&stages[s],
                               pipeline,
                               state->dynamic,
                               raster_enabled ? state->ms : NULL,
-                              state->fsr, state->rp);
+                              state->fsr, state->rp, is_mesh);
          break;
       }