mirror of
https://git.sr.ht/~eliasnaur/gio
synced 2026-07-06 01:45:36 +00:00
internal/gl: implement glGetProgramBinary
Useful for debugging shader compiler issues, such as those that may cause https://github.com/linebender/piet-gpu/issues/83 Signed-off-by: Elias Naur <mail@eliasnaur.com>
This commit is contained in:
@@ -51,6 +51,7 @@ const (
|
|||||||
NUM_EXTENSIONS = 0x821D
|
NUM_EXTENSIONS = 0x821D
|
||||||
ONE = 0x1
|
ONE = 0x1
|
||||||
ONE_MINUS_SRC_ALPHA = 0x303
|
ONE_MINUS_SRC_ALPHA = 0x303
|
||||||
|
PROGRAM_BINARY_LENGTH = 0x8741
|
||||||
QUERY_RESULT = 0x8866
|
QUERY_RESULT = 0x8866
|
||||||
QUERY_RESULT_AVAILABLE = 0x8867
|
QUERY_RESULT_AVAILABLE = 0x8867
|
||||||
R16F = 0x822d
|
R16F = 0x822d
|
||||||
|
|||||||
@@ -49,6 +49,7 @@ static void (*_glBeginQuery)(GLenum target, GLuint id);
|
|||||||
static void (*_glDeleteQueries)(GLsizei n, const GLuint *ids);
|
static void (*_glDeleteQueries)(GLsizei n, const GLuint *ids);
|
||||||
static void (*_glEndQuery)(GLenum target);
|
static void (*_glEndQuery)(GLenum target);
|
||||||
static void (*_glGenQueries)(GLsizei n, GLuint *ids);
|
static void (*_glGenQueries)(GLsizei n, GLuint *ids);
|
||||||
|
static void (*_glGetProgramBinary)(GLuint program, GLsizei bufsize, GLsizei *length, GLenum *binaryFormat, void *binary);
|
||||||
static void (*_glGetQueryObjectuiv)(GLuint id, GLenum pname, GLuint *params);
|
static void (*_glGetQueryObjectuiv)(GLuint id, GLenum pname, GLuint *params);
|
||||||
static const GLubyte* (*_glGetStringi)(GLenum name, GLuint index);
|
static const GLubyte* (*_glGetStringi)(GLenum name, GLuint index);
|
||||||
static void (*_glMemoryBarrier)(GLbitfield barriers);
|
static void (*_glMemoryBarrier)(GLbitfield barriers);
|
||||||
@@ -111,6 +112,10 @@ __attribute__ ((visibility ("hidden"))) void gio_glGenQueries(GLsizei n, GLuint
|
|||||||
_glGenQueries(n, ids);
|
_glGenQueries(n, ids);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
__attribute__ ((visibility ("hidden"))) void gio_glGetProgramBinary(GLuint program, GLsizei bufsize, GLsizei *length, GLenum *binaryFormat, void *binary) {
|
||||||
|
_glGetProgramBinary(program, bufsize, length, binaryFormat, binary);
|
||||||
|
}
|
||||||
|
|
||||||
__attribute__ ((visibility ("hidden"))) void gio_glGetQueryObjectuiv(GLuint id, GLenum pname, GLuint *params) {
|
__attribute__ ((visibility ("hidden"))) void gio_glGetQueryObjectuiv(GLuint id, GLenum pname, GLuint *params) {
|
||||||
_glGetQueryObjectuiv(id, pname, params);
|
_glGetQueryObjectuiv(id, pname, params);
|
||||||
}
|
}
|
||||||
@@ -180,6 +185,7 @@ __attribute__((constructor)) static void gio_loadGLFunctions() {
|
|||||||
_glBindImageTexture = dlsym(RTLD_DEFAULT, "glBindImageTexture");
|
_glBindImageTexture = dlsym(RTLD_DEFAULT, "glBindImageTexture");
|
||||||
_glTexStorage2D = dlsym(RTLD_DEFAULT, "glTexStorage2D");
|
_glTexStorage2D = dlsym(RTLD_DEFAULT, "glTexStorage2D");
|
||||||
_glBlitFramebuffer = dlsym(RTLD_DEFAULT, "glBlitFramebuffer");
|
_glBlitFramebuffer = dlsym(RTLD_DEFAULT, "glBlitFramebuffer");
|
||||||
|
_glGetProgramBinary = dlsym(RTLD_DEFAULT, "glGetProgramBinary");
|
||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
import "C"
|
import "C"
|
||||||
@@ -443,6 +449,17 @@ func (f *Functions) GetProgrami(p Program, pname Enum) int {
|
|||||||
return int(f.ints[0])
|
return int(f.ints[0])
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (f *Functions) GetProgramBinary(p Program) []byte {
|
||||||
|
sz := f.GetProgrami(p, PROGRAM_BINARY_LENGTH)
|
||||||
|
if sz == 0 {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
buf := make([]byte, sz)
|
||||||
|
var format C.GLenum
|
||||||
|
C.gio_glGetProgramBinary(C.GLuint(p.V), C.GLsizei(sz), nil, &format, unsafe.Pointer(&buf[0]))
|
||||||
|
return buf
|
||||||
|
}
|
||||||
|
|
||||||
func (f *Functions) GetProgramInfoLog(p Program) string {
|
func (f *Functions) GetProgramInfoLog(p Program) string {
|
||||||
n := f.GetProgrami(p, INFO_LOG_LENGTH)
|
n := f.GetProgrami(p, INFO_LOG_LENGTH)
|
||||||
buf := make([]byte, n)
|
buf := make([]byte, n)
|
||||||
|
|||||||
Reference in New Issue
Block a user