gpu: add binding flags to Backend.NewTexture

Direct3D needs to know the texture bind usage up front, in particular
whether the texture is going to be used as a render target.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
This commit is contained in:
Elias Naur
2020-02-20 23:21:06 +01:00
parent 411f566e3f
commit cae97a9861
4 changed files with 7 additions and 4 deletions
+3 -1
View File
@@ -18,7 +18,7 @@ type Backend interface {
// IsContinuousTime reports whether all timer measurements // IsContinuousTime reports whether all timer measurements
// are valid at the point of call. // are valid at the point of call.
IsTimeContinuous() bool IsTimeContinuous() bool
NewTexture(format TextureFormat, width, height int, minFilter, magFilter TextureFilter) Texture NewTexture(format TextureFormat, width, height int, minFilter, magFilter TextureFilter, bindings BufferBinding) Texture
DefaultFramebuffer() Framebuffer DefaultFramebuffer() Framebuffer
NewFramebuffer() Framebuffer NewFramebuffer() Framebuffer
NewImmutableBuffer(typ BufferBinding, data []byte) Buffer NewImmutableBuffer(typ BufferBinding, data []byte) Buffer
@@ -162,6 +162,8 @@ const (
BufferBindingIndices BufferBinding = 1 << iota BufferBindingIndices BufferBinding = 1 << iota
BufferBindingVertices BufferBindingVertices
BufferBindingUniforms BufferBindingUniforms
BufferBindingTexture
BufferBindingFramebuffer
) )
const ( const (
+1 -1
View File
@@ -171,7 +171,7 @@ func (b *Backend) DefaultFramebuffer() gpu.Framebuffer {
return b.defFBO return b.defFBO
} }
func (b *Backend) NewTexture(format gpu.TextureFormat, width, height int, minFilter, magFilter gpu.TextureFilter) gpu.Texture { func (b *Backend) NewTexture(format gpu.TextureFormat, width, height int, minFilter, magFilter gpu.TextureFilter, binding gpu.BufferBinding) gpu.Texture {
tex := &gpuTexture{backend: b, obj: b.funcs.CreateTexture()} tex := &gpuTexture{backend: b, obj: b.funcs.CreateTexture()}
switch format { switch format {
case gpu.TextureFormatFloat: case gpu.TextureFormatFloat:
+1 -1
View File
@@ -378,7 +378,7 @@ func (r *renderer) texHandle(t *texture) Texture {
if t.tex != nil { if t.tex != nil {
return t.tex return t.tex
} }
t.tex = r.ctx.NewTexture(TextureFormatSRGB, t.src.Bounds().Dx(), t.src.Bounds().Dy(), FilterLinear, FilterLinear) t.tex = r.ctx.NewTexture(TextureFormatSRGB, t.src.Bounds().Dx(), t.src.Bounds().Dy(), FilterLinear, FilterLinear, BufferBindingTexture)
t.tex.Upload(t.src) t.tex.Upload(t.src)
return t.tex return t.tex
} }
+2 -1
View File
@@ -210,7 +210,8 @@ func (s *fboSet) resize(ctx Backend, sizes []image.Point) {
f.tex.Release() f.tex.Release()
} }
f.size = sz f.size = sz
f.tex = ctx.NewTexture(TextureFormatFloat, sz.X, sz.Y, FilterNearest, FilterNearest) f.tex = ctx.NewTexture(TextureFormatFloat, sz.X, sz.Y, FilterNearest, FilterNearest,
BufferBindingTexture|BufferBindingFramebuffer)
f.fbo.BindTexture(f.tex) f.fbo.BindTexture(f.tex)
} }
} }