From 9bf4e559bca8868b6e5a5f293f5afa03176491af Mon Sep 17 00:00:00 2001 From: Elias Naur Date: Sat, 17 Apr 2021 11:02:19 +0200 Subject: [PATCH] gpu/internal/opengl: use uniform blocks on macOS The reflected uniform names are for the shader versions that don't use uniform buffer objects. For UBO shaders, the names won't resolve. This change adds a panic when shader uniforms are not found, and fixes Fixes gio#216 Signed-off-by: Elias Naur --- gpu/internal/opengl/opengl.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/gpu/internal/opengl/opengl.go b/gpu/internal/opengl/opengl.go index ecb45550..d6b15886 100644 --- a/gpu/internal/opengl/opengl.go +++ b/gpu/internal/opengl/opengl.go @@ -145,10 +145,11 @@ func newOpenGLDevice(api driver.OpenGL) (driver.Device, error) { } gles30 := gles && ver[0] >= 3 gles31 := gles && (ver[0] > 3 || (ver[0] == 3 && ver[1] >= 1)) + gl40 := !gles && ver[0] >= 4 b := &Backend{ glver: ver, gles: gles, - ubo: gles30, + ubo: gles30 || gl40, funcs: f, floatTriple: floatTriple, alphaTriple: alphaTripleFor(ver), @@ -571,6 +572,9 @@ func (b *Backend) NewProgram(vertShader, fragShader driver.ShaderSources) (drive func lookupUniform(funcs *gl.Functions, p gl.Program, loc driver.UniformLocation) uniformLocation { u := funcs.GetUniformLocation(p, loc.Name) + if !u.Valid() { + panic(fmt.Errorf("uniform %q not found", loc.Name)) + } return uniformLocation{uniform: u, offset: loc.Offset, typ: loc.Type, size: loc.Size} }