feat(wgpu): Use wgsl (finally) in the WebGPU backend (#12541) d779307982
Transpiles shaders from spv to wgsl using naga. Naga automatically
transforms specialization constants into wgsl override constants, which
we then set via the WebGPU API. However, naga is more limited in what it
supports for specialization constants (namely, it does not support
SpecConstantOp), so we switch all our specialization constants to plain
bools that don't need manipulation. Updates the WebGPU backend to use
this newly generated wgsl instead of spirv.

Co-authored-by: Chris Dalton <99840794+csmartdalton@users.noreply.github.com>
diff --git a/.rive_head b/.rive_head
index d500730..568d29a 100644
--- a/.rive_head
+++ b/.rive_head
@@ -1 +1 @@
-308565c15e128a04c6d0c463b75dfa488799add9
+d779307982703d4c0588e4c957aae64b95b62f32
diff --git a/renderer/include/rive/renderer/vulkan/vkutil.hpp b/renderer/include/rive/renderer/vulkan/vkutil.hpp
index 8944f55..8f021c6 100644
--- a/renderer/include/rive/renderer/vulkan/vkutil.hpp
+++ b/renderer/include/rive/renderer/vulkan/vkutil.hpp
@@ -22,6 +22,18 @@
 
 namespace rive::gpu::vkutil
 {
+// Vulkan vendor IDs.
+namespace vendors
+{
+constexpr static uint32_t AMD = 0x1002u;
+constexpr static uint32_t Imagination = 0x1010u;
+constexpr static uint32_t NVIDIA = 0x10DEu;
+constexpr static uint32_t ARM = 0x13B5u;
+constexpr static uint32_t Qualcomm = 0x5143u;
+constexpr static uint32_t Intel = 0x8086u;
+constexpr static uint32_t Samsung = 0x144d;
+}; // namespace vendors
+
 const char* string_from_vk_result(VkResult);
 
 inline static void vk_check(VkResult res, const char* file, int line)
diff --git a/renderer/include/rive/renderer/webgpu/render_context_webgpu_impl.hpp b/renderer/include/rive/renderer/webgpu/render_context_webgpu_impl.hpp
index e9d269b..ef9cfb1 100644
--- a/renderer/include/rive/renderer/webgpu/render_context_webgpu_impl.hpp
+++ b/renderer/include/rive/renderer/webgpu/render_context_webgpu_impl.hpp
@@ -5,6 +5,7 @@
 #pragma once
 
 #include "rive/renderer/render_context_helper_impl.hpp"
+#include "rive/renderer/texture.hpp"
 #include <map>
 #include <webgpu/webgpu_cpp.h>
 
@@ -16,6 +17,11 @@
 {
 class RenderTargetWebGPU;
 
+namespace wgsl
+{
+struct Shader;
+}
+
 class RenderContextWebGPUImpl : public RenderContextHelperImpl
 {
 public:
@@ -98,13 +104,22 @@
                             const ContextOptions&);
 
     // Create a standard PLS "draw" pipeline for the current implementation.
-    wgpu::RenderPipeline makeDrawPipeline(rive::gpu::DrawType,
-                                          gpu::InterlockMode,
-                                          gpu::ShaderMiscFlags,
-                                          wgpu::TextureFormat framebufferFormat,
-                                          wgpu::ShaderModule vertexShader,
-                                          wgpu::ShaderModule fragmentShader,
-                                          const gpu::PipelineState&);
+    // vertexShader / fragmentShader carry information about which override
+    // constants are actually used by the shader (WebGPU doesn't allow
+    // overriding a constant that is declared but not used via the main
+    // entrypoint). Pass nullptr for non-WGSL (e.g. WAGYU/GLSL) shader paths,
+    // where permutations are baked in via #defines and there are no overrides.
+    wgpu::RenderPipeline makeDrawPipeline(
+        rive::gpu::DrawType,
+        gpu::ShaderFeatures,
+        gpu::InterlockMode,
+        gpu::ShaderMiscFlags,
+        wgpu::TextureFormat framebufferFormat,
+        wgpu::ShaderModule vertexShaderModule,
+        wgpu::ShaderModule fragmentShaderModule,
+        const wgsl::Shader* vertexShader,
+        const wgsl::Shader* fragmentShader,
+        const gpu::PipelineState&);
 
     // Begin a Rive render pass that uses pixel local storage.
     wgpu::RenderPassEncoder beginPLSRenderPass(wgpu::CommandEncoder,
diff --git a/renderer/make_dawn.sh b/renderer/make_dawn.sh
index b71963f..72ef393 100755
--- a/renderer/make_dawn.sh
+++ b/renderer/make_dawn.sh
@@ -5,6 +5,7 @@
 mkdir -p dependencies
 cd dependencies
 
+echo
 if [ ! -d dawn ]; then
 	echo "Cloning Dawn..."
     git clone https://dawn.googlesource.com/dawn
@@ -14,8 +15,37 @@
 fi
 
 cd dawn
-git checkout 50f469b60b89ac3575abc43f1d6bbe7dcd39e647
+
+echo
+echo Checking out code...
+git reset --hard
+git checkout 211333b2e3e429c3508f25c81c547f602adf448c
 cp scripts/standalone.gclient .gclient
 gclient sync -f -D
+
+echo
+echo Manually applying patches to suppress compiler warnings...
+pushd build
+git apply - << 'EOF'
+diff --git a/config/compiler/BUILD.gn b/config/compiler/BUILD.gn
+index 6a96f9b6f..4c1387628 100644
+--- a/config/compiler/BUILD.gn
++++ b/config/compiler/BUILD.gn
+@@ -336,6 +336,7 @@ config("compiler") {
+   # categories here, add it to the associated file to keep this shared config
+   # smaller.
+   if (is_win) {
++    defines += [ "_SILENCE_CXX20_OLD_SHARED_PTR_ATOMIC_SUPPORT_DEPRECATION_WARNING" ]
+     configs += [ "//build/config/win:compiler" ]
+   } else if (is_android) {
+     configs += [ "//build/config/android:compiler" ]
+EOF
+popd
+
+echo
+echo Generating out/release/args.gn...
 gn gen --args='is_debug=false dawn_complete_static_libs=true use_custom_libcxx=false dawn_use_swiftshader=false angle_enable_swiftshader=false' out/release
+
+echo
+echo Compiling...
 ninja -C out/release -j20 webgpu_dawn_static cpp proc_static
diff --git a/renderer/path_fiddle/fiddle_context_dawn.cpp b/renderer/path_fiddle/fiddle_context_dawn.cpp
index 552f223..4b6c56c 100644
--- a/renderer/path_fiddle/fiddle_context_dawn.cpp
+++ b/renderer/path_fiddle/fiddle_context_dawn.cpp
@@ -66,12 +66,11 @@
 public:
     FiddleContextDawnPLS(FiddleContextOptions options) : m_options(options)
     {
-        // optionally use WGPUInstanceDescriptor::nextInChain for
-        // WGPUDawnTogglesDescriptor with various toggles enabled or
-        // disabled:
-        // https://dawn.googlesource.com/dawn/+/refs/heads/main/src/dawn/native/Toggles.cpp
+        // Enable blocking waits to simplify our Dawn backend.
+        constexpr auto timedWaitAny = WGPUInstanceFeatureName_TimedWaitAny;
         WGPUInstanceDescriptor instanceDescriptor = {
-            .capabilities = {.timedWaitAnyEnable = true},
+            .requiredFeatureCount = 1,
+            .requiredFeatures = &timedWaitAny,
         };
         m_instance =
             wgpu::Instance::Acquire(wgpuCreateInstance(&instanceDescriptor));
@@ -135,8 +134,8 @@
             assert(m_surface && "Failed to create WebGPU surface");
 
             WGPURequestAdapterOptions options = {
-                .compatibleSurface = m_surface.Get(),
                 .powerPreference = WGPUPowerPreference_HighPerformance,
+                .compatibleSurface = m_surface.Get(),
             };
 
             WGPUAdapter adapter = nullptr;
diff --git a/renderer/premake5_pls_renderer.lua b/renderer/premake5_pls_renderer.lua
index 8700f6f..070c9a4 100644
--- a/renderer/premake5_pls_renderer.lua
+++ b/renderer/premake5_pls_renderer.lua
@@ -238,14 +238,18 @@
         makecommand = makecommand .. ' rive_pls_macosx_metallib'
     end
 end
-
 if rive_target_os == 'windows' then
     makecommand = makecommand .. ' d3d'
 end
-
-if _OPTIONS['with_vulkan'] or _OPTIONS['with-dawn'] or _OPTIONS['with-webgpu'] then
+if _OPTIONS['with_vulkan'] then
     makecommand = makecommand .. ' spirv'
 end
+if _OPTIONS['with-dawn'] or _OPTIONS['with-webgpu'] then
+    if _OPTIONS['raw_shaders'] then
+        makecommand = makecommand .. ' WGSL_FLAGS="--raw"'
+    end
+    makecommand = makecommand .. ' wgsl'
+end
 
 function execute_and_check(cmd)
     print(cmd)
diff --git a/renderer/rive_vk_bootstrap/src/vulkan_device.cpp b/renderer/rive_vk_bootstrap/src/vulkan_device.cpp
index 0517db7..1bbc56d 100644
--- a/renderer/rive_vk_bootstrap/src/vulkan_device.cpp
+++ b/renderer/rive_vk_bootstrap/src/vulkan_device.cpp
@@ -36,7 +36,7 @@
 VulkanDevice::DriverVersion unpackDriverVersion(
     const VkPhysicalDeviceProperties& props)
 {
-    if (props.vendorID == VULKAN_VENDOR_NVIDIA)
+    if (props.vendorID == rive::gpu::vkutil::vendors::NVIDIA)
     {
         // NVidia uses 10|8|8|6 encoding for driver version. We'll ignore the
         // fourth version section.
@@ -47,7 +47,7 @@
         };
     }
 #ifdef _WIN32
-    else if (props.vendorID == VULKAN_VENDOR_INTEL)
+    else if (props.vendorID == rive::gpu::vkutil::vendors::Intel)
     {
         return {
             .major = props.driverVersion >> 14,
diff --git a/renderer/shader_hotload/shader_hotload.cpp b/renderer/shader_hotload/shader_hotload.cpp
index ffa5df5..a99ccf3 100644
--- a/renderer/shader_hotload/shader_hotload.cpp
+++ b/renderer/shader_hotload/shader_hotload.cpp
@@ -63,114 +63,110 @@
 
     // List of all shader bytecode files
     std::filesystem::path spirvFileNames[] = {
-        riveSpirvPath / "color_ramp.vert.spirv",
-        riveSpirvPath / "color_ramp.frag.spirv",
-        riveSpirvPath / "tessellate.vert.spirv",
-        riveSpirvPath / "tessellate.frag.spirv",
-        riveSpirvPath / "render_atlas.vert.spirv",
-        riveSpirvPath / "render_atlas_fill.frag.spirv",
-        riveSpirvPath / "render_atlas_stroke.frag.spirv",
-        riveSpirvPath / "draw_path.vert.spirv",
-        riveSpirvPath / "draw_path.frag.spirv",
-        riveSpirvPath / "draw_interior_triangles.vert.spirv",
-        riveSpirvPath / "draw_interior_triangles.frag.spirv",
-        riveSpirvPath / "draw_atlas_blit.vert.spirv",
-        riveSpirvPath / "draw_atlas_blit.frag.spirv",
-        riveSpirvPath / "draw_image_mesh.vert.spirv",
-        riveSpirvPath / "draw_image_mesh.frag.spirv",
+        riveSpirvPath / "color_ramp.vert.spv",
+        riveSpirvPath / "color_ramp.frag.spv",
+        riveSpirvPath / "tessellate.vert.spv",
+        riveSpirvPath / "tessellate.frag.spv",
+        riveSpirvPath / "render_atlas.vert.spv",
+        riveSpirvPath / "render_atlas_fill.frag.spv",
+        riveSpirvPath / "render_atlas_stroke.frag.spv",
+        riveSpirvPath / "draw_path.vert.spv",
+        riveSpirvPath / "draw_path.frag.spv",
+        riveSpirvPath / "draw_interior_triangles.vert.spv",
+        riveSpirvPath / "draw_interior_triangles.frag.spv",
+        riveSpirvPath / "draw_atlas_blit.vert.spv",
+        riveSpirvPath / "draw_atlas_blit.frag.spv",
+        riveSpirvPath / "draw_image_mesh.vert.spv",
+        riveSpirvPath / "draw_image_mesh.frag.spv",
 
-        riveSpirvPath / "atomic_draw_path.vert.spirv",
-        riveSpirvPath / "atomic_draw_path.frag.spirv",
-        riveSpirvPath / "atomic_draw_path.fixedcolor_frag.spirv",
-        riveSpirvPath / "atomic_draw_interior_triangles.vert.spirv",
-        riveSpirvPath / "atomic_draw_interior_triangles.frag.spirv",
-        riveSpirvPath / "atomic_draw_interior_triangles.fixedcolor_frag.spirv",
-        riveSpirvPath / "atomic_draw_atlas_blit.vert.spirv",
-        riveSpirvPath / "atomic_draw_atlas_blit.frag.spirv",
-        riveSpirvPath / "atomic_draw_atlas_blit.fixedcolor_frag.spirv",
-        riveSpirvPath / "atomic_draw_image_rect.vert.spirv",
-        riveSpirvPath / "atomic_draw_image_rect.frag.spirv",
-        riveSpirvPath / "atomic_draw_image_rect.fixedcolor_frag.spirv",
-        riveSpirvPath / "atomic_draw_image_mesh.vert.spirv",
-        riveSpirvPath / "atomic_draw_image_mesh.frag.spirv",
-        riveSpirvPath / "atomic_draw_image_mesh.fixedcolor_frag.spirv",
-        riveSpirvPath / "atomic_resolve.vert.spirv",
-        riveSpirvPath / "atomic_resolve.frag.spirv",
-        riveSpirvPath / "atomic_resolve.fixedcolor_frag.spirv",
-        riveSpirvPath / "atomic_resolve_coalesced.vert.spirv",
-        riveSpirvPath / "atomic_resolve_coalesced.frag.spirv",
+        riveSpirvPath / "atomic_draw_path.vert.spv",
+        riveSpirvPath / "atomic_draw_path.frag.spv",
+        riveSpirvPath / "atomic_draw_path.fixedcolor_frag.spv",
+        riveSpirvPath / "atomic_draw_interior_triangles.vert.spv",
+        riveSpirvPath / "atomic_draw_interior_triangles.frag.spv",
+        riveSpirvPath / "atomic_draw_interior_triangles.fixedcolor_frag.spv",
+        riveSpirvPath / "atomic_draw_atlas_blit.vert.spv",
+        riveSpirvPath / "atomic_draw_atlas_blit.frag.spv",
+        riveSpirvPath / "atomic_draw_atlas_blit.fixedcolor_frag.spv",
+        riveSpirvPath / "atomic_draw_image_rect.vert.spv",
+        riveSpirvPath / "atomic_draw_image_rect.frag.spv",
+        riveSpirvPath / "atomic_draw_image_rect.fixedcolor_frag.spv",
+        riveSpirvPath / "atomic_draw_image_mesh.vert.spv",
+        riveSpirvPath / "atomic_draw_image_mesh.frag.spv",
+        riveSpirvPath / "atomic_draw_image_mesh.fixedcolor_frag.spv",
+        riveSpirvPath / "atomic_resolve.vert.spv",
+        riveSpirvPath / "atomic_resolve.frag.spv",
+        riveSpirvPath / "atomic_resolve.fixedcolor_frag.spv",
+        riveSpirvPath / "atomic_resolve_coalesced.vert.spv",
+        riveSpirvPath / "atomic_resolve_coalesced.frag.spv",
 
 #ifndef RIVE_ANDROID
-        riveSpirvPath / "draw_clockwise_path.vert.spirv",
-        riveSpirvPath / "draw_clockwise_path.frag.spirv",
-        riveSpirvPath / "draw_clockwise_path.fixedcolor_frag.spirv",
-        riveSpirvPath / "draw_clockwise_clip.frag.spirv",
-        riveSpirvPath / "draw_clockwise_clip.fixedcolor_frag.spirv",
-        riveSpirvPath / "draw_clockwise_interior_triangles.vert.spirv",
-        riveSpirvPath / "draw_clockwise_interior_triangles.frag.spirv",
+        riveSpirvPath / "draw_clockwise_path.vert.spv",
+        riveSpirvPath / "draw_clockwise_path.frag.spv",
+        riveSpirvPath / "draw_clockwise_path.fixedcolor_frag.spv",
+        riveSpirvPath / "draw_clockwise_clip.frag.spv",
+        riveSpirvPath / "draw_clockwise_clip.fixedcolor_frag.spv",
+        riveSpirvPath / "draw_clockwise_interior_triangles.vert.spv",
+        riveSpirvPath / "draw_clockwise_interior_triangles.frag.spv",
+        riveSpirvPath / "draw_clockwise_interior_triangles.fixedcolor_frag.spv",
+        riveSpirvPath / "draw_clockwise_clip_interior_triangles.frag.spv",
         riveSpirvPath /
-            "draw_clockwise_interior_triangles.fixedcolor_frag.spirv",
-        riveSpirvPath / "draw_clockwise_clip_interior_triangles.frag.spirv",
-        riveSpirvPath /
-            "draw_clockwise_clip_interior_triangles.fixedcolor_frag.spirv",
-        riveSpirvPath / "draw_clockwise_atlas_blit.vert.spirv",
-        riveSpirvPath / "draw_clockwise_atlas_blit.frag.spirv",
-        riveSpirvPath / "draw_clockwise_atlas_blit.fixedcolor_frag.spirv",
-        riveSpirvPath / "draw_clockwise_image_mesh.vert.spirv",
-        riveSpirvPath / "draw_clockwise_image_mesh.frag.spirv",
-        riveSpirvPath / "draw_clockwise_image_mesh.fixedcolor_frag.spirv",
+            "draw_clockwise_clip_interior_triangles.fixedcolor_frag.spv",
+        riveSpirvPath / "draw_clockwise_atlas_blit.vert.spv",
+        riveSpirvPath / "draw_clockwise_atlas_blit.frag.spv",
+        riveSpirvPath / "draw_clockwise_atlas_blit.fixedcolor_frag.spv",
+        riveSpirvPath / "draw_clockwise_image_mesh.vert.spv",
+        riveSpirvPath / "draw_clockwise_image_mesh.frag.spv",
+        riveSpirvPath / "draw_clockwise_image_mesh.fixedcolor_frag.spv",
 #endif
 
-        riveSpirvPath / "draw_clockwise_atomic_path.vert.spirv",
-        riveSpirvPath / "draw_clockwise_atomic_path.frag.spirv",
-        riveSpirvPath / "draw_clockwise_atomic_path.fixedcolor_frag.spirv",
-        riveSpirvPath / "draw_clockwise_atomic_clip.frag.spirv",
-        riveSpirvPath / "draw_clockwise_atomic_clip.fixedcolor_frag.spirv",
-        riveSpirvPath / "draw_clockwise_atomic_borrowed_coverage.frag.spirv",
-        riveSpirvPath / "draw_clockwise_atomic_interior_triangles.vert.spirv",
-        riveSpirvPath / "draw_clockwise_atomic_interior_triangles.frag.spirv",
+        riveSpirvPath / "draw_clockwise_atomic_path.vert.spv",
+        riveSpirvPath / "draw_clockwise_atomic_path.frag.spv",
+        riveSpirvPath / "draw_clockwise_atomic_path.fixedcolor_frag.spv",
+        riveSpirvPath / "draw_clockwise_atomic_clip.frag.spv",
+        riveSpirvPath / "draw_clockwise_atomic_clip.fixedcolor_frag.spv",
+        riveSpirvPath / "draw_clockwise_atomic_borrowed_coverage.frag.spv",
+        riveSpirvPath / "draw_clockwise_atomic_interior_triangles.vert.spv",
+        riveSpirvPath / "draw_clockwise_atomic_interior_triangles.frag.spv",
         riveSpirvPath /
-            "draw_clockwise_atomic_interior_triangles.fixedcolor_frag.spirv",
+            "draw_clockwise_atomic_interior_triangles.fixedcolor_frag.spv",
         riveSpirvPath /
-            "draw_clockwise_atomic_clip_interior_triangles.frag.spirv",
+            "draw_clockwise_atomic_clip_interior_triangles.frag.spv",
         riveSpirvPath /
-            "draw_clockwise_atomic_clip_interior_triangles.fixedcolor_frag.spirv",
+            "draw_clockwise_atomic_clip_interior_triangles.fixedcolor_frag.spv",
         riveSpirvPath /
-            "draw_clockwise_atomic_borrowed_coverage_interior_triangles.frag.spirv",
-        riveSpirvPath / "clear_clockwise_atomic_clip.vert.spirv",
-        riveSpirvPath / "clear_clockwise_atomic_clip.frag.spirv",
-        riveSpirvPath / "clear_clockwise_atomic_clip.fixedcolor_frag.spirv",
-        riveSpirvPath / "draw_clockwise_atomic_atlas_blit.vert.spirv",
-        riveSpirvPath / "draw_clockwise_atomic_atlas_blit.frag.spirv",
-        riveSpirvPath /
-            "draw_clockwise_atomic_atlas_blit.fixedcolor_frag.spirv",
-        riveSpirvPath / "draw_clockwise_atomic_image_mesh.vert.spirv",
-        riveSpirvPath / "draw_clockwise_atomic_image_mesh.frag.spirv",
-        riveSpirvPath /
-            "draw_clockwise_atomic_image_mesh.fixedcolor_frag.spirv",
-        riveSpirvPath / "init_clockwise_atomic_workaround.frag.spirv",
-        riveSpirvPath /
-            "init_clockwise_atomic_workaround.fixedcolor_frag.spirv",
+            "draw_clockwise_atomic_borrowed_coverage_interior_triangles.frag.spv",
+        riveSpirvPath / "clear_clockwise_atomic_clip.vert.spv",
+        riveSpirvPath / "clear_clockwise_atomic_clip.frag.spv",
+        riveSpirvPath / "clear_clockwise_atomic_clip.fixedcolor_frag.spv",
+        riveSpirvPath / "draw_clockwise_atomic_atlas_blit.vert.spv",
+        riveSpirvPath / "draw_clockwise_atomic_atlas_blit.frag.spv",
+        riveSpirvPath / "draw_clockwise_atomic_atlas_blit.fixedcolor_frag.spv",
+        riveSpirvPath / "draw_clockwise_atomic_image_mesh.vert.spv",
+        riveSpirvPath / "draw_clockwise_atomic_image_mesh.frag.spv",
+        riveSpirvPath / "draw_clockwise_atomic_image_mesh.fixedcolor_frag.spv",
+        riveSpirvPath / "init_clockwise_atomic_workaround.frag.spv",
+        riveSpirvPath / "init_clockwise_atomic_workaround.fixedcolor_frag.spv",
 
-        riveSpirvPath / "draw_msaa_path.vert.spirv",
-        riveSpirvPath / "draw_msaa_path.noclipdistance_vert.spirv",
-        riveSpirvPath / "draw_msaa_path.frag.spirv",
-        riveSpirvPath / "draw_msaa_path.fixedcolor_frag.spirv",
-        riveSpirvPath / "draw_msaa_stencil.vert.spirv",
-        riveSpirvPath / "draw_msaa_stencil.frag.spirv",
-        riveSpirvPath / "draw_msaa_stencil.fixedcolor_frag.spirv",
-        riveSpirvPath / "draw_msaa_atlas_blit.vert.spirv",
-        riveSpirvPath / "draw_msaa_atlas_blit.noclipdistance_vert.spirv",
-        riveSpirvPath / "draw_msaa_atlas_blit.frag.spirv",
-        riveSpirvPath / "draw_msaa_atlas_blit.fixedcolor_frag.spirv",
-        riveSpirvPath / "draw_msaa_image_mesh.vert.spirv",
-        riveSpirvPath / "draw_msaa_image_mesh.noclipdistance_vert.spirv",
-        riveSpirvPath / "draw_msaa_image_mesh.frag.spirv",
-        riveSpirvPath / "draw_msaa_image_mesh.fixedcolor_frag.spirv",
-        riveSpirvPath / "draw_fullscreen_quad.vert.spirv",
-        riveSpirvPath / "draw_input_attachment.frag.spirv",
-        riveSpirvPath / "draw_msaa_color_seed_attachment.frag.spirv",
-        riveSpirvPath / "draw_msaa_resolve.frag.spirv",
+        riveSpirvPath / "draw_msaa_path.vert.spv",
+        riveSpirvPath / "draw_msaa_path.noclipdistance_vert.spv",
+        riveSpirvPath / "draw_msaa_path.frag.spv",
+        riveSpirvPath / "draw_msaa_path.fixedcolor_frag.spv",
+        riveSpirvPath / "draw_msaa_stencil.vert.spv",
+        riveSpirvPath / "draw_msaa_stencil.frag.spv",
+        riveSpirvPath / "draw_msaa_stencil.fixedcolor_frag.spv",
+        riveSpirvPath / "draw_msaa_atlas_blit.vert.spv",
+        riveSpirvPath / "draw_msaa_atlas_blit.noclipdistance_vert.spv",
+        riveSpirvPath / "draw_msaa_atlas_blit.frag.spv",
+        riveSpirvPath / "draw_msaa_atlas_blit.fixedcolor_frag.spv",
+        riveSpirvPath / "draw_msaa_image_mesh.vert.spv",
+        riveSpirvPath / "draw_msaa_image_mesh.noclipdistance_vert.spv",
+        riveSpirvPath / "draw_msaa_image_mesh.frag.spv",
+        riveSpirvPath / "draw_msaa_image_mesh.fixedcolor_frag.spv",
+        riveSpirvPath / "draw_fullscreen_quad.vert.spv",
+        riveSpirvPath / "draw_input_attachment.frag.spv",
+        riveSpirvPath / "draw_msaa_color_seed_attachment.frag.spv",
+        riveSpirvPath / "draw_msaa_resolve.frag.spv",
     };
     constexpr size_t numFiles = std::size(spirvFileNames);
 
diff --git a/renderer/src/shaders/Makefile b/renderer/src/shaders/Makefile
index 9634c38..3b3e4fa 100644
--- a/renderer/src/shaders/Makefile
+++ b/renderer/src/shaders/Makefile
@@ -322,18 +322,18 @@
 ## Usage: $(eval $(call spirv_list_rule, INPUT_FILENAME, OUTPUT_TYPE [, ADDITIONAL_COMPILE_OPTIONS]))
 ##   Where OUTPUT_TYPE is, say, "vert" or "frag" or "fixedcolor_frag", etc
 define spirv_list_rule
-  $(spirv_out_filename_no_ext).spirv: $1 $(MINIFY_STAMP) | $(OUT)/spirv/.
+  $(spirv_out_filename_no_ext).spv: $1 $(MINIFY_STAMP) | $(OUT)/spirv/.
 	@glslangValidator -S $(spirv_type) -DTARGET_SPIRV \
 		$(if $(spirv_is_vert), -DVERTEX, -DFRAGMENT $(spirv_frag_params)) \
-		-I$(OUT)  -V $3 -o $(spirv_out_filename_no_ext).spirv.unoptimized $1
+		-I$(OUT)  -V $3 -o $(spirv_out_filename_no_ext).spv.unoptimized $1
 	@spirv-opt --preserve-bindings --preserve-interface $(spirv_opt_params) \
-		$(spirv_out_filename_no_ext).spirv.unoptimized -o $(spirv_out_filename_no_ext).spirv
-	@rm $(spirv_out_filename_no_ext).spirv.unoptimized
+		$(spirv_out_filename_no_ext).spv.unoptimized -o $(spirv_out_filename_no_ext).spv
+	@rm $(spirv_out_filename_no_ext).spv.unoptimized
 
-  $(spirv_out_filename_no_ext).h: $(spirv_out_filename_no_ext).spirv
-	@python3 spirv_binary_to_header.py $(spirv_out_filename_no_ext).spirv $(spirv_out_filename_no_ext).h $(subst $(suffix $1),_$2,$(notdir $1))
+  $(spirv_out_filename_no_ext).h: $(spirv_out_filename_no_ext).spv
+	@python3 spirv_binary_to_header.py $(spirv_out_filename_no_ext).spv $(spirv_out_filename_no_ext).h $(subst $(suffix $1),_$2,$(notdir $1))
 
-  SPIRV_OUTPUTS_BINARY += $(spirv_out_filename_no_ext).spirv
+  SPIRV_OUTPUTS_BINARY += $(spirv_out_filename_no_ext).spv
   SPIRV_OUTPUTS_HEADERS += $(spirv_out_filename_no_ext).h
 endef
 
@@ -352,7 +352,7 @@
 ## All .main/vert/frag files should build
 $(eval $(call make_spirv_rules, $(SPIRV_STANDARD_INPUTS), vert frag))
 
-SPIRV_COMMON_WEBGPU_PARAMS = -DSPEC_CONST_NONE -DUSE_WEBGPU_SAMPLERS
+SPIRV_COMMON_WEBGPU_PARAMS = -DUSE_WEBGPU_SAMPLERS
 
 ## Each of the specialized SPIRV lists have their own associated rules
 $(eval $(call make_spirv_rules, $(SPIRV_FIXEDCOLOR_FRAG_INPUTS), fixedcolor_frag, -DFIXED_FUNCTION_COLOR_OUTPUT))
@@ -368,6 +368,57 @@
 spirv: $(SPIRV_OUTPUTS_HEADERS)
 spirv-binary: $(SPIRV_OUTPUTS_BINARY)
 
+## WGSL compilation. Translates WebGPU-flavored SPIR-V binaries to WGSL using
+## naga. Some Vulkan-flavored SPIR-V files aren't compatible with WebGPU so we
+## filter to the webgpu_* variants only — plus a hand-curated list of standard
+## variants that translate cleanly (e.g., shaders without combined samplers).
+$(OUT)/wgsl/.: | $(OUT)/.
+	@mkdir -p $@
+
+WGSL_OUTPUTS := \
+    $(patsubst $(OUT)/spirv/%.spv,$(OUT)/wgsl/%.wgsl, \
+        $(filter %.webgpu_vert.spv \
+                 %.webgpu_noclipdistance_vert.spv \
+                 %.webgpu_frag.spv \
+                 %.webgpu_fixedcolor_frag.spv, \
+                 $(SPIRV_OUTPUTS_BINARY))) \
+    $(OUT)/wgsl/draw_msaa_stencil.vert.wgsl \
+    $(OUT)/wgsl/draw_msaa_stencil.frag.wgsl \
+    $(OUT)/wgsl/color_ramp.vert.wgsl \
+    $(OUT)/wgsl/color_ramp.frag.wgsl
+
+## Filter naga's noisy "Unknown decoration RelaxedPrecision" warning — WGSL has
+## no precision qualifiers, so naga always drops it. bash with pipefail ensures
+## a real naga failure still fails the build (pipeline exit status reflects
+## naga's, not grep's). The trailing "[ $$? = 1 ]" absorbs grep's "no matches"
+## exit code on clean runs where naga emitted nothing.
+
+## TERM=dumb forces a terminfo entry that always exists. CI sometimes sets
+## TERM=unknown, which makes naga's terminal-detection code (ncurses-backed)
+## abort with "Error opening terminal: unknown" before it can translate.
+
+## --keep-coordinate-space disables naga's default Y-flip on gl_Position. naga
+## assumes Vulkan-flavored SPIR-V (Y-down NDC) and flips to OpenGL/ WebGPU's Y-up
+## NDC. Our GLSL is already authored for Y-up — gpu.cpp sets
+## renderTargetInverseViewportY negative so the math produces WebGPU clip coords
+## directly — and the extra flip would render upside down (Dawn's SPIR-V path
+## didn't apply it either).
+$(OUT)/wgsl/%.wgsl: $(OUT)/spirv/%.spv | $(OUT)/wgsl/.
+	@echo "wgsl/$*.wgsl"
+	@TERM=dumb bash -o pipefail -c 'naga --keep-coordinate-space "$<" "$@" 2>&1 | { grep -v "Unknown decoration RelaxedPrecision" || [ $$? = 1 ]; }'
+
+## Embed each .wgsl as a C++ raw string literal in a .hpp header that downstream
+## code can #include. The variable lives in the wgsl:: namespace and is named
+## after the basename with dots replaced by underscores (e.g.
+## wgsl::tessellate_webgpu_vert). wgsl_to_header.py minifies the source first
+## unless WGSL_FLAGS includes --raw.
+WGSL_HEADER_OUTPUTS := $(patsubst %.wgsl,%.hpp,$(WGSL_OUTPUTS))
+
+$(OUT)/wgsl/%.hpp: $(OUT)/wgsl/%.wgsl wgsl_to_header.py | $(OUT)/wgsl/.
+	@python3 wgsl_to_header.py $(WGSL_FLAGS) $< $@ $(subst .,_,$(basename $(notdir $<)))
+
+wgsl: $(WGSL_HEADER_OUTPUTS)
+
 ## d3d compilation.
 .PHONY: $(OUT)/d3d/render_atlas.frag.h
 
diff --git a/renderer/src/shaders/common.glsl b/renderer/src/shaders/common.glsl
index a406c4d..11d83f2 100644
--- a/renderer/src/shaders/common.glsl
+++ b/renderer/src/shaders/common.glsl
@@ -249,9 +249,9 @@
 // GL and Vulkan.
 INLINE half safe_clamp_for_mali(half x, half lo, half hi)
 {
-#if defined(@GL_RENDERER_MALI) || defined(@VULKAN_VENDOR_ID)
-#ifdef @VULKAN_VENDOR_ID
-    if (@VULKAN_VENDOR_ID == VULKAN_VENDOR_ARM)
+#if defined(@GL_RENDERER_MALI) || defined(@VULKAN_VENDOR_ARM)
+#ifdef @VULKAN_VENDOR_ARM
+    if (@VULKAN_VENDOR_ARM)
 #endif
     {
         if (x < hi)
@@ -262,7 +262,7 @@
         else
             return hi;
     }
-#endif // @GL_RENDERER_MALI || @VULKAN_VENDOR_ID
+#endif // @GL_RENDERER_MALI || @VULKAN_VENDOR_ARM
     return clamp(x, lo, hi);
 }
 
diff --git a/renderer/src/shaders/constants.glsl b/renderer/src/shaders/constants.glsl
index 3f8837d..0cea0a8 100644
--- a/renderer/src/shaders/constants.glsl
+++ b/renderer/src/shaders/constants.glsl
@@ -263,15 +263,6 @@
 #define BLEND_COLOR_VALID_BIT (1u << CLOCKWISE_COVERAGE_BIT_COUNT)
 #define CLOCKWISE_COVERAGE_PREFIX_ONE_VALUE (BLEND_COLOR_VALID_BIT << 1u)
 
-// Vendor IDs for driver workarounds.
-#define VULKAN_VENDOR_AMD 0x1002u
-#define VULKAN_VENDOR_IMG_TEC 0x1010u
-#define VULKAN_VENDOR_NVIDIA 0x10DEu
-#define VULKAN_VENDOR_ARM 0x13B5u
-#define VULKAN_VENDOR_QUALCOMM 0x5143u
-#define VULKAN_VENDOR_INTEL 0x8086u
-#define VULKAN_VENDOR_SAMSUNG 0x144d
-
 // Indices for SPIRV specialization constants (used in lieu of #defines in
 // Vulkan.)
 #define CLIPPING_SPECIALIZATION_IDX 0
@@ -285,7 +276,7 @@
 #define CLOCKWISE_FILL_SPECIALIZATION_IDX 8
 #define BORROWED_COVERAGE_PASS_SPECIALIZATION_IDX 9
 #define NESTED_CLIP_UPDATE_ONLY_IDX 10
-#define VULKAN_VENDOR_ID_SPECIALIZATION_IDX 11
+#define VULKAN_VENDOR_ARM_SPECIALIZATION_IDX 11
 #define SPECIALIZATION_COUNT 12
 
 // When rendering to an r32i feather atlas, use 16:16 fixed point.
diff --git a/renderer/src/shaders/draw_msaa_object.frag b/renderer/src/shaders/draw_msaa_object.frag
index 8df178e..953ec32 100644
--- a/renderer/src/shaders/draw_msaa_object.frag
+++ b/renderer/src/shaders/draw_msaa_object.frag
@@ -72,14 +72,6 @@
     // finish the the the alpha portion of the blend mode.
     color.rgb *= color.a;
     // clang-format off
-#elif defined(@SPEC_CONST_NONE) && defined(@FIXED_FUNCTION_COLOR_OUTPUT) && !defined(@DRAW_IMAGE_MESH)
-    // clang-format on
-    // in WebGPU with no specialization constants (when SPEC_CONST_NONE) is
-    // true), ENABLE_ADVANCED_BLEND is always set to true, so the vertex
-    // shader will not premultiply the color (Except with image meshes, where
-    // it's always premultiplied). Premultiply it now to get the correct color
-    // for srcOver blending.
-    color.rgb *= color.a;
 #endif
 
     // Certain platforms give us less control of the format of what we are
diff --git a/renderer/src/shaders/draw_path.vert b/renderer/src/shaders/draw_path.vert
index 211c0c3..224bdc5 100644
--- a/renderer/src/shaders/draw_path.vert
+++ b/renderer/src/shaders/draw_path.vert
@@ -2,23 +2,23 @@
  * Copyright 2022 Rive
  */
 
-// undef GENERATE_PREMULTIPLIED_PAINT_COLORS first because this file gets
+// undef GENERATE_UNMULTIPLIED_PAINT_COLORS first because this file gets
 // included multiple times with different defines in the Metal library.
-#undef GENERATE_PREMULTIPLIED_PAINT_COLORS
+#undef GENERATE_UNMULTIPLIED_PAINT_COLORS
 
 #ifdef @NEVER_GENERATE_PREMULTIPLIED_PAINT_COLORS
 // The specific fragment shader we're being compiled for expects un-multiplied
 // paint colors all the time.
-#define GENERATE_PREMULTIPLIED_PAINT_COLORS false
+#define GENERATE_UNMULTIPLIED_PAINT_COLORS true
 #elif defined(@ENABLE_ADVANCED_BLEND)
 // If advanced blend is enabled, we generate unmultiplied paint colors in the
 // shader. Otherwise we would have to just turn around and unmultiply them in
 // order to run the blend equation.
-#define GENERATE_PREMULTIPLIED_PAINT_COLORS !@ENABLE_ADVANCED_BLEND
+#define GENERATE_UNMULTIPLIED_PAINT_COLORS @ENABLE_ADVANCED_BLEND
 #else
 // As long as advanced blend is not enabled, it's more efficient for the shader
 // to generate premultiplied paint colors from the start.
-#define GENERATE_PREMULTIPLIED_PAINT_COLORS true
+#define GENERATE_UNMULTIPLIED_PAINT_COLORS false
 #endif
 
 // undef COVERAGE_TYPE first because this file gets included multiple times with
@@ -241,8 +241,16 @@
     if (paintType == SOLID_COLOR_PAINT_TYPE)
     {
         half4 color = unpackUnorm4x8(paintData.y);
-        if (GENERATE_PREMULTIPLIED_PAINT_COLORS)
+        if (GENERATE_UNMULTIPLIED_PAINT_COLORS)
+        {
+            // naga can't handle "if (!SpecConst)" when transpiling spv to wgsl.
+            // Use this if -> else construct instead so we don't have to negate
+            // a specialization constant.
+        }
+        else
+        {
             color.rgb *= color.a;
+        }
         v_paint = float4(color);
     }
 #if defined(@ENABLE_CLIPPING) && !defined(@ATLAS_BLIT)
@@ -384,12 +392,12 @@
     if (paint.a >= .0) // Is the paint a solid color?
     {
         // The vertex shader will have premultiplied 'paint' (or not) based on
-        // GENERATE_PREMULTIPLIED_PAINT_COLORS.
+        // GENERATE_UNMULTIPLIED_PAINT_COLORS.
         color = cast_float4_to_half4(paint);
-        if (GENERATE_PREMULTIPLIED_PAINT_COLORS)
-            color *= coverage;
-        else
+        if (GENERATE_UNMULTIPLIED_PAINT_COLORS)
             color.a *= coverage;
+        else
+            color *= coverage;
     }
     else if (paint.a > -1.) // Is paint is a gradient (linear or radial)?
     {
@@ -409,8 +417,16 @@
         color.a *= coverage;
         // Gradients are always unmultiplied so we don't lose color data while
         // doing the hardware filter.
-        if (GENERATE_PREMULTIPLIED_PAINT_COLORS)
+        if (GENERATE_UNMULTIPLIED_PAINT_COLORS)
+        {
+            // naga can't handle "if (!SpecConst)" when transpiling spv to wgsl.
+            // Use this if -> else construct instead so we don't have to
+            // negate a specialization constant.
+        }
+        else
+        {
             color.rgb *= color.a;
+        }
     }
     else // The paint is an image.
     {
@@ -422,10 +438,10 @@
         half opacity = paint.b * coverage;
         // Images are always premultiplied so the (transparent) background color
         // doesn't bleed into the edges during the hardware filter.
-        if (GENERATE_PREMULTIPLIED_PAINT_COLORS)
-            color *= opacity;
-        else
+        if (GENERATE_UNMULTIPLIED_PAINT_COLORS)
             color = make_half4(unmultiply_rgb(color), color.a * opacity);
+        else
+            color *= opacity;
     }
     return color;
 }
diff --git a/renderer/src/shaders/specialization.glsl b/renderer/src/shaders/specialization.glsl
index b53e6f7..32154f0 100644
--- a/renderer/src/shaders/specialization.glsl
+++ b/renderer/src/shaders/specialization.glsl
@@ -1,56 +1,37 @@
-#ifndef @SPEC_CONST_NONE
-
 layout(constant_id = CLIPPING_SPECIALIZATION_IDX) const
-    bool kEnableClipping = true;
+    bool EnableClipping = true;
 layout(constant_id = CLIP_RECT_SPECIALIZATION_IDX) const
-    bool kEnableClipRect = true;
+    bool EnableClipRect = true;
 layout(constant_id = ADVANCED_BLEND_SPECIALIZATION_IDX) const
-    bool kEnableAdvancedBlend = true;
+    bool EnableAdvancedBlend = true;
 layout(constant_id = FEATHER_SPECIALIZATION_IDX) const
-    bool kEnableFeather = true;
+    bool EnableFeather = true;
 layout(constant_id = EVEN_ODD_SPECIALIZATION_IDX) const
-    bool kEnableEvenOdd = true;
+    bool EnableEvenOdd = true;
 layout(constant_id = NESTED_CLIPPING_SPECIALIZATION_IDX) const
-    bool kEnableNestedClipping = true;
+    bool EnableNestedClipping = true;
 layout(constant_id = HSL_BLEND_MODES_SPECIALIZATION_IDX) const
-    bool kEnableHSLBlendModes = true;
-layout(constant_id = DITHER_SPECIALIZATION_IDX) const bool kEnableDither = true;
+    bool EnableHSLBlendModes = true;
+layout(constant_id = DITHER_SPECIALIZATION_IDX) const bool EnableDither = true;
 layout(constant_id = CLOCKWISE_FILL_SPECIALIZATION_IDX) const
-    bool kClockwiseFill = true;
+    bool ClockwiseFill = true;
 layout(constant_id = BORROWED_COVERAGE_PASS_SPECIALIZATION_IDX) const
-    bool kBorrowedCoveragePrepass = true;
+    bool BorrowedCoveragePrepass = false;
 layout(constant_id = NESTED_CLIP_UPDATE_ONLY_IDX) const
-    bool kNestedClipUpdateOnly = true;
-layout(constant_id = VULKAN_VENDOR_ID_SPECIALIZATION_IDX) const uint
-    kVulkanVendorID = 0;
+    bool NestedClipUpdateOnly = false;
+layout(constant_id = VULKAN_VENDOR_ARM_SPECIALIZATION_IDX) const
+    bool VulkanVendorARM = false;
 
-#define @ENABLE_CLIPPING kEnableClipping
-#define @ENABLE_CLIP_RECT kEnableClipRect
-#define @ENABLE_ADVANCED_BLEND kEnableAdvancedBlend
-#define @ENABLE_FEATHER kEnableFeather
-#define @ENABLE_EVEN_ODD kEnableEvenOdd
-#define @ENABLE_NESTED_CLIPPING kEnableNestedClipping
-#define @ENABLE_HSL_BLEND_MODES kEnableHSLBlendModes
-#define @ENABLE_DITHER kEnableDither
-#define @CLOCKWISE_FILL kClockwiseFill
-#define @BORROWED_COVERAGE_PASS kBorrowedCoveragePrepass
-#define @NESTED_CLIP_UPDATE_ONLY kNestedClipUpdateOnly
-#define @VULKAN_VENDOR_ID kVulkanVendorID
-
-#else
-
-// Specialization constants aren't supported; just compile an ubershader.
-#define @ENABLE_CLIPPING true
-#define @ENABLE_CLIP_RECT true
-#define @ENABLE_ADVANCED_BLEND true
-#define @ENABLE_FEATHER true
-#define @ENABLE_EVEN_ODD true
-#define @ENABLE_NESTED_CLIPPING true
-#define @ENABLE_HSL_BLEND_MODES true
-#define @ENABLE_DITHER true
-#define @CLOCKWISE_FILL true
-#define @BORROWED_COVERAGE_PASS false
-#define @NESTED_CLIP_UPDATE_ONLY false
-#define @VULKAN_VENDOR_ID 0
-
-#endif
+#define @ENABLE_CLIPPING EnableClipping
+#define @ENABLE_CLIP_RECT EnableClipRect
+#define @ENABLE_ADVANCED_BLEND EnableAdvancedBlend
+#define @DISABLE_ADVANCED_BLEND DisableAdvancedBlend
+#define @ENABLE_FEATHER EnableFeather
+#define @ENABLE_EVEN_ODD EnableEvenOdd
+#define @ENABLE_NESTED_CLIPPING EnableNestedClipping
+#define @ENABLE_HSL_BLEND_MODES EnableHSLBlendModes
+#define @ENABLE_DITHER EnableDither
+#define @CLOCKWISE_FILL ClockwiseFill
+#define @BORROWED_COVERAGE_PASS BorrowedCoveragePrepass
+#define @NESTED_CLIP_UPDATE_ONLY NestedClipUpdateOnly
+#define @VULKAN_VENDOR_ARM VulkanVendorARM
diff --git a/renderer/src/shaders/wgsl_to_header.py b/renderer/src/shaders/wgsl_to_header.py
new file mode 100644
index 0000000..00a1bb3
--- /dev/null
+++ b/renderer/src/shaders/wgsl_to_header.py
@@ -0,0 +1,177 @@
+# Embed a WGSL source file as a C++ string literal in a header file, plus emit a
+# per-specialization-index bool array showing which specialization constants
+# survived naga's reachability pass. The C++ side iterates the array to set only
+# overrides actually present in the shader (WebGPU doesn't allow overrides that
+# aren't reachable from the main entry point, so a fixed all-true list would
+# fail validation).
+#
+# By default, the WGSL source is minified (whitespace collapsed and naga's
+# auto-generated locals shortened). Pass --raw to leave the source untouched,
+# used when the build sets --raw_shaders.
+import argparse
+import os
+import re
+import sys
+
+# Alphabet used to generate short replacement names for naga's auto-generated
+# variables. The only character we have to exclude is `_` itself, since WGSL
+# reserves identifiers that begin with `__`.
+SAFE_NAME_CHARS = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"
+
+parser = argparse.ArgumentParser()
+parser.add_argument("input")
+parser.add_argument("output")
+parser.add_argument("variable_name")
+parser.add_argument(
+    "--raw",
+    action="store_true",
+    help="don't minify the WGSL source",
+)
+args = parser.parse_args()
+
+inPath = args.input
+outPath = args.output
+variableName = args.variable_name
+
+# Label is the .wgsl filename minus the extension (e.g., "color_ramp.vert").
+# Used as the WGPUShaderModuleDescriptor.label so WebGPU names the module in
+# its error messages.
+label = os.path.basename(inPath)
+if label.endswith(".wgsl"):
+    label = label[: -len(".wgsl")]
+
+# Pull SPECIALIZATION_COUNT from the sibling constants.glsl so the emitted
+# array length tracks the canonical value automatically.
+scriptDir = os.path.dirname(os.path.abspath(__file__))
+with open(os.path.join(scriptDir, "constants.glsl"), "r", encoding="utf-8") as f:
+    constantsSrc = f.read()
+countMatch = re.search(
+    r"^\s*#define\s+SPECIALIZATION_COUNT\s+(\d+)", constantsSrc, re.M
+)
+if not countMatch:
+    sys.stderr.write("ERROR: could not find SPECIALIZATION_COUNT in constants.glsl\n")
+    sys.exit(1)
+specializationCount = int(countMatch.group(1))
+
+with open(inPath, "r", encoding="utf-8") as f:
+    wgsl = f.read()
+
+# Minify the wgsl, unless otherwise specified.
+# NOTE: This could have ideally been done with wgsl-minifier, but it doesn't
+# support "enable clip_distances", so we roll out our own basic minifier.
+if not args.raw:
+    # Strip indentation and blank lines, then join with one space so adjacent
+    # identifiers/keywords don't merge across the original line break.
+    minified = []
+    for line in wgsl.splitlines():
+        line = line.strip()
+        if line:
+            minified.append(line)
+    wgsl = " ".join(minified)
+
+    # Drop whitespace around punctuation. `(` and `)` are deliberately excluded;
+    # stripping them broke golden tests, likely because of WGSL's template-list
+    # disambiguation interacting with adjacent `>(`.
+    wgsl = re.sub(r"\s*([;:=,{}\[\]@~+\-*/<>&|^%!])\s*", r"\1", wgsl)
+
+    # Rename naga's auto-generated variables to shorter forms. Pattern-based so
+    # we only touch names that naga reliably generates — never builtins, etc.
+    nagaPattern = re.compile(
+        r"\b(?:_e\d+|local(?:_\d+)?|phi_\d+_|unnamed|main_\d+|_naga_\w+|gl_\w+)\b"
+    )
+    nagaNames = set(nagaPattern.findall(wgsl))
+    counts = {
+        n: len(re.findall(r"\b" + re.escape(n) + r"\b", wgsl))
+        for n in nagaNames
+    }
+
+    def shortName(idx):
+        # Bijective base-62 over `SAFE_NAME_CHARS`: idx 0..61 → _a.._9,
+        # 62..3905 → _aa.._99, 3906.. → _aaa.., growing one char at a time
+        # forever. Subtracting 1 each iteration is what makes it bijective —
+        # in regular base-N, leading 'zeros' would be ambiguous (1, 01, 001
+        # all mean the same number), and we'd never reach strings like `aa`.
+        out = ""
+        idx += 1
+        while idx > 0:
+            idx -= 1
+            out = SAFE_NAME_CHARS[idx % len(SAFE_NAME_CHARS)] + out
+            idx //= len(SAFE_NAME_CHARS)
+        return "_" + out
+
+    mapping = {}
+    shortIdx = 0
+    for name in sorted(nagaNames, key=lambda n: -counts[n]):
+        candidate = shortName(shortIdx)
+        if len(candidate) >= len(name):
+            # Skip — wouldn't actually shrink. Don't burn an idx slot.
+            continue
+        mapping[name] = candidate
+        shortIdx += 1
+    if mapping:
+        renamePattern = re.compile(
+            r"\b(" + "|".join(re.escape(n) for n in mapping) + r")\b"
+        )
+        wgsl = renamePattern.sub(lambda m: mapping[m.group(0)], wgsl)
+
+# Match "@id(N) override <Name>: <type> = <default>;" — any override that
+# made it into the WGSL output. The numeric @id matches the specialization idx
+# used by the Vulkan side, so the C++ array can be indexed by it directly.
+usedIndices = {
+    int(m.group(1))
+    for m in re.finditer(r"@id\((\d+)\)\s+override\s+\w+\s*:", wgsl)
+}
+for idx in usedIndices:
+    if idx >= specializationCount:
+        sys.stderr.write(
+            f"ERROR: WGSL '{label}' uses @id({idx}), out of range for "
+            f"SPECIALIZATION_COUNT={specializationCount}\n"
+        )
+        sys.exit(1)
+
+# Use a raw string literal so we don't have to escape anything. Bail out if
+# the chosen delimiter happens to appear in the source — extremely unlikely
+# for valid WGSL, but worth catching to avoid silently corrupting the embed.
+delimiter = "WGSL"
+if f'){delimiter}"' in wgsl:
+    sys.stderr.write(
+        f'ERROR: WGSL source contains the raw-string terminator "){delimiter}\\"".\n'
+    )
+    sys.exit(1)
+
+with open(outPath, "w", encoding="utf-8") as f:
+    f.write("#pragma once\n\n")
+    f.write("#include <array>\n\n")
+    # SPECIALIZATION_COUNT lives in constants.glsl. Including it here makes
+    # the generated header self-contained.
+    f.write('#include "shaders/constants.glsl"\n\n')
+    f.write("namespace rive::gpu::wgsl\n")
+    f.write("{\n")
+
+    # The shared Shader type, repeated in every generated header behind an
+    # #ifndef guard so every translation unit sees a single definition. Per
+    # the C++ ODR, repeating the same struct definition across TUs is fine
+    # as long as the tokens are identical — which they are, since they all
+    # come from this script.
+    f.write("#ifndef RIVE_WGSL_SHADER_DEFINED\n")
+    f.write("#define RIVE_WGSL_SHADER_DEFINED\n")
+    f.write("struct Shader\n")
+    f.write("{\n")
+    f.write("    const char* source;\n")
+    f.write("    std::array<bool, SPECIALIZATION_COUNT> usedOverrides;\n")
+    f.write("    const char* label;\n")
+    f.write("};\n")
+    f.write("#endif\n\n")
+
+    f.write(f"inline constexpr Shader {variableName} = {{\n")
+    f.write(f'    .source = R"{delimiter}(\n')
+    f.write(wgsl)
+    f.write(f'){delimiter}",\n')
+    # Same length for every shader; entry i is true iff the WGSL declares
+    # @id(i). The inner braces wrap the std::array's underlying C array.
+    flags = ["true" if i in usedIndices else "false" for i in range(specializationCount)]
+    f.write("    .usedOverrides = {{" + ", ".join(flags) + "}},\n")
+    f.write(f'    .label = "{label}",\n')
+    f.write("};\n")
+
+    f.write("} // namespace wgsl\n")
diff --git a/renderer/src/vulkan/draw_pipeline_vulkan.cpp b/renderer/src/vulkan/draw_pipeline_vulkan.cpp
index f62d8a8..a95b6a4 100644
--- a/renderer/src/vulkan/draw_pipeline_vulkan.cpp
+++ b/renderer/src/vulkan/draw_pipeline_vulkan.cpp
@@ -289,7 +289,7 @@
                            gpu::ShaderMiscFlags::borrowedCoveragePass),
         enums::is_flag_set(props.shaderMiscFlags,
                            gpu::ShaderMiscFlags::nestedClipUpdateOnly),
-        pipelineManager->vendorID(),
+        pipelineManager->vendorID() == vkutil::vendors::ARM,
     };
     static_assert(CLIPPING_SPECIALIZATION_IDX == 0);
     static_assert(CLIP_RECT_SPECIALIZATION_IDX == 1);
@@ -302,7 +302,7 @@
     static_assert(CLOCKWISE_FILL_SPECIALIZATION_IDX == 8);
     static_assert(BORROWED_COVERAGE_PASS_SPECIALIZATION_IDX == 9);
     static_assert(NESTED_CLIP_UPDATE_ONLY_IDX == 10);
-    static_assert(VULKAN_VENDOR_ID_SPECIALIZATION_IDX == 11);
+    static_assert(VULKAN_VENDOR_ARM_SPECIALIZATION_IDX == 11);
     static_assert(SPECIALIZATION_COUNT == 12);
 
     VkSpecializationMapEntry permutationMapEntries[SPECIALIZATION_COUNT];
diff --git a/renderer/src/vulkan/render_context_vulkan_impl.cpp b/renderer/src/vulkan/render_context_vulkan_impl.cpp
index f56904c..1678a0c 100644
--- a/renderer/src/vulkan/render_context_vulkan_impl.cpp
+++ b/renderer/src/vulkan/render_context_vulkan_impl.cpp
@@ -824,23 +824,25 @@
     m_workarounds({
         .maxInstancesPerRenderPass =
             (m_vk->physicalDeviceProperties().apiVersion < VK_API_VERSION_1_3 &&
-             (m_vk->physicalDeviceProperties().vendorID == VULKAN_VENDOR_ARM ||
+             (m_vk->physicalDeviceProperties().vendorID ==
+                  vkutil::vendors::ARM ||
               m_vk->physicalDeviceProperties().vendorID ==
-                  VULKAN_VENDOR_IMG_TEC))
+                  vkutil::vendors::Imagination))
                 // Early Mali and PowerVR devices are known to crash when a
                 // single render pass is too complex.
                 ? (1u << 13) - 1u
                 : UINT32_MAX,
         // Early Xclipse drivers struggle with our manual msaa resolve, so we
         // always do automatic fullscreen resolves on that GPU family.
-        .avoidManualMSAAResolves =
-            m_vk->physicalDeviceProperties().vendorID == VULKAN_VENDOR_SAMSUNG,
+        .avoidManualMSAAResolves = m_vk->physicalDeviceProperties().vendorID ==
+                                   vkutil::vendors::Samsung,
         // Some Android drivers (some Android 12 and earlier Adreno drivers)
         // have issues with having both a self-dependency for dst reads and
         // resolve attachments. For now we just always manually resolve these
         // render passes that use advanced blend on Qualcomm.
         .needsManualMSAAResolveAfterDstRead =
-            m_vk->physicalDeviceProperties().vendorID == VULKAN_VENDOR_QUALCOMM,
+            m_vk->physicalDeviceProperties().vendorID ==
+            vkutil::vendors::Qualcomm,
     }),
     m_flushUniformBufferPool(m_vk, VK_BUFFER_USAGE_UNIFORM_BUFFER_BIT),
     m_imageDrawUniformBufferPool(m_vk, VK_BUFFER_USAGE_UNIFORM_BUFFER_BIT),
@@ -910,7 +912,7 @@
 
     switch (physicalDeviceProps.vendorID)
     {
-        case VULKAN_VENDOR_QUALCOMM:
+        case vkutil::vendors::Qualcomm:
             // Qualcomm advertises EXT_rasterization_order_attachment_access,
             // but it's slow. Use atomics instead on this platform.
             m_platformFeatures.supportsRasterOrderingMode = false;
@@ -924,7 +926,7 @@
             m_platformFeatures.pathIDGranularity = 2;
             break;
 
-        case VULKAN_VENDOR_ARM:
+        case vkutil::vendors::ARM:
             // Raster ordering is known to work on ARM hardware, even on old
             // drivers without EXT_rasterization_order_attachment_access, as
             // long as you define a subpass self-dependency.
@@ -932,7 +934,7 @@
                 !contextOptions.forceAtomicMode;
             break;
 
-        case VULKAN_VENDOR_IMG_TEC:
+        case vkutil::vendors::Imagination:
             // Raster ordering is known to work on IMG hardware, even without
             // EXT_rasterization_order_attachment_access, as long as you define
             // a subpass self-dependency.
@@ -3682,7 +3684,8 @@
         return nullptr;
     }
 
-    if (vk->physicalDeviceProperties().vendorID == VULKAN_VENDOR_IMG_TEC &&
+    if (vk->physicalDeviceProperties().vendorID ==
+            vkutil::vendors::Imagination &&
         vk->physicalDeviceProperties().apiVersion < VK_API_VERSION_1_3)
     {
         fprintf(
diff --git a/renderer/src/webgpu/render_context_webgpu_impl.cpp b/renderer/src/webgpu/render_context_webgpu_impl.cpp
index e8d39d1..b4be806 100644
--- a/renderer/src/webgpu/render_context_webgpu_impl.cpp
+++ b/renderer/src/webgpu/render_context_webgpu_impl.cpp
@@ -15,32 +15,29 @@
 #include <sstream>
 #include <string>
 
-namespace spirv
-{
-#include "generated/shaders/spirv/blit_texture_as_draw_filtered.webgpu_vert.h"
-#include "generated/shaders/spirv/blit_texture_as_draw_filtered.webgpu_frag.h"
-#include "generated/shaders/spirv/color_ramp.vert.h"
-#include "generated/shaders/spirv/color_ramp.frag.h"
-#include "generated/shaders/spirv/tessellate.webgpu_vert.h"
-#include "generated/shaders/spirv/tessellate.webgpu_frag.h"
-#include "generated/shaders/spirv/render_atlas.webgpu_vert.h"
-#include "generated/shaders/spirv/render_atlas_fill.webgpu_frag.h"
-#include "generated/shaders/spirv/render_atlas_stroke.webgpu_frag.h"
-#include "generated/shaders/spirv/draw_msaa_path.webgpu_vert.h"
-#include "generated/shaders/spirv/draw_msaa_path.webgpu_noclipdistance_vert.h"
-#include "generated/shaders/spirv/draw_msaa_path.webgpu_frag.h"
-#include "generated/shaders/spirv/draw_msaa_path.webgpu_fixedcolor_frag.h"
-#include "generated/shaders/spirv/draw_msaa_atlas_blit.webgpu_vert.h"
-#include "generated/shaders/spirv/draw_msaa_atlas_blit.webgpu_noclipdistance_vert.h"
-#include "generated/shaders/spirv/draw_msaa_atlas_blit.webgpu_frag.h"
-#include "generated/shaders/spirv/draw_msaa_atlas_blit.webgpu_fixedcolor_frag.h"
-#include "generated/shaders/spirv/draw_msaa_image_mesh.webgpu_vert.h"
-#include "generated/shaders/spirv/draw_msaa_image_mesh.webgpu_noclipdistance_vert.h"
-#include "generated/shaders/spirv/draw_msaa_image_mesh.webgpu_frag.h"
-#include "generated/shaders/spirv/draw_msaa_image_mesh.webgpu_fixedcolor_frag.h"
-#include "generated/shaders/spirv/draw_msaa_stencil.vert.h"
-#include "generated/shaders/spirv/draw_msaa_stencil.frag.h"
-} // namespace spirv
+#include "generated/shaders/wgsl/blit_texture_as_draw_filtered.webgpu_vert.hpp"
+#include "generated/shaders/wgsl/blit_texture_as_draw_filtered.webgpu_frag.hpp"
+#include "generated/shaders/wgsl/color_ramp.vert.hpp"
+#include "generated/shaders/wgsl/color_ramp.frag.hpp"
+#include "generated/shaders/wgsl/tessellate.webgpu_vert.hpp"
+#include "generated/shaders/wgsl/tessellate.webgpu_frag.hpp"
+#include "generated/shaders/wgsl/render_atlas.webgpu_vert.hpp"
+#include "generated/shaders/wgsl/render_atlas_fill.webgpu_frag.hpp"
+#include "generated/shaders/wgsl/render_atlas_stroke.webgpu_frag.hpp"
+#include "generated/shaders/wgsl/draw_msaa_path.webgpu_vert.hpp"
+#include "generated/shaders/wgsl/draw_msaa_path.webgpu_noclipdistance_vert.hpp"
+#include "generated/shaders/wgsl/draw_msaa_path.webgpu_frag.hpp"
+#include "generated/shaders/wgsl/draw_msaa_path.webgpu_fixedcolor_frag.hpp"
+#include "generated/shaders/wgsl/draw_msaa_atlas_blit.webgpu_vert.hpp"
+#include "generated/shaders/wgsl/draw_msaa_atlas_blit.webgpu_noclipdistance_vert.hpp"
+#include "generated/shaders/wgsl/draw_msaa_atlas_blit.webgpu_frag.hpp"
+#include "generated/shaders/wgsl/draw_msaa_atlas_blit.webgpu_fixedcolor_frag.hpp"
+#include "generated/shaders/wgsl/draw_msaa_image_mesh.webgpu_vert.hpp"
+#include "generated/shaders/wgsl/draw_msaa_image_mesh.webgpu_noclipdistance_vert.hpp"
+#include "generated/shaders/wgsl/draw_msaa_image_mesh.webgpu_frag.hpp"
+#include "generated/shaders/wgsl/draw_msaa_image_mesh.webgpu_fixedcolor_frag.hpp"
+#include "generated/shaders/wgsl/draw_msaa_stencil.vert.hpp"
+#include "generated/shaders/wgsl/draw_msaa_stencil.frag.hpp"
 
 #ifdef RIVE_DAWN
 #include <dawn/webgpu_cpp.h>
@@ -61,7 +58,7 @@
 using TexelCopyBufferInfo = ImageCopyBuffer;
 using TexelCopyTextureInfo = ImageCopyTexture;
 using TexelCopyBufferLayout = TextureDataLayout;
-using ShaderSourceSPIRV = ShaderModuleSPIRVDescriptor;
+using ShaderSourceWGSL = ShaderModuleWGSLDescriptor;
 }; // namespace wgpu
 
 static WGPUBool wgpu_bool(bool value) { return static_cast<WGPUBool>(value); }
@@ -208,14 +205,17 @@
     RIVE_UNREACHABLE();
 }
 
-static wgpu::ShaderModule compile_shader_module_spirv(wgpu::Device device,
-                                                      const uint32_t* code,
-                                                      uint32_t codeSize)
+static wgpu::ShaderModule compile_shader_module_wgsl(
+    wgpu::Device device,
+    const rive::gpu::wgsl::Shader& shader)
 {
-    wgpu::ShaderSourceSPIRV spirvSource;
-    spirvSource.code = code;
-    spirvSource.codeSize = codeSize;
-    wgpu::ShaderModuleDescriptor descriptor = {.nextInChain = &spirvSource};
+    wgpu::ShaderSourceWGSL source;
+    source.code = shader.source;
+    wgpu::ShaderModuleDescriptor descriptor = {
+        .nextInChain = &source,
+    };
+    descriptor.label = shader.label;
+
     return device.CreateShaderModule(&descriptor);
 }
 
@@ -251,9 +251,10 @@
         .GL_MAX_VERTEX_SHADER_STORAGE_BLOCKS;
 });
 
-wgpu::ShaderModule compile_shader_module_wagyu(wgpu::Device device,
-                                               const char* source,
-                                               WGPUWagyuShaderLanguage language)
+static wgpu::ShaderModule compile_shader_module_wagyu(
+    wgpu::Device device,
+    const char* source,
+    WGPUWagyuShaderLanguage language)
 {
     WGPUChainedStruct* chainedShaderModuleDescriptor = nullptr;
     WGPUWagyuShaderModuleDescriptor wagyuDesc =
@@ -353,13 +354,13 @@
         wgpu::PipelineLayout pipelineLayout =
             context->m_device.CreatePipelineLayout(&pipelineLayoutDesc);
 
-        wgpu::ShaderModule fragmentShader;
+        wgpu::ShaderModule fragmentShaderModule;
         std::ostringstream glsl;
         glsl << "#version 310 es\n";
         glsl << "#define " GLSL_FRAGMENT " true\n";
         glsl << "#define " GLSL_ENABLE_CLIPPING " true\n";
         BuildLoadStoreEXTGLSL(glsl, actions);
-        fragmentShader =
+        fragmentShaderModule =
             compile_shader_module_wagyu(context->m_device,
                                         glsl.str().c_str(),
                                         WGPUWagyuShaderLanguage_GLSLRAW);
@@ -369,7 +370,7 @@
         };
 
         wgpu::FragmentState fragmentState = {
-            .module = fragmentShader,
+            .module = fragmentShaderModule,
             .entryPoint = "main",
             .targetCount = 1,
             .targets = &colorTargetState,
@@ -442,7 +443,7 @@
         wgpu::PipelineLayout pipelineLayout =
             device.CreatePipelineLayout(&pipelineLayoutDesc);
 
-        wgpu::ShaderModule vertexShader, fragmentShader;
+        wgpu::ShaderModule vertexShaderModule, fragmentShaderModule;
 #ifdef RIVE_WAGYU
         if (impl->m_capabilities.backendType == wgpu::BackendType::OpenGLES)
         {
@@ -462,7 +463,7 @@
             vertexGLSL << "#version 310 es\n";
             vertexGLSL << "#define " GLSL_VERTEX " true\n";
             vertexGLSL << glsl.str();
-            vertexShader =
+            vertexShaderModule =
                 compile_shader_module_wagyu(device,
                                             vertexGLSL.str().c_str(),
                                             WGPUWagyuShaderLanguage_GLSLRAW);
@@ -471,7 +472,7 @@
             fragmentGLSL << "#version 310 es\n";
             fragmentGLSL << "#define " GLSL_FRAGMENT " true\n";
             fragmentGLSL << glsl.str();
-            fragmentShader =
+            fragmentShaderModule =
                 compile_shader_module_wagyu(device,
                                             fragmentGLSL.str().c_str(),
                                             WGPUWagyuShaderLanguage_GLSLRAW);
@@ -479,14 +480,10 @@
         else
 #endif
         {
-            vertexShader =
-                compile_shader_module_spirv(device,
-                                            spirv::color_ramp_vert,
-                                            std::size(spirv::color_ramp_vert));
-            fragmentShader =
-                compile_shader_module_spirv(device,
-                                            spirv::color_ramp_frag,
-                                            std::size(spirv::color_ramp_frag));
+            vertexShaderModule =
+                compile_shader_module_wgsl(device, wgsl::color_ramp_vert);
+            fragmentShaderModule =
+                compile_shader_module_wgsl(device, wgsl::color_ramp_frag);
         }
 
         wgpu::VertexAttribute attrs[] = {
@@ -511,7 +508,7 @@
         };
 
         wgpu::FragmentState fragmentState = {
-            .module = fragmentShader,
+            .module = fragmentShaderModule,
             .entryPoint = "main",
             .targetCount = 1,
             .targets = &colorTargetState,
@@ -522,7 +519,7 @@
             .layout = pipelineLayout,
             .vertex =
                 {
-                    .module = vertexShader,
+                    .module = vertexShaderModule,
                     .entryPoint = "main",
                     .bufferCount = 1,
                     .buffers = &vertexBufferLayout,
@@ -581,7 +578,7 @@
         wgpu::PipelineLayout pipelineLayout =
             device.CreatePipelineLayout(&pipelineLayoutDesc);
 
-        wgpu::ShaderModule vertexShader, fragmentShader;
+        wgpu::ShaderModule vertexShaderModule, fragmentShaderModule;
 #ifdef RIVE_WAGYU
         if (impl->m_capabilities.backendType == wgpu::BackendType::OpenGLES)
         {
@@ -607,7 +604,7 @@
             vertexGLSL << "#version 310 es\n";
             vertexGLSL << "#define " GLSL_VERTEX " true\n";
             vertexGLSL << glsl.str();
-            vertexShader =
+            vertexShaderModule =
                 compile_shader_module_wagyu(device,
                                             vertexGLSL.str().c_str(),
                                             WGPUWagyuShaderLanguage_GLSLRAW);
@@ -616,7 +613,7 @@
             fragmentGLSL << "#version 310 es\n";
             fragmentGLSL << "#define " GLSL_FRAGMENT " true\n";
             fragmentGLSL << glsl.str();
-            fragmentShader =
+            fragmentShaderModule =
                 compile_shader_module_wagyu(device,
                                             fragmentGLSL.str().c_str(),
                                             WGPUWagyuShaderLanguage_GLSLRAW);
@@ -624,14 +621,12 @@
         else
 #endif
         {
-            vertexShader = compile_shader_module_spirv(
-                device,
-                spirv::tessellate_webgpu_vert,
-                std::size(spirv::tessellate_webgpu_vert));
-            fragmentShader = compile_shader_module_spirv(
-                device,
-                spirv::tessellate_webgpu_frag,
-                std::size(spirv::tessellate_webgpu_frag));
+            vertexShaderModule =
+                compile_shader_module_wgsl(device,
+                                           wgsl::tessellate_webgpu_vert);
+            fragmentShaderModule =
+                compile_shader_module_wgsl(device,
+                                           wgsl::tessellate_webgpu_frag);
         }
 
         wgpu::VertexAttribute attrs[] = {
@@ -671,7 +666,7 @@
         };
 
         wgpu::FragmentState fragmentState = {
-            .module = fragmentShader,
+            .module = fragmentShaderModule,
             .entryPoint = "main",
             .targetCount = 1,
             .targets = &colorTargetState,
@@ -682,7 +677,7 @@
             .layout = pipelineLayout,
             .vertex =
                 {
-                    .module = vertexShader,
+                    .module = vertexShaderModule,
                     .entryPoint = "main",
                     .bufferCount = 1,
                     .buffers = &vertexBufferLayout,
@@ -741,8 +736,8 @@
         wgpu::PipelineLayout pipelineLayout =
             device.CreatePipelineLayout(&pipelineLayoutDesc);
 
-        wgpu::ShaderModule vertexShader;
-        wgpu::ShaderModule fillFragmentShader, strokeFragmentShader;
+        wgpu::ShaderModule vertexShaderModule;
+        wgpu::ShaderModule fillFragmentShaderModule, strokeFragmentShaderModule;
 #ifdef RIVE_WAGYU
         if (impl->m_capabilities.backendType == wgpu::BackendType::OpenGLES)
         {
@@ -774,7 +769,7 @@
             vertexGLSL << "#pragma shader_stage(vertex)\n";
             vertexGLSL << "#define " GLSL_VERTEX " true\n";
             vertexGLSL << glsl.str();
-            vertexShader =
+            vertexShaderModule =
                 compile_shader_module_wagyu(device,
                                             vertexGLSL.str().c_str(),
                                             WGPUWagyuShaderLanguage_GLSLRAW);
@@ -785,7 +780,7 @@
             fillGLSL << "#define " GLSL_FRAGMENT " true\n";
             fillGLSL << "#define " GLSL_ATLAS_FEATHERED_FILL " true\n";
             fillGLSL << glsl.str();
-            fillFragmentShader =
+            fillFragmentShaderModule =
                 compile_shader_module_wagyu(device,
                                             fillGLSL.str().c_str(),
                                             WGPUWagyuShaderLanguage_GLSLRAW);
@@ -796,7 +791,7 @@
             strokeGLSL << "#define " GLSL_FRAGMENT " true\n";
             strokeGLSL << "#define " GLSL_ATLAS_FEATHERED_STROKE " true\n";
             strokeGLSL << glsl.str();
-            strokeFragmentShader =
+            strokeFragmentShaderModule =
                 compile_shader_module_wagyu(device,
                                             strokeGLSL.str().c_str(),
                                             WGPUWagyuShaderLanguage_GLSLRAW);
@@ -804,18 +799,15 @@
         else
 #endif
         {
-            vertexShader = compile_shader_module_spirv(
+            vertexShaderModule =
+                compile_shader_module_wgsl(device,
+                                           wgsl::render_atlas_webgpu_vert);
+            fillFragmentShaderModule =
+                compile_shader_module_wgsl(device,
+                                           wgsl::render_atlas_fill_webgpu_frag);
+            strokeFragmentShaderModule = compile_shader_module_wgsl(
                 device,
-                spirv::render_atlas_webgpu_vert,
-                std::size(spirv::render_atlas_webgpu_vert));
-            fillFragmentShader = compile_shader_module_spirv(
-                device,
-                spirv::render_atlas_fill_webgpu_frag,
-                std::size(spirv::render_atlas_fill_webgpu_frag));
-            strokeFragmentShader = compile_shader_module_spirv(
-                device,
-                spirv::render_atlas_stroke_webgpu_frag,
-                std::size(spirv::render_atlas_stroke_webgpu_frag));
+                wgsl::render_atlas_stroke_webgpu_frag);
         }
 
         wgpu::VertexAttribute attrs[] = {
@@ -853,7 +845,7 @@
         };
 
         wgpu::FragmentState fragmentState = {
-            .module = fillFragmentShader,
+            .module = fillFragmentShaderModule,
             .entryPoint = "main",
             .targetCount = 1,
             .targets = &colorTargetState,
@@ -864,7 +856,7 @@
             .layout = pipelineLayout,
             .vertex =
                 {
-                    .module = vertexShader,
+                    .module = vertexShaderModule,
                     .entryPoint = "main",
                     .bufferCount = 1,
                     .buffers = &vertexBufferLayout,
@@ -881,7 +873,7 @@
         m_fillPipeline = device.CreateRenderPipeline(&desc);
 
         blendState.color.operation = wgpu::BlendOperation::Max;
-        fragmentState.module = strokeFragmentShader;
+        fragmentState.module = strokeFragmentShaderModule;
         m_strokePipeline = device.CreateRenderPipeline(&desc);
     }
 
@@ -913,7 +905,12 @@
         const bool fixedFunctionColorOutput =
             enums::is_flag_set(shaderMiscFlags,
                                gpu::ShaderMiscFlags::fixedFunctionColorOutput);
-        wgpu::ShaderModule vertexShader, fragmentShader;
+        wgpu::ShaderModule vertexModule, fragmentModule;
+        // Override info for the WGSL path. Stays nullptr on the WAGYU/GLSL
+        // path, where permutations are baked in via #defines instead of
+        // pipeline-overridable constants.
+        const wgsl::Shader* vertexShader = nullptr;
+        const wgsl::Shader* fragmentShader = nullptr;
 #ifdef RIVE_WAGYU
         PixelLocalStorageType plsType = context->m_capabilities.plsType;
         if (using_pls(interlockMode))
@@ -1095,7 +1092,7 @@
             vertexGLSL << "#pragma shader_stage(vertex)\n";
             vertexGLSL << "#define " GLSL_VERTEX " true\n";
             vertexGLSL << glsl.str();
-            vertexShader = compile_shader_module_wagyu(context->m_device,
+            vertexModule = compile_shader_module_wagyu(context->m_device,
                                                        vertexGLSL.str().c_str(),
                                                        language);
 
@@ -1104,7 +1101,7 @@
             fragmentGLSL << "#pragma shader_stage(fragment)\n";
             fragmentGLSL << "#define " GLSL_FRAGMENT " true\n";
             fragmentGLSL << glsl.str();
-            fragmentShader =
+            fragmentModule =
                 compile_shader_module_wagyu(context->m_device,
                                             fragmentGLSL.str().c_str(),
                                             language);
@@ -1113,8 +1110,6 @@
 #endif
         {
             assert(interlockMode == gpu::InterlockMode::msaa);
-            Span<const uint32_t> vertCode;
-            Span<const uint32_t> fragCode;
             switch (drawType)
             {
                 case DrawType::midpointFanPatches:
@@ -1129,23 +1124,20 @@
                 case DrawType::msaaMidpointFanStencilReset:
                 case DrawType::msaaMidpointFanPathsStencil:
                 case DrawType::msaaMidpointFanPathsCover:
-                    vertCode =
+                    vertexShader =
                         enums::is_flag_set(shaderFeatures,
                                            ShaderFeatures::ENABLE_CLIP_RECT)
-                            ? make_span(spirv::draw_msaa_path_webgpu_vert)
-                            : make_span(
-                                  spirv::
-                                      draw_msaa_path_webgpu_noclipdistance_vert);
-                    fragCode =
+                            ? &wgsl::draw_msaa_path_webgpu_vert
+                            : &wgsl::draw_msaa_path_webgpu_noclipdistance_vert;
+                    fragmentShader =
                         fixedFunctionColorOutput
-                            ? make_span(
-                                  spirv::draw_msaa_path_webgpu_fixedcolor_frag)
-                            : make_span(spirv::draw_msaa_path_webgpu_frag);
+                            ? &wgsl::draw_msaa_path_webgpu_fixedcolor_frag
+                            : &wgsl::draw_msaa_path_webgpu_frag;
                     break;
 
                 case DrawType::clipReset:
-                    vertCode = make_span(spirv::draw_msaa_stencil_vert);
-                    fragCode = make_span(spirv::draw_msaa_stencil_frag);
+                    vertexShader = &wgsl::draw_msaa_stencil_vert;
+                    fragmentShader = &wgsl::draw_msaa_stencil_frag;
                     break;
 
                 case DrawType::interiorTriangulation:
@@ -1154,61 +1146,49 @@
                     break;
 
                 case DrawType::atlasBlit:
-                    vertCode =
+                    vertexShader =
                         enums::is_flag_set(shaderFeatures,
                                            ShaderFeatures::ENABLE_CLIP_RECT)
-                            ? make_span(spirv::draw_msaa_atlas_blit_webgpu_vert)
-                            : make_span(
-                                  spirv::
-                                      draw_msaa_atlas_blit_webgpu_noclipdistance_vert);
-                    fragCode =
+                            ? &wgsl::draw_msaa_atlas_blit_webgpu_vert
+                            : &wgsl::
+                                  draw_msaa_atlas_blit_webgpu_noclipdistance_vert;
+                    fragmentShader =
                         fixedFunctionColorOutput
-                            ? make_span(
-                                  spirv::
-                                      draw_msaa_atlas_blit_webgpu_fixedcolor_frag)
-                            : make_span(
-                                  spirv::draw_msaa_atlas_blit_webgpu_frag);
+                            ? &wgsl::draw_msaa_atlas_blit_webgpu_fixedcolor_frag
+                            : &wgsl::draw_msaa_atlas_blit_webgpu_frag;
                     break;
 
                 case DrawType::imageMesh:
-                    vertCode =
+                    vertexShader =
                         enums::is_flag_set(shaderFeatures,
                                            ShaderFeatures::ENABLE_CLIP_RECT)
-                            ? make_span(spirv::draw_msaa_image_mesh_webgpu_vert)
-                            : make_span(
-                                  spirv::
-                                      draw_msaa_image_mesh_webgpu_noclipdistance_vert);
-                    fragCode =
+                            ? &wgsl::draw_msaa_image_mesh_webgpu_vert
+                            : &wgsl::
+                                  draw_msaa_image_mesh_webgpu_noclipdistance_vert;
+                    fragmentShader =
                         fixedFunctionColorOutput
-                            ? make_span(
-                                  spirv::
-                                      draw_msaa_image_mesh_webgpu_fixedcolor_frag)
-                            : make_span(
-                                  spirv::draw_msaa_image_mesh_webgpu_frag);
+                            ? &wgsl::draw_msaa_image_mesh_webgpu_fixedcolor_frag
+                            : &wgsl::draw_msaa_image_mesh_webgpu_frag;
                     break;
 
                 case DrawType::renderPassInitialize:
                     // MSAA render passes get initialized by drawing the
                     // previous contents into the framebuffer.
                     // (LoadAction::preserveRenderTarget only.)
-                    vertCode = make_span(
-                        spirv::blit_texture_as_draw_filtered_webgpu_vert);
-                    fragCode = make_span(
-                        spirv::blit_texture_as_draw_filtered_webgpu_frag);
+                    vertexShader =
+                        &wgsl::blit_texture_as_draw_filtered_webgpu_vert;
+                    fragmentShader =
+                        &wgsl::blit_texture_as_draw_filtered_webgpu_frag;
                     break;
 
                 case DrawType::imageRect:
                 case DrawType::renderPassResolve:
                     RIVE_UNREACHABLE();
             }
-            vertexShader = compile_shader_module_spirv(
-                context->m_device,
-                vertCode.data(),
-                math::lossless_numeric_cast<uint32_t>(vertCode.count()));
-            fragmentShader = compile_shader_module_spirv(
-                context->m_device,
-                fragCode.data(),
-                math::lossless_numeric_cast<uint32_t>(fragCode.count()));
+            vertexModule =
+                compile_shader_module_wgsl(context->m_device, *vertexShader);
+            fragmentModule =
+                compile_shader_module_wgsl(context->m_device, *fragmentShader);
         }
 
         for (auto framebufferFormat :
@@ -1217,9 +1197,12 @@
             int pipelineIdx = RenderPipelineIdx(framebufferFormat);
             m_renderPipelines[pipelineIdx] =
                 context->makeDrawPipeline(drawType,
+                                          shaderFeatures,
                                           interlockMode,
                                           shaderMiscFlags,
                                           framebufferFormat,
+                                          vertexModule,
+                                          fragmentModule,
                                           vertexShader,
                                           fragmentShader,
                                           pipelineState);
@@ -2113,22 +2096,20 @@
         wgpu::PipelineLayout pipelineLayout =
             device.CreatePipelineLayout(&pipelineLayoutDesc);
 
-        wgpu::ShaderModule vertexShader = compile_shader_module_spirv(
+        wgpu::ShaderModule vertexShaderModule = compile_shader_module_wgsl(
             device,
-            spirv::blit_texture_as_draw_filtered_webgpu_vert,
-            std::size(spirv::blit_texture_as_draw_filtered_webgpu_vert));
+            wgsl::blit_texture_as_draw_filtered_webgpu_vert);
 
-        wgpu::ShaderModule fragmentShader = compile_shader_module_spirv(
+        wgpu::ShaderModule fragmentShaderModule = compile_shader_module_wgsl(
             device,
-            spirv::blit_texture_as_draw_filtered_webgpu_frag,
-            std::size(spirv::blit_texture_as_draw_filtered_webgpu_frag));
+            wgsl::blit_texture_as_draw_filtered_webgpu_frag);
 
         wgpu::ColorTargetState colorTargetState = {
             .format = wgpu::TextureFormat::RGBA8Unorm,
         };
 
         wgpu::FragmentState fragmentState = {
-            .module = fragmentShader,
+            .module = fragmentShaderModule,
             .entryPoint = "main",
             .targetCount = 1,
             .targets = &colorTargetState,
@@ -2139,7 +2120,7 @@
             .layout = pipelineLayout,
             .vertex =
                 {
-                    .module = vertexShader,
+                    .module = vertexShaderModule,
                     .entryPoint = "main",
                 },
             .primitive =
@@ -2521,11 +2502,14 @@
 
 wgpu::RenderPipeline RenderContextWebGPUImpl::makeDrawPipeline(
     gpu::DrawType drawType,
+    gpu::ShaderFeatures shaderFeatures,
     gpu::InterlockMode interlockMode,
     gpu::ShaderMiscFlags shaderMiscFlags,
     wgpu::TextureFormat framebufferFormat,
-    wgpu::ShaderModule vertexShader,
-    wgpu::ShaderModule fragmentShader,
+    wgpu::ShaderModule vertexShaderModule,
+    wgpu::ShaderModule fragmentShaderModule,
+    const wgsl::Shader* vertexShader,
+    const wgsl::Shader* fragmentShader,
     const gpu::PipelineState& pipelineState)
 {
     std::vector<WGPUVertexAttribute> attrs;
@@ -2684,9 +2668,113 @@
     }
 #endif
 
+    // Override constants for the WGSL shaders. Mirrors the SPIRV specialization
+    // layout — same indices, same data, just delivered through WebGPU's
+    // override mechanism.
+    double shaderPermutationFlags[SPECIALIZATION_COUNT] = {
+        static_cast<double>(
+            enums::is_flag_set(shaderFeatures,
+                               gpu::ShaderFeatures::ENABLE_CLIPPING)),
+        static_cast<double>(
+            enums::is_flag_set(shaderFeatures,
+                               gpu::ShaderFeatures::ENABLE_CLIP_RECT)),
+        static_cast<double>(
+            enums::is_flag_set(shaderFeatures,
+                               gpu::ShaderFeatures::ENABLE_ADVANCED_BLEND)),
+        static_cast<double>(
+            enums::is_flag_set(shaderFeatures,
+                               gpu::ShaderFeatures::ENABLE_FEATHER)),
+        static_cast<double>(
+            enums::is_flag_set(shaderFeatures,
+                               gpu::ShaderFeatures::ENABLE_EVEN_ODD)),
+        static_cast<double>(
+            enums::is_flag_set(shaderFeatures,
+                               gpu::ShaderFeatures::ENABLE_NESTED_CLIPPING)),
+        static_cast<double>(
+            enums::is_flag_set(shaderFeatures,
+                               gpu::ShaderFeatures::ENABLE_HSL_BLEND_MODES)),
+        static_cast<double>(
+            enums::is_flag_set(shaderFeatures,
+                               gpu::ShaderFeatures::ENABLE_DITHER)),
+        static_cast<double>(
+            enums::is_flag_set(shaderMiscFlags,
+                               gpu::ShaderMiscFlags::clockwiseFill)),
+        static_cast<double>(
+            enums::is_flag_set(shaderMiscFlags,
+                               gpu::ShaderMiscFlags::borrowedCoveragePass)),
+        static_cast<double>(
+            enums::is_flag_set(shaderMiscFlags,
+                               gpu::ShaderMiscFlags::nestedClipUpdateOnly)),
+        0.0, // VULKAN_VENDOR_ARM — ignored for now, but we may want to detect
+             // this if it we find ARM bugs on WebGPU that get fixed by shader
+             // modifications.
+    };
+    static_assert(CLIPPING_SPECIALIZATION_IDX == 0);
+    static_assert(CLIP_RECT_SPECIALIZATION_IDX == 1);
+    static_assert(ADVANCED_BLEND_SPECIALIZATION_IDX == 2);
+    static_assert(FEATHER_SPECIALIZATION_IDX == 3);
+    static_assert(EVEN_ODD_SPECIALIZATION_IDX == 4);
+    static_assert(NESTED_CLIPPING_SPECIALIZATION_IDX == 5);
+    static_assert(HSL_BLEND_MODES_SPECIALIZATION_IDX == 6);
+    static_assert(DITHER_SPECIALIZATION_IDX == 7);
+    static_assert(CLOCKWISE_FILL_SPECIALIZATION_IDX == 8);
+    static_assert(BORROWED_COVERAGE_PASS_SPECIALIZATION_IDX == 9);
+    static_assert(NESTED_CLIP_UPDATE_ONLY_IDX == 10);
+    static_assert(VULKAN_VENDOR_ARM_SPECIALIZATION_IDX == 11);
+    static_assert(SPECIALIZATION_COUNT == 12);
+
+    // Build a per-stage WGPUConstantEntry[] from the shader's own override
+    // list.
+    auto buildConstants = [&](const wgsl::Shader* shader,
+                              WGPUConstantEntry* out) -> size_t {
+        if (shader == nullptr)
+        {
+            return 0;
+        }
+
+        constexpr const char* SpecializationIdxIDs[] = {
+            "0",
+            "1",
+            "2",
+            "3",
+            "4",
+            "5",
+            "6",
+            "7",
+            "8",
+            "9",
+            "10",
+            "11",
+        };
+        static_assert(std::size(SpecializationIdxIDs) == SPECIALIZATION_COUNT);
+
+        size_t count = 0;
+        for (uint32_t i = 0; i < SPECIALIZATION_COUNT; ++i)
+        {
+            if (!shader->usedOverrides[i])
+                continue;
+            out[count++] = {
+                .nextInChain = nullptr,
+                .key = WGPU_STRING_VIEW(SpecializationIdxIDs[i]),
+                .value = shaderPermutationFlags[i],
+            };
+        }
+
+        return count;
+    };
+
+    WGPUConstantEntry vertexConstantEntries[SPECIALIZATION_COUNT];
+    WGPUConstantEntry fragmentConstantEntries[SPECIALIZATION_COUNT];
+    size_t vertexConstantCount =
+        buildConstants(vertexShader, vertexConstantEntries);
+    size_t fragmentConstantCount =
+        buildConstants(fragmentShader, fragmentConstantEntries);
+
     WGPUFragmentState fragmentState = {
-        .module = fragmentShader.Get(),
+        .module = fragmentShaderModule.Get(),
         .entryPoint = WGPU_STRING_VIEW("main"),
+        .constantCount = fragmentConstantCount,
+        .constants = fragmentConstantEntries,
         .targetCount = colorAttachments.size(),
         .targets = colorAttachments.data(),
     };
@@ -2721,8 +2809,10 @@
         .layout = m_drawPipelineLayout.Get(),
         .vertex =
             {
-                .module = vertexShader.Get(),
+                .module = vertexShaderModule.Get(),
                 .entryPoint = WGPU_STRING_VIEW("main"),
+                .constantCount = vertexConstantCount,
+                .constants = vertexConstantEntries,
                 .bufferCount = std::size(vertexBufferLayouts),
                 .buffers = vertexBufferLayouts.data(),
             },
diff --git a/tests/common/offscreen_render_target_vulkan.cpp b/tests/common/offscreen_render_target_vulkan.cpp
index f34d3b3..9d07add 100644
--- a/tests/common/offscreen_render_target_vulkan.cpp
+++ b/tests/common/offscreen_render_target_vulkan.cpp
@@ -70,7 +70,7 @@
                 // can get the RGB order wrong when resolving BGRA multisampled
                 // data.
                 (riveRenderable || vk->physicalDeviceProperties().vendorID ==
-                                       VULKAN_VENDOR_QUALCOMM)
+                                       rive::gpu::vkutil::vendors::Qualcomm)
                     ? VK_FORMAT_R8G8B8A8_UNORM
                     : VK_FORMAT_B8G8R8A8_UNORM,
                 VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT |
diff --git a/tests/rive_tools_project.lua b/tests/rive_tools_project.lua
index 0afaa09..fa08790 100644
--- a/tests/rive_tools_project.lua
+++ b/tests/rive_tools_project.lua
@@ -316,7 +316,7 @@
         'system:windows',
     })
     do
-        links({ 'dxguid' })
+        links({ 'dxguid', 'onecore' })
     end
 
     filter({