[PATCH vkd3d 04/10] vkd3d: Reject 0 sample count textures in d3d12_resource_validate_desc().

Henri Verbeet hverbeet at codeweavers.com
Thu Oct 14 18:37:40 CDT 2021


From: Conor McCarthy <cmccarthy at codeweavers.com>

Buffers with 0 sample counts were already rejected here.

Signed-off-by: Conor McCarthy <cmccarthy at codeweavers.com>
Signed-off-by: Henri Verbeet <hverbeet at codeweavers.com>
---
v2: Minor style changes.
This supersedes patch 214667.

 libs/vkd3d/resource.c | 6 ++++++
 tests/d3d12.c         | 4 +---
 2 files changed, 7 insertions(+), 3 deletions(-)

diff --git a/libs/vkd3d/resource.c b/libs/vkd3d/resource.c
index d6e5d4be..705e720f 100644
--- a/libs/vkd3d/resource.c
+++ b/libs/vkd3d/resource.c
@@ -1681,6 +1681,12 @@ HRESULT d3d12_resource_validate_desc(const D3D12_RESOURCE_DESC *desc, struct d3d
             /* Fall through. */
         case D3D12_RESOURCE_DIMENSION_TEXTURE2D:
         case D3D12_RESOURCE_DIMENSION_TEXTURE3D:
+            if (!desc->SampleDesc.Count)
+            {
+                WARN("Invalid sample count 0.\n");
+                return E_INVALIDARG;
+            }
+
             if (!(format = vkd3d_format_from_d3d12_resource_desc(device, desc, 0)))
             {
                 WARN("Invalid format %#x.\n", desc->Format);
diff --git a/tests/d3d12.c b/tests/d3d12.c
index 4a7309d6..08334765 100644
--- a/tests/d3d12.c
+++ b/tests/d3d12.c
@@ -1703,9 +1703,7 @@ static void test_create_committed_resource(void)
     resource_desc.SampleDesc.Count = 0;
     hr = ID3D12Device_CreateCommittedResource(device, &heap_properties, D3D12_HEAP_FLAG_NONE, &resource_desc,
             D3D12_RESOURCE_STATE_RENDER_TARGET, &clear_value, &IID_ID3D12Resource, (void **)&resource);
-    todo ok(hr == E_INVALIDARG, "Got unexpected hr %#x.\n", hr);
-    if (SUCCEEDED(hr))
-        ID3D12Resource_Release(resource);
+    ok(hr == E_INVALIDARG, "Got unexpected hr %#x.\n", hr);
     resource_desc.SampleDesc.Count = 1;
 
     hr = ID3D12Device_CreateCommittedResource(device, &heap_properties, D3D12_HEAP_FLAG_NONE,
-- 
2.20.1




More information about the wine-devel mailing list