dotnet / Silk.NET

The high-speed OpenGL, OpenCL, OpenAL, OpenXR, GLFW, SDL, Vulkan, Assimp, WebGPU, and DirectX bindings library your mother warned you about.
https://dotnet.github.io/Silk.NET
MIT License
4.15k stars 397 forks source link

Add bindings for Tint #1842

Open LeNitrous opened 10 months ago

LeNitrous commented 10 months ago

Summary of feature

Tint is Google's compiler for the WebGPU shader language and is used by libraries such as Babylon.js and Naga. It allows compilation of SPIR-V code to and from WGSL. Used in conjunction with Shaderc and SPIRV-Cross, it will enable a full compilation chain between GLSL/HLSL to and from SPIR-V then to and from WGSL.

Comments

Tint is available via Google Git: https://dawn.googlesource.com/tint

Beyley commented 10 months ago

I dont feel Tint bindings are necessary. Both Dawn and wgpu-native are able to intake SPIRV directly without a conversion since Tint and Naga are builtin to the libraries. This doesnt cover the manually translating WGSL -> SPIRV case, however i dont believe that case would be very common, or has many uses.

With shaderc + wpgu-native/dawn, you can already compile GLSL to SPIRV, then pass that SPIRV into the respective implementation directly.

Perksey commented 10 months ago

What about WASM?

Beyley commented 10 months ago

What about WASM?

Both google and mozilla have shown interest in providing this to JS as well through an extension. I believe it already works with chromium behind the "unsafe webgpu support" flag (webgpu itself is also still behind said flag on some platforms on chromium, so thats doesnt mean much)

In either case, you probably dont want to be packing many-megabyte shader compilation and translation libraries into your game's WASM build, and should do any shader translations offline as a build step

Perksey commented 10 months ago

What about WebKit?

Beyley commented 10 months ago

What about WebKit?

Not sure about webkit, however it is extremely unlikely they will provide SPIRV support given apple is probably a very large reason we arent using SPIRV on WebGPU as the standard in the first place.

In that case it would make sense to provide Tint/Naga bindings, but we should try to steer users away from doing this at runtime in their WASM builds as much as possible, given the huge inefficiencies at play here in a web environment

Perksey commented 10 months ago

Yeah absolutely agree.