mirror of
https://github.com/wheremyfoodat/Panda3DS.git
synced 2025-06-07 03:21:38 +12:00
[OpenGL] More efficient colour mask handling
This commit is contained in:
parent
feacb9359d
commit
d80785cbb5
3 changed files with 23 additions and 1 deletions
|
@ -22,12 +22,16 @@ struct GLStateManager {
|
||||||
bool depthEnabled;
|
bool depthEnabled;
|
||||||
bool scissorEnabled;
|
bool scissorEnabled;
|
||||||
|
|
||||||
|
// Colour mask
|
||||||
|
bool redMask, greenMask, blueMask, alphaMask;
|
||||||
|
|
||||||
GLuint boundVAO;
|
GLuint boundVAO;
|
||||||
GLuint boundVBO;
|
GLuint boundVBO;
|
||||||
GLuint currentProgram;
|
GLuint currentProgram;
|
||||||
|
|
||||||
void reset();
|
void reset();
|
||||||
void resetBlend();
|
void resetBlend();
|
||||||
|
void resetColourMask();
|
||||||
void resetDepth();
|
void resetDepth();
|
||||||
void resetVAO();
|
void resetVAO();
|
||||||
void resetVBO();
|
void resetVBO();
|
||||||
|
@ -97,6 +101,17 @@ struct GLStateManager {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void setColourMask(bool r, bool g, bool b, bool a) {
|
||||||
|
if (r != redMask || g != greenMask || b != blueMask || a != alphaMask) {
|
||||||
|
r = redMask;
|
||||||
|
g = greenMask;
|
||||||
|
b = blueMask;
|
||||||
|
a = alphaMask;
|
||||||
|
|
||||||
|
glColorMask(r, g, b, a);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void bindVAO(const OpenGL::VertexArray& vao) { bindVAO(vao.handle()); }
|
void bindVAO(const OpenGL::VertexArray& vao) { bindVAO(vao.handle()); }
|
||||||
void bindVBO(const OpenGL::VertexBuffer& vbo) { bindVBO(vbo.handle()); }
|
void bindVBO(const OpenGL::VertexBuffer& vbo) { bindVBO(vbo.handle()); }
|
||||||
void useProgram(const OpenGL::Program& program) { useProgram(program.handle()); }
|
void useProgram(const OpenGL::Program& program) { useProgram(program.handle()); }
|
||||||
|
|
|
@ -850,7 +850,7 @@ void Renderer::drawVertices(PICA::PrimType primType, std::span<const Vertex> ver
|
||||||
const bool depthWriteEnable = getBit<12>(depthControl);
|
const bool depthWriteEnable = getBit<12>(depthControl);
|
||||||
const int depthFunc = getBits<4, 3>(depthControl);
|
const int depthFunc = getBits<4, 3>(depthControl);
|
||||||
const int colourMask = getBits<8, 4>(depthControl);
|
const int colourMask = getBits<8, 4>(depthControl);
|
||||||
glColorMask(colourMask & 1, colourMask & 2, colourMask & 4, colourMask & 8);
|
gl.setColourMask(colourMask & 1, colourMask & 2, colourMask & 4, colourMask & 8);
|
||||||
|
|
||||||
static constexpr std::array<GLenum, 8> depthModes = {
|
static constexpr std::array<GLenum, 8> depthModes = {
|
||||||
GL_NEVER, GL_ALWAYS, GL_EQUAL, GL_NOTEQUAL, GL_LESS, GL_LEQUAL, GL_GREATER, GL_GEQUAL
|
GL_NEVER, GL_ALWAYS, GL_EQUAL, GL_NOTEQUAL, GL_LESS, GL_LEQUAL, GL_GREATER, GL_GEQUAL
|
||||||
|
@ -1012,6 +1012,7 @@ void Renderer::displayTransfer(u32 inputAddr, u32 outputAddr, u32 inputSize, u32
|
||||||
gl.disableBlend();
|
gl.disableBlend();
|
||||||
gl.disableDepth();
|
gl.disableDepth();
|
||||||
gl.disableScissor();
|
gl.disableScissor();
|
||||||
|
gl.setColourMask(true, true, true, true);
|
||||||
gl.useProgram(displayProgram);
|
gl.useProgram(displayProgram);
|
||||||
gl.bindVAO(dummyVAO);
|
gl.bindVAO(dummyVAO);
|
||||||
|
|
||||||
|
|
|
@ -5,6 +5,11 @@ void GLStateManager::resetBlend() {
|
||||||
OpenGL::disableBlend();
|
OpenGL::disableBlend();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void GLStateManager::resetColourMask() {
|
||||||
|
redMask = greenMask = blueMask = alphaMask = true;
|
||||||
|
glColorMask(redMask, greenMask, blueMask, alphaMask);
|
||||||
|
}
|
||||||
|
|
||||||
void GLStateManager::resetDepth() {
|
void GLStateManager::resetDepth() {
|
||||||
depthEnabled = false;
|
depthEnabled = false;
|
||||||
OpenGL::disableDepth();
|
OpenGL::disableDepth();
|
||||||
|
@ -33,6 +38,7 @@ void GLStateManager::resetProgram() {
|
||||||
|
|
||||||
void GLStateManager::reset() {
|
void GLStateManager::reset() {
|
||||||
resetBlend();
|
resetBlend();
|
||||||
|
resetColourMask();
|
||||||
resetDepth();
|
resetDepth();
|
||||||
|
|
||||||
resetVAO();
|
resetVAO();
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue