Skip to content

Commit

Permalink
Merge branch 'nsubtil/dxvk-merge-step-1' into 'main'
Browse files Browse the repository at this point in the history
Merge from dxvk: commit 3ba395d

See merge request lightspeedrtx/dxvk-remix-nv!601
  • Loading branch information
nsubtil committed Dec 5, 2023
2 parents 24a2026 + d50a3ba commit ac1a6a3
Show file tree
Hide file tree
Showing 5 changed files with 265 additions and 134 deletions.
14 changes: 6 additions & 8 deletions src/dxvk/dxvk_buffer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -128,12 +128,6 @@ namespace dxvk {
"\n usage: ", info.usage));
}

VkMemoryAllocateFlags memoryAllocateFlags = 0;

if (info.usage & VK_BUFFER_USAGE_SHADER_DEVICE_ADDRESS_BIT) {
memoryAllocateFlags |= VK_MEMORY_ALLOCATE_DEVICE_ADDRESS_BIT;
}

VkMemoryDedicatedRequirements dedicatedRequirements;
dedicatedRequirements.sType = VK_STRUCTURE_TYPE_MEMORY_DEDICATED_REQUIREMENTS;
dedicatedRequirements.pNext = VK_NULL_HANDLE;
Expand Down Expand Up @@ -177,11 +171,15 @@ namespace dxvk {
bool isGpuWritable = (m_info.access & (
VK_ACCESS_SHADER_WRITE_BIT |
VK_ACCESS_TRANSFORM_FEEDBACK_WRITE_BIT_EXT)) != 0;
float priority = isGpuWritable ? 1.0f : 0.5f;

DxvkMemoryFlags hints(DxvkMemoryFlag::GpuReadable);

if (isGpuWritable)
hints.set(DxvkMemoryFlag::GpuWritable);

// Ask driver whether we should be using a dedicated allocation
handle.memory = m_memAlloc->alloc(&memReq.memoryRequirements,
dedicatedRequirements, dedMemoryAllocInfo, m_memFlags, memoryAllocateFlags, priority, category);
dedicatedRequirements, dedMemoryAllocInfo, m_memFlags, hints, category);

if (vkd->vkBindBufferMemory(vkd->device(), handle.buffer,
handle.memory.memory(), handle.memory.offset()) != VK_SUCCESS)
Expand Down
9 changes: 6 additions & 3 deletions src/dxvk/dxvk_image.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ namespace dxvk {

m_vkd->vkGetImageMemoryRequirements2(
m_vkd->device(), &memReqInfo, &memReq);

if (info.tiling != VK_IMAGE_TILING_LINEAR && !dedicatedRequirements.prefersDedicatedAllocation) {
memReq.memoryRequirements.size = align(memReq.memoryRequirements.size, memAlloc.bufferImageGranularity());
memReq.memoryRequirements.alignment = align(memReq.memoryRequirements.alignment , memAlloc.bufferImageGranularity());
Expand All @@ -151,16 +151,19 @@ namespace dxvk {
VK_ACCESS_DEPTH_STENCIL_ATTACHMENT_READ_BIT |
VK_ACCESS_DEPTH_STENCIL_ATTACHMENT_WRITE_BIT)) != 0;

float priority = isGpuWritable ? 1.0f : 0.5f;
DxvkMemoryFlags hints(DxvkMemoryFlag::GpuReadable);

if (isGpuWritable)
hints.set(DxvkMemoryFlag::GpuWritable);

if (m_shared) {
dedicatedRequirements.prefersDedicatedAllocation = VK_TRUE;
dedicatedRequirements.requiresDedicatedAllocation = VK_TRUE;
}

// Ask driver whether we should be using a dedicated allocation
m_image.memory = memAlloc.alloc(&memReq.memoryRequirements,
dedicatedRequirements, dedMemoryAllocInfo, memFlags, 0, priority, category);
dedicatedRequirements, dedMemoryAllocInfo, memFlags, hints, category);

// Try to bind the allocated memory slice to the image
if (m_vkd->vkBindImageMemory(m_vkd->device(), m_image.image,
Expand Down
Loading

0 comments on commit ac1a6a3

Please sign in to comment.