gl_rasterizer: Fix ScissorTest and Clear when scaling

This commit is contained in:
ameerj 2021-10-22 22:59:30 -04:00 committed by Fernando Sahmkow
parent 172d4f1e3b
commit 93c9eb196f

View File

@ -184,6 +184,9 @@ void RasterizerOpenGL::Clear() {
SyncRasterizeEnable(); SyncRasterizeEnable();
SyncStencilTestState(); SyncStencilTestState();
std::scoped_lock lock{texture_cache.mutex};
texture_cache.UpdateRenderTargets(true);
state_tracker.BindFramebuffer(texture_cache.GetFramebuffer()->Handle());
if (regs.clear_flags.scissor) { if (regs.clear_flags.scissor) {
SyncScissorTest(); SyncScissorTest();
} else { } else {
@ -192,10 +195,6 @@ void RasterizerOpenGL::Clear() {
} }
UNIMPLEMENTED_IF(regs.clear_flags.viewport); UNIMPLEMENTED_IF(regs.clear_flags.viewport);
std::scoped_lock lock{texture_cache.mutex};
texture_cache.UpdateRenderTargets(true);
state_tracker.BindFramebuffer(texture_cache.GetFramebuffer()->Handle());
if (use_color) { if (use_color) {
glClearBufferfv(GL_COLOR, regs.clear_buffers.RT, regs.clear_color); glClearBufferfv(GL_COLOR, regs.clear_buffers.RT, regs.clear_color);
} }
@ -925,12 +924,9 @@ void RasterizerOpenGL::SyncScissorTest() {
const auto& regs = maxwell3d.regs; const auto& regs = maxwell3d.regs;
const auto& resolution = Settings::values.resolution_info; const auto& resolution = Settings::values.resolution_info;
const auto scale_up = [resolution](u32 value) -> u32 { const bool is_rescaling{texture_cache.IsRescaling()};
if (value == 0) { const auto scale_up = [resolution, is_rescaling](u32 value) {
return 0U; return is_rescaling ? resolution.ScaleUp(value) : value;
}
const u32 converted_value = (value * resolution.up_scale) >> resolution.down_shift;
return std::max<u32>(converted_value, 1U);
}; };
for (std::size_t index = 0; index < Maxwell::NumViewports; ++index) { for (std::size_t index = 0; index < Maxwell::NumViewports; ++index) {
if (!force && !flags[Dirty::Scissor0 + index]) { if (!force && !flags[Dirty::Scissor0 + index]) {