forked from microsoft/DirectXMath
-
Notifications
You must be signed in to change notification settings - Fork 0
/
DirectXPackedVector.h
1216 lines (983 loc) · 47.8 KB
/
DirectXPackedVector.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
//-------------------------------------------------------------------------------------
// DirectXPackedVector.h -- SIMD C++ Math library
//
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.
//
// http://go.microsoft.com/fwlink/?LinkID=615560
//-------------------------------------------------------------------------------------
#pragma once
#include "DirectXMath.h"
namespace DirectX
{
namespace PackedVector
{
#pragma warning(push)
#pragma warning(disable:4201 4365 4324 4996)
// C4201: nonstandard extension used
// C4365: Off by default noise
// C4324: alignment padding warnings
// C4996: deprecation warnings
#ifdef __clang__
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wgnu-anonymous-struct"
#pragma clang diagnostic ignored "-Wnested-anon-types"
#endif
//------------------------------------------------------------------------------
// ARGB Color; 8-8-8-8 bit unsigned normalized integer components packed into
// a 32 bit integer. The normalized color is packed into 32 bits using 8 bit
// unsigned, normalized integers for the alpha, red, green, and blue components.
// The alpha component is stored in the most significant bits and the blue
// component in the least significant bits (A8R8G8B8):
// [32] aaaaaaaa rrrrrrrr gggggggg bbbbbbbb [0]
struct XMCOLOR
{
union
{
struct
{
uint8_t b; // Blue: 0/255 to 255/255
uint8_t g; // Green: 0/255 to 255/255
uint8_t r; // Red: 0/255 to 255/255
uint8_t a; // Alpha: 0/255 to 255/255
};
uint32_t c;
};
XMCOLOR() = default;
XMCOLOR(const XMCOLOR&) = default;
XMCOLOR& operator=(const XMCOLOR&) = default;
XMCOLOR(XMCOLOR&&) = default;
XMCOLOR& operator=(XMCOLOR&&) = default;
constexpr XMCOLOR(uint32_t Color) noexcept : c(Color) {}
XMCOLOR(float _r, float _g, float _b, float _a) noexcept;
explicit XMCOLOR(_In_reads_(4) const float* pArray) noexcept;
operator uint32_t () const noexcept { return c; }
XMCOLOR& operator= (const uint32_t Color) noexcept { c = Color; return *this; }
};
//------------------------------------------------------------------------------
// 16 bit floating point number consisting of a sign bit, a 5 bit biased
// exponent, and a 10 bit mantissa
using HALF = uint16_t;
//------------------------------------------------------------------------------
// 2D Vector; 16 bit floating point components
struct XMHALF2
{
union
{
struct
{
HALF x;
HALF y;
};
uint32_t v;
};
XMHALF2() = default;
XMHALF2(const XMHALF2&) = default;
XMHALF2& operator=(const XMHALF2&) = default;
XMHALF2(XMHALF2&&) = default;
XMHALF2& operator=(XMHALF2&&) = default;
explicit constexpr XMHALF2(uint32_t Packed) noexcept : v(Packed) {}
constexpr XMHALF2(HALF _x, HALF _y) noexcept : x(_x), y(_y) {}
explicit XMHALF2(_In_reads_(2) const HALF* pArray) noexcept : x(pArray[0]), y(pArray[1]) {}
XMHALF2(float _x, float _y) noexcept;
explicit XMHALF2(_In_reads_(2) const float* pArray) noexcept;
XMHALF2& operator= (uint32_t Packed) noexcept { v = Packed; return *this; }
};
//------------------------------------------------------------------------------
// 2D Vector; 16 bit signed normalized integer components
struct XMSHORTN2
{
union
{
struct
{
int16_t x;
int16_t y;
};
uint32_t v;
};
XMSHORTN2() = default;
XMSHORTN2(const XMSHORTN2&) = default;
XMSHORTN2& operator=(const XMSHORTN2&) = default;
XMSHORTN2(XMSHORTN2&&) = default;
XMSHORTN2& operator=(XMSHORTN2&&) = default;
explicit constexpr XMSHORTN2(uint32_t Packed) noexcept : v(Packed) {}
constexpr XMSHORTN2(int16_t _x, int16_t _y) noexcept : x(_x), y(_y) {}
explicit XMSHORTN2(_In_reads_(2) const int16_t* pArray) noexcept : x(pArray[0]), y(pArray[1]) {}
XMSHORTN2(float _x, float _y) noexcept;
explicit XMSHORTN2(_In_reads_(2) const float* pArray) noexcept;
XMSHORTN2& operator= (uint32_t Packed) noexcept { v = Packed; return *this; }
};
// 2D Vector; 16 bit signed integer components
struct XMSHORT2
{
union
{
struct
{
int16_t x;
int16_t y;
};
uint32_t v;
};
XMSHORT2() = default;
XMSHORT2(const XMSHORT2&) = default;
XMSHORT2& operator=(const XMSHORT2&) = default;
XMSHORT2(XMSHORT2&&) = default;
XMSHORT2& operator=(XMSHORT2&&) = default;
explicit constexpr XMSHORT2(uint32_t Packed) noexcept : v(Packed) {}
constexpr XMSHORT2(int16_t _x, int16_t _y) noexcept : x(_x), y(_y) {}
explicit XMSHORT2(_In_reads_(2) const int16_t* pArray) noexcept : x(pArray[0]), y(pArray[1]) {}
XMSHORT2(float _x, float _y) noexcept;
explicit XMSHORT2(_In_reads_(2) const float* pArray) noexcept;
XMSHORT2& operator= (uint32_t Packed) noexcept { v = Packed; return *this; }
};
// 2D Vector; 16 bit unsigned normalized integer components
struct XMUSHORTN2
{
union
{
struct
{
uint16_t x;
uint16_t y;
};
uint32_t v;
};
XMUSHORTN2() = default;
XMUSHORTN2(const XMUSHORTN2&) = default;
XMUSHORTN2& operator=(const XMUSHORTN2&) = default;
XMUSHORTN2(XMUSHORTN2&&) = default;
XMUSHORTN2& operator=(XMUSHORTN2&&) = default;
explicit constexpr XMUSHORTN2(uint32_t Packed) noexcept : v(Packed) {}
constexpr XMUSHORTN2(uint16_t _x, uint16_t _y) noexcept : x(_x), y(_y) {}
explicit XMUSHORTN2(_In_reads_(2) const uint16_t* pArray) noexcept : x(pArray[0]), y(pArray[1]) {}
XMUSHORTN2(float _x, float _y) noexcept;
explicit XMUSHORTN2(_In_reads_(2) const float* pArray) noexcept;
XMUSHORTN2& operator= (uint32_t Packed) noexcept { v = Packed; return *this; }
};
// 2D Vector; 16 bit unsigned integer components
struct XMUSHORT2
{
union
{
struct
{
uint16_t x;
uint16_t y;
};
uint32_t v;
};
XMUSHORT2() = default;
XMUSHORT2(const XMUSHORT2&) = default;
XMUSHORT2& operator=(const XMUSHORT2&) = default;
XMUSHORT2(XMUSHORT2&&) = default;
XMUSHORT2& operator=(XMUSHORT2&&) = default;
explicit constexpr XMUSHORT2(uint32_t Packed) noexcept : v(Packed) {}
constexpr XMUSHORT2(uint16_t _x, uint16_t _y) noexcept : x(_x), y(_y) {}
explicit XMUSHORT2(_In_reads_(2) const uint16_t* pArray) noexcept : x(pArray[0]), y(pArray[1]) {}
XMUSHORT2(float _x, float _y) noexcept;
explicit XMUSHORT2(_In_reads_(2) const float* pArray) noexcept;
XMUSHORT2& operator= (uint32_t Packed) noexcept { v = Packed; return *this; }
};
//------------------------------------------------------------------------------
// 2D Vector; 8 bit signed normalized integer components
struct XMBYTEN2
{
union
{
struct
{
int8_t x;
int8_t y;
};
uint16_t v;
};
XMBYTEN2() = default;
XMBYTEN2(const XMBYTEN2&) = default;
XMBYTEN2& operator=(const XMBYTEN2&) = default;
XMBYTEN2(XMBYTEN2&&) = default;
XMBYTEN2& operator=(XMBYTEN2&&) = default;
explicit constexpr XMBYTEN2(uint16_t Packed) noexcept : v(Packed) {}
constexpr XMBYTEN2(int8_t _x, int8_t _y) noexcept : x(_x), y(_y) {}
explicit XMBYTEN2(_In_reads_(2) const int8_t* pArray) noexcept : x(pArray[0]), y(pArray[1]) {}
XMBYTEN2(float _x, float _y) noexcept;
explicit XMBYTEN2(_In_reads_(2) const float* pArray) noexcept;
XMBYTEN2& operator= (uint16_t Packed) noexcept { v = Packed; return *this; }
};
// 2D Vector; 8 bit signed integer components
struct XMBYTE2
{
union
{
struct
{
int8_t x;
int8_t y;
};
uint16_t v;
};
XMBYTE2() = default;
XMBYTE2(const XMBYTE2&) = default;
XMBYTE2& operator=(const XMBYTE2&) = default;
XMBYTE2(XMBYTE2&&) = default;
XMBYTE2& operator=(XMBYTE2&&) = default;
explicit constexpr XMBYTE2(uint16_t Packed) noexcept : v(Packed) {}
constexpr XMBYTE2(int8_t _x, int8_t _y) noexcept : x(_x), y(_y) {}
explicit XMBYTE2(_In_reads_(2) const int8_t* pArray) noexcept : x(pArray[0]), y(pArray[1]) {}
XMBYTE2(float _x, float _y) noexcept;
explicit XMBYTE2(_In_reads_(2) const float* pArray) noexcept;
XMBYTE2& operator= (uint16_t Packed) noexcept { v = Packed; return *this; }
};
// 2D Vector; 8 bit unsigned normalized integer components
struct XMUBYTEN2
{
union
{
struct
{
uint8_t x;
uint8_t y;
};
uint16_t v;
};
XMUBYTEN2() = default;
XMUBYTEN2(const XMUBYTEN2&) = default;
XMUBYTEN2& operator=(const XMUBYTEN2&) = default;
XMUBYTEN2(XMUBYTEN2&&) = default;
XMUBYTEN2& operator=(XMUBYTEN2&&) = default;
explicit constexpr XMUBYTEN2(uint16_t Packed) noexcept : v(Packed) {}
constexpr XMUBYTEN2(uint8_t _x, uint8_t _y) noexcept : x(_x), y(_y) {}
explicit XMUBYTEN2(_In_reads_(2) const uint8_t* pArray) noexcept : x(pArray[0]), y(pArray[1]) {}
XMUBYTEN2(float _x, float _y) noexcept;
explicit XMUBYTEN2(_In_reads_(2) const float* pArray) noexcept;
XMUBYTEN2& operator= (uint16_t Packed) noexcept { v = Packed; return *this; }
};
// 2D Vector; 8 bit unsigned integer components
struct XMUBYTE2
{
union
{
struct
{
uint8_t x;
uint8_t y;
};
uint16_t v;
};
XMUBYTE2() = default;
XMUBYTE2(const XMUBYTE2&) = default;
XMUBYTE2& operator=(const XMUBYTE2&) = default;
XMUBYTE2(XMUBYTE2&&) = default;
XMUBYTE2& operator=(XMUBYTE2&&) = default;
explicit constexpr XMUBYTE2(uint16_t Packed) noexcept : v(Packed) {}
constexpr XMUBYTE2(uint8_t _x, uint8_t _y) noexcept : x(_x), y(_y) {}
explicit XMUBYTE2(_In_reads_(2) const uint8_t* pArray) noexcept : x(pArray[0]), y(pArray[1]) {}
XMUBYTE2(float _x, float _y) noexcept;
explicit XMUBYTE2(_In_reads_(2) const float* pArray) noexcept;
XMUBYTE2& operator= (uint16_t Packed) noexcept { v = Packed; return *this; }
};
//------------------------------------------------------------------------------
// 3D vector: 5/6/5 unsigned integer components
struct XMU565
{
union
{
struct
{
uint16_t x : 5; // 0 to 31
uint16_t y : 6; // 0 to 63
uint16_t z : 5; // 0 to 31
};
uint16_t v;
};
XMU565() = default;
XMU565(const XMU565&) = default;
XMU565& operator=(const XMU565&) = default;
XMU565(XMU565&&) = default;
XMU565& operator=(XMU565&&) = default;
explicit constexpr XMU565(uint16_t Packed) noexcept : v(Packed) {}
constexpr XMU565(uint8_t _x, uint8_t _y, uint8_t _z) noexcept : x(_x), y(_y), z(_z) {}
explicit XMU565(_In_reads_(3) const uint8_t* pArray) noexcept : x(pArray[0]), y(pArray[1]), z(pArray[2]) {}
XMU565(float _x, float _y, float _z) noexcept;
explicit XMU565(_In_reads_(3) const float* pArray) noexcept;
operator uint16_t () const noexcept { return v; }
XMU565& operator= (uint16_t Packed) noexcept { v = Packed; return *this; }
};
//------------------------------------------------------------------------------
// 3D vector: 11/11/10 floating-point components
// The 3D vector is packed into 32 bits as follows: a 5-bit biased exponent
// and 6-bit mantissa for x component, a 5-bit biased exponent and
// 6-bit mantissa for y component, a 5-bit biased exponent and a 5-bit
// mantissa for z. The z component is stored in the most significant bits
// and the x component in the least significant bits. No sign bits so
// all partial-precision numbers are positive.
// (Z10Y11X11): [32] ZZZZZzzz zzzYYYYY yyyyyyXX XXXxxxxx [0]
struct XMFLOAT3PK
{
union
{
struct
{
uint32_t xm : 6; // x-mantissa
uint32_t xe : 5; // x-exponent
uint32_t ym : 6; // y-mantissa
uint32_t ye : 5; // y-exponent
uint32_t zm : 5; // z-mantissa
uint32_t ze : 5; // z-exponent
};
uint32_t v;
};
XMFLOAT3PK() = default;
XMFLOAT3PK(const XMFLOAT3PK&) = default;
XMFLOAT3PK& operator=(const XMFLOAT3PK&) = default;
XMFLOAT3PK(XMFLOAT3PK&&) = default;
XMFLOAT3PK& operator=(XMFLOAT3PK&&) = default;
explicit constexpr XMFLOAT3PK(uint32_t Packed) noexcept : v(Packed) {}
XMFLOAT3PK(float _x, float _y, float _z) noexcept;
explicit XMFLOAT3PK(_In_reads_(3) const float* pArray) noexcept;
operator uint32_t () const noexcept { return v; }
XMFLOAT3PK& operator= (uint32_t Packed) noexcept { v = Packed; return *this; }
};
//------------------------------------------------------------------------------
// 3D vector: 9/9/9 floating-point components with shared 5-bit exponent
// The 3D vector is packed into 32 bits as follows: a 5-bit biased exponent
// with 9-bit mantissa for the x, y, and z component. The shared exponent
// is stored in the most significant bits and the x component mantissa is in
// the least significant bits. No sign bits so all partial-precision numbers
// are positive.
// (E5Z9Y9X9): [32] EEEEEzzz zzzzzzyy yyyyyyyx xxxxxxxx [0]
struct XMFLOAT3SE
{
union
{
struct
{
uint32_t xm : 9; // x-mantissa
uint32_t ym : 9; // y-mantissa
uint32_t zm : 9; // z-mantissa
uint32_t e : 5; // shared exponent
};
uint32_t v;
};
XMFLOAT3SE() = default;
XMFLOAT3SE(const XMFLOAT3SE&) = default;
XMFLOAT3SE& operator=(const XMFLOAT3SE&) = default;
XMFLOAT3SE(XMFLOAT3SE&&) = default;
XMFLOAT3SE& operator=(XMFLOAT3SE&&) = default;
explicit constexpr XMFLOAT3SE(uint32_t Packed) noexcept : v(Packed) {}
XMFLOAT3SE(float _x, float _y, float _z) noexcept;
explicit XMFLOAT3SE(_In_reads_(3) const float* pArray) noexcept;
operator uint32_t () const noexcept { return v; }
XMFLOAT3SE& operator= (uint32_t Packed) noexcept { v = Packed; return *this; }
};
//------------------------------------------------------------------------------
// 4D Vector; 16 bit floating point components
struct XMHALF4
{
union
{
struct
{
HALF x;
HALF y;
HALF z;
HALF w;
};
uint64_t v;
};
XMHALF4() = default;
XMHALF4(const XMHALF4&) = default;
XMHALF4& operator=(const XMHALF4&) = default;
XMHALF4(XMHALF4&&) = default;
XMHALF4& operator=(XMHALF4&&) = default;
explicit constexpr XMHALF4(uint64_t Packed) noexcept : v(Packed) {}
constexpr XMHALF4(HALF _x, HALF _y, HALF _z, HALF _w) noexcept : x(_x), y(_y), z(_z), w(_w) {}
explicit XMHALF4(_In_reads_(4) const HALF* pArray) noexcept : x(pArray[0]), y(pArray[1]), z(pArray[2]), w(pArray[3]) {}
XMHALF4(float _x, float _y, float _z, float _w) noexcept;
explicit XMHALF4(_In_reads_(4) const float* pArray) noexcept;
XMHALF4& operator= (uint64_t Packed) noexcept { v = Packed; return *this; }
};
//------------------------------------------------------------------------------
// 4D Vector; 16 bit signed normalized integer components
struct XMSHORTN4
{
union
{
struct
{
int16_t x;
int16_t y;
int16_t z;
int16_t w;
};
uint64_t v;
};
XMSHORTN4() = default;
XMSHORTN4(const XMSHORTN4&) = default;
XMSHORTN4& operator=(const XMSHORTN4&) = default;
XMSHORTN4(XMSHORTN4&&) = default;
XMSHORTN4& operator=(XMSHORTN4&&) = default;
explicit constexpr XMSHORTN4(uint64_t Packed) noexcept : v(Packed) {}
constexpr XMSHORTN4(int16_t _x, int16_t _y, int16_t _z, int16_t _w) noexcept : x(_x), y(_y), z(_z), w(_w) {}
explicit XMSHORTN4(_In_reads_(4) const int16_t* pArray) noexcept : x(pArray[0]), y(pArray[1]), z(pArray[2]), w(pArray[3]) {}
XMSHORTN4(float _x, float _y, float _z, float _w) noexcept;
explicit XMSHORTN4(_In_reads_(4) const float* pArray) noexcept;
XMSHORTN4& operator= (uint64_t Packed) noexcept { v = Packed; return *this; }
};
// 4D Vector; 16 bit signed integer components
struct XMSHORT4
{
union
{
struct
{
int16_t x;
int16_t y;
int16_t z;
int16_t w;
};
uint64_t v;
};
XMSHORT4() = default;
XMSHORT4(const XMSHORT4&) = default;
XMSHORT4& operator=(const XMSHORT4&) = default;
XMSHORT4(XMSHORT4&&) = default;
XMSHORT4& operator=(XMSHORT4&&) = default;
explicit constexpr XMSHORT4(uint64_t Packed) noexcept : v(Packed) {}
constexpr XMSHORT4(int16_t _x, int16_t _y, int16_t _z, int16_t _w) noexcept : x(_x), y(_y), z(_z), w(_w) {}
explicit XMSHORT4(_In_reads_(4) const int16_t* pArray) noexcept : x(pArray[0]), y(pArray[1]), z(pArray[2]), w(pArray[3]) {}
XMSHORT4(float _x, float _y, float _z, float _w) noexcept;
explicit XMSHORT4(_In_reads_(4) const float* pArray) noexcept;
XMSHORT4& operator= (uint64_t Packed) noexcept { v = Packed; return *this; }
};
// 4D Vector; 16 bit unsigned normalized integer components
struct XMUSHORTN4
{
union
{
struct
{
uint16_t x;
uint16_t y;
uint16_t z;
uint16_t w;
};
uint64_t v;
};
XMUSHORTN4() = default;
XMUSHORTN4(const XMUSHORTN4&) = default;
XMUSHORTN4& operator=(const XMUSHORTN4&) = default;
XMUSHORTN4(XMUSHORTN4&&) = default;
XMUSHORTN4& operator=(XMUSHORTN4&&) = default;
explicit constexpr XMUSHORTN4(uint64_t Packed) noexcept : v(Packed) {}
constexpr XMUSHORTN4(uint16_t _x, uint16_t _y, uint16_t _z, uint16_t _w) noexcept : x(_x), y(_y), z(_z), w(_w) {}
explicit XMUSHORTN4(_In_reads_(4) const uint16_t* pArray) noexcept : x(pArray[0]), y(pArray[1]), z(pArray[2]), w(pArray[3]) {}
XMUSHORTN4(float _x, float _y, float _z, float _w) noexcept;
explicit XMUSHORTN4(_In_reads_(4) const float* pArray) noexcept;
XMUSHORTN4& operator= (uint64_t Packed) noexcept { v = Packed; return *this; }
};
// 4D Vector; 16 bit unsigned integer components
struct XMUSHORT4
{
union
{
struct
{
uint16_t x;
uint16_t y;
uint16_t z;
uint16_t w;
};
uint64_t v;
};
XMUSHORT4() = default;
XMUSHORT4(const XMUSHORT4&) = default;
XMUSHORT4& operator=(const XMUSHORT4&) = default;
XMUSHORT4(XMUSHORT4&&) = default;
XMUSHORT4& operator=(XMUSHORT4&&) = default;
explicit constexpr XMUSHORT4(uint64_t Packed) noexcept : v(Packed) {}
constexpr XMUSHORT4(uint16_t _x, uint16_t _y, uint16_t _z, uint16_t _w) noexcept : x(_x), y(_y), z(_z), w(_w) {}
explicit XMUSHORT4(_In_reads_(4) const uint16_t* pArray) noexcept : x(pArray[0]), y(pArray[1]), z(pArray[2]), w(pArray[3]) {}
XMUSHORT4(float _x, float _y, float _z, float _w) noexcept;
explicit XMUSHORT4(_In_reads_(4) const float* pArray) noexcept;
XMUSHORT4& operator= (uint32_t Packed) noexcept { v = Packed; return *this; }
};
//------------------------------------------------------------------------------
// 4D Vector; 10-10-10-2 bit normalized components packed into a 32 bit integer
// The normalized 4D Vector is packed into 32 bits as follows: a 2 bit unsigned,
// normalized integer for the w component and 10 bit signed, normalized
// integers for the z, y, and x components. The w component is stored in the
// most significant bits and the x component in the least significant bits
// (W2Z10Y10X10): [32] wwzzzzzz zzzzyyyy yyyyyyxx xxxxxxxx [0]
struct XMXDECN4
{
union
{
struct
{
int32_t x : 10; // -511/511 to 511/511
int32_t y : 10; // -511/511 to 511/511
int32_t z : 10; // -511/511 to 511/511
uint32_t w : 2; // 0/3 to 3/3
};
uint32_t v;
};
XMXDECN4() = default;
XMXDECN4(const XMXDECN4&) = default;
XMXDECN4& operator=(const XMXDECN4&) = default;
XMXDECN4(XMXDECN4&&) = default;
XMXDECN4& operator=(XMXDECN4&&) = default;
explicit constexpr XMXDECN4(uint32_t Packed) : v(Packed) {}
XMXDECN4(float _x, float _y, float _z, float _w) noexcept;
explicit XMXDECN4(_In_reads_(4) const float* pArray) noexcept;
operator uint32_t () const noexcept { return v; }
XMXDECN4& operator= (uint32_t Packed) noexcept { v = Packed; return *this; }
};
// 4D Vector; 10-10-10-2 bit components packed into a 32 bit integer
// The normalized 4D Vector is packed into 32 bits as follows: a 2 bit unsigned
// integer for the w component and 10 bit signed integers for the
// z, y, and x components. The w component is stored in the
// most significant bits and the x component in the least significant bits
// (W2Z10Y10X10): [32] wwzzzzzz zzzzyyyy yyyyyyxx xxxxxxxx [0]
struct XM_DEPRECATED XMXDEC4
{
union
{
struct
{
int32_t x : 10; // -511 to 511
int32_t y : 10; // -511 to 511
int32_t z : 10; // -511 to 511
uint32_t w : 2; // 0 to 3
};
uint32_t v;
};
XMXDEC4() = default;
XMXDEC4(const XMXDEC4&) = default;
XMXDEC4& operator=(const XMXDEC4&) = default;
XMXDEC4(XMXDEC4&&) = default;
XMXDEC4& operator=(XMXDEC4&&) = default;
explicit constexpr XMXDEC4(uint32_t Packed) noexcept : v(Packed) {}
XMXDEC4(float _x, float _y, float _z, float _w) noexcept;
explicit XMXDEC4(_In_reads_(4) const float* pArray) noexcept;
operator uint32_t () const noexcept { return v; }
XMXDEC4& operator= (uint32_t Packed) noexcept { v = Packed; return *this; }
};
// 4D Vector; 10-10-10-2 bit normalized components packed into a 32 bit integer
// The normalized 4D Vector is packed into 32 bits as follows: a 2 bit signed,
// normalized integer for the w component and 10 bit signed, normalized
// integers for the z, y, and x components. The w component is stored in the
// most significant bits and the x component in the least significant bits
// (W2Z10Y10X10): [32] wwzzzzzz zzzzyyyy yyyyyyxx xxxxxxxx [0]
struct XM_DEPRECATED XMDECN4
{
union
{
struct
{
int32_t x : 10; // -511/511 to 511/511
int32_t y : 10; // -511/511 to 511/511
int32_t z : 10; // -511/511 to 511/511
int32_t w : 2; // -1/1 to 1/1
};
uint32_t v;
};
XMDECN4() = default;
XMDECN4(const XMDECN4&) = default;
XMDECN4& operator=(const XMDECN4&) = default;
XMDECN4(XMDECN4&&) = default;
XMDECN4& operator=(XMDECN4&&) = default;
explicit constexpr XMDECN4(uint32_t Packed) noexcept : v(Packed) {}
XMDECN4(float _x, float _y, float _z, float _w) noexcept;
explicit XMDECN4(_In_reads_(4) const float* pArray) noexcept;
operator uint32_t () const noexcept { return v; }
XMDECN4& operator= (uint32_t Packed) noexcept { v = Packed; return *this; }
};
// 4D Vector; 10-10-10-2 bit components packed into a 32 bit integer
// The 4D Vector is packed into 32 bits as follows: a 2 bit signed,
// integer for the w component and 10 bit signed integers for the
// z, y, and x components. The w component is stored in the
// most significant bits and the x component in the least significant bits
// (W2Z10Y10X10): [32] wwzzzzzz zzzzyyyy yyyyyyxx xxxxxxxx [0]
struct XM_DEPRECATED XMDEC4
{
union
{
struct
{
int32_t x : 10; // -511 to 511
int32_t y : 10; // -511 to 511
int32_t z : 10; // -511 to 511
int32_t w : 2; // -1 to 1
};
uint32_t v;
};
XMDEC4() = default;
XMDEC4(const XMDEC4&) = default;
XMDEC4& operator=(const XMDEC4&) = default;
XMDEC4(XMDEC4&&) = default;
XMDEC4& operator=(XMDEC4&&) = default;
explicit constexpr XMDEC4(uint32_t Packed) noexcept : v(Packed) {}
XMDEC4(float _x, float _y, float _z, float _w) noexcept;
explicit XMDEC4(_In_reads_(4) const float* pArray) noexcept;
operator uint32_t () const noexcept { return v; }
XMDEC4& operator= (uint32_t Packed) noexcept { v = Packed; return *this; }
};
// 4D Vector; 10-10-10-2 bit normalized components packed into a 32 bit integer
// The normalized 4D Vector is packed into 32 bits as follows: a 2 bit unsigned,
// normalized integer for the w component and 10 bit unsigned, normalized
// integers for the z, y, and x components. The w component is stored in the
// most significant bits and the x component in the least significant bits
// (W2Z10Y10X10): [32] wwzzzzzz zzzzyyyy yyyyyyxx xxxxxxxx [0]
struct XMUDECN4
{
union
{
struct
{
uint32_t x : 10; // 0/1023 to 1023/1023
uint32_t y : 10; // 0/1023 to 1023/1023
uint32_t z : 10; // 0/1023 to 1023/1023
uint32_t w : 2; // 0/3 to 3/3
};
uint32_t v;
};
XMUDECN4() = default;
XMUDECN4(const XMUDECN4&) = default;
XMUDECN4& operator=(const XMUDECN4&) = default;
XMUDECN4(XMUDECN4&&) = default;
XMUDECN4& operator=(XMUDECN4&&) = default;
explicit constexpr XMUDECN4(uint32_t Packed) noexcept : v(Packed) {}
XMUDECN4(float _x, float _y, float _z, float _w) noexcept;
explicit XMUDECN4(_In_reads_(4) const float* pArray) noexcept;
operator uint32_t () const noexcept { return v; }
XMUDECN4& operator= (uint32_t Packed) noexcept { v = Packed; return *this; }
};
// 4D Vector; 10-10-10-2 bit components packed into a 32 bit integer
// The 4D Vector is packed into 32 bits as follows: a 2 bit unsigned,
// integer for the w component and 10 bit unsigned integers
// for the z, y, and x components. The w component is stored in the
// most significant bits and the x component in the least significant bits
// (W2Z10Y10X10): [32] wwzzzzzz zzzzyyyy yyyyyyxx xxxxxxxx [0]
struct XMUDEC4
{
union
{
struct
{
uint32_t x : 10; // 0 to 1023
uint32_t y : 10; // 0 to 1023
uint32_t z : 10; // 0 to 1023
uint32_t w : 2; // 0 to 3
};
uint32_t v;
};
XMUDEC4() = default;
XMUDEC4(const XMUDEC4&) = default;
XMUDEC4& operator=(const XMUDEC4&) = default;
XMUDEC4(XMUDEC4&&) = default;
XMUDEC4& operator=(XMUDEC4&&) = default;
explicit constexpr XMUDEC4(uint32_t Packed) noexcept : v(Packed) {}
XMUDEC4(float _x, float _y, float _z, float _w) noexcept;
explicit XMUDEC4(_In_reads_(4) const float* pArray) noexcept;
operator uint32_t () const noexcept { return v; }
XMUDEC4& operator= (uint32_t Packed) noexcept { v = Packed; return *this; }
};
//------------------------------------------------------------------------------
// 4D Vector; 8 bit signed normalized integer components
struct XMBYTEN4
{
union
{
struct
{
int8_t x;
int8_t y;
int8_t z;
int8_t w;
};
uint32_t v;
};
XMBYTEN4() = default;
XMBYTEN4(const XMBYTEN4&) = default;
XMBYTEN4& operator=(const XMBYTEN4&) = default;
XMBYTEN4(XMBYTEN4&&) = default;
XMBYTEN4& operator=(XMBYTEN4&&) = default;
constexpr XMBYTEN4(int8_t _x, int8_t _y, int8_t _z, int8_t _w) noexcept : x(_x), y(_y), z(_z), w(_w) {}
explicit constexpr XMBYTEN4(uint32_t Packed) noexcept : v(Packed) {}
explicit XMBYTEN4(_In_reads_(4) const int8_t* pArray) noexcept : x(pArray[0]), y(pArray[1]), z(pArray[2]), w(pArray[3]) {}
XMBYTEN4(float _x, float _y, float _z, float _w) noexcept;
explicit XMBYTEN4(_In_reads_(4) const float* pArray) noexcept;
XMBYTEN4& operator= (uint32_t Packed) noexcept { v = Packed; return *this; }
};
// 4D Vector; 8 bit signed integer components
struct XMBYTE4
{
union
{
struct
{
int8_t x;
int8_t y;
int8_t z;
int8_t w;
};
uint32_t v;
};
XMBYTE4() = default;
XMBYTE4(const XMBYTE4&) = default;
XMBYTE4& operator=(const XMBYTE4&) = default;
XMBYTE4(XMBYTE4&&) = default;
XMBYTE4& operator=(XMBYTE4&&) = default;
constexpr XMBYTE4(int8_t _x, int8_t _y, int8_t _z, int8_t _w) noexcept : x(_x), y(_y), z(_z), w(_w) {}
explicit constexpr XMBYTE4(uint32_t Packed) noexcept : v(Packed) {}
explicit XMBYTE4(_In_reads_(4) const int8_t* pArray) noexcept : x(pArray[0]), y(pArray[1]), z(pArray[2]), w(pArray[3]) {}
XMBYTE4(float _x, float _y, float _z, float _w) noexcept;
explicit XMBYTE4(_In_reads_(4) const float* pArray) noexcept;
XMBYTE4& operator= (uint32_t Packed) noexcept { v = Packed; return *this; }
};
// 4D Vector; 8 bit unsigned normalized integer components
struct XMUBYTEN4
{
union
{
struct
{
uint8_t x;
uint8_t y;
uint8_t z;
uint8_t w;
};
uint32_t v;
};
XMUBYTEN4() = default;
XMUBYTEN4(const XMUBYTEN4&) = default;
XMUBYTEN4& operator=(const XMUBYTEN4&) = default;
XMUBYTEN4(XMUBYTEN4&&) = default;
XMUBYTEN4& operator=(XMUBYTEN4&&) = default;
constexpr XMUBYTEN4(uint8_t _x, uint8_t _y, uint8_t _z, uint8_t _w) noexcept : x(_x), y(_y), z(_z), w(_w) {}
explicit constexpr XMUBYTEN4(uint32_t Packed) noexcept : v(Packed) {}
explicit XMUBYTEN4(_In_reads_(4) const uint8_t* pArray) noexcept : x(pArray[0]), y(pArray[1]), z(pArray[2]), w(pArray[3]) {}
XMUBYTEN4(float _x, float _y, float _z, float _w) noexcept;
explicit XMUBYTEN4(_In_reads_(4) const float* pArray) noexcept;
XMUBYTEN4& operator= (uint32_t Packed) noexcept { v = Packed; return *this; }
};
// 4D Vector; 8 bit unsigned integer components
struct XMUBYTE4
{
union
{
struct
{
uint8_t x;
uint8_t y;
uint8_t z;
uint8_t w;
};
uint32_t v;
};
XMUBYTE4() = default;
XMUBYTE4(const XMUBYTE4&) = default;
XMUBYTE4& operator=(const XMUBYTE4&) = default;
XMUBYTE4(XMUBYTE4&&) = default;
XMUBYTE4& operator=(XMUBYTE4&&) = default;
constexpr XMUBYTE4(uint8_t _x, uint8_t _y, uint8_t _z, uint8_t _w) noexcept : x(_x), y(_y), z(_z), w(_w) {}
explicit constexpr XMUBYTE4(uint32_t Packed) noexcept : v(Packed) {}
explicit XMUBYTE4(_In_reads_(4) const uint8_t* pArray) noexcept : x(pArray[0]), y(pArray[1]), z(pArray[2]), w(pArray[3]) {}
XMUBYTE4(float _x, float _y, float _z, float _w) noexcept;
explicit XMUBYTE4(_In_reads_(4) const float* pArray) noexcept;
XMUBYTE4& operator= (uint32_t Packed) noexcept { v = Packed; return *this; }
};
//------------------------------------------------------------------------------
// 4D vector; 4 bit unsigned integer components
struct XMUNIBBLE4
{
union
{
struct
{
uint16_t x : 4; // 0 to 15
uint16_t y : 4; // 0 to 15
uint16_t z : 4; // 0 to 15
uint16_t w : 4; // 0 to 15
};
uint16_t v;
};
XMUNIBBLE4() = default;
XMUNIBBLE4(const XMUNIBBLE4&) = default;
XMUNIBBLE4& operator=(const XMUNIBBLE4&) = default;
XMUNIBBLE4(XMUNIBBLE4&&) = default;
XMUNIBBLE4& operator=(XMUNIBBLE4&&) = default;