dzn: Use ResolveSubresourceRegion to support non-averaging resolve modes
authorJesse Natalie <jenatali@microsoft.com>
Fri, 4 Nov 2022 22:27:24 +0000 (15:27 -0700)
committerMarge Bot <emma+marge@anholt.net>
Fri, 16 Dec 2022 18:40:47 +0000 (18:40 +0000)
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/20346>

src/microsoft/vulkan/dzn_cmd_buffer.c

index b3c157462c78a416a47449fd3d22fcac2ac8be6d..0aaf64569c417deb5a1f9a19abb119029f1cd2d7 100644 (file)
@@ -3368,6 +3368,19 @@ dzn_CmdClearAttachments(VkCommandBuffer commandBuffer,
    }
 }
 
+static D3D12_RESOLVE_MODE
+dzn_get_resolve_mode(VkResolveModeFlags mode)
+{
+   switch (mode) {
+   case VK_RESOLVE_MODE_AVERAGE_BIT: return D3D12_RESOLVE_MODE_AVERAGE;
+   case VK_RESOLVE_MODE_MAX_BIT: return D3D12_RESOLVE_MODE_MAX;
+   case VK_RESOLVE_MODE_MIN_BIT: return D3D12_RESOLVE_MODE_MIN;
+   /* TODO */
+   case VK_RESOLVE_MODE_SAMPLE_ZERO_BIT: return D3D12_RESOLVE_MODE_MIN;
+   default: return D3D12_RESOLVE_MODE_AVERAGE;
+   }
+}
+
 static void
 dzn_cmd_buffer_resolve_rendering_attachment(struct dzn_cmd_buffer *cmdbuf,
                                             const struct dzn_rendering_attachment *att,
@@ -3379,6 +3392,10 @@ dzn_cmd_buffer_resolve_rendering_attachment(struct dzn_cmd_buffer *cmdbuf,
    if (!src || !dst)
       return;
 
+   struct dzn_device *device = container_of(cmdbuf->vk.base.device, struct dzn_device, vk);
+   struct dzn_physical_device *pdev =
+      container_of(device->vk.physical, struct dzn_physical_device, vk);
+
    VkImageLayout src_layout = att->layout;
    VkImageLayout dst_layout = att->resolve.layout;
    struct dzn_image *src_img = container_of(src->vk.image, struct dzn_image, vk);
@@ -3418,10 +3435,21 @@ dzn_cmd_buffer_resolve_rendering_attachment(struct dzn_cmd_buffer *cmdbuf,
          uint32_t dst_subres =
             dzn_image_range_get_subresource_index(dst_img, &dst_range, aspect, level, layer);
 
-         ID3D12GraphicsCommandList1_ResolveSubresource(cmdbuf->cmdlist,
-                                                       dst_img->res, dst_subres,
-                                                       src_img->res, src_subres,
-                                                       dst->srv_desc.Format);
+         if (cmdbuf->cmdlist8 &&
+             pdev->options2.ProgrammableSamplePositionsTier > D3D12_PROGRAMMABLE_SAMPLE_POSITIONS_TIER_NOT_SUPPORTED) {
+            ID3D12GraphicsCommandList8_ResolveSubresourceRegion(cmdbuf->cmdlist8,
+                                                                dst_img->res, dst_subres,
+                                                                0, 0,
+                                                                src_img->res, src_subres,
+                                                                NULL,
+                                                                dst->srv_desc.Format,
+                                                                dzn_get_resolve_mode(att->resolve.mode));
+         } else {
+            ID3D12GraphicsCommandList1_ResolveSubresource(cmdbuf->cmdlist,
+                                                          dst_img->res, dst_subres,
+                                                          src_img->res, src_subres,
+                                                          dst->srv_desc.Format);
+         }
       }
    }