Skip to content

Commit

Permalink
[d3d9] Only bind textures if they are used by the shader
Browse files Browse the repository at this point in the history
  • Loading branch information
misyltoad committed Aug 11, 2021
1 parent c0c1565 commit 5e48035
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
11 changes: 6 additions & 5 deletions src/d3d9/d3d9_device.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5847,11 +5847,11 @@ namespace dxvk {
}


void D3D9DeviceEx::UndirtyTextures() {
for (uint32_t tex = m_dirtyTextures; tex; tex &= tex - 1)
void D3D9DeviceEx::UndirtyTextures(uint32_t mask) {
for (uint32_t tex = mask; tex; tex &= tex - 1)
BindTexture(bit::tzcnt(tex));

m_dirtyTextures = 0;
m_dirtyTextures &= ~mask;
}

void D3D9DeviceEx::MarkTextureBindingDirty(IDirect3DBaseTexture9* texture) {
Expand Down Expand Up @@ -5930,8 +5930,9 @@ namespace dxvk {
if (activeDirtySamplers)
UndirtySamplers(activeDirtySamplers);

if (m_dirtyTextures)
UndirtyTextures();
const uint32_t activeDirtyTextures = m_dirtyTextures & usedSamplerMask;
if (activeDirtyTextures)
UndirtyTextures(activeDirtyTextures);

if (m_flags.test(D3D9DeviceFlag::DirtyBlendState))
BindBlendState();
Expand Down
2 changes: 1 addition & 1 deletion src/d3d9/d3d9_device.h
Original file line number Diff line number Diff line change
Expand Up @@ -837,7 +837,7 @@ namespace dxvk {

void UndirtySamplers(uint32_t mask);

void UndirtyTextures();
void UndirtyTextures(uint32_t mask);

void MarkTextureBindingDirty(IDirect3DBaseTexture9* texture);

Expand Down

0 comments on commit 5e48035

Please sign in to comment.