kainino0x / webgpu-cross-platform-demo

Barebones demo of WebGPU cross-platform (web/native) via CMake/Emscripten
https://kai.graphics/webgpu-cross-platform-demo/
75 stars 7 forks source link

Correct way to write shaders #3

Closed jon-chuang closed 1 year ago

jon-chuang commented 4 years ago

Is the right thing to do to generate SPIR-V bytecode for vs/fs/cs from GLSL via glslang and then manually copy as a string into the C++ source?

Also, as an unrelated question, how well-supported is GPGPU on WebGPU atm? Is this not well supported due to restriction on SPIR-V opcodes?

kainino0x commented 4 years ago

You can use this WASM module to do GLSL compilation to SPIR-V (for Chrome and Firefox only) at runtime: https://www.npmjs.com/package/@webgpu/glslang

Note the ingestion format will eventually change from SPIR-V to a text format similar to SPIR-V.

WebGPU currently supports basic compute shaders without any hardware extensions (such as subgroup operations). It should be very roughly the same feature set as compute shaders on Vulkan, OpenGL ES 3.1, or Direct3D 11 without any extensions/optional features.