[PATCH vkd3d v2 4/9] vkd3d: Validate unbounded descriptor ranges.

Conor McCarthy cmccarthy at codeweavers.com
Mon Aug 23 10:23:23 CDT 2021


Signed-off-by: Conor McCarthy <cmccarthy at codeweavers.com>
---
 libs/vkd3d/state.c | 27 +++++++++++++++++++++++++++
 1 file changed, 27 insertions(+)

diff --git a/libs/vkd3d/state.c b/libs/vkd3d/state.c
index 4cb2c387..cccd2ac0 100644
--- a/libs/vkd3d/state.c
+++ b/libs/vkd3d/state.c
@@ -334,6 +334,7 @@ struct d3d12_root_signature_info
 static HRESULT d3d12_root_signature_info_count_descriptors(struct d3d12_root_signature_info *info,
         const D3D12_ROOT_DESCRIPTOR_TABLE *table, bool use_array)
 {
+    bool unbounded = false;
     unsigned int i;
 
     for (i = 0; i < table->NumDescriptorRanges; ++i)
@@ -341,8 +342,33 @@ static HRESULT d3d12_root_signature_info_count_descriptors(struct d3d12_root_sig
         const D3D12_DESCRIPTOR_RANGE *range = &table->pDescriptorRanges[i];
         unsigned int binding_count;
 
+        if (unbounded)
+        {
+            if (range->NumDescriptors != UINT_MAX)
+            {
+                ERR("A bounded range occurs after an unbounded range.\n");
+                return E_INVALIDARG;
+            }
+            if (range->OffsetInDescriptorsFromTableStart == D3D12_DESCRIPTOR_RANGE_OFFSET_APPEND)
+            {
+                ERR("An unbounded range with offset D3D12_DESCRIPTOR_RANGE_OFFSET_APPEND occurs after "
+                        "another unbounded range.\n");
+                return E_INVALIDARG;
+            }
+        }
+
         binding_count = use_array ? 1 : range->NumDescriptors;
 
+        if (range->NumDescriptors == UINT_MAX)
+        {
+            if (!use_array)
+            {
+                FIXME("The device does not support unbounded descriptor ranges.\n");
+                return E_NOTIMPL;
+            }
+            unbounded = true;
+        }
+
         switch (range->RangeType)
         {
             case D3D12_DESCRIPTOR_RANGE_TYPE_SRV:
@@ -780,6 +806,7 @@ static HRESULT d3d12_root_signature_init_root_descriptor_tables(struct d3d12_roo
             TRACE("Descriptor table %u, range %u, offset %u, type %#x, count %u.\n", i, j,
                     offset, range->RangeType, range->NumDescriptors);
 
+            /* If NumDescriptors == UINT_MAX, validation during counting ensures this offset is not used. */
             offset += range->NumDescriptors;
         }
 
-- 
2.32.0




More information about the wine-devel mailing list