diff options
| author | Pierre Bourdon <delroth@gmail.com> | 2014-03-26 00:08:58 +0100 |
|---|---|---|
| committer | Pierre Bourdon <delroth@gmail.com> | 2014-03-26 00:08:58 +0100 |
| commit | b4337a21928745bef151c8ab665138f7a435f198 (patch) | |
| tree | f3792e8f08d1c847059a2354db188a8d62fdd2df /Source/Core/VideoBackends/Software | |
| parent | 6351f28ab41172d7b07626da737d691ce88c9285 (diff) | |
| parent | 16105db7092707bc130a345ed1e630e2ef1f7747 (diff) | |
Merge pull request #204 from neobrain/bitfield_cleanup
Bitfield cleanup
Diffstat (limited to 'Source/Core/VideoBackends/Software')
| -rw-r--r-- | Source/Core/VideoBackends/Software/BPMemLoader.cpp | 16 | ||||
| -rw-r--r-- | Source/Core/VideoBackends/Software/EfbInterface.cpp | 368 | ||||
| -rw-r--r-- | Source/Core/VideoBackends/Software/Tev.cpp | 18 | ||||
| -rw-r--r-- | Source/Core/VideoBackends/Software/TextureEncoder.cpp | 20 |
4 files changed, 212 insertions, 210 deletions
diff --git a/Source/Core/VideoBackends/Software/BPMemLoader.cpp b/Source/Core/VideoBackends/Software/BPMemLoader.cpp index 7672e233ac..b81f2b340e 100644 --- a/Source/Core/VideoBackends/Software/BPMemLoader.cpp +++ b/Source/Core/VideoBackends/Software/BPMemLoader.cpp @@ -160,11 +160,11 @@ void SWBPWritten(int address, int newvalue) case BPMEM_TEV_REGISTER_L+6: // Reg 4 { int regNum = (address >> 1 ) & 0x3; - ColReg& reg = bpmem.tevregs[regNum].low; - bool konst = reg.type; + TevReg& reg = bpmem.tevregs[regNum]; + bool konst = reg.type_ra; - Rasterizer::SetTevReg(regNum, Tev::ALP_C, konst, reg.b); // A - Rasterizer::SetTevReg(regNum, Tev::RED_C, konst, reg.a); // R + Rasterizer::SetTevReg(regNum, Tev::ALP_C, konst, reg.alpha); + Rasterizer::SetTevReg(regNum, Tev::RED_C, konst, reg.red); break; } @@ -175,11 +175,11 @@ void SWBPWritten(int address, int newvalue) case BPMEM_TEV_REGISTER_H+6: // Reg 4 { int regNum = (address >> 1 ) & 0x3; - ColReg& reg = bpmem.tevregs[regNum].high; - bool konst = reg.type; + TevReg& reg = bpmem.tevregs[regNum]; + bool konst = reg.type_bg; - Rasterizer::SetTevReg(regNum, Tev::GRN_C, konst, reg.b); // G - Rasterizer::SetTevReg(regNum, Tev::BLU_C, konst, reg.a); // B + Rasterizer::SetTevReg(regNum, Tev::GRN_C, konst, reg.green); + Rasterizer::SetTevReg(regNum, Tev::BLU_C, konst, reg.blue); break; } diff --git a/Source/Core/VideoBackends/Software/EfbInterface.cpp b/Source/Core/VideoBackends/Software/EfbInterface.cpp index dffe392e6f..c1ded19322 100644 --- a/Source/Core/VideoBackends/Software/EfbInterface.cpp +++ b/Source/Core/VideoBackends/Software/EfbInterface.cpp @@ -33,14 +33,14 @@ namespace EfbInterface void SetPixelAlphaOnly(u32 offset, u8 a) { - switch (bpmem.zcontrol.pixel_format) + switch (bpmem.zcontrol.pixel_format) { - case PIXELFMT_RGB8_Z24: - case PIXELFMT_Z24: - case PIXELFMT_RGB565_Z16: + case PEControl::RGB8_Z24: + case PEControl::Z24: + case PEControl::RGB565_Z16: // do nothing break; - case PIXELFMT_RGBA6_Z24: + case PEControl::RGBA6_Z24: { u32 a32 = a; u32 *dst = (u32*)&efb[offset]; @@ -50,7 +50,7 @@ namespace EfbInterface } break; default: - ERROR_LOG(VIDEO, "Unsupported pixel format: %i", bpmem.zcontrol.pixel_format); + ERROR_LOG(VIDEO, "Unsupported pixel format: %i", static_cast<int>(bpmem.zcontrol.pixel_format)); } } @@ -58,8 +58,8 @@ namespace EfbInterface { switch (bpmem.zcontrol.pixel_format) { - case PIXELFMT_RGB8_Z24: - case PIXELFMT_Z24: + case PEControl::RGB8_Z24: + case PEControl::Z24: { u32 src = *(u32*)rgb; u32 *dst = (u32*)&efb[offset]; @@ -68,7 +68,7 @@ namespace EfbInterface *dst = val; } break; - case PIXELFMT_RGBA6_Z24: + case PEControl::RGBA6_Z24: { u32 src = *(u32*)rgb; u32 *dst = (u32*)&efb[offset]; @@ -79,9 +79,9 @@ namespace EfbInterface *dst = val; } break; - case PIXELFMT_RGB565_Z16: + case PEControl::RGB565_Z16: { - INFO_LOG(VIDEO, "PIXELFMT_RGB565_Z16 is not supported correctly yet"); + INFO_LOG(VIDEO, "RGB565_Z16 is not supported correctly yet"); u32 src = *(u32*)rgb; u32 *dst = (u32*)&efb[offset]; u32 val = *dst & 0xff000000; @@ -90,16 +90,16 @@ namespace EfbInterface } break; default: - ERROR_LOG(VIDEO, "Unsupported pixel format: %i", bpmem.zcontrol.pixel_format); + ERROR_LOG(VIDEO, "Unsupported pixel format: %i", static_cast<int>(bpmem.zcontrol.pixel_format)); } } void SetPixelAlphaColor(u32 offset, u8 *color) { - switch (bpmem.zcontrol.pixel_format) + switch (bpmem.zcontrol.pixel_format) { - case PIXELFMT_RGB8_Z24: - case PIXELFMT_Z24: + case PEControl::RGB8_Z24: + case PEControl::Z24: { u32 src = *(u32*)color; u32 *dst = (u32*)&efb[offset]; @@ -108,7 +108,7 @@ namespace EfbInterface *dst = val; } break; - case PIXELFMT_RGBA6_Z24: + case PEControl::RGBA6_Z24: { u32 src = *(u32*)color; u32 *dst = (u32*)&efb[offset]; @@ -120,9 +120,9 @@ namespace EfbInterface *dst = val; } break; - case PIXELFMT_RGB565_Z16: + case PEControl::RGB565_Z16: { - INFO_LOG(VIDEO, "PIXELFMT_RGB565_Z16 is not supported correctly yet"); + INFO_LOG(VIDEO, "RGB565_Z16 is not supported correctly yet"); u32 src = *(u32*)color; u32 *dst = (u32*)&efb[offset]; u32 val = *dst & 0xff000000; @@ -131,16 +131,16 @@ namespace EfbInterface } break; default: - ERROR_LOG(VIDEO, "Unsupported pixel format: %i", bpmem.zcontrol.pixel_format); + ERROR_LOG(VIDEO, "Unsupported pixel format: %i", static_cast<int>(bpmem.zcontrol.pixel_format)); } } - void GetPixelColor(u32 offset, u8 *color) + void GetPixelColor(u32 offset, u8 *color) { switch (bpmem.zcontrol.pixel_format) { - case PIXELFMT_RGB8_Z24: - case PIXELFMT_Z24: + case PEControl::RGB8_Z24: + case PEControl::Z24: { u32 src = *(u32*)&efb[offset]; u32 *dst = (u32*)color; @@ -148,7 +148,7 @@ namespace EfbInterface *dst = val; } break; - case PIXELFMT_RGBA6_Z24: + case PEControl::RGBA6_Z24: { u32 src = *(u32*)&efb[offset]; color[ALP_C] = Convert6To8(src & 0x3f); @@ -157,9 +157,9 @@ namespace EfbInterface color[RED_C] = Convert6To8((src >> 18) & 0x3f); } break; - case PIXELFMT_RGB565_Z16: + case PEControl::RGB565_Z16: { - INFO_LOG(VIDEO, "PIXELFMT_RGB565_Z16 is not supported correctly yet"); + INFO_LOG(VIDEO, "RGB565_Z16 is not supported correctly yet"); u32 src = *(u32*)&efb[offset]; u32 *dst = (u32*)color; u32 val = 0xff | ((src & 0x00ffffff) << 8); @@ -167,7 +167,7 @@ namespace EfbInterface } break; default: - ERROR_LOG(VIDEO, "Unsupported pixel format: %i", bpmem.zcontrol.pixel_format); + ERROR_LOG(VIDEO, "Unsupported pixel format: %i", static_cast<int>(bpmem.zcontrol.pixel_format)); } } @@ -175,9 +175,9 @@ namespace EfbInterface { switch (bpmem.zcontrol.pixel_format) { - case PIXELFMT_RGB8_Z24: - case PIXELFMT_RGBA6_Z24: - case PIXELFMT_Z24: + case PEControl::RGB8_Z24: + case PEControl::RGBA6_Z24: + case PEControl::Z24: { u32 *dst = (u32*)&efb[offset]; u32 val = *dst & 0xff000000; @@ -185,9 +185,9 @@ namespace EfbInterface *dst = val; } break; - case PIXELFMT_RGB565_Z16: + case PEControl::RGB565_Z16: { - INFO_LOG(VIDEO, "PIXELFMT_RGB565_Z16 is not supported correctly yet"); + INFO_LOG(VIDEO, "RGB565_Z16 is not supported correctly yet"); u32 *dst = (u32*)&efb[offset]; u32 val = *dst & 0xff000000; val |= depth & 0x00ffffff; @@ -195,111 +195,113 @@ namespace EfbInterface } break; default: - ERROR_LOG(VIDEO, "Unsupported pixel format: %i", bpmem.zcontrol.pixel_format); + ERROR_LOG(VIDEO, "Unsupported pixel format: %i", static_cast<int>(bpmem.zcontrol.pixel_format)); } } - u32 GetPixelDepth(u32 offset) + u32 GetPixelDepth(u32 offset) { u32 depth = 0; switch (bpmem.zcontrol.pixel_format) { - case PIXELFMT_RGB8_Z24: - case PIXELFMT_RGBA6_Z24: - case PIXELFMT_Z24: + case PEControl::RGB8_Z24: + case PEControl::RGBA6_Z24: + case PEControl::Z24: { depth = (*(u32*)&efb[offset]) & 0x00ffffff; } break; - case PIXELFMT_RGB565_Z16: + case PEControl::RGB565_Z16: { - INFO_LOG(VIDEO, "PIXELFMT_RGB565_Z16 is not supported correctly yet"); + INFO_LOG(VIDEO, "RGB565_Z16 is not supported correctly yet"); depth = (*(u32*)&efb[offset]) & 0x00ffffff; } break; default: - ERROR_LOG(VIDEO, "Unsupported pixel format: %i", bpmem.zcontrol.pixel_format); + ERROR_LOG(VIDEO, "Unsupported pixel format: %i", static_cast<int>(bpmem.zcontrol.pixel_format)); } return depth; } - u32 GetSourceFactor(u8 *srcClr, u8 *dstClr, int mode) + u32 GetSourceFactor(u8 *srcClr, u8 *dstClr, BlendMode::BlendFactor mode) { - switch (mode) { - case 0: // zero - return 0; - case 1: // one - return 0xffffffff; - case 2: // dstclr - return *(u32*)dstClr; - case 3: // invdstclr - return 0xffffffff - *(u32*)dstClr; - case 4: // srcalpha - { - u8 alpha = srcClr[ALP_C]; - u32 factor = alpha << 24 | alpha << 16 | alpha << 8 | alpha; - return factor; - } - case 5: // invsrcalpha - { - u8 alpha = 0xff - srcClr[ALP_C]; - u32 factor = alpha << 24 | alpha << 16 | alpha << 8 | alpha; - return factor; - } - case 6: // dstalpha - { - u8 alpha = dstClr[ALP_C]; - u32 factor = alpha << 24 | alpha << 16 | alpha << 8 | alpha; - return factor; - } - case 7: // invdstalpha - { - u8 alpha = 0xff - dstClr[ALP_C]; - u32 factor = alpha << 24 | alpha << 16 | alpha << 8 | alpha; - return factor; - } + switch (mode) + { + case BlendMode::ZERO: + return 0; + case BlendMode::ONE: + return 0xffffffff; + case BlendMode::DSTCLR: + return *(u32*)dstClr; + case BlendMode::INVDSTCLR: + return 0xffffffff - *(u32*)dstClr; + case BlendMode::SRCALPHA: + { + u8 alpha = srcClr[ALP_C]; + u32 factor = alpha << 24 | alpha << 16 | alpha << 8 | alpha; + return factor; + } + case BlendMode::INVSRCALPHA: + { + u8 alpha = 0xff - srcClr[ALP_C]; + u32 factor = alpha << 24 | alpha << 16 | alpha << 8 | alpha; + return factor; + } + case BlendMode::DSTALPHA: + { + u8 alpha = dstClr[ALP_C]; + u32 factor = alpha << 24 | alpha << 16 | alpha << 8 | alpha; + return factor; + } + case BlendMode::INVDSTALPHA: + { + u8 alpha = 0xff - dstClr[ALP_C]; + u32 factor = alpha << 24 | alpha << 16 | alpha << 8 | alpha; + return factor; + } } return 0; } - u32 GetDestinationFactor(u8 *srcClr, u8 *dstClr, int mode) + u32 GetDestinationFactor(u8 *srcClr, u8 *dstClr, BlendMode::BlendFactor mode) { - switch (mode) { - case 0: // zero - return 0; - case 1: // one - return 0xffffffff; - case 2: // srcclr - return *(u32*)srcClr; - case 3: // invsrcclr - return 0xffffffff - *(u32*)srcClr; - case 4: // srcalpha - { - u8 alpha = srcClr[ALP_C]; - u32 factor = alpha << 24 | alpha << 16 | alpha << 8 | alpha; - return factor; - } - case 5: // invsrcalpha - { - u8 alpha = 0xff - srcClr[ALP_C]; - u32 factor = alpha << 24 | alpha << 16 | alpha << 8 | alpha; - return factor; - } - case 6: // dstalpha - { - u8 alpha = dstClr[ALP_C] & 0xff; - u32 factor = alpha << 24 | alpha << 16 | alpha << 8 | alpha; - return factor; - } - case 7: // invdstalpha - { - u8 alpha = 0xff - dstClr[ALP_C]; - u32 factor = alpha << 24 | alpha << 16 | alpha << 8 | alpha; - return factor; - } + switch (mode) + { + case BlendMode::ZERO: + return 0; + case BlendMode::ONE: + return 0xffffffff; + case BlendMode::SRCCLR: + return *(u32*)srcClr; + case BlendMode::INVSRCCLR: + return 0xffffffff - *(u32*)srcClr; + case BlendMode::SRCALPHA: + { + u8 alpha = srcClr[ALP_C]; + u32 factor = alpha << 24 | alpha << 16 | alpha << 8 | alpha; + return factor; + } + case BlendMode::INVSRCALPHA: + { + u8 alpha = 0xff - srcClr[ALP_C]; + u32 factor = alpha << 24 | alpha << 16 | alpha << 8 | alpha; + return factor; + } + case BlendMode::DSTALPHA: + { + u8 alpha = dstClr[ALP_C] & 0xff; + u32 factor = alpha << 24 | alpha << 16 | alpha << 8 | alpha; + return factor; + } + case BlendMode::INVDSTALPHA: + { + u8 alpha = 0xff - dstClr[ALP_C]; + u32 factor = alpha << 24 | alpha << 16 | alpha << 8 | alpha; + return factor; + } } return 0; @@ -327,58 +329,58 @@ namespace EfbInterface } } - void LogicBlend(u32 srcClr, u32 &dstClr, int op) + void LogicBlend(u32 srcClr, u32 &dstClr, BlendMode::LogicOp op) { switch (op) { - case 0: // clear - dstClr = 0; - break; - case 1: // and - dstClr = srcClr & dstClr; - break; - case 2: // revand - dstClr = srcClr & (~dstClr); - break; - case 3: // copy - dstClr = srcClr; - break; - case 4: // invand - dstClr = (~srcClr) & dstClr; - break; - case 5: // noop - // Do nothing - break; - case 6: // xor - dstClr = srcClr ^ dstClr; - break; - case 7: // or - dstClr = srcClr | dstClr; - break; - case 8: // nor - dstClr = ~(srcClr | dstClr); - break; - case 9: // equiv - dstClr = ~(srcClr ^ dstClr); - break; - case 10: // inv - dstClr = ~dstClr; - break; - case 11: // revor - dstClr = srcClr | (~dstClr); - break; - case 12: // invcopy - dstClr = ~srcClr; - break; - case 13: // invor - dstClr = (~srcClr) | dstClr; - break; - case 14: // nand - dstClr = ~(srcClr & dstClr); - break; - case 15: // set - dstClr = 0xffffffff; - break; + case BlendMode::CLEAR: + dstClr = 0; + break; + case BlendMode::AND: + dstClr = srcClr & dstClr; + break; + case BlendMode::AND_REVERSE: + dstClr = srcClr & (~dstClr); + break; + case BlendMode::COPY: + dstClr = srcClr; + break; + case BlendMode::AND_INVERTED: + dstClr = (~srcClr) & dstClr; + break; + case BlendMode::NOOP: + // Do nothing + break; + case BlendMode::XOR: + dstClr = srcClr ^ dstClr; + break; + case BlendMode::OR: + dstClr = srcClr | dstClr; + break; + case BlendMode::NOR: + dstClr = ~(srcClr | dstClr); + break; + case BlendMode::EQUIV: + dstClr = ~(srcClr ^ dstClr); + break; + case BlendMode::INVERT: + dstClr = ~dstClr; + break; + case BlendMode::OR_REVERSE: + dstClr = srcClr | (~dstClr); + break; + case BlendMode::COPY_INVERTED: + dstClr = ~srcClr; + break; + case BlendMode::OR_INVERTED: + dstClr = (~srcClr) | dstClr; + break; + case BlendMode::NAND: + dstClr = ~(srcClr & dstClr); + break; + case BlendMode::SET: + dstClr = 0xffffffff; + break; } } @@ -584,33 +586,33 @@ namespace EfbInterface switch (bpmem.zmode.func) { - case COMPARE_NEVER: - pass = false; - break; - case COMPARE_LESS: - pass = z < depth; - break; - case COMPARE_EQUAL: - pass = z == depth; - break; - case COMPARE_LEQUAL: - pass = z <= depth; - break; - case COMPARE_GREATER: - pass = z > depth; - break; - case COMPARE_NEQUAL: - pass = z != depth; - break; - case COMPARE_GEQUAL: - pass = z >= depth; - break; - case COMPARE_ALWAYS: - pass = true; - break; - default: - pass = false; - ERROR_LOG(VIDEO, "Bad Z compare mode %i", bpmem.zmode.func); + case ZMode::NEVER: + pass = false; + break; + case ZMode::LESS: + pass = z < depth; + break; + case ZMode::EQUAL: + pass = z == depth; + break; + case ZMode::LEQUAL: + pass = z <= depth; + break; + case ZMode::GREATER: + pass = z > depth; + break; + case ZMode::NEQUAL: + pass = z != depth; + break; + case ZMode::GEQUAL: + pass = z >= depth; + break; + case ZMode::ALWAYS: + pass = true; + break; + default: + pass = false; + ERROR_LOG(VIDEO, "Bad Z compare mode %i", (int)bpmem.zmode.func); } if (pass && bpmem.zmode.updateenable) diff --git a/Source/Core/VideoBackends/Software/Tev.cpp b/Source/Core/VideoBackends/Software/Tev.cpp index 3b517175eb..1890aaa3e3 100644 --- a/Source/Core/VideoBackends/Software/Tev.cpp +++ b/Source/Core/VideoBackends/Software/Tev.cpp @@ -413,17 +413,17 @@ void Tev::DrawAlphaCompare(TevStageCombiner::AlphaCombiner &ac) } } -static bool AlphaCompare(int alpha, int ref, int comp) +static bool AlphaCompare(int alpha, int ref, AlphaTest::CompareMode comp) { switch (comp) { - case ALPHACMP_ALWAYS: return true; - case ALPHACMP_NEVER: return false; - case ALPHACMP_LEQUAL: return alpha <= ref; - case ALPHACMP_LESS: return alpha < ref; - case ALPHACMP_GEQUAL: return alpha >= ref; - case ALPHACMP_GREATER: return alpha > ref; - case ALPHACMP_EQUAL: return alpha == ref; - case ALPHACMP_NEQUAL: return alpha != ref; + case AlphaTest::ALWAYS: return true; + case AlphaTest::NEVER: return false; + case AlphaTest::LEQUAL: return alpha <= ref; + case AlphaTest::LESS: return alpha < ref; + case AlphaTest::GEQUAL: return alpha >= ref; + case AlphaTest::GREATER: return alpha > ref; + case AlphaTest::EQUAL: return alpha == ref; + case AlphaTest::NEQUAL: return alpha != ref; } return true; } diff --git a/Source/Core/VideoBackends/Software/TextureEncoder.cpp b/Source/Core/VideoBackends/Software/TextureEncoder.cpp index cf99dbf911..5913125a08 100644 --- a/Source/Core/VideoBackends/Software/TextureEncoder.cpp +++ b/Source/Core/VideoBackends/Software/TextureEncoder.cpp @@ -1386,8 +1386,8 @@ void EncodeZ24halfscale(u8 *dst, u8 *src, u32 format) void Encode(u8 *dest_ptr) { - int pixelformat = bpmem.zcontrol.pixel_format; - bool bFromZBuffer = pixelformat == PIXELFMT_Z24; + auto pixelformat = bpmem.zcontrol.pixel_format; + bool bFromZBuffer = pixelformat == PEControl::Z24; bool bIsIntensityFmt = bpmem.triggerEFBCopy.intensity_fmt > 0; u32 copyfmt = ((bpmem.triggerEFBCopy.target_pixel_format / 2) + ((bpmem.triggerEFBCopy.target_pixel_format & 1) * 8)); @@ -1409,24 +1409,24 @@ void Encode(u8 *dest_ptr) if (bpmem.triggerEFBCopy.half_scale) { - if (pixelformat == PIXELFMT_RGBA6_Z24) + if (pixelformat == PEControl::RGBA6_Z24) EncodeRGBA6halfscale(dest_ptr, src, format); - else if (pixelformat == PIXELFMT_RGB8_Z24) + else if (pixelformat == PEControl::RGB8_Z24) EncodeRGB8halfscale(dest_ptr, src, format); - else if (pixelformat == PIXELFMT_RGB565_Z16) // not supported + else if (pixelformat == PEControl::RGB565_Z16) // not supported EncodeRGB8halfscale(dest_ptr, src, format); - else if (pixelformat == PIXELFMT_Z24) + else if (pixelformat == PEControl::Z24) EncodeZ24halfscale(dest_ptr, src, format); } else { - if (pixelformat == PIXELFMT_RGBA6_Z24) + if (pixelformat == PEControl::RGBA6_Z24) EncodeRGBA6(dest_ptr, src, format); - else if (pixelformat == PIXELFMT_RGB8_Z24) + else if (pixelformat == PEControl::RGB8_Z24) EncodeRGB8(dest_ptr, src, format); - else if (pixelformat == PIXELFMT_RGB565_Z16) // not supported + else if (pixelformat == PEControl::RGB565_Z16) // not supported EncodeRGB8(dest_ptr, src, format); - else if (pixelformat == PIXELFMT_Z24) + else if (pixelformat == PEControl::Z24) EncodeZ24(dest_ptr, src, format); } } |
