turnip: enable VK_FORMAT_S8_UINT as stencil format
authorJonathan Marek <jonathan@marek.ca>
Thu, 9 Apr 2020 23:17:54 +0000 (19:17 -0400)
committerMarge Bot <eric+marge@anholt.net>
Wed, 22 Apr 2020 17:45:33 +0000 (17:45 +0000)
Signed-off-by: Jonathan Marek <jonathan@marek.ca>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/4588>

src/freedreno/vulkan/tu_clear_blit.c
src/freedreno/vulkan/tu_cmd_buffer.c
src/freedreno/vulkan/tu_formats.c
src/freedreno/vulkan/tu_image.c

index 621449285d65af0350a73b2b8e501ddbbefd22cb..550c66174631f97b12bf8a8a17534b2cf1c08c20 100644 (file)
@@ -1777,8 +1777,6 @@ tu_clear_sysmem_attachments_2d(struct tu_cmd_buffer *cmd,
 
    for (uint32_t j = 0; j < attachment_count; j++) {
          uint32_t a;
-         uint8_t mask = 0xf;
-
          if (attachments[j].aspectMask & VK_IMAGE_ASPECT_COLOR_BIT) {
             a = subpass->color_attachments[attachments[j].colorAttachment].attachment;
          } else {
@@ -1789,17 +1787,19 @@ tu_clear_sysmem_attachments_2d(struct tu_cmd_buffer *cmd,
             /* also flush color to avoid losing contents from invalidate */
             tu6_emit_event_write(cmd, cs, PC_CCU_FLUSH_COLOR_TS, true);
             tu6_emit_event_write(cmd, cs, PC_CCU_INVALIDATE_COLOR, false);
+         }
 
+         if (a == VK_ATTACHMENT_UNUSED)
+               continue;
 
+         uint8_t mask = 0xf;
+         if (cmd->state.pass->attachments[a].format == VK_FORMAT_D24_UNORM_S8_UINT) {
             if (!(attachments[j].aspectMask & VK_IMAGE_ASPECT_DEPTH_BIT))
                mask &= ~0x7;
             if (!(attachments[j].aspectMask & VK_IMAGE_ASPECT_STENCIL_BIT))
                mask &= ~0x8;
          }
 
-         if (a == VK_ATTACHMENT_UNUSED)
-               continue;
-
          const struct tu_image_view *iview =
             cmd->state.framebuffer->attachments[a].attachment;
 
@@ -2071,21 +2071,22 @@ tu_clear_gmem_attachments(struct tu_cmd_buffer *cmd,
 
       for (unsigned j = 0; j < attachment_count; j++) {
          uint32_t a;
-         unsigned clear_mask = 0;
-         if (attachments[j].aspectMask & VK_IMAGE_ASPECT_COLOR_BIT) {
-            clear_mask = 0xf;
+         if (attachments[j].aspectMask & VK_IMAGE_ASPECT_COLOR_BIT)
             a = subpass->color_attachments[attachments[j].colorAttachment].attachment;
-         } else {
+         else
             a = subpass->depth_stencil_attachment.attachment;
-            if (attachments[j].aspectMask & VK_IMAGE_ASPECT_DEPTH_BIT)
-               clear_mask |= 0x7;
-            if (attachments[j].aspectMask & VK_IMAGE_ASPECT_STENCIL_BIT)
-               clear_mask |= 0x8;
-         }
 
          if (a == VK_ATTACHMENT_UNUSED)
                continue;
 
+         unsigned clear_mask = 0xf;
+         if (cmd->state.pass->attachments[a].format == VK_FORMAT_D24_UNORM_S8_UINT) {
+            if (!(attachments[j].aspectMask & VK_IMAGE_ASPECT_DEPTH_BIT))
+               clear_mask &= ~0x7;
+            if (!(attachments[j].aspectMask & VK_IMAGE_ASPECT_STENCIL_BIT))
+               clear_mask &= ~0x8;
+         }
+
          tu_emit_clear_gmem_attachment(cmd, cs, a, clear_mask,
                                        &attachments[j].clearValue);
       }
index b6ca849c80c3fe8fc985fc70f3029836094abee5..6cf74b3f0c41144972fe8cc08c9fe339f26def62 100644 (file)
@@ -387,12 +387,14 @@ tu6_emit_zs(struct tu_cmd_buffer *cmd,
    }
 
    const struct tu_image_view *iview = fb->attachments[a].attachment;
-   enum a6xx_depth_format fmt = tu6_pipe2depth(cmd->state.pass->attachments[a].format);
+   const struct tu_render_pass_attachment *attachment =
+      &cmd->state.pass->attachments[a];
+   enum a6xx_depth_format fmt = tu6_pipe2depth(attachment->format);
 
    tu_cs_emit_pkt4(cs, REG_A6XX_RB_DEPTH_BUFFER_INFO, 6);
    tu_cs_emit(cs, A6XX_RB_DEPTH_BUFFER_INFO(.depth_format = fmt).value);
    tu_cs_image_ref(cs, iview, 0);
-   tu_cs_emit(cs, cmd->state.pass->attachments[a].gmem_offset);
+   tu_cs_emit(cs, attachment->gmem_offset);
 
    tu_cs_emit_regs(cs,
                    A6XX_GRAS_SU_DEPTH_BUFFER_INFO(.depth_format = fmt));
@@ -405,10 +407,15 @@ tu6_emit_zs(struct tu_cmd_buffer *cmd,
                    A6XX_GRAS_LRZ_BUFFER_PITCH(0),
                    A6XX_GRAS_LRZ_FAST_CLEAR_BUFFER_BASE(0));
 
-   tu_cs_emit_regs(cs,
-                   A6XX_RB_STENCIL_INFO(0));
-
-   /* enable zs? */
+   if (attachment->format == VK_FORMAT_S8_UINT) {
+      tu_cs_emit_pkt4(cs, REG_A6XX_RB_STENCIL_INFO, 6);
+      tu_cs_emit(cs, A6XX_RB_STENCIL_INFO(.separate_stencil = true).value);
+      tu_cs_image_ref(cs, iview, 0);
+      tu_cs_emit(cs, attachment->gmem_offset);
+   } else {
+      tu_cs_emit_regs(cs,
+                     A6XX_RB_STENCIL_INFO(0));
+   }
 }
 
 static void
index 528a4176f4a812e25e6b70565a0fb8e2431b356a..d4100760032cacadb85fe2b3bc5c8181458d6254 100644 (file)
@@ -354,6 +354,7 @@ tu6_pipe2depth(VkFormat format)
    case VK_FORMAT_D24_UNORM_S8_UINT:
       return DEPTH6_24_8;
    case VK_FORMAT_D32_SFLOAT:
+   case VK_FORMAT_S8_UINT:
       return DEPTH6_32;
    default:
       return ~0;
index f53566774a31dbcc56adc25210a45c2c3d3adff6..d6abef7406368dc5a0d2748fe842c1160148bd10 100644 (file)
@@ -100,6 +100,10 @@ tu_image_create(VkDevice _device,
    if (image->vk_format == VK_FORMAT_E5B9G9R9_UFLOAT_PACK32)
       ubwc_enabled = false;
 
+   /* separate stencil doesn't have a UBWC enable bit */
+   if (image->vk_format == VK_FORMAT_S8_UINT)
+      ubwc_enabled = false;
+
    if (image->extent.depth > 1) {
       tu_finishme("UBWC with 3D textures");
       ubwc_enabled = false;