Getting a gpu surface with webgl?

252 views
Skip to first unread message

Jeru Sanders

unread,
Jul 16, 2021, 8:57:23 PM7/16/21
to skia-discuss
Long story short:

```
auto interface = GrGLMakeNativeInterface();
if (!interface.get()) printf("Failed to make native interface\n");
```

I'm switching from CPU rendering to GPU. Things work great on Windows, I can create a GrDirectContext using either an msaa framebuffer or texture just fine, but in html5 via emscripten GrGLMakeNativeInterface() returns NULL.

The only thing I can think of is the fact that I'm using SDL2, to create the context.

I'm debating between tearing up all my SDL2 code, or finding a way to build source maps for skia so I can step through GrGLMakeNativeInterface() and figure out why it returns NULL.

Any suggestions? I should have a proper webgl2 and GrGLMakeNativeInterface() is the first skia related function I call, so there's not really any setup code to post.

Jeru Sanders

unread,
Jul 16, 2021, 10:26:29 PM7/16/21
to skia-discuss
I should note that I'm linking skia to an existing custom C++/opengl game engine. I'm building skia using the build guide but using `gn --args="cc=[...]\emcc.bat"` to replace the change the compiler to emcc/em++, along with a bunch of other args. That generates libskia.a that I ultimately link. I remember following a guide explaining how to do it a few months ago, but can't find it now.

I get the feeling there's probably a more "correct" way of using skia in emscripten by attaching to canvas or the browsers renderer. Instead of just running skia again cross-compiled inside my app, but I can't find very much information about this at all.

Jeru Sanders

unread,
Jul 18, 2021, 2:37:03 PM7/18/21
to skia-discuss
I figured it out, I was building with a stubbed out version of GrGLMakeAssembledWebGLInterface() that just returns NULL. I spent a few days learning how ninja and gn worked, it seems like I was missing -DSK_USE_WEBGL and possibly also -DSK_ASSUME_WEBGL=1 because `skia_gl_standard = "webgl"` doesn't get set.

I've got it building, but now I get a crash at GrStrokeTessellateOp because of unaligned memory access (full stack trace). This only happens when using a gpu-backed surface, cpu ones work fine.

I still kinda feel like I'm building this wrong though.
Reply all
Reply to author
Forward
0 new messages