1 /*---------------------------------------------------------------------------*
2 Project: Horizon
3 File: gd_Texture.h
4 Copyright (C)2011 Nintendo Co., Ltd. All rights reserved.
5 These coded instructions, statements, and computer programs contain
6 proprietary information of Nintendo of America Inc. and/or Nintendo
7 Company Ltd., and are protected by Federal copyright law. They may
8 not be disclosed to third parties or copied or duplicated in any form,
9 in whole or in part, without the prior written consent of Nintendo.
10 *---------------------------------------------------------------------------
11
12
13 */
14 #ifndef NN_GD_CTR_GD_TEXTURE_H_
15 #define NN_GD_CTR_GD_TEXTURE_H_
16
17 #include <limits>
18 #include <nn/gd/CTR/gd_Types.h>
19 #include <nn/gd/CTR/gd_Result.h>
20 #include <nn/gd/CTR/gd_Utils.h>
21
22 #include <nn/gd/CTR/gd_Memory.h>
23 #include <nn/gd/CTR/gd_Resource.h>
24
25 #include <nn/dbg/dbg_DebugString.h>
26
27 #if NN_GD_DOCUMENT_TYPE == ENGLISH
28 /* Please see man pages for details
29
30 */
31 #else
32 /* Please see man pages for details
33
34 */
35 #endif
36
37 namespace nn {
38 namespace gd {
39 namespace CTR {
40
41
42 /*********************************************************************************************************/
43 /********************************************** Internal data ********************************************/
44 class TextureStage;
45 class CombinerStage;
46 class ProceduralTextureStage;
47 class VertexInputStage;
48 namespace internal
49 {
50
51 class TextureStage;
52 class LightingStage;
53 class CombinerStage;
54 class VertexInputStage;
55 class ProceduralTextureSettings
56 {
57 private:
58 u32 m_Proctex0; // 0xa8
59 u32 m_Proctex1; // 0xa9
60 u32 m_Proctex2; // 0xaa
61 u32 m_Proctex3; // 0xab
62 u32 m_Proctex4; // 0xac
63 u32 m_Proctex5; // 0xad
64
65 u32 m_PaddingEndStruct;
66 u32 m_DirtyFieldMask;
67
68 enum
69 {
70 PTMASK_PROCTEX0 = 1 << 0,
71 PTMASK_PROCTEX1 = 1 << 1,
72 PTMASK_PROCTEX2 = 1 << 2,
73 PTMASK_PROCTEX3 = 1 << 3,
74 PTMASK_PROCTEX4 = 1 << 4,
75 PTMASK_PROCTEX5 = 1 << 5,
76
77 PTMASK_REGISTRY_COUNT = 6
78 };
79
80 friend class nn::gd::CTR::internal::TextureStage;
81 friend class nn::gd::CTR::ProceduralTextureStage;
82 friend class nn::gd::CTR::TextureStage;
83 }; // ProceduralTextureSettings
84
85 class TextureSettings
86 {
87 private:
88 u32 m_TextureUnitControl; // 0x80
89
90 //used by sampler states
91 u32 m_FormatTextureUnit0; //0x83
92 u32 m_FormatTextureUnit1; //0x93
93 u32 m_FormatTextureUnit2; //0x9b
94 u32 m_MipLevelsTextureUnit0; //0x84
95 u32 m_MipLevelsTextureUnit1; //0x94
96 u32 m_MipLevelsTextureUnit2; //0x9c
97 u32 m_TypeTextureUnit0; //0x83
98 u32 m_ShadowTextureSetting; //0x8b
99
100 u32 m_ProcTexHardwareEnabled;
101 u32 m_DirtyFieldMask;
102
103 enum
104 {
105 TXMASK_SEND_TEXTURE_UNIT_CONTROL = 1 << 0,
106 TXMASK_UPDATE_TEXTURE_UNIT_CONTROL = 1 << 0 | 1 << 1,
107 TXMASK_UPDATE_TEXTURE_SHADOW_SETTINGS = 1 << 2
108 };
109
110 friend class nn::gd::CTR::ProceduralTextureStage;
111 friend class nn::gd::CTR::internal::TextureStage;
112 friend class nn::gd::CTR::CombinerStage;
113 friend class nn::gd::CTR::TextureStage;
114 friend class nn::gd::CTR::internal::CombinerStage;
115 friend class nn::gd::CTR::internal::LightingStage;
116 friend class nn::gd::CTR::VertexInputStage;
117 friend class nn::gd::CTR::internal::VertexInputStage;
118 }; // TextureSettings
119
120 #if NN_GD_DOCUMENT_TYPE == ENGLISH
121 /* Please see man pages for details */
122 #else
123 /* Please see man pages for details */
124 #endif
125 extern ProceduralTextureSettings g_proceduralTexture;
126 #if NN_GD_DOCUMENT_TYPE == ENGLISH
127 /* Please see man pages for details */
128 #else
129 /* Please see man pages for details */
130 #endif
131 extern TextureSettings g_texture;
132
133 } // internal
134
135 #if NN_GD_DOCUMENT_TYPE == ENGLISH
136 /* Please see man pages for details
137 */
138 #else
139 /* Please see man pages for details
140 */
141 #endif
142 class Texture2DDescription;
143
144 #if NN_GD_DOCUMENT_TYPE == ENGLISH
145 /* Please see man pages for details
146 */
147 #else
148 /* Please see man pages for details
149 */
150 #endif
151 class TextureCubeDescription;
152
153 #if NN_GD_DOCUMENT_TYPE == ENGLISH
154 /* Please see man pages for details
155 */
156 #else
157 /* Please see man pages for details
158 */
159 #endif
160 class SamplerStateDescription;
161
162 #if NN_GD_DOCUMENT_TYPE == ENGLISH
163 /* Please see man pages for details
164 */
165 #else
166 /* Please see man pages for details
167 */
168 #endif
169 class Texture2DProperties;
170
171 #if NN_GD_DOCUMENT_TYPE == ENGLISH
172 /* Please see man pages for details
173 */
174 #else
175 /* Please see man pages for details
176 */
177 #endif
178 class TextureCubeProperties;
179
180 #if NN_GD_DOCUMENT_TYPE == ENGLISH
181 /* Please see man pages for details
182 */
183 #else
184 /* Please see man pages for details
185 */
186 #endif
187 class Texture2D;
188
189 #if NN_GD_DOCUMENT_TYPE == ENGLISH
190 /* Please see man pages for details
191 */
192 #else
193 /* Please see man pages for details
194 */
195 #endif
196 class TextureCube;
197
198 #if NN_GD_DOCUMENT_TYPE == ENGLISH
199 /* Please see man pages for details
200 */
201 #else
202 /* Please see man pages for details
203 */
204 #endif
205 class SamplerState;
206
207
208 /**************************************************************************************************************************/
209 /****************************************************** Texture Stage *****************************************************/
210 #if NN_GD_DOCUMENT_TYPE == ENGLISH
211 /* Please see man pages for details
212
213
214
215
216
217
218
219 */
220 #else
221 /* Please see man pages for details
222
223
224
225
226
227
228
229 */
230 #endif
231 class TextureStage
232 {
233 public:
234
235 #if NN_GD_DOCUMENT_TYPE == ENGLISH
236 /* Please see man pages for details */
237 #else
238 /* Please see man pages for details */
239 #endif
240 enum TextureUnitId
241 {
242 TEXTURE_UNIT_0 = 0,
243 TEXTURE_UNIT_1 = 1,
244 TEXTURE_UNIT_2 = 2,
245 TEXTURE_UNIT_3_PROCEDURAL = 3,
246
247 TEXTURE_UNIT_MAX_U32 = 0xffffffffu
248 };
249
250 #if NN_GD_DOCUMENT_TYPE == ENGLISH
251 /* Please see man pages for details */
252 #else
253 /* Please see man pages for details */
254 #endif
255 enum SamplerWrapMode
256 {
257 SAMPLER_WRAP_CLAMP_TO_EDGE = 0x0,
258 SAMPLER_WRAP_CLAMP_TO_BORDER = 0x1,
259 SAMPLER_WRAP_REPEAT = 0x2,
260 SAMPLER_WRAP_MIRRORED_REPEAT = 0x3,
261
262 SAMPLER_WRAP_MAX_U32 = 0xffffffffu
263 };
264
265 #if NN_GD_DOCUMENT_TYPE == ENGLISH
266 /* Please see man pages for details */
267 #else
268 /* Please see man pages for details */
269 #endif
270 enum SamplerMinFilter
271 {
272 SAMPLER_MIN_FILTER_NEAREST = 0x0,
273 SAMPLER_MIN_FILTER_LINEAR = 0x1,
274 SAMPLER_MIN_FILTER_NEAREST_MIPMAP_NEAREST = 0x2,
275 SAMPLER_MIN_FILTER_LINEAR_MIPMAP_NEAREST = 0x3,
276 SAMPLER_MIN_FILTER_NEAREST_MIPMAP_LINEAR = 0x4,
277 SAMPLER_MIN_FILTER_LINEAR_MIPMAP_LINEAR = 0x5,
278
279 SAMPLER_MIN_FILTER_RESERVED_MAX_U32 = 0xffffffffu
280 };
281
282 #if NN_GD_DOCUMENT_TYPE == ENGLISH
283 /* Please see man pages for details */
284 #else
285 /* Please see man pages for details */
286 #endif
287 enum SamplerMagFilter
288 {
289 SAMPLER_MAG_FILTER_NEAREST = 0x0,
290 SAMPLER_MAG_FILTER_LINEAR = 0x1,
291
292 SAMPLER_MAG_FILTER_RESERVED_MAX_U32 = 0xffffffffu
293 };
294
295 #if NN_GD_DOCUMENT_TYPE == ENGLISH
296 /* Please see man pages for details */
297 #else
298 /* Please see man pages for details */
299 #endif
300 enum TextureCoordinateSourceUnit2
301 {
302 UNIT2_TEXTURE_COORDINATE_FROM_UNIT_2 = 0x0,
303 UNIT2_TEXTURE_COORDINATE_FROM_UNIT_1 = 0x1
304 };
305
306 #if NN_GD_DOCUMENT_TYPE == ENGLISH
307 /* Please see man pages for details */
308 #else
309 /* Please see man pages for details */
310 #endif
311 enum TextureCoordinateSourceUnit3Procedural
312 {
313 UNIT3_PROCEDURAL_TEXTURE_COORDINATE_FROM_UNIT_0 = 0x0,
314 UNIT3_PROCEDURAL_TEXTURE_COORDINATE_FROM_UNIT_1 = 0x1,
315 UNIT3_PROCEDURAL_TEXTURE_COORDINATE_FROM_UNIT_2 = 0x2
316 };
317
318 #if NN_GD_DOCUMENT_TYPE == ENGLISH
319 /* Please see man pages for details
320
321
322
323
324
325
326 */
327 #else
328 /* Please see man pages for details
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344 */
345 #endif
346 static nnResult CreateTexture2D(const Texture2DResource* tex2DResource, Texture2DDescription* desc, Texture2D** texture2D);
347
348 #if NN_GD_DOCUMENT_TYPE == ENGLISH
349 /* Please see man pages for details
350
351
352 */
353 #else
354 /* Please see man pages for details
355
356
357
358
359
360
361 */
362 #endif
363 static nnResult GetTexture2DProperties(const Texture2D* texture2D, Texture2DProperties* properties);
364
365 #if NN_GD_DOCUMENT_TYPE == ENGLISH
366 /* Please see man pages for details
367
368 */
369 #else
370 /* Please see man pages for details
371
372
373
374
375
376 */
377 #endif
378 static nnResult ReleaseTexture2D(Texture2D* texture2D);
379
380
381 #if NN_GD_DOCUMENT_TYPE == ENGLISH
382 /* Please see man pages for details
383
384
385
386
387
388
389
390 */
391 #else
392 /* Please see man pages for details
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414 */
415 #endif
416 static nnResult CreateTextureCube(Texture2DResource** tex2DResources, TextureCubeDescription* desc, TextureCube** textureCube);
417
418 #if NN_GD_DOCUMENT_TYPE == ENGLISH
419 /* Please see man pages for details
420
421
422 */
423 #else
424 /* Please see man pages for details
425
426
427
428
429
430
431 */
432 #endif
433 static nnResult GetTextureCubeProperties(const TextureCube* TextureCube, TextureCubeProperties* properties);
434
435 #if NN_GD_DOCUMENT_TYPE == ENGLISH
436 /* Please see man pages for details
437
438 */
439 #else
440 /* Please see man pages for details
441
442
443
444
445
446 */
447 #endif
448 static nnResult ReleaseTextureCube(TextureCube* textureCube);
449
450 #if NN_GD_DOCUMENT_TYPE == ENGLISH
451 /* Please see man pages for details
452
453
454
455 */
456 #else
457 /* Please see man pages for details
458
459
460
461
462
463
464
465
466 */
467 #endif
468 static nnResult SetTexture(TextureUnitId textureUnitId, Texture2D& texture2D);
469
470 #if NN_GD_DOCUMENT_TYPE == ENGLISH
471 /* Please see man pages for details
472
473
474 */
475 #else
476 /* Please see man pages for details
477
478
479
480
481
482 */
483 #endif
484 static nnResult SetTextureUnit0(TextureCube& textureCube);
485
486 #if NN_GD_DOCUMENT_TYPE == ENGLISH
487 /* Please see man pages for details
488
489 */
490 #else
491 /* Please see man pages for details
492
493 */
494 #endif
495 static void SetTextureCoordinateSourceForUnit2(TextureCoordinateSourceUnit2 u);
496
497 #if NN_GD_DOCUMENT_TYPE == ENGLISH
498 /* Please see man pages for details
499
500 */
501 #else
502 /* Please see man pages for details
503
504 */
505 #endif
506 static void SetTextureCoordinateSourceForUnit3Procedural(TextureCoordinateSourceUnit3Procedural u);
507
508 #if NN_GD_DOCUMENT_TYPE == ENGLISH
509 /* Please see man pages for details
510
511
512 */
513 #else
514 /* Please see man pages for details
515
516
517
518
519
520
521
522
523 */
524 #endif
525 static nnResult CreateSamplerState(const SamplerStateDescription* desc, SamplerState** sampler);
526
527 #if NN_GD_DOCUMENT_TYPE == ENGLISH
528 /* Please see man pages for details
529
530
531 */
532 #else
533 /* Please see man pages for details
534
535
536
537
538
539
540
541
542 */
543 #endif
544 static nnResult SetSamplerState(TextureUnitId textureUnitId, SamplerState* sampler);
545
546 #if NN_GD_DOCUMENT_TYPE == ENGLISH
547 /* Please see man pages for details
548
549 */
550 #else
551 /* Please see man pages for details
552
553
554
555
556
557
558 */
559 #endif
560 static nnResult ReleaseSamplerState(SamplerState* sampler);
561
562 #if NN_GD_DOCUMENT_TYPE == ENGLISH
563 /* Please see man pages for details
564
565 */
566 #else
567 /* Please see man pages for details
568
569 */
570 #endif
571 static void SetPerspectiveShadow(gdBool v);
572
573 #if NN_GD_DOCUMENT_TYPE == ENGLISH
574 /* Please see man pages for details
575
576
577 */
578 #else
579 /* Please see man pages for details
580
581
582 */
583 #endif
584 static void SetShadowZScaleBias(f32 zScale, f32 zBias);
585
586 }; // TextureStage
587
588 /*************************************************************************************************************************/
589 /**************************************************** Procedural Texture *************************************************/
590 #if NN_GD_DOCUMENT_TYPE == ENGLISH
591 /* Please see man pages for details
592
593
594
595
596
597
598 */
599 #else
600 /* Please see man pages for details
601
602
603
604
605
606
607 */
608 #endif
609 class ProceduralTextureStage
610 {
611 public:
612
613 #if NN_GD_DOCUMENT_TYPE == ENGLISH
614 /* Please see man pages for details */
615 #else
616 /* Please see man pages for details */
617 #endif
618 enum ProceduralTextureRgbMap
619 {
620 RGB_MAP_U = 0x0,
621 RGB_MAP_U2 = 0x1,
622 RGB_MAP_V = 0x2,
623 RGB_MAP_V2 = 0x3,
624 RGB_MAP_ADD = 0x4,
625 RGB_MAP_ADD2 = 0x5,
626 RGB_MAP_ADDSQRT2 = 0x6,
627 RGB_MAP_MIN = 0x7,
628 RGB_MAP_MAX = 0x8,
629 RGB_MAP_RMAX = 0x9,
630
631 RGB_MAP_RESERVED_MAX_U32 = 0xffffffffu
632 };
633
634 #if NN_GD_DOCUMENT_TYPE == ENGLISH
635 /* Please see man pages for details */
636 #else
637 /* Please see man pages for details */
638 #endif
639 enum ProceduralTextureClamp
640 {
641 CLAMP_TO_ZERO = 0x0,
642 CLAMP_TO_EDGE = 0x1,
643 CLAMP_SYMMETRICAL_REPEAT = 0x2,
644 CLAMP_MIRRORED_REPEAT = 0x3,
645 CLAMP_PULSE = 0x4,
646
647 CLAMP_RESERVED_MAX_U32 = 0xffffffffu
648 };
649
650 #if NN_GD_DOCUMENT_TYPE == ENGLISH
651 /* Please see man pages for details */
652 #else
653 /* Please see man pages for details */
654 #endif
655 enum ProceduralTextureShift
656 {
657 SHIFT_NONE = 0x0,
658 SHIFT_ODD = 0x1,
659 SHIFT_EVEN = 0x2,
660
661 SHIFT_RESERVED_MAX_U32 = 0xffffffffu
662 };
663
664 #if NN_GD_DOCUMENT_TYPE == ENGLISH
665 /* Please see man pages for details */
666 #else
667 /* Please see man pages for details */
668 #endif
669 enum ProceduralTextureMinFilter
670 {
671 MIN_FILTER_NEAREST = 0x0,
672 MIN_FILTER_LINEAR = 0x1,
673 MIN_FILTER_NEAREST_MIPMAP_NEAREST = 0x2,
674 MIN_FILTER_LINEAR_MIPMAP_NEAREST = 0x3,
675 MIN_FILTER_NEAREST_MIPMAP_LINEAR = 0x4,
676 MIN_FILTER_LINEAR_MIPMAP_LINEAR = 0x5,
677
678 MIN_FILTER_RESERVED_MAX_U32 = 0xffffffffu
679 };
680
681 #if NN_GD_DOCUMENT_TYPE == ENGLISH
682 /* Please see man pages for details
683
684
685 */
686 #else
687 /* Please see man pages for details
688
689
690 */
691 #endif
692 static void SetClampUV(ProceduralTextureClamp u, ProceduralTextureClamp v);
693
694 #if NN_GD_DOCUMENT_TYPE == ENGLISH
695 /* Please see man pages for details
696
697 */
698 #else
699 /* Please see man pages for details
700
701 */
702 #endif
703 static void SetRgbMap(ProceduralTextureRgbMap rgbMap);
704
705 #if NN_GD_DOCUMENT_TYPE == ENGLISH
706 /* Please see man pages for details
707
708 */
709 #else
710 /* Please see man pages for details
711
712 */
713 #endif
714 static void SetAlphaMap(ProceduralTextureRgbMap alphaMap);
715
716 #if NN_GD_DOCUMENT_TYPE == ENGLISH
717 /* Please see man pages for details
718
719 */
720 #else
721 /* Please see man pages for details
722
723 */
724 #endif
725 static void SetAlphaSeparate(gdBool alphaSeparate);
726
727 #if NN_GD_DOCUMENT_TYPE == ENGLISH
728 /* Please see man pages for details
729
730 */
731 #else
732 /* Please see man pages for details
733
734 */
735 #endif
736 static void SetNoiseEnable(gdBool noiseEnable);
737
738 #if NN_GD_DOCUMENT_TYPE == ENGLISH
739 /* Please see man pages for details
740
741
742 */
743 #else
744 /* Please see man pages for details
745
746
747 */
748 #endif
749 static void SetShiftUV(ProceduralTextureShift u, ProceduralTextureShift v);
750
751 #if NN_GD_DOCUMENT_TYPE == ENGLISH
752 /* Please see man pages for details
753
754 */
755 #else
756 /* Please see man pages for details
757
758 */
759 #endif
760 static void SetTexBias(f32 texBias);
761
762 #if NN_GD_DOCUMENT_TYPE == ENGLISH
763 /* Please see man pages for details
764
765 */
766 #else
767 /* Please see man pages for details
768
769 */
770 #endif
771 static void SetMinFilter(ProceduralTextureMinFilter minFilter);
772
773 #if NN_GD_DOCUMENT_TYPE == ENGLISH
774 /* Please see man pages for details
775
776 */
777 #else
778 /* Please see man pages for details
779
780 */
781 #endif
782 static void SetTexWidth(u8 texWidth);
783
784 #if NN_GD_DOCUMENT_TYPE == ENGLISH
785 /* Please see man pages for details
786
787 */
788 #else
789 /* Please see man pages for details
790
791 */
792 #endif
793 static void SetTexOffset(u8 texOffset);
794
795 #if NN_GD_DOCUMENT_TYPE == ENGLISH
796 /* Please see man pages for details
797
798
799 */
800 #else
801 /* Please see man pages for details
802
803
804 */
805 #endif
806 static void SetNoiseUV(f32 noiseU[3], f32 noiseV[3]);
807
808 #if NN_GD_DOCUMENT_TYPE == ENGLISH
809 /* Please see man pages for details
810
811
812
813
814 */
815 #else
816 /* Please see man pages for details
817
818
819
820
821
822
823
824
825
826 */
827 #endif
828 static nnResult UploadLookUpTableRgbMapFloat(u32 index, f32 *Map, f32 *MapDelta, u32 lutSize);
829
830 #if NN_GD_DOCUMENT_TYPE == ENGLISH
831 /* Please see man pages for details
832
833
834
835 */
836 #else
837 /* Please see man pages for details
838
839
840
841
842
843
844
845
846 */
847 #endif
848 static nnResult UploadLookUpTableRgbMapNative(u32 index, u32 *Map, u32 lutSize);
849
850 #if NN_GD_DOCUMENT_TYPE == ENGLISH
851 /* Please see man pages for details
852
853
854
855
856 */
857 #else
858 /* Please see man pages for details
859
860
861
862
863
864
865
866
867
868 */
869 #endif
870 static nnResult UploadLookUpTableAlphaMapFloat(u32 index, f32 *Map, f32 *MapDelta, u32 lutSize);
871
872 #if NN_GD_DOCUMENT_TYPE == ENGLISH
873 /* Please see man pages for details
874
875
876
877 */
878 #else
879 /* Please see man pages for details
880
881
882
883
884
885
886
887
888 */
889 #endif
890 static nnResult UploadLookUpTableAlphaMapNative(u32 index, u32 *Map, u32 lutSize);
891
892 #if NN_GD_DOCUMENT_TYPE == ENGLISH
893 /* Please see man pages for details
894
895
896
897
898 */
899 #else
900 /* Please see man pages for details
901
902
903
904
905
906
907
908
909
910 */
911 #endif
912 static nnResult UploadLookUpTableNoiseMapFloat(u32 index, f32 *Map, f32 *MapDelta, u32 lutSize);
913
914 #if NN_GD_DOCUMENT_TYPE == ENGLISH
915 /* Please see man pages for details
916
917
918
919 */
920 #else
921 /* Please see man pages for details
922
923
924
925
926
927
928
929
930 */
931 #endif
932 static nnResult UploadLookUpTableNoiseMapNative(u32 index, u32 *Map, u32 lutSize);
933
934 #if NN_GD_DOCUMENT_TYPE == ENGLISH
935 /* Please see man pages for details
936
937
938
939
940
941
942 */
943 #else
944 /* Please see man pages for details
945
946
947
948
949
950
951
952
953
954 */
955 #endif
956 static nnResult UploadLookUpTableColorMapFloat(u32 index, f32 **Map, f32 **MapDelta, u32 lutSize);
957
958 #if NN_GD_DOCUMENT_TYPE == ENGLISH
959 /* Please see man pages for details
960
961
962
963
964 */
965 #else
966 /* Please see man pages for details
967
968
969
970
971
972
973
974
975
976
977
978
979 */
980 #endif
981 static nnResult UploadLookUpTableColorMapNative(u32 index, u32 *Map, u32 *MapDelta, u32 lutSize);
982
983 #if NN_GD_DOCUMENT_TYPE == ENGLISH
984 /* Please see man pages for details
985
986 */
987 #else
988 /* Please see man pages for details
989
990 */
991 #endif
992 class Helper
993 {
994 public:
995 #if NN_GD_DOCUMENT_TYPE == ENGLISH
996 /* Please see man pages for details
997
998
999
1000
1001 */
1002 #else
1003 /* Please see man pages for details
1004
1005
1006
1007
1008
1009
1010
1011
1012 */
1013 #endif
1014 static nnResult ConvertLookUpTableDataFloatToNative(f32 *valueData, f32 *deltaData, u32 lutSize, u32* destination);
1015
1016 #if NN_GD_DOCUMENT_TYPE == ENGLISH
1017 /* Please see man pages for details
1018
1019
1020
1021
1022
1023
1024
1025 */
1026 #else
1027 /* Please see man pages for details
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037 */
1038 #endif
1039 static nnResult ConvertColorLookUpTableDataFloatToNative(f32 **refArray, f32 **deltaArray, u32 lutSize, u32* destRef, u32* destDelta);
1040 };
1041
1042 }; // ProceduralTextureStage
1043
1044 /*****************************************************************************************************************************/
1045 /********************************************* Descriptor/Properties class definition ****************************************/
1046 #if NN_GD_DOCUMENT_TYPE == ENGLISH
1047 /* Please see man pages for details
1048
1049
1050 */
1051 #else
1052 /* Please see man pages for details
1053
1054
1055 */
1056 #endif
1057 class Texture2DDescription
1058 {
1059 public:
1060 #if NN_GD_DOCUMENT_TYPE == ENGLISH
1061 /* Please see man pages for details */
1062 #else
1063 /* Please see man pages for details */
1064 #endif
1065 s32 m_MinMipLevelIndex;
1066
1067 #if NN_GD_DOCUMENT_TYPE == ENGLISH
1068 /* Please see man pages for details */
1069 #else
1070 /* Please see man pages for details */
1071 #endif
1072 s32 m_MaxMipLevelIndex;
1073 };
1074
1075
1076 #if NN_GD_DOCUMENT_TYPE == ENGLISH
1077 /* Please see man pages for details
1078
1079
1080 */
1081 #else
1082 /* Please see man pages for details
1083
1084
1085 */
1086 #endif
1087 class Texture2DProperties
1088 {
1089 public:
1090 #if NN_GD_DOCUMENT_TYPE == ENGLISH
1091 /* Please see man pages for details */
1092 #else
1093 /* Please see man pages for details */
1094 #endif
1095 u32 m_Width;
1096
1097 #if NN_GD_DOCUMENT_TYPE == ENGLISH
1098 /* Please see man pages for details */
1099 #else
1100 /* Please see man pages for details */
1101 #endif
1102 u32 m_Height;
1103
1104 #if NN_GD_DOCUMENT_TYPE == ENGLISH
1105 /* Please see man pages for details */
1106 #else
1107 /* Please see man pages for details */
1108 #endif
1109 u32 m_CountMipLevels;
1110
1111 #if NN_GD_DOCUMENT_TYPE == ENGLISH
1112 /* Please see man pages for details */
1113 #else
1114 /* Please see man pages for details */
1115 #endif
1116 u32 m_PixelSize;
1117
1118 #if NN_GD_DOCUMENT_TYPE == ENGLISH
1119 /* Please see man pages for details */
1120 #else
1121 /* Please see man pages for details */
1122 #endif
1123 Resource::NativeResourceFormat m_Format;
1124
1125 #if NN_GD_DOCUMENT_TYPE == ENGLISH
1126 /* Please see man pages for details */
1127 #else
1128 /* Please see man pages for details */
1129 #endif
1130 Memory::MemoryLayout m_MemLayout;
1131
1132 #if NN_GD_DOCUMENT_TYPE == ENGLISH
1133 /* Please see man pages for details */
1134 #else
1135 /* Please see man pages for details */
1136 #endif
1137 Memory::MemoryLocation m_MemLocation;
1138
1139 #if NN_GD_DOCUMENT_TYPE == ENGLISH
1140 /* Please see man pages for details */
1141 #else
1142 /* Please see man pages for details */
1143 #endif
1144 u8* m_MemAddr;
1145
1146 #if NN_GD_DOCUMENT_TYPE == ENGLISH
1147 /* Please see man pages for details
1148
1149 */
1150 #else
1151 /* Please see man pages for details
1152
1153
1154
1155
1156 */
1157 #endif
GetMipmapAddress(u32 mipmapLevel)1158 MipmapResourceInfo GetMipmapAddress(u32 mipmapLevel)
1159 {
1160 MipmapResourceInfo mipmapInfo;
1161 mipmapInfo.m_Width = m_Width;
1162 mipmapInfo.m_Height = m_Height;
1163 mipmapInfo.m_MemAddr = m_MemAddr;
1164 for (u32 i=0; i<mipmapLevel; ++i)
1165 {
1166 mipmapInfo.m_MemAddr += (mipmapInfo.m_Width * mipmapInfo.m_Height * m_PixelSize) >> 3;
1167 mipmapInfo.m_Width >>= 1;
1168 mipmapInfo.m_Height >>= 1;
1169 }
1170 return mipmapInfo;
1171 }
1172 }; // Texture2DProperties
1173
1174
1175 #if NN_GD_DOCUMENT_TYPE == ENGLISH
1176 /* Please see man pages for details
1177
1178
1179 */
1180 #else
1181 /* Please see man pages for details
1182
1183
1184 */
1185 #endif
1186 class TextureCubeDescription
1187 {
1188 public:
1189 #if NN_GD_DOCUMENT_TYPE == ENGLISH
1190 /* Please see man pages for details */
1191 #else
1192 /* Please see man pages for details */
1193 #endif
1194 s32 m_MinMipLevelIndex[6];
1195
1196 #if NN_GD_DOCUMENT_TYPE == ENGLISH
1197 /* Please see man pages for details */
1198 #else
1199 /* Please see man pages for details */
1200 #endif
1201 s32 m_MaxMipLevelIndex[6];
1202
1203 #if NN_GD_DOCUMENT_TYPE == ENGLISH
1204 /* Please see man pages for details */
1205 #else
1206 /* Please see man pages for details */
1207 #endif
TextureCubeDescription()1208 TextureCubeDescription(){
1209 for (int i=0; i<6; ++i){
1210 m_MinMipLevelIndex[i] = 0;
1211 m_MaxMipLevelIndex[i] = -1;
1212 }
1213 }
1214
1215 #if NN_GD_DOCUMENT_TYPE == ENGLISH
1216 /* Please see man pages for details
1217
1218
1219 */
1220 #else
1221 /* Please see man pages for details
1222
1223
1224 */
1225 #endif
TextureCubeDescription(int minMipLevelIndex,int maxMipLevelIndex)1226 TextureCubeDescription(int minMipLevelIndex, int maxMipLevelIndex){
1227 for (int i=0; i<6; ++i){
1228 m_MinMipLevelIndex[i] = minMipLevelIndex;
1229 m_MaxMipLevelIndex[i] = maxMipLevelIndex;
1230 }
1231 }
1232 }; // TextureCubeDescription
1233
1234
1235 #if NN_GD_DOCUMENT_TYPE == ENGLISH
1236 /* Please see man pages for details
1237
1238
1239 */
1240 #else
1241 /* Please see man pages for details
1242
1243
1244 */
1245 #endif
1246 class TextureCubeProperties
1247 {
1248 public:
1249 #if NN_GD_DOCUMENT_TYPE == ENGLISH
1250 /* Please see man pages for details */
1251 #else
1252 /* Please see man pages for details */
1253 #endif
1254 u32 m_Width;
1255
1256 #if NN_GD_DOCUMENT_TYPE == ENGLISH
1257 /* Please see man pages for details */
1258 #else
1259 /* Please see man pages for details */
1260 #endif
1261 u32 m_Height;
1262
1263 #if NN_GD_DOCUMENT_TYPE == ENGLISH
1264 /* Please see man pages for details */
1265 #else
1266 /* Please see man pages for details */
1267 #endif
1268 u32 m_CountMipLevels;
1269
1270 #if NN_GD_DOCUMENT_TYPE == ENGLISH
1271 /* Please see man pages for details */
1272 #else
1273 /* Please see man pages for details */
1274 #endif
1275 u32 m_PixelSize;
1276
1277 #if NN_GD_DOCUMENT_TYPE == ENGLISH
1278 /* Please see man pages for details */
1279 #else
1280 /* Please see man pages for details */
1281 #endif
1282 Resource::NativeResourceFormat m_Format;
1283
1284 #if NN_GD_DOCUMENT_TYPE == ENGLISH
1285 /* Please see man pages for details */
1286 #else
1287 /* Please see man pages for details */
1288 #endif
1289 Memory::MemoryLayout m_MemLayout;
1290
1291 #if NN_GD_DOCUMENT_TYPE == ENGLISH
1292 /* Please see man pages for details */
1293 #else
1294 /* Please see man pages for details */
1295 #endif
1296 Memory::MemoryLocation m_MemLocation;
1297
1298 #if NN_GD_DOCUMENT_TYPE == ENGLISH
1299 /* Please see man pages for details */
1300 #else
1301 /* Please see man pages for details */
1302 #endif
1303 u8* m_MemAddr[6];
1304
1305 #if NN_GD_DOCUMENT_TYPE == ENGLISH
1306 /* Please see man pages for details
1307
1308
1309 */
1310 #else
1311 /* Please see man pages for details
1312
1313
1314
1315
1316
1317 */
1318 #endif
GetMipmapAddress(u32 faceIndex,u32 mipmapLevel)1319 MipmapResourceInfo GetMipmapAddress(u32 faceIndex, u32 mipmapLevel)
1320 {
1321 MipmapResourceInfo mipmapInfo;
1322 mipmapInfo.m_Width = m_Width;
1323 mipmapInfo.m_Height = m_Height;
1324 mipmapInfo.m_MemAddr = m_MemAddr[faceIndex];
1325 for (u32 i=0; i<mipmapLevel; ++i)
1326 {
1327 mipmapInfo.m_MemAddr += (mipmapInfo.m_Width * mipmapInfo.m_Height * m_PixelSize) >> 3;
1328 mipmapInfo.m_Width >>= 1;
1329 mipmapInfo.m_Height >>= 1;
1330 }
1331 return mipmapInfo;
1332 }
1333 }; // TextureCubeProperties
1334
1335
1336 #if NN_GD_DOCUMENT_TYPE == ENGLISH
1337 /* Please see man pages for details
1338
1339
1340 */
1341 #else
1342 /* Please see man pages for details
1343
1344
1345 */
1346 #endif
1347 class SamplerStateDescription
1348 {
1349 public:
1350
1351 #if NN_GD_DOCUMENT_TYPE == ENGLISH
1352 /* Please see man pages for details
1353
1354 */
1355 #else
1356 /* Please see man pages for details
1357
1358 */
1359 #endif
1360 TextureStage::SamplerMinFilter m_MinFilter;
1361
1362 #if NN_GD_DOCUMENT_TYPE == ENGLISH
1363 /* Please see man pages for details
1364
1365 */
1366 #else
1367 /* Please see man pages for details
1368
1369 */
1370 #endif
1371 TextureStage::SamplerMagFilter m_MagFilter;
1372
1373 #if NN_GD_DOCUMENT_TYPE == ENGLISH
1374 /* Please see man pages for details
1375
1376 */
1377 #else
1378 /* Please see man pages for details
1379
1380 */
1381 #endif
1382 TextureStage::SamplerWrapMode m_WrapS;
1383
1384 #if NN_GD_DOCUMENT_TYPE == ENGLISH
1385 /* Please see man pages for details
1386
1387 */
1388 #else
1389 /* Please see man pages for details
1390
1391 */
1392 #endif
1393 TextureStage::SamplerWrapMode m_WrapT;
1394
1395 #if NN_GD_DOCUMENT_TYPE == ENGLISH
1396 /* Please see man pages for details
1397
1398 */
1399 #else
1400 /* Please see man pages for details
1401
1402 */
1403 #endif
1404 u8 m_BorderColor[4];
1405
1406 #if NN_GD_DOCUMENT_TYPE == ENGLISH
1407 /* Please see man pages for details
1408
1409 */
1410 #else
1411 /* Please see man pages for details
1412
1413 */
1414 #endif
1415 u32 m_LodBias;
1416
1417 #if NN_GD_DOCUMENT_TYPE == ENGLISH
1418 /* Please see man pages for details
1419
1420 */
1421 #else
1422 /* Please see man pages for details
1423
1424 */
1425 #endif
1426 u32 m_MinLod;
1427
1428 #if NN_GD_DOCUMENT_TYPE == ENGLISH
1429 /* Please see man pages for details
1430
1431 */
1432 #else
1433 /* Please see man pages for details
1434
1435 */
1436 #endif
1437 u32 m_MaxLod;
1438
1439
1440 #if NN_GD_DOCUMENT_TYPE == ENGLISH
1441 /* Please see man pages for details
1442
1443 */
1444 #else
1445 /* Please see man pages for details
1446
1447 */
1448 #endif
SetMinFilter(TextureStage::SamplerMinFilter filter)1449 void SetMinFilter(TextureStage::SamplerMinFilter filter) { m_MinFilter = filter; }
1450
1451 #if NN_GD_DOCUMENT_TYPE == ENGLISH
1452 /* Please see man pages for details
1453
1454 */
1455 #else
1456 /* Please see man pages for details
1457
1458 */
1459 #endif
SetMagFilter(TextureStage::SamplerMagFilter filter)1460 void SetMagFilter(TextureStage::SamplerMagFilter filter) { m_MagFilter = filter; }
1461
1462 #if NN_GD_DOCUMENT_TYPE == ENGLISH
1463 /* Please see man pages for details
1464
1465 */
1466 #else
1467 /* Please see man pages for details
1468
1469 */
1470 #endif
SetWrapS(TextureStage::SamplerWrapMode wrap)1471 void SetWrapS(TextureStage::SamplerWrapMode wrap) { m_WrapS = wrap; }
1472
1473 #if NN_GD_DOCUMENT_TYPE == ENGLISH
1474 /* Please see man pages for details
1475
1476 */
1477 #else
1478 /* Please see man pages for details
1479
1480 */
1481 #endif
SetWrapT(TextureStage::SamplerWrapMode wrap)1482 void SetWrapT(TextureStage::SamplerWrapMode wrap) { m_WrapT = wrap; }
1483
1484 #if NN_GD_DOCUMENT_TYPE == ENGLISH
1485 /* Please see man pages for details
1486
1487
1488
1489
1490 */
1491 #else
1492 /* Please see man pages for details
1493
1494
1495
1496
1497 */
1498 #endif
SetBorderColor(u8 colorR,u8 colorG,u8 colorB,u8 colorA)1499 void SetBorderColor(u8 colorR, u8 colorG, u8 colorB, u8 colorA)
1500 {
1501 m_BorderColor[0] = colorR;
1502 m_BorderColor[1] = colorG;
1503 m_BorderColor[2] = colorB;
1504 m_BorderColor[3] = colorA;
1505 }
1506
1507 #if NN_GD_DOCUMENT_TYPE == ENGLISH
1508 /* Please see man pages for details
1509
1510
1511
1512
1513 */
1514 #else
1515 /* Please see man pages for details
1516
1517
1518
1519
1520 */
1521 #endif
SetBorderColor(f32 colorR,f32 colorG,f32 colorB,f32 colorA)1522 void SetBorderColor(f32 colorR, f32 colorG, f32 colorB, f32 colorA)
1523 {
1524 m_BorderColor[0] = Utils::FloatToUnsignedByte(colorR);
1525 m_BorderColor[1] = Utils::FloatToUnsignedByte(colorG);
1526 m_BorderColor[2] = Utils::FloatToUnsignedByte(colorB);
1527 m_BorderColor[3] = Utils::FloatToUnsignedByte(colorA);
1528 }
1529
1530 #if NN_GD_DOCUMENT_TYPE == ENGLISH
1531 /* Please see man pages for details
1532
1533 */
1534 #else
1535 /* Please see man pages for details
1536
1537 */
1538 #endif
SetLodBias(f32 biasValue)1539 void SetLodBias(f32 biasValue) { m_LodBias = Utils::Float32ToFix13Fraction8(biasValue); }
1540
1541 #if NN_GD_DOCUMENT_TYPE == ENGLISH
1542 /* Please see man pages for details
1543
1544 */
1545 #else
1546 /* Please see man pages for details
1547
1548 */
1549 #endif
SetMinLod(u32 lodValue)1550 void SetMinLod(u32 lodValue) { m_MinLod = lodValue; }
1551
1552 #if NN_GD_DOCUMENT_TYPE == ENGLISH
1553 /* Please see man pages for details
1554
1555 */
1556 #else
1557 /* Please see man pages for details
1558
1559 */
1560 #endif
SetMaxLod(u32 lodValue)1561 void SetMaxLod(u32 lodValue) { m_MaxLod = lodValue; }
1562
SamplerStateDescription()1563 SamplerStateDescription() { ToDefault(); }
1564
1565 #if NN_GD_DOCUMENT_TYPE == ENGLISH
1566 /* Please see man pages for details
1567 */
1568 #else
1569 /* Please see man pages for details
1570 */
1571 #endif
ToDefault()1572 void ToDefault()
1573 {
1574 m_MinFilter = TextureStage::SAMPLER_MIN_FILTER_NEAREST;
1575 m_MagFilter = TextureStage::SAMPLER_MAG_FILTER_NEAREST;
1576 m_WrapS = TextureStage::SAMPLER_WRAP_REPEAT;
1577 m_WrapT = TextureStage::SAMPLER_WRAP_REPEAT;
1578 m_BorderColor[0] = m_BorderColor[1] = m_BorderColor[2] = m_BorderColor[3] = 0;
1579 m_LodBias = 0;
1580 m_MinLod = 0;
1581 m_MaxLod = UINT_MAX;
1582 }
1583
1584 #if NN_GD_DOCUMENT_TYPE == ENGLISH
1585 /* Please see man pages for details
1586 */
1587 #else
1588 /* Please see man pages for details
1589 */
1590 #endif
SetShadow()1591 void SetShadow()
1592 {
1593 m_MinFilter = TextureStage::SAMPLER_MIN_FILTER_LINEAR;
1594 m_MagFilter = TextureStage::SAMPLER_MAG_FILTER_LINEAR;
1595 m_WrapS = TextureStage::SAMPLER_WRAP_CLAMP_TO_BORDER;
1596 m_WrapT = TextureStage::SAMPLER_WRAP_CLAMP_TO_BORDER;
1597 m_BorderColor[0] = m_BorderColor[1] = m_BorderColor[2] = m_BorderColor[3] = 0;
1598 m_LodBias = 0;
1599 m_MinLod = 0;
1600 m_MaxLod = UINT_MAX;
1601 }
1602
1603 #if NN_GD_DOCUMENT_TYPE == ENGLISH
1604 /* Please see man pages for details
1605 */
1606 #else
1607 /* Please see man pages for details
1608 */
1609 #endif
SetShadowCube()1610 void SetShadowCube()
1611 {
1612 m_MinFilter = TextureStage::SAMPLER_MIN_FILTER_LINEAR;
1613 m_MagFilter = TextureStage::SAMPLER_MAG_FILTER_LINEAR;
1614 m_WrapS = TextureStage::SAMPLER_WRAP_CLAMP_TO_EDGE;
1615 m_WrapT = TextureStage::SAMPLER_WRAP_CLAMP_TO_EDGE;
1616 m_BorderColor[0] = m_BorderColor[1] = m_BorderColor[2] = m_BorderColor[3] = 0;
1617 m_LodBias = 0;
1618 m_MinLod = 0;
1619 m_MaxLod = UINT_MAX;
1620 }
1621
1622 #if NN_GD_DOCUMENT_TYPE == ENGLISH
1623 /* Please see man pages for details
1624 */
1625 #else
1626 /* Please see man pages for details
1627 */
1628 #endif
SetGas()1629 void SetGas()
1630 {
1631 m_MinFilter = TextureStage::SAMPLER_MIN_FILTER_NEAREST;
1632 m_MagFilter = TextureStage::SAMPLER_MAG_FILTER_NEAREST;
1633 m_WrapS = TextureStage::SAMPLER_WRAP_CLAMP_TO_EDGE;
1634 m_WrapT = TextureStage::SAMPLER_WRAP_CLAMP_TO_EDGE;
1635 m_BorderColor[0] = m_BorderColor[1] = m_BorderColor[2] = m_BorderColor[3] = 0;
1636 m_LodBias = 0;
1637 m_MinLod = 0;
1638 m_MaxLod = UINT_MAX;
1639 }
1640 }; // SamplerStateDescription
1641
1642
1643 /**************************************************************************************************************************/
1644 /******************************************* TextureStage inline functions *************************************************/
SetPerspectiveShadow(gdBool v)1645 NN_FORCE_INLINE void TextureStage::SetPerspectiveShadow(gdBool v)
1646 {
1647 // 0x8b[0:0]
1648 internal::g_texture.m_ShadowTextureSetting &= ~(0x1);
1649 if (!v) internal::g_texture.m_ShadowTextureSetting |= 0x1;
1650 internal::g_texture.m_DirtyFieldMask |= internal::TextureSettings::TXMASK_UPDATE_TEXTURE_SHADOW_SETTINGS;
1651 }
1652
SetShadowZScaleBias(f32 zScale,f32 zBias)1653 NN_FORCE_INLINE void TextureStage::SetShadowZScaleBias(f32 zScale, f32 zBias)
1654 {
1655 u32 scale = ((((*(u32*)&zScale) >> 23) & 0xff) - 127);
1656 u32 bias;
1657 bias = Utils::Float32ToUnsignedFix24(zBias);
1658
1659 // Bias: 0x8b[23:1]
1660 internal::g_texture.m_ShadowTextureSetting &= ~(0x7fffff << 1);
1661 internal::g_texture.m_ShadowTextureSetting |= bias & 0xfffffe;
1662
1663 // Scale: 0x8b[31:24]
1664 internal::g_texture.m_ShadowTextureSetting &= ~(0xff000000);
1665 internal::g_texture.m_ShadowTextureSetting |= scale << 24;
1666 internal::g_texture.m_DirtyFieldMask |= internal::TextureSettings::TXMASK_UPDATE_TEXTURE_SHADOW_SETTINGS;
1667 }
1668
SetTextureCoordinateSourceForUnit2(TextureCoordinateSourceUnit2 u)1669 NN_FORCE_INLINE void TextureStage::SetTextureCoordinateSourceForUnit2(TextureCoordinateSourceUnit2 u)
1670 {
1671 internal::g_texture.m_TextureUnitControl &= ~(0x1 << 13);
1672 internal::g_texture.m_TextureUnitControl |= (u & 0x1) << 13;
1673 internal::g_texture.m_DirtyFieldMask |= internal::TextureSettings::TXMASK_SEND_TEXTURE_UNIT_CONTROL;
1674 }
1675
1676 /**************************************************************************************************************************/
1677 /**************************************** ProceduralTextureStage inline functions **********************************************/
1678
SetTextureCoordinateSourceForUnit3Procedural(TextureCoordinateSourceUnit3Procedural u)1679 NN_FORCE_INLINE void TextureStage::SetTextureCoordinateSourceForUnit3Procedural(TextureCoordinateSourceUnit3Procedural u)
1680 {
1681 internal::g_texture.m_TextureUnitControl &= ~(0x3 << 8);
1682 internal::g_texture.m_TextureUnitControl |= (u & 0x3) << 8;
1683 internal::g_texture.m_DirtyFieldMask |= internal::TextureSettings::TXMASK_SEND_TEXTURE_UNIT_CONTROL;
1684 }
1685
1686
SetClampUV(ProceduralTextureClamp u,ProceduralTextureClamp v)1687 NN_FORCE_INLINE void ProceduralTextureStage::SetClampUV(ProceduralTextureClamp u, ProceduralTextureClamp v)
1688 {
1689 internal::g_proceduralTexture.m_Proctex0 &= ~(0x3f);
1690 internal::g_proceduralTexture.m_Proctex0 |= (u & 0x7) | ((v & 0x7) << 3);
1691 internal::g_proceduralTexture.m_DirtyFieldMask |= internal::ProceduralTextureSettings::PTMASK_PROCTEX0;
1692 }
1693
SetRgbMap(ProceduralTextureRgbMap rgbMap)1694 NN_FORCE_INLINE void ProceduralTextureStage::SetRgbMap(ProceduralTextureRgbMap rgbMap)
1695 {
1696 internal::g_proceduralTexture.m_Proctex0 &= ~(0xf << 6);
1697 internal::g_proceduralTexture.m_Proctex0 |= (rgbMap & 0xf) << 6;
1698 internal::g_proceduralTexture.m_DirtyFieldMask |= internal::ProceduralTextureSettings::PTMASK_PROCTEX0;
1699 }
1700
SetAlphaMap(ProceduralTextureRgbMap alphaMap)1701 NN_FORCE_INLINE void ProceduralTextureStage::SetAlphaMap(ProceduralTextureRgbMap alphaMap)
1702 {
1703 internal::g_proceduralTexture.m_Proctex0 &= ~(0xf << 10);
1704 internal::g_proceduralTexture.m_Proctex0 |= (alphaMap & 0xf) << 10;
1705 internal::g_proceduralTexture.m_DirtyFieldMask |= internal::ProceduralTextureSettings::PTMASK_PROCTEX0;
1706 }
1707
SetAlphaSeparate(gdBool alphaSeparate)1708 NN_FORCE_INLINE void ProceduralTextureStage::SetAlphaSeparate(gdBool alphaSeparate)
1709 {
1710 internal::g_proceduralTexture.m_Proctex0 &= ~(1 << 14);
1711 if (alphaSeparate) internal::g_proceduralTexture.m_Proctex0 |= 1 << 14;
1712 internal::g_proceduralTexture.m_DirtyFieldMask |= internal::ProceduralTextureSettings::PTMASK_PROCTEX0;
1713 }
1714
SetNoiseEnable(gdBool noiseEnable)1715 NN_FORCE_INLINE void ProceduralTextureStage::SetNoiseEnable(gdBool noiseEnable)
1716 {
1717 internal::g_proceduralTexture.m_Proctex0 &= ~(1 << 15);
1718 if (noiseEnable) internal::g_proceduralTexture.m_Proctex0 |= 1 << 15;
1719 internal::g_proceduralTexture.m_DirtyFieldMask |= internal::ProceduralTextureSettings::PTMASK_PROCTEX0;
1720 }
1721
SetShiftUV(ProceduralTextureShift u,ProceduralTextureShift v)1722 NN_FORCE_INLINE void ProceduralTextureStage::SetShiftUV(ProceduralTextureShift u, ProceduralTextureShift v)
1723 {
1724 internal::g_proceduralTexture.m_Proctex0 &= ~(0xf << 16);
1725 internal::g_proceduralTexture.m_Proctex0 |= ((u & 0x3) << 16) | ((v & 0x3) << 18);
1726 internal::g_proceduralTexture.m_DirtyFieldMask |= internal::ProceduralTextureSettings::PTMASK_PROCTEX0;
1727 }
1728
SetTexBias(f32 texBias)1729 NN_FORCE_INLINE void ProceduralTextureStage::SetTexBias(f32 texBias)
1730 {
1731 u32 v = Utils::Float32ToFloat16(texBias);
1732
1733 internal::g_proceduralTexture.m_Proctex0 &= ~(0xff << 20);
1734 internal::g_proceduralTexture.m_Proctex0 |= (v & 0xff) << 20 ;
1735 internal::g_proceduralTexture.m_Proctex4 &= ~(0xff << 19);
1736 internal::g_proceduralTexture.m_Proctex4 |= ((v>>8) & 0xff) << 19 ;
1737
1738 internal::g_proceduralTexture.m_DirtyFieldMask |= internal::ProceduralTextureSettings::PTMASK_PROCTEX0 |
1739 internal::ProceduralTextureSettings::PTMASK_PROCTEX4;
1740 }
1741
SetMinFilter(ProceduralTextureMinFilter minFilter)1742 NN_FORCE_INLINE void ProceduralTextureStage::SetMinFilter(ProceduralTextureMinFilter minFilter)
1743 {
1744 internal::g_proceduralTexture.m_Proctex4 &= ~0x7;
1745 internal::g_proceduralTexture.m_Proctex4 |= minFilter & 0x7;
1746 internal::g_proceduralTexture.m_DirtyFieldMask |= internal::ProceduralTextureSettings::PTMASK_PROCTEX4;
1747 }
1748
SetTexWidth(u8 texWidth)1749 NN_FORCE_INLINE void ProceduralTextureStage::SetTexWidth(u8 texWidth)
1750 {
1751 internal::g_proceduralTexture.m_Proctex4 &= ~(0xff << 11);
1752 internal::g_proceduralTexture.m_Proctex4 |= texWidth << 11;
1753 internal::g_proceduralTexture.m_DirtyFieldMask |= internal::ProceduralTextureSettings::PTMASK_PROCTEX4;
1754 }
1755
SetTexOffset(u8 texOffset)1756 NN_FORCE_INLINE void ProceduralTextureStage::SetTexOffset(u8 texOffset)
1757 {
1758 internal::g_proceduralTexture.m_Proctex5 = texOffset | 0xe0c08000;
1759 internal::g_proceduralTexture.m_DirtyFieldMask |= internal::ProceduralTextureSettings::PTMASK_PROCTEX5;
1760 }
1761
1762 } // namespace CTR
1763 } // gd
1764 } // nn
1765
1766
1767 #endif //NN_GD_CTR_GD_TEXTURE_H_
1768