Conor McCarthy : vkd3d: Remove alignment validation from GetResourceAllocationInfo().

Alexandre Julliard julliard at winehq.org
Wed Nov 27 16:32:21 CST 2019


Module: vkd3d
Branch: master
Commit: 7b88754ff25cebe898c5cfe4d5ce6f13a7dbbaaf
URL:    https://source.winehq.org/git/vkd3d.git/?a=commit;h=7b88754ff25cebe898c5cfe4d5ce6f13a7dbbaaf

Author: Conor McCarthy <cmccarthy at codeweavers.com>
Date:   Thu Nov 28 00:35:06 2019 +1000

vkd3d: Remove alignment validation from GetResourceAllocationInfo().

The right place for alignment validation is d3d12_resource_validate_desc().
The mod alignment test, which returns a size of ~0 on failure, is incorrect
on systems where Vulkan requires alignments of 0x20000 or more, and breaks
Hitman 2, which uses the returned value unchecked and allocates heaps of
0xffffffff bytes.

Signed-off-by: Conor McCarthy <cmccarthy at codeweavers.com>
Signed-off-by: Henri Verbeet <hverbeet at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>

---

 libs/vkd3d/device.c | 27 ++-------------------------
 1 file changed, 2 insertions(+), 25 deletions(-)

diff --git a/libs/vkd3d/device.c b/libs/vkd3d/device.c
index 31d793f..e3bb2aa 100644
--- a/libs/vkd3d/device.c
+++ b/libs/vkd3d/device.c
@@ -2899,10 +2899,8 @@ static D3D12_RESOURCE_ALLOCATION_INFO * STDMETHODCALLTYPE d3d12_device_GetResour
         UINT count, const D3D12_RESOURCE_DESC *resource_descs)
 {
     struct d3d12_device *device = impl_from_ID3D12Device(iface);
-    const struct vkd3d_format *format;
     const D3D12_RESOURCE_DESC *desc;
     uint64_t requested_alignment;
-    uint64_t estimated_size;
 
     TRACE("iface %p, info %p, visible_mask 0x%08x, count %u, resource_descs %p.\n",
             iface, info, visible_mask, count, resource_descs);
@@ -2926,9 +2924,6 @@ static D3D12_RESOURCE_ALLOCATION_INFO * STDMETHODCALLTYPE d3d12_device_GetResour
         goto invalid;
     }
 
-    requested_alignment = desc->Alignment
-            ? desc->Alignment : D3D12_DEFAULT_RESOURCE_PLACEMENT_ALIGNMENT;
-
     if (desc->Dimension == D3D12_RESOURCE_DIMENSION_BUFFER)
     {
         info->SizeInBytes = desc->Width;
@@ -2942,27 +2937,9 @@ static D3D12_RESOURCE_ALLOCATION_INFO * STDMETHODCALLTYPE d3d12_device_GetResour
             goto invalid;
         }
 
+        requested_alignment = desc->Alignment
+                ? desc->Alignment : D3D12_DEFAULT_RESOURCE_PLACEMENT_ALIGNMENT;
         info->Alignment = max(info->Alignment, requested_alignment);
-
-        if (info->Alignment < D3D12_DEFAULT_RESOURCE_PLACEMENT_ALIGNMENT)
-        {
-            if (!(format = vkd3d_format_from_d3d12_resource_desc(device, desc, 0)))
-            {
-                WARN("Invalid format %#x.\n", desc->Format);
-                goto invalid;
-            }
-
-            estimated_size = desc->Width * desc->Height * desc->DepthOrArraySize * format->byte_count;
-            if (estimated_size > D3D12_DEFAULT_RESOURCE_PLACEMENT_ALIGNMENT)
-                info->Alignment = max(info->Alignment, D3D12_DEFAULT_RESOURCE_PLACEMENT_ALIGNMENT);
-        }
-    }
-
-    if (desc->Alignment % info->Alignment)
-    {
-        WARN("Invalid resource alignment %#"PRIx64" (required %#"PRIx64").\n",
-                desc->Alignment, info->Alignment);
-        goto invalid;
     }
 
     info->SizeInBytes = align(info->SizeInBytes, info->Alignment);




More information about the wine-cvs mailing list