diff --git a/crates/spirv-std/src/indirect_command.rs b/crates/spirv-std/src/indirect_command.rs new file mode 100644 index 0000000000..02a1ee956f --- /dev/null +++ b/crates/spirv-std/src/indirect_command.rs @@ -0,0 +1,135 @@ +use glam::UVec3; + +#[doc = ""] +pub type DeviceSize = u64; +#[doc = ""] +pub type DeviceAddress = u64; + +#[repr(C)] +#[derive(Copy, Clone, Debug, Default)] +#[doc = ""] +pub struct DrawIndirectCommand { + pub vertex_count: u32, + pub instance_count: u32, + pub first_vertex: u32, + pub first_instance: u32, +} + +#[repr(C)] +#[derive(Copy, Clone, Debug, Default)] +#[doc = ""] +pub struct DrawIndexedIndirectCommand { + pub index_count: u32, + pub instance_count: u32, + pub first_index: u32, + pub vertex_offset: i32, + pub first_instance: u32, +} + +#[repr(C)] +#[derive(Copy, Clone, Debug, Default)] +#[doc = ""] +pub struct DispatchIndirectCommand { + pub x: u32, + pub y: u32, + pub z: u32, +} + +impl From for DispatchIndirectCommand { + fn from(v: UVec3) -> Self { + Self { + x: v.x, + y: v.y, + z: v.z, + } + } +} + +impl From for UVec3 { + fn from(v: DispatchIndirectCommand) -> Self { + Self { + x: v.x, + y: v.y, + z: v.z, + } + } +} + +#[repr(C)] +#[derive(Copy, Clone, Debug, Default)] +#[doc = ""] +pub struct DrawMeshTasksIndirectCommandEXT { + pub group_count_x: u32, + pub group_count_y: u32, + pub group_count_z: u32, +} + +impl From for DrawMeshTasksIndirectCommandEXT { + fn from(v: UVec3) -> Self { + Self { + group_count_x: v.x, + group_count_y: v.y, + group_count_z: v.z, + } + } +} + +impl From for UVec3 { + fn from(v: DrawMeshTasksIndirectCommandEXT) -> Self { + Self { + x: v.group_count_x, + y: v.group_count_y, + z: v.group_count_z, + } + } +} + +#[repr(C)] +#[derive(Copy, Clone, Debug, Default)] +#[doc = ""] +pub struct TraceRaysIndirectCommandKHR { + pub width: u32, + pub height: u32, + pub depth: u32, +} + +impl From for TraceRaysIndirectCommandKHR { + fn from(v: UVec3) -> Self { + Self { + width: v.x, + height: v.y, + depth: v.z, + } + } +} + +impl From for UVec3 { + fn from(v: TraceRaysIndirectCommandKHR) -> Self { + Self { + x: v.width, + y: v.height, + z: v.depth, + } + } +} + +#[repr(C)] +#[derive(Copy, Clone, Debug, Default)] +#[doc = ""] +#[must_use] +pub struct TraceRaysIndirectCommand2KHR { + pub raygen_shader_record_address: DeviceAddress, + pub raygen_shader_record_size: DeviceSize, + pub miss_shader_binding_table_address: DeviceAddress, + pub miss_shader_binding_table_size: DeviceSize, + pub miss_shader_binding_table_stride: DeviceSize, + pub hit_shader_binding_table_address: DeviceAddress, + pub hit_shader_binding_table_size: DeviceSize, + pub hit_shader_binding_table_stride: DeviceSize, + pub callable_shader_binding_table_address: DeviceAddress, + pub callable_shader_binding_table_size: DeviceSize, + pub callable_shader_binding_table_stride: DeviceSize, + pub width: u32, + pub height: u32, + pub depth: u32, +} diff --git a/crates/spirv-std/src/lib.rs b/crates/spirv-std/src/lib.rs index 175099537a..f50e719fe0 100644 --- a/crates/spirv-std/src/lib.rs +++ b/crates/spirv-std/src/lib.rs @@ -99,6 +99,7 @@ pub mod arch; pub mod byte_addressable_buffer; pub mod float; pub mod image; +pub mod indirect_command; pub mod integer; pub mod memory; pub mod number;