Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

x/exp/shiny: gldriver forces HW acceleration on darwin #19191

Closed
fabian-z opened this issue Feb 19, 2017 · 3 comments
Closed

x/exp/shiny: gldriver forces HW acceleration on darwin #19191

fabian-z opened this issue Feb 19, 2017 · 3 comments

Comments

@fabian-z
Copy link

fabian-z commented Feb 19, 2017

Go version and OS

go version go1.8 darwin/amd64 (macOS Sierra 10.12.3)

### What did you do?

Run examples from ```golang.org/x/exp/shiny/example```:

```go get -tags=example golang.org/x/exp/shiny/example/imageview && $GOPATH/bin/imageview cat.jpg```

### What did you expect to see?

Working shiny windows using gldriver on SW renderers.

### What did you see instead?

On macOS, shiny applications fail during OpenGL setup when the system has no HW renderer available (e.g. in [overloaded GPU](https://developer.apple.com/library/content/qa/qa1502/_index.html) or VM scenarios). 
The error occurs during glGenVertexArrays and is first checked when the Cocoa backend invokes glBindVertexArray:

```
panic: gldriver: glBindVertexArray failed: 1282

goroutine 18 [running, locked to thread]:
golang.org/x/exp/shiny/driver/gldriver.drawLoop(0xc4200f4000, 0x307)
	/Users/fabian/Desktop/go/src/golang.org/x/exp/shiny/driver/gldriver/cocoa.go:146 +0x37a
created by golang.org/x/exp/shiny/driver/gldriver.preparedOpenGL
	/Users/fabian/Desktop/go/src/golang.org/x/exp/shiny/driver/gldriver/cocoa.go:83 +0xf4
```

The issue is fixed by removing ```NSOpenGLPFAAccelerated``` from ```NSOpenGLPixelFormatAttribute```:
```
diff --git a/shiny/driver/gldriver/cocoa.m b/shiny/driver/gldriver/cocoa.m
index e8e863e..1e96e3f 100644
--- a/shiny/driver/gldriver/cocoa.m
+++ b/shiny/driver/gldriver/cocoa.m
@@ -284,7 +284,6 @@ uintptr_t doNewWindow(int width, int height, char* title) {
 			NSOpenGLPFAColorSize,     24,
 			NSOpenGLPFAAlphaSize,     8,
 			NSOpenGLPFADepthSize,     16,
-			NSOpenGLPFAAccelerated,
 			NSOpenGLPFADoubleBuffer,
 			NSOpenGLPFAAllowOfflineRenderers,
 			0

```
Note that macOS will still [prefer HW accelerated rendering](https://developer.apple.com/reference/appkit/1436213-anonymous/nsopenglpfaaccelerated) with this change.

On Linux using the x11 gldriver (changing driver backend as in #12740), the built examples fail with 
```
eglCreateContext failed: EGL_BAD_CONFIG
```
However, when exporting ```LIBGL_ALWAYS_SOFTWARE=1``` to force SW rendering, the example runs fine. The mesa GLES2 demos (e.g. es2gears_x11) work without that environment flag.

I can't provide a patch for Linux gldriver right now, but I will be glad to submit a CL for Darwin if this is agreed upon.
@fabian-z
Copy link
Author

The x11 gldriver issue is likely due to ES3 being used in the call to eglCreateContext. It should be adressed by CL 37311. Changing topic since these are two separate issues.

Still looking forward to feedback regarding the Darwin HW acceleration though.
/cc @crawshaw @nigeltao

@fabian-z fabian-z changed the title x/exp/shiny: gldriver forces HW acceleration x/exp/shiny: gldriver forces HW acceleration on darwin Feb 21, 2017
@nigeltao
Copy link
Contributor

@crawshaw knows the Darwin flavor of gldriver better than I do, although it's been many months since either of us have looked at it.

@gopherbot gopherbot added this to the Unreleased milestone Mar 21, 2017
@gopherbot
Copy link

CL https://golang.org/cl/44379 mentions this issue.

@golang golang locked and limited conversation to collaborators Jun 2, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants