|
|
|
@ -427,32 +427,6 @@ void RasterizerOpenGL::Clear() { |
|
|
|
if (regs.clear_buffers.S) { |
|
|
|
ASSERT_MSG(regs.zeta_enable != 0, "Tried to clear stencil but buffer is not enabled!"); |
|
|
|
use_stencil = true; |
|
|
|
clear_state.stencil.test_enabled = true; |
|
|
|
|
|
|
|
if (regs.clear_flags.stencil) { |
|
|
|
// Stencil affects the clear so fill it with the used masks
|
|
|
|
clear_state.stencil.front.test_func = GL_ALWAYS; |
|
|
|
clear_state.stencil.front.test_mask = regs.stencil_front_func_mask; |
|
|
|
clear_state.stencil.front.action_stencil_fail = GL_KEEP; |
|
|
|
clear_state.stencil.front.action_depth_fail = GL_KEEP; |
|
|
|
clear_state.stencil.front.action_depth_pass = GL_KEEP; |
|
|
|
clear_state.stencil.front.write_mask = regs.stencil_front_mask; |
|
|
|
if (regs.stencil_two_side_enable) { |
|
|
|
clear_state.stencil.back.test_func = GL_ALWAYS; |
|
|
|
clear_state.stencil.back.test_mask = regs.stencil_back_func_mask; |
|
|
|
clear_state.stencil.back.action_stencil_fail = GL_KEEP; |
|
|
|
clear_state.stencil.back.action_depth_fail = GL_KEEP; |
|
|
|
clear_state.stencil.back.action_depth_pass = GL_KEEP; |
|
|
|
clear_state.stencil.back.write_mask = regs.stencil_back_mask; |
|
|
|
} else { |
|
|
|
clear_state.stencil.back.test_func = GL_ALWAYS; |
|
|
|
clear_state.stencil.back.test_mask = 0xFFFFFFFF; |
|
|
|
clear_state.stencil.back.write_mask = 0xFFFFFFFF; |
|
|
|
clear_state.stencil.back.action_stencil_fail = GL_KEEP; |
|
|
|
clear_state.stencil.back.action_depth_fail = GL_KEEP; |
|
|
|
clear_state.stencil.back.action_depth_pass = GL_KEEP; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
if (!use_color && !use_depth && !use_stencil) { |
|
|
|
@ -1011,35 +985,30 @@ void RasterizerOpenGL::SyncDepthTestState() { |
|
|
|
void RasterizerOpenGL::SyncStencilTestState() { |
|
|
|
auto& maxwell3d = system.GPU().Maxwell3D(); |
|
|
|
const auto& regs = maxwell3d.regs; |
|
|
|
state.stencil.test_enabled = regs.stencil_enable != 0; |
|
|
|
|
|
|
|
oglEnable(GL_STENCIL_TEST, regs.stencil_enable); |
|
|
|
if (!regs.stencil_enable) { |
|
|
|
return; |
|
|
|
} |
|
|
|
|
|
|
|
state.stencil.front.test_func = MaxwellToGL::ComparisonOp(regs.stencil_front_func_func); |
|
|
|
state.stencil.front.test_ref = regs.stencil_front_func_ref; |
|
|
|
state.stencil.front.test_mask = regs.stencil_front_func_mask; |
|
|
|
state.stencil.front.action_stencil_fail = MaxwellToGL::StencilOp(regs.stencil_front_op_fail); |
|
|
|
state.stencil.front.action_depth_fail = MaxwellToGL::StencilOp(regs.stencil_front_op_zfail); |
|
|
|
state.stencil.front.action_depth_pass = MaxwellToGL::StencilOp(regs.stencil_front_op_zpass); |
|
|
|
state.stencil.front.write_mask = regs.stencil_front_mask; |
|
|
|
glStencilFuncSeparate(GL_FRONT, MaxwellToGL::ComparisonOp(regs.stencil_front_func_func), |
|
|
|
regs.stencil_front_func_ref, regs.stencil_front_func_mask); |
|
|
|
glStencilOpSeparate(GL_FRONT, MaxwellToGL::StencilOp(regs.stencil_front_op_fail), |
|
|
|
MaxwellToGL::StencilOp(regs.stencil_front_op_zfail), |
|
|
|
MaxwellToGL::StencilOp(regs.stencil_front_op_zpass)); |
|
|
|
glStencilMaskSeparate(GL_FRONT, regs.stencil_front_mask); |
|
|
|
|
|
|
|
if (regs.stencil_two_side_enable) { |
|
|
|
state.stencil.back.test_func = MaxwellToGL::ComparisonOp(regs.stencil_back_func_func); |
|
|
|
state.stencil.back.test_ref = regs.stencil_back_func_ref; |
|
|
|
state.stencil.back.test_mask = regs.stencil_back_func_mask; |
|
|
|
state.stencil.back.action_stencil_fail = MaxwellToGL::StencilOp(regs.stencil_back_op_fail); |
|
|
|
state.stencil.back.action_depth_fail = MaxwellToGL::StencilOp(regs.stencil_back_op_zfail); |
|
|
|
state.stencil.back.action_depth_pass = MaxwellToGL::StencilOp(regs.stencil_back_op_zpass); |
|
|
|
state.stencil.back.write_mask = regs.stencil_back_mask; |
|
|
|
glStencilFuncSeparate(GL_BACK, MaxwellToGL::ComparisonOp(regs.stencil_back_func_func), |
|
|
|
regs.stencil_back_func_ref, regs.stencil_back_func_mask); |
|
|
|
glStencilOpSeparate(GL_BACK, MaxwellToGL::StencilOp(regs.stencil_back_op_fail), |
|
|
|
MaxwellToGL::StencilOp(regs.stencil_back_op_zfail), |
|
|
|
MaxwellToGL::StencilOp(regs.stencil_back_op_zpass)); |
|
|
|
glStencilMaskSeparate(GL_BACK, regs.stencil_back_mask); |
|
|
|
} else { |
|
|
|
state.stencil.back.test_func = GL_ALWAYS; |
|
|
|
state.stencil.back.test_ref = 0; |
|
|
|
state.stencil.back.test_mask = 0xFFFFFFFF; |
|
|
|
state.stencil.back.write_mask = 0xFFFFFFFF; |
|
|
|
state.stencil.back.action_stencil_fail = GL_KEEP; |
|
|
|
state.stencil.back.action_depth_fail = GL_KEEP; |
|
|
|
state.stencil.back.action_depth_pass = GL_KEEP; |
|
|
|
glStencilFuncSeparate(GL_BACK, GL_ALWAYS, 0, 0xFFFFFFFF); |
|
|
|
glStencilOpSeparate(GL_BACK, GL_KEEP, GL_KEEP, GL_KEEP); |
|
|
|
glStencilMaskSeparate(GL_BACK, 0xFFFFFFFF); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|