From 99e239ad500349fc0977c73e3cd4682aa1d17640 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B3zef=20Kucia?= Date: Tue, 25 Sep 2018 14:13:00 +0200 Subject: [PATCH] vkd3d: Implement d3d12_device_GetResourceAllocationInfo() for buffers. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit In Direct3D12, D3D12_DEFAULT_RESOURCE_PLACEMENT_ALIGNMENT is always used for buffers. We could try to use a lower alignment when supported by the Vulkan implementation, but there is no way to get buffer memory requirements without creating a buffer in Vulkan. Signed-off-by: Józef Kucia Signed-off-by: Henri Verbeet Signed-off-by: Alexandre Julliard --- libs/vkd3d/device.c | 39 +++++++++++++++++++++++++++++++++------ 1 file changed, 33 insertions(+), 6 deletions(-) diff --git a/libs/vkd3d/device.c b/libs/vkd3d/device.c index a3a00b92..54196acb 100644 --- a/libs/vkd3d/device.c +++ b/libs/vkd3d/device.c @@ -2022,16 +2022,43 @@ static void STDMETHODCALLTYPE d3d12_device_CopyDescriptorsSimple(ID3D12Device *i } static D3D12_RESOURCE_ALLOCATION_INFO * STDMETHODCALLTYPE d3d12_device_GetResourceAllocationInfo( - ID3D12Device *iface, D3D12_RESOURCE_ALLOCATION_INFO *allocation_info, UINT visible_mask, - UINT resource_desc_count, const D3D12_RESOURCE_DESC *resource_descs) + ID3D12Device *iface, D3D12_RESOURCE_ALLOCATION_INFO *info, UINT visible_mask, + UINT count, const D3D12_RESOURCE_DESC *resource_descs) { - FIXME("iface %p, allocation_info %p, visible_mask 0x%08x, resource_desc_count %u, " - "resource_descs %p stub!\n", - iface, allocation_info, visible_mask, resource_desc_count, resource_descs); + const D3D12_RESOURCE_DESC *desc; + + TRACE("iface %p, info %p, visible_mask 0x%08x, count %u, resource_descs %p.\n", + iface, info, visible_mask, count, resource_descs); debug_ignored_node_mask(visible_mask); - return allocation_info; + info->SizeInBytes = 0; + info->Alignment = 0; + + if (count != 1) + { + FIXME("Multiple resource descriptions not supported.\n"); + return info; + } + + desc = &resource_descs[0]; + if (desc->Dimension == D3D12_RESOURCE_DIMENSION_BUFFER) + { + info->SizeInBytes = align(desc->Width, D3D12_DEFAULT_RESOURCE_PLACEMENT_ALIGNMENT); + info->Alignment = D3D12_DEFAULT_RESOURCE_PLACEMENT_ALIGNMENT; + } + else + { + FIXME("Unhandled dimension %#x.\n", desc->Dimension); + } + + if (FAILED(d3d12_resource_validate_desc(desc))) + { + WARN("Invalid resource desc.\n"); + info->SizeInBytes = ~(UINT64)0; + } + + return info; } static D3D12_HEAP_PROPERTIES * STDMETHODCALLTYPE d3d12_device_GetCustomHeapProperties(ID3D12Device *iface,