[PATCH vkd3d 06/12] vkd3d: Allocate device memory when heap offset is misaligned.

Józef Kucia joseph.kucia at gmail.com
Tue Jun 11 03:13:32 CDT 2019


From: Józef Kucia <jkucia at codeweavers.com>

On radv with AMD Polaris GPUs, the alignment may be as high as 0x20000
or 0x40000. World of Warcraft seems to ignore the alignment returned
from GetResourceAllocationInfo(), and simply aligns to 0x10000
(D3D12_DEFAULT_RESOURCE_PLACEMENT_ALIGNMENT).

Signed-off-by: Józef Kucia <jkucia at codeweavers.com>
---
 libs/vkd3d/resource.c | 16 ++++++++++------
 1 file changed, 10 insertions(+), 6 deletions(-)

diff --git a/libs/vkd3d/resource.c b/libs/vkd3d/resource.c
index 15dac12abeb6..6bbd5afa2eea 100644
--- a/libs/vkd3d/resource.c
+++ b/libs/vkd3d/resource.c
@@ -1492,7 +1492,7 @@ HRESULT d3d12_committed_resource_create(struct d3d12_device *device,
 }
 
 static HRESULT vkd3d_bind_heap_memory(struct d3d12_device *device,
-        struct d3d12_resource *resource, struct d3d12_heap *heap, UINT64 heap_offset)
+        struct d3d12_resource *resource, struct d3d12_heap *heap, uint64_t heap_offset)
 {
     const struct vkd3d_vk_device_procs *vk_procs = &device->vk_procs;
     VkDevice vk_device = device->vk_device;
@@ -1506,16 +1506,16 @@ static HRESULT vkd3d_bind_heap_memory(struct d3d12_device *device,
 
     if (heap_offset % requirements.alignment)
     {
-        FIXME("Invalid heap offset %#"PRIx64".\n", heap_offset);
-        return E_INVALIDARG;
+        FIXME("Invalid heap offset %#"PRIx64" (alignment %#"PRIx64").\n",
+                heap_offset, requirements.alignment);
+        goto allocate_memory;
     }
 
     if (!(requirements.memoryTypeBits & (1u << heap->vk_memory_type)))
     {
-        FIXME("Memory type %u cannot be bound to resource %p (allowed types %#x), "
-                "allocating device memory.\n",
+        FIXME("Memory type %u cannot be bound to resource %p (allowed types %#x).\n",
                 heap->vk_memory_type, resource, requirements.memoryTypeBits);
-        return vkd3d_allocate_resource_memory(device, resource, &heap->desc.Properties, heap->desc.Flags);
+        goto allocate_memory;
     }
 
     if (d3d12_resource_is_buffer(resource))
@@ -1534,6 +1534,10 @@ static HRESULT vkd3d_bind_heap_memory(struct d3d12_device *device,
     }
 
     return hresult_from_vk_result(vr);
+
+allocate_memory:
+    FIXME("Allocating device memory.\n");
+    return vkd3d_allocate_resource_memory(device, resource, &heap->desc.Properties, heap->desc.Flags);
 }
 
 HRESULT d3d12_placed_resource_create(struct d3d12_device *device, struct d3d12_heap *heap, UINT64 heap_offset,
-- 
2.21.0




More information about the wine-devel mailing list