mirror of
https://git.sr.ht/~eliasnaur/gio
synced 2026-07-06 18:05:35 +00:00
gpu: drop Framebuffer.IsComplete in favour of an error from NewFramebuffer
Signed-off-by: Elias Naur <mail@eliasnaur.com>
This commit is contained in:
+1
-2
@@ -20,7 +20,7 @@ type Backend interface {
|
|||||||
IsTimeContinuous() bool
|
IsTimeContinuous() bool
|
||||||
NewTexture(format TextureFormat, width, height int, minFilter, magFilter TextureFilter, bindings BufferBinding) Texture
|
NewTexture(format TextureFormat, width, height int, minFilter, magFilter TextureFilter, bindings BufferBinding) Texture
|
||||||
DefaultFramebuffer() Framebuffer
|
DefaultFramebuffer() Framebuffer
|
||||||
NewFramebuffer(tex Texture) Framebuffer
|
NewFramebuffer(tex Texture) (Framebuffer, error)
|
||||||
NewImmutableBuffer(typ BufferBinding, data []byte) Buffer
|
NewImmutableBuffer(typ BufferBinding, data []byte) Buffer
|
||||||
NewBuffer(typ BufferBinding, size int) Buffer
|
NewBuffer(typ BufferBinding, size int) Buffer
|
||||||
NewProgram(vertexShader, fragmentShader ShaderSources) (Program, error)
|
NewProgram(vertexShader, fragmentShader ShaderSources) (Program, error)
|
||||||
@@ -127,7 +127,6 @@ type Framebuffer interface {
|
|||||||
Bind()
|
Bind()
|
||||||
Invalidate()
|
Invalidate()
|
||||||
Release()
|
Release()
|
||||||
IsComplete() error
|
|
||||||
}
|
}
|
||||||
|
|
||||||
type Timer interface {
|
type Timer interface {
|
||||||
|
|||||||
+7
-10
@@ -139,7 +139,7 @@ func NewBackend(f Functions) (*Backend, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (b *Backend) BeginFrame() {
|
func (b *Backend) BeginFrame() {
|
||||||
// Assume GL state is reset.
|
// Assume GL state is reset between frames.
|
||||||
b.state = glstate{}
|
b.state = glstate{}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -162,13 +162,17 @@ func (b *Backend) IsTimeContinuous() bool {
|
|||||||
return b.funcs.GetInteger(GPU_DISJOINT_EXT) == FALSE
|
return b.funcs.GetInteger(GPU_DISJOINT_EXT) == FALSE
|
||||||
}
|
}
|
||||||
|
|
||||||
func (b *Backend) NewFramebuffer(tex gpu.Texture) gpu.Framebuffer {
|
func (b *Backend) NewFramebuffer(tex gpu.Texture) (gpu.Framebuffer, error) {
|
||||||
gltex := tex.(*gpuTexture)
|
gltex := tex.(*gpuTexture)
|
||||||
fb := b.funcs.CreateFramebuffer()
|
fb := b.funcs.CreateFramebuffer()
|
||||||
fbo := &gpuFramebuffer{funcs: b.funcs, obj: fb}
|
fbo := &gpuFramebuffer{funcs: b.funcs, obj: fb}
|
||||||
fbo.Bind()
|
fbo.Bind()
|
||||||
b.funcs.FramebufferTexture2D(FRAMEBUFFER, COLOR_ATTACHMENT0, TEXTURE_2D, gltex.obj, 0)
|
b.funcs.FramebufferTexture2D(FRAMEBUFFER, COLOR_ATTACHMENT0, TEXTURE_2D, gltex.obj, 0)
|
||||||
return fbo
|
if st := b.funcs.CheckFramebufferStatus(FRAMEBUFFER); st != FRAMEBUFFER_COMPLETE {
|
||||||
|
fbo.Release()
|
||||||
|
return nil, fmt.Errorf("incomplete framebuffer, status = 0x%x, err = %d", st, b.funcs.GetError())
|
||||||
|
}
|
||||||
|
return fbo, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (b *Backend) DefaultFramebuffer() gpu.Framebuffer {
|
func (b *Backend) DefaultFramebuffer() gpu.Framebuffer {
|
||||||
@@ -536,13 +540,6 @@ func (b *gpuBuffer) BindIndex() {
|
|||||||
b.backend.funcs.BindBuffer(ELEMENT_ARRAY_BUFFER, b.obj)
|
b.backend.funcs.BindBuffer(ELEMENT_ARRAY_BUFFER, b.obj)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (f *gpuFramebuffer) IsComplete() error {
|
|
||||||
if st := f.funcs.CheckFramebufferStatus(FRAMEBUFFER); st != FRAMEBUFFER_COMPLETE {
|
|
||||||
return fmt.Errorf("incomplete framebuffer, status = 0x%x, err = %d", st, f.funcs.GetError())
|
|
||||||
}
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func (f *gpuFramebuffer) Bind() {
|
func (f *gpuFramebuffer) Bind() {
|
||||||
f.funcs.BindFramebuffer(FRAMEBUFFER, f.obj)
|
f.funcs.BindFramebuffer(FRAMEBUFFER, f.obj)
|
||||||
}
|
}
|
||||||
|
|||||||
+2
-9
@@ -489,7 +489,7 @@ func (r *renderer) stencilClips(pathCache *opCache, ops []*pathOp) {
|
|||||||
if fbo != p.place.Idx {
|
if fbo != p.place.Idx {
|
||||||
fbo = p.place.Idx
|
fbo = p.place.Idx
|
||||||
f := r.pather.stenciler.cover(fbo)
|
f := r.pather.stenciler.cover(fbo)
|
||||||
bindFramebuffer(f.fbo)
|
f.fbo.Bind()
|
||||||
r.ctx.Clear(BufferAttachmentColor)
|
r.ctx.Clear(BufferAttachmentColor)
|
||||||
}
|
}
|
||||||
data, _ := pathCache.get(p.pathKey)
|
data, _ := pathCache.get(p.pathKey)
|
||||||
@@ -513,7 +513,7 @@ func (r *renderer) intersect(ops []imageOp) {
|
|||||||
if fbo != img.place.Idx {
|
if fbo != img.place.Idx {
|
||||||
fbo = img.place.Idx
|
fbo = img.place.Idx
|
||||||
f := r.pather.stenciler.intersections.fbos[fbo]
|
f := r.pather.stenciler.intersections.fbos[fbo]
|
||||||
bindFramebuffer(f.fbo)
|
f.fbo.Bind()
|
||||||
r.ctx.Clear(BufferAttachmentColor)
|
r.ctx.Clear(BufferAttachmentColor)
|
||||||
}
|
}
|
||||||
r.ctx.Viewport(img.place.Pos.X, img.place.Pos.Y, img.clip.Dx(), img.clip.Dy())
|
r.ctx.Viewport(img.place.Pos.X, img.place.Pos.Y, img.clip.Dx(), img.clip.Dy())
|
||||||
@@ -990,13 +990,6 @@ func clipSpaceTransform(r image.Rectangle, viewport image.Point) (f32.Point, f32
|
|||||||
return scale, offset
|
return scale, offset
|
||||||
}
|
}
|
||||||
|
|
||||||
func bindFramebuffer(fbo Framebuffer) {
|
|
||||||
fbo.Bind()
|
|
||||||
if err := fbo.IsComplete(); err != nil {
|
|
||||||
panic(fmt.Errorf("AA FBO not complete: %v", err))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Fill in maximal Y coordinates of the NW and NE corners.
|
// Fill in maximal Y coordinates of the NW and NE corners.
|
||||||
func fillMaxY(verts []byte) {
|
func fillMaxY(verts []byte) {
|
||||||
contour := 0
|
contour := 0
|
||||||
|
|||||||
+5
-1
@@ -211,7 +211,11 @@ func (s *fboSet) resize(ctx Backend, sizes []image.Point) {
|
|||||||
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)
|
BufferBindingTexture|BufferBindingFramebuffer)
|
||||||
f.fbo = ctx.NewFramebuffer(f.tex)
|
fbo, err := ctx.NewFramebuffer(f.tex)
|
||||||
|
if err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
f.fbo = fbo
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Delete extra fbos.
|
// Delete extra fbos.
|
||||||
|
|||||||
Reference in New Issue
Block a user