gpu/internal/opengl: [OpenGL] respect render target when emulating sRGB

Before this change, the sRGB emulation target would always be the
current framebuffer. Now it's the render target passed to BeginFrame.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
This commit is contained in:
Elias Naur
2021-10-05 08:22:52 +02:00
parent bfd1e76b78
commit 3abc891680
+3 -1
View File
@@ -35,6 +35,7 @@ type Backend struct {
srgbaTriple textureTriple srgbaTriple textureTriple
storage [storageBindings]*buffer storage [storageBindings]*buffer
outputFBO gl.Framebuffer
sRGBFBO *SRGBFBO sRGBFBO *SRGBFBO
// vertArray is bound during a frame. We don't need it, but // vertArray is bound during a frame. We don't need it, but
@@ -234,6 +235,7 @@ func (b *Backend) BeginFrame(target driver.RenderTarget, clear bool, viewport im
panic(fmt.Errorf("opengl: invalid render target type: %T", target)) panic(fmt.Errorf("opengl: invalid render target type: %T", target))
} }
} }
b.outputFBO = renderFBO
b.glstate.bindFramebuffer(b.funcs, gl.FRAMEBUFFER, renderFBO) b.glstate.bindFramebuffer(b.funcs, gl.FRAMEBUFFER, renderFBO)
if b.gles { if b.gles {
// If the output framebuffer is not in the sRGB colorspace already, emulate it. // If the output framebuffer is not in the sRGB colorspace already, emulate it.
@@ -275,7 +277,7 @@ func (b *Backend) BeginFrame(target driver.RenderTarget, clear bool, viewport im
func (b *Backend) EndFrame() { func (b *Backend) EndFrame() {
if b.sRGBFBO != nil { if b.sRGBFBO != nil {
b.glstate.bindFramebuffer(b.funcs, gl.FRAMEBUFFER, b.savedState.drawFBO) b.glstate.bindFramebuffer(b.funcs, gl.FRAMEBUFFER, b.outputFBO)
if b.clear { if b.clear {
b.SetBlend(false) b.SetBlend(false)
} else { } else {