summaryrefslogtreecommitdiff
path: root/Source/Core
diff options
context:
space:
mode:
authorTony Wasserka <neobrainx@gmail.com>2014-06-13 20:43:02 +0200
committerTony Wasserka <neobrainx@gmail.com>2014-06-13 20:43:02 +0200
commit0bc6b49c0798a1bc5ef3449ea0b87c318a82f415 (patch)
treeb37e2ea41f7a76ea1883da804c39ef5debf9579d /Source/Core
parent27b41c1f645d906ece5b9f40adb81bbea55865de (diff)
parent3d6f9ef89788dbb64c2a6b4becb84905667b1485 (diff)
Merge pull request #483 from neobrain/bitfield_fixes
BitField fixes
Diffstat (limited to 'Source/Core')
-rw-r--r--Source/Core/Common/BitField.h23
-rw-r--r--Source/Core/VideoCommon/VertexManagerBase.cpp6
2 files changed, 25 insertions, 4 deletions
diff --git a/Source/Core/Common/BitField.h b/Source/Core/Common/BitField.h
index f7a0a0175c..8ec80de9c0 100644
--- a/Source/Core/Common/BitField.h
+++ b/Source/Core/Common/BitField.h
@@ -125,13 +125,29 @@ public:
// so that we can use this within unions
BitField() = default;
+#ifndef _WIN32
+ // We explicitly delete the copy assigment operator here, because the
+ // default copy assignment would copy the full storage value, rather than
+ // just the bits relevant to this particular bit field.
+ // Ideally, we would just implement the copy assignment to copy only the
+ // relevant bits, but this requires compiler support for unrestricted
+ // unions.
+ // MSVC 2013 has no support for this, hence we disable this code on
+ // Windows (so that the default copy assignment operator will be used).
+ // For any C++11 conformant compiler we delete the operator to make sure
+ // we never use this inappropriate operator to begin with.
+ // TODO: Implement this operator properly once all target compilers
+ // support unrestricted unions.
+ BitField& operator=(const BitField&) = delete;
+#endif
+
__forceinline BitField& operator=(T val)
{
storage = (storage & ~GetMask()) | ((val << position) & GetMask());
return *this;
}
- __forceinline operator T() const
+ __forceinline T Value() const
{
if (std::numeric_limits<T>::is_signed)
{
@@ -144,6 +160,11 @@ public:
}
}
+ __forceinline operator T() const
+ {
+ return Value();
+ }
+
private:
// StorageType is T for non-enum types and the underlying type of T if
// T is an enumeration. Note that T is wrapped within an enable_if in the
diff --git a/Source/Core/VideoCommon/VertexManagerBase.cpp b/Source/Core/VideoCommon/VertexManagerBase.cpp
index 5e44a5aa0e..84db7cffe8 100644
--- a/Source/Core/VideoCommon/VertexManagerBase.cpp
+++ b/Source/Core/VideoCommon/VertexManagerBase.cpp
@@ -154,7 +154,7 @@ void VertexManager::Flush()
#if defined(_DEBUG) || defined(DEBUGFAST)
PRIM_LOG("frame%d:\n texgen=%d, numchan=%d, dualtex=%d, ztex=%d, cole=%d, alpe=%d, ze=%d", g_ActiveConfig.iSaveTargetId, xfmem.numTexGen.numTexGens,
xfmem.numChan.numColorChans, xfmem.dualTexTrans.enabled, bpmem.ztex2.op,
- bpmem.blendmode.colorupdate, bpmem.blendmode.alphaupdate, bpmem.zmode.updateenable);
+ (int)bpmem.blendmode.colorupdate, (int)bpmem.blendmode.alphaupdate, (int)bpmem.zmode.updateenable);
for (unsigned int i = 0; i < xfmem.numChan.numColorChans; ++i)
{
@@ -175,8 +175,8 @@ void VertexManager::Flush()
xfmem.postMtxInfo[i].index, xfmem.postMtxInfo[i].normalize);
}
- PRIM_LOG("pixel: tev=%d, ind=%d, texgen=%d, dstalpha=%d, alphatest=0x%x", bpmem.genMode.numtevstages+1, bpmem.genMode.numindstages,
- bpmem.genMode.numtexgens, (u32)bpmem.dstalpha.enable, (bpmem.alpha_test.hex>>16)&0xff);
+ PRIM_LOG("pixel: tev=%d, ind=%d, texgen=%d, dstalpha=%d, alphatest=0x%x", (int)bpmem.genMode.numtevstages+1, (int)bpmem.genMode.numindstages,
+ (int)bpmem.genMode.numtexgens, (u32)bpmem.dstalpha.enable, (bpmem.alpha_test.hex>>16)&0xff);
#endif
u32 usedtextures = 0;