[GL] Fix glClear call

This commit is contained in:
wheremyfoodat 2023-07-27 21:47:39 +03:00
parent 60655febba
commit 1ea0b39a3b

View file

@ -488,6 +488,8 @@ void RendererGL::clearBuffer(u32 startAddress, u32 endAddress, u32 value, u32 co
const auto depth = depthBufferCache.findFromAddress(startAddress); const auto depth = depthBufferCache.findFromAddress(startAddress);
if (depth) { if (depth) {
depth->get().fbo.bind(OpenGL::DrawFramebuffer);
float depthVal; float depthVal;
const auto format = depth->get().format; const auto format = depth->get().format;
if (format == DepthFmt::Depth16) { if (format == DepthFmt::Depth16) {
@ -495,15 +497,17 @@ void RendererGL::clearBuffer(u32 startAddress, u32 endAddress, u32 value, u32 co
} else { } else {
depthVal = (value & 0xffffff) / 16777215.0f; depthVal = (value & 0xffffff) / 16777215.0f;
} }
depth->get().fbo.bind(OpenGL::DrawFramebuffer);
gl.setDepthMask(true); gl.setDepthMask(true);
OpenGL::setClearDepth(depthVal); OpenGL::setClearDepth(depthVal);
OpenGL::clearDepth();
if (format == DepthFmt::Depth24Stencil8) { if (format == DepthFmt::Depth24Stencil8) {
const u8 stencil = (value >> 24); const u8 stencil = (value >> 24);
OpenGL::setStencilMask(0xFF); OpenGL::setStencilMask(0xff);
OpenGL::setClearStencil(stencil); OpenGL::setClearStencil(stencil);
OpenGL::clearStencil(); OpenGL::clearDepthAndStencil();
} else {
OpenGL::clearDepth();
} }
return; return;