Skip to content

Added WGVK backend#9316

Closed
r-lyeh wants to merge 3 commits intoocornut:masterfrom
r-lyeh:master
Closed

Added WGVK backend#9316
r-lyeh wants to merge 3 commits intoocornut:masterfrom
r-lyeh:master

Conversation

@r-lyeh
Copy link
Copy Markdown
Contributor

@r-lyeh r-lyeh commented Mar 20, 2026

Let's see how the CI takes this one.

  • Clean restart from our last PR. This is using latest DearImgui commit + latest WGVK.
  • Provided SPIRV binary shaders as a WGSL fallback.
  • Fixed GLFW3+SDL2+SDL3 examples.
  • Emscripten and/or Dawn code paths are untouched.

@ocornut
Copy link
Copy Markdown
Owner

ocornut commented Mar 21, 2026

Thanks.
(FYI git info: you don’t need to create a new PR to clean an existing one. As 1 PR = 1 branch all you need to do is to force push changes to an existing PR branch if you want to eg clean history.)

@ocornut ocornut added backends web emscripten, wgpu etc. labels Mar 23, 2026
@ocornut
Copy link
Copy Markdown
Owner

ocornut commented Mar 23, 2026

Linking to #9246 and #9257 for conversation history.

@ocornut
Copy link
Copy Markdown
Owner

ocornut commented Mar 23, 2026

Where do you obtain the wgslc tool mentioned to create spirv from wgsl ?

@r-lyeh
Copy link
Copy Markdown
Contributor Author

r-lyeh commented Mar 23, 2026

@r-lyeh
Copy link
Copy Markdown
Contributor Author

r-lyeh commented Mar 23, 2026

not sure why these are not added in some tools/ subfolder in the WGVK repo

ocornut pushed a commit that referenced this pull request Mar 25, 2026
)

Squashed: minified SPIRV binaries by stripping strings + emitting in binary_to_compressed_c.
@ocornut
Copy link
Copy Markdown
Owner

ocornut commented Mar 25, 2026

Thank you.

I wanted to make sure I could rebuild the output. I confirmed I could rebuild it.
I added spv_options.strip_all_names = true; to the converter, which reduced SPIRV binaries from 4264 bytes to 3388 bytes, and I exported them using binary_to_compressed_c -u8 -nocompress which reduced the sources files by 20k-30k and line count by -220 lines. I squashed this into your commit to avoid storing unnecessary data in git permanent history.

Merged as 5978002 + minor subsequent amends 59183cf.

I also confirmed I managed to build WGVK and run the example on my PC.

While this is not yet provided as a stock .vcproj, it was very refreshing that building with WGVK was comparatively much easier and faster than building with e.g. DAWN. This becomes an alternative that I can envision running and testing much more than DAWN.

For anyone attempting to build examples,

  • Add %WGVK_DIR%/include to include path.
  • Add %WVGK_DIR%/src/wgvk.c file to project, compile with latest C standard w/ C11 atomics (in visual studio it needed /experimental:c11atomics command-line flag).

One last missing thing would be updating the CMakefile in examples/ to document and build with WGVK.

@ocornut
Copy link
Copy Markdown
Owner

ocornut commented Mar 25, 2026

I have now added support for WGVK in the 3 Cmakelist files with ed2e5dd

@r-lyeh
Copy link
Copy Markdown
Contributor Author

r-lyeh commented Mar 25, 2026

great work! thanks omar. not sure how complete/on par wgvk is against the other standards but it is definitely waaaaay better and faster than going with the classic dawn/wgpu/emscripten path imho. for dearimgui use cases it might eventually suffice with a lil bit of luck.

@ocornut
Copy link
Copy Markdown
Owner

ocornut commented Apr 23, 2026

It currently asserts on latest WGVK because of manuel5975p/WGVK@d9c6dad

ocornut added a commit that referenced this pull request Apr 23, 2026
@ocornut
Copy link
Copy Markdown
Owner

ocornut commented Apr 23, 2026

Pushed e887098 to always use SPIR-V shaders on WGVK.

Tho I am not sure the assert added by manuel5975p/WGVK@d9c6dad is wise. @manuel5975p: Is there a way at runtime or compile-time (in our code) to reliably detect if WGVK will support WGSL shaders? There's no reason for SUPPORT_WGSL to be set in your compilation unit.

@manuel5975p
Copy link
Copy Markdown

@ocornut I proposed a way to fix this in #9387, let me know what you think.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backends web emscripten, wgpu etc.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants