Skip to main content

spirv_std/
lib.rs

1#![no_std]
2#![cfg_attr(
3    target_arch = "spirv",
4    allow(internal_features),
5    feature(asm_experimental_arch, core_intrinsics, lang_items, rustc_attrs)
6)]
7#![cfg_attr(feature = "adt_const_params", feature(adt_const_params))]
8// FIXME(eddyb) update/review these lints.
9//
10// BEGIN - Embark standard lints v0.4
11// do not change or add/remove here, but one can add exceptions after this section
12// for more info see: <https://github.com/EmbarkStudios/rust-ecosystem/issues/59>
13#![deny(unsafe_code)]
14#![warn(
15    clippy::all,
16    clippy::await_holding_lock,
17    clippy::char_lit_as_u8,
18    clippy::checked_conversions,
19    clippy::dbg_macro,
20    clippy::debug_assert_with_mut_call,
21    clippy::doc_markdown,
22    clippy::empty_enums,
23    clippy::enum_glob_use,
24    clippy::exit,
25    clippy::expl_impl_clone_on_copy,
26    clippy::explicit_deref_methods,
27    clippy::explicit_into_iter_loop,
28    clippy::fallible_impl_from,
29    clippy::filter_map_next,
30    clippy::float_cmp_const,
31    clippy::fn_params_excessive_bools,
32    clippy::if_let_mutex,
33    clippy::implicit_clone,
34    clippy::imprecise_flops,
35    clippy::inefficient_to_string,
36    clippy::invalid_upcast_comparisons,
37    clippy::large_types_passed_by_value,
38    clippy::let_unit_value,
39    clippy::linkedlist,
40    clippy::lossy_float_literal,
41    clippy::macro_use_imports,
42    clippy::manual_ok_or,
43    clippy::map_err_ignore,
44    clippy::map_flatten,
45    clippy::map_unwrap_or,
46    clippy::match_same_arms,
47    clippy::match_wildcard_for_single_variants,
48    clippy::mem_forget,
49    clippy::mut_mut,
50    clippy::mutex_integer,
51    clippy::needless_borrow,
52    clippy::needless_continue,
53    clippy::option_option,
54    clippy::path_buf_push_overwrite,
55    clippy::ptr_as_ptr,
56    clippy::ref_option_ref,
57    clippy::rest_pat_in_fully_bound_structs,
58    clippy::same_functions_in_if_condition,
59    clippy::semicolon_if_nothing_returned,
60    clippy::string_add_assign,
61    clippy::string_add,
62    clippy::string_lit_as_bytes,
63    clippy::todo,
64    clippy::trait_duplication_in_bounds,
65    clippy::unimplemented,
66    clippy::unnested_or_patterns,
67    clippy::unused_self,
68    clippy::useless_transmute,
69    clippy::verbose_file_reads,
70    clippy::zero_sized_map_values,
71    future_incompatible,
72    nonstandard_style,
73    rust_2018_idioms
74)]
75// END - Embark standard lints v0.4
76// crate-specific exceptions:
77#![allow(
78    // Needed for `asm!`.
79    unsafe_code,
80    // We deblierately provide an unimplemented version of our API on CPU
81    // platforms so that code completion still works.
82    clippy::unimplemented,
83)]
84#![warn(missing_docs)]
85#![doc = include_str!("../README.md")]
86
87/// Public re-export of the `spirv-std-macros` crate.
88#[macro_use]
89pub extern crate spirv_std_macros as macros;
90pub use macros::ScalarComposite;
91pub use macros::spirv;
92pub use macros::{debug_printf, debug_printfln};
93
94pub mod arch;
95pub mod byte_addressable_buffer;
96pub mod cooperative_matrix;
97pub mod debug_printf;
98pub mod float;
99pub mod image;
100pub mod indirect_command;
101pub mod matrix;
102pub mod memory;
103pub mod ray_tracing;
104mod runtime_array;
105mod sampler;
106mod scalar;
107mod scalar_or_vector;
108mod typed_buffer;
109mod vector;
110
111pub use self::sampler::Sampler;
112pub use crate::macros::Image;
113pub use byte_addressable_buffer::ByteAddressableBuffer;
114pub use num_traits;
115pub use runtime_array::*;
116pub use scalar::*;
117pub use scalar_or_vector::*;
118pub use typed_buffer::*;
119pub use vector::*;
120
121// `spirv-std` prefers to use the most up-to-date glam feature that was enabled.
122// Even though it doesn't immediately fail, enabling multiple glam features at the same time will lead to weirdness in
123// downstream crates, as any traits in spirv_std will only be implemented on the most recent glam version.
124cfg_select! {
125    feature = "glam_0_34" => {
126        pub use ::glam_0_34 as glam;
127    }
128    feature = "glam_0_33" => {
129        pub use ::glam_0_33 as glam;
130    }
131    feature = "glam_0_32" => {
132        pub use ::glam_0_32 as glam;
133    }
134    feature = "glam_0_31" => {
135        pub use ::glam_0_31 as glam;
136    }
137    feature = "glam_0_30" => {
138        pub use ::glam_0_30 as glam;
139    }
140    _ => {
141        compile_error!(
142            "Crate `spirv-std` needs at least one one of it's `glam*` features enabled to select which glam version to use"
143        );
144    }
145}
146
147#[cfg(all(not(test), target_arch = "spirv"))]
148#[panic_handler]
149fn panic(_: &core::panic::PanicInfo<'_>) -> ! {
150    loop {}
151}
152
153#[cfg(all(not(test), target_arch = "spirv"))]
154#[lang = "eh_personality"]
155extern "C" fn rust_eh_personality() {}
156
157// See: https://github.com/rust-lang/rust/issues/84738
158#[doc(hidden)]
159/// [spirv_std_types]
160pub fn workaround_rustdoc_ice_84738() {}