Skip to content

Commit

Permalink
A few kissable changes
Browse files Browse the repository at this point in the history
  • Loading branch information
OFFTKP committed Jul 21, 2024
1 parent 82df95c commit b8712b3
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 8 deletions.
2 changes: 1 addition & 1 deletion include/PICA/gpu.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -92,8 +92,8 @@ class GPU {
// Set to false by the renderer when the lighting_lut is uploaded ot the GPU
bool lightingLUTDirty = false;

std::array<uint32_t, 128> fogLUT;
bool fogLUTDirty = false;
std::array<uint32_t, 128> fogLUT;

GPU(Memory& mem, EmulatorConfig& config);
void display() { renderer->display(); }
Expand Down
11 changes: 7 additions & 4 deletions include/PICA/pica_frag_config.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -235,10 +235,13 @@ namespace PICA {
#undef setupTevStage

fogConfig.mode = (FogMode)Helpers::getBits<0, 3>(regs[InternalRegs::TexEnvUpdateBuffer]);
fogConfig.flipDepth = Helpers::getBit<16>(regs[InternalRegs::TexEnvUpdateBuffer]);
fogConfig.fogColorR = Helpers::getBits<0, 8>(regs[InternalRegs::FogColor]);
fogConfig.fogColorG = Helpers::getBits<8, 8>(regs[InternalRegs::FogColor]);
fogConfig.fogColorB = Helpers::getBits<16, 8>(regs[InternalRegs::FogColor]);

if (fogConfig.mode == FogMode::Fog) {
fogConfig.flipDepth = Helpers::getBit<16>(regs[InternalRegs::TexEnvUpdateBuffer]);
fogConfig.fogColorR = Helpers::getBits<0, 8>(regs[InternalRegs::FogColor]);
fogConfig.fogColorG = Helpers::getBits<8, 8>(regs[InternalRegs::FogColor]);
fogConfig.fogColorB = Helpers::getBits<16, 8>(regs[InternalRegs::FogColor]);
}
}
};

Expand Down
4 changes: 2 additions & 2 deletions src/core/PICA/regs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -143,10 +143,10 @@ void GPU::writeInternalReg(u32 index, u32 value, u32 mask) {
case FogLUTData5:
case FogLUTData6:
case FogLUTData7: {
const uint32_t index = regs[FogLUTIndex] & 127;
const uint32_t index = regs[FogLUTIndex] & 0x7F;
fogLUT[index] = value;
fogLUTDirty = true;
regs[FogLUTIndex] = (index + 1) & 127;
regs[FogLUTIndex] = (index + 1) & 0x7F;
break;
}

Expand Down
2 changes: 1 addition & 1 deletion src/core/renderer_gl/renderer_gl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1026,7 +1026,7 @@ void RendererGL::initUbershader(OpenGL::Program& program) {
ubershaderData.depthmapEnableLoc = OpenGL::uniformLocation(program, "u_depthmapEnable");
ubershaderData.picaRegLoc = OpenGL::uniformLocation(program, "u_picaRegs");

// Init sampler objects. Texture 0 goes in texture unit 0, texture 1 in TU 1, texture 2 in TU 2, light maps go in TU 3, and the fog map goes in TU 4
// Init sampler objects. Texture 0 goes in texture unit 0, texture 1 in TU 1, texture 2 in TU 2 and the LUTs go in TU 3
glUniform1i(OpenGL::uniformLocation(program, "u_tex0"), 0);
glUniform1i(OpenGL::uniformLocation(program, "u_tex1"), 1);
glUniform1i(OpenGL::uniformLocation(program, "u_tex2"), 2);
Expand Down

0 comments on commit b8712b3

Please sign in to comment.