1use crate::ffi;
2use crate::types::descriptor::ReflectDescriptorSet;
3use crate::types::image::ReflectFormat;
4use crate::types::op::{ReflectBuiltIn, ReflectOp};
5use crate::types::traits::*;
6
7bitflags! {
8 #[derive(Serialize)]
9 pub struct ReflectDecorationFlags: u32 {
10 const NONE = 0;
11 const BLOCK = 1;
12 const BUFFER_BLOCK = 2;
13 const ROW_MAJOR = 4;
14 const COLUMN_MAJOR = 8;
15 const BUILT_IN = 16;
16 const NO_PERSPECTIVE = 32;
17 const FLAT = 64;
18 const NON_WRITABLE = 128;
19 }
20}
21
22impl Default for ReflectDecorationFlags {
23 fn default() -> Self {
24 ReflectDecorationFlags::NONE
25 }
26}
27
28bitflags! {
29 #[derive(Serialize)]
30 pub struct ReflectTypeFlags: u32 {
31 const UNDEFINED = 0;
32 const VOID = 1;
33 const BOOL = 2;
34 const INT = 4;
35 const FLOAT = 8;
36 const VECTOR = 256;
37 const MATRIX = 512;
38 const EXTERNAL_IMAGE = 65536;
39 const EXTERNAL_SAMPLER = 131_072;
40 const EXTERNAL_SAMPLED_IMAGE = 262_144;
41 const EXTERNAL_BLOCK = 524_288;
42 const EXTERNAL_ACCELERATION_STRUCTURE_NV = 1_048_576;
43 const EXTERNAL_MASK = 2_031_616;
44 const STRUCT = 268_435_456;
45 const ARRAY = 536_870_912;
46 }
47}
48
49impl Default for ReflectTypeFlags {
50 fn default() -> Self {
51 ReflectTypeFlags::UNDEFINED
52 }
53}
54
55bitflags! {
56 #[derive(Serialize)]
57 pub struct ReflectShaderStageFlags: u32 {
58 const UNDEFINED = 0x0000_0000;
59 const VERTEX = 0x0000_0001;
60 const TESSELLATION_CONTROL = 0x0000_0002;
61 const TESSELLATION_EVALUATION = 0x0000_0004;
62 const GEOMETRY = 0x0000_0008;
63 const FRAGMENT = 0x0000_0010;
64 const COMPUTE = 0x0000_0020;
65 const RAYGEN_BIT_NV = 256;
66 const ANY_HIT_BIT_NV = 512;
67 const CLOSEST_HIT_BIT_NV = 1024;
68 const MISS_BIT_NV = 2048;
69 const INTERSECTION_BIT_NV = 4096;
70 const CALLABLE_BIT_NV = 8192;
71 }
72}
73
74impl Default for ReflectShaderStageFlags {
75 fn default() -> Self {
76 ReflectShaderStageFlags::UNDEFINED
77 }
78}
79
80#[derive(Debug, Copy, Clone, Serialize, PartialEq)]
81pub enum ReflectDimension {
82 Undefined,
83 Type1d,
84 Type2d,
85 Type3d,
86 Cube,
87 Rect,
88 Buffer,
89 SubPassData,
90}
91
92impl Default for ReflectDimension {
93 fn default() -> Self {
94 ReflectDimension::Undefined
95 }
96}
97
98#[derive(Default, Debug, Clone, Serialize, PartialEq)]
99pub struct ReflectTypeDescription {
100 pub id: u32,
101 #[serde(skip_serializing)]
102 pub op: ReflectOp, pub type_name: String,
104 pub struct_member_name: String,
105 pub storage_class: ReflectStorageClass,
106 pub type_flags: ReflectTypeFlags,
107 pub decoration_flags: ReflectDecorationFlags,
108 pub traits: ReflectTypeDescriptionTraits,
109 pub members: Vec<ReflectTypeDescription>,
110}
111
112#[derive(Default, Debug, Clone, Serialize, PartialEq)]
113pub struct ReflectBlockVariable {
114 pub spirv_id: u32,
115 pub name: String,
116 pub offset: u32,
117 pub absolute_offset: u32,
118 pub size: u32,
119 pub padded_size: u32,
120 pub decoration_flags: ReflectDecorationFlags,
121 pub numeric: ReflectNumericTraits,
122 pub array: ReflectArrayTraits,
123 pub members: Vec<ReflectBlockVariable>,
124 pub type_description: Option<ReflectTypeDescription>,
125}
126
127#[derive(Debug, Copy, Clone, Serialize, PartialEq)]
128pub enum ReflectStorageClass {
129 Undefined,
130 UniformConstant,
131 Input,
132 Uniform,
133 Output,
134 WorkGroup,
135 CrossWorkGroup,
136 Private,
137 Function,
138 Generic,
139 PushConstant,
140 AtomicCounter,
141 Image,
142 StorageBuffer,
143}
144
145impl Default for ReflectStorageClass {
146 fn default() -> Self {
147 ReflectStorageClass::Undefined
148 }
149}
150
151#[derive(Debug, Clone, Serialize)]
152pub struct ReflectInterfaceVariable {
153 pub spirv_id: u32,
154 pub name: String,
155 pub location: u32,
156 pub storage_class: ReflectStorageClass,
157 pub semantic: String,
158 pub decoration_flags: ReflectDecorationFlags,
159 #[serde(skip_serializing)]
160 pub built_in: ReflectBuiltIn, pub numeric: ReflectNumericTraits,
162 pub array: ReflectArrayTraits,
163 pub members: Vec<ReflectInterfaceVariable>,
164 pub format: ReflectFormat,
165 pub type_description: Option<ReflectTypeDescription>,
166 pub word_offset: u32,
167 #[serde(skip_serializing)]
168 pub(crate) internal_data: *const ffi::SpvReflectInterfaceVariable,
169}
170
171#[derive(Debug, Clone, Serialize)]
172pub struct ReflectEntryPoint {
173 pub name: String,
174 pub id: u32,
175 #[serde(skip_serializing)]
176 pub spirv_execution_model: spirv_headers::ExecutionModel, pub shader_stage: ReflectShaderStageFlags,
178 pub input_variables: Vec<ReflectInterfaceVariable>,
179 pub output_variables: Vec<ReflectInterfaceVariable>,
180 pub descriptor_sets: Vec<ReflectDescriptorSet>,
181 pub used_uniforms: Vec<u32>,
182 pub used_push_constants: Vec<u32>,
183}