diff --git a/include/PICA/pica_frag_config.hpp b/include/PICA/pica_frag_config.hpp index c77ada14..48f880ce 100644 --- a/include/PICA/pica_frag_config.hpp +++ b/include/PICA/pica_frag_config.hpp @@ -146,7 +146,7 @@ namespace PICA { if (d0.enable) { d0.absInput = Helpers::getBit<1>(lutAbs) == 0; - d0.type = Helpers::getBits<0, 3>(lutSelect); + d0.type = Helpers::getBits<0, 3>(lutSelect); d0.scale = scales[Helpers::getBits<0, 3>(lutScale)]; } @@ -197,12 +197,12 @@ namespace PICA { return std::memcmp(this, &config, sizeof(FragmentConfig)) == 0; } - FragmentConfig(const std::array& regs) : lighting(regs) - { + FragmentConfig(const std::array& regs) : lighting(regs) { auto alphaTestConfig = regs[InternalRegs::AlphaTestConfig]; auto alphaTestFunction = Helpers::getBits<4, 3>(alphaTestConfig); - outConfig.alphaTestFunction = (alphaTestConfig & 1) ? static_cast(alphaTestFunction) : PICA::CompareFunction::Always; + outConfig.alphaTestFunction = + (alphaTestConfig & 1) ? static_cast(alphaTestFunction) : PICA::CompareFunction::Always; outConfig.depthMapEnable = regs[InternalRegs::DepthmapEnable] & 1; texConfig.texUnitConfig = regs[InternalRegs::TexUnitCfg]; @@ -210,9 +210,9 @@ namespace PICA { // Set up TEV stages. Annoyingly we can't just memcpy as the TEV registers are arranged like // {Source, Operand, Combiner, Color, Scale} and we want to skip the color register since it's uploaded via UBO - #define setupTevStage(stage) \ - std::memcpy(&texConfig.tevConfigs[stage * 4], ®s[InternalRegs::TexEnv##stage##Source], 3 * sizeof(u32)); \ - texConfig.tevConfigs[stage * 4 + 3] = regs[InternalRegs::TexEnv##stage##Source + 5]; +#define setupTevStage(stage) \ + std::memcpy(&texConfig.tevConfigs[stage * 4], ®s[InternalRegs::TexEnv##stage##Source], 3 * sizeof(u32)); \ + texConfig.tevConfigs[stage * 4 + 3] = regs[InternalRegs::TexEnv##stage##Source + 5]; setupTevStage(0); setupTevStage(1); @@ -220,7 +220,7 @@ namespace PICA { setupTevStage(3); setupTevStage(4); setupTevStage(5); - #undef setupTevStage +#undef setupTevStage } }; diff --git a/src/core/PICA/shader_gen_glsl.cpp b/src/core/PICA/shader_gen_glsl.cpp index 4420b873..f2e53a87 100644 --- a/src/core/PICA/shader_gen_glsl.cpp +++ b/src/core/PICA/shader_gen_glsl.cpp @@ -594,23 +594,24 @@ bool FragmentGenerator::isSamplerEnabled(u32 environmentID, u32 lutID) { } void FragmentGenerator::compileLUTLookup(std::string& shader, const PICA::FragmentConfig& config, u32 lightIndex, u32 lutID) { + const LightingLUTConfig& lut = config.lighting.luts[lutID]; uint lutIndex = 0; - bool spotAttenuationEnable = true; + bool lutEnabled = false; if (lutID == spotlightLutIndex) { // These are the spotlight attenuation LUTs lutIndex = 8u + lightIndex; - spotAttenuationEnable = config.lighting.lights[lightIndex].spotAttenuationEnable; + lutEnabled = config.lighting.lights[lightIndex].spotAttenuationEnable; } else if (lutID <= 6) { lutIndex = lutID; + lutEnabled = lut.enable; } else { Helpers::warn("Shadergen: Unimplemented LUT value"); } const bool samplerEnabled = isSamplerEnabled(config.lighting.config, lutID); - const LightingLUTConfig& lut = config.lighting.luts[lutID]; - if (!samplerEnabled || !lut.enable || !spotAttenuationEnable) { + if (!samplerEnabled || !lutEnabled) { shader += "lut_lookup_result = 1.0;\n"; return; }