zink: simplify fbfetch output detection from fs
authorMike Blumenkrantz <michael.blumenkrantz@gmail.com>
Tue, 28 Mar 2023 22:43:18 +0000 (18:43 -0400)
committerMarge Bot <emma+marge@anholt.net>
Tue, 4 Apr 2023 01:37:41 +0000 (01:37 +0000)
this should be identical to the previous code, except it also
handles depth/stencil (not yet supported)

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/22266>

src/gallium/drivers/zink/zink_program.c

index 6853c8a..91797e2 100644 (file)
@@ -1768,10 +1768,9 @@ zink_bind_fs_state(struct pipe_context *pctx,
    if (cso) {
       shader_info *info = &ctx->gfx_stages[MESA_SHADER_FRAGMENT]->info;
       if (info->fs.uses_fbfetch_output) {
-         nir_foreach_shader_out_variable(var, ctx->gfx_stages[MESA_SHADER_FRAGMENT]->nir) {
-            if (var->data.fb_fetch_output)
-               ctx->fbfetch_outputs |= BITFIELD_BIT(var->data.location - FRAG_RESULT_DATA0);
-         }
+         if (info->outputs_read & (BITFIELD_BIT(FRAG_RESULT_DEPTH) | BITFIELD_BIT(FRAG_RESULT_STENCIL)))
+            ctx->fbfetch_outputs |= BITFIELD_BIT(PIPE_MAX_COLOR_BUFS);
+         ctx->fbfetch_outputs |= info->outputs_read >> FRAG_RESULT_DATA0;
       }
       zink_update_fs_key_samples(ctx);
       if (zink_screen(pctx->screen)->info.have_EXT_rasterization_order_attachment_access) {