Gate DX12 mesh shader command signature initialization on device support. (#8297)

This commit is contained in:
David Stern 2025-10-03 20:41:58 -04:00 committed by GitHub
parent 482a983e10
commit b3c6a0b5cc
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 59 additions and 27 deletions

View File

@ -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

View File

@ -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);
}
@ -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,

View File

@ -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,
@ -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,
@ -1371,6 +1380,29 @@ impl crate::Device for super::Device {
};
size_of_val(&first_vertex) + size_of_val(&first_instance) + size_of_val(&other)
};
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::DispatchIndirectArgs>(),
&[
constant_indirect_argument_desc,
Direct3D12::D3D12_INDIRECT_ARGUMENT_DESC {
Type: Direct3D12::D3D12_INDIRECT_ARGUMENT_TYPE_DISPATCH_MESH,
..Default::default()
},
],
0,
)?)
} else {
None
};
Some(super::CommandSignatures {
draw: Self::create_command_signature(
&self.raw,
@ -1399,19 +1431,7 @@ impl crate::Device for super::Device {
],
0,
)?,
draw_mesh: Self::create_command_signature(
&self.raw,
Some(&raw),
special_constant_buffer_args_len + size_of::<wgt::DispatchIndirectArgs>(),
&[
constant_indirect_argument_desc,
Direct3D12::D3D12_INDIRECT_ARGUMENT_DESC {
Type: Direct3D12::D3D12_INDIRECT_ARGUMENT_TYPE_DISPATCH_MESH,
..Default::default()
},
],
0,
)?,
draw_mesh,
dispatch: Self::create_command_signature(
&self.raw,
Some(&raw),

View File

@ -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,
}