mirror of
https://git.sr.ht/~eliasnaur/gio
synced 2026-07-05 01:15:35 +00:00
gpu,gpu/internal,internal/gl: replace BlitFramebuffer with CopyTexture
OpenGL ES 2.0 doesn't support glBlitFramebuffer, but does support glCopyTexSubImage2D. Fortunately, we don't need the extra features of glBlitFramebuffer anyway. Signed-off-by: Elias Naur <mail@eliasnaur.com>
This commit is contained in:
@@ -165,7 +165,7 @@ func (b *Backend) BeginFrame(target driver.RenderTarget, clear bool, viewport im
|
||||
return &Framebuffer{ctx: b.ctx, dev: b.dev, renderTarget: renderTarget, foreign: true}
|
||||
}
|
||||
|
||||
func (b *Backend) BlitFramebuffer(dst, src driver.Framebuffer, srect image.Rectangle, dorigin image.Point) {
|
||||
func (b *Backend) CopyTexture(dst driver.Texture, dstOrigin image.Point, src driver.Framebuffer, srcRect image.Rectangle) {
|
||||
panic("not implemented")
|
||||
}
|
||||
|
||||
|
||||
@@ -45,7 +45,7 @@ type Device interface {
|
||||
BindFragmentUniforms(buf Buffer)
|
||||
BindStorageBuffer(binding int, buf Buffer)
|
||||
|
||||
BlitFramebuffer(dst, src Framebuffer, srcRect image.Rectangle, dstOrigin image.Point)
|
||||
CopyTexture(dst Texture, dstOrigin image.Point, src Framebuffer, srcRect image.Rectangle)
|
||||
MemoryBarrier()
|
||||
DispatchCompute(x, y, z int)
|
||||
|
||||
|
||||
@@ -524,9 +524,9 @@ func (b *Backend) startBlit() C.CFTypeRef {
|
||||
return b.blitEnc
|
||||
}
|
||||
|
||||
func (b *Backend) BlitFramebuffer(dst, src driver.Framebuffer, srect image.Rectangle, dorig image.Point) {
|
||||
func (b *Backend) CopyTexture(dst driver.Texture, dorig image.Point, src driver.Framebuffer, srect image.Rectangle) {
|
||||
enc := b.startBlit()
|
||||
dstTex := dst.(*Framebuffer).texture
|
||||
dstTex := dst.(*Texture).texture
|
||||
srcTex := src.(*Framebuffer).texture
|
||||
ssz := srect.Size()
|
||||
C.blitEncCopyFromTexture(
|
||||
|
||||
@@ -1166,15 +1166,16 @@ func (b *Backend) BindIndexBuffer(buf driver.Buffer) {
|
||||
b.glstate.bindBuffer(b.funcs, gl.ELEMENT_ARRAY_BUFFER, gbuf.obj)
|
||||
}
|
||||
|
||||
func (b *Backend) BlitFramebuffer(dst, src driver.Framebuffer, srect image.Rectangle, dorig image.Point) {
|
||||
b.glstate.bindFramebuffer(b.funcs, gl.DRAW_FRAMEBUFFER, dst.(*framebuffer).obj)
|
||||
func (b *Backend) CopyTexture(dst driver.Texture, dstOrigin image.Point, src driver.Framebuffer, srcRect image.Rectangle) {
|
||||
const unit = 0
|
||||
oldTex := b.glstate.texUnits.binds[unit]
|
||||
defer func() {
|
||||
b.glstate.bindTexture(b.funcs, unit, oldTex)
|
||||
}()
|
||||
b.glstate.bindTexture(b.funcs, unit, dst.(*texture).obj)
|
||||
b.glstate.bindFramebuffer(b.funcs, gl.READ_FRAMEBUFFER, src.(*framebuffer).obj)
|
||||
drect := image.Rectangle{Min: dorig, Max: dorig.Add(srect.Size())}
|
||||
b.funcs.BlitFramebuffer(
|
||||
srect.Min.X, srect.Min.Y, srect.Max.X, srect.Max.Y,
|
||||
drect.Min.X, drect.Min.Y, drect.Max.X, drect.Max.Y,
|
||||
gl.COLOR_BUFFER_BIT,
|
||||
gl.NEAREST)
|
||||
sz := srcRect.Size()
|
||||
b.funcs.CopyTexSubImage2D(gl.TEXTURE_2D, 0, dstOrigin.X, dstOrigin.Y, srcRect.Min.X, srcRect.Min.Y, sz.X, sz.Y)
|
||||
}
|
||||
|
||||
func (f *framebuffer) ReadPixels(src image.Rectangle, pixels []byte) error {
|
||||
|
||||
Reference in New Issue
Block a user