diff --git a/include/PICA/regs.hpp b/include/PICA/regs.hpp index 0337cc1f..e1c9a819 100644 --- a/include/PICA/regs.hpp +++ b/include/PICA/regs.hpp @@ -10,6 +10,13 @@ namespace PICA { ViewportHeight = 0x43, ViewportInvh = 0x44, + // Clipping plane control + ClipEnable = 0x47, + ClipData0 = 0x48, + ClipData1 = 0x49, + ClipData2 = 0x4A, + ClipData3 = 0x4B, + DepthScale = 0x4D, DepthOffset = 0x4E, ShaderOutputCount = 0x4F, diff --git a/include/opengl.hpp b/include/opengl.hpp index 9d93078b..b259381b 100644 --- a/include/opengl.hpp +++ b/include/opengl.hpp @@ -1,5 +1,5 @@ /*************************************************************************** - * Copyright (C) 2022 PCSX-Redux authors * + * Copyright (C) 2022 PCSX-Redux & Panda3DS authors * * * * 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 * @@ -524,6 +524,9 @@ namespace OpenGL { static void enableStencil() { glEnable(GL_STENCIL_TEST); } static void disableStencil() { glDisable(GL_STENCIL_TEST); } + static void enableClipPlane(GLuint index) { glEnable(GL_CLIP_DISTANCE0 + index); } + static void disableClipPlane(GLuint index) { glDisable(GL_CLIP_DISTANCE0 + index); } + static void setDepthFunc(DepthFunc func) { glDepthFunc(static_cast(func)); } enum Primitives { diff --git a/src/core/PICA/regs.cpp b/src/core/PICA/regs.cpp index 7cc097de..a0eb5adc 100644 --- a/src/core/PICA/regs.cpp +++ b/src/core/PICA/regs.cpp @@ -26,12 +26,12 @@ void GPU::writeReg(u32 address, u32 value) { u32 GPU::readInternalReg(u32 index) { using namespace PICA::InternalRegs; - if (index > regNum) { + if (index > regNum) [[unlikely]] { Helpers::panic("Tried to read invalid GPU register. Index: %X\n", index); return 0; } - else if (index >= LightingLUTData0 && index <= LightingLUTData7) { + else if (index >= LightingLUTData0 && index <= LightingLUTData7) [[unlikely]] { const uint32_t index = regs[LightingLUTIndex]; // Get full LUT index register const uint32_t lutID = getBits<8, 5>(index); // Get which LUT we're actually writing to uint32_t lutIndex = getBits<0, 8>(index); // And get the index inside the LUT we're writing to @@ -53,7 +53,7 @@ u32 GPU::readInternalReg(u32 index) { void GPU::writeInternalReg(u32 index, u32 value, u32 mask) { using namespace PICA::InternalRegs; - if (index > regNum) { + if (index > regNum) [[unlikely]] { Helpers::panic("Tried to write to invalid GPU register. Index: %X, value: %08X\n", index, value); return; }