# Are you going to implement support for WebGPU for C/C++ apps?

**URL:** <https://discourse.libsdl.org/t/are-you-going-to-implement-support-for-webgpu-for-c-c-apps/45645>\
**Category:** SDL Development\
**Created:** [August 22, 2023, 2:28pm UTC](https://discourse.libsdl.org/t/are-you-going-to-implement-support-for-webgpu-for-c-c-apps/45645 "2023-08-22T14:28:31Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![TomiDomi](https://discourse.libsdl.org/letter_avatar_proxy/v4/letter/t/51bf81/32.png) [@TomiDomi](https://discourse.libsdl.org/u/TomiDomi)\
**Post date:** [August 22, 2023, 2:28pm UTC](https://discourse.libsdl.org/t/are-you-going-to-implement-support-for-webgpu-for-c-c-apps/45645/1 "2023-08-22T14:28:31Z")

</div>

There are already available bindings of WebGPU for Rust and C/C++ and of course JS/TS as it is designed for these languages. In case of C/C++ it is called Dawn. Are you going to implement WebGPU interface for C/C++ apps? If I understand correctly it would allow to write shaders using WebGPU Shading Language for all platforms (Linux, Windows, MacOS, Android, Web) and use SDL for other stuff apart from graphics and GPU computations.

---

<div class="post-metadata">

**Author:** ![rtrussell](https://discourse.libsdl.org/user_avatar/discourse.libsdl.org/rtrussell/32/4768_2.png) [@rtrussell](https://discourse.libsdl.org/u/rtrussell)\
**Post date:** [August 24, 2023, 8:19am UTC](https://discourse.libsdl.org/t/are-you-going-to-implement-support-for-webgpu-for-c-c-apps/45645/2 "2023-08-24T08:19:02Z")

</div>

> [@TomiDomi](#):
>
> If I understand correctly it would allow to write shaders using WebGPU Shading Language for all platforms (Linux, Windows, MacOS, Android, Web)

That’s already possible using GLSL. My SDL2 app supports shader programming on all those platforms (plus iOS) using OpenGL/GLES/WebGL as the back end.

You can see my app running a common shader benchmark [here](https://wasm.bbcbasic.co.uk/bbcsdl.html?run=examples/graphics/seascape.bbc) (needs WebAssembly Threads, so not iOS browsers and some embedded browsers).

---

<div class="post-metadata">

**Author:** ![TomiDomi](https://discourse.libsdl.org/letter_avatar_proxy/v4/letter/t/51bf81/32.png) [@TomiDomi](https://discourse.libsdl.org/u/TomiDomi)\
**Post date:** [August 24, 2023, 8:43am UTC](https://discourse.libsdl.org/t/are-you-going-to-implement-support-for-webgpu-for-c-c-apps/45645/3 "2023-08-24T08:43:50Z")

</div>

Yeah, you are right but according to the WebGL Compute specification WebGL is obsolete and the next framework more close to the metal is WebGPU. The quotation from WebGL specs below:

> The WebGL 2.0 Compute specification was a tremendous effort spearheaded by Intel to bring compute shader support to the web via the WebGL rendering context. During the development of this specification, the decision was made to halt further expansion of the WebGL API, and instead focus the contributors’ efforts on the [WebGPU specification](https://gpuweb.github.io/gpuweb/).
> 
> For this reason, this specification should be considered obsolete. The WebGL working group thanks all of the contributors to this specification for their tremendous efforts in specifying and implementing this significant potential addition to the WebGL API. WebGPU will be the path forward for compute shaders on the web.

---

<div class="post-metadata">

**Author:** ![rtrussell](https://discourse.libsdl.org/user_avatar/discourse.libsdl.org/rtrussell/32/4768_2.png) [@rtrussell](https://discourse.libsdl.org/u/rtrussell)\
**Post date:** [August 24, 2023, 5:52pm UTC](https://discourse.libsdl.org/t/are-you-going-to-implement-support-for-webgpu-for-c-c-apps/45645/4 "2023-08-24T17:52:23Z")

</div>

> [@TomiDomi](#):
>
> according to the WebGL Compute specification WebGL is obsolete

If I worried about things becoming ‘obsolete’ or ‘deprecated’ my app would have been abandoned long ago! If and when it actually stops working, then I’ll worry. 😄

---

<div class="post-metadata">

**Author:** ![TomiDomi](https://discourse.libsdl.org/letter_avatar_proxy/v4/letter/t/51bf81/32.png) [@TomiDomi](https://discourse.libsdl.org/u/TomiDomi)\
**Post date:** [August 24, 2023, 8:13pm UTC](https://discourse.libsdl.org/t/are-you-going-to-implement-support-for-webgpu-for-c-c-apps/45645/5 "2023-08-24T20:13:23Z")

</div>

> [@rtrussell](#):
>
> If I worried about things becoming ‘obsolete’ or ‘deprecated’ my app would have been abandoned long ago! If and when it actually stops working, then I’ll worry. 😄

I am not going to convince you to rewrite your apps using WebGPU if you have them already working. I understand also that WebGL will be on the market for long time like OpenGL even if Vulkan is going to replace it finally. Simply WebGPU - if I understand it correctly - is going to relpace WebGL.

On the other hand, as I written before, there are already implementations of WebGPU in Rust and C/C++. So it is possible to write render / compute engine using WebGPU and Rust, C/C++, JS/TS and using WebGPU Shading Language instead of GLSL. Now, why reinvent the wheel again. Smart people invented WebGPU because is more close to the hardware in compare to WebGL. It uses as a back end OpenGL, Vulkan, D3D or Metal depending on the platform and availability. So as this is the possible future for Web and also supports all other platforms why not use it in future projects?

And the question is to the creators of SDL, or maybe it is already implemented but I don’t know it.

---

<div class="post-metadata">

**Author:** ![rtrussell](https://discourse.libsdl.org/user_avatar/discourse.libsdl.org/rtrussell/32/4768_2.png) [@rtrussell](https://discourse.libsdl.org/u/rtrussell)\
**Post date:** [August 26, 2023, 9:28am UTC](https://discourse.libsdl.org/t/are-you-going-to-implement-support-for-webgpu-for-c-c-apps/45645/6 "2023-08-26T09:28:24Z")

</div>

> [@TomiDomi](#):
>
> using WebGPU Shading Language instead of GLSL

How similar is WebGPU Shader Language to GLSL? I’m in a particularly tricky situation with my app (it’s a programming language) because I expose GLSL to my end users, so any change which means the shader source code has to be altered will be incompatible with their existing programs!

---

<div class="post-metadata">

**Author:** ![Zaya6](https://discourse.libsdl.org/user_avatar/discourse.libsdl.org/zaya6/32/4451_2.png) [@Zaya6](https://discourse.libsdl.org/u/Zaya6)\
**Post date:** [August 26, 2023, 3:34pm UTC](https://discourse.libsdl.org/t/are-you-going-to-implement-support-for-webgpu-for-c-c-apps/45645/7 "2023-08-26T15:34:19Z")

</div>

> [@rtrussell](#):
>
> GLSL. My SDL2 app supports shader programming on all those platforms (plus iOS) using OpenGL/GLES/WebGL as the back end.
> 
> You can see my app running a common shader benchmark [here](https://wasm.bbcbasic.co.uk/bbcsdl.html?run=examples/graphics/seascape.bbc) (needs WebAssembly Threads, so not iOS browsers and some embedded browsers).

Wow this has to be the most frustrating type of non-answer ever.

WebGpu is solves a huge problem. OpenGL has has no future on Apple platforms and will soon be removed. Vulcan also doesn’t have support for Apple platforms. Where does that leave devs hoping to create a true cross platform 3d game?

Honestly I’m surprised at the crickets in this thread considering how much the goals of both SDL and WebGpu align.

Is there anything coming up? Any discussions? Is this already possible??

---

<div class="post-metadata">

**Author:** ![rtrussell](https://discourse.libsdl.org/user_avatar/discourse.libsdl.org/rtrussell/32/4768_2.png) [@rtrussell](https://discourse.libsdl.org/u/rtrussell)\
**Post date:** [August 26, 2023, 4:02pm UTC](https://discourse.libsdl.org/t/are-you-going-to-implement-support-for-webgpu-for-c-c-apps/45645/8 "2023-08-26T16:02:46Z")

</div>

> [@Zaya6](#):
>
> OpenGL has has no future on Apple platforms and will soon be removed.

Will soon be removed? What evidence do you have of that? As I’ve noted here before, in my iOS build I receive no warnings at all about my use of OpenGL, not even that it is deprecated. Similarly when submitting my app to the iOS App Store, there are no warnings about OpenGL.

Currently, OpenGL is the only option I have in order to target Windows, MacOS, Linux, Android, iOS and in-browser (Wasm) in such a way that I can expose a common shader programming language to my end-users.

If and when WebGPU, or something else, offers that degree of cross-platform support I can consider migrating to it, although as I’ve said that will introduce incompatibilities if the shader programming language is significantly different from GLSL (i.e. can’t easily be ‘machine translated’).

If OpenGL is actually removed from any of the platforms I support before then, I will be screwed. But hopefully there is a recognition (even at Apple!) that having a common 3D/shader back-end across such a wide range of platforms is valuable.

---

<div class="post-metadata">

**Author:** ![Zaya6](https://discourse.libsdl.org/user_avatar/discourse.libsdl.org/zaya6/32/4451_2.png) [@Zaya6](https://discourse.libsdl.org/u/Zaya6)\
**Post date:** [August 26, 2023, 4:35pm UTC](https://discourse.libsdl.org/t/are-you-going-to-implement-support-for-webgpu-for-c-c-apps/45645/9 "2023-08-26T16:35:42Z")

</div>

> [@rtrussell](#):
>
> > [@Zaya6](#):
> >
> > OpenGL has has no future on Apple platforms and will soon be removed.
> 
> Will soon be removed? What evidence do you have of that? As I’ve noted here before, in my iOS build I receive no warnings at all about my use of OpenGL, not even that it is deprecated. Similarly when submitting my app to the iOS App Store, there are no warnings about OpenGL.

Unfortunately it seems so.

> …Once it’s removed, which could be two years from now, apps using OpenGL will stop working on devices running the latest operating systems, but will continue to work on devices with older OSes. [Apple defends end of OpenGL as Mac game developers threaten to leave | VentureBeat](https://venturebeat.com/games/apple-defends-end-of-opengl-as-mac-game-developers-threaten-to-leave/)

It’s been a while since that article, but it seems like the intention is to eventually remove OpenGL completely causing existing OpenGL games to stop working. Now you can see my interest in using a future proof cross-platform API 🙂

On that front I found an interesting resource in the WebGPU Native demos repo that uses GLFW in a kind of hacky way for window creation. Could something like this be possible with SDL2? I’d much rather use SDL instead of GLFW.

[webgpu-native-examples/src/core/window.c at master · samdauwe/webgpu-native-examples · GitHub](https://github.com/samdauwe/webgpu-native-examples/blob/master/src/core/window.c)

---

<div class="post-metadata">

**Author:** ![rtrussell](https://discourse.libsdl.org/user_avatar/discourse.libsdl.org/rtrussell/32/4768_2.png) [@rtrussell](https://discourse.libsdl.org/u/rtrussell)\
**Post date:** [August 26, 2023, 5:01pm UTC](https://discourse.libsdl.org/t/are-you-going-to-implement-support-for-webgpu-for-c-c-apps/45645/10 "2023-08-26T17:01:31Z")

</div>

> [@Zaya6](#):
>
> it seems like the intention is to eventually remove OpenGL completely

My understanding is that this applies only to MacOS rather than also to iOS. I know that OpenGL has been officially deprecated in MacOS for some time, but the absence of any build-time warnings makes me think the same is not true of iOS.

Why the two platforms would be treated differently I don’t know, unless it’s simply the weight of so many more iOS apps using OpenGL than MacOS apps.

---

<div class="post-metadata">

**Author:** ![Zaya6](https://discourse.libsdl.org/user_avatar/discourse.libsdl.org/zaya6/32/4451_2.png) [@Zaya6](https://discourse.libsdl.org/u/Zaya6)\
**Post date:** [August 26, 2023, 5:10pm UTC](https://discourse.libsdl.org/t/are-you-going-to-implement-support-for-webgpu-for-c-c-apps/45645/11 "2023-08-26T17:10:12Z")

</div>

It’s just feels like a risky move to continue to develop for OpenGL. Apple has a track record of yanking support for things soon after deprecating (hello flash). Sure it’s not a major concern for the short term, but it does feel somewhat like a waste to spend further time learning an API that has no future and who’s support can be cut at any time.

---

<div class="post-metadata">

**Author:** ![rtrussell](https://discourse.libsdl.org/user_avatar/discourse.libsdl.org/rtrussell/32/4768_2.png) [@rtrussell](https://discourse.libsdl.org/u/rtrussell)\
**Post date:** [August 26, 2023, 6:04pm UTC](https://discourse.libsdl.org/t/are-you-going-to-implement-support-for-webgpu-for-c-c-apps/45645/12 "2023-08-26T18:04:34Z")

</div>

> [@Zaya6](#):
>
> It’s just feels like a risky move to continue to develop for OpenGL.

I don’t disagree, but I have no choice. It’s that or a non-working app.

---

<div class="post-metadata">

**Author:** ![TomiDomi](https://discourse.libsdl.org/letter_avatar_proxy/v4/letter/t/51bf81/32.png) [@TomiDomi](https://discourse.libsdl.org/u/TomiDomi)\
**Post date:** [August 26, 2023, 8:35pm UTC](https://discourse.libsdl.org/t/are-you-going-to-implement-support-for-webgpu-for-c-c-apps/45645/13 "2023-08-26T20:35:08Z")

</div>

> [@rtrussell](#):
>
> How similar is WebGPU Shader Language to GLSL?

It is rather far from GLSL. You can read about differneces from the professional point of view here (short)  
[https://dmnsgn.me/blog/from-glsl-to-wgsl-the-future-of-shaders-on-the-web/](https://dmnsgn.me/blog/from-glsl-to-wgsl-the-future-of-shaders-on-the-web/)  
and you can read the full specs (long)  
[https://www.w3.org/TR/WGSL/](https://www.w3.org/TR/WGSL/)

From my point of view I regred that not all vendors support Vulkan and that company “rotted apple” even exist making always troubles. But live is like it is. The creators of Dawn  
are making also Tint which is

> **Tint** is a compiler for the WebGPU Shader Language (WGSL) that can be used in standalone to convert shaders from and to WGSL

I had no time to test it but maybe this is easy way to translate GLSL to WebGPU.

On the other hand I consider Vulkan as to much complicated. WebGPU looks like really nice compromise between OpenGL and Vulkan. Here I want to warn that WebGPU don’t allow for tesselation and geometric shaders but probably it will allow mesh shaders in the future.

Finally, can we have some response from SDL developers? Or maybe my question was, let to say, stupid and there is no question.

---

<div class="post-metadata">

**Author:** ![OKUMURA\_Yuki](https://discourse.libsdl.org/user_avatar/discourse.libsdl.org/okumura_yuki/32/2481_2.png) [@OKUMURA\_Yuki](https://discourse.libsdl.org/u/OKUMURA_Yuki)\
**Post date:** [August 27, 2023, 4:11am UTC](https://discourse.libsdl.org/t/are-you-going-to-implement-support-for-webgpu-for-c-c-apps/45645/14 "2023-08-27T04:11:44Z")

</div>

> [@TomiDomi](#):
>
> I had no time to test it but maybe this is easy way to translate GLSL to WebGPU.

No. Tint is a SPIR-V ↔ WGSL translator. In case you want to code WebGPU with high level shader language, you’ll need some compiler that compiles to SPIR-V such as `glslang` etc.

SDL3 will have their own (modern) GPU abstraction that will directly wraps DX12, Vulkan or Metal [SDL\_shader\_tools/docs/README-SDL\_gpu.md at main · libsdl-org/SDL\_shader\_tools · GitHub](https://github.com/libsdl-org/SDL_shader_tools/blob/main/docs/README-SDL_gpu.md) including shader language and bytecode. It’s still early stage of development but looks promising… Devs say it will wrap WebGPU as well [Future 3D API... - #3 by icculus](https://discourse.libsdl.org/t/future-3d-api/33485/3) (but unfortunately WebGPU dropped multi worker support for v1 [Create a proposal for multi-worker · Issue #354 · gpuweb/gpuweb · GitHub](https://github.com/gpuweb/gpuweb/issues/354) .)

Re: using WebGPU as portability layer; note that their C binding [GitHub - webgpu-native/webgpu-headers](https://github.com/webgpu-native/webgpu-headers) isn’t finished yet. Since Emscripten occasionally syncs their binding with Dawn, I guess using Dawn for non-web would be a good bet for now although future source compatibility is not guaranteed. SDL allows acquiring platform dependent Window or GPU context from initialized SDL window so integrating Dawn to existing SDL project shouldn’t be too hard. There’s Dawn integration for GLFW already [GitHub - eliemichel/glfw3webgpu: An extension for the GLFW library for using WebGPU native.](https://github.com/eliemichel/glfw3webgpu) and similar thing can be done on SDL.

---

<div class="post-metadata">

**Author:** ![sjr](https://discourse.libsdl.org/user_avatar/discourse.libsdl.org/sjr/32/5749_2.png) [@sjr](https://discourse.libsdl.org/u/sjr)\
**Post date:** [August 27, 2023, 7:54pm UTC](https://discourse.libsdl.org/t/are-you-going-to-implement-support-for-webgpu-for-c-c-apps/45645/15 "2023-08-27T19:54:32Z")

</div>

> [@Zaya6](#):
>
> > …Once it’s removed, which could be two years from now, apps using OpenGL will stop working on devices running the latest operating systems, but will continue to work on devices with older OSes. [Apple defends end of OpenGL as Mac game developers threaten to leave | VentureBeat](https://venturebeat.com/games/apple-defends-end-of-opengl-as-mac-game-developers-threaten-to-leave/)
> 
> It’s been a while since that article, but it seems like the intention is to eventually remove OpenGL completely causing existing OpenGL games to stop working. Now you can see my interest in using a future proof cross-platform API 🙂

That article seems to conflating deprecation with complete removal. OpenGL is already deprecated on all Apple platforms. On non-Intel platforms (iOS, M-series Macs), OpenGL is actually implemented on top of Metal. It’s unlikely that it’ll be completely removed, but obviously isn’t a priority for Apple anymore.

> [@TomiDomi](#):
>
> From my point of view I regred that not all vendors support Vulkan and that company “rotted apple” even exist making always troubles.

It’s worth keeping in mind that Metal was designed, implemented, and shipped before Vulkan was even _announced._

---

<div class="post-metadata">

**Author:** ![rtrussell](https://discourse.libsdl.org/user_avatar/discourse.libsdl.org/rtrussell/32/4768_2.png) [@rtrussell](https://discourse.libsdl.org/u/rtrussell)\
**Post date:** [August 28, 2023, 9:19am UTC](https://discourse.libsdl.org/t/are-you-going-to-implement-support-for-webgpu-for-c-c-apps/45645/16 "2023-08-28T09:19:04Z")

</div>

> [@sjr](#):
>
> OpenGL is already deprecated on all Apple platforms.

If that’s the case I find it surprising that I get **no** build-time warnings from Xcode about my use of OpenGLES on iOS. Nor do I get any warnings when submitting to the App Store.

---

<div class="post-metadata">

**Author:** ![sjr](https://discourse.libsdl.org/user_avatar/discourse.libsdl.org/sjr/32/5749_2.png) [@sjr](https://discourse.libsdl.org/u/sjr)\
**Post date:** [August 29, 2023, 1:06am UTC](https://discourse.libsdl.org/t/are-you-going-to-implement-support-for-webgpu-for-c-c-apps/45645/17 "2023-08-29T01:06:33Z")

</div>

> [@rtrussell](#):
>
> If that’s the case I find it surprising that I get **no** build-time warnings from Xcode about my use of OpenGLES on iOS. Nor do I get any warnings when submitting to the App Store.

[Apple has publicly stated that OpenGL is deprecated.](https://www.anandtech.com/show/12894/apple-deprecates-opengl-across-all-oses) I’m not surprised you aren’t getting warnings when submitting to the App Store, since OpenGL/GLES are deprecated but not currently slated for future removal.

When building using Apple’s OpenGL headers (as opposed to GLAD, GLEW, etc), you get a deprecation warning. Building a Mac app that uses OpenGL gives a long list of deprecation warnings like this:

```auto
pl_mpeg_player.c:62:3: warning: 'glGenTextures' is deprecated: first deprecated in macOS 10.14 - OpenGL API deprecated. (Define GL_SILENCE_DEPRECATION to silence these warnings) [-Wdeprecated-declarations]
                glGenTextures(1, name);
                ^
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/System/Library/Frameworks/OpenGL.framework/Headers/gl.h:2498:13: note: 'glGenTextures' has been explicitly marked deprecated here
extern void glGenTextures (GLsizei n, GLuint *textures) OPENGL_DEPRECATED(10.0, 10.14);
            ^

```

---

<div class="post-metadata">

**Author:** ![rtrussell](https://discourse.libsdl.org/user_avatar/discourse.libsdl.org/rtrussell/32/4768_2.png) [@rtrussell](https://discourse.libsdl.org/u/rtrussell)\
**Post date:** [August 29, 2023, 8:14am UTC](https://discourse.libsdl.org/t/are-you-going-to-implement-support-for-webgpu-for-c-c-apps/45645/18 "2023-08-29T08:14:15Z")

</div>

> [@sjr](#):
>
> Building a Mac app that uses OpenGL gives a long list of deprecation warnings

Mac apps, yes. Not only is OpenGL deprecated, its functionality was partly broken some while ago (if I remember rightly `SDL_RENDERER_PRESENTVSYNC` stopped working and SDL had to work around it). But I use the prebuilt SDL2 Framework so I don’t see any build errors related to that,

It was the absence of similar warnings when building for iOS from source that surprised me. I’m not explicitly including any Apple headers, my use of OpenGL stems solely from SDL2 (I’m using the standard 2.28.2 source package but with Metal disabled).

---

<div class="post-metadata">

**Author:** ![sjr](https://discourse.libsdl.org/user_avatar/discourse.libsdl.org/sjr/32/5749_2.png) [@sjr](https://discourse.libsdl.org/u/sjr)\
**Post date:** [August 29, 2023, 2:11pm UTC](https://discourse.libsdl.org/t/are-you-going-to-implement-support-for-webgpu-for-c-c-apps/45645/19 "2023-08-29T14:11:39Z")

</div>

> [@rtrussell](#):
>
> Mac apps, yes.

iOS apps as well. Apple’s headers have all GLES 1, 2, and 3 functions marked as having been deprecated in iOS 12. You can see for yourself by finding `OpenGLES.framework` on your system and looking at the headers inside.

 ![Screenshot 2023-08-29 at 7.48.22 AM](https://discourse.libsdl.org/uploads/default/original/2X/1/197cb9eab987b3253939fb625e30c1e6ec5e13de.png)

As to why you aren’t seeing the deprecation warnings even when building SDL, I’m assuming that SDL is using its own GLES definitions like in `SDL_opengles2_gl2.h` and friends.

---

<div class="post-metadata">

**Author:** ![rtrussell](https://discourse.libsdl.org/user_avatar/discourse.libsdl.org/rtrussell/32/4768_2.png) [@rtrussell](https://discourse.libsdl.org/u/rtrussell)\
**Post date:** [August 29, 2023, 10:56pm UTC](https://discourse.libsdl.org/t/are-you-going-to-implement-support-for-webgpu-for-c-c-apps/45645/20 "2023-08-29T22:56:45Z")

</div>

> [@sjr](#):
>
> As to why you aren’t seeing the deprecation warnings even when building SDL, I’m assuming that SDL is using its own GLES definitions like in `SDL_opengles2_gl2.h` and friends.

Could be. Whatever the cause, I can build my iOS apps without any warnings, and since I have no choice but to use OpenGLES that suits me fine!

[Next page](https://discourse.libsdl.org/t/are-you-going-to-implement-support-for-webgpu-for-c-c-apps/45645.md?page=2)
