ptx_parser/type/instruction/tex.rs
1//! Original PTX specification:
2//!
3//! tex.geom.v4.dtype.ctype d{|p}, [a, c] {, e} {, f};
4//! tex.geom.v4.dtype.ctype d{|p}, [a, b, c] {, e} {, f}; // explicit sampler
5//! tex.geom.v2.f16x2.ctype d{|p}, [a, c] {, e} {, f};
6//! tex.geom.v2.f16x2.ctype d{|p}, [a, b, c] {, e} {, f}; // explicit sampler
7//! // mipmaps
8//! tex.base.geom.v4.dtype.ctype d{|p}, [a, {b,} c] {, e} {, f};
9//! tex.level.geom.v4.dtype.ctype d{|p}, [a, {b,} c], lod {, e} {, f};
10//! tex.grad.geom.v4.dtype.ctype d{|p}, [a, {b,} c], dPdx, dPdy {, e} {, f};
11//! tex.base.geom.v2.f16x2.ctype d{|p}, [a, {b,} c] {, e} {, f};
12//! tex.level.geom.v2.f16x2.ctype d{|p}, [a, {b,} c], lod {, e} {, f};
13//! tex.grad.geom.v2.f16x2.ctype d{|p}, [a, {b,} c], dPdx, dPdy {, e} {, f};
14//! .geom = { .1d, .2d, .3d, .a1d, .a2d, .cube, .acube, .2dms, .a2dms };
15//! .dtype = { .u32, .s32, .f16, .f32 };
16//! .ctype = { .s32, .f32 }; // .cube, .acube require .f32
17//! // .2dms, .a2dms require .s32
18
19#![allow(unused)]
20use crate::r#type::common::*;
21
22pub mod section_0 {
23 use crate::Spanned;
24 use crate::parser::Span;
25 use crate::r#type::common::*;
26
27 use serde::Serialize;
28
29 #[derive(Debug, Clone, PartialEq, Serialize)]
30 pub enum Geom {
31 Acube, // .acube
32 A2dms, // .a2dms
33 Cube, // .cube
34 _2dms, // .2dms
35 A1d, // .a1d
36 A2d, // .a2d
37 _1d, // .1d
38 _2d, // .2d
39 _3d, // .3d
40 }
41
42 #[derive(Debug, Clone, PartialEq, Serialize)]
43 pub enum Dtype {
44 U32, // .u32
45 S32, // .s32
46 F16, // .f16
47 F32, // .f32
48 }
49
50 #[derive(Debug, Clone, PartialEq, Serialize)]
51 pub enum Ctype {
52 S32, // .s32
53 F32, // .f32
54 }
55
56 #[derive(Debug, Clone, PartialEq, Spanned, Serialize)]
57 pub struct TexGeomV4DtypeCtype {
58 pub geom: Geom, // .geom
59 pub v4: (), // .v4
60 pub dtype: Dtype, // .dtype
61 pub ctype: Ctype, // .ctype
62 pub d: GeneralOperand, // first operand of d{|p}
63 pub p: Option<GeneralOperand>, // optional second operand of d{|p}
64 pub a: TexHandler2, // [a, c]
65 pub e: Option<GeneralOperand>, // {, e}
66 pub f: Option<GeneralOperand>, // {, f}
67 pub span: Span,
68 }
69
70 #[derive(Debug, Clone, PartialEq, Spanned, Serialize)]
71 pub struct TexGeomV4DtypeCtype1 {
72 pub geom: Geom, // .geom
73 pub v4: (), // .v4
74 pub dtype: Dtype, // .dtype
75 pub ctype: Ctype, // .ctype
76 pub d: GeneralOperand, // first operand of d{|p}
77 pub p: Option<GeneralOperand>, // optional second operand of d{|p}
78 pub a: TexHandler3, // [a, b, c]
79 pub e: Option<GeneralOperand>, // {, e}
80 pub f: Option<GeneralOperand>, // {, f}
81 pub span: Span,
82 }
83
84 #[derive(Debug, Clone, PartialEq, Spanned, Serialize)]
85 pub struct TexGeomV2F16x2Ctype {
86 pub geom: Geom, // .geom
87 pub v2: (), // .v2
88 pub f16x2: (), // .f16x2
89 pub ctype: Ctype, // .ctype
90 pub d: GeneralOperand, // first operand of d{|p}
91 pub p: Option<GeneralOperand>, // optional second operand of d{|p}
92 pub a: TexHandler2, // [a, c]
93 pub e: Option<GeneralOperand>, // {, e}
94 pub f: Option<GeneralOperand>, // {, f}
95 pub span: Span,
96 }
97
98 #[derive(Debug, Clone, PartialEq, Spanned, Serialize)]
99 pub struct TexGeomV2F16x2Ctype1 {
100 pub geom: Geom, // .geom
101 pub v2: (), // .v2
102 pub f16x2: (), // .f16x2
103 pub ctype: Ctype, // .ctype
104 pub d: GeneralOperand, // first operand of d{|p}
105 pub p: Option<GeneralOperand>, // optional second operand of d{|p}
106 pub a: TexHandler3, // [a, b, c]
107 pub e: Option<GeneralOperand>, // {, e}
108 pub f: Option<GeneralOperand>, // {, f}
109 pub span: Span,
110 }
111
112 #[derive(Debug, Clone, PartialEq, Spanned, Serialize)]
113 pub struct TexBaseGeomV4DtypeCtype {
114 pub base: (), // .base
115 pub geom: Geom, // .geom
116 pub v4: (), // .v4
117 pub dtype: Dtype, // .dtype
118 pub ctype: Ctype, // .ctype
119 pub d: GeneralOperand, // first operand of d{|p}
120 pub p: Option<GeneralOperand>, // optional second operand of d{|p}
121 pub a: TexHandler3Optional, // [a, {b,}, c]
122 pub e: Option<GeneralOperand>, // {, e}
123 pub f: Option<GeneralOperand>, // {, f}
124 pub span: Span,
125 }
126
127 #[derive(Debug, Clone, PartialEq, Spanned, Serialize)]
128 pub struct TexLevelGeomV4DtypeCtype {
129 pub level: (), // .level
130 pub geom: Geom, // .geom
131 pub v4: (), // .v4
132 pub dtype: Dtype, // .dtype
133 pub ctype: Ctype, // .ctype
134 pub d: GeneralOperand, // first operand of d{|p}
135 pub p: Option<GeneralOperand>, // optional second operand of d{|p}
136 pub a: TexHandler3Optional, // [a, {b,}, c]
137 pub lod: GeneralOperand, // lod
138 pub e: Option<GeneralOperand>, // {, e}
139 pub f: Option<GeneralOperand>, // {, f}
140 pub span: Span,
141 }
142
143 #[derive(Debug, Clone, PartialEq, Spanned, Serialize)]
144 pub struct TexGradGeomV4DtypeCtype {
145 pub grad: (), // .grad
146 pub geom: Geom, // .geom
147 pub v4: (), // .v4
148 pub dtype: Dtype, // .dtype
149 pub ctype: Ctype, // .ctype
150 pub d: GeneralOperand, // first operand of d{|p}
151 pub p: Option<GeneralOperand>, // optional second operand of d{|p}
152 pub a: TexHandler3Optional, // [a, {b,}, c]
153 pub dpdx: GeneralOperand, // dPdx
154 pub dpdy: GeneralOperand, // dPdy
155 pub e: Option<GeneralOperand>, // {, e}
156 pub f: Option<GeneralOperand>, // {, f}
157 pub span: Span,
158 }
159
160 #[derive(Debug, Clone, PartialEq, Spanned, Serialize)]
161 pub struct TexBaseGeomV2F16x2Ctype {
162 pub base: (), // .base
163 pub geom: Geom, // .geom
164 pub v2: (), // .v2
165 pub f16x2: (), // .f16x2
166 pub ctype: Ctype, // .ctype
167 pub d: GeneralOperand, // first operand of d{|p}
168 pub p: Option<GeneralOperand>, // optional second operand of d{|p}
169 pub a: TexHandler3Optional, // [a, {b,}, c]
170 pub e: Option<GeneralOperand>, // {, e}
171 pub f: Option<GeneralOperand>, // {, f}
172 pub span: Span,
173 }
174
175 #[derive(Debug, Clone, PartialEq, Spanned, Serialize)]
176 pub struct TexLevelGeomV2F16x2Ctype {
177 pub level: (), // .level
178 pub geom: Geom, // .geom
179 pub v2: (), // .v2
180 pub f16x2: (), // .f16x2
181 pub ctype: Ctype, // .ctype
182 pub d: GeneralOperand, // first operand of d{|p}
183 pub p: Option<GeneralOperand>, // optional second operand of d{|p}
184 pub a: TexHandler3Optional, // [a, {b,}, c]
185 pub lod: GeneralOperand, // lod
186 pub e: Option<GeneralOperand>, // {, e}
187 pub f: Option<GeneralOperand>, // {, f}
188 pub span: Span,
189 }
190
191 #[derive(Debug, Clone, PartialEq, Spanned, Serialize)]
192 pub struct TexGradGeomV2F16x2Ctype {
193 pub grad: (), // .grad
194 pub geom: Geom, // .geom
195 pub v2: (), // .v2
196 pub f16x2: (), // .f16x2
197 pub ctype: Ctype, // .ctype
198 pub d: GeneralOperand, // first operand of d{|p}
199 pub p: Option<GeneralOperand>, // optional second operand of d{|p}
200 pub a: TexHandler3Optional, // [a, {b,}, c]
201 pub dpdx: GeneralOperand, // dPdx
202 pub dpdy: GeneralOperand, // dPdy
203 pub e: Option<GeneralOperand>, // {, e}
204 pub f: Option<GeneralOperand>, // {, f}
205 pub span: Span,
206 }
207}
208
209// Re-export types with section suffixes to avoid naming conflicts
210// e.g., Type0 for section_0::Type, Type1 for section_1::Type
211pub use section_0::Ctype as Ctype0;
212pub use section_0::Dtype as Dtype0;
213pub use section_0::Geom as Geom0;
214pub use section_0::TexBaseGeomV2F16x2Ctype;
215pub use section_0::TexBaseGeomV4DtypeCtype;
216pub use section_0::TexGeomV2F16x2Ctype;
217pub use section_0::TexGeomV2F16x2Ctype1;
218pub use section_0::TexGeomV4DtypeCtype;
219pub use section_0::TexGeomV4DtypeCtype1;
220pub use section_0::TexGradGeomV2F16x2Ctype;
221pub use section_0::TexGradGeomV4DtypeCtype;
222pub use section_0::TexLevelGeomV2F16x2Ctype;
223pub use section_0::TexLevelGeomV4DtypeCtype;