3
0
Fork 0
forked from suyu/suyu

GL_Rasterizer: Corrections to Clearing.

This commit is contained in:
Fernando Sahmkow 2019-07-14 15:00:37 -04:00 committed by FernandoS27
parent 0ff4a5fa39
commit 8cdbfe69b1
4 changed files with 28 additions and 12 deletions

View file

@ -568,7 +568,7 @@ void Maxwell3D::FinishCBData() {
const u32 id = cb_data_state.id;
memory_manager.WriteBlock(address, cb_data_state.buff[id].data(), size);
dirty.ResetVertexArrays();
dirty.OnMemoryWrite();
cb_data_state.id = null_cb_data;
cb_data_state.current = null_cb_data;

View file

@ -604,7 +604,8 @@ void RasterizerOpenGL::Clear() {
prev_state.Apply();
});
OpenGLState clear_state;
OpenGLState clear_state{OpenGLState::GetCurState()};
clear_state.DefaultViewports();
if (regs.clear_buffers.R || regs.clear_buffers.G || regs.clear_buffers.B ||
regs.clear_buffers.A) {
use_color = true;
@ -624,6 +625,7 @@ void RasterizerOpenGL::Clear() {
// true.
clear_state.depth.test_enabled = true;
clear_state.depth.test_func = GL_ALWAYS;
clear_state.depth.write_mask = GL_TRUE;
}
if (regs.clear_buffers.S) {
ASSERT_MSG(regs.zeta_enable != 0, "Tried to clear stencil but buffer is not enabled!");
@ -661,6 +663,7 @@ void RasterizerOpenGL::Clear() {
}
ConfigureClearFramebuffer(clear_state, use_color, use_depth, use_stencil);
SyncViewport(clear_state);
if (regs.clear_flags.scissor) {
SyncScissorTest(clear_state);
@ -670,11 +673,8 @@ void RasterizerOpenGL::Clear() {
clear_state.EmulateViewportWithScissor();
}
clear_state.ApplyColorMask();
clear_state.ApplyDepth();
clear_state.ApplyStencilTest();
clear_state.ApplyViewport();
clear_state.ApplyFramebufferState();
clear_state.AllDirty();
clear_state.Apply();
if (use_color) {
glClearBufferfv(GL_COLOR, 0, regs.clear_color);

View file

@ -165,6 +165,26 @@ OpenGLState::OpenGLState() {
alpha_test.ref = 0.0f;
}
void OpenGLState::DefaultViewports() {
for (auto& item : viewports) {
item.x = 0;
item.y = 0;
item.width = 0;
item.height = 0;
item.depth_range_near = 0.0f;
item.depth_range_far = 1.0f;
item.scissor.enabled = false;
item.scissor.x = 0;
item.scissor.y = 0;
item.scissor.width = 0;
item.scissor.height = 0;
}
depth_clamp.far_plane = false;
depth_clamp.near_plane = false;
}
void OpenGLState::ApplyDefaultState() {
glEnable(GL_BLEND);
glDisable(GL_FRAMEBUFFER_SRGB);

View file

@ -195,6 +195,7 @@ public:
s_rgb_used = false;
}
void DefaultViewports();
/// Apply this state as the current OpenGL state
void Apply();
@ -245,10 +246,6 @@ public:
dirty.stencil_state = is_dirty;
}
void MarkDirtyViewportState(const bool is_dirty) {
dirty.viewport_state = is_dirty;
}
void MarkDirtyPolygonOffset(const bool is_dirty) {
dirty.polygon_offset = is_dirty;
}
@ -260,7 +257,6 @@ public:
void AllDirty() {
dirty.blend_state = true;
dirty.stencil_state = true;
dirty.viewport_state = true;
dirty.polygon_offset = true;
dirty.color_mask = true;
}