• Home
  • Raw
  • Download

Lines Matching +full:vulkan +full:- +full:rules

3 // <LICENSE-APACHE or
4 // https://www.apache.org/licenses/LICENSE-2.0> or the MIT
5 // license <LICENSE-MIT or https://opensource.org/licenses/MIT>,
12 //! In Vulkan, shaders are grouped in *shader modules*. Each shader module is built from SPIR-V
14 //! GLSL-to-SPIR-V compiler does not support multiple entry points.
16 //! The vulkano library can parse and introspect SPIR-V code, but it does not fully validate the
17 //! code. You are encouraged to use the `vulkano-shaders` crate that will generate Rust code that
22 //! Vulkan has specific rules for interfacing shaders with each other, and with other parts
27 //! The Vulkan specification requires that a Vulkan implementation has runtime support for the
36 //! When buffers, push constants or other user-provided data are accessed in shaders,
38 //! storage buffer or push constant block, the SPIR-V specification requires the SPIR-V code to
41 //! SPIR-V code must also provide an `ArrayStride` or `MatrixStride` decoration for them,
44 //! locations indicated within the SPIR-V code, or the shader will read the wrong data and produce
51 //! you must know the alignment rules that the shader compiler uses. The shader compiler will
52 //! always give a variable the smallest offset that fits the alignment rules and doesn't overlap
53 //! with the previous variable. The shader compiler uses default alignment rules depending on the
56 //! ## Alignment rules
60 //! must likewise be a multiple of this number. An alignment is always a power-of-two value.
61 //! Regardless of whether the offset/stride is provided manually in the compiled SPIR-V code,
63 //! follow these alignment rules.
65 //! Three sets of [alignment rules] are supported by Vulkan. Each one has a GLSL qualifier that
69 //! - **Scalar alignment** (GLSL qualifier: `layout(scalar)`, requires the
72 //! [`#[repr(C)]`](https://doc.rust-lang.org/nomicon/other-reprs.html#reprc) attribute.
74 //! qualifier. You must also enable the [`scalar_block_layout`] feature in Vulkan.
75 //! - **Base alignment**, also known as **std430** (GLSL qualifier: `layout(std430)`).
78 //! [`uniform_buffer_standard_layout`] feature in Vulkan.
79 //! - **Extended alignment**, also known as **std140** (GLSL qualifier: `layout(std140)`).
83 //! alignment rules, it also follows the rules for the base and scalar alignments.
85 //! In all three of these alignment rules, a primitive/scalar value with a size of N bytes has an
90 //! The differences between the alignment rules are in how compound types (vectors, matrices,
96 //! |-----------|-----------------|-----------------|--------------------------|
124 //! The rules for `struct`s are similar to those of arrays. When the members of the struct have
129 //! [alignment rules]: <https://registry.khronos.org/vulkan/specs/1.3-extensions/html/chap15.html#i…
167 /// Contains SPIR-V code with one or more entry points.
177 /// Builds a new shader module from SPIR-V 32-bit words. The shader code is parsed and the
182 /// - The SPIR-V code is not validated beyond the minimum needed to extract the information.
187 ) -> Result<Arc<ShaderModule>, ShaderCreationError> { in from_words()
204 /// - Panics if the length of `bytes` is not a multiple of 4.
209 ) -> Result<Arc<ShaderModule>, ShaderCreationError> { in from_bytes()
227 /// - The SPIR-V code is not validated at all.
228 /// - The provided information must match what the SPIR-V code contains.
236 ) -> Result<Arc<ShaderModule>, ShaderCreationError> { in from_words_with_data()
318 /// - Panics if the length of `bytes` is not a multiple of 4.
326 ) -> Result<Arc<ShaderModule>, ShaderCreationError> { in from_bytes_with_data()
346 pub fn entry_point<'a>(&'a self, name: &str) -> Option<EntryPoint<'a>> { in entry_point()
367 ) -> Option<EntryPoint<'a>> { in entry_point_with_execution()
392 fn handle(&self) -> Self::Handle { in handle()
399 fn device(&self) -> &Arc<Device> { in device()
426 fn source(&self) -> Option<&(dyn Error + 'static)> { in source()
438 fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), FmtError> { in fmt()
443 "the SPIR-V capability {:?} enabled by the shader is not supported by the device", in fmt()
446 Self::SpirvError(_) => write!(f, "the SPIR-V module could not be read"), in fmt()
449 "the SPIR-V extension {} enabled by the shader is not supported by the device", in fmt()
454 "the shader uses SPIR-V version {}.{}, which is not supported by the device", in fmt()
462 fn from(err: VulkanError) -> Self { in from()
468 fn from(err: SpirvError) -> Self { in from()
483 fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), FmtError> { in fmt()
485 Self::NotSupportedByVulkan => write!(f, "not supported by Vulkan"), in fmt()
519 pub fn module(&self) -> &'a ShaderModule { in module()
525 pub fn name(&self) -> &CStr { in name()
531 pub fn execution(&self) -> &ShaderExecution { in execution()
539 ) -> impl ExactSizeIterator<Item = ((u32, u32), &DescriptorBindingRequirements)> { in descriptor_binding_requirements()
548 pub fn push_constant_requirements(&self) -> Option<&PushConstantRange> { in push_constant_requirements()
556 ) -> impl ExactSizeIterator<Item = (u32, &SpecializationConstantRequirements)> { in specialization_constant_requirements()
565 pub fn input_interface(&self) -> &ShaderInterface { in input_interface()
571 pub fn output_interface(&self) -> &ShaderInterface { in output_interface()
633 pub fn is_compatible_with(self, topology: PrimitiveTopology) -> bool { in is_compatible_with()
691 /// `None` means that the shader declares this as a runtime-sized array, and could potentially
703 /// This is `None` for non-image bindings.
707 /// This is `None` for non-image bindings.
735 /// `Dref` or `Proj` SPIR-V instructions or with an LOD bias or offset.
739 /// permitted with a sampler YCbCr conversion. This includes sampling with `Gather` SPIR-V
762 pub fn merge(&mut self, other: &Self) -> Result<(), DescriptorBindingRequirementsIncompatible> { in merge()
873 fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), FmtError> { in fmt()
911 /// any non-zero value means `true`. Integer and floating-point specialization constants are
930 /// fn descriptors() -> &'static [SpecializationMapEntry] {
956 /// - The `SpecializationMapEntry` returned must contain valid offsets and sizes.
957 /// - The size of each `SpecializationMapEntry` must match the size of the corresponding constant
961 fn descriptors() -> &'static [SpecializationMapEntry]; in descriptors()
966 fn descriptors() -> &'static [SpecializationMapEntry] { in descriptors()
978 /// For SPIR-V, this must be the value of the `SpecId` decoration applied to the specialization
993 fn from(val: SpecializationMapEntry) -> Self { in from()
1014 /// - Must only provide one entry per location.
1015 /// - The format of each element must not be larger than 128 bits.
1019 pub unsafe fn new_unchecked(elements: Vec<ShaderInterfaceEntry>) -> ShaderInterface { in new_unchecked()
1025 pub const fn empty() -> ShaderInterface { in empty()
1033 pub fn elements(&self) -> &[ShaderInterfaceEntry] { in elements()
1041 pub fn matches(&self, other: &ShaderInterface) -> Result<(), ShaderInterfaceMismatchError> { in matches()
1120 pub(crate) fn num_locations(&self) -> u32 { in num_locations()
1134 // https://registry.khronos.org/vulkan/specs/1.3-extensions/html/chap43.html#formats-numericformat
1137 fn from(val: NumericType) -> Self { in from()
1183 fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), FmtError> { in fmt()
1207 pub const fn all_graphics() -> ShaderStages {
1287 fn from(val: ShaderExecution) -> Self { in from()
1310 fn from(stages: ShaderStages) -> PipelineStages { in from()
1364 fn check_spirv_version(device: &Device, mut version: Version) -> Result<(), ShaderSupportError> { in check_spirv_version()
1372 "Vulkan API version 1.1", in check_spirv_version()
1380 "Vulkan API version 1.2", in check_spirv_version()
1388 "Vulkan API version 1.2", in check_spirv_version()
1395 "Vulkan API version 1.3", in check_spirv_version()