Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,12 @@ Bottom level categories:

## Unreleased

### Bug Fixes

#### DX12

- Fix device creation failures for devices that do not support mesh shaders. By @vorporeal in [#8297](https://github.com/gfx-rs/wgpu/pull/8297).

## v27.0.0 (2025-10-01)

### Major Changes
Expand Down
12 changes: 9 additions & 3 deletions wgpu-hal/src/dx12/command.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1338,14 +1338,17 @@ impl crate::CommandEncoder for super::CommandEncoder {

let cmd_list6: Direct3D12::ID3D12GraphicsCommandList6 =
self.list.as_ref().unwrap().cast().unwrap();
let cmd_signature = &self
let Some(cmd_signature) = &self
.pass
.layout
.special_constants
.as_ref()
.and_then(|sc| sc.indirect_cmd_signatures.as_ref())
.unwrap_or_else(|| &self.shared.cmd_signatures)
.draw_mesh;
.draw_mesh
else {
panic!("Feature `MESH_SHADING` not enabled");
};
unsafe {
cmd_list6.ExecuteIndirect(cmd_signature, draw_count, &buffer.resource, offset, None, 0);
}
Expand Down Expand Up @@ -1401,9 +1404,12 @@ impl crate::CommandEncoder for super::CommandEncoder {
self.prepare_dispatch([0; 3]);
let cmd_list6: Direct3D12::ID3D12GraphicsCommandList6 =
self.list.as_ref().unwrap().cast().unwrap();
let Some(ref command_signature) = self.shared.cmd_signatures.draw_mesh else {
panic!("Feature `MESH_SHADING` not enabled");
};
unsafe {
cmd_list6.ExecuteIndirect(
&self.shared.cmd_signatures.draw_mesh,
command_signature,
max_count,
&buffer.resource,
offset,
Expand Down
64 changes: 42 additions & 22 deletions wgpu-hal/src/dx12/device.rs
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,24 @@ impl super::Device {
// maximum number of CBV/SRV/UAV descriptors in heap for Tier 1
let capacity_views = limits.max_non_sampler_bindings as u64;

let draw_mesh = if features
.features_wgpu
.contains(wgt::FeaturesWGPU::EXPERIMENTAL_MESH_SHADER)
{
Some(Self::create_command_signature(
&raw,
None,
size_of::<wgt::DispatchIndirectArgs>(),
&[Direct3D12::D3D12_INDIRECT_ARGUMENT_DESC {
Type: Direct3D12::D3D12_INDIRECT_ARGUMENT_TYPE_DISPATCH_MESH,
..Default::default()
}],
0,
)?)
} else {
None
};

let shared = super::DeviceShared {
adapter,
zero_buffer,
Expand All @@ -140,16 +158,7 @@ impl super::Device {
}],
0,
)?,
draw_mesh: Self::create_command_signature(
&raw,
None,
size_of::<wgt::DispatchIndirectArgs>(),
&[Direct3D12::D3D12_INDIRECT_ARGUMENT_DESC {
Type: Direct3D12::D3D12_INDIRECT_ARGUMENT_TYPE_DISPATCH_MESH,
..Default::default()
}],
0,
)?,
draw_mesh,
dispatch: Self::create_command_signature(
&raw,
None,
Expand Down Expand Up @@ -1371,47 +1380,58 @@ impl crate::Device for super::Device {
};
size_of_val(&first_vertex) + size_of_val(&first_instance) + size_of_val(&other)
};
Some(super::CommandSignatures {
draw: Self::create_command_signature(

let draw_mesh = if self
.features
.features_wgpu
.contains(wgt::FeaturesWGPU::EXPERIMENTAL_MESH_SHADER)
{
Some(Self::create_command_signature(
&self.raw,
Some(&raw),
special_constant_buffer_args_len + size_of::<wgt::DrawIndirectArgs>(),
special_constant_buffer_args_len + size_of::<wgt::DispatchIndirectArgs>(),
&[
constant_indirect_argument_desc,
Direct3D12::D3D12_INDIRECT_ARGUMENT_DESC {
Type: Direct3D12::D3D12_INDIRECT_ARGUMENT_TYPE_DRAW,
Type: Direct3D12::D3D12_INDIRECT_ARGUMENT_TYPE_DISPATCH_MESH,
..Default::default()
},
],
0,
)?,
draw_indexed: Self::create_command_signature(
)?)
} else {
None
};

Some(super::CommandSignatures {
draw: Self::create_command_signature(
&self.raw,
Some(&raw),
special_constant_buffer_args_len
+ size_of::<wgt::DrawIndexedIndirectArgs>(),
special_constant_buffer_args_len + size_of::<wgt::DrawIndirectArgs>(),
&[
constant_indirect_argument_desc,
Direct3D12::D3D12_INDIRECT_ARGUMENT_DESC {
Type: Direct3D12::D3D12_INDIRECT_ARGUMENT_TYPE_DRAW_INDEXED,
Type: Direct3D12::D3D12_INDIRECT_ARGUMENT_TYPE_DRAW,
..Default::default()
},
],
0,
)?,
draw_mesh: Self::create_command_signature(
draw_indexed: Self::create_command_signature(
&self.raw,
Some(&raw),
special_constant_buffer_args_len + size_of::<wgt::DispatchIndirectArgs>(),
special_constant_buffer_args_len
+ size_of::<wgt::DrawIndexedIndirectArgs>(),
&[
constant_indirect_argument_desc,
Direct3D12::D3D12_INDIRECT_ARGUMENT_DESC {
Type: Direct3D12::D3D12_INDIRECT_ARGUMENT_TYPE_DISPATCH_MESH,
Type: Direct3D12::D3D12_INDIRECT_ARGUMENT_TYPE_DRAW_INDEXED,
..Default::default()
},
],
0,
)?,
draw_mesh,
dispatch: Self::create_command_signature(
&self.raw,
Some(&raw),
Expand Down
2 changes: 1 addition & 1 deletion wgpu-hal/src/dx12/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -659,7 +659,7 @@ struct Idler {
struct CommandSignatures {
draw: Direct3D12::ID3D12CommandSignature,
draw_indexed: Direct3D12::ID3D12CommandSignature,
draw_mesh: Direct3D12::ID3D12CommandSignature,
draw_mesh: Option<Direct3D12::ID3D12CommandSignature>,
dispatch: Direct3D12::ID3D12CommandSignature,
}

Expand Down
Loading