Skip to content

Commit

Permalink
D3D: Moved setting texture by slot mask into StateManager
Browse files Browse the repository at this point in the history
  • Loading branch information
kayru committed Dec 17, 2014
1 parent 764aee6 commit 5688c27
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 8 deletions.
11 changes: 11 additions & 0 deletions Source/Core/VideoBackends/D3D/D3DState.cpp
Expand Up @@ -215,6 +215,17 @@ u32 StateManager::UnsetTexture(ID3D11ShaderResourceView* srv)
return mask;
}

void StateManager::SetTextureByMask(u32 textureSlotMask, ID3D11ShaderResourceView* srv)
{
while (textureSlotMask)
{
unsigned long index;
_BitScanForward(&index, textureSlotMask);
SetTexture(index, srv);
textureSlotMask &= ~(1 << index);
}
}

} // namespace D3D

ID3D11SamplerState* StateCache::Get(SamplerState state)
Expand Down
3 changes: 2 additions & 1 deletion Source/Core/VideoBackends/D3D/D3DState.h
Expand Up @@ -235,7 +235,8 @@ class StateManager
}

// removes currently set texture from all slots, returns mask of previously bound slots
u32 StateManager::UnsetTexture(ID3D11ShaderResourceView* srv);
u32 UnsetTexture(ID3D11ShaderResourceView* srv);
void SetTextureByMask(u32 textureSlotMask, ID3D11ShaderResourceView* srv);

// call this immediately before any drawing operation or to explicitly apply pending resource state changes
void Apply();
Expand Down
8 changes: 1 addition & 7 deletions Source/Core/VideoBackends/D3D/TextureCache.cpp
Expand Up @@ -174,13 +174,7 @@ void TextureCache::TCacheEntry::FromRenderTarget(u32 dstAddr, unsigned int dstFo
g_renderer->RestoreAPIState();

// Restore old texture in all previously used slots, if any
while (textureSlotMask)
{
unsigned long index;
_BitScanForward(&index, textureSlotMask);
D3D::stateman->SetTexture(index, texture->GetSRV());
textureSlotMask &= ~(1 << index);
}
D3D::stateman->SetTextureByMask(textureSlotMask, texture->GetSRV());
}

if (!g_ActiveConfig.bCopyEFBToTexture)
Expand Down

0 comments on commit 5688c27

Please sign in to comment.