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:
Elias Naur
2021-08-21 11:11:38 +02:00
parent 44adf01768
commit c9970cb8e3
8 changed files with 32 additions and 20 deletions
+3 -3
View File
@@ -104,9 +104,6 @@ func (f *Functions) BlendEquation(mode Enum) {
func (f *Functions) BlendFuncSeparate(srcRGB, dstRGB, srcA, dstA Enum) {
f.Ctx.Call("blendFunc", int(srcRGB), int(dstRGB), int(srcA), int(dstA))
}
func (f *Functions) BlitFramebuffer(sx0, sy0, sx1, sy1, dx0, dy0, dx1, dy1 int, mask Enum, filter Enum) {
panic("not implemented")
}
func (f *Functions) BufferData(target Enum, size int, usage Enum) {
f.Ctx.Call("bufferData", int(target), size, int(usage))
}
@@ -128,6 +125,9 @@ func (f *Functions) ClearDepthf(d float32) {
func (f *Functions) CompileShader(s Shader) {
f.Ctx.Call("compileShader", js.Value(s))
}
func (f *Functions) CopyTexSubImage2D(target Enum, level, xoffset, yoffset, x, y, width, height int) {
f.Ctx.Call("copyTexSubImage2D", int(target), level, xoffset, yoffset, x, y, width, height)
}
func (f *Functions) CreateBuffer() Buffer {
return Buffer(f.Ctx.Call("createBuffer"))
}
+10
View File
@@ -51,6 +51,7 @@ typedef struct {
void (*glClearColor)(GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha);
void (*glClearDepthf)(GLfloat d);
void (*glCompileShader)(GLuint shader);
void (*glCopyTexSubImage2D)(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height);
GLuint (*glCreateProgram)(void);
GLuint (*glCreateShader)(GLenum type);
void (*glDeleteBuffers)(GLsizei n, const GLuint *buffers);
@@ -199,6 +200,10 @@ static void glCompileShader(glFunctions *f, GLuint shader) {
f->glCompileShader(shader);
}
static void glCopyTexSubImage2D(glFunctions *f, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height) {
f->glCopyTexSubImage2D(target, level, xoffset, yoffset, x, y, width, height);
}
static GLuint glCreateProgram(glFunctions *f) {
return f->glCreateProgram();
}
@@ -606,6 +611,7 @@ func (f *Functions) load(forceES bool) error {
f.f.glClearColor = must("glClearColor")
f.f.glClearDepthf = must("glClearDepthf")
f.f.glCompileShader = must("glCompileShader")
f.f.glCopyTexSubImage2D = must("glCopyTexSubImage2D")
f.f.glCreateProgram = must("glCreateProgram")
f.f.glCreateShader = must("glCreateShader")
f.f.glDeleteBuffers = must("glDeleteBuffers")
@@ -808,6 +814,10 @@ func (f *Functions) CompileShader(s Shader) {
C.glCompileShader(&f.f, C.GLuint(s.V))
}
func (f *Functions) CopyTexSubImage2D(target Enum, level, xoffset, yoffset, x, y, width, height int) {
C.glCopyTexSubImage2D(&f.f, C.GLenum(target), C.GLint(level), C.GLint(xoffset), C.GLint(yoffset), C.GLint(x), C.GLint(y), C.GLsizei(width), C.GLsizei(height))
}
func (f *Functions) CreateBuffer() Buffer {
C.glGenBuffers(&f.f, 1, &f.uints[0])
return Buffer{uint(f.uints[0])}
+4 -3
View File
@@ -34,6 +34,7 @@ var (
_glDeleteQueries = LibGLESv2.NewProc("glDeleteQueries")
_glDeleteVertexArrays = LibGLESv2.NewProc("glDeleteVertexArrays")
_glCompileShader = LibGLESv2.NewProc("glCompileShader")
_glCopyTexSubImage2D = LibGLESv2.NewProc("glCopyTexSubImage2D")
_glGenBuffers = LibGLESv2.NewProc("glGenBuffers")
_glGenFramebuffers = LibGLESv2.NewProc("glGenFramebuffers")
_glGenVertexArrays = LibGLESv2.NewProc("glGenVertexArrays")
@@ -158,9 +159,6 @@ func (c *Functions) BlendEquation(mode Enum) {
func (c *Functions) BlendFuncSeparate(srcRGB, dstRGB, srcA, dstA Enum) {
syscall.Syscall6(_glBlendFuncSeparate.Addr(), 4, uintptr(srcRGB), uintptr(dstRGB), uintptr(srcA), uintptr(dstA), 0, 0)
}
func (f *Functions) BlitFramebuffer(sx0, sy0, sx1, sy1, dx0, dy0, dx1, dy1 int, mask Enum, filter Enum) {
panic("not implemented")
}
func (c *Functions) BufferData(target Enum, size int, usage Enum) {
syscall.Syscall6(_glBufferData.Addr(), 4, uintptr(target), uintptr(size), 0, uintptr(usage), 0, 0)
}
@@ -187,6 +185,9 @@ func (c *Functions) ClearDepthf(d float32) {
func (c *Functions) CompileShader(s Shader) {
syscall.Syscall(_glCompileShader.Addr(), 1, uintptr(s.V), 0, 0)
}
func (f *Functions) CopyTexSubImage2D(target Enum, level, xoffset, yoffset, x, y, width, height int) {
syscall.Syscall9(_glCopyTexSubImage2D.Addr(), 8, uintptr(target), uintptr(level), uintptr(xoffset), uintptr(yoffset), uintptr(x), uintptr(y), uintptr(width), uintptr(height), 0)
}
func (c *Functions) CreateBuffer() Buffer {
var buf uintptr
syscall.Syscall(_glGenBuffers.Addr(), 2, 1, uintptr(unsafe.Pointer(&buf)), 0)