From 3af961f3ba2f15af13884ed1c5b52945cc967634 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20Rydg=C3=A5rd?= Date: Sun, 2 Apr 2023 16:38:44 +0200 Subject: [PATCH] Revert DrawPixel changes --- GPU/Software/DrawPixel.cpp | 71 ++++++++++++---------------- GPU/Software/RasterizerRectangle.cpp | 4 +- 2 files changed, 33 insertions(+), 42 deletions(-) diff --git a/GPU/Software/DrawPixel.cpp b/GPU/Software/DrawPixel.cpp index 35b5d99b8e..eda04b0b41 100644 --- a/GPU/Software/DrawPixel.cpp +++ b/GPU/Software/DrawPixel.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 2013- PPSSPP Project. +// Copyright (c) 2013- PPSSPP Project. // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by @@ -670,33 +670,29 @@ void SOFTRAST_CALL DrawSinglePixel(int x, int y, int z, int fog, Vec4IntArg colo if (z < pixelID.cached.minz || z > pixelID.cached.maxz) return; - if constexpr (!clearMode) - if (pixelID.AlphaTestFunc() != GE_COMP_ALWAYS) - if (!AlphaTestPassed(pixelID, prim_color.a())) - return; + if (pixelID.AlphaTestFunc() != GE_COMP_ALWAYS && !clearMode) + if (!AlphaTestPassed(pixelID, prim_color.a())) + return; // Fog is applied prior to color test. - if constexpr (!clearMode) { - if (pixelID.applyFog) { - Vec3 fogColor = Vec3::FromRGB(pixelID.cached.fogColor); - // This is very similar to the BLEND texfunc, and simply always rounds up. - static constexpr Vec3 roundup = Vec3::AssignToAll(255); - fogColor = (prim_color.rgb() * fog + fogColor * (255 - fog) + roundup) / 256; - prim_color.r() = fogColor.r(); - prim_color.g() = fogColor.g(); - prim_color.b() = fogColor.b(); - } + if (pixelID.applyFog && !clearMode) { + Vec3 fogColor = Vec3::FromRGB(pixelID.cached.fogColor); + // This is very similar to the BLEND texfunc, and simply always rounds up. + static constexpr Vec3 roundup = Vec3::AssignToAll(255); + fogColor = (prim_color.rgb() * fog + fogColor * (255 - fog) + roundup) / 256; + prim_color.r() = fogColor.r(); + prim_color.g() = fogColor.g(); + prim_color.b() = fogColor.b(); } - if constexpr (!clearMode) - if (pixelID.colorTest) - if (!ColorTestPassed(pixelID, prim_color.rgb())) - return; + if (pixelID.colorTest && !clearMode) + if (!ColorTestPassed(pixelID, prim_color.rgb())) + return; // In clear mode, it uses the alpha color as stencil. uint32_t targetWriteMask = pixelID.applyColorWriteMask ? pixelID.cached.colorWriteMask : 0; u8 stencil = clearMode ? prim_color.a() : GetPixelStencil(fbFormat, pixelID.cached.framebufStride, x, y); - if constexpr (clearMode) { + if (clearMode) { if (pixelID.DepthClear()) SetPixelDepth(x, y, pixelID.cached.depthbufStride, z); } else if (pixelID.stencilTest) { @@ -721,27 +717,24 @@ void SOFTRAST_CALL DrawSinglePixel(int x, int y, int z, int fog, Vec4IntArg colo } } - if constexpr (!clearMode) - if (pixelID.depthWrite) - SetPixelDepth(x, y, pixelID.cached.depthbufStride, z); + if (pixelID.depthWrite && !clearMode) + SetPixelDepth(x, y, pixelID.cached.depthbufStride, z); const u32 old_color = GetPixelColor(fbFormat, pixelID.cached.framebufStride, x, y); u32 new_color; // Dithering happens before the logic op and regardless of framebuffer format or clear mode. // We do it while alpha blending because it happens before clamping. - if (pixelID.alphaBlend) { - if constexpr (!clearMode) { - const Vec4 dst = Vec4::FromRGBA(old_color); - Vec3 blended = AlphaBlendingResult(pixelID, prim_color, dst); - if (pixelID.dithering) { - blended += Vec3::AssignToAll(pixelID.cached.ditherMatrix[(y & 3) * 4 + (x & 3)]); - } - - // ToRGB() always automatically clamps. - new_color = blended.ToRGB(); - new_color |= stencil << 24; + if (pixelID.alphaBlend && !clearMode) { + const Vec4 dst = Vec4::FromRGBA(old_color); + Vec3 blended = AlphaBlendingResult(pixelID, prim_color, dst); + if (pixelID.dithering) { + blended += Vec3::AssignToAll(pixelID.cached.ditherMatrix[(y & 3) * 4 + (x & 3)]); } + + // ToRGB() always automatically clamps. + new_color = blended.ToRGB(); + new_color |= stencil << 24; } else { if (pixelID.dithering) { // We'll discard alpha anyway. @@ -757,14 +750,12 @@ void SOFTRAST_CALL DrawSinglePixel(int x, int y, int z, int fog, Vec4IntArg colo } // Logic ops are applied after blending (if blending is enabled.) - if (pixelID.applyLogicOp) { - if constexpr (!clearMode) { - // Logic ops don't affect stencil, which happens inside ApplyLogicOp. - new_color = ApplyLogicOp(pixelID.cached.logicOp, old_color, new_color); - } + if (pixelID.applyLogicOp && !clearMode) { + // Logic ops don't affect stencil, which happens inside ApplyLogicOp. + new_color = ApplyLogicOp(pixelID.cached.logicOp, old_color, new_color); } - if constexpr (clearMode) { + if (clearMode) { if (!pixelID.ColorClear()) new_color = (new_color & 0xFF000000) | (old_color & 0x00FFFFFF); if (!pixelID.StencilClear()) diff --git a/GPU/Software/RasterizerRectangle.cpp b/GPU/Software/RasterizerRectangle.cpp index 16db7ad504..dc87a8b80d 100644 --- a/GPU/Software/RasterizerRectangle.cpp +++ b/GPU/Software/RasterizerRectangle.cpp @@ -306,8 +306,8 @@ static inline void DrawSpriteTex(const DrawingCoords &pos0, const DrawingCoords template static void DrawSpriteNoTex(const DrawingCoords &pos0, const DrawingCoords &pos1, u32 color0, const RasterizerState &state) { if constexpr (alphaBlend) - if (Vec4::FromRGBA(color0).a() == 0) - return; + if (Vec4::FromRGBA(color0).a() == 0) + return; for (int y = pos0.y; y < pos1.y; y++) { if (fmt == GE_FORMAT_8888) {