1
0
mirror of https://github.com/doitsujin/dxvk.git synced 2025-01-19 05:52:11 +01:00

[dxvk] Use high memory priority for GPU-writable resources

This commit is contained in:
Philip Rebohle 2019-01-30 12:12:54 +01:00
parent 134613375d
commit e7bf1647dd
No known key found for this signature in database
GPG Key ID: C8CC613427A31C99
2 changed files with 21 additions and 2 deletions

View File

@ -125,9 +125,18 @@ namespace dxvk {
vkd->vkGetBufferMemoryRequirements2KHR(
vkd->device(), &memReqInfo, &memReq);
// Use high memory priority for GPU-writable resources
bool isGpuWritable = (m_info.usage & (
VK_BUFFER_USAGE_STORAGE_BUFFER_BIT |
VK_BUFFER_USAGE_STORAGE_TEXEL_BUFFER_BIT)) != 0;
float priority = isGpuWritable ? 1.0f : 0.5f;
// Ask driver whether we should be using a dedicated allocation
bool useDedicated = dedicatedRequirements.prefersDedicatedAllocation;
handle.memory = m_memAlloc->alloc(&memReq.memoryRequirements,
useDedicated ? &dedMemoryAllocInfo : nullptr, m_memFlags, 0.5f);
useDedicated ? &dedMemoryAllocInfo : nullptr, m_memFlags, priority);
if (vkd->vkBindBufferMemory(vkd->device(), handle.buffer,
handle.memory.memory(), handle.memory.offset()) != VK_SUCCESS)

View File

@ -89,9 +89,19 @@ namespace dxvk {
memReq.memoryRequirements.alignment = align(memReq.memoryRequirements.alignment , memAlloc.bufferImageGranularity());
}
// Use high memory priority for GPU-writable resources
bool isGpuWritable = (m_info.usage & (
VK_IMAGE_USAGE_STORAGE_BIT |
VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT |
VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT)) != 0;
float priority = isGpuWritable ? 1.0f : 0.5f;
// Ask driver whether we should be using a dedicated allocation
bool useDedicated = dedicatedRequirements.prefersDedicatedAllocation;
m_memory = memAlloc.alloc(&memReq.memoryRequirements,
useDedicated ? &dedMemoryAllocInfo : nullptr, memFlags, 0.5f);
useDedicated ? &dedMemoryAllocInfo : nullptr, memFlags, priority);
// Try to bind the allocated memory slice to the image
if (m_vkd->vkBindImageMemory(m_vkd->device(),