mirror of
https://gitlab.winehq.org/wine/vkd3d.git
synced 2025-01-28 13:05:02 -08:00
vkd3d: Prefer cached memory for readback heaps.
Reading uncached memory is slow. Signed-off-by: Józef Kucia <jkucia@codeweavers.com> Signed-off-by: Henri Verbeet <hverbeet@codeweavers.com> Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
parent
e20ddc48a6
commit
7858eb6a83
@ -24,21 +24,26 @@ static unsigned int vkd3d_select_memory_type(struct d3d12_device *device, uint32
|
|||||||
const D3D12_HEAP_PROPERTIES *heap_properties, D3D12_HEAP_FLAGS heap_flags)
|
const D3D12_HEAP_PROPERTIES *heap_properties, D3D12_HEAP_FLAGS heap_flags)
|
||||||
{
|
{
|
||||||
const VkPhysicalDeviceMemoryProperties *memory_info = &device->memory_properties;
|
const VkPhysicalDeviceMemoryProperties *memory_info = &device->memory_properties;
|
||||||
VkMemoryPropertyFlags required_flags;
|
VkMemoryPropertyFlags flags[2];
|
||||||
unsigned int i;
|
unsigned int i, j, count = 0;
|
||||||
|
|
||||||
switch (heap_properties->Type)
|
switch (heap_properties->Type)
|
||||||
{
|
{
|
||||||
case D3D12_HEAP_TYPE_DEFAULT:
|
case D3D12_HEAP_TYPE_DEFAULT:
|
||||||
required_flags = VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT;
|
flags[count++] = VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case D3D12_HEAP_TYPE_UPLOAD:
|
||||||
|
flags[count++] = VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT | VK_MEMORY_PROPERTY_HOST_COHERENT_BIT;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case D3D12_HEAP_TYPE_CUSTOM:
|
case D3D12_HEAP_TYPE_CUSTOM:
|
||||||
FIXME("Custom heaps not supported yet.\n");
|
FIXME("Custom heaps not supported yet.\n");
|
||||||
/* fall-through */
|
/* fall-through */
|
||||||
case D3D12_HEAP_TYPE_UPLOAD:
|
|
||||||
case D3D12_HEAP_TYPE_READBACK:
|
case D3D12_HEAP_TYPE_READBACK:
|
||||||
required_flags = VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT | VK_MEMORY_PROPERTY_HOST_COHERENT_BIT;
|
flags[count++] = VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT
|
||||||
|
| VK_MEMORY_PROPERTY_HOST_CACHED_BIT | VK_MEMORY_PROPERTY_HOST_COHERENT_BIT;
|
||||||
|
flags[count++] = VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT | VK_MEMORY_PROPERTY_HOST_COHERENT_BIT;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
@ -46,12 +51,17 @@ static unsigned int vkd3d_select_memory_type(struct d3d12_device *device, uint32
|
|||||||
return ~0u;
|
return ~0u;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (i = 0; i < memory_info->memoryTypeCount; ++i)
|
for (j = 0; j < count; ++j)
|
||||||
{
|
{
|
||||||
if (!(memory_type_mask & (1u << i)))
|
VkMemoryPropertyFlags preferred_flags = flags[j];
|
||||||
continue;
|
|
||||||
if ((memory_info->memoryTypes[i].propertyFlags & required_flags) == required_flags)
|
for (i = 0; i < memory_info->memoryTypeCount; ++i)
|
||||||
return i;
|
{
|
||||||
|
if (!(memory_type_mask & (1u << i)))
|
||||||
|
continue;
|
||||||
|
if ((memory_info->memoryTypes[i].propertyFlags & preferred_flags) == preferred_flags)
|
||||||
|
return i;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return ~0u;
|
return ~0u;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user