-- v2: vkd3d: Implement ID3D12Resource2. tests/d3d12: Add a test for zero description count in test_resource_allocation_info().
From: Conor McCarthy cmccarthy@codeweavers.com
--- tests/d3d12.c | 24 ++++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-)
diff --git a/tests/d3d12.c b/tests/d3d12.c index 51ee7877d..33efa0f29 100644 --- a/tests/d3d12.c +++ b/tests/d3d12.c @@ -1545,12 +1545,14 @@ static void test_create_command_signature(void)
static void test_create_committed_resource(void) { + ID3D12ProtectedResourceSession *protected_session; D3D12_GPU_VIRTUAL_ADDRESS gpu_address; D3D12_HEAP_PROPERTIES heap_properties; D3D12_RESOURCE_DESC resource_desc; ID3D12Device *device, *tmp_device; D3D12_CLEAR_VALUE clear_value; D3D12_RESOURCE_STATES state; + ID3D12Resource1 *resource1; ID3D12Resource *resource; ID3D12Device4 *device4; unsigned int i; @@ -1884,10 +1886,17 @@ static void test_create_committed_resource(void)
hr = ID3D12Device4_CreateCommittedResource1(device4, &heap_properties, D3D12_HEAP_FLAG_NONE, &resource_desc, D3D12_RESOURCE_STATE_RENDER_TARGET, &clear_value, NULL, - &IID_ID3D12Resource, (void **)&resource); + &IID_ID3D12Resource1, (void **)&resource1); ok(hr == S_OK, "Failed to create committed resource, hr %#x.\n", hr); - ID3D12Resource_Release(resource);
+ check_interface(resource1, &IID_ID3D12Resource1, true); + + hr = ID3D12Resource1_GetProtectedResourceSession(resource1, &IID_ID3D12ProtectedResourceSession, + (void **)&protected_session); + todo + ok(hr == DXGI_ERROR_NOT_FOUND, "Got unexpected hr %#x.\n", hr); + + ID3D12Resource1_Release(resource1); ID3D12Device4_Release(device4); }
@@ -2140,12 +2149,14 @@ done:
static void test_create_placed_resource(void) { + ID3D12ProtectedResourceSession *protected_session; D3D12_GPU_VIRTUAL_ADDRESS gpu_address; ID3D12Resource *resource, *resource2; D3D12_RESOURCE_DESC resource_desc; ID3D12Device *device, *tmp_device; D3D12_CLEAR_VALUE clear_value; D3D12_RESOURCE_STATES state; + ID3D12Resource1 *resource1; D3D12_HEAP_DESC heap_desc; ID3D12Heap *heap; unsigned int i; @@ -2226,6 +2237,15 @@ static void test_create_placed_resource(void) gpu_address = ID3D12Resource_GetGPUVirtualAddress(resource); ok(gpu_address, "Got unexpected GPU virtual address %#"PRIx64".\n", gpu_address);
+ if (SUCCEEDED(ID3D12Resource_QueryInterface(resource, &IID_ID3D12Resource1, (void **)&resource1))) + { + hr = ID3D12Resource1_GetProtectedResourceSession(resource1, &IID_ID3D12ProtectedResourceSession, + (void **)&protected_session); + todo + ok(hr == DXGI_ERROR_NOT_FOUND, "Got unexpected hr %#x.\n", hr); + ID3D12Resource1_Release(resource1); + } + refcount = ID3D12Resource_Release(resource); ok(!refcount, "ID3D12Resource has %u references left.\n", (unsigned int)refcount);
From: Conor McCarthy cmccarthy@codeweavers.com
--- libs/vkd3d/resource.c | 4 ++-- tests/d3d12.c | 2 -- 2 files changed, 2 insertions(+), 4 deletions(-)
diff --git a/libs/vkd3d/resource.c b/libs/vkd3d/resource.c index c04f48702..2ecf7ef76 100644 --- a/libs/vkd3d/resource.c +++ b/libs/vkd3d/resource.c @@ -1723,9 +1723,9 @@ static HRESULT STDMETHODCALLTYPE d3d12_resource_GetHeapProperties(ID3D12Resource static HRESULT STDMETHODCALLTYPE d3d12_resource_GetProtectedResourceSession(ID3D12Resource1 *iface, REFIID iid, void **session) { - FIXME("iface %p, iid %s, session %p stub!\n", iface, debugstr_guid(iid), session); + TRACE("iface %p, iid %s, session %p.\n", iface, debugstr_guid(iid), session);
- return E_NOTIMPL; + return DXGI_ERROR_NOT_FOUND; }
static const struct ID3D12Resource1Vtbl d3d12_resource_vtbl = diff --git a/tests/d3d12.c b/tests/d3d12.c index 33efa0f29..ac40c6414 100644 --- a/tests/d3d12.c +++ b/tests/d3d12.c @@ -1893,7 +1893,6 @@ static void test_create_committed_resource(void)
hr = ID3D12Resource1_GetProtectedResourceSession(resource1, &IID_ID3D12ProtectedResourceSession, (void **)&protected_session); - todo ok(hr == DXGI_ERROR_NOT_FOUND, "Got unexpected hr %#x.\n", hr);
ID3D12Resource1_Release(resource1); @@ -2241,7 +2240,6 @@ static void test_create_placed_resource(void) { hr = ID3D12Resource1_GetProtectedResourceSession(resource1, &IID_ID3D12ProtectedResourceSession, (void **)&protected_session); - todo ok(hr == DXGI_ERROR_NOT_FOUND, "Got unexpected hr %#x.\n", hr); ID3D12Resource1_Release(resource1); }
From: Conor McCarthy cmccarthy@codeweavers.com
--- tests/d3d12.c | 4 ++++ 1 file changed, 4 insertions(+)
diff --git a/tests/d3d12.c b/tests/d3d12.c index ac40c6414..d7933ed63 100644 --- a/tests/d3d12.c +++ b/tests/d3d12.c @@ -32214,6 +32214,10 @@ static void test_resource_allocation_info(void) return; }
+ info = ID3D12Device_GetResourceAllocationInfo(device, 0, 0, &desc); + ok(info.SizeInBytes == 0, "Got unexpected size %"PRIu64".\n", info.SizeInBytes); + /* Alignment on AMD Windows is 1, but this doesn't seem important to check. */ + desc.Dimension = D3D12_RESOURCE_DIMENSION_BUFFER; desc.Alignment = 0; desc.Width = 32;
From: Conor McCarthy cmccarthy@codeweavers.com
--- include/vkd3d.h | 2 +- libs/vkd3d/command.c | 14 ++-- libs/vkd3d/device.c | 117 +++++++++++++++++++++++++------- libs/vkd3d/resource.c | 135 ++++++++++++++++++++++--------------- libs/vkd3d/vkd3d_private.h | 35 +++++----- 5 files changed, 200 insertions(+), 103 deletions(-)
diff --git a/include/vkd3d.h b/include/vkd3d.h index a3bb8e0dd..79c042302 100644 --- a/include/vkd3d.h +++ b/include/vkd3d.h @@ -182,7 +182,7 @@ struct vkd3d_image_resource_create_info const void *next;
VkImage vk_image; - D3D12_RESOURCE_DESC desc; + D3D12_RESOURCE_DESC1 desc; unsigned int flags; D3D12_RESOURCE_STATES present_state; }; diff --git a/libs/vkd3d/command.c b/libs/vkd3d/command.c index f9940b3d3..ff75247bb 100644 --- a/libs/vkd3d/command.c +++ b/libs/vkd3d/command.c @@ -3508,7 +3508,7 @@ static void vk_image_subresource_layers_from_d3d12(VkImageSubresourceLayers *sub }
static void vk_extent_3d_from_d3d12_miplevel(VkExtent3D *extent, - const D3D12_RESOURCE_DESC *resource_desc, unsigned int miplevel_idx) + const D3D12_RESOURCE_DESC1 *resource_desc, unsigned int miplevel_idx) { extent->width = d3d12_resource_desc_get_width(resource_desc, miplevel_idx); extent->height = d3d12_resource_desc_get_height(resource_desc, miplevel_idx); @@ -3517,7 +3517,7 @@ static void vk_extent_3d_from_d3d12_miplevel(VkExtent3D *extent,
static void vk_buffer_image_copy_from_d3d12(VkBufferImageCopy *copy, const D3D12_PLACED_SUBRESOURCE_FOOTPRINT *footprint, unsigned int sub_resource_idx, - const D3D12_RESOURCE_DESC *image_desc, const struct vkd3d_format *format, + const D3D12_RESOURCE_DESC1 *image_desc, const struct vkd3d_format *format, const D3D12_BOX *src_box, unsigned int dst_x, unsigned int dst_y, unsigned int dst_z) { copy->bufferOffset = footprint->Offset; @@ -3558,7 +3558,7 @@ static void vk_buffer_image_copy_from_d3d12(VkBufferImageCopy *copy,
static void vk_image_buffer_copy_from_d3d12(VkBufferImageCopy *copy, const D3D12_PLACED_SUBRESOURCE_FOOTPRINT *footprint, unsigned int sub_resource_idx, - const D3D12_RESOURCE_DESC *image_desc, const struct vkd3d_format *format, + const D3D12_RESOURCE_DESC1 *image_desc, const struct vkd3d_format *format, const D3D12_BOX *src_box, unsigned int dst_x, unsigned int dst_y, unsigned int dst_z) { VkDeviceSize row_count = footprint->Footprint.Height / format->block_height; @@ -3588,7 +3588,7 @@ static void vk_image_buffer_copy_from_d3d12(VkBufferImageCopy *copy,
static void vk_image_copy_from_d3d12(VkImageCopy *image_copy, unsigned int src_sub_resource_idx, unsigned int dst_sub_resource_idx, - const D3D12_RESOURCE_DESC *src_desc, const D3D12_RESOURCE_DESC *dst_desc, + const D3D12_RESOURCE_DESC1 *src_desc, const D3D12_RESOURCE_DESC1 *dst_desc, const struct vkd3d_format *src_format, const struct vkd3d_format *dst_format, const D3D12_BOX *src_box, unsigned int dst_x, unsigned int dst_y, unsigned int dst_z) { @@ -3621,7 +3621,7 @@ static HRESULT d3d12_command_list_allocate_transfer_buffer(struct d3d12_command_ const struct vkd3d_vk_device_procs *vk_procs = &list->device->vk_procs; struct d3d12_device *device = list->device; D3D12_HEAP_PROPERTIES heap_properties; - D3D12_RESOURCE_DESC buffer_desc; + D3D12_RESOURCE_DESC1 buffer_desc; HRESULT hr;
memset(&heap_properties, 0, sizeof(heap_properties)); @@ -3671,8 +3671,8 @@ static void d3d12_command_list_copy_incompatible_texture_region(struct d3d12_com unsigned int src_sub_resource_idx, const struct vkd3d_format *src_format, unsigned int layer_count) { const struct vkd3d_vk_device_procs *vk_procs = &list->device->vk_procs; - const D3D12_RESOURCE_DESC *dst_desc = &dst_resource->desc; - const D3D12_RESOURCE_DESC *src_desc = &src_resource->desc; + const D3D12_RESOURCE_DESC1 *dst_desc = &dst_resource->desc; + const D3D12_RESOURCE_DESC1 *src_desc = &src_resource->desc; unsigned int dst_miplevel_idx, src_miplevel_idx; struct vkd3d_buffer transfer_buffer; VkBufferImageCopy buffer_image_copy; diff --git a/libs/vkd3d/device.c b/libs/vkd3d/device.c index cf8b506fd..e93f6fec6 100644 --- a/libs/vkd3d/device.c +++ b/libs/vkd3d/device.c @@ -1970,7 +1970,7 @@ static HRESULT vkd3d_select_queues(const struct vkd3d_instance *vkd3d_instance, static bool d3d12_is_64k_msaa_supported(struct d3d12_device *device) { struct vkd3d_resource_allocation_info info; - D3D12_RESOURCE_DESC resource_desc; + D3D12_RESOURCE_DESC1 resource_desc;
memset(&resource_desc, 0, sizeof(resource_desc)); resource_desc.Dimension = D3D12_RESOURCE_DIMENSION_TEXTURE2D; @@ -3566,6 +3566,23 @@ static void STDMETHODCALLTYPE d3d12_device_CopyDescriptorsSimple(ID3D12Device7 * 1, &src_descriptor_range_offset, &descriptor_count, descriptor_heap_type); }
+void d3d12_resource_desc_promote(D3D12_RESOURCE_DESC1 *dst_desc, const D3D12_RESOURCE_DESC *src_desc) +{ + dst_desc->Dimension = src_desc->Dimension; + dst_desc->Alignment = src_desc->Alignment; + dst_desc->Width = src_desc->Width; + dst_desc->Height = src_desc->Height; + dst_desc->DepthOrArraySize = src_desc->DepthOrArraySize; + dst_desc->MipLevels = src_desc->MipLevels; + dst_desc->Format = src_desc->Format; + dst_desc->SampleDesc = src_desc->SampleDesc; + dst_desc->Layout = src_desc->Layout; + dst_desc->Flags = src_desc->Flags; + dst_desc->SamplerFeedbackMipRegion.Width = 0; + dst_desc->SamplerFeedbackMipRegion.Height = 0; + dst_desc->SamplerFeedbackMipRegion.Depth = 0; +} + static void d3d12_resource_allocation_info1_from_vkd3d(D3D12_RESOURCE_ALLOCATION_INFO1 *result, const struct vkd3d_resource_allocation_info *info) { @@ -3574,12 +3591,12 @@ static void d3d12_resource_allocation_info1_from_vkd3d(D3D12_RESOURCE_ALLOCATION result->SizeInBytes = info->size_in_bytes; }
-static void d3d12_device_get_resource_allocation_info(struct d3d12_device *device, - D3D12_RESOURCE_ALLOCATION_INFO1 *infos1, unsigned int count, const D3D12_RESOURCE_DESC *resource_descs, +static void d3d12_device_get_resource1_allocation_info(struct d3d12_device *device, + D3D12_RESOURCE_ALLOCATION_INFO1 *infos1, unsigned int count, const D3D12_RESOURCE_DESC1 *resource_descs, D3D12_RESOURCE_ALLOCATION_INFO *result) { struct vkd3d_resource_allocation_info info; - const D3D12_RESOURCE_DESC *desc; + const D3D12_RESOURCE_DESC1 *desc; uint64_t requested_alignment; unsigned int i;
@@ -3652,6 +3669,37 @@ invalid: TRACE("Alignment %#"PRIx64".\n", result->Alignment); }
+static void d3d12_device_get_resource_allocation_info(struct d3d12_device *device, + D3D12_RESOURCE_ALLOCATION_INFO1 *infos1, unsigned int count, const D3D12_RESOURCE_DESC *resource_descs, + D3D12_RESOURCE_ALLOCATION_INFO *result) +{ + D3D12_RESOURCE_DESC1 resource_descs1[4]; + D3D12_RESOURCE_DESC1 *descs1 = NULL; + unsigned int i; + + if (count > ARRAY_SIZE(resource_descs1)) + { + if (!(descs1 = vkd3d_calloc(count, sizeof(*descs1)))) + { + ERR("Failed to allocate %u resource descriptions.\n", count); + result->SizeInBytes = UINT64_MAX; + result->Alignment = D3D12_DEFAULT_RESOURCE_PLACEMENT_ALIGNMENT; + return; + } + } + + if (!descs1) + descs1 = resource_descs1; + + for (i = 0; i < count; ++i) + d3d12_resource_desc_promote(&descs1[i], &resource_descs[i]); + + d3d12_device_get_resource1_allocation_info(device, infos1, count, descs1, result); + + if (descs1 != resource_descs1) + vkd3d_free(descs1); +} + static D3D12_RESOURCE_ALLOCATION_INFO * STDMETHODCALLTYPE d3d12_device_GetResourceAllocationInfo( ID3D12Device7 *iface, D3D12_RESOURCE_ALLOCATION_INFO *info, UINT visible_mask, UINT count, const D3D12_RESOURCE_DESC *resource_descs) @@ -3717,6 +3765,7 @@ static HRESULT STDMETHODCALLTYPE d3d12_device_CreateCommittedResource(ID3D12Devi const D3D12_CLEAR_VALUE *optimized_clear_value, REFIID iid, void **resource) { struct d3d12_device *device = impl_from_ID3D12Device7(iface); + D3D12_RESOURCE_DESC1 resource_desc; struct d3d12_resource *object; HRESULT hr;
@@ -3725,14 +3774,16 @@ static HRESULT STDMETHODCALLTYPE d3d12_device_CreateCommittedResource(ID3D12Devi iface, heap_properties, heap_flags, desc, initial_state, optimized_clear_value, debugstr_guid(iid), resource);
+ d3d12_resource_desc_promote(&resource_desc, desc); + if (FAILED(hr = d3d12_committed_resource_create(device, heap_properties, heap_flags, - desc, initial_state, optimized_clear_value, NULL, &object))) + &resource_desc, initial_state, optimized_clear_value, NULL, &object))) { *resource = NULL; return hr; }
- return return_interface(&object->ID3D12Resource1_iface, &IID_ID3D12Resource1, iid, resource); + return return_interface(&object->ID3D12Resource2_iface, &IID_ID3D12Resource2, iid, resource); }
static HRESULT STDMETHODCALLTYPE d3d12_device_CreateHeap(ID3D12Device7 *iface, @@ -3760,6 +3811,7 @@ static HRESULT STDMETHODCALLTYPE d3d12_device_CreatePlacedResource(ID3D12Device7 const D3D12_CLEAR_VALUE *optimized_clear_value, REFIID iid, void **resource) { struct d3d12_device *device = impl_from_ID3D12Device7(iface); + D3D12_RESOURCE_DESC1 resource_desc; struct d3d12_heap *heap_object; struct d3d12_resource *object; HRESULT hr; @@ -3770,12 +3822,13 @@ static HRESULT STDMETHODCALLTYPE d3d12_device_CreatePlacedResource(ID3D12Device7 optimized_clear_value, debugstr_guid(iid), resource);
heap_object = unsafe_impl_from_ID3D12Heap(heap); + d3d12_resource_desc_promote(&resource_desc, desc);
if (FAILED(hr = d3d12_placed_resource_create(device, heap_object, heap_offset, - desc, initial_state, optimized_clear_value, &object))) + &resource_desc, initial_state, optimized_clear_value, &object))) return hr;
- return return_interface(&object->ID3D12Resource1_iface, &IID_ID3D12Resource1, iid, resource); + return return_interface(&object->ID3D12Resource2_iface, &IID_ID3D12Resource2, iid, resource); }
static HRESULT STDMETHODCALLTYPE d3d12_device_CreateReservedResource(ID3D12Device7 *iface, @@ -3783,17 +3836,20 @@ static HRESULT STDMETHODCALLTYPE d3d12_device_CreateReservedResource(ID3D12Devic const D3D12_CLEAR_VALUE *optimized_clear_value, REFIID iid, void **resource) { struct d3d12_device *device = impl_from_ID3D12Device7(iface); + D3D12_RESOURCE_DESC1 resource_desc; struct d3d12_resource *object; HRESULT hr;
TRACE("iface %p, desc %p, initial_state %#x, optimized_clear_value %p, iid %s, resource %p.\n", iface, desc, initial_state, optimized_clear_value, debugstr_guid(iid), resource);
+ d3d12_resource_desc_promote(&resource_desc, desc); + if (FAILED(hr = d3d12_reserved_resource_create(device, - desc, initial_state, optimized_clear_value, &object))) + &resource_desc, initial_state, optimized_clear_value, &object))) return hr;
- return return_interface(&object->ID3D12Resource1_iface, &IID_ID3D12Resource1, iid, resource); + return return_interface(&object->ID3D12Resource2_iface, &IID_ID3D12Resource2, iid, resource); }
static HRESULT STDMETHODCALLTYPE d3d12_device_CreateSharedHandle(ID3D12Device7 *iface, @@ -3880,23 +3936,16 @@ static HRESULT STDMETHODCALLTYPE d3d12_device_GetDeviceRemovedReason(ID3D12Devic return device->removed_reason; }
-static void STDMETHODCALLTYPE d3d12_device_GetCopyableFootprints(ID3D12Device7 *iface, - const D3D12_RESOURCE_DESC *desc, UINT first_sub_resource, UINT sub_resource_count, - UINT64 base_offset, D3D12_PLACED_SUBRESOURCE_FOOTPRINT *layouts, - UINT *row_counts, UINT64 *row_sizes, UINT64 *total_bytes) +static void d3d12_device_get_copyable_footprints(struct d3d12_device *device, + const D3D12_RESOURCE_DESC1 *desc, unsigned int first_sub_resource, unsigned int sub_resource_count, + uint64_t base_offset, D3D12_PLACED_SUBRESOURCE_FOOTPRINT *layouts, UINT *row_counts, + UINT64 *row_sizes, UINT64 *total_bytes) { - struct d3d12_device *device = impl_from_ID3D12Device7(iface); - unsigned int i, sub_resource_idx, miplevel_idx, row_count, row_size, row_pitch; unsigned int width, height, depth, plane_count, sub_resources_per_plane; const struct vkd3d_format *format; uint64_t offset, size, total;
- TRACE("iface %p, desc %p, first_sub_resource %u, sub_resource_count %u, base_offset %#"PRIx64", " - "layouts %p, row_counts %p, row_sizes %p, total_bytes %p.\n", - iface, desc, first_sub_resource, sub_resource_count, base_offset, - layouts, row_counts, row_sizes, total_bytes); - if (layouts) memset(layouts, 0xff, sizeof(*layouts) * sub_resource_count); if (row_counts) @@ -3965,6 +4014,25 @@ static void STDMETHODCALLTYPE d3d12_device_GetCopyableFootprints(ID3D12Device7 * *total_bytes = total; }
+static void STDMETHODCALLTYPE d3d12_device_GetCopyableFootprints(ID3D12Device7 *iface, + const D3D12_RESOURCE_DESC *desc, UINT first_sub_resource, UINT sub_resource_count, + UINT64 base_offset, D3D12_PLACED_SUBRESOURCE_FOOTPRINT *layouts, + UINT *row_counts, UINT64 *row_sizes, UINT64 *total_bytes) +{ + struct d3d12_device *device = impl_from_ID3D12Device7(iface); + D3D12_RESOURCE_DESC1 resource_desc; + + TRACE("iface %p, desc %p, first_sub_resource %u, sub_resource_count %u, base_offset %#"PRIx64", " + "layouts %p, row_counts %p, row_sizes %p, total_bytes %p.\n", + iface, desc, first_sub_resource, sub_resource_count, base_offset, + layouts, row_counts, row_sizes, total_bytes); + + d3d12_resource_desc_promote(&resource_desc, desc); + + d3d12_device_get_copyable_footprints(device, &resource_desc, first_sub_resource, sub_resource_count, + base_offset, layouts, row_counts, row_sizes, total_bytes); +} + static HRESULT STDMETHODCALLTYPE d3d12_device_CreateQueryHeap(ID3D12Device7 *iface, const D3D12_QUERY_HEAP_DESC *desc, REFIID iid, void **heap) { @@ -4130,6 +4198,7 @@ static HRESULT STDMETHODCALLTYPE d3d12_device_CreateCommittedResource1(ID3D12Dev ID3D12ProtectedResourceSession *protected_session, REFIID iid, void **resource) { struct d3d12_device *device = impl_from_ID3D12Device7(iface); + D3D12_RESOURCE_DESC1 resource_desc; struct d3d12_resource *object; HRESULT hr;
@@ -4138,14 +4207,16 @@ static HRESULT STDMETHODCALLTYPE d3d12_device_CreateCommittedResource1(ID3D12Dev iface, heap_properties, heap_flags, desc, initial_state, optimized_clear_value, protected_session, debugstr_guid(iid), resource);
+ d3d12_resource_desc_promote(&resource_desc, desc); + if (FAILED(hr = d3d12_committed_resource_create(device, heap_properties, heap_flags, - desc, initial_state, optimized_clear_value, protected_session, &object))) + &resource_desc, initial_state, optimized_clear_value, protected_session, &object))) { *resource = NULL; return hr; }
- return return_interface(&object->ID3D12Resource1_iface, &IID_ID3D12Resource1, iid, resource); + return return_interface(&object->ID3D12Resource2_iface, &IID_ID3D12Resource2, iid, resource); }
static HRESULT STDMETHODCALLTYPE d3d12_device_CreateHeap1(ID3D12Device7 *iface, diff --git a/libs/vkd3d/resource.c b/libs/vkd3d/resource.c index 2ecf7ef76..bf2e6a15a 100644 --- a/libs/vkd3d/resource.c +++ b/libs/vkd3d/resource.c @@ -651,7 +651,7 @@ VkSampleCountFlagBits vk_samples_from_dxgi_sample_desc(const DXGI_SAMPLE_DESC *d
HRESULT vkd3d_create_buffer(struct d3d12_device *device, const D3D12_HEAP_PROPERTIES *heap_properties, D3D12_HEAP_FLAGS heap_flags, - const D3D12_RESOURCE_DESC *desc, VkBuffer *vk_buffer) + const D3D12_RESOURCE_DESC1 *desc, VkBuffer *vk_buffer) { const struct vkd3d_vk_device_procs *vk_procs = &device->vk_procs; const bool sparse_resource = !heap_properties; @@ -731,7 +731,7 @@ HRESULT vkd3d_create_buffer(struct d3d12_device *device, return hresult_from_vk_result(vr); }
-static unsigned int max_miplevel_count(const D3D12_RESOURCE_DESC *desc) +static unsigned int max_miplevel_count(const D3D12_RESOURCE_DESC1 *desc) { unsigned int size = max(desc->Width, desc->Height); size = max(size, d3d12_resource_desc_get_depth(desc, 0)); @@ -775,7 +775,7 @@ static bool vkd3d_is_linear_tiling_supported(const struct d3d12_device *device,
static HRESULT vkd3d_create_image(struct d3d12_device *device, const D3D12_HEAP_PROPERTIES *heap_properties, D3D12_HEAP_FLAGS heap_flags, - const D3D12_RESOURCE_DESC *desc, struct d3d12_resource *resource, VkImage *vk_image) + const D3D12_RESOURCE_DESC1 *desc, struct d3d12_resource *resource, VkImage *vk_image) { const struct vkd3d_vk_device_procs *vk_procs = &device->vk_procs; const struct vkd3d_format_compatibility_list *compat_list; @@ -940,11 +940,11 @@ static HRESULT vkd3d_create_image(struct d3d12_device *device, }
HRESULT vkd3d_get_image_allocation_info(struct d3d12_device *device, - const D3D12_RESOURCE_DESC *desc, struct vkd3d_resource_allocation_info *allocation_info) + const D3D12_RESOURCE_DESC1 *desc, struct vkd3d_resource_allocation_info *allocation_info) { static const D3D12_HEAP_PROPERTIES heap_properties = {D3D12_HEAP_TYPE_DEFAULT}; const struct vkd3d_vk_device_procs *vk_procs = &device->vk_procs; - D3D12_RESOURCE_DESC validated_desc; + D3D12_RESOURCE_DESC1 validated_desc; VkMemoryRequirements requirements; VkImage vk_image; bool tiled; @@ -1069,7 +1069,7 @@ static void d3d12_resource_get_level_box(const struct d3d12_resource *resource, }
static void compute_image_subresource_size_in_tiles(const VkExtent3D *tile_extent, - const struct D3D12_RESOURCE_DESC *desc, unsigned int miplevel_idx, + const struct D3D12_RESOURCE_DESC1 *desc, unsigned int miplevel_idx, struct vkd3d_tiled_region_extent *size) { unsigned int width, height, depth; @@ -1258,12 +1258,13 @@ static bool d3d12_resource_init_tiles(struct d3d12_resource *resource, struct d3 }
/* ID3D12Resource */ -static HRESULT STDMETHODCALLTYPE d3d12_resource_QueryInterface(ID3D12Resource1 *iface, +static HRESULT STDMETHODCALLTYPE d3d12_resource_QueryInterface(ID3D12Resource2 *iface, REFIID riid, void **object) { TRACE("iface %p, riid %s, object %p.\n", iface, debugstr_guid(riid), object);
- if (IsEqualGUID(riid, &IID_ID3D12Resource1) + if (IsEqualGUID(riid, &IID_ID3D12Resource2) + || IsEqualGUID(riid, &IID_ID3D12Resource1) || IsEqualGUID(riid, &IID_ID3D12Resource) || IsEqualGUID(riid, &IID_ID3D12Pageable) || IsEqualGUID(riid, &IID_ID3D12DeviceChild) @@ -1281,9 +1282,9 @@ static HRESULT STDMETHODCALLTYPE d3d12_resource_QueryInterface(ID3D12Resource1 * return E_NOINTERFACE; }
-static ULONG STDMETHODCALLTYPE d3d12_resource_AddRef(ID3D12Resource1 *iface) +static ULONG STDMETHODCALLTYPE d3d12_resource_AddRef(ID3D12Resource2 *iface) { - struct d3d12_resource *resource = impl_from_ID3D12Resource1(iface); + struct d3d12_resource *resource = impl_from_ID3D12Resource2(iface); unsigned int refcount = vkd3d_atomic_increment_u32(&resource->refcount);
TRACE("%p increasing refcount to %u.\n", resource, refcount); @@ -1299,9 +1300,9 @@ static ULONG STDMETHODCALLTYPE d3d12_resource_AddRef(ID3D12Resource1 *iface) return refcount; }
-static ULONG STDMETHODCALLTYPE d3d12_resource_Release(ID3D12Resource1 *iface) +static ULONG STDMETHODCALLTYPE d3d12_resource_Release(ID3D12Resource2 *iface) { - struct d3d12_resource *resource = impl_from_ID3D12Resource1(iface); + struct d3d12_resource *resource = impl_from_ID3D12Resource2(iface); unsigned int refcount = vkd3d_atomic_decrement_u32(&resource->refcount);
TRACE("%p decreasing refcount to %u.\n", resource, refcount); @@ -1318,39 +1319,39 @@ static ULONG STDMETHODCALLTYPE d3d12_resource_Release(ID3D12Resource1 *iface) return refcount; }
-static HRESULT STDMETHODCALLTYPE d3d12_resource_GetPrivateData(ID3D12Resource1 *iface, +static HRESULT STDMETHODCALLTYPE d3d12_resource_GetPrivateData(ID3D12Resource2 *iface, REFGUID guid, UINT *data_size, void *data) { - struct d3d12_resource *resource = impl_from_ID3D12Resource1(iface); + struct d3d12_resource *resource = impl_from_ID3D12Resource2(iface);
TRACE("iface %p, guid %s, data_size %p, data %p.\n", iface, debugstr_guid(guid), data_size, data);
return vkd3d_get_private_data(&resource->private_store, guid, data_size, data); }
-static HRESULT STDMETHODCALLTYPE d3d12_resource_SetPrivateData(ID3D12Resource1 *iface, +static HRESULT STDMETHODCALLTYPE d3d12_resource_SetPrivateData(ID3D12Resource2 *iface, REFGUID guid, UINT data_size, const void *data) { - struct d3d12_resource *resource = impl_from_ID3D12Resource1(iface); + struct d3d12_resource *resource = impl_from_ID3D12Resource2(iface);
TRACE("iface %p, guid %s, data_size %u, data %p.\n", iface, debugstr_guid(guid), data_size, data);
return vkd3d_set_private_data(&resource->private_store, guid, data_size, data); }
-static HRESULT STDMETHODCALLTYPE d3d12_resource_SetPrivateDataInterface(ID3D12Resource1 *iface, +static HRESULT STDMETHODCALLTYPE d3d12_resource_SetPrivateDataInterface(ID3D12Resource2 *iface, REFGUID guid, const IUnknown *data) { - struct d3d12_resource *resource = impl_from_ID3D12Resource1(iface); + struct d3d12_resource *resource = impl_from_ID3D12Resource2(iface);
TRACE("iface %p, guid %s, data %p.\n", iface, debugstr_guid(guid), data);
return vkd3d_set_private_data_interface(&resource->private_store, guid, data); }
-static HRESULT STDMETHODCALLTYPE d3d12_resource_SetName(ID3D12Resource1 *iface, const WCHAR *name) +static HRESULT STDMETHODCALLTYPE d3d12_resource_SetName(ID3D12Resource2 *iface, const WCHAR *name) { - struct d3d12_resource *resource = impl_from_ID3D12Resource1(iface); + struct d3d12_resource *resource = impl_from_ID3D12Resource2(iface); HRESULT hr;
TRACE("iface %p, name %s.\n", iface, debugstr_w(name, resource->device->wchar_size)); @@ -1369,9 +1370,9 @@ static HRESULT STDMETHODCALLTYPE d3d12_resource_SetName(ID3D12Resource1 *iface, VK_DEBUG_REPORT_OBJECT_TYPE_IMAGE_EXT, name); }
-static HRESULT STDMETHODCALLTYPE d3d12_resource_GetDevice(ID3D12Resource1 *iface, REFIID iid, void **device) +static HRESULT STDMETHODCALLTYPE d3d12_resource_GetDevice(ID3D12Resource2 *iface, REFIID iid, void **device) { - struct d3d12_resource *resource = impl_from_ID3D12Resource1(iface); + struct d3d12_resource *resource = impl_from_ID3D12Resource2(iface);
TRACE("iface %p, iid %s, device %p.\n", iface, debugstr_guid(iid), device);
@@ -1422,10 +1423,10 @@ static void d3d12_resource_flush(struct d3d12_resource *resource, uint64_t offse ERR("Failed to flush memory, vr %d.\n", vr); }
-static HRESULT STDMETHODCALLTYPE d3d12_resource_Map(ID3D12Resource1 *iface, UINT sub_resource, +static HRESULT STDMETHODCALLTYPE d3d12_resource_Map(ID3D12Resource2 *iface, UINT sub_resource, const D3D12_RANGE *read_range, void **data) { - struct d3d12_resource *resource = impl_from_ID3D12Resource1(iface); + struct d3d12_resource *resource = impl_from_ID3D12Resource2(iface); unsigned int sub_resource_count;
TRACE("iface %p, sub_resource %u, read_range %p, data %p.\n", @@ -1471,10 +1472,10 @@ static HRESULT STDMETHODCALLTYPE d3d12_resource_Map(ID3D12Resource1 *iface, UINT return S_OK; }
-static void STDMETHODCALLTYPE d3d12_resource_Unmap(ID3D12Resource1 *iface, UINT sub_resource, +static void STDMETHODCALLTYPE d3d12_resource_Unmap(ID3D12Resource2 *iface, UINT sub_resource, const D3D12_RANGE *written_range) { - struct d3d12_resource *resource = impl_from_ID3D12Resource1(iface); + struct d3d12_resource *resource = impl_from_ID3D12Resource2(iface); unsigned int sub_resource_count;
TRACE("iface %p, sub_resource %u, written_range %p.\n", @@ -1493,31 +1494,41 @@ static void STDMETHODCALLTYPE d3d12_resource_Unmap(ID3D12Resource1 *iface, UINT d3d12_resource_flush(resource, written_range->Begin, written_range->End - written_range->Begin); }
-static D3D12_RESOURCE_DESC * STDMETHODCALLTYPE d3d12_resource_GetDesc(ID3D12Resource1 *iface, +static D3D12_RESOURCE_DESC * STDMETHODCALLTYPE d3d12_resource_GetDesc(ID3D12Resource2 *iface, D3D12_RESOURCE_DESC *resource_desc) { - struct d3d12_resource *resource = impl_from_ID3D12Resource1(iface); + struct d3d12_resource *resource = impl_from_ID3D12Resource2(iface); + const D3D12_RESOURCE_DESC1 *desc1 = &resource->desc;
TRACE("iface %p, resource_desc %p.\n", iface, resource_desc);
- *resource_desc = resource->desc; + resource_desc->Dimension = desc1->Dimension; + resource_desc->Alignment = desc1->Alignment; + resource_desc->Width = desc1->Width; + resource_desc->Height = desc1->Height; + resource_desc->DepthOrArraySize = desc1->DepthOrArraySize; + resource_desc->MipLevels = desc1->MipLevels; + resource_desc->Format = desc1->Format; + resource_desc->SampleDesc = desc1->SampleDesc; + resource_desc->Layout = desc1->Layout; + resource_desc->Flags = desc1->Flags; return resource_desc; }
-static D3D12_GPU_VIRTUAL_ADDRESS STDMETHODCALLTYPE d3d12_resource_GetGPUVirtualAddress(ID3D12Resource1 *iface) +static D3D12_GPU_VIRTUAL_ADDRESS STDMETHODCALLTYPE d3d12_resource_GetGPUVirtualAddress(ID3D12Resource2 *iface) { - struct d3d12_resource *resource = impl_from_ID3D12Resource1(iface); + struct d3d12_resource *resource = impl_from_ID3D12Resource2(iface);
TRACE("iface %p.\n", iface);
return resource->gpu_address; }
-static HRESULT STDMETHODCALLTYPE d3d12_resource_WriteToSubresource(ID3D12Resource1 *iface, +static HRESULT STDMETHODCALLTYPE d3d12_resource_WriteToSubresource(ID3D12Resource2 *iface, UINT dst_sub_resource, const D3D12_BOX *dst_box, const void *src_data, UINT src_row_pitch, UINT src_slice_pitch) { - struct d3d12_resource *resource = impl_from_ID3D12Resource1(iface); + struct d3d12_resource *resource = impl_from_ID3D12Resource2(iface); const struct vkd3d_vk_device_procs *vk_procs; VkImageSubresource vk_sub_resource; const struct vkd3d_format *format; @@ -1598,11 +1609,11 @@ static HRESULT STDMETHODCALLTYPE d3d12_resource_WriteToSubresource(ID3D12Resourc return S_OK; }
-static HRESULT STDMETHODCALLTYPE d3d12_resource_ReadFromSubresource(ID3D12Resource1 *iface, +static HRESULT STDMETHODCALLTYPE d3d12_resource_ReadFromSubresource(ID3D12Resource2 *iface, void *dst_data, UINT dst_row_pitch, UINT dst_slice_pitch, UINT src_sub_resource, const D3D12_BOX *src_box) { - struct d3d12_resource *resource = impl_from_ID3D12Resource1(iface); + struct d3d12_resource *resource = impl_from_ID3D12Resource2(iface); const struct vkd3d_vk_device_procs *vk_procs; VkImageSubresource vk_sub_resource; const struct vkd3d_format *format; @@ -1683,10 +1694,10 @@ static HRESULT STDMETHODCALLTYPE d3d12_resource_ReadFromSubresource(ID3D12Resour return S_OK; }
-static HRESULT STDMETHODCALLTYPE d3d12_resource_GetHeapProperties(ID3D12Resource1 *iface, +static HRESULT STDMETHODCALLTYPE d3d12_resource_GetHeapProperties(ID3D12Resource2 *iface, D3D12_HEAP_PROPERTIES *heap_properties, D3D12_HEAP_FLAGS *flags) { - struct d3d12_resource *resource = impl_from_ID3D12Resource1(iface); + struct d3d12_resource *resource = impl_from_ID3D12Resource2(iface); struct d3d12_heap *heap;
TRACE("iface %p, heap_properties %p, flags %p.\n", @@ -1720,7 +1731,7 @@ static HRESULT STDMETHODCALLTYPE d3d12_resource_GetHeapProperties(ID3D12Resource return S_OK; }
-static HRESULT STDMETHODCALLTYPE d3d12_resource_GetProtectedResourceSession(ID3D12Resource1 *iface, +static HRESULT STDMETHODCALLTYPE d3d12_resource_GetProtectedResourceSession(ID3D12Resource2 *iface, REFIID iid, void **session) { TRACE("iface %p, iid %s, session %p.\n", iface, debugstr_guid(iid), session); @@ -1728,7 +1739,18 @@ static HRESULT STDMETHODCALLTYPE d3d12_resource_GetProtectedResourceSession(ID3D return DXGI_ERROR_NOT_FOUND; }
-static const struct ID3D12Resource1Vtbl d3d12_resource_vtbl = +static D3D12_RESOURCE_DESC1 * STDMETHODCALLTYPE d3d12_resource_GetDesc1(ID3D12Resource2 *iface, + D3D12_RESOURCE_DESC1 *resource_desc) +{ + struct d3d12_resource *resource = impl_from_ID3D12Resource2(iface); + + TRACE("iface %p, resource_desc %p.\n", iface, resource_desc); + + *resource_desc = resource->desc; + return resource_desc; +} + +static const struct ID3D12Resource2Vtbl d3d12_resource_vtbl = { /* IUnknown methods */ d3d12_resource_QueryInterface, @@ -1751,6 +1773,8 @@ static const struct ID3D12Resource1Vtbl d3d12_resource_vtbl = d3d12_resource_GetHeapProperties, /* ID3D12Resource1 methods */ d3d12_resource_GetProtectedResourceSession, + /* ID3D12Resource2 methods */ + d3d12_resource_GetDesc1, };
struct d3d12_resource *unsafe_impl_from_ID3D12Resource(ID3D12Resource *iface) @@ -1777,7 +1801,7 @@ static void d3d12_validate_resource_flags(D3D12_RESOURCE_FLAGS flags) FIXME("Ignoring D3D12_RESOURCE_FLAG_ALLOW_CROSS_ADAPTER.\n"); }
-static bool d3d12_resource_validate_texture_format(const D3D12_RESOURCE_DESC *desc, +static bool d3d12_resource_validate_texture_format(const D3D12_RESOURCE_DESC1 *desc, const struct vkd3d_format *format) { if (desc->Format == DXGI_FORMAT_UNKNOWN) @@ -1806,7 +1830,7 @@ static bool d3d12_resource_validate_texture_format(const D3D12_RESOURCE_DESC *de return true; }
-static bool d3d12_resource_validate_texture_alignment(const D3D12_RESOURCE_DESC *desc, +static bool d3d12_resource_validate_texture_alignment(const D3D12_RESOURCE_DESC1 *desc, const struct vkd3d_format *format) { uint64_t estimated_size; @@ -1841,7 +1865,7 @@ static bool d3d12_resource_validate_texture_alignment(const D3D12_RESOURCE_DESC return true; }
-HRESULT d3d12_resource_validate_desc(const D3D12_RESOURCE_DESC *desc, struct d3d12_device *device) +HRESULT d3d12_resource_validate_desc(const D3D12_RESOURCE_DESC1 *desc, struct d3d12_device *device) { const struct vkd3d_format *format;
@@ -1950,12 +1974,12 @@ static bool d3d12_resource_validate_heap_properties(const struct d3d12_resource
static HRESULT d3d12_resource_init(struct d3d12_resource *resource, 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_RESOURCE_DESC1 *desc, D3D12_RESOURCE_STATES initial_state, const D3D12_CLEAR_VALUE *optimized_clear_value) { HRESULT hr;
- resource->ID3D12Resource1_iface.lpVtbl = &d3d12_resource_vtbl; + resource->ID3D12Resource2_iface.lpVtbl = &d3d12_resource_vtbl; resource->refcount = 1; resource->internal_refcount = 1;
@@ -2047,7 +2071,7 @@ static HRESULT d3d12_resource_init(struct d3d12_resource *resource, struct d3d12
static HRESULT d3d12_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_RESOURCE_DESC1 *desc, D3D12_RESOURCE_STATES initial_state, const D3D12_CLEAR_VALUE *optimized_clear_value, struct d3d12_resource **resource) { struct d3d12_resource *object; @@ -2086,7 +2110,7 @@ static HRESULT vkd3d_allocate_resource_memory(
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_RESOURCE_DESC1 *desc, D3D12_RESOURCE_STATES initial_state, const D3D12_CLEAR_VALUE *optimized_clear_value, ID3D12ProtectedResourceSession *protected_session, struct d3d12_resource **resource) { @@ -2108,7 +2132,7 @@ HRESULT d3d12_committed_resource_create(struct d3d12_device *device,
if (FAILED(hr = vkd3d_allocate_resource_memory(device, object, heap_properties, heap_flags))) { - d3d12_resource_Release(&object->ID3D12Resource1_iface); + d3d12_resource_Release(&object->ID3D12Resource2_iface); return hr; }
@@ -2189,7 +2213,7 @@ allocate_memory: }
HRESULT d3d12_placed_resource_create(struct d3d12_device *device, struct d3d12_heap *heap, uint64_t heap_offset, - const D3D12_RESOURCE_DESC *desc, D3D12_RESOURCE_STATES initial_state, + const D3D12_RESOURCE_DESC1 *desc, D3D12_RESOURCE_STATES initial_state, const D3D12_CLEAR_VALUE *optimized_clear_value, struct d3d12_resource **resource) { struct d3d12_resource *object; @@ -2201,7 +2225,7 @@ HRESULT d3d12_placed_resource_create(struct d3d12_device *device, struct d3d12_h
if (FAILED(hr = vkd3d_bind_heap_memory(device, object, heap, heap_offset))) { - d3d12_resource_Release(&object->ID3D12Resource1_iface); + d3d12_resource_Release(&object->ID3D12Resource2_iface); return hr; }
@@ -2213,7 +2237,7 @@ HRESULT d3d12_placed_resource_create(struct d3d12_device *device, struct d3d12_h }
HRESULT d3d12_reserved_resource_create(struct d3d12_device *device, - const D3D12_RESOURCE_DESC *desc, D3D12_RESOURCE_STATES initial_state, + const D3D12_RESOURCE_DESC1 *desc, D3D12_RESOURCE_STATES initial_state, const D3D12_CLEAR_VALUE *optimized_clear_value, struct d3d12_resource **resource) { struct d3d12_resource *object; @@ -2225,7 +2249,7 @@ HRESULT d3d12_reserved_resource_create(struct d3d12_device *device,
if (!d3d12_resource_init_tiles(object, device)) { - d3d12_resource_Release(&object->ID3D12Resource1_iface); + d3d12_resource_Release(&object->ID3D12Resource2_iface); return E_OUTOFMEMORY; }
@@ -2260,7 +2284,7 @@ HRESULT vkd3d_create_image_resource(ID3D12Device *device,
memset(object, 0, sizeof(*object));
- object->ID3D12Resource1_iface.lpVtbl = &d3d12_resource_vtbl; + object->ID3D12Resource2_iface.lpVtbl = &d3d12_resource_vtbl; object->refcount = 1; object->internal_refcount = 1; object->desc = create_info->desc; @@ -2284,7 +2308,7 @@ HRESULT vkd3d_create_image_resource(ID3D12Device *device,
TRACE("Created resource %p.\n", object);
- *resource = (ID3D12Resource *)&object->ID3D12Resource1_iface; + *resource = (ID3D12Resource *)&object->ID3D12Resource2_iface;
return S_OK; } @@ -3022,7 +3046,7 @@ static bool init_default_texture_view_desc(struct vkd3d_texture_view_desc *desc, }
static void vkd3d_texture_view_desc_normalise(struct vkd3d_texture_view_desc *desc, - const D3D12_RESOURCE_DESC *resource_desc) + const D3D12_RESOURCE_DESC1 *resource_desc) { unsigned int max_layer_count;
@@ -4815,7 +4839,7 @@ HRESULT vkd3d_init_null_resources(struct vkd3d_null_resources *null_resources, { const bool use_sparse_resources = device->vk_info.sparse_properties.residencyNonResidentStrict; D3D12_HEAP_PROPERTIES heap_properties; - D3D12_RESOURCE_DESC resource_desc; + D3D12_RESOURCE_DESC1 resource_desc; HRESULT hr;
TRACE("Creating resources for NULL views.\n"); @@ -4840,6 +4864,7 @@ HRESULT vkd3d_init_null_resources(struct vkd3d_null_resources *null_resources, resource_desc.SampleDesc.Quality = 0; resource_desc.Layout = D3D12_TEXTURE_LAYOUT_ROW_MAJOR; resource_desc.Flags = D3D12_RESOURCE_FLAG_NONE; + memset(&resource_desc.SamplerFeedbackMipRegion, 0, sizeof(resource_desc.SamplerFeedbackMipRegion));
if (FAILED(hr = vkd3d_create_buffer(device, &heap_properties, D3D12_HEAP_FLAG_NONE, &resource_desc, &null_resources->vk_buffer))) diff --git a/libs/vkd3d/vkd3d_private.h b/libs/vkd3d/vkd3d_private.h index bb78ba777..445ea2d8c 100644 --- a/libs/vkd3d/vkd3d_private.h +++ b/libs/vkd3d/vkd3d_private.h @@ -720,11 +720,11 @@ struct d3d12_resource_tile_info /* ID3D12Resource */ struct d3d12_resource { - ID3D12Resource1 ID3D12Resource1_iface; + ID3D12Resource2 ID3D12Resource2_iface; unsigned int refcount; unsigned int internal_refcount;
- D3D12_RESOURCE_DESC desc; + D3D12_RESOURCE_DESC1 desc; const struct vkd3d_format *format;
D3D12_GPU_VIRTUAL_ADDRESS gpu_address; @@ -752,12 +752,12 @@ struct d3d12_resource
static inline struct d3d12_resource *impl_from_ID3D12Resource(ID3D12Resource *iface) { - return CONTAINING_RECORD(iface, struct d3d12_resource, ID3D12Resource1_iface); + return CONTAINING_RECORD(iface, struct d3d12_resource, ID3D12Resource2_iface); }
-static inline struct d3d12_resource *impl_from_ID3D12Resource1(ID3D12Resource1 *iface) +static inline struct d3d12_resource *impl_from_ID3D12Resource2(ID3D12Resource2 *iface) { - return CONTAINING_RECORD(iface, struct d3d12_resource, ID3D12Resource1_iface); + return CONTAINING_RECORD(iface, struct d3d12_resource, ID3D12Resource2_iface); }
static inline bool d3d12_resource_is_buffer(const struct d3d12_resource *resource) @@ -778,7 +778,8 @@ struct vkd3d_resource_allocation_info };
bool d3d12_resource_is_cpu_accessible(const struct d3d12_resource *resource); -HRESULT d3d12_resource_validate_desc(const D3D12_RESOURCE_DESC *desc, struct d3d12_device *device); +HRESULT d3d12_resource_validate_desc(const D3D12_RESOURCE_DESC1 *desc, struct d3d12_device *device); +void d3d12_resource_desc_promote(D3D12_RESOURCE_DESC1 *dst_desc, const D3D12_RESOURCE_DESC *src_desc); void d3d12_resource_get_tiling(struct d3d12_device *device, const struct d3d12_resource *resource, UINT *total_tile_count, D3D12_PACKED_MIP_INFO *packed_mip_info, D3D12_TILE_SHAPE *standard_tile_shape, UINT *sub_resource_tiling_count, UINT first_sub_resource_tiling, @@ -786,14 +787,14 @@ void d3d12_resource_get_tiling(struct d3d12_device *device, const struct d3d12_r
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_RESOURCE_DESC1 *desc, D3D12_RESOURCE_STATES initial_state, const D3D12_CLEAR_VALUE *optimized_clear_value, ID3D12ProtectedResourceSession *protected_session, struct d3d12_resource **resource); HRESULT d3d12_placed_resource_create(struct d3d12_device *device, struct d3d12_heap *heap, uint64_t heap_offset, - const D3D12_RESOURCE_DESC *desc, D3D12_RESOURCE_STATES initial_state, + const D3D12_RESOURCE_DESC1 *desc, D3D12_RESOURCE_STATES initial_state, const D3D12_CLEAR_VALUE *optimized_clear_value, struct d3d12_resource **resource); HRESULT d3d12_reserved_resource_create(struct d3d12_device *device, - const D3D12_RESOURCE_DESC *desc, D3D12_RESOURCE_STATES initial_state, + const D3D12_RESOURCE_DESC1 *desc, D3D12_RESOURCE_STATES initial_state, const D3D12_CLEAR_VALUE *optimized_clear_value, struct d3d12_resource **resource); struct d3d12_resource *unsafe_impl_from_ID3D12Resource(ID3D12Resource *iface);
@@ -802,9 +803,9 @@ HRESULT vkd3d_allocate_buffer_memory(struct d3d12_device *device, VkBuffer vk_bu VkDeviceMemory *vk_memory, uint32_t *vk_memory_type, VkDeviceSize *vk_memory_size); HRESULT vkd3d_create_buffer(struct d3d12_device *device, const D3D12_HEAP_PROPERTIES *heap_properties, D3D12_HEAP_FLAGS heap_flags, - const D3D12_RESOURCE_DESC *desc, VkBuffer *vk_buffer); + const D3D12_RESOURCE_DESC1 *desc, VkBuffer *vk_buffer); HRESULT vkd3d_get_image_allocation_info(struct d3d12_device *device, - const D3D12_RESOURCE_DESC *desc, struct vkd3d_resource_allocation_info *allocation_info); + const D3D12_RESOURCE_DESC1 *desc, struct vkd3d_resource_allocation_info *allocation_info);
enum vkd3d_view_type { @@ -1904,7 +1905,7 @@ HRESULT vkd3d_init_format_info(struct d3d12_device *device); void vkd3d_cleanup_format_info(struct d3d12_device *device);
static inline const struct vkd3d_format *vkd3d_format_from_d3d12_resource_desc( - const struct d3d12_device *device, const D3D12_RESOURCE_DESC *desc, DXGI_FORMAT view_format) + const struct d3d12_device *device, const D3D12_RESOURCE_DESC1 *desc, DXGI_FORMAT view_format) { return vkd3d_get_format(device, view_format ? view_format : desc->Format, desc->Flags & D3D12_RESOURCE_FLAG_ALLOW_DEPTH_STENCIL); @@ -1915,31 +1916,31 @@ static inline bool d3d12_box_is_empty(const D3D12_BOX *box) return box->right <= box->left || box->bottom <= box->top || box->back <= box->front; }
-static inline unsigned int d3d12_resource_desc_get_width(const D3D12_RESOURCE_DESC *desc, +static inline unsigned int d3d12_resource_desc_get_width(const D3D12_RESOURCE_DESC1 *desc, unsigned int miplevel_idx) { return max(1, desc->Width >> miplevel_idx); }
-static inline unsigned int d3d12_resource_desc_get_height(const D3D12_RESOURCE_DESC *desc, +static inline unsigned int d3d12_resource_desc_get_height(const D3D12_RESOURCE_DESC1 *desc, unsigned int miplevel_idx) { return max(1, desc->Height >> miplevel_idx); }
-static inline unsigned int d3d12_resource_desc_get_depth(const D3D12_RESOURCE_DESC *desc, +static inline unsigned int d3d12_resource_desc_get_depth(const D3D12_RESOURCE_DESC1 *desc, unsigned int miplevel_idx) { unsigned int d = desc->Dimension != D3D12_RESOURCE_DIMENSION_TEXTURE3D ? 1 : desc->DepthOrArraySize; return max(1, d >> miplevel_idx); }
-static inline unsigned int d3d12_resource_desc_get_layer_count(const D3D12_RESOURCE_DESC *desc) +static inline unsigned int d3d12_resource_desc_get_layer_count(const D3D12_RESOURCE_DESC1 *desc) { return desc->Dimension != D3D12_RESOURCE_DIMENSION_TEXTURE3D ? desc->DepthOrArraySize : 1; }
-static inline unsigned int d3d12_resource_desc_get_sub_resource_count(const D3D12_RESOURCE_DESC *desc) +static inline unsigned int d3d12_resource_desc_get_sub_resource_count(const D3D12_RESOURCE_DESC1 *desc) { return d3d12_resource_desc_get_layer_count(desc) * desc->MipLevels; }
This merge request was approved by Giovanni Mascellani.
+void d3d12_resource_desc_promote(D3D12_RESOURCE_DESC1 *dst_desc, const D3D12_RESOURCE_DESC *src_desc) +{ + dst_desc->Dimension = src_desc->Dimension; + dst_desc->Alignment = src_desc->Alignment; + dst_desc->Width = src_desc->Width; + dst_desc->Height = src_desc->Height; + dst_desc->DepthOrArraySize = src_desc->DepthOrArraySize; + dst_desc->MipLevels = src_desc->MipLevels; + dst_desc->Format = src_desc->Format; + dst_desc->SampleDesc = src_desc->SampleDesc; + dst_desc->Layout = src_desc->Layout; + dst_desc->Flags = src_desc->Flags; + dst_desc->SamplerFeedbackMipRegion.Width = 0; + dst_desc->SamplerFeedbackMipRegion.Height = 0; + dst_desc->SamplerFeedbackMipRegion.Depth = 0; +}
This is not used outside device.c. We'd typically implemented that like this: ```c static void d3d12_resource_desc1_from_desc(D3D12_RESOURCE_DESC1 *desc1, const D3D12_RESOURCE_DESC *desc) { memcpy(desc1, desc, sizeof(*desc)) desc1->SamplerFeedbackMipRegion.Width = 0; desc1->SamplerFeedbackMipRegion.Height = 0; desc1->SamplerFeedbackMipRegion.Depth = 0; } ```
+static void d3d12_device_get_resource_allocation_info(struct d3d12_device *device, + D3D12_RESOURCE_ALLOCATION_INFO1 *infos1, unsigned int count, const D3D12_RESOURCE_DESC *resource_descs, + D3D12_RESOURCE_ALLOCATION_INFO *result) +{ + D3D12_RESOURCE_DESC1 resource_descs1[4]; + D3D12_RESOURCE_DESC1 *descs1 = NULL; + unsigned int i; + + if (count > ARRAY_SIZE(resource_descs1)) + { + if (!(descs1 = vkd3d_calloc(count, sizeof(*descs1)))) + { + ERR("Failed to allocate %u resource descriptions.\n", count); + result->SizeInBytes = UINT64_MAX; + result->Alignment = D3D12_DEFAULT_RESOURCE_PLACEMENT_ALIGNMENT; + return; + } + } + + if (!descs1) + descs1 = resource_descs1;
I.e., ```c { D3D12_RESOURCE_DESC1 resource_descs1[4]; D3D12_RESOURCE_DESC1 *descs1; unsigned int i;
if (count <= ARRAY_SIZE(resource_descs1)) { descs1 = resource_descs1; } else if (!(descs1 = vkd3d_calloc(count, sizeof(*descs1)))) { ... return; }
...
if (descs1 != resource_descs1) vkd3d_free(descs1); } ``` right?
-static D3D12_RESOURCE_DESC * STDMETHODCALLTYPE d3d12_resource_GetDesc(ID3D12Resource1 *iface, +static D3D12_RESOURCE_DESC * STDMETHODCALLTYPE d3d12_resource_GetDesc(ID3D12Resource2 *iface, D3D12_RESOURCE_DESC *resource_desc) { - struct d3d12_resource *resource = impl_from_ID3D12Resource1(iface); + struct d3d12_resource *resource = impl_from_ID3D12Resource2(iface); + const D3D12_RESOURCE_DESC1 *desc1 = &resource->desc; TRACE("iface %p, resource_desc %p.\n", iface, resource_desc); - *resource_desc = resource->desc; + resource_desc->Dimension = desc1->Dimension; + resource_desc->Alignment = desc1->Alignment; + resource_desc->Width = desc1->Width; + resource_desc->Height = desc1->Height; + resource_desc->DepthOrArraySize = desc1->DepthOrArraySize; + resource_desc->MipLevels = desc1->MipLevels; + resource_desc->Format = desc1->Format; + resource_desc->SampleDesc = desc1->SampleDesc; + resource_desc->Layout = desc1->Layout; + resource_desc->Flags = desc1->Flags; return resource_desc; }
Somewhat like above, we'd normally just use "memcpy(resource_desc, &resource->desc, sizeof(*resource_desc))" here.