From 2ce0f42c146c34002665168d0b9422d767b18332 Mon Sep 17 00:00:00 2001 From: Lioncash Date: Sun, 22 Apr 2018 23:43:05 -0400 Subject: [PATCH 1/3] Common: Move BitSet into the Common namespace This should be under the common namespace, considering where it's living --- Source/Core/Common/BitSet.h | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/Source/Core/Common/BitSet.h b/Source/Core/Common/BitSet.h index f8506e7c89..752a28faea 100644 --- a/Source/Core/Common/BitSet.h +++ b/Source/Core/Common/BitSet.h @@ -83,8 +83,7 @@ inline int LeastSignificantSetBit(u64 val) } #endif -// namespace avoids conflict with OS X Carbon; don't use BitSet directly -namespace BS +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 @@ -207,9 +206,9 @@ public: constexpr Iterator end() const { return Iterator(m_val, -1); } IntTy m_val; }; -} +} // namespace Common -typedef BS::BitSet BitSet8; -typedef BS::BitSet BitSet16; -typedef BS::BitSet BitSet32; -typedef BS::BitSet BitSet64; +using BitSet8 = Common::BitSet; +using BitSet16 = Common::BitSet; +using BitSet32 = Common::BitSet; +using BitSet64 = Common::BitSet; From d68f437e673ac11f608e937d9f3a0657f9a78783 Mon Sep 17 00:00:00 2001 From: Lioncash Date: Sun, 22 Apr 2018 23:45:02 -0400 Subject: [PATCH 2/3] 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); } From 46375793750eccf707e1f0ee24d649656d073950 Mon Sep 17 00:00:00 2001 From: Lioncash Date: Sun, 22 Apr 2018 23:56:28 -0400 Subject: [PATCH 3/3] Common: Amend CommonTypes include within BitSet.h We do includes relative to the root, rather than direct pathing. --- Source/Core/Common/BitSet.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/Core/Common/BitSet.h b/Source/Core/Common/BitSet.h index 06b540d37d..4425b6067c 100644 --- a/Source/Core/Common/BitSet.h +++ b/Source/Core/Common/BitSet.h @@ -5,7 +5,7 @@ #include #include #include -#include "CommonTypes.h" +#include "Common/CommonTypes.h" #ifdef _WIN32