mirror of
https://git.suyu.dev/suyu/suyu.git
synced 2024-11-15 22:54:00 +00:00
GL_State: Feedback and fixes
This commit is contained in:
parent
5ad889f6fd
commit
4be61013a1
4 changed files with 27 additions and 14 deletions
|
@ -1129,24 +1129,30 @@ public:
|
||||||
union {
|
union {
|
||||||
struct {
|
struct {
|
||||||
bool null_dirty;
|
bool null_dirty;
|
||||||
|
|
||||||
// Vertex Attributes
|
// Vertex Attributes
|
||||||
bool vertex_attrib_format;
|
bool vertex_attrib_format;
|
||||||
|
|
||||||
// Vertex Arrays
|
// Vertex Arrays
|
||||||
std::array<bool, 32> vertex_array;
|
std::array<bool, 32> vertex_array;
|
||||||
|
|
||||||
bool vertex_array_buffers;
|
bool vertex_array_buffers;
|
||||||
|
|
||||||
// Vertex Instances
|
// Vertex Instances
|
||||||
std::array<bool, 32> vertex_instance;
|
std::array<bool, 32> vertex_instance;
|
||||||
|
|
||||||
bool vertex_instances;
|
bool vertex_instances;
|
||||||
|
|
||||||
// Render Targets
|
// Render Targets
|
||||||
std::array<bool, 8> render_target;
|
std::array<bool, 8> render_target;
|
||||||
bool depth_buffer;
|
bool depth_buffer;
|
||||||
|
|
||||||
bool render_settings;
|
bool render_settings;
|
||||||
|
|
||||||
// Shaders
|
// Shaders
|
||||||
bool shaders;
|
bool shaders;
|
||||||
// State
|
|
||||||
|
// Rasterizer State
|
||||||
bool viewport;
|
bool viewport;
|
||||||
bool clip_coefficient;
|
bool clip_coefficient;
|
||||||
bool cull_mode;
|
bool cull_mode;
|
||||||
|
|
|
@ -1059,7 +1059,7 @@ void RasterizerOpenGL::SyncStencilTestState() {
|
||||||
state.stencil.back.action_depth_fail = GL_KEEP;
|
state.stencil.back.action_depth_fail = GL_KEEP;
|
||||||
state.stencil.back.action_depth_pass = GL_KEEP;
|
state.stencil.back.action_depth_pass = GL_KEEP;
|
||||||
}
|
}
|
||||||
state.MarkDirtyStencilState(true);
|
state.MarkDirtyStencilState();
|
||||||
maxwell3d.dirty.stencil_test = false;
|
maxwell3d.dirty.stencil_test = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1081,7 +1081,7 @@ void RasterizerOpenGL::SyncColorMask() {
|
||||||
dest.alpha_enabled = (source.A == 0) ? GL_FALSE : GL_TRUE;
|
dest.alpha_enabled = (source.A == 0) ? GL_FALSE : GL_TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
state.MarkDirtyColorMask(true);
|
state.MarkDirtyColorMask();
|
||||||
maxwell3d.dirty.color_mask = false;
|
maxwell3d.dirty.color_mask = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1125,7 +1125,7 @@ void RasterizerOpenGL::SyncBlendState() {
|
||||||
state.blend[i].enabled = false;
|
state.blend[i].enabled = false;
|
||||||
}
|
}
|
||||||
maxwell3d.dirty.blend_state = false;
|
maxwell3d.dirty.blend_state = false;
|
||||||
state.MarkDirtyBlendState(true);
|
state.MarkDirtyBlendState();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1143,7 +1143,7 @@ void RasterizerOpenGL::SyncBlendState() {
|
||||||
blend.dst_a_func = MaxwellToGL::BlendFunc(src.factor_dest_a);
|
blend.dst_a_func = MaxwellToGL::BlendFunc(src.factor_dest_a);
|
||||||
}
|
}
|
||||||
|
|
||||||
state.MarkDirtyBlendState(true);
|
state.MarkDirtyBlendState();
|
||||||
maxwell3d.dirty.blend_state = false;
|
maxwell3d.dirty.blend_state = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1209,7 +1209,7 @@ void RasterizerOpenGL::SyncPolygonOffset() {
|
||||||
state.polygon_offset.factor = regs.polygon_offset_factor;
|
state.polygon_offset.factor = regs.polygon_offset_factor;
|
||||||
state.polygon_offset.clamp = regs.polygon_offset_clamp;
|
state.polygon_offset.clamp = regs.polygon_offset_clamp;
|
||||||
|
|
||||||
state.MarkDirtyPolygonOffset(true);
|
state.MarkDirtyPolygonOffset();
|
||||||
maxwell3d.dirty.polygon_offset = false;
|
maxwell3d.dirty.polygon_offset = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -238,20 +238,20 @@ public:
|
||||||
/// Viewport does not affects glClearBuffer so emulate viewport using scissor test
|
/// Viewport does not affects glClearBuffer so emulate viewport using scissor test
|
||||||
void EmulateViewportWithScissor();
|
void EmulateViewportWithScissor();
|
||||||
|
|
||||||
void MarkDirtyBlendState(const bool is_dirty) {
|
void MarkDirtyBlendState() {
|
||||||
dirty.blend_state = is_dirty;
|
dirty.blend_state = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void MarkDirtyStencilState(const bool is_dirty) {
|
void MarkDirtyStencilState() {
|
||||||
dirty.stencil_state = is_dirty;
|
dirty.stencil_state = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void MarkDirtyPolygonOffset(const bool is_dirty) {
|
void MarkDirtyPolygonOffset() {
|
||||||
dirty.polygon_offset = is_dirty;
|
dirty.polygon_offset = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void MarkDirtyColorMask(const bool is_dirty) {
|
void MarkDirtyColorMask() {
|
||||||
dirty.color_mask = is_dirty;
|
dirty.color_mask = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void AllDirty() {
|
void AllDirty() {
|
||||||
|
|
|
@ -108,6 +108,7 @@ void RendererOpenGL::SwapBuffers(
|
||||||
|
|
||||||
// Maintain the rasterizer's state as a priority
|
// Maintain the rasterizer's state as a priority
|
||||||
OpenGLState prev_state = OpenGLState::GetCurState();
|
OpenGLState prev_state = OpenGLState::GetCurState();
|
||||||
|
state.AllDirty();
|
||||||
state.Apply();
|
state.Apply();
|
||||||
|
|
||||||
if (framebuffer) {
|
if (framebuffer) {
|
||||||
|
@ -140,6 +141,7 @@ void RendererOpenGL::SwapBuffers(
|
||||||
system.GetPerfStats().BeginSystemFrame();
|
system.GetPerfStats().BeginSystemFrame();
|
||||||
|
|
||||||
// Restore the rasterizer state
|
// Restore the rasterizer state
|
||||||
|
prev_state.AllDirty();
|
||||||
prev_state.Apply();
|
prev_state.Apply();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -206,6 +208,7 @@ void RendererOpenGL::InitOpenGLObjects() {
|
||||||
// Link shaders and get variable locations
|
// Link shaders and get variable locations
|
||||||
shader.CreateFromSource(vertex_shader, nullptr, fragment_shader);
|
shader.CreateFromSource(vertex_shader, nullptr, fragment_shader);
|
||||||
state.draw.shader_program = shader.handle;
|
state.draw.shader_program = shader.handle;
|
||||||
|
state.AllDirty();
|
||||||
state.Apply();
|
state.Apply();
|
||||||
uniform_modelview_matrix = glGetUniformLocation(shader.handle, "modelview_matrix");
|
uniform_modelview_matrix = glGetUniformLocation(shader.handle, "modelview_matrix");
|
||||||
uniform_color_texture = glGetUniformLocation(shader.handle, "color_texture");
|
uniform_color_texture = glGetUniformLocation(shader.handle, "color_texture");
|
||||||
|
@ -338,12 +341,14 @@ void RendererOpenGL::DrawScreenTriangles(const ScreenInfo& screen_info, float x,
|
||||||
// Workaround brigthness problems in SMO by enabling sRGB in the final output
|
// Workaround brigthness problems in SMO by enabling sRGB in the final output
|
||||||
// if it has been used in the frame. Needed because of this bug in QT: QTBUG-50987
|
// if it has been used in the frame. Needed because of this bug in QT: QTBUG-50987
|
||||||
state.framebuffer_srgb.enabled = OpenGLState::GetsRGBUsed();
|
state.framebuffer_srgb.enabled = OpenGLState::GetsRGBUsed();
|
||||||
|
state.AllDirty();
|
||||||
state.Apply();
|
state.Apply();
|
||||||
glNamedBufferSubData(vertex_buffer.handle, 0, sizeof(vertices), vertices.data());
|
glNamedBufferSubData(vertex_buffer.handle, 0, sizeof(vertices), vertices.data());
|
||||||
glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
|
glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
|
||||||
// Restore default state
|
// Restore default state
|
||||||
state.framebuffer_srgb.enabled = false;
|
state.framebuffer_srgb.enabled = false;
|
||||||
state.texture_units[0].texture = 0;
|
state.texture_units[0].texture = 0;
|
||||||
|
state.AllDirty();
|
||||||
state.Apply();
|
state.Apply();
|
||||||
// Clear sRGB state for the next frame
|
// Clear sRGB state for the next frame
|
||||||
OpenGLState::ClearsRGBUsed();
|
OpenGLState::ClearsRGBUsed();
|
||||||
|
@ -388,6 +393,7 @@ void RendererOpenGL::CaptureScreenshot() {
|
||||||
GLuint old_read_fb = state.draw.read_framebuffer;
|
GLuint old_read_fb = state.draw.read_framebuffer;
|
||||||
GLuint old_draw_fb = state.draw.draw_framebuffer;
|
GLuint old_draw_fb = state.draw.draw_framebuffer;
|
||||||
state.draw.read_framebuffer = state.draw.draw_framebuffer = screenshot_framebuffer.handle;
|
state.draw.read_framebuffer = state.draw.draw_framebuffer = screenshot_framebuffer.handle;
|
||||||
|
state.AllDirty();
|
||||||
state.Apply();
|
state.Apply();
|
||||||
|
|
||||||
Layout::FramebufferLayout layout{renderer_settings.screenshot_framebuffer_layout};
|
Layout::FramebufferLayout layout{renderer_settings.screenshot_framebuffer_layout};
|
||||||
|
@ -407,6 +413,7 @@ void RendererOpenGL::CaptureScreenshot() {
|
||||||
screenshot_framebuffer.Release();
|
screenshot_framebuffer.Release();
|
||||||
state.draw.read_framebuffer = old_read_fb;
|
state.draw.read_framebuffer = old_read_fb;
|
||||||
state.draw.draw_framebuffer = old_draw_fb;
|
state.draw.draw_framebuffer = old_draw_fb;
|
||||||
|
state.AllDirty();
|
||||||
state.Apply();
|
state.Apply();
|
||||||
glDeleteRenderbuffers(1, &renderbuffer);
|
glDeleteRenderbuffers(1, &renderbuffer);
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue