gl-render-manager: Implement logic ops
This commit is contained in:
parent
acb692677b
commit
e531a7da43
4 changed files with 41 additions and 9 deletions
|
@ -229,15 +229,7 @@ void DrawEngineGLES::ApplyDrawState(int prim) {
|
||||||
|
|
||||||
#ifndef USING_GLES2
|
#ifndef USING_GLES2
|
||||||
if (gstate_c.Supports(GPU_SUPPORTS_LOGIC_OP)) {
|
if (gstate_c.Supports(GPU_SUPPORTS_LOGIC_OP)) {
|
||||||
// TODO: Make this dynamic
|
renderManager->SetLogicOp(gstate.isLogicOpEnabled(), logicOps[gstate.getLogicOp()]);
|
||||||
// Logic Ops
|
|
||||||
if (gstate.isLogicOpEnabled() && gstate.getLogicOp() != GE_LOGIC_COPY) {
|
|
||||||
// TODO: Fix logic ops.
|
|
||||||
//glstate.colorLogicOp.enable();
|
|
||||||
//glstate.logicOp.set(logicOps[gstate.getLogicOp()]);
|
|
||||||
} else {
|
|
||||||
//glstate.colorLogicOp.disable();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
|
@ -405,6 +405,9 @@ void GLQueueRunner::PerformRenderPass(const GLRStep &step) {
|
||||||
glDisable(GL_CULL_FACE);
|
glDisable(GL_CULL_FACE);
|
||||||
glDisable(GL_DITHER);
|
glDisable(GL_DITHER);
|
||||||
glEnable(GL_SCISSOR_TEST);
|
glEnable(GL_SCISSOR_TEST);
|
||||||
|
#ifndef USING_GLES2
|
||||||
|
glDisable(GL_COLOR_LOGIC_OP);
|
||||||
|
#endif
|
||||||
|
|
||||||
/*
|
/*
|
||||||
#ifndef USING_GLES2
|
#ifndef USING_GLES2
|
||||||
|
@ -430,12 +433,14 @@ void GLQueueRunner::PerformRenderPass(const GLRStep &step) {
|
||||||
int colorMask = -1;
|
int colorMask = -1;
|
||||||
int depthMask = -1;
|
int depthMask = -1;
|
||||||
int depthFunc = -1;
|
int depthFunc = -1;
|
||||||
|
int logicOp = -1;
|
||||||
GLuint curArrayBuffer = (GLuint)-1;
|
GLuint curArrayBuffer = (GLuint)-1;
|
||||||
GLuint curElemArrayBuffer = (GLuint)-1;
|
GLuint curElemArrayBuffer = (GLuint)-1;
|
||||||
bool depthEnabled = false;
|
bool depthEnabled = false;
|
||||||
bool blendEnabled = false;
|
bool blendEnabled = false;
|
||||||
bool cullEnabled = false;
|
bool cullEnabled = false;
|
||||||
bool ditherEnabled = false;
|
bool ditherEnabled = false;
|
||||||
|
bool logicEnabled = false;
|
||||||
GLuint blendEqColor = (GLuint)-1;
|
GLuint blendEqColor = (GLuint)-1;
|
||||||
GLuint blendEqAlpha = (GLuint)-1;
|
GLuint blendEqAlpha = (GLuint)-1;
|
||||||
|
|
||||||
|
@ -496,6 +501,22 @@ void GLQueueRunner::PerformRenderPass(const GLRStep &step) {
|
||||||
colorMask = c.blend.mask;
|
colorMask = c.blend.mask;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
case GLRRenderCommand::LOGICOP:
|
||||||
|
#ifndef USING_GLES2
|
||||||
|
if (c.logic.enabled) {
|
||||||
|
if (!logicEnabled) {
|
||||||
|
glEnable(GL_COLOR_LOGIC_OP);
|
||||||
|
logicEnabled = true;
|
||||||
|
}
|
||||||
|
if (logicOp != c.logic.logicOp) {
|
||||||
|
glLogicOp(c.logic.logicOp);
|
||||||
|
}
|
||||||
|
} else if (!c.logic.enabled && logicEnabled) {
|
||||||
|
glDisable(GL_COLOR_LOGIC_OP);
|
||||||
|
logicEnabled = false;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
break;
|
||||||
case GLRRenderCommand::CLEAR:
|
case GLRRenderCommand::CLEAR:
|
||||||
glDisable(GL_SCISSOR_TEST);
|
glDisable(GL_SCISSOR_TEST);
|
||||||
if (c.clear.colorMask != colorMask) {
|
if (c.clear.colorMask != colorMask) {
|
||||||
|
@ -814,6 +835,9 @@ void GLQueueRunner::PerformRenderPass(const GLRStep &step) {
|
||||||
glDisable(GL_STENCIL_TEST);
|
glDisable(GL_STENCIL_TEST);
|
||||||
glDisable(GL_BLEND);
|
glDisable(GL_BLEND);
|
||||||
glDisable(GL_CULL_FACE);
|
glDisable(GL_CULL_FACE);
|
||||||
|
#ifndef USING_GLES2
|
||||||
|
glDisable(GL_COLOR_LOGIC_OP);
|
||||||
|
#endif
|
||||||
glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE);
|
glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -32,6 +32,7 @@ enum class GLRRenderCommand : uint8_t {
|
||||||
STENCILOP,
|
STENCILOP,
|
||||||
BLEND,
|
BLEND,
|
||||||
BLENDCOLOR,
|
BLENDCOLOR,
|
||||||
|
LOGICOP,
|
||||||
UNIFORM4I,
|
UNIFORM4I,
|
||||||
UNIFORM4F,
|
UNIFORM4F,
|
||||||
UNIFORMMATRIX,
|
UNIFORMMATRIX,
|
||||||
|
@ -55,6 +56,7 @@ enum class GLRRenderCommand : uint8_t {
|
||||||
|
|
||||||
// TODO: Bloated since the biggest struct decides the size. Will need something more efficient (separate structs with shared
|
// TODO: Bloated since the biggest struct decides the size. Will need something more efficient (separate structs with shared
|
||||||
// type field, smashed right after each other?)
|
// type field, smashed right after each other?)
|
||||||
|
// Also, all GLenums are really only 16 bits.
|
||||||
struct GLRRenderData {
|
struct GLRRenderData {
|
||||||
GLRRenderCommand cmd;
|
GLRRenderCommand cmd;
|
||||||
union {
|
union {
|
||||||
|
@ -71,6 +73,10 @@ struct GLRRenderData {
|
||||||
struct {
|
struct {
|
||||||
float color[4];
|
float color[4];
|
||||||
} blendColor;
|
} blendColor;
|
||||||
|
struct {
|
||||||
|
GLboolean enabled;
|
||||||
|
GLenum logicOp;
|
||||||
|
} logic;
|
||||||
struct {
|
struct {
|
||||||
GLboolean enabled;
|
GLboolean enabled;
|
||||||
GLboolean write;
|
GLboolean write;
|
||||||
|
|
|
@ -505,6 +505,16 @@ public:
|
||||||
curRenderStep_->commands.push_back(data);
|
curRenderStep_->commands.push_back(data);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifndef USING_GLES2
|
||||||
|
void SetLogicOp(bool enabled, GLenum logicOp) {
|
||||||
|
_dbg_assert_(G3D, curRenderStep_ && curRenderStep_->stepType == GLRStepType::RENDER);
|
||||||
|
GLRRenderData data{ GLRRenderCommand::LOGICOP };
|
||||||
|
data.logic.enabled = enabled;
|
||||||
|
data.logic.logicOp = logicOp;
|
||||||
|
curRenderStep_->commands.push_back(data);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
void SetStencilFunc(bool enabled, GLenum func, uint8_t refValue, uint8_t compareMask) {
|
void SetStencilFunc(bool enabled, GLenum func, uint8_t refValue, uint8_t compareMask) {
|
||||||
_dbg_assert_(G3D, curRenderStep_ && curRenderStep_->stepType == GLRStepType::RENDER);
|
_dbg_assert_(G3D, curRenderStep_ && curRenderStep_->stepType == GLRStepType::RENDER);
|
||||||
GLRRenderData data{ GLRRenderCommand::STENCILFUNC };
|
GLRRenderData data{ GLRRenderCommand::STENCILFUNC };
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue