Skip to content

Initial naga changes for mesh shaders #7930

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 91 commits into
base: trunk
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
91 commits
Select commit Hold shift + click to select a range
f7e6e18
Initial(untested commit), vulkan and gles only supported
SupaMaggie70Incorporated Jan 17, 2025
4e5772b
Maybe fixed compiles for metal and dx12
SupaMaggie70Incorporated Jan 18, 2025
a5f8909
Merge branch 'gfx-rs:trunk' into mesh-shading/wgpu-hal
SupaMaggie70Incorporated Jan 18, 2025
ab83fa7
Hopefully fixed compiles for other backends and updated to functional…
SupaMaggie70Incorporated Jan 18, 2025
0b2bb72
I don't get git
SupaMaggie70Incorporated Jan 18, 2025
06d3f52
Fixed the clippy warning
SupaMaggie70Incorporated Jan 18, 2025
8b67893
Initial naga changes and outline
SupaMaggie70Incorporated Jan 18, 2025
441e64f
Fixed minor issue
SupaMaggie70Incorporated Jan 18, 2025
1939260
Merge recent changes, most significantly features type overhaul
SupaMaggie70Incorporated Feb 8, 2025
37fd5ac
Merge branch 'mesh-shading/wgpu-hal' into mesh-shading/naga-init
SupaMaggie70Incorporated Feb 8, 2025
5a66eab
Fixed silly documentation mistake
SupaMaggie70Incorporated Feb 9, 2025
81df0dc
Merge branch 'mesh-shading/wgpu-hal' into mesh-shading/naga-init
SupaMaggie70Incorporated Feb 9, 2025
a9d6ae3
Hopefully fixed some issues in CI
SupaMaggie70Incorporated Feb 9, 2025
a6b8019
Automatic changes caused by tests
SupaMaggie70Incorporated Feb 9, 2025
4840189
Fixed issue with multiview feature
SupaMaggie70Incorporated Feb 13, 2025
0743fb0
Merge branch 'mesh-shading/wgpu-hal' into mesh-shading/naga-init
SupaMaggie70Incorporated Feb 13, 2025
6f4f8cf
CI will hate this one - made some changes based on discussion of prop…
SupaMaggie70Incorporated Feb 13, 2025
e7ec2a7
Made CI slightly less angry
SupaMaggie70Incorporated Feb 13, 2025
6c2c9ac
Dummy commit for dummy CI
SupaMaggie70Incorporated Feb 13, 2025
8c07665
Merge branch 'trunk' into mesh-shading/wgpu-hal
SupaMaggie70Incorporated Feb 13, 2025
909736a
Merge branch 'mesh-shading/wgpu-hal' into mesh-shading/naga-init
SupaMaggie70Incorporated Feb 13, 2025
34a3d05
(Tried to) Merge branch 'trunk' into mesh-shading/naga-init
SupaMaggie70Incorporated Jul 7, 2025
88acd65
Tried to undo cargo.lock changes
SupaMaggie70Incorporated Jul 7, 2025
8c6e887
Dusted off this ancient PR
SupaMaggie70Incorporated Jul 7, 2025
53f2891
Updated naga snapshots
SupaMaggie70Incorporated Jul 7, 2025
f71ff9b
A little more work
SupaMaggie70Incorporated Jul 7, 2025
145699c
Worked a little more
SupaMaggie70Incorporated Jul 7, 2025
c6e0450
Now (almost) parses!
SupaMaggie70Incorporated Jul 7, 2025
de03c4a
Updated wgsl file to not specify unsigned integer literals. Will work…
SupaMaggie70Incorporated Jul 9, 2025
b4486c1
Merge branch 'trunk' into mesh-shading/naga-init
SupaMaggie70Incorporated Jul 11, 2025
20c198a
Merge branch 'trunk' into mesh-shading/naga-init
SupaMaggie70Incorporated Jul 11, 2025
7884781
Added more stuff to naga IR and a tiny bit of validation
SupaMaggie70Incorporated Jul 12, 2025
defa58b
Fixed some typos lol
SupaMaggie70Incorporated Jul 12, 2025
d5f1770
Added changelog entry
SupaMaggie70Incorporated Jul 12, 2025
b4ef6ca
Merge branch 'trunk' into mesh-shading/naga-init
SupaMaggie70Incorporated Jul 12, 2025
7e7850e
Added task_payload storage class parsing to wgsl, validation for it, etc
SupaMaggie70Incorporated Jul 12, 2025
9fd01d5
Added output type validation
SupaMaggie70Incorporated Jul 12, 2025
bb95324
Tried to fix u32 casting
SupaMaggie70Incorporated Jul 12, 2025
aff163f
Attempted to fix u32 to i32 automatic conversion issue
SupaMaggie70Incorporated Jul 12, 2025
4612795
Fixed stupid naga validation bug
SupaMaggie70Incorporated Jul 12, 2025
8de0f04
Updated snapshots
SupaMaggie70Incorporated Jul 12, 2025
ac3901f
Tried to clarify mesh validation errors
SupaMaggie70Incorporated Jul 12, 2025
000052a
Made it adjust mesh shader metadata during compaction
SupaMaggie70Incorporated Jul 12, 2025
fe3a832
Added more validation for the output type of entry points
SupaMaggie70Incorporated Jul 12, 2025
62fa627
Made it allow @mesh_task_size declared in a struct for task output
SupaMaggie70Incorporated Jul 12, 2025
3774358
Smartified the task output checking
SupaMaggie70Incorporated Jul 12, 2025
8adf8c6
A little more work for SPIRV writing and added back point index builtin
SupaMaggie70Incorporated Jul 12, 2025
75d42bd
Now it can (almost) compile a task shader!
SupaMaggie70Incorporated Jul 13, 2025
611992d
Task shaders can now be written properly!!!!
SupaMaggie70Incorporated Jul 13, 2025
74e8352
Cleaned up task shader writing
SupaMaggie70Incorporated Jul 13, 2025
7ed6e47
More minor fixes to task shader and made it require SPIR-V 1.4
SupaMaggie70Incorporated Jul 13, 2025
5bb4c3f
Now also passes spirv-val
SupaMaggie70Incorporated Jul 13, 2025
2976b78
Fixed silly typo that CI noticed
SupaMaggie70Incorporated Jul 13, 2025
2174592
Updated snapshots
SupaMaggie70Incorporated Jul 13, 2025
2e6f11c
Attempted to make a small adjustment to SPIR-V writing
SupaMaggie70Incorporated Jul 13, 2025
784dd80
A lot more progress made
SupaMaggie70Incorporated Jul 14, 2025
cef766a
HAHAHAH YEASSS
SupaMaggie70Incorporated Jul 14, 2025
41e462b
Merge branch 'trunk' into mesh-shading/naga-init
SupaMaggie70Incorporated Jul 14, 2025
072391f
Updated snapshots
SupaMaggie70Incorporated Jul 14, 2025
23946cd
Updated mesh shading spec, also to include @per_primitive attribute
SupaMaggie70Incorporated Jul 14, 2025
471300e
Final tweaks to the spec
SupaMaggie70Incorporated Jul 14, 2025
44f71b1
Small tweaks
SupaMaggie70Incorporated Jul 14, 2025
c7a728c
A few more small tweaks
SupaMaggie70Incorporated Jul 14, 2025
a5f30c8
More nitpicky tweaks, next focus is actually addressing the problem i…
SupaMaggie70Incorporated Jul 14, 2025
6df6e11
Pushing broken changes for now because I have to switch dev platforms…
SupaMaggie70Incorporated Jul 14, 2025
cc865bb
Updated to not have 2 arrays of structs (gross)
SupaMaggie70Incorporated Jul 14, 2025
291d56c
Updated snapshots
SupaMaggie70Incorporated Jul 14, 2025
e858583
Tried to hopefully fix stupid issue
SupaMaggie70Incorporated Jul 14, 2025
d0821d7
Updated mesh-shader.toml config
SupaMaggie70Incorporated Jul 14, 2025
04e0144
Update rspirv version
SupaMaggie70Incorporated Jul 14, 2025
1250fee
Updated naga snapshots
SupaMaggie70Incorporated Jul 14, 2025
2f2206c
Merge branch 'update-rspirv-version' into mesh-shading/naga-init
SupaMaggie70Incorporated Jul 14, 2025
c9c7a63
Updated snapshots
SupaMaggie70Incorporated Jul 14, 2025
65c40a4
Reformatted the config toml
SupaMaggie70Incorporated Jul 14, 2025
55435ee
Merge branch 'trunk' into mesh-shading/naga-init
SupaMaggie70Incorporated Jul 14, 2025
cef1606
Implemented coordinate flipping
SupaMaggie70Incorporated Jul 14, 2025
2cbe48e
Merge branch 'trunk' into mesh-shading/naga-init
SupaMaggie70Incorporated Jul 17, 2025
aa045a0
Merge branch 'trunk' into mesh-shading/naga-init
SupaMaggie70Incorporated Jul 19, 2025
a83d664
Merge branch 'trunk' into mesh-shading/naga-init
SupaMaggie70Incorporated Aug 9, 2025
6577197
Updated shader test outputs
SupaMaggie70Incorporated Aug 9, 2025
825a060
Added per primitive stuff
SupaMaggie70Incorporated Aug 9, 2025
0ce1860
Tried to completely overhaul the output variable writing for spirv
SupaMaggie70Incorporated Aug 9, 2025
14b2b84
Committing this nonsense before it all gets destroyed again by my stu…
SupaMaggie70Incorporated Aug 9, 2025
789ba11
A little more progress (I'm paranoid)
SupaMaggie70Incorporated Aug 9, 2025
0eaa7d1
A little more progress (still very broken)
SupaMaggie70Incorporated Aug 9, 2025
66b5397
Updated my todos
SupaMaggie70Incorporated Aug 9, 2025
44340b4
It frickin works now I think
SupaMaggie70Incorporated Aug 9, 2025
4200116
Implemented coordinate flip
SupaMaggie70Incorporated Aug 9, 2025
397d89d
Made the example properly work with ALL naga shaders!!
SupaMaggie70Incorporated Aug 10, 2025
97381d5
Upgraded the copy algorithm to not be complete garbage
SupaMaggie70Incorporated Aug 10, 2025
866b85d
Final tweaks and removing // TODO 's
SupaMaggie70Incorporated Aug 10, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ By @Vecvec in [#7913](https://github.com/gfx-rs/wgpu/pull/7913).
#### Naga

- Naga now requires that no type be larger than 1 GB. This limit may be lowered in the future; feedback on an appropriate value for the limit is welcome. By @andyleiserson in [#7950](https://github.com/gfx-rs/wgpu/pull/7950).
- Added mesh shader support to naga with `WGSL` frontend and `SPIR-V` backend. By @SupaMaggie70Incorporated in [#7930](https://github.com/gfx-rs/wgpu/pull/7930).

#### DX12

Expand Down
32 changes: 16 additions & 16 deletions docs/api-specs/mesh_shading.md
Original file line number Diff line number Diff line change
Expand Up @@ -80,32 +80,36 @@ This shader stage can be selected by marking a function with `@task`. Task shade

The output of this determines how many workgroups of mesh shaders will be dispatched. Once dispatched, global id variables will be local to the task shader workgroup dispatch, and mesh shaders won't know the position of their dispatch among all mesh shader dispatches unless this is passed through the payload. The output may be zero to skip dispatching any mesh shader workgroups for the task shader workgroup.

If task shaders are marked with `@payload(someVar)`, where `someVar` is global variable declared like `var<workgroup> someVar: <type>`, task shaders may write to `someVar`. This payload is passed to the mesh shader workgroup that is invoked. The mesh shader can skip declaring `@payload` to ignore this input.
If task shaders are marked with `@payload(someVar)`, where `someVar` is global variable declared like `var<task_payload> someVar: <type>`, task shaders may use `someVar` as if it is a read-write workgroup storage variable. This payload is passed to the mesh shader workgroup that is invoked. The mesh shader can skip declaring `@payload` to ignore this input.

### Mesh shader
This shader stage can be selected by marking a function with `@mesh`. Mesh shaders must not return anything.

Mesh shaders can be marked with `@payload(someVar)` similar to task shaders. Unlike task shaders, mesh shaders cannot write to this workgroup memory. Declaring `@payload` in a pipeline with no task shader, in a pipeline with a task shader that doesn't declare `@payload`, or in a task shader with an `@payload` that is statically sized and smaller than the mesh shader payload is illegal.
Mesh shaders can be marked with `@payload(someVar)` similar to task shaders. Unlike task shaders, mesh shaders cannot write to this memory. Declaring `@payload` in a pipeline with no task shader, in a pipeline with a task shader that doesn't declare `@payload`, or in a task shader with an `@payload` that is statically sized and smaller than the mesh shader payload is illegal.

Mesh shaders must be marked with `@vertex_output(OutputType, numOutputs)`, where `numOutputs` is the maximum number of vertices to be output by a mesh shader, and `OutputType` is the data associated with vertices, similar to a standard vertex shader output.
Mesh shaders must be marked with `@vertex_output(OutputType, numOutputs)`, where `numOutputs` is the maximum number of vertices to be output by a mesh shader, and `OutputType` is the data associated with vertices, similar to a standard vertex shader output, and must be a struct.

Mesh shaders must also be marked with `@primitive_output(OutputType, numOutputs)`, which is similar to `@vertex_output` except it describes the primitive outputs.

### Mesh shader outputs

Primitive outputs from mesh shaders have some additional builtins they can set. These include `@builtin(cull_primitive)`, which must be a boolean value. If this is set to true, then the primitive is skipped during rendering.
Vertex outputs from mesh shaders function identically to outputs of vertex shaders, and as such must have a field with `@builtin(position)`.

Primitive outputs from mesh shaders have some additional builtins they can set. These include `@builtin(cull_primitive)`, which must be a boolean value. If this is set to true, then the primitive is skipped during rendering. All non-builtin primitive outputs must be decorated with `@per_primitive`.

Mesh shader primitive outputs must also specify exactly one of `@builtin(triangle_indices)`, `@builtin(line_indices)`, or `@builtin(point_index)`. This determines the output topology of the mesh shader, and must match the output topology of the pipeline descriptor the mesh shader is used with. These must be of type `vec3<u32>`, `vec2<u32>`, and `u32` respectively. When setting this, each of the indices must be less than the number of vertices declared in `setMeshOutputs`.

Additionally, the `@location` attributes from the vertex and primitive outputs can't overlap.

Before setting any vertices or indices, or exiting, the mesh shader must call `setMeshOutputs(numVertices: u32, numIndices: u32)`, which declares the number of vertices and indices that will be written to. These must be less than the corresponding maximums set in `@vertex_output` and `@primitive_output`. The mesh shader must then write to exactly these numbers of vertices and primitives.
Before setting any vertices or indices, or exiting, the mesh shader must call `setMeshOutputs(numVertices: u32, numIndices: u32)`, which declares the number of vertices and indices that will be written to. These must be less than the corresponding maximums set in `@vertex_output` and `@primitive_output`. The mesh shader must then write to exactly these numbers of vertices and primitives. A varying member with `@per_primitive` cannot be used in function interfaces except as the primitive output for mesh shaders or as input for fragment shaders.

The mesh shader can write to vertices using the `setVertex(idx: u32, vertex: VertexOutput)` where `VertexOutput` is replaced with the vertex type declared in `@vertex_output`, and `idx` is the index of the vertex to write. Similarly, the mesh shader can write to vertices using `setPrimitive(idx: u32, primitive: PrimitiveOutput)`. These can be written to multiple times, however unsynchronized writes are undefined behavior. The primitives and indices are shared across the entire mesh shader workgroup.

### Fragment shader

Fragment shaders may now be passed the primitive info from a mesh shader the same was as they are passed vertex inputs, for example `fn fs_main(vertex: VertexOutput, primitive: PrimitiveOutput)`. The primitive state is part of the fragment input and must match the output of the mesh shader in the pipeline.
Fragment shaders can access vertex output data as if it is from a vertex shader. They can also access primitive output data, provided the input is decorated with `@per_primitive`. The `@per_primitive` attribute can be applied to a value directly, such as `@per_primitive @location(1) value: vec4<f32>`, to a struct such as `@per_primitive primitive_input: PrimitiveInput` where `PrimitiveInput` is a struct containing fields decorated with `@location` and `@builtin`, or to members of a struct that are themselves decorated with `@location` or `@builtin`.

The primitive state is part of the fragment input and must match the output of the mesh shader in the pipeline. Using `@per_primitive` also requires enabling the mesh shader extension. Additionally, the locations of vertex and primitive input cannot overlap.

### Full example

Expand All @@ -115,9 +119,9 @@ The following is a full example of WGSL shaders that could be used to create a m
enable mesh_shading;

const positions = array(
vec4(0.,-1.,0.,1.),
vec4(-1.,1.,0.,1.),
vec4(1.,1.,0.,1.)
vec4(0.,1.,0.,1.),
vec4(-1.,-1.,0.,1.),
vec4(1.,-1.,0.,1.)
);
const colors = array(
vec4(0.,1.,0.,1.),
Expand All @@ -128,7 +132,7 @@ struct TaskPayload {
colorMask: vec4<f32>,
visible: bool,
}
var<workgroup> taskPayload: TaskPayload;
var<task_payload> taskPayload: TaskPayload;
var<workgroup> workgroupData: f32;
struct VertexOutput {
@builtin(position) position: vec4<f32>,
Expand All @@ -137,14 +141,12 @@ struct VertexOutput {
struct PrimitiveOutput {
@builtin(triangle_indices) index: vec3<u32>,
@builtin(cull_primitive) cull: bool,
@location(1) colorMask: vec4<f32>,
@per_primitive @location(1) colorMask: vec4<f32>,
}
struct PrimitiveInput {
@location(1) colorMask: vec4<f32>,
@per_primitive @location(1) colorMask: vec4<f32>,
}
fn test_function(input: u32) {

}
@task
@payload(taskPayload)
@workgroup_size(1)
Expand All @@ -163,8 +165,6 @@ fn ms_main(@builtin(local_invocation_index) index: u32, @builtin(global_invocati
workgroupData = 2.0;
var v: VertexOutput;

test_function(1);

v.position = positions[0];
v.color = colors[0] * taskPayload.colorMask;
setVertex(0, v);
Expand Down
58 changes: 13 additions & 45 deletions examples/features/src/mesh_shader/mod.rs
Original file line number Diff line number Diff line change
@@ -1,37 +1,4 @@
use std::{io::Write, process::Stdio};

// Same as in mesh shader tests
fn compile_glsl(
device: &wgpu::Device,
data: &[u8],
shader_stage: &'static str,
) -> wgpu::ShaderModule {
let cmd = std::process::Command::new("glslc")
.args([
&format!("-fshader-stage={shader_stage}"),
"-",
"-o",
"-",
"--target-env=vulkan1.2",
"--target-spv=spv1.4",
])
.stdin(Stdio::piped())
.stdout(Stdio::piped())
.spawn()
.expect("Failed to call glslc");
cmd.stdin.as_ref().unwrap().write_all(data).unwrap();
println!("{shader_stage}");
let output = cmd.wait_with_output().expect("Error waiting for glslc");
assert!(output.status.success());
unsafe {
device.create_shader_module_passthrough(wgpu::ShaderModuleDescriptorPassthrough::SpirV(
wgpu::ShaderModuleDescriptorSpirV {
label: None,
source: wgpu::util::make_spirv_raw(&output.stdout),
},
))
}
}
use wgpu::include_wgsl;

pub struct Example {
pipeline: wgpu::RenderPipeline,
Expand All @@ -48,27 +15,28 @@ impl crate::framework::Example for Example {
bind_group_layouts: &[],
push_constant_ranges: &[],
});
let (ts, ms, fs) = (
compile_glsl(device, include_bytes!("shader.task"), "task"),
compile_glsl(device, include_bytes!("shader.mesh"), "mesh"),
compile_glsl(device, include_bytes!("shader.frag"), "frag"),
);
let shader_module = unsafe {
device.create_shader_module_trusted(
include_wgsl!("shader.wgsl"),
wgpu::ShaderRuntimeChecks::unchecked(),
)
};
let pipeline = device.create_mesh_pipeline(&wgpu::MeshPipelineDescriptor {
label: None,
layout: Some(&pipeline_layout),
task: Some(wgpu::TaskState {
module: &ts,
entry_point: Some("main"),
module: &shader_module,
entry_point: Some("ts_main"),
compilation_options: Default::default(),
}),
mesh: wgpu::MeshState {
module: &ms,
entry_point: Some("main"),
module: &shader_module,
entry_point: Some("ms_main"),
compilation_options: Default::default(),
},
fragment: Some(wgpu::FragmentState {
module: &fs,
entry_point: Some("main"),
module: &shader_module,
entry_point: Some("fs_main"),
compilation_options: Default::default(),
targets: &[Some(config.view_formats[0].into())],
}),
Expand Down
71 changes: 71 additions & 0 deletions examples/features/src/mesh_shader/shader.wgsl
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
enable mesh_shading;

const positions = array(
vec4(0.,1.,0.,1.),
vec4(-1.,-1.,0.,1.),
vec4(1.,-1.,0.,1.)
);
const colors = array(
vec4(0.,1.,0.,1.),
vec4(0.,0.,1.,1.),
vec4(1.,0.,0.,1.)
);
struct TaskPayload {
colorMask: vec4<f32>,
visible: bool,
}
var<task_payload> taskPayload: TaskPayload;
var<workgroup> workgroupData: f32;
struct VertexOutput {
@builtin(position) position: vec4<f32>,
@location(0) color: vec4<f32>,
}
struct PrimitiveOutput {
@builtin(triangle_indices) index: vec3<u32>,
@builtin(cull_primitive) cull: bool,
@per_primitive @location(1) colorMask: vec4<f32>,
}
struct PrimitiveInput {
@per_primitive @location(1) colorMask: vec4<f32>,
}

@task
@payload(taskPayload)
@workgroup_size(1)
fn ts_main() -> @builtin(mesh_task_size) vec3<u32> {
workgroupData = 1.0;
taskPayload.colorMask = vec4(1.0, 1.0, 0.0, 1.0);
taskPayload.visible = true;
return vec3(3, 1, 1);
}
@mesh
@payload(taskPayload)
@vertex_output(VertexOutput, 3) @primitive_output(PrimitiveOutput, 1)
@workgroup_size(1)
fn ms_main(@builtin(local_invocation_index) index: u32, @builtin(global_invocation_id) id: vec3<u32>) {
setMeshOutputs(3, 1);
workgroupData = 2.0;
var v: VertexOutput;

v.position = positions[0];
v.color = colors[0] * taskPayload.colorMask;
setVertex(0, v);

v.position = positions[1];
v.color = colors[1] * taskPayload.colorMask;
setVertex(1, v);

v.position = positions[2];
v.color = colors[2] * taskPayload.colorMask;
setVertex(2, v);

var p: PrimitiveOutput;
p.index = vec3<u32>(0, 1, 2);
p.cull = !taskPayload.visible;
p.colorMask = vec4<f32>(1.0, 0.0, 1.0, 1.0);
setPrimitive(0, p);
}
@fragment
fn fs_main(vertex: VertexOutput, primitive: PrimitiveInput) -> @location(0) vec4<f32> {
return vertex.color * primitive.colorMask;
}
25 changes: 25 additions & 0 deletions naga-cli/src/bin/naga.rs
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,12 @@ struct Args {
#[argh(option)]
shader_model: Option<ShaderModelArg>,

/// the SPIR-V version to use if targeting SPIR-V
///
/// For example, 1.0, 1.4, etc
#[argh(option)]
spirv_version: Option<SpirvVersionArg>,

/// the shader stage, for example 'frag', 'vert', or 'compute'.
/// if the shader stage is unspecified it will be derived from
/// the file extension.
Expand Down Expand Up @@ -189,6 +195,22 @@ impl FromStr for ShaderModelArg {
}
}

#[derive(Debug, Clone)]
struct SpirvVersionArg(u8, u8);

impl FromStr for SpirvVersionArg {
type Err = String;

fn from_str(s: &str) -> Result<Self, Self::Err> {
let dot = s
.find(".")
.ok_or_else(|| "Missing dot separator".to_owned())?;
let major = s[..dot].parse::<u8>().map_err(|e| e.to_string())?;
let minor = s[dot + 1..].parse::<u8>().map_err(|e| e.to_string())?;
Ok(Self(major, minor))
}
}

/// Newtype so we can implement [`FromStr`] for `ShaderSource`.
#[derive(Debug, Clone, Copy)]
struct ShaderStage(naga::ShaderStage);
Expand Down Expand Up @@ -465,6 +487,9 @@ fn run() -> anyhow::Result<()> {
if let Some(ref version) = args.metal_version {
params.msl.lang_version = version.0;
}
if let Some(ref version) = args.spirv_version {
params.spv_out.lang_version = (version.0, version.1);
}
params.keep_coordinate_space = args.keep_coordinate_space;

params.dot.cfg_only = args.dot_cfg_only;
Expand Down
19 changes: 19 additions & 0 deletions naga/src/back/dot/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -307,6 +307,25 @@ impl StatementGraph {
crate::RayQueryFunction::Terminate => "RayQueryTerminate",
}
}
S::MeshFunction(crate::MeshFunction::SetMeshOutputs {
vertex_count,
primitive_count,
}) => {
self.dependencies.push((id, vertex_count, "vertex_count"));
self.dependencies
.push((id, primitive_count, "primitive_count"));
"SetMeshOutputs"
}
S::MeshFunction(crate::MeshFunction::SetVertex { index, value }) => {
self.dependencies.push((id, index, "index"));
self.dependencies.push((id, value, "value"));
"SetVertex"
}
S::MeshFunction(crate::MeshFunction::SetPrimitive { index, value }) => {
self.dependencies.push((id, index, "index"));
self.dependencies.push((id, value, "value"));
"SetPrimitive"
}
S::SubgroupBallot { result, predicate } => {
if let Some(predicate) = predicate {
self.dependencies.push((id, predicate, "predicate"));
Expand Down
1 change: 1 addition & 0 deletions naga/src/back/glsl/features.rs
Original file line number Diff line number Diff line change
Expand Up @@ -610,6 +610,7 @@ impl<W> Writer<'_, W> {
interpolation,
sampling,
blend_src,
per_primitive: _,
} => {
if interpolation == Some(Interpolation::Linear) {
self.features.request(Features::NOPERSPECTIVE_QUALIFIER);
Expand Down
Loading
Loading