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
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
1848
1849
1850
1851
1852
1853
1854
1855
1856
1857
1858
1859
1860
1861
1862
1863
1864
1865
1866
1867
1868
1869
1870
1871
1872
1873
1874
1875
1876
1877
1878
1879
1880
1881
1882
1883
1884
1885
1886
1887
1888
1889
1890
1891
1892
1893
1894
1895
1896
1897
1898
1899
1900
1901
1902
1903
1904
1905
1906
1907
1908
1909
1910
1911
1912
1913
1914
1915
1916
1917
1918
1919
1920
1921
1922
1923
1924
1925
1926
1927
1928
1929
1930
1931
1932
1933
1934
1935
1936
1937
1938
1939
1940
1941
1942
1943
1944
1945
1946
1947
1948
1949
1950
1951
1952
1953
1954
1955
1956
1957
1958
1959
1960
1961
1962
1963
1964
1965
1966
1967
1968
1969
1970
1971
1972
1973
1974
1975
1976
1977
1978
1979
1980
1981
1982
1983
1984
1985
1986
1987
1988
1989
1990
1991
1992
1993
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
2027
2028
2029
2030
2031
2032
2033
2034
2035
2036
2037
2038
2039
2040
2041
2042
2043
2044
2045
2046
2047
2048
2049
2050
2051
2052
2053
2054
2055
2056
2057
2058
2059
2060
2061
2062
2063
2064
2065
2066
2067
2068
2069
2070
2071
2072
2073
2074
2075
2076
2077
2078
2079
2080
2081
2082
2083
2084
2085
2086
2087
2088
2089
2090
2091
2092
2093
2094
2095
2096
2097
2098
2099
2100
2101
2102
2103
2104
2105
2106
2107
2108
2109
2110
2111
2112
2113
2114
2115
2116
2117
2118
2119
2120
2121
2122
2123
2124
2125
2126
2127
2128
2129
2130
2131
2132
2133
2134
2135
2136
2137
2138
2139
2140
2141
2142
2143
2144
2145
2146
2147
2148
2149
2150
2151
2152
2153
2154
2155
2156
2157
2158
2159
2160
2161
2162
2163
2164
2165
2166
2167
2168
2169
2170
2171
2172
2173
2174
2175
2176
2177
2178
2179
2180
2181
2182
2183
2184
2185
2186
2187
2188
2189
2190
2191
2192
2193
2194
2195
2196
2197
2198
2199
2200
2201
2202
2203
2204
2205
2206
2207
2208
2209
2210
2211
2212
2213
2214
2215
2216
2217
2218
2219
2220
2221
2222
2223
2224
2225
2226
2227
2228
2229
2230
2231
2232
2233
2234
2235
2236
2237
2238
2239
2240
2241
2242
2243
2244
2245
2246
2247
2248
2249
2250
2251
2252
2253
2254
2255
2256
2257
2258
2259
2260
2261
2262
2263
2264
2265
2266
2267
2268
2269
2270
2271
2272
2273
2274
2275
2276
2277
2278
2279
2280
2281
2282
2283
2284
2285
2286
2287
2288
2289
2290
2291
2292
2293
2294
2295
2296
2297
2298
2299
2300
2301
2302
2303
2304
2305
2306
2307
2308
2309
2310
2311
2312
2313
2314
2315
2316
2317
2318
2319
2320
2321
2322
2323
2324
2325
2326
2327
2328
2329
2330
2331
2332
2333
2334
2335
2336
2337
2338
2339
2340
2341
2342
2343
2344
2345
2346
2347
2348
2349
2350
2351
2352
2353
2354
2355
2356
2357
2358
2359
2360
2361
2362
2363
2364
2365
2366
2367
2368
2369
2370
2371
2372
2373
2374
2375
2376
2377
2378
2379
2380
2381
2382
2383
2384
2385
2386
2387
2388
2389
2390
2391
2392
2393
2394
2395
2396
2397
2398
2399
2400
2401
2402
2403
2404
2405
2406
2407
2408
2409
2410
2411
2412
2413
2414
2415
2416
2417
2418
2419
2420
2421
2422
2423
2424
2425
2426
2427
2428
2429
2430
2431
2432
2433
2434
2435
2436
2437
2438
2439
2440
2441
2442
2443
2444
2445
2446
2447
2448
2449
2450
2451
2452
2453
2454
2455
2456
2457
2458
2459
2460
2461
2462
2463
2464
2465
2466
2467
2468
2469
2470
2471
2472
2473
2474
2475
2476
2477
2478
2479
2480
2481
2482
2483
2484
2485
2486
2487
2488
2489
2490
2491
2492
2493
2494
2495
2496
2497
2498
2499
2500
2501
2502
2503
2504
2505
2506
2507
2508
2509
2510
2511
2512
2513
2514
2515
2516
2517
2518
2519
2520
2521
2522
2523
2524
2525
2526
2527
2528
2529
2530
2531
2532
2533
2534
2535
2536
2537
2538
2539
2540
2541
2542
2543
2544
2545
2546
2547
2548
2549
2550
2551
2552
2553
2554
2555
2556
2557
2558
2559
2560
2561
2562
2563
2564
2565
2566
2567
2568
2569
2570
2571
2572
2573
2574
2575
2576
2577
2578
2579
2580
2581
2582
2583
2584
2585
2586
2587
2588
2589
2590
2591
2592
2593
2594
2595
2596
2597
2598
2599
2600
2601
2602
2603
2604
2605
2606
2607
2608
2609
2610
2611
2612
2613
2614
2615
2616
2617
2618
2619
2620
2621
2622
2623
2624
2625
2626
2627
2628
2629
2630
2631
2632
2633
2634
2635
2636
2637
2638
2639
2640
2641
2642
2643
2644
2645
2646
2647
2648
2649
2650
2651
2652
2653
2654
2655
2656
2657
2658
2659
2660
2661
2662
2663
2664
2665
2666
2667
2668
2669
2670
2671
2672
2673
2674
2675
2676
2677
2678
2679
2680
2681
2682
2683
2684
2685
2686
2687
2688
2689
2690
2691
2692
2693
2694
2695
2696
2697
2698
2699
2700
2701
2702
2703
2704
2705
2706
2707
2708
2709
2710
2711
2712
2713
2714
2715
2716
2717
2718
2719
2720
2721
2722
2723
2724
2725
2726
2727
2728
2729
2730
2731
2732
2733
2734
2735
2736
2737
2738
2739
2740
2741
2742
2743
2744
2745
2746
2747
2748
2749
2750
2751
2752
2753
2754
2755
2756
2757
2758
2759
2760
2761
2762
2763
2764
2765
2766
2767
2768
2769
2770
2771
2772
2773
2774
2775
2776
2777
2778
2779
2780
2781
2782
2783
2784
2785
2786
2787
2788
2789
2790
2791
2792
2793
2794
2795
2796
2797
2798
2799
2800
2801
2802
2803
2804
2805
2806
2807
2808
2809
2810
2811
2812
2813
2814
2815
2816
2817
2818
2819
2820
2821
2822
2823
2824
2825
2826
2827
2828
2829
2830
2831
2832
2833
2834
2835
2836
2837
2838
2839
2840
2841
2842
2843
2844
2845
2846
2847
2848
2849
2850
2851
2852
2853
2854
2855
2856
2857
2858
2859
2860
2861
2862
2863
2864
2865
2866
2867
2868
2869
2870
2871
2872
2873
2874
2875
2876
2877
2878
2879
2880
2881
2882
2883
2884
2885
2886
2887
2888
2889
2890
2891
2892
2893
2894
2895
2896
2897
2898
2899
2900
2901
2902
2903
2904
2905
2906
2907
2908
2909
2910
2911
2912
2913
2914
2915
2916
2917
2918
2919
2920
2921
2922
2923
2924
2925
2926
2927
2928
2929
2930
2931
2932
2933
2934
2935
2936
2937
2938
2939
2940
2941
2942
2943
2944
2945
2946
2947
2948
2949
2950
2951
2952
2953
2954
2955
2956
2957
2958
2959
2960
2961
2962
2963
2964
2965
2966
2967
2968
2969
2970
2971
2972
2973
2974
2975
2976
2977
2978
2979
2980
2981
2982
2983
2984
2985
2986
2987
2988
2989
2990
2991
2992
2993
2994
2995
2996
2997
2998
2999
3000
3001
3002
3003
3004
3005
3006
3007
3008
3009
3010
3011
3012
3013
3014
3015
3016
3017
3018
3019
3020
3021
3022
3023
3024
3025
3026
3027
3028
3029
3030
3031
3032
3033
3034
3035
3036
3037
3038
3039
3040
3041
3042
3043
3044
3045
3046
3047
3048
3049
3050
3051
3052
3053
3054
3055
3056
3057
3058
3059
3060
3061
3062
3063
3064
3065
3066
3067
3068
3069
3070
3071
3072
3073
3074
3075
3076
3077
3078
3079
3080
3081
3082
3083
3084
3085
3086
3087
3088
3089
3090
3091
3092
3093
3094
3095
3096
3097
3098
3099
3100
3101
3102
3103
3104
3105
3106
3107
3108
3109
3110
3111
3112
3113
3114
3115
3116
3117
3118
3119
3120
3121
3122
3123
3124
3125
3126
3127
3128
3129
3130
3131
3132
3133
3134
3135
3136
3137
3138
3139
3140
3141
3142
3143
3144
3145
3146
3147
3148
3149
3150
3151
3152
3153
3154
3155
3156
3157
3158
3159
3160
3161
3162
3163
|
/*
* Mesa 3-D graphics library
* Version: 7.5
*
* 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
* BRIAN PAUL 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 "main/glheader.h"
#include "main/config.h"
#include "main/compiler.h"
#include "main/mfeatures.h"
#include "main/bitset.h"
#include "glapi/glapi.h"
#include "math/m_matrix.h" /* GLmatrix */
/**
* Color channel data type.
*/
#if CHAN_BITS == 8
typedef GLubyte GLchan;
#define CHAN_MAX 255
#define CHAN_MAXF 255.0F
#define CHAN_TYPE GL_UNSIGNED_BYTE
#elif CHAN_BITS == 16
typedef GLushort GLchan;
#define CHAN_MAX 65535
#define CHAN_MAXF 65535.0F
#define CHAN_TYPE GL_UNSIGNED_SHORT
#elif CHAN_BITS == 32
typedef GLfloat GLchan;
#define CHAN_MAX 1.0
#define CHAN_MAXF 1.0F
#define CHAN_TYPE GL_FLOAT
#else
#error "illegal number of color channel bits"
#endif
/**
* Stencil buffer data type.
*/
#if STENCIL_BITS==8
typedef GLubyte GLstencil;
#elif STENCIL_BITS==16
typedef GLushort GLstencil;
#else
# error "illegal number of stencil bits"
#endif
/**
* Fixed point data type.
*/
typedef int GLfixed;
/*
* Fixed point arithmetic macros
*/
#ifndef FIXED_FRAC_BITS
#define FIXED_FRAC_BITS 11
#endif
#define FIXED_SHIFT FIXED_FRAC_BITS
#define FIXED_ONE (1 << FIXED_SHIFT)
#define FIXED_HALF (1 << (FIXED_SHIFT-1))
#define FIXED_FRAC_MASK (FIXED_ONE - 1)
#define FIXED_INT_MASK (~FIXED_FRAC_MASK)
#define FIXED_EPSILON 1
#define FIXED_SCALE ((float) FIXED_ONE)
#define FIXED_DBL_SCALE ((double) FIXED_ONE)
#define FloatToFixed(X) (IROUND((X) * FIXED_SCALE))
#define FixedToDouble(X) ((X) * (1.0 / FIXED_DBL_SCALE))
#define IntToFixed(I) ((I) << FIXED_SHIFT)
#define FixedToInt(X) ((X) >> FIXED_SHIFT)
#define FixedToUns(X) (((unsigned int)(X)) >> FIXED_SHIFT)
#define FixedCeil(X) (((X) + FIXED_ONE - FIXED_EPSILON) & FIXED_INT_MASK)
#define FixedFloor(X) ((X) & FIXED_INT_MASK)
#define FixedToFloat(X) ((X) * (1.0F / FIXED_SCALE))
#define PosFloatToFixed(X) FloatToFixed(X)
#define SignedFloatToFixed(X) FloatToFixed(X)
/**
* \name Some forward type declarations
*/
/*@{*/
struct _mesa_HashTable;
struct gl_pixelstore_attrib;
struct gl_program_cache;
struct gl_texture_format;
struct gl_texture_image;
struct gl_texture_object;
struct st_context;
typedef struct __GLcontextRec GLcontext;
typedef struct __GLcontextModesRec GLvisual;
typedef struct gl_framebuffer GLframebuffer;
/*@}*/
/**
* Indexes for vertex program attributes.
* GL_NV_vertex_program aliases generic attributes over the conventional
* attributes. In GL_ARB_vertex_program shader the aliasing is optional.
* In GL_ARB_vertex_shader / OpenGL 2.0 the aliasing is disallowed (the
* generic attributes are distinct/separate).
*/
enum
{
VERT_ATTRIB_POS = 0,
VERT_ATTRIB_WEIGHT = 1,
VERT_ATTRIB_NORMAL = 2,
VERT_ATTRIB_COLOR0 = 3,
VERT_ATTRIB_COLOR1 = 4,
VERT_ATTRIB_FOG = 5,
VERT_ATTRIB_COLOR_INDEX = 6,
VERT_ATTRIB_POINT_SIZE = 6, /*alias*/
VERT_ATTRIB_EDGEFLAG = 7,
VERT_ATTRIB_TEX0 = 8,
VERT_ATTRIB_TEX1 = 9,
VERT_ATTRIB_TEX2 = 10,
VERT_ATTRIB_TEX3 = 11,
VERT_ATTRIB_TEX4 = 12,
VERT_ATTRIB_TEX5 = 13,
VERT_ATTRIB_TEX6 = 14,
VERT_ATTRIB_TEX7 = 15,
VERT_ATTRIB_GENERIC0 = 16,
VERT_ATTRIB_GENERIC1 = 17,
VERT_ATTRIB_GENERIC2 = 18,
VERT_ATTRIB_GENERIC3 = 19,
VERT_ATTRIB_GENERIC4 = 20,
VERT_ATTRIB_GENERIC5 = 21,
VERT_ATTRIB_GENERIC6 = 22,
VERT_ATTRIB_GENERIC7 = 23,
VERT_ATTRIB_GENERIC8 = 24,
VERT_ATTRIB_GENERIC9 = 25,
VERT_ATTRIB_GENERIC10 = 26,
VERT_ATTRIB_GENERIC11 = 27,
VERT_ATTRIB_GENERIC12 = 28,
VERT_ATTRIB_GENERIC13 = 29,
VERT_ATTRIB_GENERIC14 = 30,
VERT_ATTRIB_GENERIC15 = 31,
VERT_ATTRIB_MAX = 32
};
/**
* Bitflags for vertex attributes.
* These are used in bitfields in many places.
*/
/*@{*/
#define VERT_BIT_POS (1 << VERT_ATTRIB_POS)
#define VERT_BIT_WEIGHT (1 << VERT_ATTRIB_WEIGHT)
#define VERT_BIT_NORMAL (1 << VERT_ATTRIB_NORMAL)
#define VERT_BIT_COLOR0 (1 << VERT_ATTRIB_COLOR0)
#define VERT_BIT_COLOR1 (1 << VERT_ATTRIB_COLOR1)
#define VERT_BIT_FOG (1 << VERT_ATTRIB_FOG)
#define VERT_BIT_COLOR_INDEX (1 << VERT_ATTRIB_COLOR_INDEX)
#define VERT_BIT_EDGEFLAG (1 << VERT_ATTRIB_EDGEFLAG)
#define VERT_BIT_TEX0 (1 << VERT_ATTRIB_TEX0)
#define VERT_BIT_TEX1 (1 << VERT_ATTRIB_TEX1)
#define VERT_BIT_TEX2 (1 << VERT_ATTRIB_TEX2)
#define VERT_BIT_TEX3 (1 << VERT_ATTRIB_TEX3)
#define VERT_BIT_TEX4 (1 << VERT_ATTRIB_TEX4)
#define VERT_BIT_TEX5 (1 << VERT_ATTRIB_TEX5)
#define VERT_BIT_TEX6 (1 << VERT_ATTRIB_TEX6)
#define VERT_BIT_TEX7 (1 << VERT_ATTRIB_TEX7)
#define VERT_BIT_GENERIC0 (1 << VERT_ATTRIB_GENERIC0)
#define VERT_BIT_GENERIC1 (1 << VERT_ATTRIB_GENERIC1)
#define VERT_BIT_GENERIC2 (1 << VERT_ATTRIB_GENERIC2)
#define VERT_BIT_GENERIC3 (1 << VERT_ATTRIB_GENERIC3)
#define VERT_BIT_GENERIC4 (1 << VERT_ATTRIB_GENERIC4)
#define VERT_BIT_GENERIC5 (1 << VERT_ATTRIB_GENERIC5)
#define VERT_BIT_GENERIC6 (1 << VERT_ATTRIB_GENERIC6)
#define VERT_BIT_GENERIC7 (1 << VERT_ATTRIB_GENERIC7)
#define VERT_BIT_GENERIC8 (1 << VERT_ATTRIB_GENERIC8)
#define VERT_BIT_GENERIC9 (1 << VERT_ATTRIB_GENERIC9)
#define VERT_BIT_GENERIC10 (1 << VERT_ATTRIB_GENERIC10)
#define VERT_BIT_GENERIC11 (1 << VERT_ATTRIB_GENERIC11)
#define VERT_BIT_GENERIC12 (1 << VERT_ATTRIB_GENERIC12)
#define VERT_BIT_GENERIC13 (1 << VERT_ATTRIB_GENERIC13)
#define VERT_BIT_GENERIC14 (1 << VERT_ATTRIB_GENERIC14)
#define VERT_BIT_GENERIC15 (1 << VERT_ATTRIB_GENERIC15)
#define VERT_BIT_TEX(u) (1 << (VERT_ATTRIB_TEX0 + (u)))
#define VERT_BIT_GENERIC(g) (1 << (VERT_ATTRIB_GENERIC0 + (g)))
/*@}*/
/**
* Indexes for vertex program result attributes
*/
/*@{*/
enum
{
VERT_RESULT_HPOS = 0,
VERT_RESULT_COL0 = 1,
VERT_RESULT_COL1 = 2,
VERT_RESULT_FOGC = 3,
VERT_RESULT_TEX0 = 4,
VERT_RESULT_TEX1 = 5,
VERT_RESULT_TEX2 = 6,
VERT_RESULT_TEX3 = 7,
VERT_RESULT_TEX4 = 8,
VERT_RESULT_TEX5 = 9,
VERT_RESULT_TEX6 = 10,
VERT_RESULT_TEX7 = 11,
VERT_RESULT_PSIZ = 12,
VERT_RESULT_BFC0 = 13,
VERT_RESULT_BFC1 = 14,
VERT_RESULT_EDGE = 15,
VERT_RESULT_VAR0 = 16 /**< shader varying */,
VERT_RESULT_MAX = (VERT_RESULT_VAR0 + MAX_VARYING)
};
/*@}*/
/**
* Indexes for fragment program input attributes.
*/
enum
{
FRAG_ATTRIB_WPOS = 0,
FRAG_ATTRIB_COL0 = 1,
FRAG_ATTRIB_COL1 = 2,
FRAG_ATTRIB_FOGC = 3,
FRAG_ATTRIB_TEX0 = 4,
FRAG_ATTRIB_TEX1 = 5,
FRAG_ATTRIB_TEX2 = 6,
FRAG_ATTRIB_TEX3 = 7,
FRAG_ATTRIB_TEX4 = 8,
FRAG_ATTRIB_TEX5 = 9,
FRAG_ATTRIB_TEX6 = 10,
FRAG_ATTRIB_TEX7 = 11,
FRAG_ATTRIB_VAR0 = 12, /**< shader varying */
FRAG_ATTRIB_MAX = (FRAG_ATTRIB_VAR0 + MAX_VARYING)
};
/**
* Bitflags for fragment program input attributes.
*/
/*@{*/
#define FRAG_BIT_WPOS (1 << FRAG_ATTRIB_WPOS)
#define FRAG_BIT_COL0 (1 << FRAG_ATTRIB_COL0)
#define FRAG_BIT_COL1 (1 << FRAG_ATTRIB_COL1)
#define FRAG_BIT_FOGC (1 << FRAG_ATTRIB_FOGC)
#define FRAG_BIT_TEX0 (1 << FRAG_ATTRIB_TEX0)
#define FRAG_BIT_TEX1 (1 << FRAG_ATTRIB_TEX1)
#define FRAG_BIT_TEX2 (1 << FRAG_ATTRIB_TEX2)
#define FRAG_BIT_TEX3 (1 << FRAG_ATTRIB_TEX3)
#define FRAG_BIT_TEX4 (1 << FRAG_ATTRIB_TEX4)
#define FRAG_BIT_TEX5 (1 << FRAG_ATTRIB_TEX5)
#define FRAG_BIT_TEX6 (1 << FRAG_ATTRIB_TEX6)
#define FRAG_BIT_TEX7 (1 << FRAG_ATTRIB_TEX7)
#define FRAG_BIT_VAR0 (1 << FRAG_ATTRIB_VAR0)
#define FRAG_BIT_TEX(U) (FRAG_BIT_TEX0 << (U))
#define FRAG_BIT_VAR(V) (FRAG_BIT_VAR0 << (V))
#define FRAG_BITS_TEX_ANY (FRAG_BIT_TEX0| \
FRAG_BIT_TEX1| \
FRAG_BIT_TEX2| \
FRAG_BIT_TEX3| \
FRAG_BIT_TEX4| \
FRAG_BIT_TEX5| \
FRAG_BIT_TEX6| \
FRAG_BIT_TEX7)
/*@}*/
/**
* Fragment program results
*/
enum
{
FRAG_RESULT_COLR = 0,
FRAG_RESULT_COLH = 1,
FRAG_RESULT_DEPR = 2,
FRAG_RESULT_DATA0 = 3,
FRAG_RESULT_MAX = (FRAG_RESULT_DATA0 + MAX_DRAW_BUFFERS)
};
/**
* Indexes for all renderbuffers
*/
enum {
BUFFER_FRONT_LEFT = 0, /* the four standard color buffers */
BUFFER_BACK_LEFT = 1,
BUFFER_FRONT_RIGHT = 2,
BUFFER_BACK_RIGHT = 3,
BUFFER_AUX0 = 4, /* optional aux buffer */
BUFFER_AUX1 = 5,
BUFFER_AUX2 = 6,
BUFFER_AUX3 = 7,
BUFFER_DEPTH = 8,
BUFFER_STENCIL = 9,
BUFFER_ACCUM = 10,
BUFFER_COLOR0 = 11, /* generic renderbuffers */
BUFFER_COLOR1 = 12,
BUFFER_COLOR2 = 13,
BUFFER_COLOR3 = 14,
BUFFER_COLOR4 = 15,
BUFFER_COLOR5 = 16,
BUFFER_COLOR6 = 17,
BUFFER_COLOR7 = 18,
BUFFER_COUNT = 19
};
/**
* 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_AUX1 | \
BUFFER_BIT_AUX2 | \
BUFFER_BIT_AUX3 | \
BUFFER_BIT_COLOR0 | \
BUFFER_BIT_COLOR1 | \
BUFFER_BIT_COLOR2 | \
BUFFER_BIT_COLOR3 | \
BUFFER_BIT_COLOR4 | \
BUFFER_BIT_COLOR5 | \
BUFFER_BIT_COLOR6 | \
BUFFER_BIT_COLOR7)
/** The pixel transfer path has three color tables: */
/*@{*/
#define COLORTABLE_PRECONVOLUTION 0
#define COLORTABLE_POSTCONVOLUTION 1
#define COLORTABLE_POSTCOLORMATRIX 2
#define COLORTABLE_MAX 3
/*@}*/
/**
* Data structure for color tables
*/
struct gl_color_table
{
GLenum InternalFormat; /**< The user-specified format */
GLenum _BaseFormat; /**< GL_ALPHA, GL_RGBA, GL_RGB, etc */
GLuint Size; /**< number of entries in table */
GLfloat *TableF; /**< Color table, floating point values */
GLubyte *TableUB; /**< Color table, ubyte values */
GLubyte RedSize;
GLubyte GreenSize;
GLubyte BlueSize;
GLubyte AlphaSize;
GLubyte LuminanceSize;
GLubyte IntensitySize;
};
/**
* \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_INDEX_AMBIENT 0
#define MAT_INDEX_DIFFUSE 1
#define MAT_INDEX_SPECULAR 2
#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)
/*@}*/
#define EXP_TABLE_SIZE 512 /**< Specular exponent lookup table sizes */
#define SHINE_TABLE_SIZE 256 /**< Material shininess lookup table sizes */
/**
* Material shininess lookup table.
*/
struct gl_shine_tab
{
struct gl_shine_tab *next, *prev;
GLfloat tab[SHINE_TABLE_SIZE+1];
GLfloat shininess;
GLuint refcount;
};
/**
* Light source state.
*/
struct gl_light
{
struct gl_light *next; /**< double linked list with sentinel */
struct gl_light *prev;
GLfloat Ambient[4]; /**< ambient color */
GLfloat Diffuse[4]; /**< diffuse color */
GLfloat Specular[4]; /**< specular color */
GLfloat EyePosition[4]; /**< position in eye coordinates */
GLfloat EyeDirection[4]; /**< spotlight dir in eye coordinates */
GLfloat SpotExponent;
GLfloat SpotCutoff; /**< in degrees */
GLfloat _CosCutoffNeg; /**< = cos(SpotCutoff) */
GLfloat _CosCutoff; /**< = MAX(0, cos(SpotCutoff)) */
GLfloat ConstantAttenuation;
GLfloat LinearAttenuation;
GLfloat QuadraticAttenuation;
GLboolean Enabled; /**< On/off flag */
/**
* \name Derived fields
*/
/*@{*/
GLbitfield _Flags; /**< State */
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 _NormDirection[4]; /**< normalized spotlight direction */
GLfloat _VP_inf_spot_attenuation;
GLfloat _SpotExpTable[EXP_TABLE_SIZE][2]; /**< to replace a pow() call */
GLfloat _MatAmbient[2][3]; /**< material ambient * light ambient */
GLfloat _MatDiffuse[2][3]; /**< material diffuse * light diffuse */
GLfloat _MatSpecular[2][3]; /**< material spec * light specular */
GLfloat _dli; /**< CI diffuse light intensity */
GLfloat _sli; /**< CI specular light intensity */
/*@}*/
};
/**
* 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? */
GLenum ColorControl; /**< either GL_SINGLE_COLOR
* or GL_SEPARATE_SPECULAR_COLOR */
};
/**
* Material state.
*/
struct gl_material
{
GLfloat Attrib[MAT_ATTRIB_MAX][4];
};
/**
* Accumulation buffer attribute group (GL_ACCUM_BUFFER_BIT)
*/
struct gl_accum_attrib
{
GLfloat ClearColor[4]; /**< Accumulation buffer clear color */
};
/**
* Color buffer attribute group (GL_COLOR_BUFFER_BIT).
*/
struct gl_colorbuffer_attrib
{
GLuint ClearIndex; /**< Index to use for glClear */
GLclampf ClearColor[4]; /**< Color to use for glClear */
GLuint IndexMask; /**< Color index write mask */
GLubyte ColorMask[4]; /**< Each flag is 0xff or 0x0 */
GLenum DrawBuffer[MAX_DRAW_BUFFERS]; /**< Which buffer to draw into */
/**
* \name alpha testing
*/
/*@{*/
GLboolean AlphaEnabled; /**< Alpha test enabled flag */
GLenum AlphaFunc; /**< Alpha test function */
GLclampf AlphaRef; /**< Alpha reference value */
/*@}*/
/**
* \name Blending
*/
/*@{*/
GLboolean BlendEnabled; /**< Blending enabled flag */
GLenum BlendSrcRGB; /**< Blending source operator */
GLenum BlendDstRGB; /**< Blending destination operator */
GLenum BlendSrcA; /**< GL_INGR_blend_func_separate */
GLenum BlendDstA; /**< GL_INGR_blend_func_separate */
GLenum BlendEquationRGB; /**< Blending equation */
GLenum BlendEquationA; /**< GL_EXT_blend_equation_separate */
GLfloat BlendColor[4]; /**< Blending color */
/*@}*/
/**
* \name Logic op
*/
/*@{*/
GLenum LogicOp; /**< Logic operator */
GLboolean IndexLogicOpEnabled; /**< Color index logic op enabled flag */
GLboolean ColorLogicOpEnabled; /**< RGBA logic op enabled flag */
GLboolean _LogicOpEnabled; /**< RGBA logic op + EXT_blend_logic_op enabled flag */
/*@}*/
GLboolean DitherFlag; /**< Dither enable flag */
GLenum ClampFragmentColor; /**< GL_TRUE, GL_FALSE or GL_FIXED_ONLY_ARB */
GLenum ClampReadColor; /**< GL_TRUE, GL_FALSE or GL_FIXED_ONLY_ARB */
};
/**
* Current attribute group (GL_CURRENT_BIT).
*/
struct gl_current_attrib
{
/**
* \name Current vertex attributes.
* \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.
*/
/*@{*/
GLfloat Attrib[VERT_ATTRIB_MAX][4]; /**< Position, color, texcoords, etc */
/*@}*/
/**
* \name Current raster position attributes (always valid).
* \note This set of attributes is very similar to the SWvertex struct.
*/
/*@{*/
GLfloat RasterPos[4];
GLfloat RasterDistance;
GLfloat RasterColor[4];
GLfloat RasterSecondaryColor[4];
GLfloat RasterIndex;
GLfloat RasterTexCoords[MAX_TEXTURE_UNITS][4];
GLboolean RasterPosValid;
/*@}*/
};
/**
* Depth buffer attribute group (GL_DEPTH_BUFFER_BIT).
*/
struct gl_depthbuffer_attrib
{
GLenum 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 */
GLfloat BoundsMin, BoundsMax;/**< GL_EXT_depth_bounds_test */
};
/**
* glEnable()/glDisable() attribute group (GL_ENABLE_BIT).
*/
struct gl_enable_attrib
{
GLboolean AlphaTest;
GLboolean AutoNormal;
GLboolean Blend;
GLbitfield ClipPlanes;
GLboolean ColorMaterial;
GLboolean ColorTable[COLORTABLE_MAX];
GLboolean Convolution1D;
GLboolean Convolution2D;
GLboolean Separable2D;
GLboolean CullFace;
GLboolean DepthTest;
GLboolean Dither;
GLboolean Fog;
GLboolean Histogram;
GLboolean Light[MAX_LIGHTS];
GLboolean Lighting;
GLboolean LineSmooth;
GLboolean LineStipple;
GLboolean IndexLogicOp;
GLboolean ColorLogicOp;
GLboolean Map1Color4;
GLboolean Map1Index;
GLboolean Map1Normal;
GLboolean Map1TextureCoord1;
GLboolean Map1TextureCoord2;
GLboolean Map1TextureCoord3;
GLboolean Map1TextureCoord4;
GLboolean Map1Vertex3;
GLboolean Map1Vertex4;
GLboolean Map1Attrib[16]; /* GL_NV_vertex_program */
GLboolean Map2Color4;
GLboolean Map2Index;
GLboolean Map2Normal;
GLboolean Map2TextureCoord1;
GLboolean Map2TextureCoord2;
GLboolean Map2TextureCoord3;
GLboolean Map2TextureCoord4;
GLboolean Map2Vertex3;
GLboolean Map2Vertex4;
GLboolean Map2Attrib[16]; /* GL_NV_vertex_program */
GLboolean MinMax;
GLboolean Normalize;
GLboolean PixelTexture;
GLboolean PointSmooth;
GLboolean PolygonOffsetPoint;
GLboolean PolygonOffsetLine;
GLboolean PolygonOffsetFill;
GLboolean PolygonSmooth;
GLboolean PolygonStipple;
GLboolean RescaleNormals;
GLboolean Scissor;
GLboolean Stencil;
GLboolean StencilTwoSide; /* GL_EXT_stencil_two_side */
GLboolean MultisampleEnabled; /* GL_ARB_multisample */
GLboolean SampleAlphaToCoverage; /* GL_ARB_multisample */
GLboolean SampleAlphaToOne; /* GL_ARB_multisample */
GLboolean SampleCoverage; /* GL_ARB_multisample */
GLboolean SampleCoverageInvert; /* GL_ARB_multisample */
GLboolean RasterPositionUnclipped; /* GL_IBM_rasterpos_clip */
GLuint Texture[MAX_TEXTURE_UNITS];
GLuint TexGen[MAX_TEXTURE_UNITS];
/* SGI_texture_color_table */
GLboolean TextureColorTable[MAX_TEXTURE_UNITS];
/* GL_ARB_vertex_program / GL_NV_vertex_program */
GLboolean VertexProgram;
GLboolean VertexProgramPointSize;
GLboolean VertexProgramTwoSide;
/* GL_ARB_point_sprite / GL_NV_point_sprite */
GLboolean PointSprite;
GLboolean FragmentShaderATI;
};
/**
* 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 Map1Attrib[16]; /* GL_NV_vertex_program */
GLboolean Map2Color4;
GLboolean Map2Index;
GLboolean Map2Normal;
GLboolean Map2TextureCoord1;
GLboolean Map2TextureCoord2;
GLboolean Map2TextureCoord3;
GLboolean Map2TextureCoord4;
GLboolean Map2Vertex3;
GLboolean Map2Vertex4;
GLboolean Map2Attrib[16]; /* GL_NV_vertex_program */
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;
/*@}*/
};
/**
* Fog attribute group (GL_FOG_BIT).
*/
struct gl_fog_attrib
{
GLboolean Enabled; /**< Fog enabled flag */
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 */
GLenum Mode; /**< Fog mode */
GLboolean ColorSumEnabled;
GLenum FogCoordinateSource; /**< GL_EXT_fog_coord */
GLfloat _Scale; /**< (End == Start) ? 1.0 : 1.0 / (End - Start) */
};
/**
* Hint attribute group (GL_HINT_BIT).
*
* Values are always one of GL_FASTEST, GL_NICEST, or GL_DONT_CARE.
*/
struct gl_hint_attrib
{
GLenum PerspectiveCorrection;
GLenum PointSmooth;
GLenum LineSmooth;
GLenum PolygonSmooth;
GLenum Fog;
GLenum ClipVolumeClipping; /**< GL_EXT_clip_volume_hint */
GLenum TextureCompression; /**< GL_ARB_texture_compression */
GLenum GenerateMipmap; /**< GL_SGIS_generate_mipmap */
GLenum FragmentShaderDerivative; /**< GL_ARB_fragment_shader */
};
/**
* Histogram attributes.
*/
struct gl_histogram_attrib
{
GLuint Width; /**< number of table entries */
GLint Format; /**< GL_ALPHA, GL_RGB, etc */
GLuint Count[HISTOGRAM_TABLE_SIZE][4]; /**< the histogram */
GLboolean Sink; /**< terminate image transfer? */
GLubyte RedSize; /**< Bits per counter */
GLubyte GreenSize;
GLubyte BlueSize;
GLubyte AlphaSize;
GLubyte LuminanceSize;
};
/**
* Color Min/max state.
*/
struct gl_minmax_attrib
{
GLenum Format;
GLboolean Sink;
GLfloat Min[4], Max[4]; /**< RGBA */
};
/**
* Image convolution state.
*/
struct gl_convolution_attrib
{
GLenum Format;
GLenum InternalFormat;
GLuint Width;
GLuint Height;
GLfloat Filter[MAX_CONVOLUTION_WIDTH * MAX_CONVOLUTION_HEIGHT * 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)
/*@}*/
/**
* Lighting attribute group (GL_LIGHT_BIT).
*/
struct gl_light_attrib
{
struct gl_light Light[MAX_LIGHTS]; /**< Array of light sources */
struct gl_lightmodel Model; /**< Lighting model */
/**
* Must flush FLUSH_VERTICES before referencing:
*/
/*@{*/
struct gl_material Material; /**< Includes front & back values */
/*@}*/
GLboolean Enabled; /**< Lighting enabled flag */
GLenum ShadeModel; /**< GL_FLAT or GL_SMOOTH */
GLenum ColorMaterialFace; /**< GL_FRONT, BACK or FRONT_AND_BACK */
GLenum ColorMaterialMode; /**< GL_AMBIENT, GL_DIFFUSE, etc */
GLbitfield ColorMaterialBitmask; /**< bitmask formed from Face and Mode */
GLboolean ColorMaterialEnabled;
GLenum ClampVertexColor;
struct gl_light EnabledList; /**< List sentinel */
/**
* Derived state for optimizations:
*/
/*@{*/
GLboolean _NeedEyeCoords;
GLboolean _NeedVertices; /**< Use fast shader? */
GLbitfield _Flags; /**< LIGHT_* flags, see above */
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;
};
/**
* Used by device drivers to hook new commands into display lists.
*/
struct gl_list_instruction
{
GLuint Size;
void (*Execute)( GLcontext *ctx, void *data );
void (*Destroy)( GLcontext *ctx, void *data );
void (*Print)( GLcontext *ctx, void *data );
};
#define MAX_DLIST_EXT_OPCODES 16
/**
* Used by device drivers to hook new commands into display lists.
*/
struct gl_list_extensions
{
struct gl_list_instruction Opcode[MAX_DLIST_EXT_OPCODES];
GLuint NumOpcodes;
};
/**
* Multisample attribute group (GL_MULTISAMPLE_BIT).
*/
struct gl_multisample_attrib
{
GLboolean Enabled;
GLboolean _Enabled; /**< true if Enabled and multisample buffer */
GLboolean SampleAlphaToCoverage;
GLboolean SampleAlphaToOne;
GLboolean SampleCoverage;
GLfloat SampleCoverageValue;
GLboolean SampleCoverageInvert;
};
/**
* A pixelmap (see glPixelMap)
*/
struct gl_pixelmap
{
GLint Size;
GLfloat Map[MAX_PIXEL_MAP_TABLE];
GLubyte Map8[MAX_PIXEL_MAP_TABLE]; /**< converted to 8-bit color */
};
/**
* 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
{
GLenum 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;
/* There are multiple color table stages: */
GLboolean ColorTableEnabled[COLORTABLE_MAX];
GLfloat ColorTableScale[COLORTABLE_MAX][4]; /**< RGBA */
GLfloat ColorTableBias[COLORTABLE_MAX][4]; /**< RGBA */
/* Convolution (GL_EXT_convolution) */
GLboolean Convolution1DEnabled;
GLboolean Convolution2DEnabled;
GLboolean Separable2DEnabled;
GLfloat ConvolutionBorderColor[3][4];
GLenum ConvolutionBorderMode[3];
GLfloat ConvolutionFilterScale[3][4]; /**< RGBA */
GLfloat ConvolutionFilterBias[3][4]; /**< RGBA */
GLfloat PostConvolutionScale[4]; /**< RGBA */
GLfloat PostConvolutionBias[4]; /**< RGBA */
/* Color matrix (GL_SGI_color_matrix) */
/* Note: the color matrix is not part of this attrib group */
GLfloat PostColorMatrixScale[4]; /**< RGBA */
GLfloat PostColorMatrixBias[4]; /**< RGBA */
/* Histogram & minmax (GL_EXT_histogram) */
/* Note: histogram and minmax data are not part of this attrib group */
GLboolean HistogramEnabled;
GLboolean MinMaxEnabled;
/*--- End Pixel Transfer State ---*/
/* Pixel Zoom */
GLfloat ZoomX, ZoomY;
/** GL_SGI_texture_color_table */
GLfloat TextureColorTableScale[4];
GLfloat TextureColorTableBias[4];
};
/**
* Point attribute group (GL_POINT_BIT).
*/
struct gl_point_attrib
{
GLboolean SmoothFlag; /**< True if GL_POINT_SMOOTH is enabled */
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 _Attenuated; /**< True if Params != [1, 0, 0] */
GLboolean PointSprite; /**< GL_NV/ARB_point_sprite */
GLboolean CoordReplace[MAX_TEXTURE_UNITS]; /**< GL_ARB_point_sprite */
GLenum SpriteRMode; /**< GL_NV_point_sprite (only!) */
GLenum SpriteOrigin; /**< GL_ARB_point_sprite */
};
/**
* Polygon attribute group (GL_POLYGON_BIT).
*/
struct gl_polygon_attrib
{
GLenum 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 _FrontBit; /**< 0=GL_CCW, 1=GL_CW */
GLboolean CullFlag; /**< Culling on/off flag */
GLboolean SmoothFlag; /**< True if GL_POLYGON_SMOOTH is enabled */
GLboolean StippleFlag; /**< True if GL_POLYGON_STIPPLE is enabled */
GLenum CullFaceMode; /**< Culling mode GL_FRONT or GL_BACK */
GLfloat OffsetFactor; /**< Polygon offset factor, from user */
GLfloat OffsetUnits; /**< Polygon offset units, 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_attrib
{
GLboolean Enabled; /**< Scissor test enabled? */
GLint X, Y; /**< Lower left corner of box */
GLsizei Width, Height; /**< Size of box */
};
/**
* 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) */
GLboolean _TestTwoSide;
GLubyte _BackFace; /**< Current back stencil state (1 or 2) */
GLenum Function[3]; /**< Stencil function */
GLenum FailFunc[3]; /**< Fail function */
GLenum ZPassFunc[3]; /**< Depth buffer pass function */
GLenum 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 */
};
/**
* An index for each type of texture object. These correspond to the GL
* target target enums, such as GL_TEXTURE_2D, GL_TEXTURE_CUBE_MAP, etc.
* Note: the order is from highest priority to lowest priority.
*/
enum {
TEXTURE_2D_ARRAY_INDEX,
TEXTURE_1D_ARRAY_INDEX,
TEXTURE_CUBE_INDEX,
TEXTURE_3D_INDEX,
TEXTURE_RECT_INDEX,
TEXTURE_2D_INDEX,
TEXTURE_1D_INDEX,
NUM_TEXTURE_TARGETS
};
/**
* Bit flags for each type of texture object
* Used for Texture.Unit[]._ReallyEnabled flags.
*/
/*@{*/
#define TEXTURE_2D_ARRAY_BIT (1 << TEXTURE_2D_ARRAY_INDEX)
#define TEXTURE_1D_ARRAY_BIT (1 << TEXTURE_1D_ARRAY_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)
/*@}*/
/**
* TexGenEnabled flags.
*/
/*@{*/
#define S_BIT 1
#define T_BIT 2
#define R_BIT 4
#define Q_BIT 8
/*@}*/
/**
* Bit flag versions of the corresponding GL_ constants.
*/
/*@{*/
#define TEXGEN_SPHERE_MAP 0x1
#define TEXGEN_OBJ_LINEAR 0x2
#define TEXGEN_EYE_LINEAR 0x4
#define TEXGEN_REFLECTION_MAP_NV 0x8
#define TEXGEN_NORMAL_MAP_NV 0x10
#define TEXGEN_NEED_NORMALS (TEXGEN_SPHERE_MAP | \
TEXGEN_REFLECTION_MAP_NV | \
TEXGEN_NORMAL_MAP_NV)
#define TEXGEN_NEED_EYE_COORD (TEXGEN_SPHERE_MAP | \
TEXGEN_REFLECTION_MAP_NV | \
TEXGEN_NORMAL_MAP_NV | \
TEXGEN_EYE_LINEAR)
/*@}*/
/** Tex-gen enabled for texture unit? */
#define ENABLE_TEXGEN(unit) (1 << (unit))
/** Non-identity texture matrix for texture unit? */
#define ENABLE_TEXMAT(unit) (1 << (unit))
/**
* Texel fetch function prototype. We use texel fetch functions to
* extract RGBA, color indexes and depth components out of 1D, 2D and 3D
* texture images. These functions help to isolate us from the gritty
* details of all the various texture image encodings.
*
* \param texImage texture image.
* \param col texel column.
* \param row texel row.
* \param img texel image level/layer.
* \param texelOut output texel (up to 4 GLchans)
*/
typedef void (*FetchTexelFuncC)( const struct gl_texture_image *texImage,
GLint col, GLint row, GLint img,
GLchan *texelOut );
/**
* As above, but returns floats.
* Used for depth component images and for upcoming signed/float
* texture images.
*/
typedef void (*FetchTexelFuncF)( const struct gl_texture_image *texImage,
GLint col, GLint row, GLint img,
GLfloat *texelOut );
typedef void (*StoreTexelFunc)(struct gl_texture_image *texImage,
GLint col, GLint row, GLint img,
const void *texel);
/**
* This macro defines the (many) parameters to the texstore functions.
* \param dims either 1 or 2 or 3
* \param baseInternalFormat user-specified base internal format
* \param dstFormat destination Mesa texture format
* \param dstAddr destination image address
* \param dstX/Y/Zoffset destination x/y/z offset (ala TexSubImage), in texels
* \param dstRowStride destination image row stride, in bytes
* \param dstImageOffsets offset of each 2D slice within 3D texture, in texels
* \param srcWidth/Height/Depth source image size, in pixels
* \param srcFormat incoming image format
* \param srcType incoming image data type
* \param srcAddr source image address
* \param srcPacking source image packing parameters
*/
#define TEXSTORE_PARAMS \
GLcontext *ctx, GLuint dims, \
GLenum baseInternalFormat, \
const struct gl_texture_format *dstFormat, \
GLvoid *dstAddr, \
GLint dstXoffset, GLint dstYoffset, GLint dstZoffset, \
GLint dstRowStride, const GLuint *dstImageOffsets, \
GLint srcWidth, GLint srcHeight, GLint srcDepth, \
GLenum srcFormat, GLenum srcType, \
const GLvoid *srcAddr, \
const struct gl_pixelstore_attrib *srcPacking
/**
* Texture image storage function.
*/
typedef GLboolean (*StoreTexImageFunc)(TEXSTORE_PARAMS);
/**
* Texture format record
*/
struct gl_texture_format
{
GLint MesaFormat; /**< One of the MESA_FORMAT_* values */
GLenum BaseFormat; /**< Either GL_RGB, GL_RGBA, GL_ALPHA,
* GL_LUMINANCE, GL_LUMINANCE_ALPHA,
* GL_INTENSITY, GL_COLOR_INDEX or
* GL_DEPTH_COMPONENT.
*/
GLenum DataType; /**< GL_FLOAT or GL_UNSIGNED_NORMALIZED_ARB */
/**
* Bits per texel component. These are just rough approximations
* for compressed texture formats.
*/
/*@{*/
GLubyte RedBits;
GLubyte GreenBits;
GLubyte BlueBits;
GLubyte AlphaBits;
GLubyte LuminanceBits;
GLubyte IntensityBits;
GLubyte IndexBits;
GLubyte DepthBits;
GLubyte StencilBits; /**< GL_EXT_packed_depth_stencil */
/*@}*/
GLuint TexelBytes; /**< Bytes per texel, 0 if compressed format */
StoreTexImageFunc StoreImage;
/**
* \name Texel fetch function pointers
*/
/*@{*/
FetchTexelFuncC FetchTexel1D;
FetchTexelFuncC FetchTexel2D;
FetchTexelFuncC FetchTexel3D;
FetchTexelFuncF FetchTexel1Df;
FetchTexelFuncF FetchTexel2Df;
FetchTexelFuncF FetchTexel3Df;
/*@}*/
StoreTexelFunc StoreTexel;
};
/**
* Texture image state. Describes the dimensions of a texture image,
* the texel format and pointers to Texel Fetch functions.
*/
struct gl_texture_image
{
GLenum _BaseFormat; /**< Either GL_RGB, GL_RGBA, GL_ALPHA,
* GL_LUMINANCE, GL_LUMINANCE_ALPHA,
* GL_INTENSITY, GL_COLOR_INDEX,
* GL_DEPTH_COMPONENT or GL_DEPTH_STENCIL_EXT
* only. Used for choosing TexEnv arithmetic.
*/
GLint InternalFormat; /**< Internal format as given by the user */
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 MaxLog2; /**< = MAX(WidthLog2, HeightLog2) */
GLfloat WidthScale; /**< used for mipmap LOD computation */
GLfloat HeightScale; /**< used for mipmap LOD computation */
GLfloat DepthScale; /**< used for mipmap LOD computation */
GLboolean IsClientData; /**< Data owned by client? */
GLboolean _IsPowerOfTwo; /**< Are all dimensions powers of two? */
const struct gl_texture_format *TexFormat;
struct gl_texture_object *TexObject; /**< Pointer back to parent object */
FetchTexelFuncC FetchTexelc; /**< GLchan texel fetch function pointer */
FetchTexelFuncF FetchTexelf; /**< Float texel fetch function pointer */
GLboolean IsCompressed; /**< GL_ARB_texture_compression */
GLuint CompressedSize; /**< GL_ARB_texture_compression */
GLuint RowStride; /**< Padded width in units of texels */
GLuint *ImageOffsets; /**< if 3D texture: array [Depth] of offsets to
each 2D slice in 'Data', in texels */
GLvoid *Data; /**< Image data, accessed via FetchTexel() */
/**
* \name For device driver:
*/
/*@{*/
void *DriverData; /**< Arbitrary device driver data */
/*@}*/
};
/**
* Indexes for cube map faces.
*/
/*@{*/
#define FACE_POS_X 0
#define FACE_NEG_X 1
#define FACE_POS_Y 2
#define FACE_NEG_Y 3
#define FACE_POS_Z 4
#define FACE_NEG_Z 5
#define MAX_FACES 6
/*@}*/
/**
* Texture object state. Contains the array of mipmap images, border color,
* wrap modes, filter modes, shadow/texcompare state, and the per-texture
* color palette.
*/
struct gl_texture_object
{
_glthread_Mutex Mutex; /**< for thread safety */
GLint RefCount; /**< reference count */
GLuint Name; /**< the user-visible texture object ID */
GLenum Target; /**< GL_TEXTURE_1D, GL_TEXTURE_2D, etc. */
GLfloat Priority; /**< in [0,1] */
GLfloat BorderColor[4]; /**< unclamped */
GLchan _BorderChan[4]; /**< clamped, as GLchan */
GLenum WrapS; /**< S-axis texture image wrap mode */
GLenum WrapT; /**< T-axis texture image wrap mode */
GLenum WrapR; /**< R-axis texture image wrap mode */
GLenum MinFilter; /**< minification filter */
GLenum MagFilter; /**< magnification filter */
GLfloat MinLod; /**< min lambda, OpenGL 1.2 */
GLfloat MaxLod; /**< max lambda, OpenGL 1.2 */
GLfloat LodBias; /**< OpenGL 1.4 */
GLint BaseLevel; /**< min mipmap level, OpenGL 1.2 */
GLint MaxLevel; /**< max mipmap level, OpenGL 1.2 */
GLfloat MaxAnisotropy; /**< GL_EXT_texture_filter_anisotropic */
GLenum CompareMode; /**< GL_ARB_shadow */
GLenum CompareFunc; /**< GL_ARB_shadow */
GLfloat CompareFailValue; /**< GL_ARB_shadow_ambient */
GLenum _Function; /**< Comparison function derived from
* \c CompareOperator, \c CompareMode, and
* \c CompareFunc.
*/
GLenum DepthMode; /**< GL_ARB_depth_texture */
GLint _MaxLevel; /**< actual max mipmap level (q in the spec) */
GLfloat _MaxLambda; /**< = _MaxLevel - BaseLevel (q - b in spec) */
GLint CropRect[4]; /**< GL_OES_draw_texture */
GLenum Swizzle[4]; /**< GL_EXT_texture_swizzle */
GLuint _Swizzle; /**< same as Swizzle, but SWIZZLE_* format */
GLboolean GenerateMipmap; /**< GL_SGIS_generate_mipmap */
GLboolean _Complete; /**< Is texture object complete? */
GLboolean _RenderToTexture; /**< Any rendering to this texture? */
/** Actual texture images, indexed by [cube face] and [mipmap level] */
struct gl_texture_image *Image[MAX_FACES][MAX_TEXTURE_LEVELS];
/** GL_EXT_paletted_texture */
struct gl_color_table Palette;
/**
* \name For device driver.
* Note: instead of attaching driver data to this pointer, it's preferable
* to instead use this struct as a base class for your own texture object
* class. Driver->NewTextureObject() can be used to implement the
* allocation.
*/
void *DriverData; /**< Arbitrary device driver data */
};
/**
* Texture combine environment state.
* Up to four combiner sources are possible with GL_NV_texture_env_combine4.
*/
struct gl_tex_env_combine_state
{
GLenum ModeRGB; /**< GL_REPLACE, GL_DECAL, GL_ADD, etc. */
GLenum ModeA; /**< GL_REPLACE, GL_DECAL, GL_ADD, etc. */
GLenum SourceRGB[4]; /**< GL_PRIMARY_COLOR, GL_TEXTURE, etc. */
GLenum SourceA[4]; /**< GL_PRIMARY_COLOR, GL_TEXTURE, etc. */
GLenum OperandRGB[4]; /**< SRC_COLOR, ONE_MINUS_SRC_COLOR, etc */
GLenum OperandA[4]; /**< SRC_ALPHA, ONE_MINUS_SRC_ALPHA, etc */
GLuint ScaleShiftRGB; /**< 0, 1 or 2 */
GLuint ScaleShiftA; /**< 0, 1 or 2 */
GLuint _NumArgsRGB; /**< Number of inputs used for the RGB combiner */
GLuint _NumArgsA; /**< Number of inputs used for the A combiner */
};
/**
* Texture coord generation state.
*/
struct gl_texgen
{
GLenum Mode; /**< GL_EYE_LINEAR, GL_SPHERE_MAP, etc */
GLbitfield _ModeBit; /**< TEXGEN_x bit corresponding to Mode */
GLfloat ObjectPlane[4];
GLfloat EyePlane[4];
};
/**
* Texture unit state. Contains enable flags, texture environment/function/
* combiners, texgen state, pointers to current texture objects and
* post-filter color tables.
*/
struct gl_texture_unit
{
GLbitfield Enabled; /**< bitmask of TEXTURE_*_BIT flags */
GLbitfield _ReallyEnabled; /**< 0 or exactly one of TEXTURE_*_BIT flags */
GLenum EnvMode; /**< GL_MODULATE, GL_DECAL, GL_BLEND, etc. */
GLfloat EnvColor[4];
struct gl_texgen GenS;
struct gl_texgen GenT;
struct gl_texgen GenR;
struct gl_texgen GenQ;
GLbitfield TexGenEnabled; /**< Bitwise-OR of [STRQ]_BIT values */
GLbitfield _GenFlags; /**< Bitwise-OR of Gen[STRQ]._ModeBit */
GLfloat LodBias; /**< for biasing mipmap levels */
/**
* \name GL_EXT_texture_env_combine
*/
struct gl_tex_env_combine_state Combine;
/**
* Derived state based on \c EnvMode and the \c BaseFormat of the
* currently enabled texture.
*/
struct gl_tex_env_combine_state _EnvMode;
/**
* Currently enabled combiner state. This will point to either
* \c Combine or \c _EnvMode.
*/
struct gl_tex_env_combine_state *_CurrentCombine;
/** Current texture object pointers */
struct gl_texture_object *CurrentTex[NUM_TEXTURE_TARGETS];
/** Points to highest priority, complete and enabled texture object */
struct gl_texture_object *_Current;
/** GL_SGI_texture_color_table */
/*@{*/
struct gl_color_table ColorTable;
struct gl_color_table ProxyColorTable;
GLboolean ColorTableEnabled;
/*@}*/
};
/**
* Texture attribute group (GL_TEXTURE_BIT).
*/
struct gl_texture_attrib
{
/**
* name multitexture
*/
/**@{*/
GLuint CurrentUnit; /**< Active texture unit [0, MaxTextureImageUnits-1] */
GLbitfield _EnabledUnits; /**< one bit set for each really-enabled unit */
GLbitfield _EnabledCoordUnits; /**< one bit per enabled coordinate unit */
GLbitfield _GenFlags; /**< for texgen */
GLbitfield _TexGenEnabled; /**< Mask of ENABLE_TEXGEN flags */
GLbitfield _TexMatEnabled; /**< Mask of ENABLE_TEXMAT flags */
/**@}*/
struct gl_texture_unit Unit[MAX_TEXTURE_UNITS];
struct gl_texture_object *ProxyTex[NUM_TEXTURE_TARGETS];
/** GL_EXT_shared_texture_palette */
GLboolean SharedPalette;
struct gl_color_table Palette;
};
/**
* Transformation attribute group (GL_TRANSFORM_BIT).
*/
struct gl_transform_attrib
{
GLenum MatrixMode; /**< Matrix mode */
GLfloat EyeUserPlane[MAX_CLIP_PLANES][4]; /**< User clip planes */
GLfloat _ClipUserPlane[MAX_CLIP_PLANES][4]; /**< derived */
GLbitfield ClipPlanesEnabled; /**< on/off bitmask */
GLboolean Normalize; /**< Normalize all normals? */
GLboolean RescaleNormals; /**< GL_EXT_rescale_normal */
GLboolean RasterPositionUnclipped; /**< GL_IBM_rasterpos_clip */
GLboolean CullVertexFlag; /**< True if GL_CULL_VERTEX_EXT is enabled */
GLfloat CullEyePos[4];
GLfloat CullObjPos[4];
};
/**
* Viewport attribute group (GL_VIEWPORT_BIT).
*/
struct gl_viewport_attrib
{
GLint X, Y; /**< position */
GLsizei Width, Height; /**< size */
GLfloat Near, Far; /**< Depth buffer range */
GLmatrix _WindowMap; /**< Mapping transformation as a matrix. */
};
/**
* Node for the attribute stack.
*/
struct gl_attrib_node
{
GLbitfield kind;
void *data;
struct gl_attrib_node *next;
};
/**
* GL_ARB_vertex/pixel_buffer_object buffer object
*/
struct gl_buffer_object
{
GLint RefCount;
GLuint Name;
GLenum Usage;
GLenum Access;
GLvoid *Pointer; /**< Only valid while buffer is mapped */
GLsizeiptrARB Size; /**< Size of storage in bytes */
GLubyte *Data; /**< Location of storage either in RAM or VRAM. */
GLboolean OnCard; /**< Is buffer in VRAM? (hardware drivers) */
};
/**
* Client pixel packing/unpacking attributes
*/
struct gl_pixelstore_attrib
{
GLint Alignment;
GLint RowLength;
GLint SkipPixels;
GLint SkipRows;
GLint ImageHeight; /**< for GL_EXT_texture3D */
GLint SkipImages; /**< for GL_EXT_texture3D */
GLboolean SwapBytes;
GLboolean LsbFirst;
GLboolean ClientStorage; /**< GL_APPLE_client_storage */
GLboolean Invert; /**< GL_MESA_pack_invert */
struct gl_buffer_object *BufferObj; /**< GL_ARB_pixel_buffer_object */
};
/**
* Client vertex array attributes
*/
struct gl_client_array
{
GLint Size; /**< components per element (1,2,3,4) */
GLenum Type; /**< datatype: GL_FLOAT, GL_INT, etc */
GLenum Format; /**< default: GL_RGBA, but may be GL_BGRA */
GLsizei Stride; /**< user-specified stride */
GLsizei StrideB; /**< actual stride in bytes */
const GLubyte *Ptr; /**< Points to array data */
GLboolean Enabled; /**< Enabled flag is a boolean */
GLboolean Normalized; /**< GL_ARB_vertex_program */
/**< GL_ARB_vertex_buffer_object */
struct gl_buffer_object *BufferObj;
GLuint _MaxElement;
};
/**
* Collection of vertex arrays. Defined by the GL_APPLE_vertex_array_object
* extension, but a nice encapsulation in any case.
*/
struct gl_array_object
{
/** Name of the array object as received from glGenVertexArrayAPPLE. */
GLuint Name;
/** Conventional vertex arrays */
/*@{*/
struct gl_client_array Vertex;
struct gl_client_array Normal;
struct gl_client_array Color;
struct gl_client_array SecondaryColor;
struct gl_client_array FogCoord;
struct gl_client_array Index;
struct gl_client_array EdgeFlag;
struct gl_client_array TexCoord[MAX_TEXTURE_COORD_UNITS];
struct gl_client_array PointSize;
/*@}*/
/** Generic arrays for vertex programs/shaders */
struct gl_client_array VertexAttrib[VERT_ATTRIB_MAX];
/** Mask of _NEW_ARRAY_* values indicating which arrays are enabled */
GLbitfield _Enabled;
};
/**
* Vertex array state
*/
struct gl_array_attrib
{
struct gl_array_object *ArrayObj;
struct gl_array_object *DefaultArrayObj;
GLint ActiveTexture; /**< Client Active Texture */
GLuint LockFirst; /**< GL_EXT_compiled_vertex_array */
GLuint LockCount; /**< GL_EXT_compiled_vertex_array */
GLbitfield NewState; /**< mask of _NEW_ARRAY_* values */
#if FEATURE_ARB_vertex_buffer_object
struct gl_buffer_object *NullBufferObj;
struct gl_buffer_object *ArrayBufferObj;
struct gl_buffer_object *ElementArrayBufferObj;
#endif
GLuint _MaxElement; /* Min of all enabled array's maxes */
};
/**
* Feedback buffer state
*/
struct gl_feedback
{
GLenum Type;
GLbitfield _Mask; /* FB_* bits */
GLfloat *Buffer;
GLuint BufferSize;
GLuint Count;
};
/**
* Selection buffer state
*/
struct gl_selection
{
GLuint *Buffer; /**< selection buffer */
GLuint BufferSize; /**< size of the selection buffer */
GLuint BufferCount; /**< number of values in the selection buffer */
GLuint Hits; /**< number of records in the selection buffer */
GLuint NameStackDepth; /**< name stack depth */
GLuint NameStack[MAX_NAME_STACK_DEPTH]; /**< name stack */
GLboolean HitFlag; /**< hit flag */
GLfloat HitMinZ; /**< minimum hit depth */
GLfloat HitMaxZ; /**< maximum hit depth */
};
/**
* 1-D Evaluator control points
*/
struct gl_1d_map
{
GLuint Order; /**< Number of control points */
GLfloat u1, u2, du; /**< u1, u2, 1.0/(u2-u1) */
GLfloat *Points; /**< Points to contiguous control points */
};
/**
* 2-D Evaluator control points
*/
struct gl_2d_map
{
GLuint Uorder; /**< Number of control points in U dimension */
GLuint Vorder; /**< Number of control points in V dimension */
GLfloat u1, u2, du;
GLfloat v1, v2, dv;
GLfloat *Points; /**< Points to contiguous control points */
};
/**
* All evaluator control point state
*/
struct gl_evaluators
{
/**
* \name 1-D maps
*/
/*@{*/
struct gl_1d_map Map1Vertex3;
struct gl_1d_map Map1Vertex4;
struct gl_1d_map Map1Index;
struct gl_1d_map Map1Color4;
struct gl_1d_map Map1Normal;
struct gl_1d_map Map1Texture1;
struct gl_1d_map Map1Texture2;
struct gl_1d_map Map1Texture3;
struct gl_1d_map Map1Texture4;
struct gl_1d_map Map1Attrib[16]; /**< GL_NV_vertex_program */
/*@}*/
/**
* \name 2-D maps
*/
/*@{*/
struct gl_2d_map Map2Vertex3;
struct gl_2d_map Map2Vertex4;
struct gl_2d_map Map2Index;
struct gl_2d_map Map2Color4;
struct gl_2d_map Map2Normal;
struct gl_2d_map Map2Texture1;
struct gl_2d_map Map2Texture2;
struct gl_2d_map Map2Texture3;
struct gl_2d_map Map2Texture4;
struct gl_2d_map Map2Attrib[16]; /**< GL_NV_vertex_program */
/*@}*/
};
/**
* Names of the various vertex/fragment program register files, etc.
*
* NOTE: first four tokens must fit into 2 bits (see t_vb_arbprogram.c)
* All values should fit in a 4-bit field.
*
* NOTE: PROGRAM_ENV_PARAM, PROGRAM_STATE_VAR, PROGRAM_NAMED_PARAM,
* PROGRAM_CONSTANT, and PROGRAM_UNIFORM can all be considered to
* be "uniform" variables since they can only be set outside glBegin/End.
* They're also all stored in the same Parameters array.
*/
enum register_file
{
PROGRAM_TEMPORARY = 0, /**< machine->Temporary[] */
PROGRAM_LOCAL_PARAM = 1, /**< gl_program->LocalParams[] */
PROGRAM_ENV_PARAM = 2, /**< gl_program->Parameters[] */
PROGRAM_STATE_VAR = 3, /**< gl_program->Parameters[] */
PROGRAM_INPUT = 4, /**< machine->Inputs[] */
PROGRAM_OUTPUT = 5, /**< machine->Outputs[] */
PROGRAM_NAMED_PARAM = 6, /**< gl_program->Parameters[] */
PROGRAM_CONSTANT = 7, /**< gl_program->Parameters[] */
PROGRAM_UNIFORM = 8, /**< gl_program->Parameters[] */
PROGRAM_VARYING = 9, /**< machine->Inputs[]/Outputs[] */
PROGRAM_WRITE_ONLY = 10, /**< A dummy, write-only register */
PROGRAM_ADDRESS = 11, /**< machine->AddressReg */
PROGRAM_SAMPLER = 12, /**< for shader samplers, compile-time only */
PROGRAM_UNDEFINED = 13, /**< Invalid value */
PROGRAM_FILE_MAX
};
/** Vertex and fragment instructions */
struct prog_instruction;
struct gl_program_parameter_list;
struct gl_uniform_list;
/**
* Base class for any kind of program object
*/
struct gl_program
{
GLuint Id;
GLubyte *String; /**< Null-terminated program text */
GLint RefCount;
GLenum Target; /**< GL_VERTEX/FRAGMENT_PROGRAM_ARB, GL_FRAGMENT_PROGRAM_NV */
GLenum Format; /**< String encoding format */
GLboolean Resident;
struct prog_instruction *Instructions;
GLbitfield InputsRead; /**< Bitmask of which input regs are read */
GLbitfield OutputsWritten; /**< Bitmask of which output regs are written to */
GLbitfield InputFlags[MAX_PROGRAM_INPUTS]; /**< PROG_PARAM_BIT_x flags */
GLbitfield OutputFlags[MAX_PROGRAM_OUTPUTS]; /**< PROG_PARAM_BIT_x flags */
GLbitfield TexturesUsed[MAX_TEXTURE_UNITS]; /**< TEXTURE_x_BIT bitmask */
GLbitfield SamplersUsed; /**< Bitfield of which samplers are used */
GLbitfield ShadowSamplers; /**< Texture units used for shadow sampling. */
/** Named parameters, constants, etc. from program text */
struct gl_program_parameter_list *Parameters;
/** Numbered local parameters */
GLfloat LocalParams[MAX_PROGRAM_LOCAL_PARAMS][4];
/** Vertex/fragment shader varying vars */
struct gl_program_parameter_list *Varying;
/** Vertex program user-defined attributes */
struct gl_program_parameter_list *Attributes;
/** Map from sampler unit to texture unit (set by glUniform1i()) */
GLubyte SamplerUnits[MAX_SAMPLERS];
/** Which texture target is being sampled (TEXTURE_1D/2D/3D/etc_INDEX) */
GLubyte SamplerTargets[MAX_SAMPLERS];
/** Logical counts */
/*@{*/
GLuint NumInstructions;
GLuint NumTemporaries;
GLuint NumParameters;
GLuint NumAttributes;
GLuint NumAddressRegs;
GLuint NumAluInstructions;
GLuint NumTexInstructions;
GLuint NumTexIndirections;
/*@}*/
/** Native, actual h/w counts */
/*@{*/
GLuint NumNativeInstructions;
GLuint NumNativeTemporaries;
GLuint NumNativeParameters;
GLuint NumNativeAttributes;
GLuint NumNativeAddressRegs;
GLuint NumNativeAluInstructions;
GLuint NumNativeTexInstructions;
GLuint NumNativeTexIndirections;
/*@}*/
};
/** Vertex program object */
struct gl_vertex_program
{
struct gl_program Base; /**< base class */
GLboolean IsNVProgram; /**< is this a GL_NV_vertex_program program? */
GLboolean IsPositionInvariant;
void *TnlData; /**< should probably use Base.DriverData */
};
/** Fragment program object */
struct gl_fragment_program
{
struct gl_program Base; /**< base class */
GLenum FogOption;
GLboolean UsesKill; /**< shader uses KIL instruction */
GLboolean UsesPointCoord; /**< shader uses gl_PointCoord */
GLboolean UsesFrontFacing; /**< shader used gl_FrontFacing */
GLboolean UsesFogFragCoord; /**< shader used gl_FogFragCoord */
};
/**
* State common to vertex and fragment programs.
*/
struct gl_program_state
{
GLint ErrorPos; /* GL_PROGRAM_ERROR_POSITION_ARB/NV */
const char *ErrorString; /* GL_PROGRAM_ERROR_STRING_ARB/NV */
};
/**
* Context state for vertex programs.
*/
struct gl_vertex_program_state
{
GLboolean Enabled; /**< User-set GL_VERTEX_PROGRAM_ARB/NV flag */
GLboolean _Enabled; /**< Enabled and _valid_ user program? */
GLboolean PointSizeEnabled; /**< GL_VERTEX_PROGRAM_POINT_SIZE_ARB/NV */
GLboolean TwoSideEnabled; /**< GL_VERTEX_PROGRAM_TWO_SIDE_ARB/NV */
struct gl_vertex_program *Current; /**< User-bound vertex program */
/** Currently enabled and valid vertex program (including internal programs,
* user-defined vertex programs and GLSL vertex shaders).
* This is the program we must use when rendering.
*/
struct gl_vertex_program *_Current;
GLfloat Parameters[MAX_PROGRAM_ENV_PARAMS][4]; /**< Env params */
/* For GL_NV_vertex_program only: */
GLenum TrackMatrix[MAX_PROGRAM_ENV_PARAMS / 4];
GLenum TrackMatrixTransform[MAX_PROGRAM_ENV_PARAMS / 4];
/** Should fixed-function T&L be implemented with a vertex prog? */
GLboolean _MaintainTnlProgram;
/** Program to emulate fixed-function T&L (see above) */
struct gl_vertex_program *_TnlProgram;
/** Cache of fixed-function programs */
struct gl_program_cache *Cache;
#if FEATURE_MESA_program_debug
GLprogramcallbackMESA Callback;
GLvoid *CallbackData;
GLboolean CallbackEnabled;
GLuint CurrentPosition;
#endif
GLboolean _Overriden;
};
/**
* Context state for fragment programs.
*/
struct gl_fragment_program_state
{
GLboolean Enabled; /**< User-set fragment program enable flag */
GLboolean _Enabled; /**< Enabled and _valid_ user program? */
struct gl_fragment_program *Current; /**< User-bound fragment program */
/** Currently enabled and valid fragment program (including internal programs,
* user-defined fragment programs and GLSL fragment shaders).
* This is the program we must use when rendering.
*/
struct gl_fragment_program *_Current;
GLfloat Parameters[MAX_PROGRAM_ENV_PARAMS][4]; /**< Env params */
/** Should fixed-function texturing be implemented with a fragment prog? */
GLboolean _MaintainTexEnvProgram;
/** Program to emulate fixed-function texture env/combine (see above) */
struct gl_fragment_program *_TexEnvProgram;
/** Cache of fixed-function programs */
struct gl_program_cache *Cache;
#if FEATURE_MESA_program_debug
GLprogramcallbackMESA Callback;
GLvoid *CallbackData;
GLboolean CallbackEnabled;
GLuint CurrentPosition;
#endif
};
/**
* ATI_fragment_shader runtime state
*/
#define ATI_FS_INPUT_PRIMARY 0
#define ATI_FS_INPUT_SECONDARY 1
struct atifs_instruction;
struct atifs_setupinst;
/**
* ATI fragment shader
*/
struct ati_fragment_shader
{
GLuint Id;
GLint RefCount;
struct atifs_instruction *Instructions[2];
struct atifs_setupinst *SetupInst[2];
GLfloat Constants[8][4];
GLbitfield LocalConstDef; /** Indicates which constants have been set */
GLubyte numArithInstr[2];
GLubyte regsAssigned[2];
GLubyte NumPasses; /** 1 or 2 */
GLubyte cur_pass;
GLubyte last_optype;
GLboolean interpinp1;
GLboolean isValid;
GLuint swizzlerq;
};
/**
* Context state for GL_ATI_fragment_shader
*/
struct gl_ati_fragment_shader_state
{
GLboolean Enabled;
GLboolean _Enabled; /** enabled and valid shader? */
GLboolean Compiling;
GLfloat GlobalConstants[8][4];
struct ati_fragment_shader *Current;
};
/**
* Occlusion/timer query object.
*/
struct gl_query_object
{
GLenum Target; /**< The query target, when active */
GLuint Id; /**< hash table ID/name */
GLuint64EXT Result; /**< the counter */
GLboolean Active; /**< inside Begin/EndQuery */
GLboolean Ready; /**< result is ready? */
};
/**
* Context state for query objects.
*/
struct gl_query_state
{
struct _mesa_HashTable *QueryObjects;
struct gl_query_object *CurrentOcclusionObject; /* GL_ARB_occlusion_query */
struct gl_query_object *CurrentTimerObject; /* GL_EXT_timer_query */
};
/** Set by #pragma directives */
struct gl_sl_pragmas
{
GLboolean Optimize; /**< defaults on */
GLboolean Debug; /**< defaults off */
};
/**
* A GLSL vertex or fragment shader object.
*/
struct gl_shader
{
GLenum Type; /**< GL_FRAGMENT_SHADER || GL_VERTEX_SHADER (first field!) */
GLuint Name; /**< AKA the handle */
GLint RefCount; /**< Reference count */
GLboolean DeletePending;
GLboolean CompileStatus;
GLboolean Main; /**< shader defines main() */
const GLchar *Source; /**< Source code string */
struct gl_program *Program; /**< Post-compile assembly code */
GLchar *InfoLog;
struct gl_sl_pragmas Pragmas;
};
/**
* A GLSL program object.
* Basically a linked collection of vertex and fragment shaders.
*/
struct gl_shader_program
{
GLenum Type; /**< Always GL_SHADER_PROGRAM (internal token) */
GLuint Name; /**< aka handle or ID */
GLint RefCount; /**< Reference count */
GLboolean DeletePending;
GLuint NumShaders; /**< number of attached shaders */
struct gl_shader **Shaders; /**< List of attached the shaders */
/** User-defined attribute bindings (glBindAttribLocation) */
struct gl_program_parameter_list *Attributes;
/* post-link info: */
struct gl_vertex_program *VertexProgram; /**< Linked vertex program */
struct gl_fragment_program *FragmentProgram; /**< Linked fragment prog */
struct gl_uniform_list *Uniforms;
struct gl_program_parameter_list *Varying;
GLboolean LinkStatus; /**< GL_LINK_STATUS */
GLboolean Validated;
GLchar *InfoLog;
};
#define GLSL_DUMP 0x1 /**< Dump shaders to stdout */
#define GLSL_LOG 0x2 /**< Write shaders to files */
#define GLSL_OPT 0x4 /**< Force optimizations (override pragmas) */
#define GLSL_NO_OPT 0x8 /**< Force no optimizations (override pragmas) */
#define GLSL_UNIFORMS 0x10 /**< Print glUniform calls */
/**
* Context state for GLSL vertex/fragment shaders.
*/
struct gl_shader_state
{
struct gl_shader_program *CurrentProgram; /**< The user-bound program */
/** Driver-selectable options: */
GLboolean EmitHighLevelInstructions; /**< IF/ELSE/ENDIF vs. BRA, etc. */
GLboolean EmitCondCodes; /**< Use condition codes? */
GLboolean EmitComments; /**< Annotated instructions */
void *MemPool;
GLbitfield Flags; /**< Mask of GLSL_x flags */
};
/**
* State which can be shared by multiple contexts:
*/
struct gl_shared_state
{
_glthread_Mutex Mutex; /**< for thread safety */
GLint RefCount; /**< Reference count */
struct _mesa_HashTable *DisplayList; /**< Display lists hash table */
struct _mesa_HashTable *TexObjects; /**< Texture objects hash table */
/** Default texture objects (shared by all texture units) */
struct gl_texture_object *DefaultTex[NUM_TEXTURE_TARGETS];
/**
* \name Thread safety and statechange notification for texture
* objects.
*
* \todo Improve the granularity of locking.
*/
/*@{*/
_glthread_Mutex TexMutex; /**< texobj thread safety */
GLuint TextureStateStamp; /**< state notification for shared tex */
/*@}*/
/**
* \name Vertex/fragment programs
*/
/*@{*/
struct _mesa_HashTable *Programs; /**< All vertex/fragment programs */
#if FEATURE_ARB_vertex_program
struct gl_vertex_program *DefaultVertexProgram;
#endif
#if FEATURE_ARB_fragment_program
struct gl_fragment_program *DefaultFragmentProgram;
#endif
/*@}*/
#if FEATURE_ATI_fragment_shader
struct _mesa_HashTable *ATIShaders;
struct ati_fragment_shader *DefaultFragmentShader;
#endif
#if FEATURE_ARB_vertex_buffer_object || FEATURE_ARB_pixel_buffer_object
struct _mesa_HashTable *BufferObjects;
#endif
#if FEATURE_ARB_shader_objects
/** Table of both gl_shader and gl_shader_program objects */
struct _mesa_HashTable *ShaderObjects;
#endif
#if FEATURE_EXT_framebuffer_object
struct _mesa_HashTable *RenderBuffers;
struct _mesa_HashTable *FrameBuffers;
#endif
/** Objects associated with the GL_APPLE_vertex_array_object extension. */
struct _mesa_HashTable *ArrayObjects;
void *DriverData; /**< Device driver shared state */
};
/**
* A renderbuffer stores colors or depth values or stencil values.
* A framebuffer object will have a collection of these.
* Data are read/written to the buffer with a handful of Get/Put functions.
*
* Instances of this object are allocated with the Driver's NewRenderbuffer
* hook. Drivers will likely wrap this class inside a driver-specific
* class to simulate inheritance.
*/
struct gl_renderbuffer
{
#define RB_MAGIC 0xaabbccdd
int Magic; /** XXX TEMPORARY DEBUG INFO */
_glthread_Mutex Mutex; /**< for thread safety */
GLuint ClassID; /**< Useful for drivers */
GLuint Name;
GLint RefCount;
GLuint Width, Height;
GLenum InternalFormat; /**< The user-specified format */
GLenum _ActualFormat; /**< The driver-chosen format */
GLenum _BaseFormat; /**< Either GL_RGB, GL_RGBA, GL_DEPTH_COMPONENT or
GL_STENCIL_INDEX. */
GLenum ColorEncoding; /**< GL_LINEAR or GL_SRGB */
GLenum ComponentType; /**< GL_FLOAT, GL_INT, GL_UNSIGNED_INT,
GL_UNSIGNED_NORMALIZED or GL_INDEX */
GLubyte RedBits; /**< Bits of red per pixel */
GLubyte GreenBits;
GLubyte BlueBits;
GLubyte AlphaBits;
GLubyte IndexBits;
GLubyte DepthBits;
GLubyte StencilBits;
GLubyte NumSamples;
GLenum DataType; /**< Type of values passed to the Get/Put functions */
GLvoid *Data; /**< This may not be used by some kinds of RBs */
/* Used to wrap one renderbuffer around another: */
struct gl_renderbuffer *Wrapped;
/* Delete this renderbuffer */
void (*Delete)(struct gl_renderbuffer *rb);
/* Allocate new storage for this renderbuffer */
GLboolean (*AllocStorage)(GLcontext *ctx, struct gl_renderbuffer *rb,
GLenum internalFormat,
GLuint width, GLuint height);
/* Lock/Unlock are called before/after calling the Get/Put functions.
* Not sure this is the right place for these yet.
void (*Lock)(GLcontext *ctx, struct gl_renderbuffer *rb);
void (*Unlock)(GLcontext *ctx, struct gl_renderbuffer *rb);
*/
/* Return a pointer to the element/pixel at (x,y).
* Should return NULL if the buffer memory can't be directly addressed.
*/
void *(*GetPointer)(GLcontext *ctx, struct gl_renderbuffer *rb,
GLint x, GLint y);
/* Get/Read a row of values.
* The values will be of format _BaseFormat and type DataType.
*/
void (*GetRow)(GLcontext *ctx, struct gl_renderbuffer *rb, GLuint count,
GLint x, GLint y, void *values);
/* Get/Read values at arbitrary locations.
* The values will be of format _BaseFormat and type DataType.
*/
void (*GetValues)(GLcontext *ctx, struct gl_renderbuffer *rb, GLuint count,
const GLint x[], const GLint y[], void *values);
/* Put/Write a row of values.
* The values will be of format _BaseFormat and type DataType.
*/
void (*PutRow)(GLcontext *ctx, struct gl_renderbuffer *rb, GLuint count,
GLint x, GLint y, const void *values, const GLubyte *mask);
/* Put/Write a row of RGB values. This is a special-case routine that's
* only used for RGBA renderbuffers when the source data is GL_RGB. That's
* a common case for glDrawPixels and some triangle routines.
* The values will be of format GL_RGB and type DataType.
*/
void (*PutRowRGB)(GLcontext *ctx, struct gl_renderbuffer *rb, GLuint count,
GLint x, GLint y, const void *values, const GLubyte *mask);
/* Put/Write a row of identical values.
* The values will be of format _BaseFormat and type DataType.
*/
void (*PutMonoRow)(GLcontext *ctx, struct gl_renderbuffer *rb, GLuint count,
GLint x, GLint y, const void *value, const GLubyte *mask);
/* Put/Write values at arbitrary locations.
* The values will be of format _BaseFormat and type DataType.
*/
void (*PutValues)(GLcontext *ctx, struct gl_renderbuffer *rb, GLuint count,
const GLint x[], const GLint y[], const void *values,
const GLubyte *mask);
/* Put/Write identical values at arbitrary locations.
* The values will be of format _BaseFormat and type DataType.
*/
void (*PutMonoValues)(GLcontext *ctx, struct gl_renderbuffer *rb,
GLuint count, const GLint x[], const GLint y[],
const void *value, const GLubyte *mask);
};
/**
* A renderbuffer attachment point points to either a texture object
* (and specifies a mipmap level, cube face or 3D texture slice) or
* points to a renderbuffer.
*/
struct gl_renderbuffer_attachment
{
GLenum Type; /**< \c GL_NONE or \c GL_TEXTURE or \c GL_RENDERBUFFER_EXT */
GLboolean Complete;
/**
* If \c Type is \c GL_RENDERBUFFER_EXT, this stores a pointer to the
* application supplied renderbuffer object.
*/
struct gl_renderbuffer *Renderbuffer;
/**
* If \c Type is \c GL_TEXTURE, this stores a pointer to the application
* supplied texture object.
*/
struct gl_texture_object *Texture;
GLuint TextureLevel; /**< Attached mipmap level. */
GLuint CubeMapFace; /**< 0 .. 5, for cube map textures. */
GLuint Zoffset; /**< Slice for 3D textures, or layer for both 1D
* and 2D array textures */
};
/**
* A framebuffer is a collection of renderbuffers (color, depth, stencil, etc).
* In C++ terms, think of this as a base class from which device drivers
* will make derived classes.
*/
struct gl_framebuffer
{
_glthread_Mutex Mutex; /**< for thread safety */
GLuint Name; /* if zero, this is a window system framebuffer */
GLint RefCount;
GLboolean DeletePending;
GLvisual Visual; /**< The framebuffer's visual.
Immutable if this is a window system buffer.
Computed from attachments if user-made FBO. */
GLboolean Initialized;
GLuint Width, Height; /**< size of frame buffer in pixels */
/** \name Drawing bounds (Intersection of buffer size and scissor box) */
/*@{*/
GLint _Xmin, _Xmax; /**< inclusive */
GLint _Ymin, _Ymax; /**< exclusive */
/*@}*/
/** \name Derived Z buffer stuff */
/*@{*/
GLuint _DepthMax; /**< Max depth buffer value */
GLfloat _DepthMaxF; /**< Float max depth buffer value */
GLfloat _MRD; /**< minimum resolvable difference in Z values */
/*@}*/
GLenum _Status; /* One of the GL_FRAMEBUFFER_(IN)COMPLETE_* tokens */
/* Array of all renderbuffer attachments, indexed by BUFFER_* tokens. */
struct gl_renderbuffer_attachment Attachment[BUFFER_COUNT];
/* In unextended OpenGL these vars are part of the GL_COLOR_BUFFER
* attribute group and GL_PIXEL attribute group, respectively.
*/
GLenum ColorDrawBuffer[MAX_DRAW_BUFFERS];
GLenum ColorReadBuffer;
/** Computed from ColorDraw/ReadBuffer above */
GLuint _NumColorDrawBuffers;
GLint _ColorDrawBufferIndexes[MAX_DRAW_BUFFERS]; /**< BUFFER_x or -1 */
GLint _ColorReadBufferIndex; /* -1 = None */
struct gl_renderbuffer *_ColorDrawBuffers[MAX_DRAW_BUFFERS];
struct gl_renderbuffer *_ColorReadBuffer;
/** The Actual depth/stencil buffers to use. May be wrappers around the
* depth/stencil buffers attached above. */
struct gl_renderbuffer *_DepthBuffer;
struct gl_renderbuffer *_StencilBuffer;
/** Delete this framebuffer */
void (*Delete)(struct gl_framebuffer *fb);
};
/**
* Limits for vertex and fragment programs.
*/
struct gl_program_constants
{
/* logical limits */
GLuint MaxInstructions;
GLuint MaxAluInstructions; /* fragment programs only, for now */
GLuint MaxTexInstructions; /* fragment programs only, for now */
GLuint MaxTexIndirections; /* fragment programs only, for now */
GLuint MaxAttribs;
GLuint MaxTemps;
GLuint MaxAddressRegs; /* vertex program only, for now */
GLuint MaxParameters;
GLuint MaxLocalParams;
GLuint MaxEnvParams;
/* native/hardware limits */
GLuint MaxNativeInstructions;
GLuint MaxNativeAluInstructions; /* fragment programs only, for now */
GLuint MaxNativeTexInstructions; /* fragment programs only, for now */
GLuint MaxNativeTexIndirections; /* fragment programs only, for now */
GLuint MaxNativeAttribs;
GLuint MaxNativeTemps;
GLuint MaxNativeAddressRegs; /* vertex program only, for now */
GLuint MaxNativeParameters;
/* For shaders */
GLuint MaxUniformComponents;
};
/**
* Constants which may be overridden by device driver during context creation
* but are never changed after that.
*/
struct gl_constants
{
GLint MaxTextureLevels; /**< Maximum number of allowed mipmap levels. */
GLint Max3DTextureLevels; /**< Maximum number of allowed mipmap levels for 3D texture targets. */
GLint MaxCubeTextureLevels; /**< Maximum number of allowed mipmap levels for GL_ARB_texture_cube_map */
GLint MaxArrayTextureLayers; /**< Maximum number of layers in an array texture. */
GLint MaxTextureRectSize; /* GL_NV_texture_rectangle */
GLuint MaxTextureCoordUnits;
GLuint MaxTextureImageUnits;
GLuint MaxTextureUnits; /**< = MIN(CoordUnits, ImageUnits) */
GLfloat MaxTextureMaxAnisotropy; /**< GL_EXT_texture_filter_anisotropic */
GLfloat MaxTextureLodBias; /**< GL_EXT_texture_lod_bias */
GLuint MaxArrayLockSize;
GLint SubPixelBits;
GLfloat MinPointSize, MaxPointSize; /* aliased */
GLfloat MinPointSizeAA, MaxPointSizeAA; /* antialiased */
GLfloat PointSizeGranularity;
GLfloat MinLineWidth, MaxLineWidth; /* aliased */
GLfloat MinLineWidthAA, MaxLineWidthAA; /* antialiased */
GLfloat LineWidthGranularity;
GLuint MaxColorTableSize;
GLuint MaxConvolutionWidth;
GLuint MaxConvolutionHeight;
GLuint MaxClipPlanes;
GLuint MaxLights;
GLfloat MaxShininess; /* GL_NV_light_max_exponent */
GLfloat MaxSpotExponent; /* GL_NV_light_max_exponent */
GLuint MaxViewportWidth, MaxViewportHeight;
struct gl_program_constants VertexProgram; /* GL_ARB_vertex_program */
struct gl_program_constants FragmentProgram; /* GL_ARB_fragment_program */
/* shared by vertex and fragment program: */
GLuint MaxProgramMatrices;
GLuint MaxProgramMatrixStackDepth;
/* vertex array / buffer object bounds checking */
GLboolean CheckArrayBounds;
/* GL_ARB_draw_buffers */
GLuint MaxDrawBuffers;
/* GL_OES_read_format */
GLenum ColorReadFormat;
GLenum ColorReadType;
/* GL_EXT_framebuffer_object */
GLuint MaxColorAttachments;
GLuint MaxRenderbufferSize;
/* GL_ARB_vertex_shader */
GLuint MaxVertexTextureImageUnits;
GLuint MaxVarying; /**< Number of float[4] vectors */
/* GL_ARB_framebuffer_object */
GLuint MaxSamples;
};
/**
* Enable flag for each OpenGL extension. Different device drivers will
* enable different extensions at runtime.
*/
struct gl_extensions
{
/**
* \name Flags to quickly test if certain extensions are available.
*
* Not every extension needs to have such a flag, but it's encouraged.
*/
/*@{*/
GLboolean dummy; /* don't remove this! */
GLboolean ARB_depth_texture;
GLboolean ARB_draw_buffers;
GLboolean ARB_fragment_program;
GLboolean ARB_fragment_program_shadow;
GLboolean ARB_fragment_shader;
GLboolean ARB_framebuffer_object;
GLboolean ARB_half_float_pixel;
GLboolean ARB_imaging;
GLboolean ARB_multisample;
GLboolean ARB_multitexture;
GLboolean ARB_occlusion_query;
GLboolean ARB_point_sprite;
GLboolean ARB_shader_objects;
GLboolean ARB_shading_language_100;
GLboolean ARB_shading_language_120;
GLboolean ARB_shadow;
GLboolean ARB_shadow_ambient; /* or GL_ARB_shadow_ambient */
GLboolean ARB_texture_border_clamp;
GLboolean ARB_texture_compression;
GLboolean ARB_texture_cube_map;
GLboolean ARB_texture_env_combine;
GLboolean ARB_texture_env_crossbar;
GLboolean ARB_texture_env_dot3;
GLboolean ARB_texture_float;
GLboolean ARB_texture_mirrored_repeat;
GLboolean ARB_texture_non_power_of_two;
GLboolean ARB_transpose_matrix;
GLboolean ARB_vertex_buffer_object;
GLboolean ARB_vertex_program;
GLboolean ARB_vertex_shader;
GLboolean ARB_window_pos;
GLboolean EXT_abgr;
GLboolean EXT_bgra;
GLboolean EXT_blend_color;
GLboolean EXT_blend_equation_separate;
GLboolean EXT_blend_func_separate;
GLboolean EXT_blend_logic_op;
GLboolean EXT_blend_minmax;
GLboolean EXT_blend_subtract;
GLboolean EXT_clip_volume_hint;
GLboolean EXT_cull_vertex;
GLboolean EXT_convolution;
GLboolean EXT_compiled_vertex_array;
GLboolean EXT_copy_texture;
GLboolean EXT_depth_bounds_test;
GLboolean EXT_draw_range_elements;
GLboolean EXT_framebuffer_object;
GLboolean EXT_fog_coord;
GLboolean EXT_framebuffer_blit;
GLboolean EXT_gpu_program_parameters;
GLboolean EXT_histogram;
GLboolean EXT_multi_draw_arrays;
GLboolean EXT_paletted_texture;
GLboolean EXT_packed_depth_stencil;
GLboolean EXT_packed_pixels;
GLboolean EXT_pixel_buffer_object;
GLboolean EXT_point_parameters;
GLboolean EXT_polygon_offset;
GLboolean EXT_rescale_normal;
GLboolean EXT_shadow_funcs;
GLboolean EXT_secondary_color;
GLboolean EXT_separate_specular_color;
GLboolean EXT_shared_texture_palette;
GLboolean EXT_stencil_wrap;
GLboolean EXT_stencil_two_side;
GLboolean EXT_subtexture;
GLboolean EXT_texture;
GLboolean EXT_texture_object;
GLboolean EXT_texture3D;
GLboolean EXT_texture_compression_s3tc;
GLboolean EXT_texture_env_add;
GLboolean EXT_texture_env_combine;
GLboolean EXT_texture_env_dot3;
GLboolean EXT_texture_filter_anisotropic;
GLboolean EXT_texture_lod_bias;
GLboolean EXT_texture_mirror_clamp;
GLboolean EXT_texture_sRGB;
GLboolean EXT_texture_swizzle;
GLboolean EXT_timer_query;
GLboolean EXT_vertex_array;
GLboolean EXT_vertex_array_bgra;
GLboolean EXT_vertex_array_set;
/* vendor extensions */
GLboolean APPLE_client_storage;
GLboolean APPLE_packed_pixels;
GLboolean APPLE_vertex_array_object;
GLboolean ATI_texture_mirror_once;
GLboolean ATI_texture_env_combine3;
GLboolean ATI_fragment_shader;
GLboolean ATI_separate_stencil;
GLboolean IBM_rasterpos_clip;
GLboolean IBM_multimode_draw_arrays;
GLboolean MESA_pack_invert;
GLboolean MESA_packed_depth_stencil;
GLboolean MESA_program_debug;
GLboolean MESA_resize_buffers;
GLboolean MESA_ycbcr_texture;
GLboolean MESA_texture_array;
GLboolean NV_blend_square;
GLboolean NV_fragment_program;
GLboolean NV_light_max_exponent;
GLboolean NV_point_sprite;
GLboolean NV_texgen_reflection;
GLboolean NV_texture_env_combine4;
GLboolean NV_texture_rectangle;
GLboolean NV_vertex_program;
GLboolean NV_vertex_program1_1;
GLboolean OES_read_format;
GLboolean SGI_color_matrix;
GLboolean SGI_color_table;
GLboolean SGI_texture_color_table;
GLboolean SGIS_generate_mipmap;
GLboolean SGIS_texture_edge_clamp;
GLboolean SGIS_texture_lod;
GLboolean TDFX_texture_compression_FXT1;
GLboolean S3_s3tc;
/*@}*/
/* The extension string */
const GLubyte *String;
};
/**
* A stack of matrices (projection, modelview, color, texture, etc).
*/
struct gl_matrix_stack
{
GLmatrix *Top; /**< points into Stack */
GLmatrix *Stack; /**< array [MaxDepth] of GLmatrix */
GLuint Depth; /**< 0 <= Depth < MaxDepth */
GLuint MaxDepth; /**< size of Stack[] array */
GLuint DirtyFlag; /**< _NEW_MODELVIEW or _NEW_PROJECTION, for example */
};
/**
* \name Bits for image transfer operations
*
* \sa __GLcontextRec::ImageTransferState.
*/
/*@{*/
#define IMAGE_SCALE_BIAS_BIT 0x1
#define IMAGE_SHIFT_OFFSET_BIT 0x2
#define IMAGE_MAP_COLOR_BIT 0x4
#define IMAGE_COLOR_TABLE_BIT 0x8
#define IMAGE_CONVOLUTION_BIT 0x10
#define IMAGE_POST_CONVOLUTION_SCALE_BIAS 0x20
#define IMAGE_POST_CONVOLUTION_COLOR_TABLE_BIT 0x40
#define IMAGE_COLOR_MATRIX_BIT 0x80
#define IMAGE_POST_COLOR_MATRIX_COLOR_TABLE_BIT 0x100
#define IMAGE_HISTOGRAM_BIT 0x200
#define IMAGE_MIN_MAX_BIT 0x400
#define IMAGE_CLAMP_BIT 0x800 /* extra */
/** Pixel Transfer ops up to convolution */
#define IMAGE_PRE_CONVOLUTION_BITS (IMAGE_SCALE_BIAS_BIT | \
IMAGE_SHIFT_OFFSET_BIT | \
IMAGE_MAP_COLOR_BIT | \
IMAGE_COLOR_TABLE_BIT)
/** Pixel transfer ops after convolution */
#define IMAGE_POST_CONVOLUTION_BITS (IMAGE_POST_CONVOLUTION_SCALE_BIAS | \
IMAGE_POST_CONVOLUTION_COLOR_TABLE_BIT | \
IMAGE_COLOR_MATRIX_BIT | \
IMAGE_POST_COLOR_MATRIX_COLOR_TABLE_BIT |\
IMAGE_HISTOGRAM_BIT | \
IMAGE_MIN_MAX_BIT)
/*@}*/
/**
* \name Bits to indicate what state has changed.
*
* 4 unused flags.
*/
/*@{*/
#define _NEW_MODELVIEW 0x1 /**< __GLcontextRec::ModelView */
#define _NEW_PROJECTION 0x2 /**< __GLcontextRec::Projection */
#define _NEW_TEXTURE_MATRIX 0x4 /**< __GLcontextRec::TextureMatrix */
#define _NEW_COLOR_MATRIX 0x8 /**< __GLcontextRec::ColorMatrix */
#define _NEW_ACCUM 0x10 /**< __GLcontextRec::Accum */
#define _NEW_COLOR 0x20 /**< __GLcontextRec::Color */
#define _NEW_DEPTH 0x40 /**< __GLcontextRec::Depth */
#define _NEW_EVAL 0x80 /**< __GLcontextRec::Eval, __GLcontextRec::EvalMap */
#define _NEW_FOG 0x100 /**< __GLcontextRec::Fog */
#define _NEW_HINT 0x200 /**< __GLcontextRec::Hint */
#define _NEW_LIGHT 0x400 /**< __GLcontextRec::Light */
#define _NEW_LINE 0x800 /**< __GLcontextRec::Line */
#define _NEW_PIXEL 0x1000 /**< __GLcontextRec::Pixel */
#define _NEW_POINT 0x2000 /**< __GLcontextRec::Point */
#define _NEW_POLYGON 0x4000 /**< __GLcontextRec::Polygon */
#define _NEW_POLYGONSTIPPLE 0x8000 /**< __GLcontextRec::PolygonStipple */
#define _NEW_SCISSOR 0x10000 /**< __GLcontextRec::Scissor */
#define _NEW_STENCIL 0x20000 /**< __GLcontextRec::Stencil */
#define _NEW_TEXTURE 0x40000 /**< __GLcontextRec::Texture */
#define _NEW_TRANSFORM 0x80000 /**< __GLcontextRec::Transform */
#define _NEW_VIEWPORT 0x100000 /**< __GLcontextRec::Viewport */
#define _NEW_PACKUNPACK 0x200000 /**< __GLcontextRec::Pack, __GLcontextRec::Unpack */
#define _NEW_ARRAY 0x400000 /**< __GLcontextRec::Array */
#define _NEW_RENDERMODE 0x800000 /**< __GLcontextRec::RenderMode, __GLcontextRec::Feedback, __GLcontextRec::Select */
#define _NEW_BUFFERS 0x1000000 /**< __GLcontextRec::Visual, __GLcontextRec::DrawBuffer, */
#define _NEW_MULTISAMPLE 0x2000000 /**< __GLcontextRec::Multisample */
#define _NEW_TRACK_MATRIX 0x4000000 /**< __GLcontextRec::VertexProgram */
#define _NEW_PROGRAM 0x8000000 /**< __GLcontextRec::VertexProgram */
#define _NEW_CURRENT_ATTRIB 0x10000000 /**< __GLcontextRec::Current */
#define _NEW_ALL ~0
/*@}*/
/**
* \name Bits to track array state changes
*
* Also used to summarize array enabled.
*/
/*@{*/
#define _NEW_ARRAY_VERTEX VERT_BIT_POS
#define _NEW_ARRAY_WEIGHT VERT_BIT_WEIGHT
#define _NEW_ARRAY_NORMAL VERT_BIT_NORMAL
#define _NEW_ARRAY_COLOR0 VERT_BIT_COLOR0
#define _NEW_ARRAY_COLOR1 VERT_BIT_COLOR1
#define _NEW_ARRAY_FOGCOORD VERT_BIT_FOG
#define _NEW_ARRAY_INDEX VERT_BIT_COLOR_INDEX
#define _NEW_ARRAY_EDGEFLAG VERT_BIT_EDGEFLAG
#define _NEW_ARRAY_POINT_SIZE VERT_BIT_COLOR_INDEX /* aliased */
#define _NEW_ARRAY_TEXCOORD_0 VERT_BIT_TEX0
#define _NEW_ARRAY_TEXCOORD_1 VERT_BIT_TEX1
#define _NEW_ARRAY_TEXCOORD_2 VERT_BIT_TEX2
#define _NEW_ARRAY_TEXCOORD_3 VERT_BIT_TEX3
#define _NEW_ARRAY_TEXCOORD_4 VERT_BIT_TEX4
#define _NEW_ARRAY_TEXCOORD_5 VERT_BIT_TEX5
#define _NEW_ARRAY_TEXCOORD_6 VERT_BIT_TEX6
#define _NEW_ARRAY_TEXCOORD_7 VERT_BIT_TEX7
#define _NEW_ARRAY_ATTRIB_0 VERT_BIT_GENERIC0 /* start at bit 16 */
#define _NEW_ARRAY_ALL 0xffffffff
#define _NEW_ARRAY_TEXCOORD(i) (_NEW_ARRAY_TEXCOORD_0 << (i))
#define _NEW_ARRAY_ATTRIB(i) (_NEW_ARRAY_ATTRIB_0 << (i))
/*@}*/
/**
* \name A bunch of flags that we think might be useful to drivers.
*
* Set in the __GLcontextRec::_TriangleCaps bitfield.
*/
/*@{*/
#define DD_FLATSHADE 0x1
#define DD_SEPARATE_SPECULAR 0x2
#define DD_TRI_CULL_FRONT_BACK 0x4 /* special case on some hw */
#define DD_TRI_LIGHT_TWOSIDE 0x8
#define DD_TRI_UNFILLED 0x10
#define DD_TRI_SMOOTH 0x20
#define DD_TRI_STIPPLE 0x40
#define DD_TRI_OFFSET 0x80
#define DD_LINE_SMOOTH 0x100
#define DD_LINE_STIPPLE 0x200
#define DD_LINE_WIDTH 0x400
#define DD_POINT_SMOOTH 0x800
#define DD_POINT_SIZE 0x1000
#define DD_POINT_ATTEN 0x2000
#define DD_TRI_TWOSTENCIL 0x4000
/*@}*/
/**
* \name Define the state changes under which each of these bits might change
*/
/*@{*/
#define _DD_NEW_FLATSHADE _NEW_LIGHT
#define _DD_NEW_SEPARATE_SPECULAR (_NEW_LIGHT | _NEW_FOG | _NEW_PROGRAM)
#define _DD_NEW_TRI_CULL_FRONT_BACK _NEW_POLYGON
#define _DD_NEW_TRI_LIGHT_TWOSIDE _NEW_LIGHT
#define _DD_NEW_TRI_UNFILLED _NEW_POLYGON
#define _DD_NEW_TRI_SMOOTH _NEW_POLYGON
#define _DD_NEW_TRI_STIPPLE _NEW_POLYGON
#define _DD_NEW_TRI_OFFSET _NEW_POLYGON
#define _DD_NEW_LINE_SMOOTH _NEW_LINE
#define _DD_NEW_LINE_STIPPLE _NEW_LINE
#define _DD_NEW_LINE_WIDTH _NEW_LINE
#define _DD_NEW_POINT_SMOOTH _NEW_POINT
#define _DD_NEW_POINT_SIZE _NEW_POINT
#define _DD_NEW_POINT_ATTEN _NEW_POINT
/*@}*/
/**
* Composite state flags
*/
/*@{*/
#define _MESA_NEW_NEED_EYE_COORDS (_NEW_LIGHT | \
_NEW_TEXTURE | \
_NEW_POINT | \
_NEW_PROGRAM | \
_NEW_MODELVIEW)
#define _MESA_NEW_NEED_NORMALS (_NEW_LIGHT | \
_NEW_TEXTURE)
#define _MESA_NEW_TRANSFER_STATE (_NEW_PIXEL | \
_NEW_COLOR_MATRIX)
/*@}*/
/* This has to be included here. */
#include "dd.h"
#define NUM_VERTEX_FORMAT_ENTRIES (sizeof(GLvertexformat) / sizeof(void *))
/**
* Core Mesa's support for tnl modules:
*/
struct gl_tnl_module
{
/**
* Vertex format to be lazily swapped into current dispatch.
*/
const GLvertexformat *Current;
/**
* \name Record of functions swapped out.
* On restore, only need to swap these functions back in.
*/
/*@{*/
struct {
_glapi_proc * location;
_glapi_proc function;
} Swapped[NUM_VERTEX_FORMAT_ENTRIES];
GLuint SwapCount;
/*@}*/
};
/**
* Display list flags.
* Strictly this is a tnl-private concept, but it doesn't seem
* worthwhile adding a tnl private structure just to hold this one bit
* of information:
*/
#define DLIST_DANGLING_REFS 0x1
/** Opaque declaration of display list payload data type */
union gl_dlist_node;
/**
* Provide a location where information about a display list can be
* collected. Could be extended with driverPrivate structures,
* etc. in the future.
*/
struct gl_display_list
{
GLuint Name;
GLbitfield Flags; /**< DLIST_x flags */
/** The dlist commands are in a linked list of nodes */
union gl_dlist_node *Head;
};
/**
* State used during display list compilation and execution.
*/
struct gl_dlist_state
{
GLuint CallDepth; /**< Current recursion calling depth */
struct gl_display_list *CurrentList; /**< List currently being compiled */
union gl_dlist_node *CurrentBlock; /**< Pointer to current block of nodes */
GLuint CurrentPos; /**< Index into current block of nodes */
GLvertexformat ListVtxfmt;
GLubyte ActiveAttribSize[VERT_ATTRIB_MAX];
GLfloat CurrentAttrib[VERT_ATTRIB_MAX][4];
GLubyte ActiveMaterialSize[MAT_ATTRIB_MAX];
GLfloat CurrentMaterial[MAT_ATTRIB_MAX][4];
GLubyte ActiveIndex;
GLfloat CurrentIndex;
GLubyte ActiveEdgeFlag;
GLboolean CurrentEdgeFlag;
};
/**
* Mesa rendering context.
*
* This is the central context data structure for Mesa. Almost all
* OpenGL state is contained in this structure.
* Think of this as a base class from which device drivers will derive
* sub classes.
*
* The GLcontext typedef names this structure.
*/
struct __GLcontextRec
{
/** State possibly shared with other contexts in the address space */
struct gl_shared_state *Shared;
/** \name API function pointer tables */
/*@{*/
struct _glapi_table *Save; /**< Display list save functions */
struct _glapi_table *Exec; /**< Execute functions */
struct _glapi_table *CurrentDispatch; /**< == Save or Exec !! */
/*@}*/
GLvisual Visual;
GLframebuffer *DrawBuffer; /**< buffer for writing */
GLframebuffer *ReadBuffer; /**< buffer for reading */
GLframebuffer *WinSysDrawBuffer; /**< set with MakeCurrent */
GLframebuffer *WinSysReadBuffer; /**< set with MakeCurrent */
/**
* Device driver function pointer table
*/
struct dd_function_table Driver;
void *DriverCtx; /**< Points to device driver context/state */
/** Core/Driver constants */
struct gl_constants Const;
/** \name The various 4x4 matrix stacks */
/*@{*/
struct gl_matrix_stack ModelviewMatrixStack;
struct gl_matrix_stack ProjectionMatrixStack;
struct gl_matrix_stack ColorMatrixStack;
struct gl_matrix_stack TextureMatrixStack[MAX_TEXTURE_UNITS];
struct gl_matrix_stack ProgramMatrixStack[MAX_PROGRAM_MATRICES];
struct gl_matrix_stack *CurrentStack; /**< Points to one of the above stacks */
/*@}*/
/** Combined modelview and projection matrix */
GLmatrix _ModelProjectMatrix;
/** \name Display lists */
struct gl_dlist_state ListState;
GLboolean ExecuteFlag; /**< Execute GL commands? */
GLboolean CompileFlag; /**< Compile GL commands into display list? */
/** Extension information */
struct gl_extensions Extensions;
/** \name State attribute stack (for glPush/PopAttrib) */
/*@{*/
GLuint AttribStackDepth;
struct gl_attrib_node *AttribStack[MAX_ATTRIB_STACK_DEPTH];
/*@}*/
/** \name Renderer attribute groups
*
* We define a struct for each attribute group to make pushing and popping
* attributes easy. Also it's a good organization.
*/
/*@{*/
struct gl_accum_attrib Accum; /**< Accum buffer attributes */
struct gl_colorbuffer_attrib Color; /**< Color buffer attributes */
struct gl_current_attrib Current; /**< Current attributes */
struct gl_depthbuffer_attrib Depth; /**< Depth buffer attributes */
struct gl_eval_attrib Eval; /**< Eval attributes */
struct gl_fog_attrib Fog; /**< Fog attributes */
struct gl_hint_attrib Hint; /**< Hint attributes */
struct gl_light_attrib Light; /**< Light attributes */
struct gl_line_attrib Line; /**< Line attributes */
struct gl_list_attrib List; /**< List attributes */
struct gl_multisample_attrib Multisample;
struct gl_pixel_attrib Pixel; /**< Pixel attributes */
struct gl_point_attrib Point; /**< Point attributes */
struct gl_polygon_attrib Polygon; /**< Polygon attributes */
GLuint PolygonStipple[32]; /**< Polygon stipple */
struct gl_scissor_attrib Scissor; /**< Scissor attributes */
struct gl_stencil_attrib Stencil; /**< Stencil buffer attributes */
struct gl_texture_attrib Texture; /**< Texture attributes */
struct gl_transform_attrib Transform; /**< Transformation attributes */
struct gl_viewport_attrib Viewport; /**< Viewport attributes */
/*@}*/
/** \name Client attribute stack */
/*@{*/
GLuint ClientAttribStackDepth;
struct gl_attrib_node *ClientAttribStack[MAX_CLIENT_ATTRIB_STACK_DEPTH];
/*@}*/
/** \name Client attribute groups */
/*@{*/
struct gl_array_attrib Array; /**< Vertex arrays */
struct gl_pixelstore_attrib Pack; /**< Pixel packing */
struct gl_pixelstore_attrib Unpack; /**< Pixel unpacking */
struct gl_pixelstore_attrib DefaultPacking; /**< Default params */
/*@}*/
/** \name Other assorted state (not pushed/popped on attribute stack) */
/*@{*/
struct gl_pixelmaps PixelMaps;
struct gl_histogram_attrib Histogram;
struct gl_minmax_attrib MinMax;
struct gl_convolution_attrib Convolution1D;
struct gl_convolution_attrib Convolution2D;
struct gl_convolution_attrib Separable2D;
struct gl_evaluators EvalMap; /**< All evaluators */
struct gl_feedback Feedback; /**< Feedback */
struct gl_selection Select; /**< Selection */
struct gl_color_table ColorTable[COLORTABLE_MAX];
struct gl_color_table ProxyColorTable[COLORTABLE_MAX];
#if 0
struct gl_color_table PostConvolutionColorTable;
struct gl_color_table ProxyPostConvolutionColorTable;
struct gl_color_table PostColorMatrixColorTable;
struct gl_color_table ProxyPostColorMatrixColorTable;
#endif
struct gl_program_state Program; /**< for vertex or fragment progs */
struct gl_vertex_program_state VertexProgram; /**< GL_ARB/NV_vertex_program */
struct gl_fragment_program_state FragmentProgram; /**< GL_ARB/NV_vertex_program */
struct gl_ati_fragment_shader_state ATIFragmentShader; /**< GL_ATI_fragment_shader */
struct gl_query_state Query; /**< GL_ARB_occlusion_query */
struct gl_shader_state Shader; /**< GLSL shader object state */
/*@}*/
#if FEATURE_EXT_framebuffer_object
struct gl_renderbuffer *CurrentRenderbuffer;
#endif
GLenum ErrorValue; /**< Last error code */
GLenum RenderMode; /**< either GL_RENDER, GL_SELECT, GL_FEEDBACK */
GLbitfield NewState; /**< bitwise-or of _NEW_* flags */
GLbitfield varying_vp_inputs; /**< mask of VERT_BIT_* flags */
/** \name Derived state */
/*@{*/
/** Bitwise-or of DD_* flags. Note that this bitfield may be used before
* state validation so they need to always be current.
*/
GLbitfield _TriangleCaps;
GLbitfield _ImageTransferState;/**< bitwise-or of IMAGE_*_BIT flags */
GLfloat _EyeZDir[3];
GLfloat _ModelViewInvScale;
GLboolean _NeedEyeCoords;
GLboolean _ForceEyeCoords;
GLenum _CurrentProgram; /* currently executing program */
GLuint TextureStateTimestamp; /* detect changes to shared state */
struct gl_shine_tab *_ShineTable[2]; /**< Active shine tables */
struct gl_shine_tab *_ShineTabList; /**< MRU list of inactive shine tables */
/**@}*/
struct gl_list_extensions ListExt; /**< driver dlist extensions */
/** \name For debugging/development only */
/*@{*/
GLboolean FirstTimeCurrent;
/*@}*/
/** Dither disable via MESA_NO_DITHER env var */
GLboolean NoDither;
/** software compression/decompression supported or not */
GLboolean Mesa_DXTn;
/** Core tnl module support */
struct gl_tnl_module TnlModule;
/**
* \name Hooks for module contexts.
*
* These will eventually live in the driver or elsewhere.
*/
/*@{*/
void *swrast_context;
void *swsetup_context;
void *swtnl_context;
void *swtnl_im;
struct st_context *st;
void *aelt_context;
/*@}*/
};
/** The string names for GL_POINT, GL_LINE_LOOP, etc */
extern const char *_mesa_prim_name[GL_POLYGON+4];
#ifdef DEBUG
extern int MESA_VERBOSE;
extern int MESA_DEBUG_FLAGS;
# define MESA_FUNCTION __FUNCTION__
#else
# define MESA_VERBOSE 0
# define MESA_DEBUG_FLAGS 0
# define MESA_FUNCTION "a function"
# ifndef NDEBUG
# define NDEBUG
# endif
#endif
enum _verbose
{
VERBOSE_VARRAY = 0x0001,
VERBOSE_TEXTURE = 0x0002,
VERBOSE_IMMEDIATE = 0x0004,
VERBOSE_PIPELINE = 0x0008,
VERBOSE_DRIVER = 0x0010,
VERBOSE_STATE = 0x0020,
VERBOSE_API = 0x0040,
VERBOSE_DISPLAY_LIST = 0x0100,
VERBOSE_LIGHTING = 0x0200,
VERBOSE_PRIMS = 0x0400,
VERBOSE_VERTS = 0x0800,
VERBOSE_DISASSEM = 0x1000,
};
enum _debug
{
DEBUG_ALWAYS_FLUSH = 0x1
};
#endif /* MTYPES_H */
|