diff --git a/Source/Core/Core/FifoPlayer/FifoPlaybackAnalyzer.cpp b/Source/Core/Core/FifoPlayer/FifoPlaybackAnalyzer.cpp index 95175b6d94..3dbd84777b 100644 --- a/Source/Core/Core/FifoPlayer/FifoPlaybackAnalyzer.cpp +++ b/Source/Core/Core/FifoPlayer/FifoPlaybackAnalyzer.cpp @@ -246,7 +246,7 @@ void FifoPlaybackAnalyzer::StoreEfbCopyRegion() UPE_Copy peCopy = m_BpMem.triggerEFBCopy; u32 copyfmt = peCopy.tp_realFormat(); - bool bFromZBuffer = m_BpMem.zcontrol.pixel_format == PIXELFMT_Z24; + bool bFromZBuffer = m_BpMem.zcontrol.pixel_format == PEControl::Z24; u32 address = bpmem.copyTexDest << 5; u32 format = copyfmt; diff --git a/Source/Core/VideoBackends/D3D/PSTextureEncoder.cpp b/Source/Core/VideoBackends/D3D/PSTextureEncoder.cpp index db7eb9ee3e..aa35479767 100644 --- a/Source/Core/VideoBackends/D3D/PSTextureEncoder.cpp +++ b/Source/Core/VideoBackends/D3D/PSTextureEncoder.cpp @@ -1031,8 +1031,8 @@ void PSTextureEncoder::Shutdown() } size_t PSTextureEncoder::Encode(u8* dst, unsigned int dstFormat, - unsigned int srcFormat, const EFBRectangle& srcRect, bool isIntensity, - bool scaleByHalf) + PEControl::PixelFormat srcFormat, const EFBRectangle& srcRect, + bool isIntensity, bool scaleByHalf) { if (!m_ready) // Make sure we initialized OK return 0; @@ -1122,7 +1122,7 @@ size_t PSTextureEncoder::Encode(u8* dst, unsigned int dstFormat, D3D::context->OMSetRenderTargets(1, &m_outRTV, nullptr); - ID3D11ShaderResourceView* pEFB = (srcFormat == PIXELFMT_Z24) ? + ID3D11ShaderResourceView* pEFB = (srcFormat == PEControl::Z24) ? FramebufferManager::GetEFBDepthTexture()->GetSRV() : // FIXME: Instead of resolving EFB, it would be better to pick out a // single sample from each pixel. The game may break if it isn't @@ -1208,10 +1208,10 @@ static const char* INTENSITY_FUNC_NAMES[2] = { "Intensity_0", "Intensity_1" }; -bool PSTextureEncoder::SetStaticShader(unsigned int dstFormat, unsigned int srcFormat, +bool PSTextureEncoder::SetStaticShader(unsigned int dstFormat, PEControl::PixelFormat srcFormat, bool isIntensity, bool scaleByHalf) { - size_t fetchNum = srcFormat; + size_t fetchNum = static_cast(srcFormat); size_t scaledFetchNum = scaleByHalf ? 1 : 0; size_t intensityNum = isIntensity ? 1 : 0; size_t generatorNum = dstFormat; @@ -1244,7 +1244,7 @@ bool PSTextureEncoder::SetStaticShader(unsigned int dstFormat, unsigned int srcF } INFO_LOG(VIDEO, "Compiling efb encoding shader for dstFormat 0x%X, srcFormat %d, isIntensity %d, scaleByHalf %d", - dstFormat, srcFormat, isIntensity ? 1 : 0, scaleByHalf ? 1 : 0); + dstFormat, static_cast(srcFormat), isIntensity ? 1 : 0, scaleByHalf ? 1 : 0); // Shader permutation not found, so compile it D3DBlob* bytecode = nullptr; @@ -1258,7 +1258,7 @@ bool PSTextureEncoder::SetStaticShader(unsigned int dstFormat, unsigned int srcF if (!D3D::CompilePixelShader(EFB_ENCODE_PS, sizeof(EFB_ENCODE_PS), &bytecode, macros)) { WARN_LOG(VIDEO, "EFB encoder shader for dstFormat 0x%X, srcFormat %d, isIntensity %d, scaleByHalf %d failed to compile", - dstFormat, srcFormat, isIntensity ? 1 : 0, scaleByHalf ? 1 : 0); + dstFormat, static_cast(srcFormat), isIntensity ? 1 : 0, scaleByHalf ? 1 : 0); // Add dummy shader to map to prevent trying to compile over and // over again m_staticShaders[key] = nullptr; @@ -1369,9 +1369,9 @@ static const char* INTENSITY_CLASS_NAMES[2] = { }; bool PSTextureEncoder::SetDynamicShader(unsigned int dstFormat, - unsigned int srcFormat, bool isIntensity, bool scaleByHalf) + PEControl::PixelFormat srcFormat, bool isIntensity, bool scaleByHalf) { - size_t fetchNum = srcFormat; + size_t fetchNum = static_cast(srcFormat); size_t scaledFetchNum = scaleByHalf ? 1 : 0; size_t intensityNum = isIntensity ? 1 : 0; size_t generatorNum = dstFormat; diff --git a/Source/Core/VideoBackends/D3D/PSTextureEncoder.h b/Source/Core/VideoBackends/D3D/PSTextureEncoder.h index e581775b73..c14020acfe 100644 --- a/Source/Core/VideoBackends/D3D/PSTextureEncoder.h +++ b/Source/Core/VideoBackends/D3D/PSTextureEncoder.h @@ -32,8 +32,8 @@ public: void Init(); void Shutdown(); size_t Encode(u8* dst, unsigned int dstFormat, - unsigned int srcFormat, const EFBRectangle& srcRect, bool isIntensity, - bool scaleByHalf); + PEControl::PixelFormat srcFormat, const EFBRectangle& srcRect, + bool isIntensity, bool scaleByHalf); private: @@ -54,15 +54,15 @@ private: // Stuff only used in static-linking mode (SM4.0-compatible) bool InitStaticMode(); - bool SetStaticShader(unsigned int dstFormat, unsigned int srcFormat, - bool isIntensity, bool scaleByHalf); + bool SetStaticShader(unsigned int dstFormat, + PEControl::PixelFormat srcFormat, bool isIntensity, bool scaleByHalf); typedef unsigned int ComboKey; // Key for a shader combination - ComboKey MakeComboKey(unsigned int dstFormat, unsigned int srcFormat, - bool isIntensity, bool scaleByHalf) + ComboKey MakeComboKey(unsigned int dstFormat, + PEControl::PixelFormat srcFormat, bool isIntensity, bool scaleByHalf) { - return (dstFormat << 4) | (srcFormat << 2) | (isIntensity ? (1<<1) : 0) + return (dstFormat << 4) | (static_cast(srcFormat) << 2) | (isIntensity ? (1<<1) : 0) | (scaleByHalf ? (1<<0) : 0); } @@ -74,8 +74,8 @@ private: // Microsoft fixes their bloody HLSL compiler) bool InitDynamicMode(); - bool SetDynamicShader(unsigned int dstFormat, unsigned int srcFormat, - bool isIntensity, bool scaleByHalf); + bool SetDynamicShader(unsigned int dstFormat, + PEControl::PixelFormat srcFormat, bool isIntensity, bool scaleByHalf); ID3D11PixelShader* m_dynamicShader; ID3D11ClassLinkage* m_classLinkage; diff --git a/Source/Core/VideoBackends/D3D/Render.cpp b/Source/Core/VideoBackends/D3D/Render.cpp index 6ed8ae82bc..f890726e35 100644 --- a/Source/Core/VideoBackends/D3D/Render.cpp +++ b/Source/Core/VideoBackends/D3D/Render.cpp @@ -315,7 +315,7 @@ void Renderer::SetColorMask() UINT8 color_mask = 0; if (bpmem.alpha_test.TestResult() != AlphaTest::FAIL) { - if (bpmem.blendmode.alphaupdate && (bpmem.zcontrol.pixel_format == PIXELFMT_RGBA6_Z24)) + if (bpmem.blendmode.alphaupdate && (bpmem.zcontrol.pixel_format == PEControl::RGBA6_Z24)) color_mask = D3D11_COLOR_WRITE_ENABLE_ALPHA; if (bpmem.blendmode.colorupdate) color_mask |= D3D11_COLOR_WRITE_ENABLE_RED | D3D11_COLOR_WRITE_ENABLE_GREEN | D3D11_COLOR_WRITE_ENABLE_BLUE; @@ -409,7 +409,7 @@ u32 Renderer::AccessEFB(EFBAccessType type, u32 x, u32 y, u32 poke_data) float val = *(float*)map.pData; u32 ret = 0; - if (bpmem.zcontrol.pixel_format == PIXELFMT_RGB565_Z16) + if (bpmem.zcontrol.pixel_format == PEControl::RGB565_Z16) { // if Z is in 16 bit format you must return a 16 bit integer ret = ((u32)(val * 0xffff)); @@ -440,15 +440,15 @@ u32 Renderer::AccessEFB(EFBAccessType type, u32 x, u32 y, u32 poke_data) // check what to do with the alpha channel (GX_PokeAlphaRead) PixelEngine::UPEAlphaReadReg alpha_read_mode = PixelEngine::GetAlphaReadMode(); - if (bpmem.zcontrol.pixel_format == PIXELFMT_RGBA6_Z24) + if (bpmem.zcontrol.pixel_format == PEControl::RGBA6_Z24) { ret = RGBA8ToRGBA6ToRGBA8(ret); } - else if (bpmem.zcontrol.pixel_format == PIXELFMT_RGB565_Z16) + else if (bpmem.zcontrol.pixel_format == PEControl::RGB565_Z16) { ret = RGBA8ToRGB565ToRGBA8(ret); } - if (bpmem.zcontrol.pixel_format != PIXELFMT_RGBA6_Z24) + if (bpmem.zcontrol.pixel_format != PEControl::RGBA6_Z24) { ret |= 0xFF000000; } @@ -634,7 +634,7 @@ void Renderer::SetBlendMode(bool forceUpdate) { // Our render target always uses an alpha channel, so we need to override the blend functions to assume a destination alpha of 1 if the render target isn't supposed to have an alpha channel // Example: D3DBLEND_DESTALPHA needs to be D3DBLEND_ONE since the result without an alpha channel is assumed to always be 1. - bool target_has_alpha = bpmem.zcontrol.pixel_format == PIXELFMT_RGBA6_Z24; + bool target_has_alpha = bpmem.zcontrol.pixel_format == PEControl::RGBA6_Z24; const D3D11_BLEND d3dSrcFactors[8] = { D3D11_BLEND_ZERO, diff --git a/Source/Core/VideoBackends/D3D/TextureCache.cpp b/Source/Core/VideoBackends/D3D/TextureCache.cpp index 608cbd67cc..773833ee18 100644 --- a/Source/Core/VideoBackends/D3D/TextureCache.cpp +++ b/Source/Core/VideoBackends/D3D/TextureCache.cpp @@ -121,7 +121,7 @@ TextureCache::TCacheEntryBase* TextureCache::CreateTexture(unsigned int width, } void TextureCache::TCacheEntry::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) { @@ -159,9 +159,9 @@ void TextureCache::TCacheEntry::FromRenderTarget(u32 dstAddr, unsigned int dstFo // Create texture copy D3D::drawShadedTexQuad( - (srcFormat == PIXELFMT_Z24) ? FramebufferManager::GetEFBDepthTexture()->GetSRV() : FramebufferManager::GetEFBColorTexture()->GetSRV(), + (srcFormat == PEControl::Z24) ? FramebufferManager::GetEFBDepthTexture()->GetSRV() : FramebufferManager::GetEFBColorTexture()->GetSRV(), &sourcerect, Renderer::GetTargetWidth(), Renderer::GetTargetHeight(), - (srcFormat == PIXELFMT_Z24) ? PixelShaderCache::GetDepthMatrixProgram(true) : PixelShaderCache::GetColorMatrixProgram(true), + (srcFormat == PEControl::Z24) ? PixelShaderCache::GetDepthMatrixProgram(true) : PixelShaderCache::GetColorMatrixProgram(true), VertexShaderCache::GetSimpleVertexShader(), VertexShaderCache::GetSimpleInputLayout()); D3D::context->OMSetRenderTargets(1, &FramebufferManager::GetEFBColorTexture()->GetRTV(), FramebufferManager::GetEFBDepthTexture()->GetDSV()); diff --git a/Source/Core/VideoBackends/D3D/TextureCache.h b/Source/Core/VideoBackends/D3D/TextureCache.h index 569f2d024f..6045d3f7db 100644 --- a/Source/Core/VideoBackends/D3D/TextureCache.h +++ b/Source/Core/VideoBackends/D3D/TextureCache.h @@ -30,7 +30,7 @@ private: unsigned int expanded_width, unsigned int levels) override; 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) override; diff --git a/Source/Core/VideoBackends/D3D/TextureEncoder.h b/Source/Core/VideoBackends/D3D/TextureEncoder.h index 56f4092ea8..d5448088e1 100644 --- a/Source/Core/VideoBackends/D3D/TextureEncoder.h +++ b/Source/Core/VideoBackends/D3D/TextureEncoder.h @@ -111,8 +111,8 @@ public: virtual void Shutdown() = 0; // Returns size in bytes of encoded block of memory virtual size_t Encode(u8* dst, unsigned int dstFormat, - unsigned int srcFormat, const EFBRectangle& srcRect, bool isIntensity, - bool scaleByHalf) = 0; + PEControl::PixelFormat srcFormat, const EFBRectangle& srcRect, + bool isIntensity, bool scaleByHalf) = 0; }; diff --git a/Source/Core/VideoBackends/OGL/Render.cpp b/Source/Core/VideoBackends/OGL/Render.cpp index a9ea91f7bc..e493150de7 100644 --- a/Source/Core/VideoBackends/OGL/Render.cpp +++ b/Source/Core/VideoBackends/OGL/Render.cpp @@ -877,7 +877,7 @@ void Renderer::SetColorMask() { if (bpmem.blendmode.colorupdate) ColorMask = GL_TRUE; - if (bpmem.blendmode.alphaupdate && (bpmem.zcontrol.pixel_format == PIXELFMT_RGBA6_Z24)) + if (bpmem.blendmode.alphaupdate && (bpmem.zcontrol.pixel_format == PEControl::RGBA6_Z24)) AlphaMask = GL_TRUE; } glColorMask(ColorMask, ColorMask, ColorMask, AlphaMask); @@ -989,7 +989,7 @@ u32 Renderer::AccessEFB(EFBAccessType type, u32 x, u32 y, u32 poke_data) // Scale the 32-bit value returned by glReadPixels to a 24-bit // value (GC uses a 24-bit Z-buffer). // TODO: in RE0 this value is often off by one, which causes lighting to disappear - if (bpmem.zcontrol.pixel_format == PIXELFMT_RGB565_Z16) + if (bpmem.zcontrol.pixel_format == PEControl::RGB565_Z16) { // if Z is in 16 bit format you must return a 16 bit integer z = z >> 16; @@ -1047,15 +1047,15 @@ u32 Renderer::AccessEFB(EFBAccessType type, u32 x, u32 y, u32 poke_data) // check what to do with the alpha channel (GX_PokeAlphaRead) PixelEngine::UPEAlphaReadReg alpha_read_mode = PixelEngine::GetAlphaReadMode(); - if (bpmem.zcontrol.pixel_format == PIXELFMT_RGBA6_Z24) + if (bpmem.zcontrol.pixel_format == PEControl::RGBA6_Z24) { color = RGBA8ToRGBA6ToRGBA8(color); } - else if (bpmem.zcontrol.pixel_format == PIXELFMT_RGB565_Z16) + else if (bpmem.zcontrol.pixel_format == PEControl::RGB565_Z16) { color = RGBA8ToRGB565ToRGBA8(color); } - if (bpmem.zcontrol.pixel_format != PIXELFMT_RGBA6_Z24) + if (bpmem.zcontrol.pixel_format != PEControl::RGBA6_Z24) { color |= 0xFF000000; } @@ -1207,7 +1207,7 @@ void Renderer::SetBlendMode(bool forceUpdate) { // Our render target always uses an alpha channel, so we need to override the blend functions to assume a destination alpha of 1 if the render target isn't supposed to have an alpha channel // Example: D3DBLEND_DESTALPHA needs to be D3DBLEND_ONE since the result without an alpha channel is assumed to always be 1. - bool target_has_alpha = bpmem.zcontrol.pixel_format == PIXELFMT_RGBA6_Z24; + bool target_has_alpha = bpmem.zcontrol.pixel_format == PEControl::RGBA6_Z24; bool useDstAlpha = !g_ActiveConfig.bDstAlphaPass && bpmem.dstalpha.enable && bpmem.blendmode.alphaupdate && target_has_alpha; bool useDualSource = useDstAlpha && g_ActiveConfig.backend_info.bSupportsDualSourceBlend; diff --git a/Source/Core/VideoBackends/OGL/TextureCache.cpp b/Source/Core/VideoBackends/OGL/TextureCache.cpp index 6a20813e80..3757bc45f9 100644 --- a/Source/Core/VideoBackends/OGL/TextureCache.cpp +++ b/Source/Core/VideoBackends/OGL/TextureCache.cpp @@ -258,14 +258,14 @@ TextureCache::TCacheEntryBase* TextureCache::CreateRenderTargetTexture( } void TextureCache::TCacheEntry::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) { g_renderer->ResetAPIState(); // reset any game specific settings // Make sure to resolve anything we need to read from. - const GLuint read_texture = (srcFormat == PIXELFMT_Z24) ? + const GLuint read_texture = (srcFormat == PEControl::Z24) ? FramebufferManager::ResolveAndGetDepthTarget(srcRect) : FramebufferManager::ResolveAndGetRenderTarget(srcRect); @@ -282,7 +282,7 @@ void TextureCache::TCacheEntry::FromRenderTarget(u32 dstAddr, unsigned int dstFo glViewport(0, 0, virtual_width, virtual_height); - if (srcFormat == PIXELFMT_Z24) + if (srcFormat == PEControl::Z24) { s_DepthMatrixProgram.Bind(); if (s_DepthCbufid != cbufid) @@ -298,7 +298,7 @@ void TextureCache::TCacheEntry::FromRenderTarget(u32 dstAddr, unsigned int dstFo } TargetRectangle R = g_renderer->ConvertEFBRectangle(srcRect); - glUniform4f(srcFormat == PIXELFMT_Z24 ? s_DepthCopyPositionUniform : s_ColorCopyPositionUniform, + glUniform4f(srcFormat == PEControl::Z24 ? s_DepthCopyPositionUniform : s_ColorCopyPositionUniform, R.left, R.top, R.right, R.bottom); GL_REPORT_ERRORD(); @@ -312,7 +312,7 @@ void TextureCache::TCacheEntry::FromRenderTarget(u32 dstAddr, unsigned int dstFo int encoded_size = TextureConverter::EncodeToRamFromTexture( addr, read_texture, - srcFormat == PIXELFMT_Z24, + srcFormat == PEControl::Z24, isIntensity, dstFormat, scaleByHalf, diff --git a/Source/Core/VideoBackends/OGL/TextureCache.h b/Source/Core/VideoBackends/OGL/TextureCache.h index 19190efd0d..e1e2ec694c 100644 --- a/Source/Core/VideoBackends/OGL/TextureCache.h +++ b/Source/Core/VideoBackends/OGL/TextureCache.h @@ -43,7 +43,7 @@ private: unsigned int expanded_width, unsigned int level) override; 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) override; diff --git a/Source/Core/VideoBackends/Software/EfbInterface.cpp b/Source/Core/VideoBackends/Software/EfbInterface.cpp index dffe392e6f..b994193b09 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(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(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(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(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,31 +195,31 @@ namespace EfbInterface } break; default: - ERROR_LOG(VIDEO, "Unsupported pixel format: %i", bpmem.zcontrol.pixel_format); + ERROR_LOG(VIDEO, "Unsupported pixel format: %i", static_cast(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(bpmem.zcontrol.pixel_format)); } return depth; 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); } } 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(old_format), static_cast(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(new_format), static_cast(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 6f49e12c08..356ee6c133 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" diff --git a/Source/Core/VideoCommon/BPMemory.h b/Source/Core/VideoCommon/BPMemory.h index ca08d9b9a7..ef7c41d88d 100644 --- a/Source/Core/VideoCommon/BPMemory.h +++ b/Source/Core/VideoCommon/BPMemory.h @@ -773,36 +773,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; }; @@ -999,7 +1001,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/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/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);