Merge pull request #483 from neobrain/bitfield_fixes

BitField fixes
This commit is contained in:
Tony Wasserka 2014-06-13 20:43:02 +02:00
commit 0bc6b49c07
2 changed files with 25 additions and 4 deletions

View File

@ -125,13 +125,29 @@ public:
// so that we can use this within unions // so that we can use this within unions
BitField() = default; 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) __forceinline BitField& operator=(T val)
{ {
storage = (storage & ~GetMask()) | ((val << position) & GetMask()); storage = (storage & ~GetMask()) | ((val << position) & GetMask());
return *this; return *this;
} }
__forceinline operator T() const __forceinline T Value() const
{ {
if (std::numeric_limits<T>::is_signed) if (std::numeric_limits<T>::is_signed)
{ {
@ -144,6 +160,11 @@ public:
} }
} }
__forceinline operator T() const
{
return Value();
}
private: private:
// StorageType is T for non-enum types and the underlying type of T if // 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 // T is an enumeration. Note that T is wrapped within an enable_if in the

View File

@ -154,7 +154,7 @@ void VertexManager::Flush()
#if defined(_DEBUG) || defined(DEBUGFAST) #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, 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, 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) 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); 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, PRIM_LOG("pixel: tev=%d, ind=%d, texgen=%d, dstalpha=%d, alphatest=0x%x", (int)bpmem.genMode.numtevstages+1, (int)bpmem.genMode.numindstages,
bpmem.genMode.numtexgens, (u32)bpmem.dstalpha.enable, (bpmem.alpha_test.hex>>16)&0xff); (int)bpmem.genMode.numtexgens, (u32)bpmem.dstalpha.enable, (bpmem.alpha_test.hex>>16)&0xff);
#endif #endif
u32 usedtextures = 0; u32 usedtextures = 0;