Skip to content

Wgvk dynamic wgsl detection#9387

Open
manuel5975p wants to merge 2 commits intoocornut:masterfrom
manuel5975p:wgvk_dynamic_wgsl_detection
Open

Wgvk dynamic wgsl detection#9387
manuel5975p wants to merge 2 commits intoocornut:masterfrom
manuel5975p:wgvk_dynamic_wgsl_detection

Conversation

@manuel5975p
Copy link
Copy Markdown

Two commits:

  1. detect WGSL support at runtime instead of excluding WGVK at compile time.
    Drops the #if !defined(IMGUI_IMPL_WEBGPU_BACKEND_WGVK) guard around the WGSL shader module
    creation. Now WGSL is attempted on all backends; if the module comes back null (or fails the
    wrapping validation error scope), an empty stage_desc is returned and the existing SPIRV
    fallback at the call site kicks in. Result: WGVK builds with WGVK_WGSL_SUPPORT=SIMPLE_WGSL
    or =TINT actually use WGSL now; builds without it fall through cleanly.

  2. GLFW+WGPU: wire up the IMGUI_WGVK_DIR path.The if(IMGUI_WGVK_DIR) block in the example's CMakeLists was a stub. Filled in: find_package(Vulkan), pkg-config wayland-client, find_package(X11), set the
    SUPPORT_*_SURFACE defines that wgvk.c reads, and assemble the LIBRARIES list.
    Without these the example failed at link (missing glfw/Vulkan symbols) and at runtime
    ("Unsupported surface SType" assertion in WGVK).

I wouldn't mind rebasing the cmake related commit out if youd rather keep it out of imgui and address it on the WGVK side.

… WGVK at compile time.

Previously WGVK was hard-disabled from WGSL via #if !defined(IMGUI_IMPL_WEBGPU_BACKEND_WGVK),
forcing the SPIRV fallback unconditionally. Now the WGSL path is attempted on all backends
and an empty stage_desc is returned when the module fails to compile letting the existing
SPIRV fallback at the call site kick in.
on top of that, WGVK by default now builds with WGSL support (SIMPLE_WGSL/TINT)
can now actually use WGSL, a build without it will return NULL from wgpuDeviceCreateShaderModule
and fall through cleanly. A push/pop validation error scope is wrapped around the call to
catch WGSL validation errors that surface as a nonnull but invalid module.
The block was a stub - find Vulkan, detect Wayland/X11, set the SUPPORT_*_SURFACE
defines that wgvk.c needs, and link the right platform libs. Builds and runs on
Linux now; previously failed at link with missing glfw symbols and at runtime
with "Unsupported surface SType" when wgvk.c was compiled without the surface
defines.
@manuel5975p manuel5975p mentioned this pull request May 1, 2026
@ocornut
Copy link
Copy Markdown
Owner

ocornut commented May 1, 2026

I don’t mind the cmakefile changes but they need to be done on all 3 similar cmakefiles.

@ocornut ocornut added backends vulkan web emscripten, wgpu etc. labels May 5, 2026
@ocornut
Copy link
Copy Markdown
Owner

ocornut commented May 5, 2026

@manuel5975p Can you confirm that:

  • The runtime validation checks works for Dawn and WGPU-Native as well?
  • That both commits may be merged separately? (they don't require each others)

@manuel5975p
Copy link
Copy Markdown
Author

As far as I know, Dawn and wgpu-native always include a wgsl parser (since it's required by the webgpu spec). But yes, that means WGSL shader creation will not

  • return NULL
  • emit a validation error

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

Labels

backends vulkan web emscripten, wgpu etc.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants