nvk: Set the discard bit for Z/S self-deps
authorFaith Ekstrand <faith.ekstrand@collabora.com>
Fri, 8 Sep 2023 23:05:01 +0000 (18:05 -0500)
committerMarge Bot <emma+marge@anholt.net>
Sat, 9 Sep 2023 05:17:05 +0000 (05:17 +0000)
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/25135>

src/nouveau/vulkan/nvk_graphics_pipeline.c
src/nouveau/vulkan/nvk_shader.c
src/nouveau/vulkan/nvk_shader.h

index e7320fb..a0ab6a8 100644 (file)
@@ -54,9 +54,15 @@ emit_pipeline_rs_state(struct nv_push *p,
 
 static void
 nvk_populate_fs_key(struct nvk_fs_key *key,
-                    const struct vk_multisample_state *ms)
+                    const struct vk_multisample_state *ms,
+                    const struct vk_render_pass_state *rp)
 {
    memset(key, 0, sizeof(*key));
+
+   if (rp->pipeline_flags &
+       VK_PIPELINE_CREATE_DEPTH_STENCIL_ATTACHMENT_FEEDBACK_LOOP_BIT_EXT)
+      key->zs_self_dep = true;
+
    if (ms == NULL || ms->rasterization_samples <= 1)
       return;
 
@@ -344,7 +350,7 @@ nvk_graphics_pipeline_create(struct nvk_device *dev,
 
       struct nvk_fs_key fs_key_tmp, *fs_key = NULL;
       if (stage == MESA_SHADER_FRAGMENT) {
-         nvk_populate_fs_key(&fs_key_tmp, state.ms);
+         nvk_populate_fs_key(&fs_key_tmp, state.ms, state.rp);
          fs_key = &fs_key_tmp;
       }
 
index 0a66cf2..cbe6571 100644 (file)
@@ -946,7 +946,8 @@ nvk_hdr_interp_mode(const struct nv50_ir_varying *var)
 
 
 static int
-nvk_fs_gen_header(struct nvk_shader *fs, struct nv50_ir_prog_info_out *info)
+nvk_fs_gen_header(struct nvk_shader *fs, const struct nvk_fs_key *key,
+                  struct nv50_ir_prog_info_out *info)
 {
    unsigned i, c, a, m;
 
@@ -954,7 +955,7 @@ nvk_fs_gen_header(struct nvk_shader *fs, struct nv50_ir_prog_info_out *info)
    fs->hdr[0] = 0x20062 | (5 << 10);
    fs->hdr[5] = 0x80000000; /* getting a trap if FRAG_COORD_UMASK.w = 0 */
 
-   if (info->prop.fp.usesDiscard)
+   if (info->prop.fp.usesDiscard || key->zs_self_dep)
       fs->hdr[0] |= 0x8000;
    if (!info->prop.fp.separateFragData)
       fs->hdr[0] |= 0x4000;
@@ -1144,7 +1145,7 @@ nvk_compile_nir(struct nvk_physical_device *pdev, nir_shader *nir,
       ret = nvk_vs_gen_header(shader, &info_out);
       break;
    case PIPE_SHADER_FRAGMENT:
-      ret = nvk_fs_gen_header(shader, &info_out);
+      ret = nvk_fs_gen_header(shader, fs_key, &info_out);
       shader->fs.uses_sample_shading = nir->info.fs.uses_sample_shading;
       break;
    case PIPE_SHADER_GEOMETRY:
index dbf9d32..11c9ed7 100644 (file)
@@ -25,6 +25,7 @@ struct vk_shader_module;
 struct nvk_fs_key {
    bool msaa;
    bool force_per_sample;
+   bool zs_self_dep;
 };
 
 struct nvk_transform_feedback_state {