mirror of
https://github.com/doitsujin/dxvk.git
synced 2025-01-19 05:52:11 +01:00
[dxvk] Use GPU-local buffer in clearCompressedColorImage
Saves VA space in applications that do not initialize their textures..
This commit is contained in:
parent
436357e280
commit
bea16263e4
@ -514,10 +514,8 @@ namespace dxvk {
|
|||||||
image->info().format,
|
image->info().format,
|
||||||
image->mipLevelExtent(subresources.baseMipLevel));
|
image->mipLevelExtent(subresources.baseMipLevel));
|
||||||
|
|
||||||
auto stagingSlice = m_staging.alloc(CACHE_LINE_SIZE, dataSize);
|
auto zeroBuffer = createZeroBuffer(dataSize);
|
||||||
auto stagingHandle = stagingSlice.getSliceHandle();
|
auto zeroHandle = zeroBuffer->getSliceHandle();
|
||||||
|
|
||||||
std::memset(stagingHandle.mapPtr, 0, dataSize);
|
|
||||||
|
|
||||||
if (m_execBarriers.isImageDirty(image, subresources, DxvkAccess::Write))
|
if (m_execBarriers.isImageDirty(image, subresources, DxvkAccess::Write))
|
||||||
m_execBarriers.recordCommands(m_cmd);
|
m_execBarriers.recordCommands(m_cmd);
|
||||||
@ -537,7 +535,7 @@ namespace dxvk {
|
|||||||
|
|
||||||
for (uint32_t layer = 0; layer < subresources.layerCount; layer++) {
|
for (uint32_t layer = 0; layer < subresources.layerCount; layer++) {
|
||||||
VkBufferImageCopy region;
|
VkBufferImageCopy region;
|
||||||
region.bufferOffset = stagingHandle.offset;
|
region.bufferOffset = zeroHandle.offset;
|
||||||
region.bufferRowLength = 0;
|
region.bufferRowLength = 0;
|
||||||
region.bufferImageHeight = 0;
|
region.bufferImageHeight = 0;
|
||||||
region.imageSubresource = vk::makeSubresourceLayers(
|
region.imageSubresource = vk::makeSubresourceLayers(
|
||||||
@ -546,7 +544,7 @@ namespace dxvk {
|
|||||||
region.imageExtent = extent;
|
region.imageExtent = extent;
|
||||||
|
|
||||||
m_cmd->cmdCopyBufferToImage(DxvkCmdBuffer::ExecBuffer,
|
m_cmd->cmdCopyBufferToImage(DxvkCmdBuffer::ExecBuffer,
|
||||||
stagingHandle.handle, image->handle(),
|
zeroHandle.handle, image->handle(),
|
||||||
image->pickLayout(VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL),
|
image->pickLayout(VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL),
|
||||||
1, ®ion);
|
1, ®ion);
|
||||||
}
|
}
|
||||||
@ -562,7 +560,7 @@ namespace dxvk {
|
|||||||
image->info().access);
|
image->info().access);
|
||||||
|
|
||||||
m_cmd->trackResource<DxvkAccess::Write>(image);
|
m_cmd->trackResource<DxvkAccess::Write>(image);
|
||||||
m_cmd->trackResource<DxvkAccess::Read>(stagingSlice.buffer());
|
m_cmd->trackResource<DxvkAccess::Read>(zeroBuffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -4793,5 +4791,27 @@ namespace dxvk {
|
|||||||
|
|
||||||
return m_cpLookupCache[idx];
|
return m_cpLookupCache[idx];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Rc<DxvkBuffer> DxvkContext::createZeroBuffer(
|
||||||
|
VkDeviceSize size) {
|
||||||
|
if (m_zeroBuffer != nullptr && m_zeroBuffer->info().size >= size)
|
||||||
|
return m_zeroBuffer;
|
||||||
|
|
||||||
|
DxvkBufferCreateInfo bufInfo;
|
||||||
|
bufInfo.size = align<VkDeviceSize>(size, 1 << 20);
|
||||||
|
bufInfo.usage = VK_BUFFER_USAGE_TRANSFER_DST_BIT
|
||||||
|
| VK_BUFFER_USAGE_TRANSFER_SRC_BIT;
|
||||||
|
bufInfo.stages = VK_PIPELINE_STAGE_TRANSFER_BIT;
|
||||||
|
bufInfo.access = VK_ACCESS_TRANSFER_WRITE_BIT
|
||||||
|
| VK_ACCESS_TRANSFER_READ_BIT;
|
||||||
|
|
||||||
|
m_zeroBuffer = m_device->createBuffer(bufInfo,
|
||||||
|
VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT);
|
||||||
|
|
||||||
|
clearBuffer(m_zeroBuffer, 0, size, 0);
|
||||||
|
m_execBarriers.recordCommands(m_cmd);
|
||||||
|
return m_zeroBuffer;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
@ -1014,6 +1014,7 @@ namespace dxvk {
|
|||||||
|
|
||||||
Rc<DxvkCommandList> m_cmd;
|
Rc<DxvkCommandList> m_cmd;
|
||||||
Rc<DxvkDescriptorPool> m_descPool;
|
Rc<DxvkDescriptorPool> m_descPool;
|
||||||
|
Rc<DxvkBuffer> m_zeroBuffer;
|
||||||
|
|
||||||
DxvkContextFlags m_flags;
|
DxvkContextFlags m_flags;
|
||||||
DxvkContextState m_state;
|
DxvkContextState m_state;
|
||||||
@ -1217,6 +1218,9 @@ namespace dxvk {
|
|||||||
DxvkComputePipeline* lookupComputePipeline(
|
DxvkComputePipeline* lookupComputePipeline(
|
||||||
const DxvkComputePipelineShaders& shaders);
|
const DxvkComputePipelineShaders& shaders);
|
||||||
|
|
||||||
|
Rc<DxvkBuffer> createZeroBuffer(
|
||||||
|
VkDeviceSize size);
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
Loading…
x
Reference in New Issue
Block a user