gl_state_tracker: Implement dirty flags for alpha testing
This commit is contained in:
parent
9e46953580
commit
3c22bd92d8
|
@ -1267,13 +1267,23 @@ void RasterizerOpenGL::SyncPolygonOffset() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void RasterizerOpenGL::SyncAlphaTest() {
|
void RasterizerOpenGL::SyncAlphaTest() {
|
||||||
const auto& regs = system.GPU().Maxwell3D().regs;
|
auto& gpu = system.GPU().Maxwell3D();
|
||||||
UNIMPLEMENTED_IF_MSG(regs.alpha_test_enabled != 0 && regs.rt_control.count > 1,
|
auto& flags = gpu.dirty.flags;
|
||||||
"Alpha Testing is enabled with more than one rendertarget");
|
if (!flags[Dirty::AlphaTest]) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
flags[Dirty::AlphaTest] = false;
|
||||||
|
|
||||||
|
const auto& regs = gpu.regs;
|
||||||
|
if (regs.alpha_test_enabled && regs.rt_control.count > 1) {
|
||||||
|
LOG_WARNING(Render_OpenGL, "Alpha testing with more than one render target is not tested");
|
||||||
|
}
|
||||||
|
|
||||||
oglEnable(GL_ALPHA_TEST, regs.alpha_test_enabled);
|
|
||||||
if (regs.alpha_test_enabled) {
|
if (regs.alpha_test_enabled) {
|
||||||
|
glEnable(GL_ALPHA_TEST);
|
||||||
glAlphaFunc(MaxwellToGL::ComparisonOp(regs.alpha_test_func), regs.alpha_test_ref);
|
glAlphaFunc(MaxwellToGL::ComparisonOp(regs.alpha_test_func), regs.alpha_test_ref);
|
||||||
|
} else {
|
||||||
|
glDisable(GL_ALPHA_TEST);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -149,6 +149,13 @@ void SetupDirtyStencilTest(Tables& tables) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void SetupDirtyAlphaTest(Tables& tables) {
|
||||||
|
auto& table = tables[0];
|
||||||
|
table[OFF(alpha_test_ref)] = AlphaTest;
|
||||||
|
table[OFF(alpha_test_func)] = AlphaTest;
|
||||||
|
table[OFF(alpha_test_enabled)] = AlphaTest;
|
||||||
|
}
|
||||||
|
|
||||||
void SetupDirtyBlend(Tables& tables) {
|
void SetupDirtyBlend(Tables& tables) {
|
||||||
FillBlock(tables[0], OFF(blend_color), NUM(blend_color), BlendColor);
|
FillBlock(tables[0], OFF(blend_color), NUM(blend_color), BlendColor);
|
||||||
|
|
||||||
|
@ -205,6 +212,7 @@ void StateTracker::Initialize() {
|
||||||
SetupDirtyShaders(tables);
|
SetupDirtyShaders(tables);
|
||||||
SetupDirtyDepthTest(tables);
|
SetupDirtyDepthTest(tables);
|
||||||
SetupDirtyStencilTest(tables);
|
SetupDirtyStencilTest(tables);
|
||||||
|
SetupDirtyAlphaTest(tables);
|
||||||
SetupDirtyBlend(tables);
|
SetupDirtyBlend(tables);
|
||||||
SetupDirtyPrimitiveRestart(tables);
|
SetupDirtyPrimitiveRestart(tables);
|
||||||
SetupDirtyPolygonOffset(tables);
|
SetupDirtyPolygonOffset(tables);
|
||||||
|
|
|
@ -62,6 +62,7 @@ enum : u8 {
|
||||||
DepthMask,
|
DepthMask,
|
||||||
DepthTest,
|
DepthTest,
|
||||||
StencilTest,
|
StencilTest,
|
||||||
|
AlphaTest,
|
||||||
PrimitiveRestart,
|
PrimitiveRestart,
|
||||||
PolygonOffset,
|
PolygonOffset,
|
||||||
|
|
||||||
|
|
|
@ -195,7 +195,7 @@ layout (location = 0) out vec4 color;
|
||||||
layout (binding = 0) uniform sampler2D color_texture;
|
layout (binding = 0) uniform sampler2D color_texture;
|
||||||
|
|
||||||
void main() {
|
void main() {
|
||||||
color = texture(color_texture, frag_tex_coord);
|
color = vec4(texture(color_texture, frag_tex_coord).rgb, 1.0f);
|
||||||
}
|
}
|
||||||
)";
|
)";
|
||||||
|
|
||||||
|
@ -600,7 +600,6 @@ void RendererOpenGL::DrawScreen(const Layout::FramebufferLayout& layout) {
|
||||||
glDisable(GL_FRAMEBUFFER_SRGB);
|
glDisable(GL_FRAMEBUFFER_SRGB);
|
||||||
}
|
}
|
||||||
glDisable(GL_COLOR_LOGIC_OP);
|
glDisable(GL_COLOR_LOGIC_OP);
|
||||||
glDisable(GL_ALPHA_TEST);
|
|
||||||
glDisable(GL_DEPTH_TEST);
|
glDisable(GL_DEPTH_TEST);
|
||||||
glDisable(GL_STENCIL_TEST);
|
glDisable(GL_STENCIL_TEST);
|
||||||
glDisable(GL_POLYGON_OFFSET_FILL);
|
glDisable(GL_POLYGON_OFFSET_FILL);
|
||||||
|
|
Reference in New Issue