mirror of
https://github.com/doitsujin/dxvk.git
synced 2024-12-02 01:24:11 +01:00
[dxvk] Use vkCmdUpdateBuffer to clear tiny buffers
While this might consume a few more CPU cycles, UpdateBuffer may be cheaper on the GPU for very small buffers, so we should use it instead. Also seems to fix rendering issues in Far Cry Primal for unknown reasons.
This commit is contained in:
parent
8543f96413
commit
311661e404
@ -260,19 +260,32 @@ namespace dxvk {
|
||||
uint32_t value) {
|
||||
this->spillRenderPass();
|
||||
|
||||
if (length == buffer->info().size)
|
||||
length = align(length, 4);
|
||||
|
||||
length = align(length, sizeof(uint32_t));
|
||||
auto slice = buffer->getSliceHandle(offset, length);
|
||||
|
||||
if (m_barriers.isBufferDirty(slice, DxvkAccess::Write))
|
||||
m_barriers.recordCommands(m_cmd);
|
||||
|
||||
m_cmd->cmdFillBuffer(
|
||||
slice.handle,
|
||||
slice.offset,
|
||||
slice.length,
|
||||
value);
|
||||
constexpr VkDeviceSize updateThreshold = 256;
|
||||
|
||||
if (length <= updateThreshold * sizeof(uint32_t)) {
|
||||
std::array<uint32_t, updateThreshold> data;
|
||||
|
||||
for (uint32_t i = 0; i < length / sizeof(uint32_t); i++)
|
||||
data[i] = value;
|
||||
|
||||
m_cmd->cmdUpdateBuffer(
|
||||
slice.handle,
|
||||
slice.offset,
|
||||
slice.length,
|
||||
data.data());
|
||||
} else {
|
||||
m_cmd->cmdFillBuffer(
|
||||
slice.handle,
|
||||
slice.offset,
|
||||
slice.length,
|
||||
value);
|
||||
}
|
||||
|
||||
m_barriers.accessBuffer(slice,
|
||||
VK_PIPELINE_STAGE_TRANSFER_BIT,
|
||||
|
Loading…
Reference in New Issue
Block a user