citro3d/texture/
enums.rs

1/// Texture filters.
2#[repr(u8)]
3#[derive(Debug, Clone, Copy, PartialEq, Eq)]
4#[doc(alias = "GPU_TEXTURE_FILTER_PARAM")]
5pub enum Filter {
6    #[doc(alias = "GPU_NEAREST")]
7    Nearest = ctru_sys::GPU_NEAREST,
8
9    #[doc(alias = "GPU_LINEAR")]
10    Linear = ctru_sys::GPU_LINEAR,
11}
12
13impl TryFrom<u8> for Filter {
14    type Error = String;
15
16    fn try_from(value: u8) -> Result<Self, Self::Error> {
17        match value {
18            ctru_sys::GPU_NEAREST => Ok(Self::Nearest),
19            ctru_sys::GPU_LINEAR => Ok(Self::Linear),
20            _ => Err("invalid value for FilterParam".to_string()),
21        }
22    }
23}
24
25/// Texture wrap modes.
26#[repr(u8)]
27#[derive(Debug, Clone, Copy, PartialEq, Eq)]
28#[doc(alias = "GPU_TEXTURE_WRAP_PARAM")]
29pub enum Wrap {
30    #[doc(alias = "GPU_CLAMP_TO_EDGE")]
31    ClampToEdge = ctru_sys::GPU_CLAMP_TO_EDGE,
32
33    #[doc(alias = "GPU_CLAMP_TO_BORDER")]
34    ClampToBorder = ctru_sys::GPU_CLAMP_TO_BORDER,
35
36    #[doc(alias = "GPU_REPEAT")]
37    Repeat = ctru_sys::GPU_REPEAT,
38
39    #[doc(alias = "GPU_MIRRORED_REPEAT")]
40    MirroredRepeat = ctru_sys::GPU_MIRRORED_REPEAT,
41}
42
43impl TryFrom<u8> for Wrap {
44    type Error = String;
45    fn try_from(value: u8) -> Result<Self, Self::Error> {
46        match value {
47            ctru_sys::GPU_CLAMP_TO_EDGE => Ok(Self::ClampToEdge),
48            ctru_sys::GPU_CLAMP_TO_BORDER => Ok(Self::ClampToBorder),
49            ctru_sys::GPU_REPEAT => Ok(Self::Repeat),
50            ctru_sys::GPU_MIRRORED_REPEAT => Ok(Self::MirroredRepeat),
51            _ => Err("invalid value for Wrap".to_string()),
52        }
53    }
54}
55
56/// Texture modes.
57#[repr(u8)]
58#[derive(Debug, Clone, Copy, PartialEq, Eq)]
59#[doc(alias = "GPU_TEXTURE_MODE_PARAM")]
60pub enum Mode {
61    #[doc(alias = "GPU_TEX_2D")]
62    Tex2D = ctru_sys::GPU_TEX_2D,
63
64    #[doc(alias = "GPU_TEX_CUBE_MAP")]
65    CubeMap = ctru_sys::GPU_TEX_CUBE_MAP,
66
67    #[doc(alias = "GPU_TEX_SHADOW_2D")]
68    Shadow2D = ctru_sys::GPU_TEX_SHADOW_2D,
69
70    #[doc(alias = "GPU_TEX_PROJECTION")]
71    Projection = ctru_sys::GPU_TEX_PROJECTION,
72
73    #[doc(alias = "GPU_TEX_SHADOW_CUBE")]
74    ShadowCube = ctru_sys::GPU_TEX_SHADOW_CUBE,
75
76    #[doc(alias = "GPU_TEX_DISABLED")]
77    Disabled = ctru_sys::GPU_TEX_DISABLED,
78}
79
80impl TryFrom<u8> for Mode {
81    type Error = String;
82    fn try_from(value: u8) -> Result<Self, Self::Error> {
83        match value {
84            ctru_sys::GPU_TEX_2D => Ok(Self::Tex2D),
85            ctru_sys::GPU_TEX_CUBE_MAP => Ok(Self::CubeMap),
86            ctru_sys::GPU_TEX_SHADOW_2D => Ok(Self::Shadow2D),
87            ctru_sys::GPU_TEX_PROJECTION => Ok(Self::Projection),
88            ctru_sys::GPU_TEX_SHADOW_CUBE => Ok(Self::ShadowCube),
89            ctru_sys::GPU_TEX_DISABLED => Ok(Self::Disabled),
90            _ => Err("invalid value for Mode".to_string()),
91        }
92    }
93}
94
95#[repr(u8)]
96#[derive(Debug, Clone, Copy, PartialEq, Eq)]
97pub enum Index {
98    Texture0 = 0,
99    Texture1 = 1,
100    Texture2 = 2,
101    Texture3 = 3,
102}
103
104impl Index {
105    pub const ALL: [Index; 4] = [
106        Index::Texture0,
107        Index::Texture1,
108        Index::Texture2,
109        Index::Texture3,
110    ];
111}
112
113/// Supported texture units.
114#[repr(u8)]
115#[derive(Debug, Clone, Copy, PartialEq, Eq)]
116#[doc(alias = "GPU_TEXUNIT")]
117pub enum Unit {
118    #[doc(alias = "GPU_TEXUNIT0")]
119    Unit0 = ctru_sys::GPU_TEXUNIT0,
120
121    #[doc(alias = "GPU_TEXUNIT1")]
122    Unit1 = ctru_sys::GPU_TEXUNIT1,
123
124    #[doc(alias = "GPU_TEXUNIT2")]
125    Unit2 = ctru_sys::GPU_TEXUNIT2,
126}
127
128impl TryFrom<u8> for Unit {
129    type Error = String;
130    fn try_from(value: u8) -> Result<Self, Self::Error> {
131        match value {
132            ctru_sys::GPU_TEXUNIT0 => Ok(Self::Unit0),
133            ctru_sys::GPU_TEXUNIT1 => Ok(Self::Unit1),
134            ctru_sys::GPU_TEXUNIT2 => Ok(Self::Unit2),
135            _ => Err("invalid value for Unit".to_string()),
136        }
137    }
138}
139
140/// Supported texture formats.
141#[repr(u8)]
142#[derive(Debug, Clone, Copy, PartialEq, Eq)]
143#[doc(alias = "GPU_TEXCOLOR")]
144pub enum ColorFormat {
145    /// 8-bit Red + 8-bit Green + 8-bit Blue + 8-bit Alpha
146    #[doc(alias = "GPU_RGBA8")]
147    Rgba8 = ctru_sys::GPU_RGBA8,
148
149    /// 8-bit Red + 8-bit Green + 8-bit Blue    #[doc(alias = "GPU_RGB8")]
150    Rgb8 = ctru_sys::GPU_RGB8,
151
152    /// 5-bit Red + 5-bit Green + 5-bit Blue + 1-bit Alpha
153    #[doc(alias = "GPU_RGBA5551")]
154    Rgba5551 = ctru_sys::GPU_RGBA5551,
155
156    /// 5-bit Red + 6-bit Green + 5-bit Blue
157    #[doc(alias = "GPU_RGB565")]
158    Rgb565 = ctru_sys::GPU_RGB565,
159
160    /// 4-bit Red + 4-bit Green + 4-bit Blue + 4-bit Alpha
161    #[doc(alias = "GPU_RGBA4")]
162    Rgba4 = ctru_sys::GPU_RGBA4,
163
164    /// 8-bit Luminance + 8-bit Alpha
165    #[doc(alias = "GPU_LA8")]
166    La8 = ctru_sys::GPU_LA8,
167
168    /// 8-bit Hi + 8-bit Lo
169    #[doc(alias = "GPU_HILO8")]
170    Hilo8 = ctru_sys::GPU_HILO8,
171
172    /// 8-bit Luminance
173    #[doc(alias = "GPU_L8")]
174    L8 = ctru_sys::GPU_L8,
175
176    /// 8-bit Alpha
177    #[doc(alias = "GPU_A8")]
178    A8 = ctru_sys::GPU_A8,
179
180    /// 4-bit Luminance + 4-bit Alpha
181    #[doc(alias = "GPU_LA4")]
182    La4 = ctru_sys::GPU_LA4,
183
184    /// 4-bit Luminance
185    #[doc(alias = "GPU_L4")]
186    L4 = ctru_sys::GPU_L4,
187
188    /// 4-bit Alpha
189    #[doc(alias = "GPU_A4")]
190    A4 = ctru_sys::GPU_A4,
191
192    /// ETC1 texture compression
193    #[doc(alias = "GPU_ETC1")]
194    Etc1 = ctru_sys::GPU_ETC1,
195
196    /// ETC1 texture compression + 4-bit Alpha
197    #[doc(alias = "GPU_ETC1A4")]
198    Etc1A4 = ctru_sys::GPU_ETC1A4,
199}
200
201impl ColorFormat {
202    pub const fn bits_per_pixel(&self) -> usize {
203        match self {
204            Self::Rgba8 => 32,
205            Self::Rgb8 => 24,
206            Self::Rgba5551 | Self::Rgb565 | Self::Rgba4 | Self::La8 | Self::Hilo8 => 16,
207            Self::L8 | Self::A8 | Self::La4 | Self::Etc1A4 => 8,
208            Self::L4 | Self::A4 | Self::Etc1 => 4,
209        }
210    }
211}
212
213impl TryFrom<u8> for ColorFormat {
214    type Error = String;
215    fn try_from(value: u8) -> Result<Self, Self::Error> {
216        match value {
217            ctru_sys::GPU_RGBA8 => Ok(Self::Rgba8),
218            ctru_sys::GPU_RGB8 => Ok(Self::Rgb8),
219            ctru_sys::GPU_RGBA5551 => Ok(Self::Rgba5551),
220            ctru_sys::GPU_RGB565 => Ok(Self::Rgb565),
221            ctru_sys::GPU_RGBA4 => Ok(Self::Rgba4),
222            ctru_sys::GPU_LA8 => Ok(Self::La8),
223            ctru_sys::GPU_HILO8 => Ok(Self::Hilo8),
224            ctru_sys::GPU_L8 => Ok(Self::L8),
225            ctru_sys::GPU_A8 => Ok(Self::A8),
226            ctru_sys::GPU_LA4 => Ok(Self::La4),
227            ctru_sys::GPU_L4 => Ok(Self::L4),
228            ctru_sys::GPU_A4 => Ok(Self::A4),
229            ctru_sys::GPU_ETC1 => Ok(Self::Etc1),
230            ctru_sys::GPU_ETC1A4 => Ok(Self::Etc1A4),
231            _ => Err("invalid value for ColorFormat".to_string()),
232        }
233    }
234}
235
236/// Texture faces.
237///
238/// Faces are used for CubeMaps.
239/// Standard 2D textures use only [`Face::PositiveX`], also accessible as [`Face::Bidimensional`].
240#[repr(u8)]
241#[derive(Debug, Clone, Copy, PartialEq, Eq, Default)]
242#[doc(alias = "GPU_TEXFACE")]
243pub enum Face {
244    /// +X face.
245    ///
246    /// This corresponds to the only face of 2D textures (see [`Face::Bidimensional`]).
247    #[doc(alias = "GPU_POSITIVE_X")]
248    #[default]
249    PositiveX = ctru_sys::GPU_POSITIVE_X,
250
251    /// -X face.
252    #[doc(alias = "GPU_NEGATIVE_X")]
253    NegativeX = ctru_sys::GPU_NEGATIVE_X,
254
255    /// +Y face.
256    #[doc(alias = "GPU_POSITIVE_Y")]
257    PositiveY = ctru_sys::GPU_POSITIVE_Y,
258
259    /// -Y face.
260    #[doc(alias = "GPU_NEGATIVE_Y")]
261    NegativeY = ctru_sys::GPU_NEGATIVE_Y,
262
263    /// +Z face.
264    #[doc(alias = "GPU_POSITIVE_Z")]
265    PositiveZ = ctru_sys::GPU_POSITIVE_Z,
266
267    /// -Z face.
268    #[doc(alias = "GPU_NEGATIVE_Z")]
269    NegativeZ = ctru_sys::GPU_NEGATIVE_Z,
270}
271
272impl Face {
273    /// 2D face.
274    ///
275    /// Equal in value to [`Face::PositiveX`].
276    #[allow(non_upper_case_globals)]
277    #[doc(alias = "GPU_TEXFACE_2D")]
278    pub const Bidimensional: Self = Self::PositiveX;
279}
280
281impl TryFrom<u8> for Face {
282    type Error = String;
283    fn try_from(value: u8) -> Result<Self, Self::Error> {
284        match value {
285            ctru_sys::GPU_POSITIVE_X => Ok(Self::PositiveX),
286            // ctru_sys::GPU_TEXFACE_2D and ctru_sys::GPU_POSITIVE_X have the same value which causes problems with rust.
287            // ctru_sys::GPU_TEXFACE_2D => Ok(Self::Bidimensional),
288            ctru_sys::GPU_NEGATIVE_X => Ok(Self::NegativeX),
289            ctru_sys::GPU_POSITIVE_Y => Ok(Self::PositiveY),
290            ctru_sys::GPU_NEGATIVE_Y => Ok(Self::NegativeY),
291            ctru_sys::GPU_POSITIVE_Z => Ok(Self::PositiveZ),
292            ctru_sys::GPU_NEGATIVE_Z => Ok(Self::NegativeZ),
293            _ => Err("invalid value for Face".to_string()),
294        }
295    }
296}
297
298/// Procedural texture clamp modes.
299#[repr(u8)]
300#[derive(Debug, Clone, Copy, PartialEq, Eq)]
301#[doc(alias = "GPU_PROCTEX_CLAMP")]
302pub enum ProceduralTextureClamp {
303    /// Clamp to zero.
304    #[doc(alias = "GPU_PT_CLAMP_TO_ZERO")]
305    ClampToZero = ctru_sys::GPU_PT_CLAMP_TO_ZERO,
306
307    /// Clamp to edge.
308    #[doc(alias = "GPU_PT_CLAMP_TO_EDGE")]
309    ClampToEdge = ctru_sys::GPU_PT_CLAMP_TO_EDGE,
310
311    /// Symmetrical repeat.
312    #[doc(alias = "GPU_PT_REPEAT")]
313    Repeat = ctru_sys::GPU_PT_REPEAT,
314
315    /// Mirrored repeat.
316    #[doc(alias = "GPU_PT_MIRRORED_REPEAT")]
317    MirroredRepeat = ctru_sys::GPU_PT_MIRRORED_REPEAT,
318
319    /// Pulse.
320    #[doc(alias = "GPU_PT_PULSE")]
321    Pulse = ctru_sys::GPU_PT_PULSE,
322}
323
324impl TryFrom<u8> for ProceduralTextureClamp {
325    type Error = String;
326    fn try_from(value: u8) -> Result<Self, Self::Error> {
327        match value {
328            ctru_sys::GPU_PT_CLAMP_TO_ZERO => Ok(Self::ClampToZero),
329            ctru_sys::GPU_PT_CLAMP_TO_EDGE => Ok(Self::ClampToEdge),
330            ctru_sys::GPU_PT_REPEAT => Ok(Self::Repeat),
331            ctru_sys::GPU_PT_MIRRORED_REPEAT => Ok(Self::MirroredRepeat),
332            ctru_sys::GPU_PT_PULSE => Ok(Self::Pulse),
333            _ => Err("invalid value for ProceduralTextureClamp".to_string()),
334        }
335    }
336}
337
338/// Procedural texture mapping functions.
339#[repr(u8)]
340#[derive(Debug, Clone, Copy, PartialEq, Eq)]
341#[doc(alias = "GPU_PROCTEX_MAPFUNC")]
342pub enum ProceduralTextureMappingFunction {
343    /// U
344    #[doc(alias = "GPU_PT_U")]
345    U = ctru_sys::GPU_PT_U,
346
347    /// U2
348    #[doc(alias = "GPU_PT_U2")]
349    U2 = ctru_sys::GPU_PT_U2,
350
351    /// V
352    #[doc(alias = "GPU_PT_V")]
353    V = ctru_sys::GPU_PT_V,
354
355    /// V2
356    #[doc(alias = "GPU_PT_V2")]
357    V2 = ctru_sys::GPU_PT_V2,
358
359    /// U+V
360    #[doc(alias = "GPU_PT_ADD")]
361    Add = ctru_sys::GPU_PT_ADD,
362
363    /// U2+V2
364    #[doc(alias = "GPU_PT_ADD2")]
365    Add2 = ctru_sys::GPU_PT_ADD2,
366
367    /// sqrt(U2+V2)
368    #[doc(alias = "GPU_PT_SQRT2")]
369    Sqrt2 = ctru_sys::GPU_PT_SQRT2,
370
371    /// min
372    #[doc(alias = "GPU_PT_MIN")]
373    Min = ctru_sys::GPU_PT_MIN,
374
375    /// max
376    #[doc(alias = "GPU_PT_MAX")]
377    Max = ctru_sys::GPU_PT_MAX,
378
379    /// rmax
380    #[doc(alias = "GPU_PT_RMAX")]
381    RMax = ctru_sys::GPU_PT_RMAX,
382}
383
384impl TryFrom<u8> for ProceduralTextureMappingFunction {
385    type Error = String;
386    fn try_from(value: u8) -> Result<Self, Self::Error> {
387        match value {
388            ctru_sys::GPU_PT_U => Ok(Self::U),
389            ctru_sys::GPU_PT_U2 => Ok(Self::U2),
390            ctru_sys::GPU_PT_V => Ok(Self::V),
391            ctru_sys::GPU_PT_V2 => Ok(Self::V2),
392            ctru_sys::GPU_PT_ADD => Ok(Self::Add),
393            ctru_sys::GPU_PT_ADD2 => Ok(Self::Add2),
394            ctru_sys::GPU_PT_SQRT2 => Ok(Self::Sqrt2),
395            ctru_sys::GPU_PT_MIN => Ok(Self::Min),
396            ctru_sys::GPU_PT_MAX => Ok(Self::Max),
397            ctru_sys::GPU_PT_RMAX => Ok(Self::RMax),
398            _ => Err("invalid value for ProceduralTextureMappingFunction".to_string()),
399        }
400    }
401}
402
403/// Procedural texture shift values.
404#[repr(u8)]
405#[derive(Debug, Clone, Copy, PartialEq, Eq)]
406#[doc(alias = "GPU_PROCTEX_SHIFT")]
407pub enum ProceduralTextureShift {
408    /// No shift.
409    #[doc(alias = "GPU_PT_NONE")]
410    None = ctru_sys::GPU_PT_NONE,
411
412    /// Odd shift.
413    #[doc(alias = "GPU_PT_ODD")]
414    Odd = ctru_sys::GPU_PT_ODD,
415
416    /// Even shift.
417    #[doc(alias = "GPU_PT_EVEN")]
418    Even = ctru_sys::GPU_PT_EVEN,
419}
420
421impl TryFrom<u8> for ProceduralTextureShift {
422    type Error = String;
423
424    fn try_from(value: u8) -> Result<Self, Self::Error> {
425        match value {
426            ctru_sys::GPU_PT_NONE => Ok(Self::None),
427            ctru_sys::GPU_PT_ODD => Ok(Self::Odd),
428            ctru_sys::GPU_PT_EVEN => Ok(Self::Even),
429            _ => Err("invalid value for ProceduralTextureShift".to_string()),
430        }
431    }
432}
433
434/// Procedural texture filter values.
435#[repr(u8)]
436#[derive(Debug, Clone, Copy, PartialEq, Eq)]
437#[doc(alias = "GPU_PROCTEX_FILTER")]
438pub enum ProceduralTextureFilter {
439    /// Nearest-neighbor
440    #[doc(alias = "GPU_PT_NEAREST")]
441    Nearest = ctru_sys::GPU_PT_NEAREST,
442
443    /// Linear interpolation
444    #[doc(alias = "GPU_PT_LINEAR")]
445    Linear = ctru_sys::GPU_PT_LINEAR,
446
447    /// Nearest-neighbor with mipmap using nearest-neighbor
448    #[doc(alias = "GPU_PT_NEAREST_MIP_NEAREST")]
449    NearestMipNearest = ctru_sys::GPU_PT_NEAREST_MIP_NEAREST,
450
451    /// Linear interpolation with mipmap using nearest-neighbor
452    #[doc(alias = "GPU_PT_LINEAR_MIP_NEAREST")]
453    LinearMipNearest = ctru_sys::GPU_PT_LINEAR_MIP_NEAREST,
454
455    /// Nearest-neighbor with mipmap using linear interpolation
456    #[doc(alias = "GPU_PT_NEAREST_MIP_LINEAR")]
457    NearestMipLinear = ctru_sys::GPU_PT_NEAREST_MIP_LINEAR,
458
459    /// Linear interpolation with mipmap using linear interpolation
460    #[doc(alias = "GPU_PT_LINEAR_MIP_LINEAR")]
461    LinearMipLinear = ctru_sys::GPU_PT_LINEAR_MIP_LINEAR,
462}
463
464impl TryFrom<u8> for ProceduralTextureFilter {
465    type Error = String;
466
467    fn try_from(value: u8) -> Result<Self, Self::Error> {
468        match value {
469            ctru_sys::GPU_PT_NEAREST => Ok(Self::Nearest),
470            ctru_sys::GPU_PT_LINEAR => Ok(Self::Linear),
471            ctru_sys::GPU_PT_NEAREST_MIP_NEAREST => Ok(Self::NearestMipNearest),
472            ctru_sys::GPU_PT_LINEAR_MIP_NEAREST => Ok(Self::LinearMipNearest),
473            ctru_sys::GPU_PT_NEAREST_MIP_LINEAR => Ok(Self::NearestMipLinear),
474            ctru_sys::GPU_PT_LINEAR_MIP_LINEAR => Ok(Self::LinearMipLinear),
475            _ => Err("invalid value for ProceduralTextureFilter".to_string()),
476        }
477    }
478}
479
480/// Procedural texture LUT IDs.
481#[repr(u8)]
482#[derive(Debug, Clone, Copy, PartialEq, Eq)]
483#[doc(alias = "GPU_PROCTEX_LUTID")]
484pub enum ProceduralTextureLutId {
485    /// Noise table
486    #[doc(alias = "GPU_LUT_NOISE")]
487    Noise = ctru_sys::GPU_LUT_NOISE,
488
489    /// RGB mapping function table
490    #[doc(alias = "GPU_LUT_RGBMAP")]
491    RGBMap = ctru_sys::GPU_LUT_RGBMAP,
492
493    /// Alpha mapping function table
494    #[doc(alias = "GPU_LUT_ALPHAMAP")]
495    AlphaMap = ctru_sys::GPU_LUT_ALPHAMAP,
496
497    /// Color table
498    #[doc(alias = "GPU_LUT_COLOR")]
499    Color = ctru_sys::GPU_LUT_COLOR,
500
501    /// Color difference table
502    #[doc(alias = "GPU_LUT_COLORDIF")]
503    ColorDif = ctru_sys::GPU_LUT_COLORDIF,
504}
505
506impl TryFrom<u8> for ProceduralTextureLutId {
507    type Error = String;
508
509    fn try_from(value: u8) -> Result<Self, Self::Error> {
510        match value {
511            ctru_sys::GPU_LUT_NOISE => Ok(Self::Noise),
512            ctru_sys::GPU_LUT_RGBMAP => Ok(Self::RGBMap),
513            ctru_sys::GPU_LUT_ALPHAMAP => Ok(Self::AlphaMap),
514            ctru_sys::GPU_LUT_COLOR => Ok(Self::Color),
515            ctru_sys::GPU_LUT_COLORDIF => Ok(Self::ColorDif),
516            _ => Err("invalid value for ProceduralTextureLutId".to_string()),
517        }
518    }
519}
520
521/// Texture RGB combiner operands.
522#[repr(u8)]
523#[derive(Debug, Clone, Copy, PartialEq, Eq)]
524#[doc(alias = "GPU_TEVOP_RGB")]
525pub enum RgbOperand {
526    /// Source color.
527    #[doc(alias = "GPU_TEVOP_RGB_SRC_COLOR")]
528    SrcColor = ctru_sys::GPU_TEVOP_RGB_SRC_COLOR,
529
530    /// Source color - 1.
531    #[doc(alias = "GPU_TEVOP_RGB_ONE_MINUS_SRC_COLOR")]
532    OneMinusSrcColor = ctru_sys::GPU_TEVOP_RGB_ONE_MINUS_SRC_COLOR,
533
534    /// Source alpha.
535    #[doc(alias = "GPU_TEVOP_RGB_SRC_ALPHA")]
536    SrcAlpha = ctru_sys::GPU_TEVOP_RGB_SRC_ALPHA,
537
538    /// Source alpha - 1.
539    #[doc(alias = "GPU_TEVOP_RGB_ONE_MINUS_SRC_ALPHA")]
540    OneMinusSrcAlpha = ctru_sys::GPU_TEVOP_RGB_ONE_MINUS_SRC_ALPHA,
541
542    /// Source red.
543    #[doc(alias = "GPU_TEVOP_RGB_SRC_R")]
544    SrcR = ctru_sys::GPU_TEVOP_RGB_SRC_R,
545
546    /// Source red - 1.
547    #[doc(alias = "GPU_TEVOP_RGB_ONE_MINUS_SRC_R")]
548    OneMinusSrcR = ctru_sys::GPU_TEVOP_RGB_ONE_MINUS_SRC_R,
549
550    /// Unknown.
551    #[doc(alias = "GPU_TEVOP_RGB_0x06")]
552    _0x06 = ctru_sys::GPU_TEVOP_RGB_0x06,
553
554    /// Unknown.
555    #[doc(alias = "GPU_TEVOP_RGB_0x07")]
556    UnknownHex07 = ctru_sys::GPU_TEVOP_RGB_0x07,
557
558    /// Source green.
559    #[doc(alias = "GPU_TEVOP_RGB_SRC_G")]
560    SrcG = ctru_sys::GPU_TEVOP_RGB_SRC_G,
561
562    /// Source green - 1.
563    #[doc(alias = "GPU_TEVOP_RGB_ONE_MINUS_SRC_G")]
564    OneMinusSrcG = ctru_sys::GPU_TEVOP_RGB_ONE_MINUS_SRC_G,
565
566    /// Unknown.
567    #[doc(alias = "GPU_TEVOP_RGB_0x0A")]
568    UnknownHex0A = ctru_sys::GPU_TEVOP_RGB_0x0A,
569
570    /// Unknown.
571    #[doc(alias = "GPU_TEVOP_RGB_0x0B")]
572    UnknownHex0B = ctru_sys::GPU_TEVOP_RGB_0x0B,
573
574    /// Source blue.
575    #[doc(alias = "GPU_TEVOP_RGB_SRC_B")]
576    SrcB = ctru_sys::GPU_TEVOP_RGB_SRC_B,
577
578    /// Source blue - 1.
579    #[doc(alias = "GPU_TEVOP_RGB_ONE_MINUS_SRC_B")]
580    OneMinusSrcB = ctru_sys::GPU_TEVOP_RGB_ONE_MINUS_SRC_B,
581
582    /// Unknown.
583    #[doc(alias = "GPU_TEVOP_RGB_0x0E")]
584    UnknownHex0E = ctru_sys::GPU_TEVOP_RGB_0x0E,
585
586    /// Unknown.
587    #[doc(alias = "GPU_TEVOP_RGB_0x0F")]
588    UnknownHex0F = ctru_sys::GPU_TEVOP_RGB_0x0F,
589}
590
591impl TryFrom<u8> for RgbOperand {
592    type Error = String;
593    fn try_from(value: u8) -> Result<Self, Self::Error> {
594        match value {
595            ctru_sys::GPU_TEVOP_RGB_SRC_COLOR => Ok(Self::SrcColor),
596            ctru_sys::GPU_TEVOP_RGB_ONE_MINUS_SRC_COLOR => Ok(Self::OneMinusSrcColor),
597            ctru_sys::GPU_TEVOP_RGB_SRC_ALPHA => Ok(Self::SrcAlpha),
598            ctru_sys::GPU_TEVOP_RGB_ONE_MINUS_SRC_ALPHA => Ok(Self::OneMinusSrcAlpha),
599            ctru_sys::GPU_TEVOP_RGB_SRC_R => Ok(Self::SrcR),
600            ctru_sys::GPU_TEVOP_RGB_ONE_MINUS_SRC_R => Ok(Self::OneMinusSrcR),
601            ctru_sys::GPU_TEVOP_RGB_0x06 => Ok(Self::_0x06),
602            ctru_sys::GPU_TEVOP_RGB_0x07 => Ok(Self::UnknownHex07),
603            ctru_sys::GPU_TEVOP_RGB_SRC_G => Ok(Self::SrcG),
604            ctru_sys::GPU_TEVOP_RGB_ONE_MINUS_SRC_G => Ok(Self::OneMinusSrcG),
605            ctru_sys::GPU_TEVOP_RGB_0x0A => Ok(Self::UnknownHex0A),
606            ctru_sys::GPU_TEVOP_RGB_0x0B => Ok(Self::UnknownHex0B),
607            ctru_sys::GPU_TEVOP_RGB_SRC_B => Ok(Self::SrcB),
608            ctru_sys::GPU_TEVOP_RGB_ONE_MINUS_SRC_B => Ok(Self::OneMinusSrcB),
609            ctru_sys::GPU_TEVOP_RGB_0x0E => Ok(Self::UnknownHex0E),
610            ctru_sys::GPU_TEVOP_RGB_0x0F => Ok(Self::UnknownHex0F),
611            _ => Err("invalid value for RgbOperand".to_string()),
612        }
613    }
614}
615
616/// Texture Alpha combiner operands.
617#[repr(u8)]
618#[derive(Debug, Clone, Copy, PartialEq, Eq)]
619#[doc(alias = "GPU_TEVOP_A")]
620pub enum AlphaOperand {
621    /// Source alpha.
622    #[doc(alias = "GPU_TEVOP_A_SRC_ALPHA")]
623    SrcAlpha = ctru_sys::GPU_TEVOP_A_SRC_ALPHA,
624
625    /// Source alpha - 1.
626    #[doc(alias = "GPU_TEVOP_A_ONE_MINUS_SRC_ALPHA")]
627    OneMinusSrcAlpha = ctru_sys::GPU_TEVOP_A_ONE_MINUS_SRC_ALPHA,
628
629    /// Source red.
630    #[doc(alias = "GPU_TEVOP_A_SRC_R")]
631    SrcRed = ctru_sys::GPU_TEVOP_A_SRC_R,
632
633    /// Source red - 1.
634    #[doc(alias = "GPU_TEVOP_A_ONE_MINUS_SRC_R")]
635    OneMinusSrcRed = ctru_sys::GPU_TEVOP_A_ONE_MINUS_SRC_R,
636
637    /// Source green.
638    #[doc(alias = "GPU_TEVOP_A_SRC_G")]
639    SrcGreen = ctru_sys::GPU_TEVOP_A_SRC_G,
640
641    /// Source green - 1.
642    #[doc(alias = "GPU_TEVOP_A_ONE_MINUS_SRC_G")]
643    OneMinusSrcGreen = ctru_sys::GPU_TEVOP_A_ONE_MINUS_SRC_G,
644
645    /// Source blue.
646    #[doc(alias = "GPU_TEVOP_A_SRC_B")]
647    SrcBlue = ctru_sys::GPU_TEVOP_A_SRC_B,
648
649    /// Source blue - 1.
650    #[doc(alias = "GPU_TEVOP_A_ONE_MINUS_SRC_B")]
651    OneMinusSrcBlue = ctru_sys::GPU_TEVOP_A_ONE_MINUS_SRC_B,
652}
653
654impl TryFrom<u8> for AlphaOperand {
655    type Error = String;
656    fn try_from(value: u8) -> Result<Self, Self::Error> {
657        match value {
658            ctru_sys::GPU_TEVOP_A_SRC_ALPHA => Ok(Self::SrcAlpha),
659            ctru_sys::GPU_TEVOP_A_ONE_MINUS_SRC_ALPHA => Ok(Self::OneMinusSrcAlpha),
660            ctru_sys::GPU_TEVOP_A_SRC_R => Ok(Self::SrcRed),
661            ctru_sys::GPU_TEVOP_A_ONE_MINUS_SRC_R => Ok(Self::OneMinusSrcRed),
662            ctru_sys::GPU_TEVOP_A_SRC_G => Ok(Self::SrcGreen),
663            ctru_sys::GPU_TEVOP_A_ONE_MINUS_SRC_G => Ok(Self::OneMinusSrcGreen),
664            ctru_sys::GPU_TEVOP_A_SRC_B => Ok(Self::SrcBlue),
665            ctru_sys::GPU_TEVOP_A_ONE_MINUS_SRC_B => Ok(Self::OneMinusSrcBlue),
666            _ => Err("invalid value for AlphaOperand".to_string()),
667        }
668    }
669}
670
671/// Texture scale factors.
672#[repr(u8)]
673#[derive(Debug, Clone, Copy, PartialEq, Eq)]
674#[doc(alias = "GPU_TEVSCALE")]
675pub enum Scale {
676    /// 1x scale
677    #[doc(alias = "GPU_TEVSCALE_1")]
678    Original = ctru_sys::GPU_TEVSCALE_1,
679
680    /// 2x scale
681    #[doc(alias = "GPU_TEVSCALE_2")]
682    Double = ctru_sys::GPU_TEVSCALE_2,
683
684    /// 4x scale
685    #[doc(alias = "GPU_TEVSCALE_4")]
686    Quadruple = ctru_sys::GPU_TEVSCALE_4,
687}
688
689impl TryFrom<u8> for Scale {
690    type Error = String;
691    fn try_from(value: u8) -> Result<Self, Self::Error> {
692        match value {
693            ctru_sys::GPU_TEVSCALE_1 => Ok(Self::Original),
694            ctru_sys::GPU_TEVSCALE_2 => Ok(Self::Double),
695            ctru_sys::GPU_TEVSCALE_4 => Ok(Self::Quadruple),
696            _ => Err("invalid value for Scale".to_string()),
697        }
698    }
699}