Skip to content

Commit

Permalink
[dxvk] Fix xfb counter buffer draw tracking
Browse files Browse the repository at this point in the history
  • Loading branch information
doitsujin committed Aug 23, 2023
1 parent 915244c commit c2cd129
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
13 changes: 8 additions & 5 deletions src/dxvk/dxvk_context.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4832,13 +4832,14 @@ namespace dxvk {
VkDeviceSize ctrOffsets[MaxNumXfbBuffers];

for (uint32_t i = 0; i < MaxNumXfbBuffers; i++) {
auto physSlice = m_state.xfb.counters[i].getSliceHandle();
m_state.xfb.activeCounters[i] = m_state.xfb.counters[i];
auto physSlice = m_state.xfb.activeCounters[i].getSliceHandle();

ctrBuffers[i] = physSlice.handle;
ctrOffsets[i] = physSlice.offset;

if (physSlice.handle != VK_NULL_HANDLE)
m_cmd->trackResource<DxvkAccess::Read>(m_state.xfb.counters[i].buffer());
m_cmd->trackResource<DxvkAccess::Read>(m_state.xfb.activeCounters[i].buffer());
}

m_cmd->cmdBeginTransformFeedback(
Expand All @@ -4858,13 +4859,15 @@ namespace dxvk {
VkDeviceSize ctrOffsets[MaxNumXfbBuffers];

for (uint32_t i = 0; i < MaxNumXfbBuffers; i++) {
auto physSlice = m_state.xfb.counters[i].getSliceHandle();
auto physSlice = m_state.xfb.activeCounters[i].getSliceHandle();

ctrBuffers[i] = physSlice.handle;
ctrOffsets[i] = physSlice.offset;

if (physSlice.handle != VK_NULL_HANDLE)
m_cmd->trackResource<DxvkAccess::Write>(m_state.xfb.counters[i].buffer());
m_cmd->trackResource<DxvkAccess::Write>(m_state.xfb.activeCounters[i].buffer());

m_state.xfb.activeCounters[i] = DxvkBufferSlice();
}

m_queryManager.endQueries(m_cmd,
Expand Down Expand Up @@ -6073,7 +6076,7 @@ namespace dxvk {
&& m_state.gp.flags.test(DxvkGraphicsPipelineFlag::HasTransformFeedback)) {
for (uint32_t i = 0; i < MaxNumXfbBuffers && !requiresBarrier; i++) {
const auto& xfbBufferSlice = m_state.xfb.buffers[i];
const auto& xfbCounterSlice = m_state.xfb.counters[i];
const auto& xfbCounterSlice = m_state.xfb.activeCounters[i];

if (xfbBufferSlice.length()) {
requiresBarrier = this->checkBufferBarrier<DoEmit>(xfbBufferSlice,
Expand Down
1 change: 1 addition & 0 deletions src/dxvk/dxvk_context_state.h
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,7 @@ namespace dxvk {
struct DxvkXfbState {
std::array<DxvkBufferSlice, MaxNumXfbBuffers> buffers;
std::array<DxvkBufferSlice, MaxNumXfbBuffers> counters;
std::array<DxvkBufferSlice, MaxNumXfbBuffers> activeCounters;
};


Expand Down

0 comments on commit c2cd129

Please sign in to comment.