gl_state: Remove framebuffer sRGB tracking

master
ReinUsesLisp 2019-12-26 01:01:41 +07:00
parent d5ab0358b6
commit 04d1134191
6 changed files with 25 additions and 21 deletions

@ -332,7 +332,6 @@ void RasterizerOpenGL::ConfigureFramebuffers() {
View depth_surface = texture_cache.GetDepthBufferSurface(true); View depth_surface = texture_cache.GetDepthBufferSurface(true);
const auto& regs = gpu.regs; const auto& regs = gpu.regs;
state.framebuffer_srgb.enabled = regs.framebuffer_srgb != 0;
UNIMPLEMENTED_IF(regs.rt_separate_frag_data == 0); UNIMPLEMENTED_IF(regs.rt_separate_frag_data == 0);
// Bind the framebuffer surfaces // Bind the framebuffer surfaces
@ -455,6 +454,9 @@ void RasterizerOpenGL::Clear() {
} }
} }
// TODO: Signal state tracker about these changes
SyncFramebufferSRGB();
if (!use_color && !use_depth && !use_stencil) { if (!use_color && !use_depth && !use_stencil) {
// No color surface nor depth/stencil surface are enabled // No color surface nor depth/stencil surface are enabled
return; return;
@ -511,6 +513,7 @@ void RasterizerOpenGL::Draw(bool is_indexed, bool is_instanced) {
SyncPointState(); SyncPointState();
SyncPolygonOffset(); SyncPolygonOffset();
SyncAlphaTest(); SyncAlphaTest();
SyncFramebufferSRGB();
buffer_cache.Acquire(); buffer_cache.Acquire();
@ -1198,4 +1201,9 @@ void RasterizerOpenGL::SyncAlphaTest() {
} }
} }
void RasterizerOpenGL::SyncFramebufferSRGB() {
const auto& regs = system.GPU().Maxwell3D().regs;
oglEnable(GL_FRAMEBUFFER_SRGB, regs.framebuffer_srgb);
}
} // namespace OpenGL } // namespace OpenGL

@ -187,6 +187,9 @@ private:
/// Syncs the alpha test state to match the guest state /// Syncs the alpha test state to match the guest state
void SyncAlphaTest(); void SyncAlphaTest();
/// Syncs the framebuffer sRGB state to match the guest state
void SyncFramebufferSRGB();
/// Check for extension that are not strictly required but are needed for correct emulation /// Check for extension that are not strictly required but are needed for correct emulation
void CheckExtensions(); void CheckExtensions();

@ -131,17 +131,6 @@ void OpenGLState::ApplyMultisample() {
multisample_control.alpha_to_one); multisample_control.alpha_to_one);
} }
void OpenGLState::ApplySRgb() {
if (cur_state.framebuffer_srgb.enabled == framebuffer_srgb.enabled)
return;
cur_state.framebuffer_srgb.enabled = framebuffer_srgb.enabled;
if (framebuffer_srgb.enabled) {
glEnable(GL_FRAMEBUFFER_SRGB);
} else {
glDisable(GL_FRAMEBUFFER_SRGB);
}
}
void OpenGLState::ApplyRasterizerDiscard() { void OpenGLState::ApplyRasterizerDiscard() {
Enable(GL_RASTERIZER_DISCARD, cur_state.rasterizer_discard, rasterizer_discard); Enable(GL_RASTERIZER_DISCARD, cur_state.rasterizer_discard, rasterizer_discard);
} }
@ -341,7 +330,6 @@ void OpenGLState::Apply() {
ApplyColorMask(); ApplyColorMask();
ApplyViewport(); ApplyViewport();
ApplyStencilTest(); ApplyStencilTest();
ApplySRgb();
ApplyBlending(); ApplyBlending();
ApplyTextures(); ApplyTextures();
ApplySamplers(); ApplySamplers();

@ -13,10 +13,6 @@ namespace OpenGL {
class OpenGLState { class OpenGLState {
public: public:
struct {
bool enabled = false; // GL_FRAMEBUFFER_SRGB
} framebuffer_srgb;
struct { struct {
bool alpha_to_coverage = false; // GL_ALPHA_TO_COVERAGE bool alpha_to_coverage = false; // GL_ALPHA_TO_COVERAGE
bool alpha_to_one = false; // GL_ALPHA_TO_ONE bool alpha_to_one = false; // GL_ALPHA_TO_ONE
@ -121,7 +117,6 @@ public:
void ApplyClipDistances(); void ApplyClipDistances();
void ApplyFragmentColorClamp(); void ApplyFragmentColorClamp();
void ApplyMultisample(); void ApplyMultisample();
void ApplySRgb();
void ApplyRasterizerDiscard(); void ApplyRasterizerDiscard();
void ApplyColorMask(); void ApplyColorMask();
void ApplyStencilTest(); void ApplyStencilTest();

@ -528,9 +528,15 @@ void TextureCacheOpenGL::ImageBlit(View& src_view, View& dst_view,
OpenGLState state; OpenGLState state;
state.draw.read_framebuffer = src_framebuffer.handle; state.draw.read_framebuffer = src_framebuffer.handle;
state.draw.draw_framebuffer = dst_framebuffer.handle; state.draw.draw_framebuffer = dst_framebuffer.handle;
state.framebuffer_srgb.enabled = dst_params.srgb_conversion;
state.Apply(); state.Apply();
// TODO: Signal state tracker about these changes
if (dst_params.srgb_conversion) {
glEnable(GL_FRAMEBUFFER_SRGB);
} else {
glDisable(GL_FRAMEBUFFER_SRGB);
}
u32 buffers{}; u32 buffers{};
UNIMPLEMENTED_IF(src_params.target == SurfaceTarget::Texture3D); UNIMPLEMENTED_IF(src_params.target == SurfaceTarget::Texture3D);

@ -555,11 +555,15 @@ void RendererOpenGL::DrawScreenTriangles(const ScreenInfo& screen_info, float x,
}; };
state.textures[0] = screen_info.display_texture; state.textures[0] = screen_info.display_texture;
state.framebuffer_srgb.enabled = screen_info.display_srgb;
state.Apply(); state.Apply();
// TODO: Signal state tracker about these changes // TODO: Signal state tracker about these changes
glEnable(GL_CULL_FACE); glEnable(GL_CULL_FACE);
if (screen_info.display_srgb) {
glEnable(GL_FRAMEBUFFER_SRGB);
} else {
glDisable(GL_FRAMEBUFFER_SRGB);
}
glDisable(GL_COLOR_LOGIC_OP); glDisable(GL_COLOR_LOGIC_OP);
glDisable(GL_ALPHA_TEST); glDisable(GL_ALPHA_TEST);
glDisable(GL_DEPTH_TEST); glDisable(GL_DEPTH_TEST);
@ -577,8 +581,8 @@ void RendererOpenGL::DrawScreenTriangles(const ScreenInfo& screen_info, float x,
glNamedBufferSubData(vertex_buffer.handle, 0, sizeof(vertices), std::data(vertices)); glNamedBufferSubData(vertex_buffer.handle, 0, sizeof(vertices), std::data(vertices));
glDrawArrays(GL_TRIANGLE_STRIP, 0, 4); glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
// Restore default state // Restore default state
state.framebuffer_srgb.enabled = false;
state.textures[0] = 0; state.textures[0] = 0;
state.Apply(); state.Apply();
} }