Skip to content

Commit

Permalink
gpu/internal/opengl: give up on OpenGL ES 3.1 compute
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
eliasnaur committed Sep 23, 2021
1 parent d9effda commit 53fe2e5
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions gpu/internal/opengl/opengl.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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") {
Expand Down Expand Up @@ -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)
}
Expand Down

0 comments on commit 53fe2e5

Please sign in to comment.