mirror of
https://github.com/doitsujin/dxvk.git
synced 2024-11-30 04:24:11 +01:00
[dxvk] Avoid redundant vertex and index buffer tracking
Same optimization as for regular resources. Mostly reduces load on the cleanup thread.
This commit is contained in:
parent
c3ebf4658c
commit
afe2b487a6
@ -43,6 +43,7 @@ namespace dxvk {
|
||||
m_cmd->beginRecording();
|
||||
|
||||
// Mark all resources as untracked
|
||||
m_vbTracked.clear();
|
||||
m_rcTracked.clear();
|
||||
|
||||
// The current state of the internal command buffer is
|
||||
@ -149,8 +150,16 @@ namespace dxvk {
|
||||
void DxvkContext::bindIndexBuffer(
|
||||
const DxvkBufferSlice& buffer,
|
||||
VkIndexType indexType) {
|
||||
if (!m_state.vi.indexBuffer.matches(buffer)
|
||||
|| (m_state.vi.indexType != indexType)) {
|
||||
bool needsUpdate = !m_state.vi.indexBuffer.matchesBuffer(buffer);
|
||||
|
||||
if (likely(!needsUpdate)) {
|
||||
needsUpdate = !m_state.vi.indexBuffer.matchesRange(buffer)
|
||||
|| m_state.vi.indexType != indexType;
|
||||
} else {
|
||||
m_vbTracked.clr(MaxNumVertexBindings);
|
||||
}
|
||||
|
||||
if (needsUpdate) {
|
||||
m_state.vi.indexBuffer = buffer;
|
||||
m_state.vi.indexType = indexType;
|
||||
|
||||
@ -244,7 +253,14 @@ namespace dxvk {
|
||||
uint32_t binding,
|
||||
const DxvkBufferSlice& buffer,
|
||||
uint32_t stride) {
|
||||
if (!m_state.vi.vertexBuffers[binding].matches(buffer)) {
|
||||
bool needsUpdate = !m_state.vi.vertexBuffers[binding].matchesBuffer(buffer);
|
||||
|
||||
if (likely(!needsUpdate))
|
||||
needsUpdate = !m_state.vi.vertexBuffers[binding].matchesRange(buffer);
|
||||
else
|
||||
m_vbTracked.clr(binding);
|
||||
|
||||
if (needsUpdate) {
|
||||
m_state.vi.vertexBuffers[binding] = buffer;
|
||||
m_flags.set(DxvkContextFlag::GpDirtyVertexBuffers);
|
||||
}
|
||||
@ -3730,8 +3746,9 @@ namespace dxvk {
|
||||
bufferInfo.buffer.buffer,
|
||||
bufferInfo.buffer.offset,
|
||||
m_state.vi.indexType);
|
||||
m_cmd->trackResource(
|
||||
m_state.vi.indexBuffer.buffer());
|
||||
|
||||
if (m_vbTracked.set(MaxNumVertexBindings))
|
||||
m_cmd->trackResource(m_state.vi.indexBuffer.buffer());
|
||||
} else {
|
||||
m_cmd->cmdBindIndexBuffer(
|
||||
m_device->dummyBufferHandle(),
|
||||
@ -3761,7 +3778,8 @@ namespace dxvk {
|
||||
buffers[i] = vbo.buffer.buffer;
|
||||
offsets[i] = vbo.buffer.offset;
|
||||
|
||||
m_cmd->trackResource(m_state.vi.vertexBuffers[binding].buffer());
|
||||
if (m_vbTracked.set(binding))
|
||||
m_cmd->trackResource(m_state.vi.vertexBuffers[binding].buffer());
|
||||
} else {
|
||||
buffers[i] = m_device->dummyBufferHandle();
|
||||
offsets[i] = 0;
|
||||
|
@ -994,7 +994,8 @@ namespace dxvk {
|
||||
VkDescriptorSet m_gpSet = VK_NULL_HANDLE;
|
||||
VkDescriptorSet m_cpSet = VK_NULL_HANDLE;
|
||||
|
||||
DxvkBindingSet<MaxNumResourceSlots> m_rcTracked;
|
||||
DxvkBindingSet<MaxNumVertexBindings + 1> m_vbTracked;
|
||||
DxvkBindingSet<MaxNumResourceSlots> m_rcTracked;
|
||||
|
||||
std::array<DxvkShaderResourceSlot, MaxNumResourceSlots> m_rc;
|
||||
std::array<DxvkDescriptorInfo, MaxNumActiveBindings> m_descInfos;
|
||||
|
Loading…
Reference in New Issue
Block a user