1
0
mirror of https://github.com/doitsujin/dxvk.git synced 2024-11-30 13:24:10 +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:
Philip Rebohle 2019-06-27 01:51:15 +02:00
parent c3ebf4658c
commit afe2b487a6
No known key found for this signature in database
GPG Key ID: C8CC613427A31C99
2 changed files with 26 additions and 7 deletions

View File

@ -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;

View File

@ -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;