Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
55 commits
Select commit Hold shift + click to select a range
0622940
[spv-out] Support for mesh shaders
cwfitzgerald Dec 12, 2025
dc69d86
Update mesh_shader.rs
inner-daemons Dec 13, 2025
dfd360f
Tried one thing
inner-daemons Dec 14, 2025
c1973fe
Updated snapshots
inner-daemons Dec 14, 2025
50c2aa9
Tried another thing
inner-daemons Dec 14, 2025
7749867
Removed per primitive stuff + cull primitive
inner-daemons Dec 14, 2025
ca3f93a
Testing new thing
inner-daemons Dec 14, 2025
4fbfc60
Ahh well I think I'm done for the night
inner-daemons Dec 14, 2025
7551f6a
Slight improvements
inner-daemons Dec 14, 2025
3225030
Fixed another comment
inner-daemons Dec 14, 2025
c34c474
Added note on feature
inner-daemons Dec 14, 2025
18164ee
Preparing for merge as is
inner-daemons Dec 14, 2025
0b9bf09
Ok I'm tired
inner-daemons Dec 14, 2025
da72786
Blah blah blah
inner-daemons Dec 14, 2025
8862d56
Updated loop logic
inner-daemons Dec 14, 2025
0286af7
Tried something else
inner-daemons Dec 14, 2025
7cc51c9
Tried another little fix
inner-daemons Dec 14, 2025
3818efe
Tried something new
inner-daemons Dec 14, 2025
ea50cb0
Told it to skip instead of expect a failure
inner-daemons Dec 14, 2025
8d9a451
Redocumented feature, made tests run on AMD
inner-daemons Dec 15, 2025
3edc37c
Removed obseleted files, updated changelog, updated shaders
inner-daemons Dec 15, 2025
6ffd2d5
Added task shader to the changelog entry
inner-daemons Dec 15, 2025
094a5ac
Enabled debugigng
inner-daemons Dec 15, 2025
6417327
Fixed typo
inner-daemons Dec 15, 2025
2e863e2
Trying with better aligned task payload stuff
inner-daemons Dec 15, 2025
05eada6
Made the tests actually run on LLVMPIPE
inner-daemons Dec 15, 2025
6dc1fd0
Testing on LLVMPIPE if removing task payload reads does anything
inner-daemons Dec 15, 2025
883a443
Undid test that didnt work
inner-daemons Dec 15, 2025
3457ed5
Tried making it write a barrier
inner-daemons Dec 15, 2025
cad1bdf
Wrote another barrier I guess
inner-daemons Dec 15, 2025
4927043
Gonna see if this one does anything
inner-daemons Dec 15, 2025
19af909
Jeez im stupid
inner-daemons Dec 15, 2025
3d7327f
Removed debugging files
inner-daemons Dec 15, 2025
c4574e7
Fixed the example shader sorta
inner-daemons Dec 15, 2025
ff46752
Blah blah blah
inner-daemons Dec 15, 2025
a5324ee
Merge remote-tracking branch 'upstream/trunk' into mesh-shading/spv-w…
inner-daemons Dec 15, 2025
c36f9f8
Final cleanup
inner-daemons Dec 15, 2025
4c29d13
Added new mesh shader tasks
inner-daemons Dec 16, 2025
c08d00a
Fixed test
inner-daemons Dec 16, 2025
7703aef
Fixed some test shenanigans
inner-daemons Dec 16, 2025
90624c8
Seeing if this breaks anything
inner-daemons Dec 16, 2025
307f908
Tried to fix one issue
inner-daemons Dec 16, 2025
a99af0f
Initial commit setting up tests
inner-daemons Dec 16, 2025
1460a93
Merge branch 'mesh-shading/spv-write' into mesh-shading/msl-write
inner-daemons Dec 16, 2025
126ad72
Updated example & test to use wgsl on metal
inner-daemons Dec 16, 2025
605cf49
Pushing rq
inner-daemons Dec 16, 2025
47f67e9
Some more work
inner-daemons Dec 16, 2025
9401a59
A tiny bit more
inner-daemons Dec 16, 2025
7732b5d
Now generating mostly valid but incomplete code
inner-daemons Dec 16, 2025
1eb263d
Pretty much done except the workgroup issue
inner-daemons Dec 16, 2025
e51d1ac
Stuff works now !!!
inner-daemons Dec 16, 2025
1abc4d6
Merge remote-tracking branch 'upstream/trunk' into mesh-shading/msl-w…
inner-daemons Dec 17, 2025
c9872be
Updated snapshots
inner-daemons Dec 17, 2025
92e9780
Fixed point writing
inner-daemons Dec 17, 2025
ccbf784
Made it check for MSL version before writing mesh shaders
inner-daemons Dec 17, 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
22 changes: 1 addition & 21 deletions examples/features/src/mesh_shader/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,18 +38,6 @@ fn compile_hlsl(device: &wgpu::Device, entry: &str, stage_str: &str) -> wgpu::Sh
}
}

fn compile_msl(device: &wgpu::Device, entry: &str) -> wgpu::ShaderModule {
unsafe {
device.create_shader_module_passthrough(wgpu::ShaderModuleDescriptorPassthrough {
entry_point: entry.to_owned(),
label: None,
msl: Some(std::borrow::Cow::Borrowed(include_str!("shader.metal"))),
num_workgroups: (1, 1, 1),
..Default::default()
})
}
}

pub struct Example {
pipeline: wgpu::RenderPipeline,
}
Expand All @@ -61,7 +49,7 @@ impl crate::framework::Example for Example {
_queue: &wgpu::Queue,
) -> Self {
let (ts, ms, fs, ts_name, ms_name, fs_name) = match adapter.get_info().backend {
wgpu::Backend::Vulkan => (
wgpu::Backend::Vulkan | wgpu::Backend::Metal => (
compile_wgsl(device),
compile_wgsl(device),
compile_wgsl(device),
Expand All @@ -77,14 +65,6 @@ impl crate::framework::Example for Example {
"main",
"main",
),
wgpu::Backend::Metal => (
compile_msl(device, "taskShader"),
compile_msl(device, "meshShader"),
compile_msl(device, "fragShader"),
"main",
"main",
"main",
),
_ => panic!("Example can currently only run on vulkan, dx12 or metal"),
};
let pipeline_layout = device.create_pipeline_layout(&wgpu::PipelineLayoutDescriptor {
Expand Down
77 changes: 0 additions & 77 deletions examples/features/src/mesh_shader/shader.metal

This file was deleted.

30 changes: 26 additions & 4 deletions naga/src/back/msl/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,7 @@ enum ResolvedBinding {
interpolation: Option<ResolvedInterpolation>,
},
Resource(BindTarget),
Payload,
}

#[derive(Copy, Clone)]
Expand Down Expand Up @@ -237,6 +238,8 @@ pub enum Error {
ResolveArraySizeError(#[from] crate::proc::ResolveArraySizeError),
#[error("entry point with stage {0:?} and name '{1}' not found")]
EntryPointNotFound(ir::ShaderStage, String),
#[error("Cannot use mesh shader syntax prior to MSL 3.0")]
UnsupportedMeshShader,
}

#[derive(Clone, Debug, PartialEq, thiserror::Error)]
Expand Down Expand Up @@ -275,6 +278,9 @@ enum LocationMode {
/// Output from the fragment shader.
FragmentOutput,

/// Output from the mesh shader.
MeshOutput,

/// Compute shader input or output.
Uniform,
}
Expand Down Expand Up @@ -551,7 +557,7 @@ impl Options {
interpolation,
sampling,
blend_src,
per_primitive: _,
per_primitive,
} => match mode {
LocationMode::VertexInput => Ok(ResolvedBinding::Attribute(location)),
LocationMode::FragmentOutput => {
Expand All @@ -563,7 +569,9 @@ impl Options {
blend_src,
})
}
LocationMode::VertexOutput | LocationMode::FragmentInput => {
LocationMode::VertexOutput
| LocationMode::FragmentInput
| LocationMode::MeshOutput => {
Ok(ResolvedBinding::User {
prefix: if self.spirv_cross_compatibility {
"locn"
Expand All @@ -577,7 +585,11 @@ impl Options {
// sampling is `None` only for Flat interpolation.
let interpolation = interpolation.unwrap();
let sampling = sampling.unwrap_or(crate::Sampling::Center);
Some(ResolvedInterpolation::from_binding(interpolation, sampling))
Some(ResolvedInterpolation::from_binding(
interpolation,
sampling,
per_primitive,
))
},
})
}
Expand Down Expand Up @@ -714,6 +726,7 @@ impl ResolvedBinding {
Bi::CullPrimitive => "primitive_culled",
// TODO: figure out how to make this written as a function call
Bi::PointIndex | Bi::LineIndices | Bi::TriangleIndices => unimplemented!(),
// These aren't real builtins that backends are aware of
Bi::MeshTaskSize
| Bi::VertexCount
| Bi::PrimitiveCount
Expand Down Expand Up @@ -755,17 +768,26 @@ impl ResolvedBinding {
return Err(Error::UnimplementedBindTarget(target.clone()));
}
}
Self::Payload => write!(out, "payload")?,
}
write!(out, "]]")?;
Ok(())
}
}

impl ResolvedInterpolation {
const fn from_binding(interpolation: crate::Interpolation, sampling: crate::Sampling) -> Self {
const fn from_binding(
interpolation: crate::Interpolation,
sampling: crate::Sampling,
per_primitive: bool,
) -> Self {
use crate::Interpolation as I;
use crate::Sampling as S;

if per_primitive {
return Self::Flat;
}

match (interpolation, sampling) {
(I::Perspective, S::Center) => Self::CenterPerspective,
(I::Perspective, S::Centroid) => Self::CentroidPerspective,
Expand Down
Loading