gl_state_tracker: Implement dirty flags for sRGB

master
ReinUsesLisp 2019-12-30 00:53:53 +07:00
parent d8f5c45051
commit 13afd0e5b0
5 changed files with 21 additions and 2 deletions

@ -1301,8 +1301,14 @@ void RasterizerOpenGL::SyncAlphaTest() {
}
void RasterizerOpenGL::SyncFramebufferSRGB() {
const auto& regs = system.GPU().Maxwell3D().regs;
oglEnable(GL_FRAMEBUFFER_SRGB, regs.framebuffer_srgb);
auto& gpu = system.GPU().Maxwell3D();
auto& flags = gpu.dirty.flags;
if (!flags[Dirty::FramebufferSRGB]) {
return;
}
flags[Dirty::FramebufferSRGB] = false;
oglEnable(GL_FRAMEBUFFER_SRGB, gpu.regs.framebuffer_srgb);
}
} // namespace OpenGL

@ -193,6 +193,10 @@ void SetupDirtyRasterizeEnable(Tables& tables) {
tables[0][OFF(rasterize_enable)] = RasterizeEnable;
}
void SetupDirtyFramebufferSRGB(Tables& tables) {
tables[0][OFF(framebuffer_srgb)] = FramebufferSRGB;
}
void SetupDirtyMisc(Tables& tables) {
auto& table = tables[0];
@ -226,6 +230,7 @@ void StateTracker::Initialize() {
SetupDirtyPolygonOffset(tables);
SetupDirtyMultisampleControl(tables);
SetupDirtyRasterizeEnable(tables);
SetupDirtyFramebufferSRGB(tables);
SetupDirtyMisc(tables);
auto& store = dirty.on_write_stores;

@ -67,6 +67,7 @@ enum : u8 {
PolygonOffset,
MultisampleControl,
RasterizeEnable,
FramebufferSRGB,
Last
};
@ -153,6 +154,11 @@ public:
flags[OpenGL::Dirty::RasterizeEnable] = true;
}
void NotifyFramebufferSRGB() {
auto& flags = system.GPU().Maxwell3D().dirty.flags;
flags[OpenGL::Dirty::FramebufferSRGB] = true;
}
private:
Core::System& system;
};

@ -523,6 +523,7 @@ void TextureCacheOpenGL::ImageBlit(View& src_view, View& dst_view,
state_tracker.NotifyBlend0();
state_tracker.NotifyFramebuffer();
state_tracker.NotifyRasterizeEnable();
state_tracker.NotifyFramebufferSRGB();
if (dst_params.srgb_conversion) {
glEnable(GL_FRAMEBUFFER_SRGB);

@ -588,6 +588,7 @@ void RendererOpenGL::DrawScreen(const Layout::FramebufferLayout& layout) {
state_tracker.NotifyStencilTest();
state_tracker.NotifyPolygonOffset();
state_tracker.NotifyRasterizeEnable();
state_tracker.NotifyFramebufferSRGB();
program_manager.UseVertexShader(vertex_program.handle);
program_manager.UseGeometryShader(0);