Skip to content

Conversation

@inner-daemons
Copy link
Collaborator

@inner-daemons inner-daemons commented Oct 31, 2025

Connections
Works towards #7197
Builds on #8370

Description

Add a SPIR-V writer for mesh shaders

All major changes here are in the SPIR-V backend for naga and naga snapshots. Other "changes" are inherited from #8370

Testing

Mesh shader test WGSL is now written to SPIR-V as a snapshot. Mesh shader tests & example use naga-written spirv on vulkan backend.

Squash or Rebase?
Squash

Checklist

  • Run cargo fmt.
  • Run taplo format.
  • Run cargo clippy --tests. If applicable, add:
    • --target wasm32-unknown-unknown
  • Run cargo xtask test to run tests.
  • If this contains user-facing changes, add a CHANGELOG.md entry.
inner-daemons and others added 30 commits August 14, 2025 12:53
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR adds WGSL mesh shader support to wgpu, enabling the use of mesh shaders on the Vulkan backend through naga's WGSL frontend and SPIR-V backend. The implementation introduces new shader stages (Task and Mesh), new built-ins, a task_payload address space, and updates the API to use a workgroup output variable approach instead of imperative setVertex/setPrimitive calls.

Key changes:

  • Adds mesh shader capability validation in wgpu-core
  • Implements WGSL parsing for mesh shader syntax including @mesh, @task, @payload, and @per_primitive attributes
  • Adds SPIR-V backend support for mesh shader emission
  • Removes GLSL compilation in favor of WGSL for Vulkan mesh shaders
  • Updates documentation and adds comprehensive test coverage

Reviewed Changes

Copilot reviewed 39 out of 51 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
wgpu-core/src/device/mod.rs Adds MESH_SHADER capability to validator based on feature flag
naga/src/ir/mod.rs Adds new built-ins (VertexCount, Vertices, etc.) and restructures MeshStageInfo to include output_variable
naga/src/front/wgsl/parse/mod.rs Implements parsing for mesh shader attributes and directives
naga/src/valid/interface.rs Adds validation for mesh shader constraints and output types
naga/src/back/spv/writer.rs Implements SPIR-V emission for mesh shaders including output variable setup
tests/tests/wgpu-gpu/mesh_shader/mod.rs Replaces GLSL compilation with WGSL, removes MESH_DISABLED test
tests/tests/wgpu-gpu/mesh_shader/shader.wgsl New WGSL test shader for mesh shaders
docs/api-specs/mesh_shading.md Updates documentation to reflect new workgroup variable approach
CHANGELOG.md Documents the new feature additions
Comments suppressed due to low confidence (1)

naga/src/back/spv/writer.rs:1

  • Using NonMaxU32::new(0).unwrap() to create a null handle is fragile and unclear. Consider defining a constant like NULL_TYPE_HANDLE or using a more explicit pattern to represent invalid/placeholder handles.
use alloc::{string::String, vec, vec::Vec}; 

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

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

Labels

None yet

3 participants