Skip to content

Commit

Permalink
Merge pull request #483 from neobrain/bitfield_fixes
Browse files Browse the repository at this point in the history
BitField fixes
  • Loading branch information
neobrain committed Jun 13, 2014
2 parents 27b41c1 + 3d6f9ef commit 0bc6b49
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 4 deletions.
23 changes: 22 additions & 1 deletion Source/Core/Common/BitField.h
Expand Up @@ -125,13 +125,29 @@ struct BitField
// 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)
{
Expand All @@ -144,6 +160,11 @@ struct BitField
}
}

__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
Expand Down
6 changes: 3 additions & 3 deletions Source/Core/VideoCommon/VertexManagerBase.cpp
Expand Up @@ -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)
{
Expand All @@ -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;
Expand Down

0 comments on commit 0bc6b49

Please sign in to comment.