[PATCH vkd3d 07/13] vkd3d: Add helper to find bit-compatible UINT format for a DXGI format.

Philip Rebohle philip.rebohle at tu-dortmund.de
Mon Nov 11 10:03:42 CST 2019


Needed to imlpement ClearUnorderedAccessViewUint for non-UINT formats.

Signed-off-by: Philip Rebohle <philip.rebohle at tu-dortmund.de>
---
 libs/vkd3d/utils.c         | 33 +++++++++++++++++++++++++++++++++
 libs/vkd3d/vkd3d_private.h |  2 ++
 2 files changed, 35 insertions(+)

diff --git a/libs/vkd3d/utils.c b/libs/vkd3d/utils.c
index 1fc0e9d..fb608d2 100644
--- a/libs/vkd3d/utils.c
+++ b/libs/vkd3d/utils.c
@@ -451,6 +451,39 @@ const struct vkd3d_format *vkd3d_get_format(const struct d3d12_device *device,
     return NULL;
 }
 
+const struct vkd3d_format *vkd3d_find_uint_format(const struct d3d12_device *device,
+        DXGI_FORMAT dxgi_format)
+{
+    DXGI_FORMAT typeless_format = DXGI_FORMAT_UNKNOWN;
+    const struct vkd3d_format *vkd3d_format;
+    unsigned int i;
+
+    for (i = 0; i < ARRAY_SIZE(vkd3d_format_compatibility_info); i++)
+    {
+        if (vkd3d_format_compatibility_info[i].format == dxgi_format)
+        {
+            typeless_format = vkd3d_format_compatibility_info[i].typeless_format;
+            break;
+        }
+    }
+
+    if (!typeless_format)
+        return NULL;
+
+    for (i = 0; i < ARRAY_SIZE(vkd3d_format_compatibility_info); i++)
+    {
+        if (vkd3d_format_compatibility_info[i].typeless_format == typeless_format)
+        {
+            vkd3d_format = vkd3d_get_format(device, vkd3d_format_compatibility_info[i].format, false);
+
+            if (vkd3d_format->type == VKD3D_FORMAT_TYPE_UINT)
+                return vkd3d_format;
+        }
+    }
+
+    return NULL;
+}
+
 void vkd3d_format_copy_data(const struct vkd3d_format *format, const uint8_t *src,
         unsigned int src_row_pitch, unsigned int src_slice_pitch, uint8_t *dst, unsigned int dst_row_pitch,
         unsigned int dst_slice_pitch, unsigned int w, unsigned int h, unsigned int d)
diff --git a/libs/vkd3d/vkd3d_private.h b/libs/vkd3d/vkd3d_private.h
index d8b4f2f..6f3ac09 100644
--- a/libs/vkd3d/vkd3d_private.h
+++ b/libs/vkd3d/vkd3d_private.h
@@ -1254,6 +1254,8 @@ void vkd3d_format_copy_data(const struct vkd3d_format *format, const uint8_t *sr
 
 const struct vkd3d_format *vkd3d_get_format(const struct d3d12_device *device,
         DXGI_FORMAT dxgi_format, bool depth_stencil) DECLSPEC_HIDDEN;
+const struct vkd3d_format *vkd3d_find_uint_format(const struct d3d12_device *device,
+        DXGI_FORMAT dxgi_format) DECLSPEC_HIDDEN;
 
 HRESULT vkd3d_init_format_info(struct d3d12_device *device) DECLSPEC_HIDDEN;
 void vkd3d_cleanup_format_info(struct d3d12_device *device) DECLSPEC_HIDDEN;
-- 
2.24.0




More information about the wine-devel mailing list