gpu: specify target Texture Backend.NewFramebuffer

OpenGL doesn't care if the texture to a framebuffer changes, but
Direct3D does. Change Backend to better match both APIs.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
This commit is contained in:
Elias Naur
2020-02-21 15:02:54 +01:00
parent cae97a9861
commit eb7e11ee8e
3 changed files with 11 additions and 15 deletions
+4 -5
View File
@@ -193,9 +193,7 @@ func newStenciler(ctx Backend) *stenciler {
func (s *fboSet) resize(ctx Backend, sizes []image.Point) {
// Add fbos.
for i := len(s.fbos); i < len(sizes); i++ {
s.fbos = append(s.fbos, stencilFBO{
fbo: ctx.NewFramebuffer(),
})
s.fbos = append(s.fbos, stencilFBO{})
}
// Resize fbos.
for i, sz := range sizes {
@@ -206,13 +204,14 @@ func (s *fboSet) resize(ctx Backend, sizes []image.Point) {
waste := float32(sz.X*sz.Y) / float32(f.size.X*f.size.Y)
resize = resize || waste > 1.2
if resize {
if f.tex != nil {
if f.fbo != nil {
f.fbo.Release()
f.tex.Release()
}
f.size = sz
f.tex = ctx.NewTexture(TextureFormatFloat, sz.X, sz.Y, FilterNearest, FilterNearest,
BufferBindingTexture|BufferBindingFramebuffer)
f.fbo.BindTexture(f.tex)
f.fbo = ctx.NewFramebuffer(f.tex)
}
}
// Delete extra fbos.