From 53fe2e5235daf64a9cb87b3ae976e787f52721c3 Mon Sep 17 00:00:00 2001 From: Elias Naur Date: Thu, 23 Sep 2021 10:03:55 +0200 Subject: [PATCH] gpu/internal/opengl: give up on OpenGL ES 3.1 compute There are too many driver issues with ES 3.1 compute shaders. Most devices support Vulkan but some, such as the Samsung J2, will fall back to the CPU renderer. Signed-off-by: Elias Naur --- gpu/internal/opengl/opengl.go | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/gpu/internal/opengl/opengl.go b/gpu/internal/opengl/opengl.go index 15b8fc660..658a0ff7d 100644 --- a/gpu/internal/opengl/opengl.go +++ b/gpu/internal/opengl/opengl.go @@ -172,6 +172,13 @@ func init() { driver.NewOpenGLDevice = newOpenGLDevice } +// Supporting compute programs is theoretically possible with OpenGL ES 3.1. In +// practice, there are too many driver issues, especially on Android (e.g. +// Google Pixel, Samsung J2 are both broken i different ways). Disable support +// and rely on Vulkan for devices that support it, and the CPU fallback for +// devices that don't. +const brokenGLES31 = true + func newOpenGLDevice(api driver.OpenGL) (driver.Device, error) { f, err := gl.NewFunctions(api.Context, api.ES) if err != nil { @@ -201,7 +208,7 @@ func newOpenGLDevice(api driver.OpenGL) (driver.Device, error) { if ffboErr == nil { b.feats.Features |= driver.FeatureFloatRenderTargets } - if gles31 { + if gles31 && !brokenGLES31 { b.feats.Features |= driver.FeatureCompute } if hasExtension(exts, "GL_EXT_disjoint_timer_query_webgl2") || hasExtension(exts, "GL_EXT_disjoint_timer_query") { @@ -851,7 +858,9 @@ func (b *Backend) clearOutput(colR, colG, colB, colA float32) { } func (b *Backend) NewComputeProgram(src shader.Sources) (driver.Program, error) { - p, err := gl.CreateComputeProgram(b.funcs, src.GLSL310ES) + // We don't support ES 3.1 compute, see brokenGLES31 above. + const GLES31Source = "" + p, err := gl.CreateComputeProgram(b.funcs, GLES31Source) if err != nil { return nil, fmt.Errorf("%s: %v", src.Name, err) }