Skip to content
Open
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
76 changes: 0 additions & 76 deletions crates/spirv-std/src/arch.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,25 +8,6 @@ use crate::Integer;
use crate::{Scalar, SignedInteger, UnsignedInteger, Vector};
#[cfg(target_arch = "spirv")]
use core::arch::asm;
use glam::UVec2;

mod atomics;
mod barrier;
mod demote_to_helper_invocation_ext;
mod derivative;
mod mesh_shading;
mod primitive;
mod ray_tracing;
mod subgroup;

pub use atomics::*;
pub use barrier::*;
pub use demote_to_helper_invocation_ext::*;
pub use derivative::*;
pub use mesh_shading::*;
pub use primitive::*;
pub use ray_tracing::*;
pub use subgroup::*;

/// Result is true if any component of `vector` is true, otherwise result is
/// false.
Expand Down Expand Up @@ -132,63 +113,6 @@ pub unsafe fn vector_insert_dynamic<T: Scalar, V: Vector<T, N>, const N: usize>(
}
}

/// Fragment-shader discard. Equivalvent to `discard()` from GLSL
///
/// Ceases all further processing in any invocation that executes it: Only
/// instructions these invocations executed before [kill] have observable side
/// effects.
#[spirv_std_macros::gpu_only]
#[doc(alias = "OpKill", alias = "discard")]
#[allow(clippy::empty_loop)]
pub fn kill() -> ! {
unsafe { asm!("OpKill", options(noreturn)) }
}

/// Read from the shader clock with either the `Subgroup` or `Device` scope.
///
/// See:
/// <https://htmlpreview.github.io/?https://github.com/KhronosGroup/SPIRV-Registry/blob/master/extensions/KHR/SPV_KHR_shader_clock.html>
#[spirv_std_macros::gpu_only]
#[doc(alias = "OpReadClockKHR")]
pub fn read_clock_khr<const SCOPE: u32>() -> u64 {
unsafe {
let mut result: u64;

asm! {
"%uint = OpTypeInt 32 0",
"%scope = OpConstant %uint {scope}",
"{result} = OpReadClockKHR typeof*{result} %scope",
result = out(reg) result,
scope = const SCOPE,
};

result
}
}

/// Like `read_clock_khr` but returns a vector to avoid requiring the `Int64`
/// capability. It returns a 'vector of two-components of 32-bit unsigned
/// integer type with the first component containing the 32 least significant
/// bits and the second component containing the 32 most significant bits.'
#[spirv_std_macros::gpu_only]
#[doc(alias = "OpReadClockKHR")]
pub fn read_clock_uvec2_khr<const SCOPE: u32>() -> UVec2 {
unsafe {
let mut result = UVec2::default();

asm! {
"%uint = OpTypeInt 32 0",
"%scope = OpConstant %uint {scope}",
"%result = OpReadClockKHR typeof*{result} %scope",
"OpStore {result} %result",
result = in(reg) &mut result,
scope = const SCOPE,
};

result
}
}

#[cfg(target_arch = "spirv")]
unsafe fn call_glsl_op_with_ints<T: Integer, const OP: u32>(a: T, b: T) -> T {
unsafe {
Expand Down
92 changes: 0 additions & 92 deletions crates/spirv-std/src/arch/ray_tracing.rs

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
//! Intrinsics for atomic operations

#[cfg(target_arch = "spirv")]
use core::arch::asm;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
//! Intrinsics for barrier operations

#[cfg(target_arch = "spirv")]
use core::arch::asm;

Expand Down
22 changes: 22 additions & 0 deletions crates/spirv-std/src/fragment/mod.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
//! Intrinsics for fragment shaders

#[cfg(target_arch = "spirv")]
use core::arch::asm;

mod demote_to_helper_invocation;
mod derivative;

pub use demote_to_helper_invocation::*;
pub use derivative::*;

/// Fragment-shader discard. Equivalent to `discard()` from GLSL
///
/// Ceases all further processing in any invocation that executes it: Only
/// instructions these invocations executed before [kill] have observable side
/// effects.
#[spirv_std_macros::gpu_only]
#[doc(alias = "OpKill", alias = "discard")]
#[allow(clippy::empty_loop)]
pub fn kill() -> ! {
unsafe { asm!("OpKill", options(noreturn)) }
}
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
//! Intrinsics for geometry shaders

#[cfg(target_arch = "spirv")]
use core::arch::asm;

Expand Down
4 changes: 2 additions & 2 deletions crates/spirv-std/src/image.rs
Original file line number Diff line number Diff line change
Expand Up @@ -446,7 +446,7 @@ impl<
coordinate = in(reg) &coordinate,
depth_reference = in(reg) &depth_reference,
lod = in(reg) &lod,
)
);
}
result
}
Expand Down Expand Up @@ -698,7 +698,7 @@ impl<
coordinate = in(reg) &coordinate,
depth_reference = in(reg) &depth_reference,
lod = in(reg) &lod,
)
);
}
result
}
Expand Down
9 changes: 8 additions & 1 deletion crates/spirv-std/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -92,18 +92,25 @@ pub use macros::spirv;
pub use macros::{debug_printf, debug_printfln};

pub mod arch;
pub mod atomic;
pub mod barrier;
pub mod byte_addressable_buffer;
pub mod debug_printf;
pub mod float;
pub mod fragment;
pub mod geometry;
pub mod image;
pub mod indirect_command;
pub mod matrix;
pub mod memory;
pub mod mesh;
pub mod ray_tracing;
mod runtime_array;
mod sampler;
mod scalar;
mod scalar_or_vector;
pub mod shader_clock;
pub mod subgroup;
pub mod task;
mod typed_buffer;
mod vector;

Expand Down
38 changes: 38 additions & 0 deletions crates/spirv-std/src/mesh.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
//! Intrinsics for mesh shaders

#[cfg(target_arch = "spirv")]
use core::arch::asm;

/// Sets the actual output size of the primitives and vertices that the mesh shader
/// workgroup will emit upon completion.
///
/// 'Vertex Count' must be a 32-bit unsigned integer value.
/// It defines the array size of per-vertex outputs.
///
/// 'Primitive Count' must a 32-bit unsigned integer value.
/// It defines the array size of per-primitive outputs.
///
/// The arguments are taken from the first invocation in each workgroup.
/// Any invocation must execute this instruction no more than once and under
/// uniform control flow.
/// There must not be any control flow path to an output write that is not preceded
/// by this instruction.
///
/// This instruction is only valid in the *`MeshEXT`* Execution Model.
///
/// # Safety
/// * Must be called **exactly once** in mesh shaders
/// * Must be called in uniform control flow
/// * Must not write any output before this instruction in invoked
#[spirv_std_macros::gpu_only]
#[doc(alias = "OpSetMeshOutputsEXT")]
#[inline]
pub unsafe fn set_mesh_outputs_ext(vertex_count: u32, primitive_count: u32) {
unsafe {
asm! {
"OpSetMeshOutputsEXT {vertex_count} {primitive_count}",
vertex_count = in(reg) vertex_count,
primitive_count = in(reg) primitive_count,
}
}
}
Loading
Loading