GL_Rasterizer: Corrections to Clearing.
This commit is contained in:
parent
0ff4a5fa39
commit
8cdbfe69b1
|
@ -568,7 +568,7 @@ void Maxwell3D::FinishCBData() {
|
||||||
|
|
||||||
const u32 id = cb_data_state.id;
|
const u32 id = cb_data_state.id;
|
||||||
memory_manager.WriteBlock(address, cb_data_state.buff[id].data(), size);
|
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.id = null_cb_data;
|
||||||
cb_data_state.current = null_cb_data;
|
cb_data_state.current = null_cb_data;
|
||||||
|
|
|
@ -604,7 +604,8 @@ void RasterizerOpenGL::Clear() {
|
||||||
prev_state.Apply();
|
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 ||
|
if (regs.clear_buffers.R || regs.clear_buffers.G || regs.clear_buffers.B ||
|
||||||
regs.clear_buffers.A) {
|
regs.clear_buffers.A) {
|
||||||
use_color = true;
|
use_color = true;
|
||||||
|
@ -624,6 +625,7 @@ void RasterizerOpenGL::Clear() {
|
||||||
// true.
|
// true.
|
||||||
clear_state.depth.test_enabled = true;
|
clear_state.depth.test_enabled = true;
|
||||||
clear_state.depth.test_func = GL_ALWAYS;
|
clear_state.depth.test_func = GL_ALWAYS;
|
||||||
|
clear_state.depth.write_mask = GL_TRUE;
|
||||||
}
|
}
|
||||||
if (regs.clear_buffers.S) {
|
if (regs.clear_buffers.S) {
|
||||||
ASSERT_MSG(regs.zeta_enable != 0, "Tried to clear stencil but buffer is not enabled!");
|
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);
|
ConfigureClearFramebuffer(clear_state, use_color, use_depth, use_stencil);
|
||||||
|
|
||||||
SyncViewport(clear_state);
|
SyncViewport(clear_state);
|
||||||
if (regs.clear_flags.scissor) {
|
if (regs.clear_flags.scissor) {
|
||||||
SyncScissorTest(clear_state);
|
SyncScissorTest(clear_state);
|
||||||
|
@ -670,11 +673,8 @@ void RasterizerOpenGL::Clear() {
|
||||||
clear_state.EmulateViewportWithScissor();
|
clear_state.EmulateViewportWithScissor();
|
||||||
}
|
}
|
||||||
|
|
||||||
clear_state.ApplyColorMask();
|
clear_state.AllDirty();
|
||||||
clear_state.ApplyDepth();
|
clear_state.Apply();
|
||||||
clear_state.ApplyStencilTest();
|
|
||||||
clear_state.ApplyViewport();
|
|
||||||
clear_state.ApplyFramebufferState();
|
|
||||||
|
|
||||||
if (use_color) {
|
if (use_color) {
|
||||||
glClearBufferfv(GL_COLOR, 0, regs.clear_color);
|
glClearBufferfv(GL_COLOR, 0, regs.clear_color);
|
||||||
|
|
|
@ -165,6 +165,26 @@ OpenGLState::OpenGLState() {
|
||||||
alpha_test.ref = 0.0f;
|
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() {
|
void OpenGLState::ApplyDefaultState() {
|
||||||
glEnable(GL_BLEND);
|
glEnable(GL_BLEND);
|
||||||
glDisable(GL_FRAMEBUFFER_SRGB);
|
glDisable(GL_FRAMEBUFFER_SRGB);
|
||||||
|
|
|
@ -195,6 +195,7 @@ public:
|
||||||
s_rgb_used = false;
|
s_rgb_used = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void DefaultViewports();
|
||||||
/// Apply this state as the current OpenGL state
|
/// Apply this state as the current OpenGL state
|
||||||
void Apply();
|
void Apply();
|
||||||
|
|
||||||
|
@ -245,10 +246,6 @@ public:
|
||||||
dirty.stencil_state = is_dirty;
|
dirty.stencil_state = is_dirty;
|
||||||
}
|
}
|
||||||
|
|
||||||
void MarkDirtyViewportState(const bool is_dirty) {
|
|
||||||
dirty.viewport_state = is_dirty;
|
|
||||||
}
|
|
||||||
|
|
||||||
void MarkDirtyPolygonOffset(const bool is_dirty) {
|
void MarkDirtyPolygonOffset(const bool is_dirty) {
|
||||||
dirty.polygon_offset = is_dirty;
|
dirty.polygon_offset = is_dirty;
|
||||||
}
|
}
|
||||||
|
@ -260,7 +257,6 @@ public:
|
||||||
void AllDirty() {
|
void AllDirty() {
|
||||||
dirty.blend_state = true;
|
dirty.blend_state = true;
|
||||||
dirty.stencil_state = true;
|
dirty.stencil_state = true;
|
||||||
dirty.viewport_state = true;
|
|
||||||
dirty.polygon_offset = true;
|
dirty.polygon_offset = true;
|
||||||
dirty.color_mask = true;
|
dirty.color_mask = true;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue