mirror of
https://github.com/hrydgard/ppsspp.git
synced 2024-11-26 23:10:38 +00:00
Revert DrawPixel changes
This commit is contained in:
parent
fc62d587c0
commit
3af961f3ba
@ -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<int> fogColor = Vec3<int>::FromRGB(pixelID.cached.fogColor);
|
||||
// This is very similar to the BLEND texfunc, and simply always rounds up.
|
||||
static constexpr Vec3<int> roundup = Vec3<int>::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<int> fogColor = Vec3<int>::FromRGB(pixelID.cached.fogColor);
|
||||
// This is very similar to the BLEND texfunc, and simply always rounds up.
|
||||
static constexpr Vec3<int> roundup = Vec3<int>::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<int> dst = Vec4<int>::FromRGBA(old_color);
|
||||
Vec3<int> blended = AlphaBlendingResult(pixelID, prim_color, dst);
|
||||
if (pixelID.dithering) {
|
||||
blended += Vec3<int>::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<int> dst = Vec4<int>::FromRGBA(old_color);
|
||||
Vec3<int> blended = AlphaBlendingResult(pixelID, prim_color, dst);
|
||||
if (pixelID.dithering) {
|
||||
blended += Vec3<int>::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())
|
||||
|
@ -306,8 +306,8 @@ static inline void DrawSpriteTex(const DrawingCoords &pos0, const DrawingCoords
|
||||
template <GEBufferFormat fmt, bool alphaBlend>
|
||||
static void DrawSpriteNoTex(const DrawingCoords &pos0, const DrawingCoords &pos1, u32 color0, const RasterizerState &state) {
|
||||
if constexpr (alphaBlend)
|
||||
if (Vec4<int>::FromRGBA(color0).a() == 0)
|
||||
return;
|
||||
if (Vec4<int>::FromRGBA(color0).a() == 0)
|
||||
return;
|
||||
|
||||
for (int y = pos0.y; y < pos1.y; y++) {
|
||||
if (fmt == GE_FORMAT_8888) {
|
||||
|
Loading…
Reference in New Issue
Block a user