1use alloc::{
72 format,
73 string::{String, ToString},
74 vec::Vec,
75};
76use core::fmt::{Error as FmtError, Write};
77
78use crate::{arena::Handle, back::TaskDispatchLimits, ir, proc::index, valid::ModuleInfo};
79
80mod keywords;
81mod mesh_shader;
82mod ray;
83pub mod sampler;
84mod writer;
85
86pub use writer::Writer;
87
88pub type Slot = u8;
89pub type InlineSamplerIndex = u8;
90
91#[derive(Clone, Debug, PartialEq, Eq, Hash)]
92#[cfg_attr(feature = "serialize", derive(serde::Serialize))]
93#[cfg_attr(feature = "deserialize", derive(serde::Deserialize))]
94pub enum BindSamplerTarget {
95 Resource(Slot),
96 Inline(InlineSamplerIndex),
97}
98
99#[derive(Clone, Debug, PartialEq, Eq, Hash)]
105#[cfg_attr(feature = "serialize", derive(serde::Serialize))]
106#[cfg_attr(feature = "deserialize", derive(serde::Deserialize))]
107pub struct BindExternalTextureTarget {
108 pub planes: [Slot; 3],
109 pub params: Slot,
110}
111
112#[derive(Clone, Debug, Default, PartialEq, Eq, Hash)]
113#[cfg_attr(feature = "serialize", derive(serde::Serialize))]
114#[cfg_attr(feature = "deserialize", derive(serde::Deserialize))]
115#[cfg_attr(any(feature = "serialize", feature = "deserialize"), serde(default))]
116pub struct BindTarget {
117 pub buffer: Option<Slot>,
118 pub texture: Option<Slot>,
119 pub sampler: Option<BindSamplerTarget>,
120 pub external_texture: Option<BindExternalTextureTarget>,
121 pub mutable: bool,
122}
123
124#[cfg(feature = "deserialize")]
125#[derive(serde::Deserialize)]
126struct BindingMapSerialization {
127 resource_binding: crate::ResourceBinding,
128 bind_target: BindTarget,
129}
130
131#[cfg(feature = "deserialize")]
132fn deserialize_binding_map<'de, D>(deserializer: D) -> Result<BindingMap, D::Error>
133where
134 D: serde::Deserializer<'de>,
135{
136 use serde::Deserialize;
137
138 let vec = Vec::<BindingMapSerialization>::deserialize(deserializer)?;
139 let mut map = BindingMap::default();
140 for item in vec {
141 map.insert(item.resource_binding, item.bind_target);
142 }
143 Ok(map)
144}
145
146pub type BindingMap = alloc::collections::BTreeMap<crate::ResourceBinding, BindTarget>;
148
149#[derive(Clone, Debug, Default, Hash, Eq, PartialEq)]
150#[cfg_attr(feature = "serialize", derive(serde::Serialize))]
151#[cfg_attr(feature = "deserialize", derive(serde::Deserialize))]
152#[cfg_attr(any(feature = "serialize", feature = "deserialize"), serde(default))]
153pub struct EntryPointResources {
154 #[cfg_attr(
155 feature = "deserialize",
156 serde(deserialize_with = "deserialize_binding_map")
157 )]
158 pub resources: BindingMap,
159
160 pub immediates_buffer: Option<Slot>,
161
162 pub sizes_buffer: Option<Slot>,
166}
167
168pub type EntryPointResourceMap = alloc::collections::BTreeMap<String, EntryPointResources>;
169
170enum ResolvedBinding {
171 BuiltIn(crate::BuiltIn),
172 Attribute(u32),
173 Color {
174 location: u32,
175 blend_src: Option<u32>,
176 },
177 User {
178 prefix: &'static str,
179 index: u32,
180 interpolation: Option<ResolvedInterpolation>,
181 },
182 Resource(BindTarget),
183 Payload,
184}
185
186#[derive(Copy, Clone)]
187enum ResolvedInterpolation {
188 CenterPerspective,
189 CenterNoPerspective,
190 CentroidPerspective,
191 CentroidNoPerspective,
192 SamplePerspective,
193 SampleNoPerspective,
194 Flat,
195 PerVertex,
196}
197
198#[derive(Debug, thiserror::Error)]
201pub enum Error {
202 #[error(transparent)]
203 Format(#[from] FmtError),
204 #[error("bind target {0:?} is empty")]
205 UnimplementedBindTarget(BindTarget),
206 #[error("composing of {0:?} is not implemented yet")]
207 UnsupportedCompose(Handle<crate::Type>),
208 #[error("operation {0:?} is not implemented yet")]
209 UnsupportedBinaryOp(crate::BinaryOperator),
210 #[error("standard function '{0}' is not implemented yet")]
211 UnsupportedCall(String),
212 #[error("feature '{0}' is not implemented yet")]
213 FeatureNotImplemented(String),
214 #[error("internal naga error: module should not have validated: {0}")]
215 GenericValidation(String),
216 #[error("BuiltIn {0:?} is not supported")]
217 UnsupportedBuiltIn(crate::BuiltIn),
218 #[error("capability {0:?} is not supported")]
219 CapabilityNotSupported(crate::valid::Capabilities),
220 #[error("attribute '{0}' is not supported for target MSL version")]
221 UnsupportedAttribute(String),
222 #[error("function '{0}' is not supported for target MSL version")]
223 UnsupportedFunction(String),
224 #[error("can not use writable storage buffers in fragment stage prior to MSL 1.2")]
225 UnsupportedWritableStorageBuffer,
226 #[error("can not use writable storage textures in {0:?} stage prior to MSL 1.2")]
227 UnsupportedWritableStorageTexture(ir::ShaderStage),
228 #[error("can not use read-write storage textures prior to MSL 1.2")]
229 UnsupportedRWStorageTexture,
230 #[error("array of '{0}' is not supported for target MSL version")]
231 UnsupportedArrayOf(String),
232 #[error("array of type '{0:?}' is not supported")]
233 UnsupportedArrayOfType(Handle<crate::Type>),
234 #[error("ray tracing is not supported prior to MSL 2.4")]
235 UnsupportedRayTracing,
236 #[error("cooperative matrix is not supported prior to MSL 2.3")]
237 UnsupportedCooperativeMatrix,
238 #[error("overrides should not be present at this stage")]
239 Override,
240 #[error("bitcasting to {0:?} is not supported")]
241 UnsupportedBitCast(crate::TypeInner),
242 #[error(transparent)]
243 ResolveArraySizeError(#[from] crate::proc::ResolveArraySizeError),
244 #[error("entry point with stage {0:?} and name '{1}' not found")]
245 EntryPointNotFound(ir::ShaderStage, String),
246 #[error("Cannot use mesh shader syntax prior to MSL 3.0")]
247 UnsupportedMeshShader,
248 #[error("Per vertex fragment inputs are not supported prior to MSL 4.0")]
249 PerVertexNotSupported,
250}
251
252#[derive(Clone, Debug, PartialEq, thiserror::Error)]
253#[cfg_attr(feature = "serialize", derive(serde::Serialize))]
254#[cfg_attr(feature = "deserialize", derive(serde::Deserialize))]
255pub enum EntryPointError {
256 #[error("global '{0}' doesn't have a binding")]
257 MissingBinding(String),
258 #[error("mapping of {0:?} is missing")]
259 MissingBindTarget(crate::ResourceBinding),
260 #[error("mapping for immediates is missing")]
261 MissingImmediateData,
262 #[error("mapping for sizes buffer is missing")]
263 MissingSizesBuffer,
264}
265
266#[derive(Clone, Copy, Debug)]
275enum LocationMode {
276 VertexInput,
278
279 VertexOutput,
281
282 FragmentInput,
284
285 FragmentOutput,
287
288 MeshOutput,
290
291 Uniform,
293}
294
295#[derive(Clone, Debug, Hash, PartialEq, Eq)]
296#[cfg_attr(feature = "serialize", derive(serde::Serialize))]
297#[cfg_attr(feature = "deserialize", derive(serde::Deserialize))]
298#[cfg_attr(feature = "deserialize", serde(default))]
299pub struct Options {
300 pub lang_version: (u8, u8),
302 pub per_entry_point_map: EntryPointResourceMap,
304 pub inline_samplers: Vec<sampler::InlineSampler>,
306 pub spirv_cross_compatibility: bool,
308 pub fake_missing_bindings: bool,
310 pub bounds_check_policies: index::BoundsCheckPolicies,
312 pub zero_initialize_workgroup_memory: bool,
314 pub force_loop_bounding: bool,
317 pub task_dispatch_limits: Option<TaskDispatchLimits>,
320 pub mesh_shader_primitive_indices_clamp: bool,
322}
323
324impl Default for Options {
325 fn default() -> Self {
326 Options {
327 lang_version: (1, 0),
328 per_entry_point_map: EntryPointResourceMap::default(),
329 inline_samplers: Vec::new(),
330 spirv_cross_compatibility: false,
331 fake_missing_bindings: true,
332 bounds_check_policies: index::BoundsCheckPolicies::default(),
333 zero_initialize_workgroup_memory: true,
334 force_loop_bounding: true,
335 task_dispatch_limits: None,
336 mesh_shader_primitive_indices_clamp: true,
337 }
338 }
339}
340
341#[repr(u32)]
344#[derive(Copy, Clone, Debug, Hash, Eq, PartialEq)]
345#[cfg_attr(feature = "serialize", derive(serde::Serialize))]
346#[cfg_attr(feature = "deserialize", derive(serde::Deserialize))]
347pub enum VertexFormat {
348 Uint8 = 0,
350 Uint8x2 = 1,
352 Uint8x4 = 2,
354 Sint8 = 3,
356 Sint8x2 = 4,
358 Sint8x4 = 5,
360 Unorm8 = 6,
362 Unorm8x2 = 7,
364 Unorm8x4 = 8,
366 Snorm8 = 9,
368 Snorm8x2 = 10,
370 Snorm8x4 = 11,
372 Uint16 = 12,
374 Uint16x2 = 13,
376 Uint16x4 = 14,
378 Sint16 = 15,
380 Sint16x2 = 16,
382 Sint16x4 = 17,
384 Unorm16 = 18,
386 Unorm16x2 = 19,
388 Unorm16x4 = 20,
390 Snorm16 = 21,
392 Snorm16x2 = 22,
394 Snorm16x4 = 23,
396 Float16 = 24,
398 Float16x2 = 25,
400 Float16x4 = 26,
402 Float32 = 27,
404 Float32x2 = 28,
406 Float32x3 = 29,
408 Float32x4 = 30,
410 Uint32 = 31,
412 Uint32x2 = 32,
414 Uint32x3 = 33,
416 Uint32x4 = 34,
418 Sint32 = 35,
420 Sint32x2 = 36,
422 Sint32x3 = 37,
424 Sint32x4 = 38,
426 #[cfg_attr(
428 any(feature = "serialize", feature = "deserialize"),
429 serde(rename = "unorm10-10-10-2")
430 )]
431 Unorm10_10_10_2 = 43,
432 #[cfg_attr(
434 any(feature = "serialize", feature = "deserialize"),
435 serde(rename = "unorm8x4-bgra")
436 )]
437 Unorm8x4Bgra = 44,
438}
439
440#[derive(Debug, Default, Clone, Copy, PartialEq, Eq, Hash)]
442#[cfg_attr(feature = "serialize", derive(serde::Serialize))]
443#[cfg_attr(feature = "deserialize", derive(serde::Deserialize))]
444pub enum VertexBufferStepMode {
445 Constant,
446 #[default]
447 ByVertex,
448 ByInstance,
449}
450
451#[derive(Debug, Clone, PartialEq, Eq, Hash)]
454#[cfg_attr(feature = "serialize", derive(serde::Serialize))]
455#[cfg_attr(feature = "deserialize", derive(serde::Deserialize))]
456pub struct AttributeMapping {
457 pub shader_location: u32,
459 pub offset: u32,
461 pub format: VertexFormat,
467}
468
469#[derive(Debug, Default, Clone, PartialEq, Eq, Hash)]
472#[cfg_attr(feature = "serialize", derive(serde::Serialize))]
473#[cfg_attr(feature = "deserialize", derive(serde::Deserialize))]
474pub struct VertexBufferMapping {
475 pub id: u32,
477 pub stride: u32,
479 pub step_mode: VertexBufferStepMode,
481 pub attributes: Vec<AttributeMapping>,
483}
484
485#[derive(Debug, Default, Clone)]
487#[cfg_attr(feature = "serialize", derive(serde::Serialize))]
488#[cfg_attr(feature = "deserialize", derive(serde::Deserialize))]
489#[cfg_attr(feature = "deserialize", serde(default))]
490pub struct PipelineOptions {
491 pub entry_point: Option<(ir::ShaderStage, String)>,
499
500 pub allow_and_force_point_size: bool,
507
508 pub vertex_pulling_transform: bool,
516
517 pub vertex_buffer_mappings: Vec<VertexBufferMapping>,
520}
521
522impl Options {
523 fn resolve_local_binding(
524 &self,
525 binding: &crate::Binding,
526 mode: LocationMode,
527 ) -> Result<ResolvedBinding, Error> {
528 match *binding {
529 crate::Binding::BuiltIn(mut built_in) => {
530 match built_in {
531 crate::BuiltIn::Position { ref mut invariant } => {
532 if *invariant && self.lang_version < (2, 1) {
533 return Err(Error::UnsupportedAttribute("invariant".to_string()));
534 }
535
536 if !matches!(mode, LocationMode::VertexOutput) {
539 *invariant = false;
540 }
541 }
542 crate::BuiltIn::BaseInstance if self.lang_version < (1, 2) => {
543 return Err(Error::UnsupportedAttribute("base_instance".to_string()));
544 }
545 crate::BuiltIn::InstanceIndex if self.lang_version < (1, 2) => {
546 return Err(Error::UnsupportedAttribute("instance_id".to_string()));
547 }
548 crate::BuiltIn::PrimitiveIndex if self.lang_version < (2, 3) => {
551 return Err(Error::UnsupportedAttribute("primitive_id".to_string()));
552 }
553 crate::BuiltIn::ViewIndex if self.lang_version < (2, 2) => {
557 return Err(Error::UnsupportedAttribute("amplification_id".to_string()));
558 }
559 crate::BuiltIn::Barycentric { .. } if self.lang_version < (2, 3) => {
562 return Err(Error::UnsupportedAttribute("barycentric_coord".to_string()));
563 }
564 _ => {}
565 }
566
567 Ok(ResolvedBinding::BuiltIn(built_in))
568 }
569 crate::Binding::Location {
570 location,
571 interpolation,
572 sampling,
573 blend_src,
574 per_primitive,
575 } => match mode {
576 LocationMode::VertexInput => Ok(ResolvedBinding::Attribute(location)),
577 LocationMode::FragmentOutput => {
578 if blend_src.is_some() && self.lang_version < (1, 2) {
579 return Err(Error::UnsupportedAttribute("blend_src".to_string()));
580 }
581 Ok(ResolvedBinding::Color {
582 location,
583 blend_src,
584 })
585 }
586 LocationMode::VertexOutput
587 | LocationMode::FragmentInput
588 | LocationMode::MeshOutput => {
589 Ok(ResolvedBinding::User {
590 prefix: if self.spirv_cross_compatibility {
591 "locn"
592 } else {
593 "loc"
594 },
595 index: location,
596 interpolation: {
597 let interpolation = interpolation.unwrap();
601 let sampling = sampling.unwrap_or(crate::Sampling::Center);
602 Some(ResolvedInterpolation::from_binding(
603 interpolation,
604 sampling,
605 per_primitive,
606 ))
607 },
608 })
609 }
610 LocationMode::Uniform => Err(Error::GenericValidation(format!(
611 "Unexpected Binding::Location({location}) for the Uniform mode"
612 ))),
613 },
614 }
615 }
616
617 fn get_entry_point_resources(&self, ep: &crate::EntryPoint) -> Option<&EntryPointResources> {
618 self.per_entry_point_map.get(&ep.name)
619 }
620
621 fn get_resource_binding_target(
622 &self,
623 ep: &crate::EntryPoint,
624 res_binding: &crate::ResourceBinding,
625 ) -> Option<&BindTarget> {
626 self.get_entry_point_resources(ep)
627 .and_then(|res| res.resources.get(res_binding))
628 }
629
630 fn resolve_resource_binding(
631 &self,
632 ep: &crate::EntryPoint,
633 res_binding: &crate::ResourceBinding,
634 ) -> Result<ResolvedBinding, EntryPointError> {
635 let target = self.get_resource_binding_target(ep, res_binding);
636 match target {
637 Some(target) => Ok(ResolvedBinding::Resource(target.clone())),
638 None if self.fake_missing_bindings => Ok(ResolvedBinding::User {
639 prefix: "fake",
640 index: 0,
641 interpolation: None,
642 }),
643 None => Err(EntryPointError::MissingBindTarget(*res_binding)),
644 }
645 }
646
647 fn resolve_immediates(
648 &self,
649 ep: &crate::EntryPoint,
650 ) -> Result<ResolvedBinding, EntryPointError> {
651 let slot = self
652 .get_entry_point_resources(ep)
653 .and_then(|res| res.immediates_buffer);
654 match slot {
655 Some(slot) => Ok(ResolvedBinding::Resource(BindTarget {
656 buffer: Some(slot),
657 ..Default::default()
658 })),
659 None if self.fake_missing_bindings => Ok(ResolvedBinding::User {
660 prefix: "fake",
661 index: 0,
662 interpolation: None,
663 }),
664 None => Err(EntryPointError::MissingImmediateData),
665 }
666 }
667
668 fn resolve_sizes_buffer(
669 &self,
670 ep: &crate::EntryPoint,
671 ) -> Result<ResolvedBinding, EntryPointError> {
672 let slot = self
673 .get_entry_point_resources(ep)
674 .and_then(|res| res.sizes_buffer);
675 match slot {
676 Some(slot) => Ok(ResolvedBinding::Resource(BindTarget {
677 buffer: Some(slot),
678 ..Default::default()
679 })),
680 None if self.fake_missing_bindings => Ok(ResolvedBinding::User {
681 prefix: "fake",
682 index: 0,
683 interpolation: None,
684 }),
685 None => Err(EntryPointError::MissingSizesBuffer),
686 }
687 }
688}
689
690impl ResolvedBinding {
691 fn as_inline_sampler<'a>(&self, options: &'a Options) -> Option<&'a sampler::InlineSampler> {
692 match *self {
693 Self::Resource(BindTarget {
694 sampler: Some(BindSamplerTarget::Inline(index)),
695 ..
696 }) => Some(&options.inline_samplers[index as usize]),
697 _ => None,
698 }
699 }
700
701 fn try_fmt<W: Write>(&self, out: &mut W) -> Result<(), Error> {
702 write!(out, " [[")?;
703 match *self {
704 Self::BuiltIn(built_in) => {
705 use crate::BuiltIn as Bi;
706 let name = match built_in {
707 Bi::Position { invariant: false } => "position",
708 Bi::Position { invariant: true } => "position, invariant",
709 Bi::ViewIndex => "amplification_id",
710 Bi::BaseInstance => "base_instance",
712 Bi::BaseVertex => "base_vertex",
713 Bi::ClipDistances => "clip_distance",
714 Bi::InstanceIndex => "instance_id",
715 Bi::PointSize => "point_size",
716 Bi::VertexIndex => "vertex_id",
717 Bi::FragDepth => "depth(any)",
719 Bi::PointCoord => "point_coord",
720 Bi::FrontFacing => "front_facing",
721 Bi::PrimitiveIndex => "primitive_id",
722 Bi::Barycentric { perspective: true } => "barycentric_coord",
723 Bi::Barycentric { perspective: false } => {
724 "barycentric_coord, center_no_perspective"
725 }
726 Bi::SampleIndex => "sample_id",
727 Bi::SampleMask => "sample_mask",
728 Bi::GlobalInvocationId => "thread_position_in_grid",
730 Bi::LocalInvocationId => "thread_position_in_threadgroup",
731 Bi::LocalInvocationIndex => "thread_index_in_threadgroup",
732 Bi::WorkGroupId => "threadgroup_position_in_grid",
733 Bi::WorkGroupSize => "dispatch_threads_per_threadgroup",
734 Bi::NumWorkGroups => "threadgroups_per_grid",
735 Bi::NumSubgroups => "simdgroups_per_threadgroup",
737 Bi::SubgroupId => "simdgroup_index_in_threadgroup",
738 Bi::SubgroupSize => "threads_per_simdgroup",
739 Bi::SubgroupInvocationId => "thread_index_in_simdgroup",
740 Bi::CullDistance | Bi::DrawIndex => {
741 return Err(Error::UnsupportedBuiltIn(built_in))
742 }
743 Bi::CullPrimitive => "primitive_culled",
744 Bi::PointIndex | Bi::LineIndices | Bi::TriangleIndices => unimplemented!(),
746 Bi::MeshTaskSize
749 | Bi::VertexCount
750 | Bi::PrimitiveCount
751 | Bi::Vertices
752 | Bi::Primitives
753 | Bi::RayInvocationId
754 | Bi::NumRayInvocations
755 | Bi::InstanceCustomData
756 | Bi::GeometryIndex
757 | Bi::WorldRayOrigin
758 | Bi::WorldRayDirection
759 | Bi::ObjectRayOrigin
760 | Bi::ObjectRayDirection
761 | Bi::RayTmin
762 | Bi::RayTCurrentMax
763 | Bi::ObjectToWorld
764 | Bi::WorldToObject
765 | Bi::HitKind => unreachable!(),
766 };
767 write!(out, "{name}")?;
768 }
769 Self::Attribute(index) => write!(out, "attribute({index})")?,
770 Self::Color {
771 location,
772 blend_src,
773 } => {
774 if let Some(blend_src) = blend_src {
775 write!(out, "color({location}) index({blend_src})")?
776 } else {
777 write!(out, "color({location})")?
778 }
779 }
780 Self::User {
781 prefix,
782 index,
783 interpolation,
784 } => {
785 write!(out, "user({prefix}{index})")?;
786 if let Some(interpolation) = interpolation {
787 write!(out, ", ")?;
788 interpolation.try_fmt(out)?;
789 }
790 }
791 Self::Resource(ref target) => {
792 if let Some(id) = target.buffer {
793 write!(out, "buffer({id})")?;
794 } else if let Some(id) = target.texture {
795 write!(out, "texture({id})")?;
796 } else if let Some(BindSamplerTarget::Resource(id)) = target.sampler {
797 write!(out, "sampler({id})")?;
798 } else {
799 return Err(Error::UnimplementedBindTarget(target.clone()));
800 }
801 }
802 Self::Payload => write!(out, "payload")?,
803 }
804 write!(out, "]]")?;
805 Ok(())
806 }
807}
808
809impl ResolvedInterpolation {
810 const fn from_binding(
811 interpolation: crate::Interpolation,
812 sampling: crate::Sampling,
813 per_primitive: bool,
814 ) -> Self {
815 use crate::Interpolation as I;
816 use crate::Sampling as S;
817
818 if per_primitive {
819 return Self::Flat;
820 }
821
822 match (interpolation, sampling) {
823 (I::Perspective, S::Center) => Self::CenterPerspective,
824 (I::Perspective, S::Centroid) => Self::CentroidPerspective,
825 (I::Perspective, S::Sample) => Self::SamplePerspective,
826 (I::Linear, S::Center) => Self::CenterNoPerspective,
827 (I::Linear, S::Centroid) => Self::CentroidNoPerspective,
828 (I::Linear, S::Sample) => Self::SampleNoPerspective,
829 (I::Flat, _) => Self::Flat,
830 (I::PerVertex, S::Center) => Self::PerVertex,
831 _ => unreachable!(),
832 }
833 }
834
835 fn try_fmt<W: Write>(self, out: &mut W) -> Result<(), Error> {
836 let identifier = match self {
837 Self::CenterPerspective => "center_perspective",
838 Self::CenterNoPerspective => "center_no_perspective",
839 Self::CentroidPerspective => "centroid_perspective",
840 Self::CentroidNoPerspective => "centroid_no_perspective",
841 Self::SamplePerspective => "sample_perspective",
842 Self::SampleNoPerspective => "sample_no_perspective",
843 Self::Flat => "flat",
844 Self::PerVertex => unreachable!(),
845 };
846 out.write_str(identifier)?;
847 Ok(())
848 }
849}
850
851struct EntryPointArgument {
852 ty_name: String,
853 name: String,
854 binding: String,
855 init: Option<Handle<crate::Expression>>,
856}
857
858type BackendResult = Result<(), Error>;
860
861const NAMESPACE: &str = "metal";
862
863const WRAPPED_ARRAY_FIELD: &str = "inner";
867
868pub struct TranslationInfo {
871 pub entry_point_names: Vec<Result<String, EntryPointError>>,
876}
877
878pub fn write_string(
879 module: &crate::Module,
880 info: &ModuleInfo,
881 options: &Options,
882 pipeline_options: &PipelineOptions,
883) -> Result<(String, TranslationInfo), Error> {
884 let mut w = Writer::new(String::new());
885 let info = w.write(module, info, options, pipeline_options)?;
886 Ok((w.finish(), info))
887}
888
889pub fn supported_capabilities() -> crate::valid::Capabilities {
890 use crate::valid::Capabilities as Caps;
891 Caps::IMMEDIATES
892 | Caps::PRIMITIVE_INDEX
894 | Caps::TEXTURE_AND_SAMPLER_BINDING_ARRAY
895 | Caps::STORAGE_TEXTURE_BINDING_ARRAY
897 | Caps::STORAGE_BUFFER_BINDING_ARRAY
898 | Caps::CLIP_DISTANCES
899 | Caps::STORAGE_TEXTURE_16BIT_NORM_FORMATS
901 | Caps::MULTIVIEW
902 | Caps::MULTISAMPLED_SHADING
904 | Caps::RAY_QUERY
905 | Caps::DUAL_SOURCE_BLENDING
906 | Caps::CUBE_ARRAY_TEXTURES
907 | Caps::SHADER_INT64
908 | Caps::SUBGROUP
909 | Caps::SUBGROUP_BARRIER
910 | Caps::SHADER_INT64_ATOMIC_MIN_MAX
912 | Caps::SHADER_FLOAT32_ATOMIC
914 | Caps::TEXTURE_ATOMIC
915 | Caps::TEXTURE_INT64_ATOMIC
916 | Caps::SHADER_FLOAT16
918 | Caps::SHADER_INT16
919 | Caps::TEXTURE_EXTERNAL
920 | Caps::SHADER_FLOAT16_IN_FLOAT32
921 | Caps::SHADER_BARYCENTRICS
922 | Caps::MESH_SHADER
923 | Caps::MESH_SHADER_POINT_TOPOLOGY
924 | Caps::TEXTURE_AND_SAMPLER_BINDING_ARRAY_NON_UNIFORM_INDEXING
925 | Caps::STORAGE_TEXTURE_BINDING_ARRAY_NON_UNIFORM_INDEXING
927 | Caps::STORAGE_BUFFER_BINDING_ARRAY_NON_UNIFORM_INDEXING
928 | Caps::COOPERATIVE_MATRIX
929 | Caps::PER_VERTEX
930 | Caps::MEMORY_DECORATION_COHERENT
934}
935
936#[test]
937fn test_error_size() {
938 assert_eq!(size_of::<Error>(), 40);
939}