Skip to content

Commit

Permalink
[d3d11] Skip unnecessary iterations when binding graphics UAVs
Browse files Browse the repository at this point in the history
Some games will unconditionally use a high index for UAVStartSlot.
  • Loading branch information
doitsujin committed Feb 20, 2025
1 parent d48cc1b commit 5490c64
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/d3d11/d3d11_context.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5275,10 +5275,14 @@ namespace dxvk {

if (unlikely(NumUAVs || m_state.om.maxUav)) {
if (likely(NumUAVs != D3D11_KEEP_UNORDERED_ACCESS_VIEWS)) {
uint32_t newMaxUav = NumUAVs ? UAVStartSlot + NumUAVs : 0;
uint32_t newMinUav = NumUAVs ? UAVStartSlot : D3D11_1_UAV_SLOT_COUNT;
uint32_t newMaxUav = NumUAVs ? UAVStartSlot + NumUAVs : 0u;

uint32_t oldMinUav = std::exchange(m_state.om.minUav, newMinUav);
uint32_t oldMaxUav = std::exchange(m_state.om.maxUav, newMaxUav);

for (uint32_t i = 0; i < std::max(oldMaxUav, newMaxUav); i++) {
for (uint32_t i = std::min(oldMinUav, newMinUav);
i < std::max(oldMaxUav, newMaxUav); i++) {
D3D11UnorderedAccessView* uav = nullptr;
uint32_t ctr = ~0u;

Expand Down
1 change: 1 addition & 0 deletions src/d3d11/d3d11_context_state.h
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,7 @@ namespace dxvk {
UINT stencilRef = D3D11_DEFAULT_STENCIL_REFERENCE;

UINT maxRtv = 0u;
UINT minUav = 0u;
UINT maxUav = 0u;

void reset() {
Expand Down

0 comments on commit 5490c64

Please sign in to comment.