gl_state_tracker: Implement depth dirty flags
This commit is contained in:
parent
b910a83a47
commit
40a2c57df5
|
@ -1024,13 +1024,23 @@ void RasterizerOpenGL::SyncPrimitiveRestart() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void RasterizerOpenGL::SyncDepthTestState() {
|
void RasterizerOpenGL::SyncDepthTestState() {
|
||||||
const auto& regs = system.GPU().Maxwell3D().regs;
|
auto& gpu = system.GPU().Maxwell3D();
|
||||||
|
auto& flags = gpu.dirty.flags;
|
||||||
|
|
||||||
glDepthMask(regs.depth_write_enabled ? GL_TRUE : GL_FALSE);
|
const auto& regs = gpu.regs;
|
||||||
|
if (flags[Dirty::DepthMask]) {
|
||||||
|
flags[Dirty::DepthMask] = false;
|
||||||
|
glDepthMask(regs.depth_write_enabled ? GL_TRUE : GL_FALSE);
|
||||||
|
}
|
||||||
|
|
||||||
oglEnable(GL_DEPTH_TEST, regs.depth_test_enable);
|
if (flags[Dirty::DepthTest]) {
|
||||||
if (regs.depth_test_enable) {
|
flags[Dirty::DepthTest] = false;
|
||||||
glDepthFunc(MaxwellToGL::ComparisonOp(regs.depth_test_func));
|
if (regs.depth_test_enable) {
|
||||||
|
glEnable(GL_DEPTH_TEST);
|
||||||
|
glDepthFunc(MaxwellToGL::ComparisonOp(regs.depth_test_func));
|
||||||
|
} else {
|
||||||
|
glDisable(GL_DEPTH_TEST);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -129,6 +129,13 @@ void SetupDirtyShaders(Tables& tables) {
|
||||||
Shaders);
|
Shaders);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void SetupDirtyDepthTest(Tables& tables) {
|
||||||
|
auto& table = tables[0];
|
||||||
|
table[OFF(depth_test_enable)] = DepthTest;
|
||||||
|
table[OFF(depth_write_enabled)] = DepthMask;
|
||||||
|
table[OFF(depth_test_func)] = DepthTest;
|
||||||
|
}
|
||||||
|
|
||||||
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);
|
||||||
|
|
||||||
|
@ -169,6 +176,7 @@ void StateTracker::Initialize() {
|
||||||
SetupDirtyVertexArrays(tables);
|
SetupDirtyVertexArrays(tables);
|
||||||
SetupDirtyVertexFormat(tables);
|
SetupDirtyVertexFormat(tables);
|
||||||
SetupDirtyShaders(tables);
|
SetupDirtyShaders(tables);
|
||||||
|
SetupDirtyDepthTest(tables);
|
||||||
SetupDirtyBlend(tables);
|
SetupDirtyBlend(tables);
|
||||||
SetupDirtyMisc(tables);
|
SetupDirtyMisc(tables);
|
||||||
|
|
||||||
|
|
|
@ -58,8 +58,9 @@ enum : u8 {
|
||||||
|
|
||||||
FrontFace,
|
FrontFace,
|
||||||
CullTest,
|
CullTest,
|
||||||
PrimitiveRestart,
|
DepthMask,
|
||||||
DepthTest,
|
DepthTest,
|
||||||
|
PrimitiveRestart,
|
||||||
StencilTest,
|
StencilTest,
|
||||||
ColorMask,
|
ColorMask,
|
||||||
PolygonOffset,
|
PolygonOffset,
|
||||||
|
@ -129,6 +130,11 @@ public:
|
||||||
flags[OpenGL::Dirty::CullTest] = true;
|
flags[OpenGL::Dirty::CullTest] = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void NotifyDepthTest() {
|
||||||
|
auto& flags = system.GPU().Maxwell3D().dirty.flags;
|
||||||
|
flags[OpenGL::Dirty::DepthTest] = true;
|
||||||
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Core::System& system;
|
Core::System& system;
|
||||||
};
|
};
|
||||||
|
|
|
@ -584,6 +584,7 @@ void RendererOpenGL::DrawScreen(const Layout::FramebufferLayout& layout) {
|
||||||
state_tracker.NotifyFramebuffer();
|
state_tracker.NotifyFramebuffer();
|
||||||
state_tracker.NotifyFrontFace();
|
state_tracker.NotifyFrontFace();
|
||||||
state_tracker.NotifyCullTest();
|
state_tracker.NotifyCullTest();
|
||||||
|
state_tracker.NotifyDepthTest();
|
||||||
|
|
||||||
program_manager.UseVertexShader(vertex_program.handle);
|
program_manager.UseVertexShader(vertex_program.handle);
|
||||||
program_manager.UseGeometryShader(0);
|
program_manager.UseGeometryShader(0);
|
||||||
|
|
Reference in New Issue