From d68f437e673ac11f608e937d9f3a0657f9a78783 Mon Sep 17 00:00:00 2001 From: Lioncash Date: Sun, 22 Apr 2018 23:45:02 -0400 Subject: [PATCH] Common: Move BitSet helper functions into the Common namespace --- Source/Core/Common/BitSet.h | 8 ++++---- Source/Core/VideoBackends/D3D/D3DState.cpp | 10 +++++----- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/Source/Core/Common/BitSet.h b/Source/Core/Common/BitSet.h index 752a28faea..06b540d37d 100644 --- a/Source/Core/Common/BitSet.h +++ b/Source/Core/Common/BitSet.h @@ -7,12 +7,12 @@ #include #include "CommonTypes.h" -// Helper functions: - #ifdef _WIN32 #include +namespace Common +{ template constexpr int CountSetBits(T v) { @@ -49,6 +49,8 @@ inline int LeastSignificantSetBit(u64 val) return (int)index; } #else +namespace Common +{ constexpr int CountSetBits(u8 val) { return __builtin_popcount(val); @@ -83,8 +85,6 @@ inline int LeastSignificantSetBit(u64 val) } #endif -namespace Common -{ // Similar to std::bitset, this is a class which encapsulates a bitset, i.e. // using the set bits of an integer to represent a set of integers. Like that // class, it acts like an array of bools: diff --git a/Source/Core/VideoBackends/D3D/D3DState.cpp b/Source/Core/VideoBackends/D3D/D3DState.cpp index 8a2862479b..25742d2a65 100644 --- a/Source/Core/VideoBackends/D3D/D3DState.cpp +++ b/Source/Core/VideoBackends/D3D/D3DState.cpp @@ -28,8 +28,8 @@ void StateManager::Apply() if (!m_dirtyFlags) return; - int textureMaskShift = LeastSignificantSetBit((u32)DirtyFlag_Texture0); - int samplerMaskShift = LeastSignificantSetBit((u32)DirtyFlag_Sampler0); + const int textureMaskShift = Common::LeastSignificantSetBit((u32)DirtyFlag_Texture0); + const int samplerMaskShift = Common::LeastSignificantSetBit((u32)DirtyFlag_Sampler0); u32 dirtyTextures = (m_dirtyFlags & @@ -105,7 +105,7 @@ void StateManager::Apply() while (dirtyTextures) { - int index = LeastSignificantSetBit(dirtyTextures); + const int index = Common::LeastSignificantSetBit(dirtyTextures); if (m_current.textures[index] != m_pending.textures[index]) { D3D::context->PSSetShaderResources(index, 1, &m_pending.textures[index]); @@ -117,7 +117,7 @@ void StateManager::Apply() while (dirtySamplers) { - int index = LeastSignificantSetBit(dirtySamplers); + const int index = Common::LeastSignificantSetBit(dirtySamplers); if (m_current.samplers[index] != m_pending.samplers[index]) { D3D::context->PSSetSamplers(index, 1, &m_pending.samplers[index]); @@ -187,7 +187,7 @@ void StateManager::SetTextureByMask(u32 textureSlotMask, ID3D11ShaderResourceVie { while (textureSlotMask) { - int index = LeastSignificantSetBit(textureSlotMask); + const int index = Common::LeastSignificantSetBit(textureSlotMask); SetTexture(index, srv); textureSlotMask &= ~(1 << index); }