mirror of
https://github.com/doitsujin/dxvk.git
synced 2024-12-05 01:24:14 +01:00
[dxvk] Repurpose updateBuffer
Only allow it for very small updates where scheduling a copy command would likely be slower. Some drivers have special paths for tiny updates.
This commit is contained in:
parent
a03c038f03
commit
6a3de28f94
@ -2134,10 +2134,7 @@ namespace dxvk {
|
||||
VkDeviceSize size,
|
||||
const void* data) {
|
||||
bool isHostVisible = buffer->memFlags() & VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT;
|
||||
|
||||
bool replaceBuffer = (size == buffer->info().size)
|
||||
&& (size <= (1 << 18))
|
||||
&& !isHostVisible;
|
||||
bool replaceBuffer = size == buffer->info().size && !isHostVisible;
|
||||
|
||||
DxvkBufferSliceHandle bufferSlice;
|
||||
DxvkCmdBuffer cmdBuffer;
|
||||
@ -2165,34 +2162,11 @@ namespace dxvk {
|
||||
m_execBarriers.recordCommands(m_cmd);
|
||||
}
|
||||
|
||||
// Vulkan specifies that small amounts of data (up to 64kB) can
|
||||
// be copied to a buffer directly if the size is a multiple of
|
||||
// four. Anything else must be copied through a staging buffer.
|
||||
// We'll limit the size to 4kB in order to keep command buffers
|
||||
// reasonably small, we do not know how much data apps may upload.
|
||||
if ((size <= 4096) && ((size & 0x3) == 0) && ((offset & 0x3) == 0)) {
|
||||
m_cmd->cmdUpdateBuffer(
|
||||
cmdBuffer,
|
||||
bufferSlice.handle,
|
||||
bufferSlice.offset,
|
||||
bufferSlice.length,
|
||||
data);
|
||||
} else {
|
||||
auto stagingSlice = m_staging.alloc(CACHE_LINE_SIZE, size);
|
||||
auto stagingHandle = stagingSlice.getSliceHandle();
|
||||
|
||||
std::memcpy(stagingHandle.mapPtr, data, size);
|
||||
|
||||
VkBufferCopy region;
|
||||
region.srcOffset = stagingHandle.offset;
|
||||
region.dstOffset = bufferSlice.offset;
|
||||
region.size = size;
|
||||
|
||||
m_cmd->cmdCopyBuffer(cmdBuffer,
|
||||
stagingHandle.handle, bufferSlice.handle, 1, ®ion);
|
||||
|
||||
m_cmd->trackResource<DxvkAccess::Read>(stagingSlice.buffer());
|
||||
}
|
||||
m_cmd->cmdUpdateBuffer(cmdBuffer,
|
||||
bufferSlice.handle,
|
||||
bufferSlice.offset,
|
||||
bufferSlice.length,
|
||||
data);
|
||||
|
||||
auto& barriers = replaceBuffer
|
||||
? m_initBarriers
|
||||
|
Loading…
Reference in New Issue
Block a user