vkd3d: Pad resource allocation size to allow texture placement at a 64kb alignment.

Signed-off-by: Conor McCarthy <cmccarthy@codeweavers.com>
Signed-off-by: Henri Verbeet <hverbeet@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Conor McCarthy 2021-07-06 13:25:56 +10:00 committed by Alexandre Julliard
parent fdad6a9bde
commit cea28ec77e
3 changed files with 18 additions and 4 deletions

View File

@ -3221,7 +3221,7 @@ static D3D12_RESOURCE_ALLOCATION_INFO * STDMETHODCALLTYPE d3d12_device_GetResour
if (desc->Dimension == D3D12_RESOURCE_DIMENSION_BUFFER)
{
info->SizeInBytes = desc->Width;
info->SizeInBytes = align(desc->Width, D3D12_DEFAULT_RESOURCE_PLACEMENT_ALIGNMENT);
info->Alignment = D3D12_DEFAULT_RESOURCE_PLACEMENT_ALIGNMENT;
}
else
@ -3235,9 +3235,18 @@ static D3D12_RESOURCE_ALLOCATION_INFO * STDMETHODCALLTYPE d3d12_device_GetResour
requested_alignment = desc->Alignment
? desc->Alignment : D3D12_DEFAULT_RESOURCE_PLACEMENT_ALIGNMENT;
info->Alignment = max(info->Alignment, requested_alignment);
}
info->SizeInBytes = align(info->SizeInBytes, info->Alignment);
info->SizeInBytes = align(info->SizeInBytes, info->Alignment);
/* Pad by the maximum heap offset increase which may be needed to align to a higher
* Vulkan requirement an offset supplied by the calling application. This allows
* us to return the standard D3D12 alignment and adjust resource placement later. */
if (info->Alignment > requested_alignment)
{
info->SizeInBytes += info->Alignment - requested_alignment;
info->Alignment = requested_alignment;
}
}
TRACE("Size %#"PRIx64", alignment %#"PRIx64".\n", info->SizeInBytes, info->Alignment);

View File

@ -1901,9 +1901,15 @@ static HRESULT vkd3d_bind_heap_memory(struct d3d12_device *device,
VkResult vr;
if (d3d12_resource_is_buffer(resource))
{
VK_CALL(vkGetBufferMemoryRequirements(vk_device, resource->u.vk_buffer, &requirements));
}
else
{
VK_CALL(vkGetImageMemoryRequirements(vk_device, resource->u.vk_image, &requirements));
/* Padding in d3d12_device_GetResourceAllocationInfo() leaves room to align the offset. */
heap_offset = align(heap_offset, requirements.alignment);
}
if (heap_offset % requirements.alignment)
{

View File

@ -29863,7 +29863,6 @@ static void test_64kb_texture_alignment(void)
/* If the heap could not be used, the texture is not aliased. */
reset_command_list(command_list, context.allocator);
get_texture_readback_with_command_list(textures[1], 0, &rb, queue, command_list);
todo_if(info.Alignment > D3D12_DEFAULT_RESOURCE_PLACEMENT_ALIGNMENT)
check_readback_data_uint(&rb, &box, 0xdeadbeef, 0);
release_resource_readback(&rb);