From 7218fbbe97dfcbc23be92ca85ef109b0edc55a43 Mon Sep 17 00:00:00 2001 From: "Unknown W. Brackets" Date: Mon, 17 Jan 2022 00:03:06 -0800 Subject: [PATCH] softgpu: Guide more SSE light factor handling. Missed these others in computed state. Helps mostly to do this inside Process(). --- GPU/Software/Lighting.cpp | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/GPU/Software/Lighting.cpp b/GPU/Software/Lighting.cpp index 5489a56c8e..12cf349be3 100644 --- a/GPU/Software/Lighting.cpp +++ b/GPU/Software/Lighting.cpp @@ -41,15 +41,18 @@ static inline float pspLightPow(float v, float e) { return v; } -static inline Vec4 LightColorFactor(uint32_t c, const Vec4 &ones) { +static inline Vec4 LightColorFactor(const Vec4 &expanded, const Vec4 &ones) { #if defined(_M_SSE) && !PPSSPP_ARCH(X86) - Vec4 expanded = Vec4::FromRGBA(c); return _mm_add_epi32(_mm_slli_epi32(expanded.ivec, 1), ones.ivec); #else - return Vec4::FromRGBA(c) * 2 + ones; + return expanded * 2 + ones; #endif } +static inline Vec4 LightColorFactor(uint32_t c, const Vec4 &ones) { + return LightColorFactor(Vec4::FromRGBA(c), ones); +} + static inline bool IsLargerThanHalf(const Vec4 &v) { #if defined(_M_SSE) && !PPSSPP_ARCH(X86) __m128i add23 = _mm_add_epi32(v.ivec, _mm_shuffle_epi32(v.ivec, _MM_SHUFFLE(3, 2, 3, 2))); @@ -121,7 +124,7 @@ void ComputeState(State *state, bool hasColor0) { state->colorForSpecular = (materialupdate & 4) != 0; if (!state->colorForAmbient) { - state->material.ambientColorFactor = Vec4::FromRGBA(gstate.getMaterialAmbientRGBA()) * 2 + ones; + state->material.ambientColorFactor = LightColorFactor(gstate.getMaterialAmbientRGBA(), ones); if (state->material.ambientColorFactor == ones && anyAmbient) { for (int i = 0; i < 4; ++i) state->lights[i].ambient = false; @@ -129,7 +132,7 @@ void ComputeState(State *state, bool hasColor0) { } if (anyDiffuse && !state->colorForDiffuse) { - state->material.diffuseColorFactor = Vec4::FromRGBA(gstate.getMaterialDiffuse()) * 2 + ones; + state->material.diffuseColorFactor = LightColorFactor(gstate.getMaterialDiffuse(), ones); if (state->material.diffuseColorFactor == ones) { anyDiffuse = false; for (int i = 0; i < 4; ++i) @@ -138,7 +141,7 @@ void ComputeState(State *state, bool hasColor0) { } if (anySpecular && !state->colorForSpecular) { - state->material.specularColorFactor = Vec4::FromRGBA(gstate.getMaterialSpecular()) * 2 + ones; + state->material.specularColorFactor = LightColorFactor(gstate.getMaterialSpecular(), ones); if (state->material.specularColorFactor == ones) { anySpecular = false; for (int i = 0; i < 4; ++i) @@ -180,7 +183,7 @@ void Process(VertexData &vertex, const WorldCoords &worldpos, const WorldCoords const Vec4 ones = Vec4::AssignToAll(1); Vec4 colorFactor; if (state.colorForAmbient || state.colorForDiffuse || state.colorForSpecular) - colorFactor = vertex.color0 * 2 + ones; + colorFactor = LightColorFactor(vertex.color0, ones); Vec4 mec = Vec4::FromRGBA(gstate.getMaterialEmissive());