[PATCH vkd3d 1/9] vkd3d: Add support for fake placed resources.

Józef Kucia joseph.kucia at gmail.com
Tue Sep 25 07:12:59 CDT 2018


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

Placed resources are not allocated from a given heap yet.

Signed-off-by: Józef Kucia <jkucia at codeweavers.com>
---
 libs/vkd3d/device.c        | 22 ++++++++++++++++------
 libs/vkd3d/resource.c      | 20 ++++++++++++++++++++
 libs/vkd3d/vkd3d_private.h |  4 ++++
 3 files changed, 40 insertions(+), 6 deletions(-)

diff --git a/libs/vkd3d/device.c b/libs/vkd3d/device.c
index b57e3ceb99e5..a3a00b92c241 100644
--- a/libs/vkd3d/device.c
+++ b/libs/vkd3d/device.c
@@ -2091,15 +2091,25 @@ static HRESULT STDMETHODCALLTYPE d3d12_device_CreateHeap(ID3D12Device *iface,
 static HRESULT STDMETHODCALLTYPE d3d12_device_CreatePlacedResource(ID3D12Device *iface,
         ID3D12Heap *heap, UINT64 heap_offset,
         const D3D12_RESOURCE_DESC *desc, D3D12_RESOURCE_STATES initial_state,
-        const D3D12_CLEAR_VALUE *optimized_clear_value,
-        REFIID riid, void **resource)
+        const D3D12_CLEAR_VALUE *optimized_clear_value, REFIID iid, void **resource)
 {
-    FIXME("iface %p, heap %p, heap_offset %#"PRIx64", desc %p, initial_state %#x, "
-            "optimized_clear_value %p, riid %s, resource %p stub!\n",
+    struct d3d12_device *device = impl_from_ID3D12Device(iface);
+    struct d3d12_heap *heap_object;
+    struct d3d12_resource *object;
+    HRESULT hr;
+
+    TRACE("iface %p, heap %p, heap_offset %#"PRIx64", desc %p, initial_state %#x, "
+            "optimized_clear_value %p, iid %s, resource %p.\n",
             iface, heap, heap_offset, desc, initial_state,
-            optimized_clear_value, debugstr_guid(riid), resource);
+            optimized_clear_value, debugstr_guid(iid), resource);
 
-    return E_NOTIMPL;
+    heap_object = unsafe_impl_from_ID3D12Heap(heap);
+
+    if (FAILED(hr = d3d12_placed_resource_create(device, heap_object, heap_offset,
+            desc, initial_state, optimized_clear_value, &object)))
+        return hr;
+
+    return return_interface(&object->ID3D12Resource_iface, &IID_ID3D12Resource, iid, resource);
 }
 
 static HRESULT STDMETHODCALLTYPE d3d12_device_CreateReservedResource(ID3D12Device *iface,
diff --git a/libs/vkd3d/resource.c b/libs/vkd3d/resource.c
index 10f1d835e792..15804500681b 100644
--- a/libs/vkd3d/resource.c
+++ b/libs/vkd3d/resource.c
@@ -146,6 +146,14 @@ static const struct ID3D12HeapVtbl d3d12_heap_vtbl =
     d3d12_heap_GetDesc,
 };
 
+struct d3d12_heap *unsafe_impl_from_ID3D12Heap(ID3D12Heap *iface)
+{
+    if (!iface)
+        return NULL;
+    assert(iface->lpVtbl == &d3d12_heap_vtbl);
+    return impl_from_ID3D12Heap(iface);
+}
+
 static HRESULT validate_heap_desc(const D3D12_HEAP_DESC *desc)
 {
     if (!desc->SizeInBytes)
@@ -1049,6 +1057,18 @@ HRESULT d3d12_committed_resource_create(struct d3d12_device *device,
     return S_OK;
 }
 
+HRESULT d3d12_placed_resource_create(struct d3d12_device *device, struct d3d12_heap *heap, UINT64 heap_offset,
+        const D3D12_RESOURCE_DESC *desc, D3D12_RESOURCE_STATES initial_state,
+        const D3D12_CLEAR_VALUE *optimized_clear_value, struct d3d12_resource **resource)
+{
+    const D3D12_HEAP_DESC *heap_desc = &heap->desc;
+
+    FIXME("Ignoring heap %p, offset %"PRIu64".\n", heap, heap_offset);
+
+    return d3d12_committed_resource_create(device, &heap_desc->Properties, heap_desc->Flags,
+            desc, initial_state, optimized_clear_value, resource);
+}
+
 HRESULT vkd3d_create_image_resource(ID3D12Device *device,
         const struct vkd3d_image_resource_create_info *create_info, ID3D12Resource **resource)
 {
diff --git a/libs/vkd3d/vkd3d_private.h b/libs/vkd3d/vkd3d_private.h
index 5aaa56505db0..c4d6dd531728 100644
--- a/libs/vkd3d/vkd3d_private.h
+++ b/libs/vkd3d/vkd3d_private.h
@@ -195,6 +195,7 @@ struct d3d12_heap
 
 HRESULT d3d12_heap_create(struct d3d12_device *device,
         const D3D12_HEAP_DESC *desc, struct d3d12_heap **heap) DECLSPEC_HIDDEN;
+struct d3d12_heap *unsafe_impl_from_ID3D12Heap(ID3D12Heap *iface) DECLSPEC_HIDDEN;
 
 #define VKD3D_RESOURCE_PUBLIC_FLAGS \
         (VKD3D_RESOURCE_INITIAL_STATE_TRANSITION | VKD3D_RESOURCE_PRESENT_STATE_TRANSITION)
@@ -245,6 +246,9 @@ HRESULT d3d12_committed_resource_create(struct d3d12_device *device,
         const D3D12_HEAP_PROPERTIES *heap_properties, D3D12_HEAP_FLAGS heap_flags,
         const D3D12_RESOURCE_DESC *desc, D3D12_RESOURCE_STATES initial_state,
         const D3D12_CLEAR_VALUE *optimized_clear_value, struct d3d12_resource **resource) DECLSPEC_HIDDEN;
+HRESULT d3d12_placed_resource_create(struct d3d12_device *device, struct d3d12_heap *heap, UINT64 heap_offset,
+        const D3D12_RESOURCE_DESC *desc, D3D12_RESOURCE_STATES initial_state,
+        const D3D12_CLEAR_VALUE *optimized_clear_value, struct d3d12_resource **resource) DECLSPEC_HIDDEN;
 struct d3d12_resource *unsafe_impl_from_ID3D12Resource(ID3D12Resource *iface) DECLSPEC_HIDDEN;
 
 struct vkd3d_view
-- 
2.16.4




More information about the wine-devel mailing list