Signed-off-by: Conor McCarthy cmccarthy@codeweavers.com --- libs/vkd3d/resource.c | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-)
diff --git a/libs/vkd3d/resource.c b/libs/vkd3d/resource.c index 626772e..ddd8bfc 100644 --- a/libs/vkd3d/resource.c +++ b/libs/vkd3d/resource.c @@ -58,9 +58,19 @@ static unsigned int vkd3d_select_memory_type(struct d3d12_device *device, uint32 break;
case D3D12_HEAP_TYPE_CUSTOM: - FIXME("Custom heaps not supported yet.\n"); - flags[count++] = VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT - | VK_MEMORY_PROPERTY_HOST_CACHED_BIT | VK_MEMORY_PROPERTY_HOST_COHERENT_BIT; + switch (heap_properties->CPUPageProperty) + { + case D3D12_CPU_PAGE_PROPERTY_WRITE_COMBINE: + flags[count++] = VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT | VK_MEMORY_PROPERTY_HOST_COHERENT_BIT; + break; + default: + WARN("Invalid CPU page property.\n"); + /* Fall through. */ + case D3D12_CPU_PAGE_PROPERTY_WRITE_BACK: + flags[count++] = VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT + | VK_MEMORY_PROPERTY_HOST_CACHED_BIT | VK_MEMORY_PROPERTY_HOST_COHERENT_BIT; + break; + } flags[count++] = VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT | VK_MEMORY_PROPERTY_HOST_COHERENT_BIT; flags[count++] = VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT; break;
On Tue, 22 Oct 2019 at 17:42, Conor McCarthy cmccarthy@codeweavers.com wrote:
case D3D12_HEAP_TYPE_CUSTOM:
FIXME("Custom heaps not supported yet.\n");
flags[count++] = VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT
| VK_MEMORY_PROPERTY_HOST_CACHED_BIT | VK_MEMORY_PROPERTY_HOST_COHERENT_BIT;
switch (heap_properties->CPUPageProperty)
{
case D3D12_CPU_PAGE_PROPERTY_WRITE_COMBINE:
flags[count++] = VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT | VK_MEMORY_PROPERTY_HOST_COHERENT_BIT;
break;
default:
WARN("Invalid CPU page property.\n");
/* Fall through. */
I'd argue that's the kind of thing that should make the allocation fail, and for which it's probably easy enough to write a test. The MSDN page for D3D12_HEAP_PROPERTIES seems to imply that at least D3D12_CPU_PAGE_PROPERTY_NOT_AVAILABLE is a valid value.
case D3D12_CPU_PAGE_PROPERTY_WRITE_BACK:
flags[count++] = VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT
| VK_MEMORY_PROPERTY_HOST_CACHED_BIT | VK_MEMORY_PROPERTY_HOST_COHERENT_BIT;
break;
} flags[count++] = VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT | VK_MEMORY_PROPERTY_HOST_COHERENT_BIT; flags[count++] = VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT; break;
If CPUPageProperty is D3D12_CPU_PAGE_PROPERTY_WRITE_COMBINE, we now try HOST_COHERENT | HOST_VISIBLE twice. We should probably also take MemoryPoolPreference into account to decide whether to prefer DEVICE_LOCAL or not.