citro3d/
texture.rs

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