/
mtypes.h
5629 lines (4754 loc) · 172 KB
/
mtypes.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
/*
* Mesa 3-D graphics library
*
* Copyright (C) 1999-2008 Brian Paul All Rights Reserved.
* Copyright (C) 2009 VMware, Inc. All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
* OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
* OTHER DEALINGS IN THE SOFTWARE.
*/
/**
* \file mtypes.h
* Main Mesa data structures.
*
* Please try to mark derived values with a leading underscore ('_').
*/
#ifndef MTYPES_H
#define MTYPES_H
#include <stdint.h> /* uint32_t */
#include <stdbool.h>
#include "c11/threads.h"
#include "main/glheader.h"
#include "main/glthread.h"
#include "main/menums.h"
#include "main/config.h"
#include "glapi/glapi.h"
#include "math/m_matrix.h" /* GLmatrix */
#include "compiler/shader_enums.h"
#include "compiler/shader_info.h"
#include "main/formats.h" /* MESA_FORMAT_COUNT */
#include "compiler/glsl/list.h"
#include "util/simple_mtx.h"
#include "util/u_dynarray.h"
#include "vbo/vbo.h"
#ifdef __cplusplus
extern "C" {
#endif
#define GET_COLORMASK_BIT(mask, buf, chan) (((mask) >> (4 * (buf) + (chan))) & 0x1)
#define GET_COLORMASK(mask, buf) (((mask) >> (4 * (buf))) & 0xf)
/**
* \name Some forward type declarations
*/
/*@{*/
struct _mesa_HashTable;
struct gl_attrib_node;
struct gl_list_extensions;
struct gl_meta_state;
struct gl_program_cache;
struct gl_texture_object;
struct gl_debug_state;
struct gl_context;
struct st_context;
struct gl_uniform_storage;
struct prog_instruction;
struct gl_program_parameter_list;
struct gl_shader_spirv_data;
struct set;
struct shader_includes;
/*@}*/
/** Extra draw modes beyond GL_POINTS, GL_TRIANGLE_FAN, etc */
#define PRIM_MAX GL_PATCHES
#define PRIM_OUTSIDE_BEGIN_END (PRIM_MAX + 1)
#define PRIM_UNKNOWN (PRIM_MAX + 2)
/**
* Determine if the given gl_varying_slot appears in the fragment shader.
*/
static inline GLboolean
_mesa_varying_slot_in_fs(gl_varying_slot slot)
{
switch (slot) {
case VARYING_SLOT_PSIZ:
case VARYING_SLOT_BFC0:
case VARYING_SLOT_BFC1:
case VARYING_SLOT_EDGE:
case VARYING_SLOT_CLIP_VERTEX:
case VARYING_SLOT_LAYER:
case VARYING_SLOT_TESS_LEVEL_OUTER:
case VARYING_SLOT_TESS_LEVEL_INNER:
case VARYING_SLOT_BOUNDING_BOX0:
case VARYING_SLOT_BOUNDING_BOX1:
case VARYING_SLOT_VIEWPORT_MASK:
return GL_FALSE;
default:
return GL_TRUE;
}
}
/**
* Bit flags for all renderbuffers
*/
#define BUFFER_BIT_FRONT_LEFT (1 << BUFFER_FRONT_LEFT)
#define BUFFER_BIT_BACK_LEFT (1 << BUFFER_BACK_LEFT)
#define BUFFER_BIT_FRONT_RIGHT (1 << BUFFER_FRONT_RIGHT)
#define BUFFER_BIT_BACK_RIGHT (1 << BUFFER_BACK_RIGHT)
#define BUFFER_BIT_AUX0 (1 << BUFFER_AUX0)
#define BUFFER_BIT_AUX1 (1 << BUFFER_AUX1)
#define BUFFER_BIT_AUX2 (1 << BUFFER_AUX2)
#define BUFFER_BIT_AUX3 (1 << BUFFER_AUX3)
#define BUFFER_BIT_DEPTH (1 << BUFFER_DEPTH)
#define BUFFER_BIT_STENCIL (1 << BUFFER_STENCIL)
#define BUFFER_BIT_ACCUM (1 << BUFFER_ACCUM)
#define BUFFER_BIT_COLOR0 (1 << BUFFER_COLOR0)
#define BUFFER_BIT_COLOR1 (1 << BUFFER_COLOR1)
#define BUFFER_BIT_COLOR2 (1 << BUFFER_COLOR2)
#define BUFFER_BIT_COLOR3 (1 << BUFFER_COLOR3)
#define BUFFER_BIT_COLOR4 (1 << BUFFER_COLOR4)
#define BUFFER_BIT_COLOR5 (1 << BUFFER_COLOR5)
#define BUFFER_BIT_COLOR6 (1 << BUFFER_COLOR6)
#define BUFFER_BIT_COLOR7 (1 << BUFFER_COLOR7)
/**
* Mask of all the color buffer bits (but not accum).
*/
#define BUFFER_BITS_COLOR (BUFFER_BIT_FRONT_LEFT | \
BUFFER_BIT_BACK_LEFT | \
BUFFER_BIT_FRONT_RIGHT | \
BUFFER_BIT_BACK_RIGHT | \
BUFFER_BIT_AUX0 | \
BUFFER_BIT_COLOR0 | \
BUFFER_BIT_COLOR1 | \
BUFFER_BIT_COLOR2 | \
BUFFER_BIT_COLOR3 | \
BUFFER_BIT_COLOR4 | \
BUFFER_BIT_COLOR5 | \
BUFFER_BIT_COLOR6 | \
BUFFER_BIT_COLOR7)
/* Mask of bits for depth+stencil buffers */
#define BUFFER_BITS_DEPTH_STENCIL (BUFFER_BIT_DEPTH | BUFFER_BIT_STENCIL)
/**
* Framebuffer configuration (aka visual / pixelformat)
* Note: some of these fields should be boolean, but it appears that
* code in drivers/dri/common/util.c requires int-sized fields.
*/
struct gl_config
{
GLboolean floatMode;
GLuint doubleBufferMode;
GLuint stereoMode;
GLint redBits, greenBits, blueBits, alphaBits; /* bits per comp */
GLuint redMask, greenMask, blueMask, alphaMask;
GLint redShift, greenShift, blueShift, alphaShift;
GLint rgbBits; /* total bits for rgb */
GLint accumRedBits, accumGreenBits, accumBlueBits, accumAlphaBits;
GLint depthBits;
GLint stencilBits;
GLint numAuxBuffers;
GLint level;
/* EXT_visual_rating / GLX 1.2 */
GLint visualRating;
/* EXT_visual_info / GLX 1.2 */
GLint transparentPixel;
/* colors are floats scaled to ints */
GLint transparentRed, transparentGreen, transparentBlue, transparentAlpha;
GLint transparentIndex;
/* ARB_multisample / SGIS_multisample */
GLint sampleBuffers;
GLuint samples;
/* OML_swap_method */
GLint swapMethod;
/* EXT_texture_from_pixmap */
GLint bindToTextureRgb;
GLint bindToTextureRgba;
GLint bindToMipmapTexture;
GLint bindToTextureTargets;
GLint yInverted;
/* EXT_framebuffer_sRGB */
GLint sRGBCapable;
/* EGL_KHR_mutable_render_buffer */
GLuint mutableRenderBuffer; /* bool */
};
/**
* \name Bit flags used for updating material values.
*/
/*@{*/
#define MAT_ATTRIB_FRONT_AMBIENT 0
#define MAT_ATTRIB_BACK_AMBIENT 1
#define MAT_ATTRIB_FRONT_DIFFUSE 2
#define MAT_ATTRIB_BACK_DIFFUSE 3
#define MAT_ATTRIB_FRONT_SPECULAR 4
#define MAT_ATTRIB_BACK_SPECULAR 5
#define MAT_ATTRIB_FRONT_EMISSION 6
#define MAT_ATTRIB_BACK_EMISSION 7
#define MAT_ATTRIB_FRONT_SHININESS 8
#define MAT_ATTRIB_BACK_SHININESS 9
#define MAT_ATTRIB_FRONT_INDEXES 10
#define MAT_ATTRIB_BACK_INDEXES 11
#define MAT_ATTRIB_MAX 12
#define MAT_ATTRIB_AMBIENT(f) (MAT_ATTRIB_FRONT_AMBIENT+(f))
#define MAT_ATTRIB_DIFFUSE(f) (MAT_ATTRIB_FRONT_DIFFUSE+(f))
#define MAT_ATTRIB_SPECULAR(f) (MAT_ATTRIB_FRONT_SPECULAR+(f))
#define MAT_ATTRIB_EMISSION(f) (MAT_ATTRIB_FRONT_EMISSION+(f))
#define MAT_ATTRIB_SHININESS(f)(MAT_ATTRIB_FRONT_SHININESS+(f))
#define MAT_ATTRIB_INDEXES(f) (MAT_ATTRIB_FRONT_INDEXES+(f))
#define MAT_BIT_FRONT_AMBIENT (1<<MAT_ATTRIB_FRONT_AMBIENT)
#define MAT_BIT_BACK_AMBIENT (1<<MAT_ATTRIB_BACK_AMBIENT)
#define MAT_BIT_FRONT_DIFFUSE (1<<MAT_ATTRIB_FRONT_DIFFUSE)
#define MAT_BIT_BACK_DIFFUSE (1<<MAT_ATTRIB_BACK_DIFFUSE)
#define MAT_BIT_FRONT_SPECULAR (1<<MAT_ATTRIB_FRONT_SPECULAR)
#define MAT_BIT_BACK_SPECULAR (1<<MAT_ATTRIB_BACK_SPECULAR)
#define MAT_BIT_FRONT_EMISSION (1<<MAT_ATTRIB_FRONT_EMISSION)
#define MAT_BIT_BACK_EMISSION (1<<MAT_ATTRIB_BACK_EMISSION)
#define MAT_BIT_FRONT_SHININESS (1<<MAT_ATTRIB_FRONT_SHININESS)
#define MAT_BIT_BACK_SHININESS (1<<MAT_ATTRIB_BACK_SHININESS)
#define MAT_BIT_FRONT_INDEXES (1<<MAT_ATTRIB_FRONT_INDEXES)
#define MAT_BIT_BACK_INDEXES (1<<MAT_ATTRIB_BACK_INDEXES)
#define FRONT_MATERIAL_BITS (MAT_BIT_FRONT_EMISSION | \
MAT_BIT_FRONT_AMBIENT | \
MAT_BIT_FRONT_DIFFUSE | \
MAT_BIT_FRONT_SPECULAR | \
MAT_BIT_FRONT_SHININESS | \
MAT_BIT_FRONT_INDEXES)
#define BACK_MATERIAL_BITS (MAT_BIT_BACK_EMISSION | \
MAT_BIT_BACK_AMBIENT | \
MAT_BIT_BACK_DIFFUSE | \
MAT_BIT_BACK_SPECULAR | \
MAT_BIT_BACK_SHININESS | \
MAT_BIT_BACK_INDEXES)
#define ALL_MATERIAL_BITS (FRONT_MATERIAL_BITS | BACK_MATERIAL_BITS)
/*@}*/
/**
* Material state.
*/
struct gl_material
{
GLfloat Attrib[MAT_ATTRIB_MAX][4];
};
/**
* Light state flags.
*/
/*@{*/
#define LIGHT_SPOT 0x1
#define LIGHT_LOCAL_VIEWER 0x2
#define LIGHT_POSITIONAL 0x4
#define LIGHT_NEED_VERTICES (LIGHT_POSITIONAL|LIGHT_LOCAL_VIEWER)
/*@}*/
/**
* Light source state.
*/
struct gl_light
{
GLboolean Enabled; /**< On/off flag */
/**
* \name Derived fields
*/
/*@{*/
GLbitfield _Flags; /**< Mask of LIGHT_x bits defined above */
GLfloat _Position[4]; /**< position in eye/obj coordinates */
GLfloat _VP_inf_norm[3]; /**< Norm direction to infinite light */
GLfloat _h_inf_norm[3]; /**< Norm( _VP_inf_norm + <0,0,1> ) */
GLfloat _NormSpotDirection[4]; /**< normalized spotlight direction */
GLfloat _VP_inf_spot_attenuation;
GLfloat _MatAmbient[2][3]; /**< material ambient * light ambient */
GLfloat _MatDiffuse[2][3]; /**< material diffuse * light diffuse */
GLfloat _MatSpecular[2][3]; /**< material spec * light specular */
/*@}*/
};
/**
* Light model state.
*/
struct gl_lightmodel
{
GLfloat Ambient[4]; /**< ambient color */
GLboolean LocalViewer; /**< Local (or infinite) view point? */
GLboolean TwoSide; /**< Two (or one) sided lighting? */
GLenum16 ColorControl; /**< either GL_SINGLE_COLOR
or GL_SEPARATE_SPECULAR_COLOR */
};
/**
* Accumulation buffer attribute group (GL_ACCUM_BUFFER_BIT)
*/
struct gl_accum_attrib
{
GLfloat ClearColor[4]; /**< Accumulation buffer clear color */
};
/**
* Used for storing clear color, texture border color, etc.
* The float values are typically unclamped.
*/
union gl_color_union
{
GLfloat f[4];
GLint i[4];
GLuint ui[4];
};
/**
* Color buffer attribute group (GL_COLOR_BUFFER_BIT).
*/
struct gl_colorbuffer_attrib
{
GLuint ClearIndex; /**< Index for glClear */
union gl_color_union ClearColor; /**< Color for glClear, unclamped */
GLuint IndexMask; /**< Color index write mask */
/** 4 colormask bits per draw buffer, max 8 draw buffers. 4*8 = 32 bits */
GLbitfield ColorMask;
GLenum16 DrawBuffer[MAX_DRAW_BUFFERS]; /**< Which buffer to draw into */
/**
* \name alpha testing
*/
/*@{*/
GLboolean AlphaEnabled; /**< Alpha test enabled flag */
GLenum16 AlphaFunc; /**< Alpha test function */
GLfloat AlphaRefUnclamped;
GLclampf AlphaRef; /**< Alpha reference value */
/*@}*/
/**
* \name Blending
*/
/*@{*/
GLbitfield BlendEnabled; /**< Per-buffer blend enable flags */
/* NOTE: this does _not_ depend on fragment clamping or any other clamping
* control, only on the fixed-pointness of the render target.
* The query does however depend on fragment color clamping.
*/
GLfloat BlendColorUnclamped[4]; /**< Blending color */
GLfloat BlendColor[4]; /**< Blending color */
struct
{
GLenum16 SrcRGB; /**< RGB blend source term */
GLenum16 DstRGB; /**< RGB blend dest term */
GLenum16 SrcA; /**< Alpha blend source term */
GLenum16 DstA; /**< Alpha blend dest term */
GLenum16 EquationRGB; /**< GL_ADD, GL_SUBTRACT, etc. */
GLenum16 EquationA; /**< GL_ADD, GL_SUBTRACT, etc. */
} Blend[MAX_DRAW_BUFFERS];
/** Bitfield of color buffers with enabled dual source blending. */
GLbitfield _BlendUsesDualSrc;
/** Are the blend func terms currently different for each buffer/target? */
GLboolean _BlendFuncPerBuffer;
/** Are the blend equations currently different for each buffer/target? */
GLboolean _BlendEquationPerBuffer;
/**
* Which advanced blending mode is in use (or BLEND_NONE).
*
* KHR_blend_equation_advanced only allows advanced blending with a single
* draw buffer, and NVX_blend_equation_advanced_multi_draw_buffer still
* requires all draw buffers to match, so we only need a single value.
*/
enum gl_advanced_blend_mode _AdvancedBlendMode;
/** Coherency requested via glEnable(GL_BLEND_ADVANCED_COHERENT_KHR)? */
bool BlendCoherent;
/*@}*/
/**
* \name Logic op
*/
/*@{*/
GLboolean IndexLogicOpEnabled; /**< Color index logic op enabled flag */
GLboolean ColorLogicOpEnabled; /**< RGBA logic op enabled flag */
GLenum16 LogicOp; /**< Logic operator */
enum gl_logicop_mode _LogicOp;
/*@}*/
GLboolean DitherFlag; /**< Dither enable flag */
GLboolean _ClampFragmentColor; /** < with GL_FIXED_ONLY_ARB resolved */
GLenum16 ClampFragmentColor; /**< GL_TRUE, GL_FALSE or GL_FIXED_ONLY_ARB */
GLenum16 ClampReadColor; /**< GL_TRUE, GL_FALSE or GL_FIXED_ONLY_ARB */
GLboolean sRGBEnabled; /**< Framebuffer sRGB blending/updating requested */
};
/**
* Vertex format to describe a vertex element.
*/
struct gl_vertex_format
{
GLenum16 Type; /**< datatype: GL_FLOAT, GL_INT, etc */
GLenum16 Format; /**< default: GL_RGBA, but may be GL_BGRA */
enum pipe_format _PipeFormat:16; /**< pipe_format for Gallium */
GLubyte Size:5; /**< components per element (1,2,3,4) */
GLubyte Normalized:1; /**< GL_ARB_vertex_program */
GLubyte Integer:1; /**< Integer-valued? */
GLubyte Doubles:1; /**< double values are not converted to floats */
GLubyte _ElementSize; /**< Size of each element in bytes */
};
/**
* Current attribute group (GL_CURRENT_BIT).
*/
struct gl_current_attrib
{
/**
* \name Current vertex attributes (color, texcoords, etc).
* \note Values are valid only after FLUSH_VERTICES has been called.
* \note Index and Edgeflag current values are stored as floats in the
* SIX and SEVEN attribute slots.
* \note We need double storage for 64-bit vertex attributes
*/
GLfloat Attrib[VERT_ATTRIB_MAX][4*2];
/**
* \name Current raster position attributes (always up to date after a
* glRasterPos call).
*/
GLfloat RasterPos[4];
GLfloat RasterDistance;
GLfloat RasterColor[4];
GLfloat RasterSecondaryColor[4];
GLfloat RasterTexCoords[MAX_TEXTURE_COORD_UNITS][4];
GLboolean RasterPosValid;
};
/**
* Depth buffer attribute group (GL_DEPTH_BUFFER_BIT).
*/
struct gl_depthbuffer_attrib
{
GLenum16 Func; /**< Function for depth buffer compare */
GLclampd Clear; /**< Value to clear depth buffer to */
GLboolean Test; /**< Depth buffering enabled flag */
GLboolean Mask; /**< Depth buffer writable? */
GLboolean BoundsTest; /**< GL_EXT_depth_bounds_test */
GLclampd BoundsMin, BoundsMax;/**< GL_EXT_depth_bounds_test */
};
/**
* Evaluator attribute group (GL_EVAL_BIT).
*/
struct gl_eval_attrib
{
/**
* \name Enable bits
*/
/*@{*/
GLboolean Map1Color4;
GLboolean Map1Index;
GLboolean Map1Normal;
GLboolean Map1TextureCoord1;
GLboolean Map1TextureCoord2;
GLboolean Map1TextureCoord3;
GLboolean Map1TextureCoord4;
GLboolean Map1Vertex3;
GLboolean Map1Vertex4;
GLboolean Map2Color4;
GLboolean Map2Index;
GLboolean Map2Normal;
GLboolean Map2TextureCoord1;
GLboolean Map2TextureCoord2;
GLboolean Map2TextureCoord3;
GLboolean Map2TextureCoord4;
GLboolean Map2Vertex3;
GLboolean Map2Vertex4;
GLboolean AutoNormal;
/*@}*/
/**
* \name Map Grid endpoints and divisions and calculated du values
*/
/*@{*/
GLint MapGrid1un;
GLfloat MapGrid1u1, MapGrid1u2, MapGrid1du;
GLint MapGrid2un, MapGrid2vn;
GLfloat MapGrid2u1, MapGrid2u2, MapGrid2du;
GLfloat MapGrid2v1, MapGrid2v2, MapGrid2dv;
/*@}*/
};
/**
* Compressed fog mode.
*/
enum gl_fog_mode
{
FOG_NONE,
FOG_LINEAR,
FOG_EXP,
FOG_EXP2,
};
/**
* Fog attribute group (GL_FOG_BIT).
*/
struct gl_fog_attrib
{
GLboolean Enabled; /**< Fog enabled flag */
GLboolean ColorSumEnabled;
uint8_t _PackedMode; /**< Fog mode as 2 bits */
uint8_t _PackedEnabledMode; /**< Masked CompressedMode */
GLfloat ColorUnclamped[4]; /**< Fog color */
GLfloat Color[4]; /**< Fog color */
GLfloat Density; /**< Density >= 0.0 */
GLfloat Start; /**< Start distance in eye coords */
GLfloat End; /**< End distance in eye coords */
GLfloat Index; /**< Fog index */
GLenum16 Mode; /**< Fog mode */
GLenum16 FogCoordinateSource;/**< GL_EXT_fog_coord */
GLenum16 FogDistanceMode; /**< GL_NV_fog_distance */
};
/**
* Hint attribute group (GL_HINT_BIT).
*
* Values are always one of GL_FASTEST, GL_NICEST, or GL_DONT_CARE.
*/
struct gl_hint_attrib
{
GLenum16 PerspectiveCorrection;
GLenum16 PointSmooth;
GLenum16 LineSmooth;
GLenum16 PolygonSmooth;
GLenum16 Fog;
GLenum16 TextureCompression; /**< GL_ARB_texture_compression */
GLenum16 GenerateMipmap; /**< GL_SGIS_generate_mipmap */
GLenum16 FragmentShaderDerivative; /**< GL_ARB_fragment_shader */
GLuint MaxShaderCompilerThreads; /**< GL_ARB_parallel_shader_compile */
};
struct gl_light_uniforms {
/* These must be in the same order as the STATE_* enums,
* which should also match the order of gl_LightSource members.
*/
GLfloat Ambient[4]; /**< STATE_AMBIENT */
GLfloat Diffuse[4]; /**< STATE_DIFFUSE */
GLfloat Specular[4]; /**< STATE_SPECULAR */
GLfloat EyePosition[4]; /**< STATE_POSITION in eye coordinates */
GLfloat _HalfVector[4]; /**< STATE_HALF_VECTOR */
GLfloat SpotDirection[3]; /**< STATE_SPOT_DIRECTION in eye coordinates */
GLfloat _CosCutoff; /**< = MAX(0, cos(SpotCutoff)) */
GLfloat ConstantAttenuation; /**< STATE_ATTENUATION */
GLfloat LinearAttenuation;
GLfloat QuadraticAttenuation;
GLfloat SpotExponent;
GLfloat SpotCutoff; /**< STATE_SPOT_CUTOFF in degrees */
};
/**
* Lighting attribute group (GL_LIGHT_BIT).
*/
struct gl_light_attrib
{
/* gl_LightSource uniforms */
union {
struct gl_light_uniforms LightSource[MAX_LIGHTS];
GLfloat LightSourceData[(sizeof(struct gl_light_uniforms) / 4) * MAX_LIGHTS];
};
struct gl_light Light[MAX_LIGHTS]; /**< Array of light sources */
struct gl_lightmodel Model; /**< Lighting model */
/**
* Front and back material values.
* Note: must call FLUSH_VERTICES() before using.
*/
struct gl_material Material;
GLboolean Enabled; /**< Lighting enabled flag */
GLboolean ColorMaterialEnabled;
GLenum16 ShadeModel; /**< GL_FLAT or GL_SMOOTH */
GLenum16 ProvokingVertex; /**< GL_EXT_provoking_vertex */
GLenum16 ColorMaterialFace; /**< GL_FRONT, BACK or FRONT_AND_BACK */
GLenum16 ColorMaterialMode; /**< GL_AMBIENT, GL_DIFFUSE, etc */
GLbitfield _ColorMaterialBitmask; /**< bitmask formed from Face and Mode */
GLboolean _ClampVertexColor;
GLenum16 ClampVertexColor; /**< GL_TRUE, GL_FALSE, GL_FIXED_ONLY */
/**
* Derived state for optimizations:
*/
/*@{*/
GLbitfield _EnabledLights; /**< bitmask containing enabled lights */
GLboolean _NeedEyeCoords;
GLboolean _NeedVertices; /**< Use fast shader? */
GLfloat _BaseColor[2][3];
/*@}*/
};
/**
* Line attribute group (GL_LINE_BIT).
*/
struct gl_line_attrib
{
GLboolean SmoothFlag; /**< GL_LINE_SMOOTH enabled? */
GLboolean StippleFlag; /**< GL_LINE_STIPPLE enabled? */
GLushort StipplePattern; /**< Stipple pattern */
GLint StippleFactor; /**< Stipple repeat factor */
GLfloat Width; /**< Line width */
};
/**
* Display list attribute group (GL_LIST_BIT).
*/
struct gl_list_attrib
{
GLuint ListBase;
};
/**
* Multisample attribute group (GL_MULTISAMPLE_BIT).
*/
struct gl_multisample_attrib
{
GLboolean Enabled;
GLboolean SampleAlphaToCoverage;
GLboolean SampleAlphaToOne;
GLboolean SampleCoverage;
GLboolean SampleCoverageInvert;
GLboolean SampleShading;
/* ARB_texture_multisample / GL3.2 additions */
GLboolean SampleMask;
GLfloat SampleCoverageValue; /**< In range [0, 1] */
GLfloat MinSampleShadingValue; /**< In range [0, 1] */
/** The GL spec defines this as an array but >32x MSAA is madness */
GLbitfield SampleMaskValue;
/* NV_alpha_to_coverage_dither_control */
GLenum SampleAlphaToCoverageDitherControl;
};
/**
* A pixelmap (see glPixelMap)
*/
struct gl_pixelmap
{
GLint Size;
GLfloat Map[MAX_PIXEL_MAP_TABLE];
};
/**
* Collection of all pixelmaps
*/
struct gl_pixelmaps
{
struct gl_pixelmap RtoR; /**< i.e. GL_PIXEL_MAP_R_TO_R */
struct gl_pixelmap GtoG;
struct gl_pixelmap BtoB;
struct gl_pixelmap AtoA;
struct gl_pixelmap ItoR;
struct gl_pixelmap ItoG;
struct gl_pixelmap ItoB;
struct gl_pixelmap ItoA;
struct gl_pixelmap ItoI;
struct gl_pixelmap StoS;
};
/**
* Pixel attribute group (GL_PIXEL_MODE_BIT).
*/
struct gl_pixel_attrib
{
GLenum16 ReadBuffer; /**< source buffer for glRead/CopyPixels() */
/*--- Begin Pixel Transfer State ---*/
/* Fields are in the order in which they're applied... */
/** Scale & Bias (index shift, offset) */
/*@{*/
GLfloat RedBias, RedScale;
GLfloat GreenBias, GreenScale;
GLfloat BlueBias, BlueScale;
GLfloat AlphaBias, AlphaScale;
GLfloat DepthBias, DepthScale;
GLint IndexShift, IndexOffset;
/*@}*/
/* Pixel Maps */
/* Note: actual pixel maps are not part of this attrib group */
GLboolean MapColorFlag;
GLboolean MapStencilFlag;
/*--- End Pixel Transfer State ---*/
/** glPixelZoom */
GLfloat ZoomX, ZoomY;
};
/**
* Point attribute group (GL_POINT_BIT).
*/
struct gl_point_attrib
{
GLfloat Size; /**< User-specified point size */
GLfloat Params[3]; /**< GL_EXT_point_parameters */
GLfloat MinSize, MaxSize; /**< GL_EXT_point_parameters */
GLfloat Threshold; /**< GL_EXT_point_parameters */
GLboolean SmoothFlag; /**< True if GL_POINT_SMOOTH is enabled */
GLboolean _Attenuated; /**< True if Params != [1, 0, 0] */
GLboolean PointSprite; /**< GL_NV/ARB_point_sprite */
GLbitfield CoordReplace; /**< GL_ARB_point_sprite*/
GLenum16 SpriteOrigin; /**< GL_ARB_point_sprite */
};
/**
* Polygon attribute group (GL_POLYGON_BIT).
*/
struct gl_polygon_attrib
{
GLenum16 FrontFace; /**< Either GL_CW or GL_CCW */
GLenum FrontMode; /**< Either GL_POINT, GL_LINE or GL_FILL */
GLenum BackMode; /**< Either GL_POINT, GL_LINE or GL_FILL */
GLboolean CullFlag; /**< Culling on/off flag */
GLboolean SmoothFlag; /**< True if GL_POLYGON_SMOOTH is enabled */
GLboolean StippleFlag; /**< True if GL_POLYGON_STIPPLE is enabled */
GLenum16 CullFaceMode; /**< Culling mode GL_FRONT or GL_BACK */
GLfloat OffsetFactor; /**< Polygon offset factor, from user */
GLfloat OffsetUnits; /**< Polygon offset units, from user */
GLfloat OffsetClamp; /**< Polygon offset clamp, from user */
GLboolean OffsetPoint; /**< Offset in GL_POINT mode */
GLboolean OffsetLine; /**< Offset in GL_LINE mode */
GLboolean OffsetFill; /**< Offset in GL_FILL mode */
};
/**
* Scissor attributes (GL_SCISSOR_BIT).
*/
struct gl_scissor_rect
{
GLint X, Y; /**< Lower left corner of box */
GLsizei Width, Height; /**< Size of box */
};
struct gl_scissor_attrib
{
GLbitfield EnableFlags; /**< Scissor test enabled? */
struct gl_scissor_rect ScissorArray[MAX_VIEWPORTS];
GLint NumWindowRects; /**< Count of enabled window rectangles */
GLenum16 WindowRectMode; /**< Whether to include or exclude the rects */
struct gl_scissor_rect WindowRects[MAX_WINDOW_RECTANGLES];
};
/**
* Stencil attribute group (GL_STENCIL_BUFFER_BIT).
*
* Three sets of stencil data are tracked so that OpenGL 2.0,
* GL_EXT_stencil_two_side, and GL_ATI_separate_stencil can all be supported
* simultaneously. In each of the stencil state arrays, element 0 corresponds
* to GL_FRONT. Element 1 corresponds to the OpenGL 2.0 /
* GL_ATI_separate_stencil GL_BACK state. Element 2 corresponds to the
* GL_EXT_stencil_two_side GL_BACK state.
*
* The derived value \c _BackFace is either 1 or 2 depending on whether or
* not GL_STENCIL_TEST_TWO_SIDE_EXT is enabled.
*
* The derived value \c _TestTwoSide is set when the front-face and back-face
* stencil state are different.
*/
struct gl_stencil_attrib
{
GLboolean Enabled; /**< Enabled flag */
GLboolean TestTwoSide; /**< GL_EXT_stencil_two_side */
GLubyte ActiveFace; /**< GL_EXT_stencil_two_side (0 or 2) */
GLubyte _BackFace; /**< Current back stencil state (1 or 2) */
GLenum16 Function[3]; /**< Stencil function */
GLenum16 FailFunc[3]; /**< Fail function */
GLenum16 ZPassFunc[3]; /**< Depth buffer pass function */
GLenum16 ZFailFunc[3]; /**< Depth buffer fail function */
GLint Ref[3]; /**< Reference value */
GLuint ValueMask[3]; /**< Value mask */
GLuint WriteMask[3]; /**< Write mask */
GLuint Clear; /**< Clear value */
};
/**
* Bit flags for each type of texture object
*/
/*@{*/
#define TEXTURE_2D_MULTISAMPLE_BIT (1 << TEXTURE_2D_MULTISAMPLE_INDEX)
#define TEXTURE_2D_MULTISAMPLE_ARRAY_BIT (1 << TEXTURE_2D_MULTISAMPLE_ARRAY_INDEX)
#define TEXTURE_CUBE_ARRAY_BIT (1 << TEXTURE_CUBE_ARRAY_INDEX)
#define TEXTURE_BUFFER_BIT (1 << TEXTURE_BUFFER_INDEX)
#define TEXTURE_2D_ARRAY_BIT (1 << TEXTURE_2D_ARRAY_INDEX)
#define TEXTURE_1D_ARRAY_BIT (1 << TEXTURE_1D_ARRAY_INDEX)
#define TEXTURE_EXTERNAL_BIT (1 << TEXTURE_EXTERNAL_INDEX)
#define TEXTURE_CUBE_BIT (1 << TEXTURE_CUBE_INDEX)
#define TEXTURE_3D_BIT (1 << TEXTURE_3D_INDEX)
#define TEXTURE_RECT_BIT (1 << TEXTURE_RECT_INDEX)
#define TEXTURE_2D_BIT (1 << TEXTURE_2D_INDEX)
#define TEXTURE_1D_BIT (1 << TEXTURE_1D_INDEX)
/*@}*/
/**
* Texture image state. Drivers will typically create a subclass of this
* with extra fields for memory buffers, etc.
*/
struct gl_texture_image
{
GLint InternalFormat; /**< Internal format as given by the user */
GLenum16 _BaseFormat; /**< Either GL_RGB, GL_RGBA, GL_ALPHA,
* GL_LUMINANCE, GL_LUMINANCE_ALPHA,
* GL_INTENSITY, GL_DEPTH_COMPONENT or
* GL_DEPTH_STENCIL_EXT only. Used for
* choosing TexEnv arithmetic.
*/
mesa_format TexFormat; /**< The actual texture memory format */
GLuint Border; /**< 0 or 1 */
GLuint Width; /**< = 2^WidthLog2 + 2*Border */
GLuint Height; /**< = 2^HeightLog2 + 2*Border */
GLuint Depth; /**< = 2^DepthLog2 + 2*Border */
GLuint Width2; /**< = Width - 2*Border */
GLuint Height2; /**< = Height - 2*Border */
GLuint Depth2; /**< = Depth - 2*Border */
GLuint WidthLog2; /**< = log2(Width2) */
GLuint HeightLog2; /**< = log2(Height2) */
GLuint DepthLog2; /**< = log2(Depth2) */
GLuint MaxNumLevels; /**< = maximum possible number of mipmap
levels, computed from the dimensions */
struct gl_texture_object *TexObject; /**< Pointer back to parent object */
GLuint Level; /**< Which mipmap level am I? */
/** Cube map face: index into gl_texture_object::Image[] array */
GLuint Face;
/** GL_ARB_texture_multisample */
GLuint NumSamples; /**< Sample count, or 0 for non-multisample */
GLboolean FixedSampleLocations; /**< Same sample locations for all pixels? */
};
/**
* Indexes for cube map faces.
*/
typedef enum
{
FACE_POS_X = 0,
FACE_NEG_X = 1,
FACE_POS_Y = 2,
FACE_NEG_Y = 3,
FACE_POS_Z = 4,
FACE_NEG_Z = 5,
MAX_FACES = 6
} gl_face_index;
/**
* Sampler state saved and restore by glPush/PopAttrib.
*
* Don't put fields here that glPushAttrib shouldn't save.
* E.g. no GLES fields because GLES doesn't have glPushAttrib.
*/
struct gl_sampler_attrib
{
GLenum16 WrapS; /**< S-axis texture image wrap mode */
GLenum16 WrapT; /**< T-axis texture image wrap mode */
GLenum16 WrapR; /**< R-axis texture image wrap mode */
GLenum16 MinFilter; /**< minification filter */
GLenum16 MagFilter; /**< magnification filter */
GLenum16 sRGBDecode; /**< GL_DECODE_EXT or GL_SKIP_DECODE_EXT */
union gl_color_union BorderColor; /**< Interpreted according to texture format */
GLfloat MinLod; /**< min lambda, OpenGL 1.2 */
GLfloat MaxLod; /**< max lambda, OpenGL 1.2 */
GLfloat LodBias; /**< OpenGL 1.4 */
GLfloat MaxAnisotropy; /**< GL_EXT_texture_filter_anisotropic */
GLenum16 CompareMode; /**< GL_ARB_shadow */
GLenum16 CompareFunc; /**< GL_ARB_shadow */
GLboolean CubeMapSeamless; /**< GL_AMD_seamless_cubemap_per_texture */
GLenum16 ReductionMode; /**< GL_EXT_texture_filter_minmax */
};
/**
* Texture state saved and restored by glPush/PopAttrib.
*
* Don't put fields here that glPushAttrib shouldn't save.
* E.g. no GLES fields because GLES doesn't have glPushAttrib.
*/
struct gl_texture_object_attrib
{
GLfloat Priority; /**< in [0,1] */
GLint BaseLevel; /**< min mipmap level, OpenGL 1.2 */
GLint MaxLevel; /**< max mipmap level (max=1000), OpenGL 1.2 */
GLenum Swizzle[4]; /**< GL_EXT_texture_swizzle */
GLushort _Swizzle; /**< same as Swizzle, but SWIZZLE_* format */
GLenum16 DepthMode; /**< GL_ARB_depth_texture */
GLenum16 ImageFormatCompatibilityType; /**< GL_ARB_shader_image_load_store */
GLushort MinLayer; /**< GL_ARB_texture_view */
GLushort NumLayers; /**< GL_ARB_texture_view */
GLboolean GenerateMipmap; /**< GL_SGIS_generate_mipmap */
GLbyte ImmutableLevels; /**< ES 3.0 / ARB_texture_view */
GLubyte MinLevel; /**< GL_ARB_texture_view */
GLubyte NumLevels; /**< GL_ARB_texture_view */
};
/**
* Sampler object state. These objects are new with GL_ARB_sampler_objects
* and OpenGL 3.3. Legacy texture objects also contain a sampler object.
*/
struct gl_sampler_object
{
simple_mtx_t Mutex;
GLuint Name;
GLchar *Label; /**< GL_KHR_debug */
GLint RefCount;
struct gl_sampler_attrib Attrib; /**< State saved by glPushAttrib */
/** GL_ARB_bindless_texture */
bool HandleAllocated;
struct util_dynarray Handles;
};
/**
* Texture object state. Contains the array of mipmap images, border color,
* wrap modes, filter modes, and shadow/texcompare state.
*/
struct gl_texture_object
{
simple_mtx_t Mutex; /**< for thread safety */
GLint RefCount; /**< reference count */
GLuint Name; /**< the user-visible texture object ID */