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