From b0d0c2d7658f6563cd0e687449fedbc0ba76c603 Mon Sep 17 00:00:00 2001 From: Faith Ekstrand Date: Tue, 10 Oct 2023 21:34:59 -0500 Subject: [PATCH] nvk: Always emit at least one color attachment Without this, alpha to coverage doesn't work because the hardware ignores the output of the first color from the shader. Part-of: --- src/nouveau/vulkan/nvk_cmd_draw.c | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/src/nouveau/vulkan/nvk_cmd_draw.c b/src/nouveau/vulkan/nvk_cmd_draw.c index a54e42f7d0f..6adc81589b3 100644 --- a/src/nouveau/vulkan/nvk_cmd_draw.c +++ b/src/nouveau/vulkan/nvk_cmd_draw.c @@ -575,13 +575,9 @@ nvk_CmdBeginRendering(VkCommandBuffer commandBuffer, BITSET_SET(dyn->dirty, MESA_VK_DYNAMIC_DS_DEPTH_BOUNDS_TEST_ENABLE); BITSET_SET(dyn->dirty, MESA_VK_DYNAMIC_DS_STENCIL_TEST_ENABLE); - /* If we don't have any attachments, emit a dummy color attachment */ - if (render->color_att_count == 0 && - render->depth_att.iview == NULL && - render->stencil_att.iview == NULL) - render->color_att_count = 1; - - struct nv_push *p = nvk_cmd_buffer_push(cmd, render->color_att_count * 10 + 27); + /* Always emit at least one color attachment, even if it's just a dummy. */ + uint32_t color_att_count = MAX2(1, render->color_att_count); + struct nv_push *p = nvk_cmd_buffer_push(cmd, color_att_count * 10 + 27); P_IMMD(p, NV9097, SET_MME_SHADOW_SCRATCH(NVK_MME_SCRATCH_VIEW_MASK), render->view_mask); @@ -597,7 +593,7 @@ nvk_CmdBeginRendering(VkCommandBuffer commandBuffer, }); enum nil_sample_layout sample_layout = NIL_SAMPLE_LAYOUT_INVALID; - for (uint32_t i = 0; i < render->color_att_count; i++) { + for (uint32_t i = 0; i < color_att_count; i++) { if (render->color_att[i].iview) { const struct nvk_image_view *iview = render->color_att[i].iview; const struct nvk_image *image = (struct nvk_image *)iview->vk.image; @@ -661,7 +657,7 @@ nvk_CmdBeginRendering(VkCommandBuffer commandBuffer, } P_IMMD(p, NV9097, SET_CT_SELECT, { - .target_count = render->color_att_count, + .target_count = color_att_count, .target0 = 0, .target1 = 1, .target2 = 2,