gl_state_tracker: Implement dirty flags for alpha testing
This commit is contained in:
parent
9e46953580
commit
3c22bd92d8
4 changed files with 24 additions and 6 deletions
|
@ -1267,13 +1267,23 @@ void RasterizerOpenGL::SyncPolygonOffset() {
|
|||
}
|
||||
|
||||
void RasterizerOpenGL::SyncAlphaTest() {
|
||||
const auto& regs = system.GPU().Maxwell3D().regs;
|
||||
UNIMPLEMENTED_IF_MSG(regs.alpha_test_enabled != 0 && regs.rt_control.count > 1,
|
||||
"Alpha Testing is enabled with more than one rendertarget");
|
||||
auto& gpu = system.GPU().Maxwell3D();
|
||||
auto& flags = gpu.dirty.flags;
|
||||
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) {
|
||||
glEnable(GL_ALPHA_TEST);
|
||||
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) {
|
||||
FillBlock(tables[0], OFF(blend_color), NUM(blend_color), BlendColor);
|
||||
|
||||
|
@ -205,6 +212,7 @@ void StateTracker::Initialize() {
|
|||
SetupDirtyShaders(tables);
|
||||
SetupDirtyDepthTest(tables);
|
||||
SetupDirtyStencilTest(tables);
|
||||
SetupDirtyAlphaTest(tables);
|
||||
SetupDirtyBlend(tables);
|
||||
SetupDirtyPrimitiveRestart(tables);
|
||||
SetupDirtyPolygonOffset(tables);
|
||||
|
|
|
@ -62,6 +62,7 @@ enum : u8 {
|
|||
DepthMask,
|
||||
DepthTest,
|
||||
StencilTest,
|
||||
AlphaTest,
|
||||
PrimitiveRestart,
|
||||
PolygonOffset,
|
||||
|
||||
|
|
|
@ -195,7 +195,7 @@ layout (location = 0) out vec4 color;
|
|||
layout (binding = 0) uniform sampler2D color_texture;
|
||||
|
||||
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_COLOR_LOGIC_OP);
|
||||
glDisable(GL_ALPHA_TEST);
|
||||
glDisable(GL_DEPTH_TEST);
|
||||
glDisable(GL_STENCIL_TEST);
|
||||
glDisable(GL_POLYGON_OFFSET_FILL);
|
||||
|
|
Loading…
Reference in a new issue