GPU: Always enable the depth write when clearing the depth buffer.
The GPU ignores that register when clearing, but OpenGL obeys the glDepthMask parameter, so we set the depth mask to GL_TRUE when clearing the depth buffer. It will be restored to the correct value automatically on the next draw call.
This commit is contained in:
parent
9fc0d1d701
commit
b37354cca8
1 changed files with 8 additions and 3 deletions
|
@ -322,9 +322,6 @@ std::pair<Surface, Surface> RasterizerOpenGL::ConfigureFramebuffers(bool using_c
|
||||||
bool using_depth_fb) {
|
bool using_depth_fb) {
|
||||||
const auto& regs = Core::System().GetInstance().GPU().Maxwell3D().regs;
|
const auto& regs = Core::System().GetInstance().GPU().Maxwell3D().regs;
|
||||||
|
|
||||||
// Sync the depth test state before configuring the framebuffer surfaces.
|
|
||||||
SyncDepthTestState();
|
|
||||||
|
|
||||||
// TODO(bunnei): Implement this
|
// TODO(bunnei): Implement this
|
||||||
const bool has_stencil = false;
|
const bool has_stencil = false;
|
||||||
|
|
||||||
|
@ -389,6 +386,13 @@ void RasterizerOpenGL::Clear() {
|
||||||
if (regs.clear_buffers.Z) {
|
if (regs.clear_buffers.Z) {
|
||||||
clear_mask |= GL_DEPTH_BUFFER_BIT;
|
clear_mask |= GL_DEPTH_BUFFER_BIT;
|
||||||
use_depth_fb = true;
|
use_depth_fb = true;
|
||||||
|
|
||||||
|
// Always enable the depth write when clearing the depth buffer. The depth write mask is
|
||||||
|
// ignored when clearing the buffer in the Switch, but OpenGL obeys it so we set it to true.
|
||||||
|
state.depth.test_enabled = true;
|
||||||
|
state.depth.write_mask = GL_TRUE;
|
||||||
|
state.depth.test_func = GL_ALWAYS;
|
||||||
|
state.Apply();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (clear_mask == 0)
|
if (clear_mask == 0)
|
||||||
|
@ -423,6 +427,7 @@ void RasterizerOpenGL::DrawArrays() {
|
||||||
auto [dirty_color_surface, dirty_depth_surface] =
|
auto [dirty_color_surface, dirty_depth_surface] =
|
||||||
ConfigureFramebuffers(true, regs.zeta.Address() != 0);
|
ConfigureFramebuffers(true, regs.zeta.Address() != 0);
|
||||||
|
|
||||||
|
SyncDepthTestState();
|
||||||
SyncBlendState();
|
SyncBlendState();
|
||||||
SyncCullMode();
|
SyncCullMode();
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue