vkd3d: Add partial implementation for CreateHeap1().

Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com>
This commit is contained in:
Nikolay Sivov 2023-10-07 19:50:59 +02:00 committed by Alexandre Julliard
parent 75c2af3640
commit 6ba75fd92f
Notes: Alexandre Julliard 2023-10-09 23:10:01 +02:00
Approved-by: Henri Verbeet (@hverbeet)
Approved-by: Alexandre Julliard (@julliard)
Merge-Request: https://gitlab.winehq.org/wine/vkd3d/-/merge_requests/397
4 changed files with 36 additions and 6 deletions

View File

@ -3645,7 +3645,7 @@ static HRESULT STDMETHODCALLTYPE d3d12_device_CreateHeap(ID3D12Device5 *iface,
TRACE("iface %p, desc %p, iid %s, heap %p.\n",
iface, desc, debugstr_guid(iid), heap);
if (FAILED(hr = d3d12_heap_create(device, desc, NULL, &object)))
if (FAILED(hr = d3d12_heap_create(device, desc, NULL, NULL, &object)))
{
*heap = NULL;
return hr;
@ -4024,10 +4024,20 @@ static HRESULT STDMETHODCALLTYPE d3d12_device_CreateHeap1(ID3D12Device5 *iface,
const D3D12_HEAP_DESC *desc, ID3D12ProtectedResourceSession *protected_session,
REFIID iid, void **heap)
{
FIXME("iface %p, desc %p, protected_session %p, iid %s, heap %p stub!\n",
struct d3d12_device *device = impl_from_ID3D12Device5(iface);
struct d3d12_heap *object;
HRESULT hr;
TRACE("iface %p, desc %p, protected_session %p, iid %s, heap %p.\n",
iface, desc, protected_session, debugstr_guid(iid), heap);
return E_NOTIMPL;
if (FAILED(hr = d3d12_heap_create(device, desc, NULL, protected_session, &object)))
{
*heap = NULL;
return hr;
}
return return_interface(&object->ID3D12Heap_iface, &IID_ID3D12Heap, iid, heap);
}
static HRESULT STDMETHODCALLTYPE d3d12_device_CreateReservedResource1(ID3D12Device5 *iface,

View File

@ -574,11 +574,15 @@ static HRESULT d3d12_heap_init(struct d3d12_heap *heap,
}
HRESULT d3d12_heap_create(struct d3d12_device *device, const D3D12_HEAP_DESC *desc,
const struct d3d12_resource *resource, struct d3d12_heap **heap)
const struct d3d12_resource *resource, ID3D12ProtectedResourceSession *protected_session,
struct d3d12_heap **heap)
{
struct d3d12_heap *object;
HRESULT hr;
if (protected_session)
FIXME("Protected session is not supported.\n");
if (!(object = vkd3d_malloc(sizeof(*object))))
return E_OUTOFMEMORY;
@ -2064,7 +2068,7 @@ static HRESULT vkd3d_allocate_resource_memory(
heap_desc.Properties = *heap_properties;
heap_desc.Alignment = 0;
heap_desc.Flags = heap_flags;
if (SUCCEEDED(hr = d3d12_heap_create(device, &heap_desc, resource, &resource->heap)))
if (SUCCEEDED(hr = d3d12_heap_create(device, &heap_desc, resource, NULL, &resource->heap)))
resource->flags |= VKD3D_RESOURCE_DEDICATED_HEAP;
return hr;
}

View File

@ -682,7 +682,7 @@ struct d3d12_heap
};
HRESULT d3d12_heap_create(struct d3d12_device *device, const D3D12_HEAP_DESC *desc,
const struct d3d12_resource *resource, struct d3d12_heap **heap);
const struct d3d12_resource *resource, ID3D12ProtectedResourceSession *protected_session, struct d3d12_heap **heap);
struct d3d12_heap *unsafe_impl_from_ID3D12Heap(ID3D12Heap *iface);
#define VKD3D_RESOURCE_PUBLIC_FLAGS \

View File

@ -1849,6 +1849,7 @@ static void test_create_heap(void)
ID3D12Device *device, *tmp_device;
bool is_pool_L1_supported;
HRESULT hr, expected_hr;
ID3D12Device4 *device4;
unsigned int i, j;
ID3D12Heap *heap;
ULONG refcount;
@ -2063,6 +2064,21 @@ static void test_create_heap(void)
vkd3d_test_pop_context();
}
if (SUCCEEDED(ID3D12Device_QueryInterface(device, &IID_ID3D12Device4, (void **)&device4)))
{
desc.SizeInBytes = D3D12_DEFAULT_RESOURCE_PLACEMENT_ALIGNMENT;
memset(&desc.Properties, 0, sizeof(desc.Properties));
desc.Properties.Type = D3D12_HEAP_TYPE_DEFAULT;
desc.Alignment = 0;
desc.Flags = D3D12_HEAP_FLAG_ALLOW_ONLY_NON_RT_DS_TEXTURES;
hr = ID3D12Device4_CreateHeap1(device4, &desc, NULL, &IID_ID3D12Heap, (void **)&heap);
ok(hr == S_OK, "Failed to create heap, hr %#x.\n", hr);
ID3D12Heap_Release(heap);
ID3D12Device4_Release(device4);
}
done:
refcount = ID3D12Device_Release(device);
ok(!refcount, "ID3D12Device has %u references left.\n", (unsigned int)refcount);