gpu,gpu/backend: don't assume constant output framebuffer

Return the output framebuffer from BeginFrame, to make it clear that
it may change between frames. Delete CurrentFramebuffer which is no
longer needed.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
This commit is contained in:
Elias Naur
2021-03-02 20:43:59 +01:00
parent 3d3ff575e3
commit 25a19481e3
5 changed files with 17 additions and 21 deletions
+4 -3
View File
@@ -167,9 +167,10 @@ func NewBackend(ctx Context) (*Backend, error) {
return b, nil
}
func (b *Backend) BeginFrame() {
func (b *Backend) BeginFrame() backend.Framebuffer {
// Assume GL state is reset between frames.
b.state = glstate{}
return b.currentFramebuffer()
}
func (b *Backend) EndFrame() {
@@ -228,7 +229,7 @@ func (b *Backend) NewFramebuffer(tex backend.Texture, depthBits int) (backend.Fr
return fbo, nil
}
func (b *Backend) CurrentFramebuffer() backend.Framebuffer {
func (b *Backend) currentFramebuffer() backend.Framebuffer {
fboID := glimpl.Framebuffer(b.funcs.GetBinding(glimpl.FRAMEBUFFER_BINDING))
return &gpuFramebuffer{backend: b, obj: fboID, foreign: true}
}
@@ -802,7 +803,7 @@ func (f *gpuFramebuffer) Invalidate() {
func (f *gpuFramebuffer) Release() {
if f.foreign {
panic("cannot release framebuffer created by CurrentFramebuffer")
panic("framebuffer not created by NewBuffer")
}
f.backend.funcs.DeleteFramebuffer(f.obj)
if f.hasDepth {