From 16d3dbc5ea04ea1bd05f32b7041bfb2f6d6e876d Mon Sep 17 00:00:00 2001 From: Tony Wasserka Date: Mon, 21 Apr 2014 22:34:23 +0200 Subject: [PATCH 1/2] BPMemory: Use BitField for the GenMode fields. --- Source/Core/VideoCommon/BPMemory.h | 22 ++++++++++++++-------- Source/Core/VideoCommon/BPStructs.cpp | 6 +++--- 2 files changed, 17 insertions(+), 11 deletions(-) diff --git a/Source/Core/VideoCommon/BPMemory.h b/Source/Core/VideoCommon/BPMemory.h index 5332c3e8d4..09f0efbaf7 100644 --- a/Source/Core/VideoCommon/BPMemory.h +++ b/Source/Core/VideoCommon/BPMemory.h @@ -531,16 +531,22 @@ struct FourTexUnits union GenMode { - struct + enum CullMode : u32 { - u32 numtexgens : 4; // 0xF - u32 numcolchans : 5; // 0x1E0 - u32 multisampling : 1; // 0x200 - u32 numtevstages : 4; // 0x3C00 - u32 cullmode : 2; // 0xC000 - u32 numindstages : 3; // 0x30000 - u32 zfreeze : 5; //0x3C0000 + CULL_NONE = 0, + CULL_BACK = 1, // cull back-facing primitives + CULL_FRONT = 2, // cull front-facing primitives + CULL_ALL = 3, // cull all primitives }; + + BitField< 0,4,u32> numtexgens; + BitField< 4,5,u32> numcolchans; + BitField< 9,1,u32> multisampling; + BitField<10,4,u32> numtevstages; + BitField<14,2,CullMode> cullmode; + BitField<16,3,u32> numindstages; + BitField<19,5,u32> zfreeze; + u32 hex; }; diff --git a/Source/Core/VideoCommon/BPStructs.cpp b/Source/Core/VideoCommon/BPStructs.cpp index 8b904a95f8..d3caaf49d3 100644 --- a/Source/Core/VideoCommon/BPStructs.cpp +++ b/Source/Core/VideoCommon/BPStructs.cpp @@ -91,9 +91,9 @@ void BPWritten(const BPCmd& bp) case BPMEM_GENMODE: // Set the Generation Mode { PRIM_LOG("genmode: texgen=%d, col=%d, multisampling=%d, tev=%d, cullmode=%d, ind=%d, zfeeze=%d", - bpmem.genMode.numtexgens, bpmem.genMode.numcolchans, - bpmem.genMode.multisampling, bpmem.genMode.numtevstages+1, bpmem.genMode.cullmode, - bpmem.genMode.numindstages, bpmem.genMode.zfreeze); + (u32)bpmem.genMode.numtexgens, (u32)bpmem.genMode.numcolchans, + (u32)bpmem.genMode.multisampling, (u32)bpmem.genMode.numtevstages+1, (u32)bpmem.genMode.cullmode, + (u32)bpmem.genMode.numindstages, (u32)bpmem.genMode.zfreeze); // Only call SetGenerationMode when cull mode changes. if (bp.changes & 0xC000) From 762572a08ce17a83a5c5b2c2b968c92778f7221b Mon Sep 17 00:00:00 2001 From: Tony Wasserka Date: Mon, 21 Apr 2014 22:38:08 +0200 Subject: [PATCH 2/2] BPMemory: Fix GenMode using an incorrect number of bits for the number of color chans. --- Source/Core/VideoCommon/BPMemory.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Source/Core/VideoCommon/BPMemory.h b/Source/Core/VideoCommon/BPMemory.h index 09f0efbaf7..a615f5d3a7 100644 --- a/Source/Core/VideoCommon/BPMemory.h +++ b/Source/Core/VideoCommon/BPMemory.h @@ -540,7 +540,9 @@ union GenMode }; BitField< 0,4,u32> numtexgens; - BitField< 4,5,u32> numcolchans; + BitField< 4,3,u32> numcolchans; + // 1 bit unused? + BitField< 8,1,u32> flat_shading; // unconfirmed BitField< 9,1,u32> multisampling; BitField<10,4,u32> numtevstages; BitField<14,2,CullMode> cullmode;