summaryrefslogtreecommitdiff
path: root/Source/Core/VideoCommon
diff options
context:
space:
mode:
authorPierre Bourdon <delroth@gmail.com>2014-03-26 00:08:58 +0100
committerPierre Bourdon <delroth@gmail.com>2014-03-26 00:08:58 +0100
commitb4337a21928745bef151c8ab665138f7a435f198 (patch)
treef3792e8f08d1c847059a2354db188a8d62fdd2df /Source/Core/VideoCommon
parent6351f28ab41172d7b07626da737d691ce88c9285 (diff)
parent16105db7092707bc130a345ed1e630e2ef1f7747 (diff)
Merge pull request #204 from neobrain/bitfield_cleanup
Bitfield cleanup
Diffstat (limited to 'Source/Core/VideoCommon')
-rw-r--r--Source/Core/VideoCommon/BPFunctions.cpp49
-rw-r--r--Source/Core/VideoCommon/BPFunctions.h2
-rw-r--r--Source/Core/VideoCommon/BPMemory.cpp6
-rw-r--r--Source/Core/VideoCommon/BPMemory.h281
-rw-r--r--Source/Core/VideoCommon/BPStructs.cpp19
-rw-r--r--Source/Core/VideoCommon/Debugger.cpp2
-rw-r--r--Source/Core/VideoCommon/PixelShaderManager.cpp12
-rw-r--r--Source/Core/VideoCommon/RenderBase.cpp4
-rw-r--r--Source/Core/VideoCommon/RenderBase.h6
-rw-r--r--Source/Core/VideoCommon/TextureCacheBase.cpp6
-rw-r--r--Source/Core/VideoCommon/TextureCacheBase.h4
-rw-r--r--Source/Core/VideoCommon/VertexManagerBase.cpp2
12 files changed, 209 insertions, 184 deletions
diff --git a/Source/Core/VideoCommon/BPFunctions.cpp b/Source/Core/VideoCommon/BPFunctions.cpp
index 1149392179..58362f1a57 100644
--- a/Source/Core/VideoCommon/BPFunctions.cpp
+++ b/Source/Core/VideoCommon/BPFunctions.cpp
@@ -79,10 +79,10 @@ void SetColorMask()
g_renderer->SetColorMask();
}
-void CopyEFB(u32 dstAddr, unsigned int dstFormat, unsigned int srcFormat,
+void CopyEFB(u32 dstAddr, unsigned int dstFormat, PEControl::PixelFormat srcFormat,
const EFBRectangle& srcRect, bool isIntensity, bool scaleByHalf)
{
- // bpmem.zcontrol.pixel_format to PIXELFMT_Z24 is when the game wants to copy from ZBuffer (Zbuffer uses 24-bit Format)
+ // bpmem.zcontrol.pixel_format to PEControl::Z24 is when the game wants to copy from ZBuffer (Zbuffer uses 24-bit Format)
if (g_ActiveConfig.bEFBCopyEnable)
{
TextureCache::CopyRenderTargetToTexture(dstAddr, dstFormat, srcFormat,
@@ -111,11 +111,12 @@ void ClearScreen(const EFBRectangle &rc)
bool colorEnable = bpmem.blendmode.colorupdate;
bool alphaEnable = bpmem.blendmode.alphaupdate;
bool zEnable = bpmem.zmode.updateenable;
+ auto pixel_format = bpmem.zcontrol.pixel_format;
// (1): Disable unused color channels
- if (bpmem.zcontrol.pixel_format == PIXELFMT_RGB8_Z24 ||
- bpmem.zcontrol.pixel_format == PIXELFMT_RGB565_Z16 ||
- bpmem.zcontrol.pixel_format == PIXELFMT_Z24)
+ if (pixel_format == PEControl::RGB8_Z24 ||
+ pixel_format == PEControl::RGB565_Z16 ||
+ pixel_format == PEControl::Z24)
{
alphaEnable = false;
}
@@ -126,11 +127,11 @@ void ClearScreen(const EFBRectangle &rc)
u32 z = bpmem.clearZValue;
// (2) drop additional accuracy
- if (bpmem.zcontrol.pixel_format == PIXELFMT_RGBA6_Z24)
+ if (pixel_format == PEControl::RGBA6_Z24)
{
color = RGBA8ToRGBA6ToRGBA8(color);
}
- else if (bpmem.zcontrol.pixel_format == PIXELFMT_RGB565_Z16)
+ else if (pixel_format == PEControl::RGB565_Z16)
{
color = RGBA8ToRGB565ToRGBA8(color);
z = Z24ToZ16ToZ24(z);
@@ -156,8 +157,8 @@ void OnPixelFormatChange()
!g_ActiveConfig.backend_info.bSupportsFormatReinterpretation)
return;
- u32 old_format = Renderer::GetPrevPixelFormat();
- u32 new_format = bpmem.zcontrol.pixel_format;
+ auto old_format = Renderer::GetPrevPixelFormat();
+ auto new_format = bpmem.zcontrol.pixel_format;
// no need to reinterpret pixel data in these cases
if (new_format == old_format || old_format == (unsigned int)-1)
@@ -166,31 +167,31 @@ void OnPixelFormatChange()
// Check for pixel format changes
switch (old_format)
{
- case PIXELFMT_RGB8_Z24:
- case PIXELFMT_Z24:
+ case PEControl::RGB8_Z24:
+ case PEControl::Z24:
// Z24 and RGB8_Z24 are treated equal, so just return in this case
- if (new_format == PIXELFMT_RGB8_Z24 || new_format == PIXELFMT_Z24)
+ if (new_format == PEControl::RGB8_Z24 || new_format == PEControl::Z24)
goto skip;
- if (new_format == PIXELFMT_RGBA6_Z24)
+ if (new_format == PEControl::RGBA6_Z24)
convtype = 0;
- else if (new_format == PIXELFMT_RGB565_Z16)
+ else if (new_format == PEControl::RGB565_Z16)
convtype = 1;
break;
- case PIXELFMT_RGBA6_Z24:
- if (new_format == PIXELFMT_RGB8_Z24 ||
- new_format == PIXELFMT_Z24)
+ case PEControl::RGBA6_Z24:
+ if (new_format == PEControl::RGB8_Z24 ||
+ new_format == PEControl::Z24)
convtype = 2;
- else if (new_format == PIXELFMT_RGB565_Z16)
+ else if (new_format == PEControl::RGB565_Z16)
convtype = 3;
break;
- case PIXELFMT_RGB565_Z16:
- if (new_format == PIXELFMT_RGB8_Z24 ||
- new_format == PIXELFMT_Z24)
+ case PEControl::RGB565_Z16:
+ if (new_format == PEControl::RGB8_Z24 ||
+ new_format == PEControl::Z24)
convtype = 4;
- else if (new_format == PIXELFMT_RGBA6_Z24)
+ else if (new_format == PEControl::RGBA6_Z24)
convtype = 5;
break;
@@ -200,14 +201,14 @@ void OnPixelFormatChange()
if (convtype == -1)
{
- ERROR_LOG(VIDEO, "Unhandled EFB format change: %d to %d\n", old_format, new_format);
+ ERROR_LOG(VIDEO, "Unhandled EFB format change: %d to %d\n", static_cast<int>(old_format), static_cast<int>(new_format));
goto skip;
}
g_renderer->ReinterpretPixelData(convtype);
skip:
- DEBUG_LOG(VIDEO, "pixelfmt: pixel=%d, zc=%d", new_format, bpmem.zcontrol.zformat);
+ DEBUG_LOG(VIDEO, "pixelfmt: pixel=%d, zc=%d", static_cast<int>(new_format), static_cast<int>(bpmem.zcontrol.zformat));
Renderer::StorePixelFormat(new_format);
}
diff --git a/Source/Core/VideoCommon/BPFunctions.h b/Source/Core/VideoCommon/BPFunctions.h
index dfaaa39600..77b7f86c91 100644
--- a/Source/Core/VideoCommon/BPFunctions.h
+++ b/Source/Core/VideoCommon/BPFunctions.h
@@ -31,7 +31,7 @@ void SetBlendMode();
void SetDitherMode();
void SetLogicOpMode();
void SetColorMask();
-void CopyEFB(u32 dstAddr, unsigned int dstFormat, unsigned int srcFormat,
+void CopyEFB(u32 dstAddr, unsigned int dstFormat, PEControl::PixelFormat srcFormat,
const EFBRectangle& srcRect, bool isIntensity, bool scaleByHalf);
void ClearScreen(const EFBRectangle &rc);
void OnPixelFormatChange();
diff --git a/Source/Core/VideoCommon/BPMemory.cpp b/Source/Core/VideoCommon/BPMemory.cpp
index 7902bf70a6..1f74d8d36d 100644
--- a/Source/Core/VideoCommon/BPMemory.cpp
+++ b/Source/Core/VideoCommon/BPMemory.cpp
@@ -92,7 +92,7 @@ void GetBPRegInfo(const u8* data, char* name, size_t name_size, char* desc, size
case BPMEM_ZCOMPARE:
{
SetRegName(BPMEM_ZCOMPARE);
- PE_CONTROL config; config.hex = cmddata;
+ PEControl config; config.hex = cmddata;
const char* pixel_formats[] = { "RGB8_Z24", "RGBA6_Z24", "RGB565_Z16", "Z24", "Y8", "U8", "V8", "YUV420" };
const char* zformats[] = { "linear", "compressed (near)", "compressed (mid)", "compressed (far)", "inv linear", "compressed (inv near)", "compressed (inv mid)", "compressed (inv far)" };
snprintf(desc, desc_size, "EFB pixel format: %s\n"
@@ -158,7 +158,7 @@ void GetBPRegInfo(const u8* data, char* name, size_t name_size, char* desc, size
no_yes[copy.half_scale],
no_yes[copy.scale_invert],
no_yes[copy.clear],
- copy.frame_to_field,
+ (u32)copy.frame_to_field,
no_yes[copy.copy_to_xfb],
no_yes[copy.intensity_fmt],
no_yes[copy.auto_conv]);
@@ -292,7 +292,7 @@ void GetBPRegInfo(const u8* data, char* name, size_t name_size, char* desc, size
snprintf(desc, desc_size, "test 1: %s (ref: %#02x)\n"
"test 2: %s (ref: %#02x)\n"
"logic: %s\n",
- functions[test.comp0], test.ref0, functions[test.comp1], test.ref1, logic[test.logic]);
+ functions[test.comp0], (int)test.ref0, functions[test.comp1], (int)test.ref1, logic[test.logic]);
break;
}
diff --git a/Source/Core/VideoCommon/BPMemory.h b/Source/Core/VideoCommon/BPMemory.h
index 2bb35d92c0..1519d542fd 100644
--- a/Source/Core/VideoCommon/BPMemory.h
+++ b/Source/Core/VideoCommon/BPMemory.h
@@ -4,6 +4,7 @@
#pragma once
+#include "Common/BitField.h"
#include "Common/Common.h"
#pragma pack(4)
@@ -148,27 +149,6 @@
#define GX_TEVREG1 2
#define GX_TEVREG2 3
-#define ALPHACMP_NEVER 0
-#define ALPHACMP_LESS 1
-#define ALPHACMP_EQUAL 2
-#define ALPHACMP_LEQUAL 3
-#define ALPHACMP_GREATER 4
-#define ALPHACMP_NEQUAL 5
-#define ALPHACMP_GEQUAL 6
-#define ALPHACMP_ALWAYS 7
-
-enum Compare
-{
- COMPARE_NEVER = 0,
- COMPARE_LESS,
- COMPARE_EQUAL,
- COMPARE_LEQUAL,
- COMPARE_GREATER,
- COMPARE_NEQUAL,
- COMPARE_GEQUAL,
- COMPARE_ALWAYS
-};
-
#define ZTEXTURE_DISABLE 0
#define ZTEXTURE_ADD 1
#define ZTEXTURE_REPLACE 2
@@ -178,14 +158,6 @@ enum Compare
#define TevBias_SUBHALF 2
#define TevBias_COMPARE 3
-enum AlphaOp
-{
- ALPHAOP_AND = 0,
- ALPHAOP_OR,
- ALPHAOP_XOR,
- ALPHAOP_XNOR,
-};
-
union IND_MTXA
{
struct
@@ -609,31 +581,52 @@ union X10Y10
// Framebuffer/pixel stuff (incl fog)
-#define GX_BL_ZERO 0
-#define GX_BL_ONE 1
-#define GX_BL_SRCCLR 2 // for dst factor
-#define GX_BL_INVSRCCLR 3 // for dst factor
-#define GX_BL_SRCALPHA 4
-#define GX_BL_INVSRCALPHA 5
-#define GX_BL_DSTALPHA 6
-#define GX_BL_INVDSTALPHA 7
-#define GX_BL_DSTCLR GX_BL_SRCCLR // for src factor
-#define GX_BL_INVDSTCLR GX_BL_INVSRCCLR // for src factor
-
union BlendMode
{
- struct
+ enum BlendFactor : u32
+ {
+ ZERO = 0,
+ ONE = 1,
+ SRCCLR = 2, // for dst factor
+ INVSRCCLR = 3, // for dst factor
+ DSTCLR = SRCCLR, // for src factor
+ INVDSTCLR = INVSRCCLR, // for src factor
+ SRCALPHA = 4,
+ INVSRCALPHA = 5,
+ DSTALPHA = 6,
+ INVDSTALPHA = 7
+ };
+
+ enum LogicOp : u32
{
- u32 blendenable : 1;
- u32 logicopenable : 1;
- u32 dither : 1;
- u32 colorupdate : 1;
- u32 alphaupdate : 1;
- u32 dstfactor : 3; //BLEND_ONE, BLEND_INV_SRc etc
- u32 srcfactor : 3;
- u32 subtract : 1;
- u32 logicmode : 4;
+ CLEAR = 0,
+ AND = 1,
+ AND_REVERSE = 2,
+ COPY = 3,
+ AND_INVERTED = 4,
+ NOOP = 5,
+ XOR = 6,
+ OR = 7,
+ NOR = 8,
+ EQUIV = 9,
+ INVERT = 10,
+ OR_REVERSE = 11,
+ COPY_INVERTED = 12,
+ OR_INVERTED = 13,
+ NAND = 14,
+ SET = 15
};
+
+ BitField< 0,1,u32> blendenable;
+ BitField< 1,1,u32> logicopenable;
+ BitField< 2,1,u32> dither;
+ BitField< 3,1,u32> colorupdate;
+ BitField< 4,1,u32> alphaupdate;
+ BitField< 5,3,BlendFactor> dstfactor;
+ BitField< 8,3,BlendFactor> srcfactor;
+ BitField<11,1,u32> subtract;
+ BitField<12,4,LogicOp> logicmode;
+
u32 hex;
};
@@ -733,12 +726,22 @@ struct FogParams
union ZMode
{
- struct
+ enum CompareMode : u32
{
- u32 testenable : 1;
- u32 func : 3;
- u32 updateenable : 1; //size?
+ NEVER = 0,
+ LESS = 1,
+ EQUAL = 2,
+ LEQUAL = 3,
+ GREATER = 4,
+ NEQUAL = 5,
+ GEQUAL = 6,
+ ALWAYS = 7
};
+
+ BitField<0,1,u32> testenable;
+ BitField<1,3,CompareMode> func;
+ BitField<4,1,u32> updateenable;
+
u32 hex;
};
@@ -772,36 +775,38 @@ union FieldMask
u32 hex;
};
-#define PIXELFMT_RGB8_Z24 0
-#define PIXELFMT_RGBA6_Z24 1
-#define PIXELFMT_RGB565_Z16 2
-#define PIXELFMT_Z24 3
-#define PIXELFMT_Y8 4
-#define PIXELFMT_U8 5
-#define PIXELFMT_V8 6
-#define PIXELFMT_YUV420 7
-
-#define ZC_LINEAR 0
-#define ZC_NEAR 1
-#define ZC_MID 2
-#define ZC_FAR 3
-// It seems these Z formats aren't supported/were removed ?
-#define ZC_INV_LINEAR 4
-#define ZC_INV_NEAR 5
-#define ZC_INV_MID 6
-#define ZC_INV_FAR 7
-
-union PE_CONTROL
+union PEControl
{
- struct
+ enum PixelFormat : u32
{
- u32 pixel_format : 3; // PIXELFMT_X
- u32 zformat : 3; // Z Compression for 16bit Z format
- u32 early_ztest : 1; // 1: before tex stage
- u32 unused : 17;
- u32 rid : 8;
+ RGB8_Z24 = 0,
+ RGBA6_Z24 = 1,
+ RGB565_Z16 = 2,
+ Z24 = 3,
+ Y8 = 4,
+ U8 = 5,
+ V8 = 6,
+ YUV420 = 7
};
+ enum DepthFormat : u32
+ {
+ ZLINEAR = 0,
+ ZNEAR = 1,
+ ZMID = 2,
+ ZFAR = 3,
+
+ // It seems these Z formats aren't supported/were removed ?
+ ZINV_LINEAR = 4,
+ ZINV_NEAR = 5,
+ ZINV_MID = 6,
+ ZINV_FAR = 7
+ };
+
+ BitField< 0,3,PixelFormat> pixel_format;
+ BitField< 3,3,DepthFormat> zformat;
+ BitField< 6,1,u32> early_ztest;
+
u32 hex;
};
@@ -828,22 +833,25 @@ struct TCoordInfo
};
-union ColReg
+union TevReg
{
- u32 hex;
- struct
- {
- s32 a : 11;
- u32 : 1;
- s32 b : 11;
- u32 type : 1;
- };
-};
+ u64 hex;
-struct TevReg
-{
- ColReg low;
- ColReg high;
+ // Access to individual registers
+ BitField< 0, 32,u64> low;
+ BitField<32, 32,u64> high;
+
+ // Low register
+ BitField< 0,11,s64> red;
+
+ BitField<12,11,s64> alpha;
+ BitField<23, 1,u64> type_ra;
+
+ // High register
+ BitField<32,11,s64> blue;
+
+ BitField<44,11,s64> green;
+ BitField<55, 1,u64> type_bg;
};
union TevKSel
@@ -864,14 +872,32 @@ union TevKSel
union AlphaTest
{
- struct
+ enum CompareMode : u32
{
- u32 ref0 : 8;
- u32 ref1 : 8;
- u32 comp0 : 3;
- u32 comp1 : 3;
- u32 logic : 2;
+ NEVER = 0,
+ LESS = 1,
+ EQUAL = 2,
+ LEQUAL = 3,
+ GREATER = 4,
+ NEQUAL = 5,
+ GEQUAL = 6,
+ ALWAYS = 7
};
+
+ enum Op
+ {
+ AND = 0,
+ OR = 1,
+ XOR = 2,
+ XNOR = 3
+ };
+
+ BitField< 0,8, u32> ref0;
+ BitField< 8,8, u32> ref1;
+ BitField<16,3, CompareMode> comp0;
+ BitField<19,3, CompareMode> comp1;
+ BitField<22,2, Op> logic;
+
u32 hex;
enum TEST_RESULT
@@ -885,31 +911,31 @@ union AlphaTest
{
switch (logic)
{
- case 0: // AND
- if (comp0 == ALPHACMP_ALWAYS && comp1 == ALPHACMP_ALWAYS)
+ case AND:
+ if (comp0 == ALWAYS && comp1 == ALWAYS)
return PASS;
- if (comp0 == ALPHACMP_NEVER || comp1 == ALPHACMP_NEVER)
+ if (comp0 == NEVER || comp1 == NEVER)
return FAIL;
break;
- case 1: // OR
- if (comp0 == ALPHACMP_ALWAYS || comp1 == ALPHACMP_ALWAYS)
+ case OR:
+ if (comp0 == ALWAYS || comp1 == ALWAYS)
return PASS;
- if (comp0 == ALPHACMP_NEVER && comp1 == ALPHACMP_NEVER)
+ if (comp0 == NEVER && comp1 == NEVER)
return FAIL;
break;
- case 2: // XOR
- if ((comp0 == ALPHACMP_ALWAYS && comp1 == ALPHACMP_NEVER) || (comp0 == ALPHACMP_NEVER && comp1 == ALPHACMP_ALWAYS))
+ case XOR:
+ if ((comp0 == ALWAYS && comp1 == NEVER) || (comp0 == NEVER && comp1 == ALWAYS))
return PASS;
- if ((comp0 == ALPHACMP_ALWAYS && comp1 == ALPHACMP_ALWAYS) || (comp0 == ALPHACMP_NEVER && comp1 == ALPHACMP_NEVER))
+ if ((comp0 == ALWAYS && comp1 == ALWAYS) || (comp0 == NEVER && comp1 == NEVER))
return FAIL;
break;
- case 3: // XNOR
- if ((comp0 == ALPHACMP_ALWAYS && comp1 == ALPHACMP_NEVER) || (comp0 == ALPHACMP_NEVER && comp1 == ALPHACMP_ALWAYS))
+ case XNOR:
+ if ((comp0 == ALWAYS && comp1 == NEVER) || (comp0 == NEVER && comp1 == ALWAYS))
return FAIL;
- if ((comp0 == ALPHACMP_ALWAYS && comp1 == ALPHACMP_ALWAYS) || (comp0 == ALPHACMP_NEVER && comp1 == ALPHACMP_NEVER))
+ if ((comp0 == ALWAYS && comp1 == ALWAYS) || (comp0 == NEVER && comp1 == NEVER))
return PASS;
break;
}
@@ -920,21 +946,20 @@ union AlphaTest
union UPE_Copy
{
u32 Hex;
- struct
- {
- u32 clamp0 : 1; // if set clamp top
- u32 clamp1 : 1; // if set clamp bottom
- u32 yuv : 1; // if set, color conversion from RGB to YUV
- u32 target_pixel_format : 4; // realformat is (fmt/2)+((fmt&1)*8).... for some reason the msb is the lsb (pattern: cycling right shift)
- u32 gamma : 2; // gamma correction.. 0 = 1.0 ; 1 = 1.7 ; 2 = 2.2 ; 3 is reserved
- u32 half_scale : 1; // "mipmap" filter... 0 = no filter (scale 1:1) ; 1 = box filter (scale 2:1)
- u32 scale_invert : 1; // if set vertical scaling is on
- u32 clear : 1;
- u32 frame_to_field : 2; // 0 progressive ; 1 is reserved ; 2 = interlaced (even lines) ; 3 = interlaced 1 (odd lines)
- u32 copy_to_xfb : 1;
- u32 intensity_fmt : 1; // if set, is an intensity format (I4,I8,IA4,IA8)
- u32 auto_conv : 1; // if 0 automatic color conversion by texture format and pixel type
- };
+
+ BitField< 0,1,u32> clamp0; // if set clamp top
+ BitField< 1,1,u32> clamp1; // if set clamp bottom
+ BitField< 2,1,u32> yuv; // if set, color conversion from RGB to YUV
+ BitField< 3,4,u32> target_pixel_format; // realformat is (fmt/2)+((fmt&1)*8).... for some reason the msb is the lsb (pattern: cycling right shift)
+ BitField< 7,2,u32> gamma; // gamma correction.. 0 = 1.0 ; 1 = 1.7 ; 2 = 2.2 ; 3 is reserved
+ BitField< 9,1,u32> half_scale; // "mipmap" filter... 0 = no filter (scale 1:1) ; 1 = box filter (scale 2:1)
+ BitField<10,1,u32> scale_invert; // if set vertical scaling is on
+ BitField<11,1,u32> clear;
+ BitField<12,2,u32> frame_to_field; // 0 progressive ; 1 is reserved ; 2 = interlaced (even lines) ; 3 = interlaced 1 (odd lines)
+ BitField<14,1,u32> copy_to_xfb;
+ BitField<15,1,u32> intensity_fmt; // if set, is an intensity format (I4,I8,IA4,IA8)
+ BitField<16,1,u32> auto_conv; // if 0 automatic color conversion by texture format and pixel type
+
u32 tp_realFormat() {
return target_pixel_format / 2 + (target_pixel_format & 1) * 8;
}
@@ -996,7 +1021,7 @@ struct BPMemory
ZMode zmode; //40
BlendMode blendmode; //41
ConstantAlpha dstalpha; //42
- PE_CONTROL zcontrol; //43 GXSetZCompLoc, GXPixModeSync
+ PEControl zcontrol; //43 GXSetZCompLoc, GXPixModeSync
FieldMask fieldmask; //44
u32 drawdone; //45, bit1=1 if end of list
u32 unknown5; //46 clock?
diff --git a/Source/Core/VideoCommon/BPStructs.cpp b/Source/Core/VideoCommon/BPStructs.cpp
index ff60ff6392..8b904a95f8 100644
--- a/Source/Core/VideoCommon/BPStructs.cpp
+++ b/Source/Core/VideoCommon/BPStructs.cpp
@@ -133,8 +133,8 @@ void BPWritten(const BPCmd& bp)
SetLineWidth();
break;
case BPMEM_ZMODE: // Depth Control
- PRIM_LOG("zmode: test=%d, func=%d, upd=%d", bpmem.zmode.testenable, bpmem.zmode.func,
- bpmem.zmode.updateenable);
+ PRIM_LOG("zmode: test=%d, func=%d, upd=%d", (int)bpmem.zmode.testenable,
+ (int)bpmem.zmode.func, (int)bpmem.zmode.updateenable);
SetDepthMode();
break;
case BPMEM_BLENDMODE: // Blending Control
@@ -142,8 +142,9 @@ void BPWritten(const BPCmd& bp)
if (bp.changes & 0xFFFF)
{
PRIM_LOG("blendmode: en=%d, open=%d, colupd=%d, alphaupd=%d, dst=%d, src=%d, sub=%d, mode=%d",
- bpmem.blendmode.blendenable, bpmem.blendmode.logicopenable, bpmem.blendmode.colorupdate, bpmem.blendmode.alphaupdate,
- bpmem.blendmode.dstfactor, bpmem.blendmode.srcfactor, bpmem.blendmode.subtract, bpmem.blendmode.logicmode);
+ (int)bpmem.blendmode.blendenable, (int)bpmem.blendmode.logicopenable, (int)bpmem.blendmode.colorupdate,
+ (int)bpmem.blendmode.alphaupdate, (int)bpmem.blendmode.dstfactor, (int)bpmem.blendmode.srcfactor,
+ (int)bpmem.blendmode.subtract, (int)bpmem.blendmode.logicmode);
// Set LogicOp Blending Mode
if (bp.changes & 0xF002) // logicopenable | logicmode
@@ -304,8 +305,10 @@ void BPWritten(const BPCmd& bp)
PixelShaderManager::SetFogColorChanged();
break;
case BPMEM_ALPHACOMPARE: // Compare Alpha Values
- PRIM_LOG("alphacmp: ref0=%d, ref1=%d, comp0=%d, comp1=%d, logic=%d", bpmem.alpha_test.ref0,
- bpmem.alpha_test.ref1, bpmem.alpha_test.comp0, bpmem.alpha_test.comp1, bpmem.alpha_test.logic);
+ PRIM_LOG("alphacmp: ref0=%d, ref1=%d, comp0=%d, comp1=%d, logic=%d",
+ (int)bpmem.alpha_test.ref0, (int)bpmem.alpha_test.ref1,
+ (int)bpmem.alpha_test.comp0, (int)bpmem.alpha_test.comp1,
+ (int)bpmem.alpha_test.logic);
if (bp.changes & 0xFFFF)
PixelShaderManager::SetAlpha();
if (bp.changes)
@@ -560,9 +563,9 @@ void BPWritten(const BPCmd& bp)
// don't compare with changes!
int num = (bp.address >> 1) & 0x3;
if ((bp.address & 1) == 0)
- PixelShaderManager::SetColorChanged(bpmem.tevregs[num].low.type, num);
+ PixelShaderManager::SetColorChanged(bpmem.tevregs[num].type_ra, num);
else
- PixelShaderManager::SetColorChanged(bpmem.tevregs[num].high.type, num);
+ PixelShaderManager::SetColorChanged(bpmem.tevregs[num].type_bg, num);
}
break;
diff --git a/Source/Core/VideoCommon/Debugger.cpp b/Source/Core/VideoCommon/Debugger.cpp
index 3197c5dd85..c5ca50f132 100644
--- a/Source/Core/VideoCommon/Debugger.cpp
+++ b/Source/Core/VideoCommon/Debugger.cpp
@@ -86,7 +86,7 @@ void GFXDebuggerBase::DumpPixelShader(const std::string& path)
const std::string filename = StringFromFormat("%sdump_ps.txt", path.c_str());
std::string output;
- bool useDstAlpha = !g_ActiveConfig.bDstAlphaPass && bpmem.dstalpha.enable && bpmem.blendmode.alphaupdate && bpmem.zcontrol.pixel_format == PIXELFMT_RGBA6_Z24;
+ bool useDstAlpha = !g_ActiveConfig.bDstAlphaPass && bpmem.dstalpha.enable && bpmem.blendmode.alphaupdate && bpmem.zcontrol.pixel_format == PEControl::RGBA6_Z24;
if (!useDstAlpha)
{
output = "Destination alpha disabled:\n";
diff --git a/Source/Core/VideoCommon/PixelShaderManager.cpp b/Source/Core/VideoCommon/PixelShaderManager.cpp
index 7cbb155be2..bd24ce269a 100644
--- a/Source/Core/VideoCommon/PixelShaderManager.cpp
+++ b/Source/Core/VideoCommon/PixelShaderManager.cpp
@@ -148,17 +148,13 @@ void PixelShaderManager::SetConstants()
}
}
-// This one is high in profiles (0.5%).
-// TODO: Move conversion out, only store the raw color value
-// and update it when the shader constant is set, only.
-// TODO: Conversion should be checked in the context of tev_fixes..
void PixelShaderManager::SetColorChanged(int type, int num)
{
int4* c = type ? constants.kcolors : constants.colors;
- c[num][0] = bpmem.tevregs[num].low.a;
- c[num][3] = bpmem.tevregs[num].low.b;
- c[num][2] = bpmem.tevregs[num].high.a;
- c[num][1] = bpmem.tevregs[num].high.b;
+ c[num][0] = bpmem.tevregs[num].red;
+ c[num][3] = bpmem.tevregs[num].alpha;
+ c[num][2] = bpmem.tevregs[num].blue;
+ c[num][1] = bpmem.tevregs[num].green;
dirty = true;
PRIM_LOG("pixel %scolor%d: %d %d %d %d\n", type?"k":"", num, c[num][0], c[num][1], c[num][2], c[num][3]);
diff --git a/Source/Core/VideoCommon/RenderBase.cpp b/Source/Core/VideoCommon/RenderBase.cpp
index 0b5d890aa6..12dc7b4bfc 100644
--- a/Source/Core/VideoCommon/RenderBase.cpp
+++ b/Source/Core/VideoCommon/RenderBase.cpp
@@ -64,7 +64,7 @@ int Renderer::s_LastEFBScale;
bool Renderer::s_skipSwap;
bool Renderer::XFBWrited;
-unsigned int Renderer::prev_efb_format = (unsigned int)-1;
+PEControl::PixelFormat Renderer::prev_efb_format = (PEControl::PixelFormat)-1;
unsigned int Renderer::efb_scale_numeratorX = 1;
unsigned int Renderer::efb_scale_numeratorY = 1;
unsigned int Renderer::efb_scale_denominatorX = 1;
@@ -89,7 +89,7 @@ Renderer::Renderer()
Renderer::~Renderer()
{
// invalidate previous efb format
- prev_efb_format = (unsigned int)-1;
+ prev_efb_format = (PEControl::PixelFormat)-1;
efb_scale_numeratorX = efb_scale_numeratorY = efb_scale_denominatorX = efb_scale_denominatorY = 1;
diff --git a/Source/Core/VideoCommon/RenderBase.h b/Source/Core/VideoCommon/RenderBase.h
index e16ee8fd40..5ae0a677eb 100644
--- a/Source/Core/VideoCommon/RenderBase.h
+++ b/Source/Core/VideoCommon/RenderBase.h
@@ -111,8 +111,8 @@ public:
virtual bool SaveScreenshot(const std::string &filename, const TargetRectangle &rc) = 0;
- static unsigned int GetPrevPixelFormat() { return prev_efb_format; }
- static void StorePixelFormat(unsigned int new_format) { prev_efb_format = new_format; }
+ static PEControl::PixelFormat GetPrevPixelFormat() { return prev_efb_format; }
+ static void StorePixelFormat(PEControl::PixelFormat new_format) { prev_efb_format = new_format; }
protected:
@@ -151,7 +151,7 @@ protected:
static bool XFBWrited;
private:
- static unsigned int prev_efb_format;
+ static PEControl::PixelFormat prev_efb_format;
static unsigned int efb_scale_numeratorX;
static unsigned int efb_scale_numeratorY;
static unsigned int efb_scale_denominatorX;
diff --git a/Source/Core/VideoCommon/TextureCacheBase.cpp b/Source/Core/VideoCommon/TextureCacheBase.cpp
index 6c9ef30e28..04b25cb4fc 100644
--- a/Source/Core/VideoCommon/TextureCacheBase.cpp
+++ b/Source/Core/VideoCommon/TextureCacheBase.cpp
@@ -572,7 +572,7 @@ TextureCache::TCacheEntryBase* TextureCache::Load(unsigned int const stage,
return ReturnEntry(stage, entry);
}
-void TextureCache::CopyRenderTargetToTexture(u32 dstAddr, unsigned int dstFormat, unsigned int srcFormat,
+void TextureCache::CopyRenderTargetToTexture(u32 dstAddr, unsigned int dstFormat, PEControl::PixelFormat srcFormat,
const EFBRectangle& srcRect, bool isIntensity, bool scaleByHalf)
{
// Emulation methods:
@@ -623,9 +623,9 @@ void TextureCache::CopyRenderTargetToTexture(u32 dstAddr, unsigned int dstFormat
ColorMask[0] = ColorMask[1] = ColorMask[2] = ColorMask[3] = 255.0f;
ColorMask[4] = ColorMask[5] = ColorMask[6] = ColorMask[7] = 1.0f / 255.0f;
unsigned int cbufid = -1;
- bool efbHasAlpha = bpmem.zcontrol.pixel_format == PIXELFMT_RGBA6_Z24;
+ bool efbHasAlpha = bpmem.zcontrol.pixel_format == PEControl::RGBA6_Z24;
- if (srcFormat == PIXELFMT_Z24)
+ if (srcFormat == PEControl::Z24)
{
switch (dstFormat)
{
diff --git a/Source/Core/VideoCommon/TextureCacheBase.h b/Source/Core/VideoCommon/TextureCacheBase.h
index f66726f478..f5229f72ff 100644
--- a/Source/Core/VideoCommon/TextureCacheBase.h
+++ b/Source/Core/VideoCommon/TextureCacheBase.h
@@ -77,7 +77,7 @@ public:
virtual void Load(unsigned int width, unsigned int height,
unsigned int expanded_width, unsigned int level) = 0;
virtual void FromRenderTarget(u32 dstAddr, unsigned int dstFormat,
- unsigned int srcFormat, const EFBRectangle& srcRect,
+ PEControl::PixelFormat srcFormat, const EFBRectangle& srcRect,
bool isIntensity, bool scaleByHalf, unsigned int cbufid,
const float *colmat) = 0;
@@ -103,7 +103,7 @@ public:
static TCacheEntryBase* Load(unsigned int stage, u32 address, unsigned int width, unsigned int height,
int format, unsigned int tlutaddr, int tlutfmt, bool use_mipmaps, unsigned int maxlevel, bool from_tmem);
- static void CopyRenderTargetToTexture(u32 dstAddr, unsigned int dstFormat, unsigned int srcFormat,
+ static void CopyRenderTargetToTexture(u32 dstAddr, unsigned int dstFormat, PEControl::PixelFormat srcFormat,
const EFBRectangle& srcRect, bool isIntensity, bool scaleByHalf);
static void RequestInvalidateTextureCache();
diff --git a/Source/Core/VideoCommon/VertexManagerBase.cpp b/Source/Core/VideoCommon/VertexManagerBase.cpp
index ee72d074cd..624631b805 100644
--- a/Source/Core/VideoCommon/VertexManagerBase.cpp
+++ b/Source/Core/VideoCommon/VertexManagerBase.cpp
@@ -219,7 +219,7 @@ void VertexManager::Flush()
bool useDstAlpha = !g_ActiveConfig.bDstAlphaPass &&
bpmem.dstalpha.enable &&
bpmem.blendmode.alphaupdate &&
- bpmem.zcontrol.pixel_format == PIXELFMT_RGBA6_Z24;
+ bpmem.zcontrol.pixel_format == PEControl::RGBA6_Z24;
if (PerfQueryBase::ShouldEmulate())
g_perf_query->EnableQuery(bpmem.zcontrol.early_ztest ? PQG_ZCOMP_ZCOMPLOC : PQG_ZCOMP);