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
|
/*
* IWineD3D implementation
*
* Copyright 2002-2004 Jason Edmeades
* Copyright 2003-2004 Raphael Junqueira
* Copyright 2004 Christian Costa
* Copyright 2005 Oliver Stieber
* Copyright 2007-2008 Stefan Dösinger for CodeWeavers
* Copyright 2009 Henri Verbeet for CodeWeavers
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/
/*
* Oracle LGPL Disclaimer: For the avoidance of doubt, except that if any license choice
* other than GPL or LGPL is available it will apply instead, Oracle elects to use only
* the Lesser General Public License version 2.1 (LGPLv2) at this time for any software where
* a choice of LGPL license versions is made available with the language indicating
* that LGPLv2 or any later version may be used, or where a choice of which version
* of the LGPL is applied is otherwise unspecified.
*/
#include "config.h"
#include <stdio.h>
#include "wined3d_private.h"
#ifdef VBOX_WITH_WDDM
# include <VBoxCrHgsmi.h>
#endif
#ifdef VBOX_WITH_VMSVGA
# ifdef RT_OS_WINDOWS
DECLIMPORT(void) APIENTRY glFinish(void);
# else
void glFinish(void);
# endif
#endif
WINE_DEFAULT_DEBUG_CHANNEL(d3d);
WINE_DECLARE_DEBUG_CHANNEL(d3d_caps);
#define GLINFO_LOCATION (*gl_info)
#define WINE_DEFAULT_VIDMEM (64 * 1024 * 1024)
/* The d3d device ID */
#if 0 /* VBox: unused */
static const GUID IID_D3DDEVICE_D3DUID = { 0xaeb2cdd4, 0x6e41, 0x43ea, { 0x94,0x1c,0x83,0x61,0xcc,0x76,0x07,0x81 } };
#endif
/* Extension detection */
static const struct {
const char *extension_string;
GL_SupportedExt extension;
DWORD version;
} EXTENSION_MAP[] = {
/* APPLE */
{"GL_APPLE_client_storage", APPLE_CLIENT_STORAGE, 0 },
{"GL_APPLE_fence", APPLE_FENCE, 0 },
{"GL_APPLE_float_pixels", APPLE_FLOAT_PIXELS, 0 },
{"GL_APPLE_flush_buffer_range", APPLE_FLUSH_BUFFER_RANGE, 0 },
{"GL_APPLE_flush_render", APPLE_FLUSH_RENDER, 0 },
{"GL_APPLE_ycbcr_422", APPLE_YCBCR_422, 0 },
/* ARB */
{"GL_ARB_color_buffer_float", ARB_COLOR_BUFFER_FLOAT, 0 },
{"GL_ARB_depth_buffer_float", ARB_DEPTH_BUFFER_FLOAT, 0 },
{"GL_ARB_depth_clamp", ARB_DEPTH_CLAMP, 0 },
{"GL_ARB_depth_texture", ARB_DEPTH_TEXTURE, 0 },
{"GL_ARB_draw_buffers", ARB_DRAW_BUFFERS, 0 },
{"GL_ARB_fragment_program", ARB_FRAGMENT_PROGRAM, 0 },
{"GL_ARB_fragment_shader", ARB_FRAGMENT_SHADER, 0 },
{"GL_ARB_framebuffer_object", ARB_FRAMEBUFFER_OBJECT, 0 },
{"GL_ARB_geometry_shader4", ARB_GEOMETRY_SHADER4, 0 },
{"GL_ARB_half_float_pixel", ARB_HALF_FLOAT_PIXEL, 0 },
{"GL_ARB_half_float_vertex", ARB_HALF_FLOAT_VERTEX, 0 },
{"GL_ARB_imaging", ARB_IMAGING, 0 },
{"GL_ARB_map_buffer_range", ARB_MAP_BUFFER_RANGE, 0 },
{"GL_ARB_multisample", ARB_MULTISAMPLE, 0 }, /* needs GLX_ARB_MULTISAMPLE as well */
{"GL_ARB_multitexture", ARB_MULTITEXTURE, 0 },
{"GL_ARB_occlusion_query", ARB_OCCLUSION_QUERY, 0 },
{"GL_ARB_pixel_buffer_object", ARB_PIXEL_BUFFER_OBJECT, 0 },
{"GL_ARB_point_parameters", ARB_POINT_PARAMETERS, 0 },
{"GL_ARB_point_sprite", ARB_POINT_SPRITE, 0 },
{"GL_ARB_provoking_vertex", ARB_PROVOKING_VERTEX, 0 },
{"GL_ARB_shader_objects", ARB_SHADER_OBJECTS, 0 },
{"GL_ARB_shader_texture_lod", ARB_SHADER_TEXTURE_LOD, 0 },
{"GL_ARB_shading_language_100", ARB_SHADING_LANGUAGE_100, 0 },
{"GL_ARB_sync", ARB_SYNC, 0 },
{"GL_ARB_texture_border_clamp", ARB_TEXTURE_BORDER_CLAMP, 0 },
{"GL_ARB_texture_compression", ARB_TEXTURE_COMPRESSION, 0 },
{"GL_ARB_texture_cube_map", ARB_TEXTURE_CUBE_MAP, 0 },
{"GL_ARB_texture_env_add", ARB_TEXTURE_ENV_ADD, 0 },
{"GL_ARB_texture_env_combine", ARB_TEXTURE_ENV_COMBINE, 0 },
{"GL_ARB_texture_env_dot3", ARB_TEXTURE_ENV_DOT3, 0 },
{"GL_ARB_texture_float", ARB_TEXTURE_FLOAT, 0 },
{"GL_ARB_texture_mirrored_repeat", ARB_TEXTURE_MIRRORED_REPEAT, 0 },
{"GL_IBM_texture_mirrored_repeat", ARB_TEXTURE_MIRRORED_REPEAT, 0 },
{"GL_ARB_texture_non_power_of_two", ARB_TEXTURE_NON_POWER_OF_TWO, MAKEDWORD_VERSION(2, 0) },
{"GL_ARB_texture_rectangle", ARB_TEXTURE_RECTANGLE, 0 },
{"GL_ARB_texture_rg", ARB_TEXTURE_RG, 0 },
{"GL_ARB_vertex_array_bgra", ARB_VERTEX_ARRAY_BGRA, 0 },
{"GL_ARB_vertex_blend", ARB_VERTEX_BLEND, 0 },
{"GL_ARB_vertex_buffer_object", ARB_VERTEX_BUFFER_OBJECT, 0 },
{"GL_ARB_vertex_program", ARB_VERTEX_PROGRAM, 0 },
{"GL_ARB_vertex_shader", ARB_VERTEX_SHADER, 0 },
/* ATI */
{"GL_ATI_fragment_shader", ATI_FRAGMENT_SHADER, 0 },
{"GL_ATI_separate_stencil", ATI_SEPARATE_STENCIL, 0 },
{"GL_ATI_texture_compression_3dc", ATI_TEXTURE_COMPRESSION_3DC, 0 },
{"GL_ATI_texture_env_combine3", ATI_TEXTURE_ENV_COMBINE3, 0 },
{"GL_ATI_texture_mirror_once", ATI_TEXTURE_MIRROR_ONCE, 0 },
/* EXT */
{"GL_EXT_blend_color", EXT_BLEND_COLOR, 0 },
{"GL_EXT_blend_equation_separate", EXT_BLEND_EQUATION_SEPARATE, 0 },
{"GL_EXT_blend_func_separate", EXT_BLEND_FUNC_SEPARATE, 0 },
{"GL_EXT_blend_minmax", EXT_BLEND_MINMAX, 0 },
{"GL_EXT_draw_buffers2", EXT_DRAW_BUFFERS2, 0 },
{"GL_EXT_fog_coord", EXT_FOG_COORD, 0 },
{"GL_EXT_framebuffer_blit", EXT_FRAMEBUFFER_BLIT, 0 },
{"GL_EXT_framebuffer_multisample", EXT_FRAMEBUFFER_MULTISAMPLE, 0 },
{"GL_EXT_framebuffer_object", EXT_FRAMEBUFFER_OBJECT, 0 },
{"GL_EXT_gpu_program_parameters", EXT_GPU_PROGRAM_PARAMETERS, 0 },
{"GL_EXT_gpu_shader4", EXT_GPU_SHADER4, 0 },
{"GL_EXT_packed_depth_stencil", EXT_PACKED_DEPTH_STENCIL, 0 },
{"GL_EXT_paletted_texture", EXT_PALETTED_TEXTURE, 0 },
{"GL_EXT_point_parameters", EXT_POINT_PARAMETERS, 0 },
{"GL_EXT_provoking_vertex", EXT_PROVOKING_VERTEX, 0 },
{"GL_EXT_secondary_color", EXT_SECONDARY_COLOR, 0 },
{"GL_EXT_stencil_two_side", EXT_STENCIL_TWO_SIDE, 0 },
{"GL_EXT_stencil_wrap", EXT_STENCIL_WRAP, 0 },
{"GL_EXT_texture3D", EXT_TEXTURE3D, MAKEDWORD_VERSION(1, 2) },
{"GL_EXT_texture_compression_rgtc", EXT_TEXTURE_COMPRESSION_RGTC, 0 },
{"GL_EXT_texture_compression_s3tc", EXT_TEXTURE_COMPRESSION_S3TC, 0 },
{"GL_EXT_texture_env_add", EXT_TEXTURE_ENV_ADD, 0 },
{"GL_EXT_texture_env_combine", EXT_TEXTURE_ENV_COMBINE, 0 },
{"GL_EXT_texture_env_dot3", EXT_TEXTURE_ENV_DOT3, 0 },
{"GL_EXT_texture_filter_anisotropic", EXT_TEXTURE_FILTER_ANISOTROPIC, 0 },
{"GL_EXT_texture_lod_bias", EXT_TEXTURE_LOD_BIAS, 0 },
{"GL_EXT_texture_sRGB", EXT_TEXTURE_SRGB, 0 },
{"GL_EXT_vertex_array_bgra", EXT_VERTEX_ARRAY_BGRA, 0 },
/* NV */
{"GL_NV_depth_clamp", NV_DEPTH_CLAMP, 0 },
{"GL_NV_fence", NV_FENCE, 0 },
{"GL_NV_fog_distance", NV_FOG_DISTANCE, 0 },
{"GL_NV_fragment_program", NV_FRAGMENT_PROGRAM, 0 },
{"GL_NV_fragment_program2", NV_FRAGMENT_PROGRAM2, 0 },
{"GL_NV_fragment_program_option", NV_FRAGMENT_PROGRAM_OPTION, 0 },
{"GL_NV_half_float", NV_HALF_FLOAT, 0 },
{"GL_NV_light_max_exponent", NV_LIGHT_MAX_EXPONENT, 0 },
{"GL_NV_register_combiners", NV_REGISTER_COMBINERS, 0 },
{"GL_NV_register_combiners2", NV_REGISTER_COMBINERS2, 0 },
{"GL_NV_texgen_reflection", NV_TEXGEN_REFLECTION, 0 },
{"GL_NV_texture_env_combine4", NV_TEXTURE_ENV_COMBINE4, 0 },
{"GL_NV_texture_shader", NV_TEXTURE_SHADER, 0 },
{"GL_NV_texture_shader2", NV_TEXTURE_SHADER2, 0 },
{"GL_NV_vertex_program", NV_VERTEX_PROGRAM, 0 },
{"GL_NV_vertex_program1_1", NV_VERTEX_PROGRAM1_1, 0 },
{"GL_NV_vertex_program2", NV_VERTEX_PROGRAM2, 0 },
{"GL_NV_vertex_program2_option", NV_VERTEX_PROGRAM2_OPTION, 0 },
{"GL_NV_vertex_program3", NV_VERTEX_PROGRAM3, 0 },
/* SGI */
{"GL_SGIS_generate_mipmap", SGIS_GENERATE_MIPMAP, 0 },
};
/**********************************************************
* Utility functions follow
**********************************************************/
const struct min_lookup minMipLookup[] =
{
/* NONE POINT LINEAR */
{{GL_NEAREST, GL_NEAREST, GL_NEAREST}}, /* NONE */
{{GL_NEAREST, GL_NEAREST_MIPMAP_NEAREST, GL_NEAREST_MIPMAP_LINEAR}}, /* POINT*/
{{GL_LINEAR, GL_LINEAR_MIPMAP_NEAREST, GL_LINEAR_MIPMAP_LINEAR}}, /* LINEAR */
};
const struct min_lookup minMipLookup_noFilter[] =
{
/* NONE POINT LINEAR */
{{GL_NEAREST, GL_NEAREST, GL_NEAREST}}, /* NONE */
{{GL_NEAREST, GL_NEAREST, GL_NEAREST}}, /* POINT */
{{GL_NEAREST, GL_NEAREST, GL_NEAREST}}, /* LINEAR */
};
const struct min_lookup minMipLookup_noMip[] =
{
/* NONE POINT LINEAR */
{{GL_NEAREST, GL_NEAREST, GL_NEAREST}}, /* NONE */
{{GL_NEAREST, GL_NEAREST, GL_NEAREST}}, /* POINT */
{{GL_LINEAR, GL_LINEAR, GL_LINEAR }}, /* LINEAR */
};
const GLenum magLookup[] =
{
/* NONE POINT LINEAR */
GL_NEAREST, GL_NEAREST, GL_LINEAR,
};
const GLenum magLookup_noFilter[] =
{
/* NONE POINT LINEAR */
GL_NEAREST, GL_NEAREST, GL_NEAREST,
};
/* drawStridedSlow attributes */
glAttribFunc position_funcs[WINED3D_FFP_EMIT_COUNT];
glAttribFunc diffuse_funcs[WINED3D_FFP_EMIT_COUNT];
glAttribFunc specular_func_3ubv;
glAttribFunc specular_funcs[WINED3D_FFP_EMIT_COUNT];
glAttribFunc normal_funcs[WINED3D_FFP_EMIT_COUNT];
glMultiTexCoordFunc multi_texcoord_funcs[WINED3D_FFP_EMIT_COUNT];
/**********************************************************
* IWineD3D parts follows
**********************************************************/
/* GL locking is done by the caller */
static inline BOOL test_arb_vs_offset_limit(const struct wined3d_gl_info *gl_info)
{
GLuint prog;
BOOL ret = FALSE;
const char *testcode =
"!!ARBvp1.0\n"
"PARAM C[66] = { program.env[0..65] };\n"
"ADDRESS A0;"
"PARAM zero = {0.0, 0.0, 0.0, 0.0};\n"
"ARL A0.x, zero.x;\n"
"MOV result.position, C[A0.x + 65];\n"
"END\n";
while(glGetError());
GL_EXTCALL(glGenProgramsARB(1, &prog));
if(!prog) {
ERR("Failed to create an ARB offset limit test program\n");
}
GL_EXTCALL(glBindProgramARB(GL_VERTEX_PROGRAM_ARB, prog));
GL_EXTCALL(glProgramStringARB(GL_VERTEX_PROGRAM_ARB, GL_PROGRAM_FORMAT_ASCII_ARB,
(GLsizei)strlen(testcode), testcode));
if(glGetError() != 0) {
TRACE("OpenGL implementation does not allow indirect addressing offsets > 63\n");
TRACE("error: %s\n", debugstr_a((const char *)glGetString(GL_PROGRAM_ERROR_STRING_ARB)));
ret = TRUE;
} else TRACE("OpenGL implementation allows offsets > 63\n");
GL_EXTCALL(glBindProgramARB(GL_VERTEX_PROGRAM_ARB, 0));
GL_EXTCALL(glDeleteProgramsARB(1, &prog));
checkGLcall("ARB vp offset limit test cleanup");
return ret;
}
static DWORD ver_for_ext(GL_SupportedExt ext)
{
unsigned int i;
for (i = 0; i < (sizeof(EXTENSION_MAP) / sizeof(*EXTENSION_MAP)); ++i) {
if(EXTENSION_MAP[i].extension == ext) {
return EXTENSION_MAP[i].version;
}
}
return 0;
}
static BOOL match_ati_r300_to_500(const struct wined3d_gl_info *gl_info, const char *gl_renderer,
enum wined3d_gl_vendor gl_vendor, enum wined3d_pci_vendor card_vendor, enum wined3d_pci_device device)
{
if (card_vendor != HW_VENDOR_ATI) return FALSE;
if (device == CARD_ATI_RADEON_9500) return TRUE;
if (device == CARD_ATI_RADEON_X700) return TRUE;
if (device == CARD_ATI_RADEON_X1600) return TRUE;
return FALSE;
}
static BOOL match_geforce5(const struct wined3d_gl_info *gl_info, const char *gl_renderer,
enum wined3d_gl_vendor gl_vendor, enum wined3d_pci_vendor card_vendor, enum wined3d_pci_device device)
{
if (card_vendor == HW_VENDOR_NVIDIA)
{
if (device == CARD_NVIDIA_GEFORCEFX_5800 || device == CARD_NVIDIA_GEFORCEFX_5600)
{
return TRUE;
}
}
return FALSE;
}
static BOOL match_apple(const struct wined3d_gl_info *gl_info, const char *gl_renderer,
enum wined3d_gl_vendor gl_vendor, enum wined3d_pci_vendor card_vendor, enum wined3d_pci_device device)
{
/* MacOS has various specialities in the extensions it advertises. Some have to be loaded from
* the opengl 1.2+ core, while other extensions are advertised, but software emulated. So try to
* detect the Apple OpenGL implementation to apply some extension fixups afterwards.
*
* Detecting this isn't really easy. The vendor string doesn't mention Apple. Compile-time checks
* aren't sufficient either because a Linux binary may display on a macos X server via remote X11.
* So try to detect the GL implementation by looking at certain Apple extensions. Some extensions
* like client storage might be supported on other implementations too, but GL_APPLE_flush_render
* is specific to the Mac OS X window management, and GL_APPLE_ycbcr_422 is QuickTime specific. So
* the chance that other implementations support them is rather small since Win32 QuickTime uses
* DirectDraw, not OpenGL.
*
* This test has been moved into wined3d_guess_gl_vendor()
*/
if (gl_vendor == GL_VENDOR_APPLE)
{
return TRUE;
}
return FALSE;
}
/* Context activation is done by the caller. */
static void test_pbo_functionality(struct wined3d_gl_info *gl_info)
{
/* Some OpenGL implementations, namely Apple's Geforce 8 driver, advertises PBOs,
* but glTexSubImage from a PBO fails miserably, with the first line repeated over
* all the texture. This function detects this bug by its symptom and disables PBOs
* if the test fails.
*
* The test uploads a 4x4 texture via the PBO in the "native" format GL_BGRA,
* GL_UNSIGNED_INT_8_8_8_8_REV. This format triggers the bug, and it is what we use
* for D3DFMT_A8R8G8B8. Then the texture is read back without any PBO and the data
* read back is compared to the original. If they are equal PBOs are assumed to work,
* otherwise the PBO extension is disabled. */
GLuint texture, pbo;
static const unsigned int pattern[] =
{
0x00000000, 0x000000ff, 0x0000ff00, 0x40ff0000,
0x80ffffff, 0x40ffff00, 0x00ff00ff, 0x0000ffff,
0x00ffff00, 0x00ff00ff, 0x0000ffff, 0x000000ff,
0x80ff00ff, 0x0000ffff, 0x00ff00ff, 0x40ff00ff
};
unsigned int check[sizeof(pattern) / sizeof(pattern[0])];
/* No PBO -> No point in testing them. */
if (!gl_info->supported[ARB_PIXEL_BUFFER_OBJECT]) return;
ENTER_GL();
while (glGetError());
glGenTextures(1, &texture);
glBindTexture(GL_TEXTURE_2D, texture);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAX_LEVEL, 0);
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA8, 4, 4, 0, GL_BGRA, GL_UNSIGNED_INT_8_8_8_8_REV, 0);
checkGLcall("Specifying the PBO test texture");
GL_EXTCALL(glGenBuffersARB(1, &pbo));
GL_EXTCALL(glBindBufferARB(GL_PIXEL_UNPACK_BUFFER_ARB, pbo));
GL_EXTCALL(glBufferDataARB(GL_PIXEL_UNPACK_BUFFER_ARB, sizeof(pattern), pattern, GL_STREAM_DRAW_ARB));
checkGLcall("Specifying the PBO test pbo");
glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 4, 4, GL_BGRA, GL_UNSIGNED_INT_8_8_8_8_REV, NULL);
checkGLcall("Loading the PBO test texture");
GL_EXTCALL(glBindBufferARB(GL_PIXEL_UNPACK_BUFFER_ARB, 0));
#ifdef VBOX_WITH_VMSVGA
glFinish();
#else
wglFinish(); /* just to be sure */
#endif
memset(check, 0, sizeof(check));
glGetTexImage(GL_TEXTURE_2D, 0, GL_BGRA, GL_UNSIGNED_INT_8_8_8_8_REV, check);
checkGLcall("Reading back the PBO test texture");
glDeleteTextures(1, &texture);
GL_EXTCALL(glDeleteBuffersARB(1, &pbo));
checkGLcall("PBO test cleanup");
LEAVE_GL();
if (memcmp(check, pattern, sizeof(check)))
{
WARN_(d3d_caps)("PBO test failed, read back data doesn't match original.\n");
WARN_(d3d_caps)("Disabling PBOs. This may result in slower performance.\n");
gl_info->supported[ARB_PIXEL_BUFFER_OBJECT] = FALSE;
}
else
{
TRACE_(d3d_caps)("PBO test successful.\n");
}
}
static BOOL match_apple_intel(const struct wined3d_gl_info *gl_info, const char *gl_renderer,
enum wined3d_gl_vendor gl_vendor, enum wined3d_pci_vendor card_vendor, enum wined3d_pci_device device)
{
return (card_vendor == HW_VENDOR_INTEL) && (gl_vendor == GL_VENDOR_APPLE);
}
static BOOL match_apple_nonr500ati(const struct wined3d_gl_info *gl_info, const char *gl_renderer,
enum wined3d_gl_vendor gl_vendor, enum wined3d_pci_vendor card_vendor, enum wined3d_pci_device device)
{
if (gl_vendor != GL_VENDOR_APPLE) return FALSE;
if (card_vendor != HW_VENDOR_ATI) return FALSE;
if (device == CARD_ATI_RADEON_X1600) return FALSE;
return TRUE;
}
static BOOL match_fglrx(const struct wined3d_gl_info *gl_info, const char *gl_renderer,
enum wined3d_gl_vendor gl_vendor, enum wined3d_pci_vendor card_vendor, enum wined3d_pci_device device)
{
return gl_vendor == GL_VENDOR_FGLRX;
}
static BOOL match_dx10_capable(const struct wined3d_gl_info *gl_info, const char *gl_renderer,
enum wined3d_gl_vendor gl_vendor, enum wined3d_pci_vendor card_vendor, enum wined3d_pci_device device)
{
/* DX9 cards support 40 single float varyings in hardware, most drivers report 32. ATI misreports
* 44 varyings. So assume that if we have more than 44 varyings we have a dx10 card.
* This detection is for the gl_ClipPos varying quirk. If a d3d9 card really supports more than 44
* varyings and we subtract one in dx9 shaders its not going to hurt us because the dx9 limit is
* hardcoded
*
* dx10 cards usually have 64 varyings */
return gl_info->limits.glsl_varyings > 44;
}
/* A GL context is provided by the caller */
static BOOL match_allows_spec_alpha(const struct wined3d_gl_info *gl_info, const char *gl_renderer,
enum wined3d_gl_vendor gl_vendor, enum wined3d_pci_vendor card_vendor, enum wined3d_pci_device device)
{
GLenum error;
DWORD data[16];
if (!gl_info->supported[EXT_SECONDARY_COLOR]) return FALSE;
ENTER_GL();
while(glGetError());
GL_EXTCALL(glSecondaryColorPointerEXT)(4, GL_UNSIGNED_BYTE, 4, data);
error = glGetError();
LEAVE_GL();
if(error == GL_NO_ERROR)
{
TRACE("GL Implementation accepts 4 component specular color pointers\n");
return TRUE;
}
else
{
TRACE("GL implementation does not accept 4 component specular colors, error %s\n",
debug_glerror(error));
return FALSE;
}
}
static BOOL match_apple_nvts(const struct wined3d_gl_info *gl_info, const char *gl_renderer,
enum wined3d_gl_vendor gl_vendor, enum wined3d_pci_vendor card_vendor, enum wined3d_pci_device device)
{
if (!match_apple(gl_info, gl_renderer, gl_vendor, card_vendor, device)) return FALSE;
return gl_info->supported[NV_TEXTURE_SHADER];
}
/* A GL context is provided by the caller */
static BOOL match_broken_nv_clip(const struct wined3d_gl_info *gl_info, const char *gl_renderer,
enum wined3d_gl_vendor gl_vendor, enum wined3d_pci_vendor card_vendor, enum wined3d_pci_device device)
{
GLuint prog;
BOOL ret = FALSE;
GLint pos;
const char *testcode =
"!!ARBvp1.0\n"
"OPTION NV_vertex_program2;\n"
"MOV result.clip[0], 0.0;\n"
"MOV result.position, 0.0;\n"
"END\n";
if (!gl_info->supported[NV_VERTEX_PROGRAM2_OPTION]) return FALSE;
ENTER_GL();
while(glGetError());
GL_EXTCALL(glGenProgramsARB(1, &prog));
if(!prog)
{
ERR("Failed to create the NVvp clip test program\n");
LEAVE_GL();
return FALSE;
}
GL_EXTCALL(glBindProgramARB(GL_VERTEX_PROGRAM_ARB, prog));
GL_EXTCALL(glProgramStringARB(GL_VERTEX_PROGRAM_ARB, GL_PROGRAM_FORMAT_ASCII_ARB,
(GLsizei)strlen(testcode), testcode));
glGetIntegerv(GL_PROGRAM_ERROR_POSITION_ARB, &pos);
if(pos != -1)
{
WARN("GL_NV_vertex_program2_option result.clip[] test failed\n");
TRACE("error: %s\n", debugstr_a((const char *)glGetString(GL_PROGRAM_ERROR_STRING_ARB)));
ret = TRUE;
while(glGetError());
}
else TRACE("GL_NV_vertex_program2_option result.clip[] test passed\n");
GL_EXTCALL(glBindProgramARB(GL_VERTEX_PROGRAM_ARB, 0));
GL_EXTCALL(glDeleteProgramsARB(1, &prog));
checkGLcall("GL_NV_vertex_program2_option result.clip[] test cleanup");
LEAVE_GL();
return ret;
}
/* Context activation is done by the caller. */
static BOOL match_fbo_tex_update(const struct wined3d_gl_info *gl_info, const char *gl_renderer,
enum wined3d_gl_vendor gl_vendor, enum wined3d_pci_vendor card_vendor, enum wined3d_pci_device device)
{
char data[4 * 4 * 4];
GLuint tex, fbo;
GLenum status;
#ifndef VBOX_WITH_VMSVGA
if (wined3d_settings.offscreen_rendering_mode != ORM_FBO) return FALSE;
#endif
memset(data, 0xcc, sizeof(data));
ENTER_GL();
glGenTextures(1, &tex);
glBindTexture(GL_TEXTURE_2D, tex);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA8, 4, 4, 0, GL_BGRA, GL_UNSIGNED_INT_8_8_8_8_REV, NULL);
checkGLcall("glTexImage2D");
gl_info->fbo_ops.glGenFramebuffers(1, &fbo);
gl_info->fbo_ops.glBindFramebuffer(GL_FRAMEBUFFER, fbo);
gl_info->fbo_ops.glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, tex, 0);
checkGLcall("glFramebufferTexture2D");
status = gl_info->fbo_ops.glCheckFramebufferStatus(GL_FRAMEBUFFER);
if (status != GL_FRAMEBUFFER_COMPLETE) ERR("FBO status %#x\n", status);
checkGLcall("glCheckFramebufferStatus");
memset(data, 0x11, sizeof(data));
glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 4, 4, GL_BGRA, GL_UNSIGNED_INT_8_8_8_8_REV, data);
checkGLcall("glTexSubImage2D");
glClearColor(0.996, 0.729, 0.745, 0.792);
glClear(GL_COLOR_BUFFER_BIT);
checkGLcall("glClear");
glGetTexImage(GL_TEXTURE_2D, 0, GL_BGRA, GL_UNSIGNED_INT_8_8_8_8_REV, data);
checkGLcall("glGetTexImage");
gl_info->fbo_ops.glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, 0, 0);
gl_info->fbo_ops.glBindFramebuffer(GL_FRAMEBUFFER, 0);
glBindTexture(GL_TEXTURE_2D, 0);
checkGLcall("glBindTexture");
gl_info->fbo_ops.glDeleteFramebuffers(1, &fbo);
glDeleteTextures(1, &tex);
checkGLcall("glDeleteTextures");
LEAVE_GL();
return *(DWORD *)data == 0x11111111;
}
static void quirk_arb_constants(struct wined3d_gl_info *gl_info)
{
TRACE_(d3d_caps)("Using ARB vs constant limit(=%u) for GLSL.\n", gl_info->limits.arb_vs_native_constants);
gl_info->limits.glsl_vs_float_constants = gl_info->limits.arb_vs_native_constants;
TRACE_(d3d_caps)("Using ARB ps constant limit(=%u) for GLSL.\n", gl_info->limits.arb_ps_native_constants);
gl_info->limits.glsl_ps_float_constants = gl_info->limits.arb_ps_native_constants;
}
static void quirk_apple_glsl_constants(struct wined3d_gl_info *gl_info)
{
quirk_arb_constants(gl_info);
/* MacOS needs uniforms for relative addressing offsets. This can accumulate to quite a few uniforms.
* Beyond that the general uniform isn't optimal, so reserve a number of uniforms. 12 vec4's should
* allow 48 different offsets or other helper immediate values. */
TRACE_(d3d_caps)("Reserving 12 GLSL constants for compiler private use.\n");
gl_info->reserved_glsl_constants = max(gl_info->reserved_glsl_constants, 12);
}
/* fglrx crashes with a very bad kernel panic if GL_POINT_SPRITE_ARB is set to GL_COORD_REPLACE_ARB
* on more than one texture unit. This means that the d3d9 visual point size test will cause a
* kernel panic on any machine running fglrx 9.3(latest that supports r300 to r500 cards). This
* quirk only enables point sprites on the first texture unit. This keeps point sprites working in
* most games, but avoids the crash
*
* A more sophisticated way would be to find all units that need texture coordinates and enable
* point sprites for one if only one is found, and software emulate point sprites in drawStridedSlow
* if more than one unit needs texture coordinates(This requires software ffp and vertex shaders though)
*
* Note that disabling the extension entirely does not gain predictability because there is no point
* sprite capability flag in d3d, so the potential rendering bugs are the same if we disable the extension. */
static void quirk_one_point_sprite(struct wined3d_gl_info *gl_info)
{
if (gl_info->supported[ARB_POINT_SPRITE])
{
TRACE("Limiting point sprites to one texture unit.\n");
gl_info->limits.point_sprite_units = 1;
}
}
static void quirk_ati_dx9(struct wined3d_gl_info *gl_info)
{
quirk_arb_constants(gl_info);
/* MacOS advertises GL_ARB_texture_non_power_of_two on ATI r500 and earlier cards, although
* these cards only support GL_ARB_texture_rectangle(D3DPTEXTURECAPS_NONPOW2CONDITIONAL).
* If real NP2 textures are used, the driver falls back to software. We could just remove the
* extension and use GL_ARB_texture_rectangle instead, but texture_rectangle is inconventient
* due to the non-normalized texture coordinates. Thus set an internal extension flag,
* GL_WINE_normalized_texrect, which signals the code that it can use non power of two textures
* as per GL_ARB_texture_non_power_of_two, but has to stick to the texture_rectangle limits.
*
* fglrx doesn't advertise GL_ARB_texture_non_power_of_two, but it advertises opengl 2.0 which
* has this extension promoted to core. The extension loading code sets this extension supported
* due to that, so this code works on fglrx as well. */
if(gl_info->supported[ARB_TEXTURE_NON_POWER_OF_TWO])
{
TRACE("GL_ARB_texture_non_power_of_two advertised on R500 or earlier card, removing.\n");
gl_info->supported[ARB_TEXTURE_NON_POWER_OF_TWO] = FALSE;
gl_info->supported[WINE_NORMALIZED_TEXRECT] = TRUE;
}
/* fglrx has the same structural issues as the one described in quirk_apple_glsl_constants, although
* it is generally more efficient. Reserve just 8 constants. */
TRACE_(d3d_caps)("Reserving 8 GLSL constants for compiler private use.\n");
gl_info->reserved_glsl_constants = max(gl_info->reserved_glsl_constants, 8);
}
static void quirk_no_np2(struct wined3d_gl_info *gl_info)
{
/* The nVidia GeForceFX series reports OpenGL 2.0 capabilities with the latest drivers versions, but
* doesn't explicitly advertise the ARB_tex_npot extension in the GL extension string.
* This usually means that ARB_tex_npot is supported in hardware as long as the application is staying
* within the limits enforced by the ARB_texture_rectangle extension. This however is not true for the
* FX series, which instantly falls back to a slower software path as soon as ARB_tex_npot is used.
* We therefore completely remove ARB_tex_npot from the list of supported extensions.
*
* Note that wine_normalized_texrect can't be used in this case because internally it uses ARB_tex_npot,
* triggering the software fallback. There is not much we can do here apart from disabling the
* software-emulated extension and reenable ARB_tex_rect (which was previously disabled
* in IWineD3DImpl_FillGLCaps).
* This fixup removes performance problems on both the FX 5900 and FX 5700 (e.g. for framebuffer
* post-processing effects in the game "Max Payne 2").
* The behaviour can be verified through a simple test app attached in bugreport #14724. */
TRACE("GL_ARB_texture_non_power_of_two advertised through OpenGL 2.0 on NV FX card, removing.\n");
gl_info->supported[ARB_TEXTURE_NON_POWER_OF_TWO] = FALSE;
gl_info->supported[ARB_TEXTURE_RECTANGLE] = TRUE;
}
static void quirk_texcoord_w(struct wined3d_gl_info *gl_info)
{
/* The Intel GPUs on MacOS set the .w register of texcoords to 0.0 by default, which causes problems
* with fixed function fragment processing. Ideally this flag should be detected with a test shader
* and OpenGL feedback mode, but some GL implementations (MacOS ATI at least, probably all MacOS ones)
* do not like vertex shaders in feedback mode and return an error, even though it should be valid
* according to the spec.
*
* We don't want to enable this on all cards, as it adds an extra instruction per texcoord used. This
* makes the shader slower and eats instruction slots which should be available to the d3d app.
*
* ATI Radeon HD 2xxx cards on MacOS have the issue. Instead of checking for the buggy cards, blacklist
* all radeon cards on Macs and whitelist the good ones. That way we're prepared for the future. If
* this workaround is activated on cards that do not need it, it won't break things, just affect
* performance negatively. */
TRACE("Enabling vertex texture coord fixes in vertex shaders.\n");
gl_info->quirks |= WINED3D_QUIRK_SET_TEXCOORD_W;
}
static void quirk_clip_varying(struct wined3d_gl_info *gl_info)
{
gl_info->quirks |= WINED3D_QUIRK_GLSL_CLIP_VARYING;
}
static void quirk_allows_specular_alpha(struct wined3d_gl_info *gl_info)
{
gl_info->quirks |= WINED3D_QUIRK_ALLOWS_SPECULAR_ALPHA;
}
static void quirk_apple_nvts(struct wined3d_gl_info *gl_info)
{
gl_info->supported[NV_TEXTURE_SHADER] = FALSE;
gl_info->supported[NV_TEXTURE_SHADER2] = FALSE;
}
static void quirk_disable_nvvp_clip(struct wined3d_gl_info *gl_info)
{
gl_info->quirks |= WINED3D_QUIRK_NV_CLIP_BROKEN;
}
static void quirk_fbo_tex_update(struct wined3d_gl_info *gl_info)
{
gl_info->quirks |= WINED3D_QUIRK_FBO_TEX_UPDATE;
}
static BOOL match_ati_hd4800(const struct wined3d_gl_info *gl_info, const char *gl_renderer,
enum wined3d_gl_vendor gl_vendor, enum wined3d_pci_vendor card_vendor, enum wined3d_pci_device device)
{
if (card_vendor != HW_VENDOR_ATI) return FALSE;
if (device == CARD_ATI_RADEON_HD4800) return TRUE;
return FALSE;
}
static void quirk_fullsize_blit(struct wined3d_gl_info *gl_info)
{
gl_info->quirks |= WINED3D_QUIRK_FULLSIZE_BLIT;
}
#ifdef VBOX_WITH_WDDM
static BOOL match_mesa_nvidia(const struct wined3d_gl_info *gl_info, const char *gl_renderer,
enum wined3d_gl_vendor gl_vendor, enum wined3d_pci_vendor card_vendor, enum wined3d_pci_device device)
{
if (card_vendor != HW_VENDOR_NVIDIA) return FALSE;
if (gl_vendor != GL_VENDOR_MESA) return FALSE;
return TRUE;
}
static void quirk_no_shader_3(struct wined3d_gl_info *gl_info)
{
int vs_selected_mode, ps_selected_mode;
select_shader_mode(gl_info, &ps_selected_mode, &vs_selected_mode);
if (vs_selected_mode != SHADER_GLSL && ps_selected_mode != SHADER_GLSL)
return;
gl_info->limits.arb_ps_instructions = 512;
}
#endif
static BOOL match_intel(const struct wined3d_gl_info *gl_info, const char *gl_renderer,
enum wined3d_gl_vendor gl_vendor, enum wined3d_pci_vendor card_vendor, enum wined3d_pci_device device)
{
if (card_vendor == HW_VENDOR_INTEL) return TRUE;
if (gl_vendor == GL_VENDOR_INTEL) return TRUE;
return FALSE;
}
static void quirk_force_blit(struct wined3d_gl_info *gl_info)
{
gl_info->quirks |= WINED3D_QUIRK_FORCE_BLIT;
}
struct driver_quirk
{
BOOL (*match)(const struct wined3d_gl_info *gl_info, const char *gl_renderer,
enum wined3d_gl_vendor gl_vendor, enum wined3d_pci_vendor card_vendor, enum wined3d_pci_device device);
void (*apply)(struct wined3d_gl_info *gl_info);
const char *description;
};
static const struct driver_quirk quirk_table[] =
{
{
match_ati_r300_to_500,
quirk_ati_dx9,
"ATI GLSL constant and normalized texrect quirk"
},
/* MacOS advertises more GLSL vertex shader uniforms than supported by the hardware, and if more are
* used it falls back to software. While the compiler can detect if the shader uses all declared
* uniforms, the optimization fails if the shader uses relative addressing. So any GLSL shader
* using relative addressing falls back to software.
*
* ARB vp gives the correct amount of uniforms, so use it instead of GLSL. */
{
match_apple,
quirk_apple_glsl_constants,
"Apple GLSL uniform override"
},
{
match_geforce5,
quirk_no_np2,
"Geforce 5 NP2 disable"
},
{
match_apple_intel,
quirk_texcoord_w,
"Init texcoord .w for Apple Intel GPU driver"
},
{
match_apple_nonr500ati,
quirk_texcoord_w,
"Init texcoord .w for Apple ATI >= r600 GPU driver"
},
{
match_fglrx,
quirk_one_point_sprite,
"Fglrx point sprite crash workaround"
},
{
match_dx10_capable,
quirk_clip_varying,
"Reserved varying for gl_ClipPos"
},
{
/* GL_EXT_secondary_color does not allow 4 component secondary colors, but most
* GL implementations accept it. The Mac GL is the only implementation known to
* reject it.
*
* If we can pass 4 component specular colors, do it, because (a) we don't have
* to screw around with the data, and (b) the D3D fixed function vertex pipeline
* passes specular alpha to the pixel shader if any is used. Otherwise the
* specular alpha is used to pass the fog coordinate, which we pass to opengl
* via GL_EXT_fog_coord.
*/
match_allows_spec_alpha,
quirk_allows_specular_alpha,
"Allow specular alpha quirk"
},
{
/* The pixel formats provided by GL_NV_texture_shader are broken on OSX
* (rdar://5682521).
*/
match_apple_nvts,
quirk_apple_nvts,
"Apple NV_texture_shader disable"
},
#ifndef VBOX_WITH_VMSVGA
{
match_broken_nv_clip,
quirk_disable_nvvp_clip,
"Apple NV_vertex_program clip bug quirk"
},
#endif
{
match_fbo_tex_update,
quirk_fbo_tex_update,
"FBO rebind for attachment updates"
},
{
match_ati_hd4800,
quirk_fullsize_blit,
"Fullsize blit"
},
#ifdef VBOX_WITH_WDDM
{
match_mesa_nvidia,
quirk_no_shader_3,
"disable shader 3 support"
},
#endif
{
match_intel,
quirk_force_blit,
"force framebuffer blit when possible"
}
};
/* Context activation is done by the caller. */
static void fixup_extensions(struct wined3d_gl_info *gl_info, const char *gl_renderer,
enum wined3d_gl_vendor gl_vendor, enum wined3d_pci_vendor card_vendor, enum wined3d_pci_device device)
{
unsigned int i;
for (i = 0; i < (sizeof(quirk_table) / sizeof(*quirk_table)); ++i)
{
if (!quirk_table[i].match(gl_info, gl_renderer, gl_vendor, card_vendor, device)) continue;
TRACE_(d3d_caps)("Applying driver quirk \"%s\".\n", quirk_table[i].description);
quirk_table[i].apply(gl_info);
}
/* Find out if PBOs work as they are supposed to. */
test_pbo_functionality(gl_info);
}
/* Certain applications (Steam) complain if we report an outdated driver version. In general,
* reporting a driver version is moot because we are not the Windows driver, and we have different
* bugs, features, etc.
*
* The driver version has the form "x.y.z.w".
*
* "x" is the Windows version the driver is meant for:
* 4 -> 95/98/NT4
* 5 -> 2000
* 6 -> 2000/XP
* 7 -> Vista
* 8 -> Win 7
*
* "y" is the Direct3D level the driver supports:
* 11 -> d3d6
* 12 -> d3d7
* 13 -> d3d8
* 14 -> d3d9
* 15 -> d3d10
*
* "z" is unknown, possibly vendor specific.
*
* "w" is the vendor specific driver version.
*/
struct driver_version_information
{
WORD vendor; /* reported PCI card vendor ID */
WORD card; /* reported PCI card device ID */
const char *description; /* Description of the card e.g. NVIDIA RIVA TNT */
WORD d3d_level; /* driver hiword to report */
WORD lopart_hi, lopart_lo; /* driver loword to report */
};
#if 0 /* VBox: unused */
static const struct driver_version_information driver_version_table[] =
{
/* Nvidia drivers. Geforce6 and newer cards are supported by the current driver (180.x)
* GeforceFX support is up to 173.x, - driver uses numbering x.y.11.7341 for 173.41 where x is the windows revision (6=2000/xp, 7=vista), y is unknown
* Geforce2MX/3/4 up to 96.x - driver uses numbering 9.6.8.9 for 96.89
* TNT/Geforce1/2 up to 71.x - driver uses numbering 7.1.8.6 for 71.86
*
* All version numbers used below are from the Linux nvidia drivers. */
{HW_VENDOR_NVIDIA, CARD_NVIDIA_RIVA_TNT, "NVIDIA RIVA TNT", 1, 8, 6 },
{HW_VENDOR_NVIDIA, CARD_NVIDIA_RIVA_TNT2, "NVIDIA RIVA TNT2/TNT2 Pro", 1, 8, 6 },
{HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE, "NVIDIA GeForce 256", 1, 8, 6 },
{HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE2_MX, "NVIDIA GeForce2 MX/MX 400", 6, 4, 3 },
{HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE2, "NVIDIA GeForce2 GTS/GeForce2 Pro", 1, 8, 6 },
{HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE3, "NVIDIA GeForce3", 6, 10, 9371 },
{HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE4_MX, "NVIDIA GeForce4 MX 460", 6, 10, 9371 },
{HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE4_TI4200, "NVIDIA GeForce4 Ti 4200", 6, 10, 9371 },
{HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCEFX_5200, "NVIDIA GeForce FX 5200", 15, 11, 7516 },
{HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCEFX_5600, "NVIDIA GeForce FX 5600", 15, 11, 7516 },
{HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCEFX_5800, "NVIDIA GeForce FX 5800", 15, 11, 7516 },
{HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_6200, "NVIDIA GeForce 6200", 15, 11, 8618 },
{HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_6600GT, "NVIDIA GeForce 6600 GT", 15, 11, 8618 },
{HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_6800, "NVIDIA GeForce 6800", 15, 11, 8618 },
{HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_7300, "NVIDIA GeForce Go 7300", 15, 11, 8585 },
{HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_7400, "NVIDIA GeForce Go 7400", 15, 11, 8585 },
{HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_7600, "NVIDIA GeForce 7600 GT", 15, 11, 8618 },
{HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_7800GT, "NVIDIA GeForce 7800 GT", 15, 11, 8618 },
{HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_8300GS, "NVIDIA GeForce 8300 GS", 15, 11, 8618 },
{HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_8600GT, "NVIDIA GeForce 8600 GT", 15, 11, 8618 },
{HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_8600MGT, "NVIDIA GeForce 8600M GT", 15, 11, 8585 },
{HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_8800GTS, "NVIDIA GeForce 8800 GTS", 15, 11, 8618 },
{HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_9200, "NVIDIA GeForce 9200", 15, 11, 8618 },
{HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_9400GT, "NVIDIA GeForce 9400 GT", 15, 11, 8618 },
{HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_9500GT, "NVIDIA GeForce 9500 GT", 15, 11, 8618 },
{HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_9600GT, "NVIDIA GeForce 9600 GT", 15, 11, 8618 },
{HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_9800GT, "NVIDIA GeForce 9800 GT", 15, 11, 8618 },
{HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_GTX260, "NVIDIA GeForce GTX 260", 15, 11, 8618 },
{HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_GTX275, "NVIDIA GeForce GTX 275", 15, 11, 8618 },
{HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_GTX280, "NVIDIA GeForce GTX 280", 15, 11, 8618 },
{HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_GT240, "NVIDIA GeForce GT 240", 15, 11, 8618 },
/* ATI cards. The driver versions are somewhat similar, but not quite the same. Let's hardcode. */
{HW_VENDOR_ATI, CARD_ATI_RADEON_9500, "ATI Radeon 9500", 14, 10, 6764 },
{HW_VENDOR_ATI, CARD_ATI_RADEON_X700, "ATI Radeon X700 SE", 14, 10, 6764 },
{HW_VENDOR_ATI, CARD_ATI_RADEON_X1600, "ATI Radeon X1600 Series", 14, 10, 6764 },
{HW_VENDOR_ATI, CARD_ATI_RADEON_HD2350, "ATI Mobility Radeon HD 2350", 14, 10, 6764 },
{HW_VENDOR_ATI, CARD_ATI_RADEON_HD2600, "ATI Mobility Radeon HD 2600", 14, 10, 6764 },
{HW_VENDOR_ATI, CARD_ATI_RADEON_HD2900, "ATI Radeon HD 2900 XT", 14, 10, 6764 },
{HW_VENDOR_ATI, CARD_ATI_RADEON_HD4350, "ATI Radeon HD 4350", 14, 10, 6764 },
{HW_VENDOR_ATI, CARD_ATI_RADEON_HD4600, "ATI Radeon HD 4600 Series", 14, 10, 6764 },
{HW_VENDOR_ATI, CARD_ATI_RADEON_HD4700, "ATI Radeon HD 4700 Series", 14, 10, 6764 },
{HW_VENDOR_ATI, CARD_ATI_RADEON_HD4800, "ATI Radeon HD 4800 Series", 14, 10, 6764 },
{HW_VENDOR_ATI, CARD_ATI_RADEON_HD5700, "ATI Radeon HD 5700 Series", 14, 10, 8681 },
{HW_VENDOR_ATI, CARD_ATI_RADEON_HD5800, "ATI Radeon HD 5800 Series", 14, 10, 8681 },
/* TODO: Add information about legacy ATI hardware, Intel and other cards. */
};
#endif /* VBox: unused */
static DWORD wined3d_parse_gl_version(const char *gl_version)
{
const char *ptr = gl_version;
int major, minor;
major = atoi(ptr);
if (major <= 0) ERR_(d3d_caps)("Invalid opengl major version: %d.\n", major);
while (isdigit(*ptr)) ++ptr;
if (*ptr++ != '.') ERR_(d3d_caps)("Invalid opengl version string: %s.\n", debugstr_a(gl_version));
minor = atoi(ptr);
TRACE_(d3d_caps)("Found OpenGL version: %d.%d.\n", major, minor);
return MAKEDWORD_VERSION(major, minor);
}
static enum wined3d_gl_vendor wined3d_guess_gl_vendor(struct wined3d_gl_info *gl_info, const char *gl_vendor_string, const char *gl_renderer)
{
/* MacOS has various specialities in the extensions it advertises. Some have to be loaded from
* the opengl 1.2+ core, while other extensions are advertised, but software emulated. So try to
* detect the Apple OpenGL implementation to apply some extension fixups afterwards.
*
* Detecting this isn't really easy. The vendor string doesn't mention Apple. Compile-time checks
* aren't sufficient either because a Linux binary may display on a macos X server via remote X11.
* So try to detect the GL implementation by looking at certain Apple extensions. Some extensions
* like client storage might be supported on other implementations too, but GL_APPLE_flush_render
* is specific to the Mac OS X window management, and GL_APPLE_ycbcr_422 is QuickTime specific. So
* the chance that other implementations support them is rather small since Win32 QuickTime uses
* DirectDraw, not OpenGL. */
if (gl_info->supported[APPLE_FENCE]
&& gl_info->supported[APPLE_CLIENT_STORAGE]
&& gl_info->supported[APPLE_FLUSH_RENDER]
&& gl_info->supported[APPLE_YCBCR_422])
return GL_VENDOR_APPLE;
if (strstr(gl_vendor_string, "NVIDIA"))
return GL_VENDOR_NVIDIA;
if (strstr(gl_vendor_string, "ATI"))
return GL_VENDOR_FGLRX;
if (strstr(gl_vendor_string, "Intel(R)")
|| strstr(gl_renderer, "Intel(R)")
|| strstr(gl_vendor_string, "Intel Inc."))
{
if (strstr(gl_renderer, "Mesa"))
return GL_VENDOR_MESA;
return GL_VENDOR_INTEL;
}
if (strstr(gl_vendor_string, "Mesa")
|| strstr(gl_vendor_string, "Advanced Micro Devices, Inc.")
|| strstr(gl_vendor_string, "DRI R300 Project")
|| strstr(gl_vendor_string, "X.Org R300 Project")
|| strstr(gl_vendor_string, "Tungsten Graphics, Inc")
|| strstr(gl_vendor_string, "VMware, Inc.")
|| strstr(gl_renderer, "Mesa")
|| strstr(gl_renderer, "Gallium"))
return GL_VENDOR_MESA;
FIXME_(d3d_caps)("Received unrecognized GL_VENDOR %s. Returning GL_VENDOR_UNKNOWN.\n",
debugstr_a(gl_vendor_string));
return GL_VENDOR_UNKNOWN;
}
static enum wined3d_pci_vendor wined3d_guess_card_vendor(const char *gl_vendor_string, const char *gl_renderer)
{
if (strstr(gl_vendor_string, "NVIDIA"))
return HW_VENDOR_NVIDIA;
if (strstr(gl_vendor_string, "ATI")
|| strstr(gl_vendor_string, "Advanced Micro Devices, Inc.")
|| strstr(gl_vendor_string, "X.Org R300 Project")
|| strstr(gl_vendor_string, "DRI R300 Project"))
return HW_VENDOR_ATI;
if (strstr(gl_vendor_string, "Intel(R)")
|| strstr(gl_renderer, "Intel(R)")
|| strstr(gl_vendor_string, "Intel Inc."))
return HW_VENDOR_INTEL;
if (strstr(gl_vendor_string, "Mesa")
|| strstr(gl_vendor_string, "Tungsten Graphics, Inc")
|| strstr(gl_vendor_string, "VMware, Inc."))
return HW_VENDOR_SOFTWARE;
FIXME_(d3d_caps)("Received unrecognized GL_VENDOR %s. Returning HW_VENDOR_NVIDIA.\n", debugstr_a(gl_vendor_string));
return HW_VENDOR_NVIDIA;
}
static enum wined3d_pci_device select_card_nvidia_binary(const struct wined3d_gl_info *gl_info,
const char *gl_renderer, unsigned int *vidmem)
{
#ifndef VBOX_WITH_WDDM
if (WINE_D3D10_CAPABLE(gl_info))
#endif
{
/* Geforce 200 - highend */
if (strstr(gl_renderer, "GTX 280")
|| strstr(gl_renderer, "GTX 285")
|| strstr(gl_renderer, "GTX 295"))
{
*vidmem = 1024;
return CARD_NVIDIA_GEFORCE_GTX280;
}
/* Geforce 200 - midend high */
if (strstr(gl_renderer, "GTX 275"))
{
*vidmem = 896;
return CARD_NVIDIA_GEFORCE_GTX275;
}
/* Geforce 200 - midend */
if (strstr(gl_renderer, "GTX 260"))
{
*vidmem = 1024;
return CARD_NVIDIA_GEFORCE_GTX260;
}
/* Geforce 200 - midend */
if (strstr(gl_renderer, "GT 240"))
{
*vidmem = 512;
return CARD_NVIDIA_GEFORCE_GT240;
}
/* Geforce9 - highend / Geforce 200 - midend (GTS 150/250 are based on the same core) */
if (strstr(gl_renderer, "9800")
|| strstr(gl_renderer, "GTS 150")
|| strstr(gl_renderer, "GTS 250"))
{
*vidmem = 512;
return CARD_NVIDIA_GEFORCE_9800GT;
}
/* Geforce9 - midend */
if (strstr(gl_renderer, "9600"))
{
*vidmem = 384; /* The 9600GSO has 384MB, the 9600GT has 512-1024MB */
return CARD_NVIDIA_GEFORCE_9600GT;
}
/* Geforce9 - midend low / Geforce 200 - low */
if (strstr(gl_renderer, "9500")
|| strstr(gl_renderer, "GT 120")
|| strstr(gl_renderer, "GT 130"))
{
*vidmem = 256; /* The 9500GT has 256-1024MB */
return CARD_NVIDIA_GEFORCE_9500GT;
}
/* Geforce9 - lowend */
if (strstr(gl_renderer, "9400"))
{
*vidmem = 256; /* The 9400GT has 256-1024MB */
return CARD_NVIDIA_GEFORCE_9400GT;
}
/* Geforce9 - lowend low */
if (strstr(gl_renderer, "9100")
|| strstr(gl_renderer, "9200")
|| strstr(gl_renderer, "9300")
|| strstr(gl_renderer, "G 100"))
{
*vidmem = 256; /* The 9100-9300 cards have 256MB */
return CARD_NVIDIA_GEFORCE_9200;
}
/* Geforce8 - highend */
if (strstr(gl_renderer, "8800"))
{
*vidmem = 320; /* The 8800GTS uses 320MB, a 8800GTX can have 768MB */
return CARD_NVIDIA_GEFORCE_8800GTS;
}
/* Geforce8 - midend mobile */
if (strstr(gl_renderer, "8600 M"))
{
*vidmem = 512;
return CARD_NVIDIA_GEFORCE_8600MGT;
}
/* Geforce8 - midend */
if (strstr(gl_renderer, "8600")
|| strstr(gl_renderer, "8700"))
{
*vidmem = 256;
return CARD_NVIDIA_GEFORCE_8600GT;
}
/* Geforce8 - lowend */
if (strstr(gl_renderer, "8100")
|| strstr(gl_renderer, "8200")
|| strstr(gl_renderer, "8300")
|| strstr(gl_renderer, "8400")
|| strstr(gl_renderer, "8500"))
{
*vidmem = 128; /* 128-256MB for a 8300, 256-512MB for a 8400 */
return CARD_NVIDIA_GEFORCE_8300GS;
}
/* Geforce8-compatible fall back if the GPU is not in the list yet */
*vidmem = 128;
return CARD_NVIDIA_GEFORCE_8300GS;
}
/* Both the GeforceFX, 6xxx and 7xxx series support D3D9. The last two types have more
* shader capabilities, so we use the shader capabilities to distinguish between FX and 6xxx/7xxx.
*/
if (WINE_D3D9_CAPABLE(gl_info) && gl_info->supported[NV_VERTEX_PROGRAM3])
{
/* Geforce7 - highend */
if (strstr(gl_renderer, "7800")
|| strstr(gl_renderer, "7900")
|| strstr(gl_renderer, "7950")
|| strstr(gl_renderer, "Quadro FX 4")
|| strstr(gl_renderer, "Quadro FX 5"))
{
*vidmem = 256; /* A 7800GT uses 256MB while highend 7900 cards can use 512MB */
return CARD_NVIDIA_GEFORCE_7800GT;
}
/* Geforce7 midend */
if (strstr(gl_renderer, "7600")
|| strstr(gl_renderer, "7700"))
{
*vidmem = 256; /* The 7600 uses 256-512MB */
return CARD_NVIDIA_GEFORCE_7600;
}
/* Geforce7 lower medium */
if (strstr(gl_renderer, "7400"))
{
*vidmem = 256; /* The 7400 uses 256-512MB */
return CARD_NVIDIA_GEFORCE_7400;
}
/* Geforce7 lowend */
if (strstr(gl_renderer, "7300"))
{
*vidmem = 256; /* Mac Pros with this card have 256 MB */
return CARD_NVIDIA_GEFORCE_7300;
}
/* Geforce6 highend */
if (strstr(gl_renderer, "6800"))
{
*vidmem = 128; /* The 6800 uses 128-256MB, the 7600 uses 256-512MB */
return CARD_NVIDIA_GEFORCE_6800;
}
/* Geforce6 - midend */
if (strstr(gl_renderer, "6600")
|| strstr(gl_renderer, "6610")
|| strstr(gl_renderer, "6700"))
{
*vidmem = 128; /* A 6600GT has 128-256MB */
return CARD_NVIDIA_GEFORCE_6600GT;
}
/* Geforce6/7 lowend */
*vidmem = 64; /* */
return CARD_NVIDIA_GEFORCE_6200; /* Geforce 6100/6150/6200/7300/7400/7500 */
}
if (WINE_D3D9_CAPABLE(gl_info))
{
/* GeforceFX - highend */
if (strstr(gl_renderer, "5800")
|| strstr(gl_renderer, "5900")
|| strstr(gl_renderer, "5950")
|| strstr(gl_renderer, "Quadro FX"))
{
*vidmem = 256; /* 5800-5900 cards use 256MB */
return CARD_NVIDIA_GEFORCEFX_5800;
}
/* GeforceFX - midend */
if (strstr(gl_renderer, "5600")
|| strstr(gl_renderer, "5650")
|| strstr(gl_renderer, "5700")
|| strstr(gl_renderer, "5750"))
{
*vidmem = 128; /* A 5600 uses 128-256MB */
return CARD_NVIDIA_GEFORCEFX_5600;
}
/* GeforceFX - lowend */
*vidmem = 64; /* Normal FX5200 cards use 64-256MB; laptop (non-standard) can have less */
return CARD_NVIDIA_GEFORCEFX_5200; /* GeforceFX 5100/5200/5250/5300/5500 */
}
if (WINE_D3D8_CAPABLE(gl_info))
{
if (strstr(gl_renderer, "GeForce4 Ti") || strstr(gl_renderer, "Quadro4"))
{
*vidmem = 64; /* Geforce4 Ti cards have 64-128MB */
return CARD_NVIDIA_GEFORCE4_TI4200; /* Geforce4 Ti4200/Ti4400/Ti4600/Ti4800, Quadro4 */
}
*vidmem = 64; /* Geforce3 cards have 64-128MB */
return CARD_NVIDIA_GEFORCE3; /* Geforce3 standard/Ti200/Ti500, Quadro DCC */
}
if (WINE_D3D7_CAPABLE(gl_info))
{
if (strstr(gl_renderer, "GeForce4 MX"))
{
/* Most Geforce4MX GPUs have at least 64MB of memory, some
* early models had 32MB but most have 64MB or even 128MB. */
*vidmem = 64;
return CARD_NVIDIA_GEFORCE4_MX; /* MX420/MX440/MX460/MX4000 */
}
if (strstr(gl_renderer, "GeForce2 MX") || strstr(gl_renderer, "Quadro2 MXR"))
{
*vidmem = 32; /* Geforce2MX GPUs have 32-64MB of video memory */
return CARD_NVIDIA_GEFORCE2_MX; /* Geforce2 standard/MX100/MX200/MX400, Quadro2 MXR */
}
if (strstr(gl_renderer, "GeForce2") || strstr(gl_renderer, "Quadro2"))
{
*vidmem = 32; /* Geforce2 GPUs have 32-64MB of video memory */
return CARD_NVIDIA_GEFORCE2; /* Geforce2 GTS/Pro/Ti/Ultra, Quadro2 */
}
/* Most Geforce1 cards have 32MB, there are also some rare 16
* and 64MB (Dell) models. */
*vidmem = 32;
return CARD_NVIDIA_GEFORCE; /* Geforce 256/DDR, Quadro */
}
if (strstr(gl_renderer, "TNT2"))
{
*vidmem = 32; /* Most TNT2 boards have 32MB, though there are 16MB boards too */
return CARD_NVIDIA_RIVA_TNT2; /* Riva TNT2 standard/M64/Pro/Ultra */
}
*vidmem = 16; /* Most TNT boards have 16MB, some rare models have 8MB */
return CARD_NVIDIA_RIVA_TNT; /* Riva TNT, Vanta */
}
static enum wined3d_pci_device select_card_ati_binary(const struct wined3d_gl_info *gl_info,
const char *gl_renderer, unsigned int *vidmem)
{
/* See http://developer.amd.com/drivers/pc_vendor_id/Pages/default.aspx
*
* Beware: renderer string do not match exact card model,
* eg HD 4800 is returned for multiple cards, even for RV790 based ones. */
#ifndef VBOX_WITH_WDDM
if (WINE_D3D10_CAPABLE(gl_info))
#endif
{
/* Radeon EG CYPRESS XT / PRO HD5800 - highend */
if (strstr(gl_renderer, "HD 5800") /* Radeon EG CYPRESS HD58xx generic renderer string */
|| strstr(gl_renderer, "HD 5850") /* Radeon EG CYPRESS XT */
|| strstr(gl_renderer, "HD 5870")) /* Radeon EG CYPRESS PRO */
{
*vidmem = 1024; /* note: HD58xx cards use 1024MB */
return CARD_ATI_RADEON_HD5800;
}
/* Radeon EG JUNIPER XT / LE HD5700 - midend */
if (strstr(gl_renderer, "HD 5700") /* Radeon EG JUNIPER HD57xx generic renderer string */
|| strstr(gl_renderer, "HD 5750") /* Radeon EG JUNIPER LE */
|| strstr(gl_renderer, "HD 5770")) /* Radeon EG JUNIPER XT */
{
*vidmem = 512; /* note: HD5770 cards use 1024MB and HD5750 cards use 512MB or 1024MB */
return CARD_ATI_RADEON_HD5700;
}
/* Radeon R7xx HD4800 - highend */
if (strstr(gl_renderer, "HD 4800") /* Radeon RV7xx HD48xx generic renderer string */
|| strstr(gl_renderer, "HD 4830") /* Radeon RV770 */
|| strstr(gl_renderer, "HD 4850") /* Radeon RV770 */
|| strstr(gl_renderer, "HD 4870") /* Radeon RV770 */
|| strstr(gl_renderer, "HD 4890")) /* Radeon RV790 */
{
*vidmem = 512; /* note: HD4890 cards use 1024MB */
return CARD_ATI_RADEON_HD4800;
}
/* Radeon R740 HD4700 - midend */
if (strstr(gl_renderer, "HD 4700") /* Radeon RV770 */
|| strstr(gl_renderer, "HD 4770")) /* Radeon RV740 */
{
*vidmem = 512;
return CARD_ATI_RADEON_HD4700;
}
/* Radeon R730 HD4600 - midend */
if (strstr(gl_renderer, "HD 4600") /* Radeon RV730 */
|| strstr(gl_renderer, "HD 4650") /* Radeon RV730 */
|| strstr(gl_renderer, "HD 4670")) /* Radeon RV730 */
{
*vidmem = 512;
return CARD_ATI_RADEON_HD4600;
}
/* Radeon R710 HD4500/HD4350 - lowend */
if (strstr(gl_renderer, "HD 4350") /* Radeon RV710 */
|| strstr(gl_renderer, "HD 4550")) /* Radeon RV710 */
{
*vidmem = 256;
return CARD_ATI_RADEON_HD4350;
}
/* Radeon R6xx HD2900/HD3800 - highend */
if (strstr(gl_renderer, "HD 2900")
|| strstr(gl_renderer, "HD 3870")
|| strstr(gl_renderer, "HD 3850"))
{
*vidmem = 512; /* HD2900/HD3800 uses 256-1024MB */
return CARD_ATI_RADEON_HD2900;
}
/* Radeon R6xx HD2600/HD3600 - midend; HD3830 is China-only midend */
if (strstr(gl_renderer, "HD 2600")
|| strstr(gl_renderer, "HD 3830")
|| strstr(gl_renderer, "HD 3690")
|| strstr(gl_renderer, "HD 3650"))
{
*vidmem = 256; /* HD2600/HD3600 uses 256-512MB */
return CARD_ATI_RADEON_HD2600;
}
/* Radeon R6xx HD2350/HD2400/HD3400 - lowend
* Note HD2300=DX9, HD2350=DX10 */
if (strstr(gl_renderer, "HD 2350")
|| strstr(gl_renderer, "HD 2400")
|| strstr(gl_renderer, "HD 3470")
|| strstr(gl_renderer, "HD 3450")
|| strstr(gl_renderer, "HD 3430")
|| strstr(gl_renderer, "HD 3400"))
{
*vidmem = 256; /* HD2350/2400 use 256MB, HD34xx use 256-512MB */
return CARD_ATI_RADEON_HD2350;
}
/* Radeon R6xx/R7xx integrated */
if (strstr(gl_renderer, "HD 3100")
|| strstr(gl_renderer, "HD 3200")
|| strstr(gl_renderer, "HD 3300"))
{
*vidmem = 128; /* 128MB */
return CARD_ATI_RADEON_HD3200;
}
/* Default for when no GPU has been found */
*vidmem = 128; /* 128MB */
return CARD_ATI_RADEON_HD3200;
}
if (WINE_D3D8_CAPABLE(gl_info))
{
/* Radeon R5xx */
if (strstr(gl_renderer, "X1600")
|| strstr(gl_renderer, "X1650")
|| strstr(gl_renderer, "X1800")
|| strstr(gl_renderer, "X1900")
|| strstr(gl_renderer, "X1950"))
{
*vidmem = 128; /* X1600 uses 128-256MB, >=X1800 uses 256MB */
return CARD_ATI_RADEON_X1600;
}
/* Radeon R4xx + X1300/X1400/X1450/X1550/X2300/X2500/HD2300 (lowend R5xx)
* Note X2300/X2500/HD2300 are R5xx GPUs with a 2xxx naming but they are still DX9-only */
if (strstr(gl_renderer, "X700")
|| strstr(gl_renderer, "X800")
|| strstr(gl_renderer, "X850")
|| strstr(gl_renderer, "X1300")
|| strstr(gl_renderer, "X1400")
|| strstr(gl_renderer, "X1450")
|| strstr(gl_renderer, "X1550")
|| strstr(gl_renderer, "X2300")
|| strstr(gl_renderer, "X2500")
|| strstr(gl_renderer, "HD 2300")
)
{
*vidmem = 128; /* x700/x8*0 use 128-256MB, >=x1300 128-512MB */
return CARD_ATI_RADEON_X700;
}
/* Radeon Xpress Series - onboard, DX9b, Shader 2.0, 300-400MHz */
if (strstr(gl_renderer, "Radeon Xpress"))
{
*vidmem = 64; /* Shared RAM, BIOS configurable, 64-256M */
return CARD_ATI_RADEON_XPRESS_200M;
}
/* Radeon R3xx */
*vidmem = 64; /* Radeon 9500 uses 64MB, higher models use up to 256MB */
return CARD_ATI_RADEON_9500; /* Radeon 9500/9550/9600/9700/9800/X300/X550/X600 */
}
if (WINE_D3D8_CAPABLE(gl_info))
{
*vidmem = 64; /* 8500/9000 cards use mostly 64MB, though there are 32MB and 128MB models */
return CARD_ATI_RADEON_8500; /* Radeon 8500/9000/9100/9200/9300 */
}
if (WINE_D3D7_CAPABLE(gl_info))
{
*vidmem = 32; /* There are models with up to 64MB */
return CARD_ATI_RADEON_7200; /* Radeon 7000/7100/7200/7500 */
}
*vidmem = 16; /* There are 16-32MB models */
return CARD_ATI_RAGE_128PRO;
}
static enum wined3d_pci_device select_card_intel_binary(const struct wined3d_gl_info *gl_info,
const char *gl_renderer, unsigned int *vidmem)
{
if (strstr(gl_renderer, "X3100"))
{
/* MacOS calls the card GMA X3100, Google findings also suggest the name GM965 */
*vidmem = 128;
return CARD_INTEL_X3100;
}
if (strstr(gl_renderer, "GMA 950") || strstr(gl_renderer, "945GM"))
{
/* MacOS calls the card GMA 950, but everywhere else the PCI ID is named 945GM */
*vidmem = 64;
return CARD_INTEL_I945GM;
}
if (strstr(gl_renderer, "915GM")) return CARD_INTEL_I915GM;
if (strstr(gl_renderer, "915G")) return CARD_INTEL_I915G;
if (strstr(gl_renderer, "865G")) return CARD_INTEL_I865G;
if (strstr(gl_renderer, "855G")) return CARD_INTEL_I855G;
if (strstr(gl_renderer, "830G")) return CARD_INTEL_I830G;
return CARD_INTEL_I915G;
}
static enum wined3d_pci_device select_card_ati_mesa(const struct wined3d_gl_info *gl_info,
const char *gl_renderer, unsigned int *vidmem)
{
/* See http://developer.amd.com/drivers/pc_vendor_id/Pages/default.aspx
*
* Beware: renderer string do not match exact card model,
* eg HD 4800 is returned for multiple cards, even for RV790 based ones. */
if (strstr(gl_renderer, "Gallium"))
{
/* Radeon R7xx HD4800 - highend */
if (strstr(gl_renderer, "R700") /* Radeon R7xx HD48xx generic renderer string */
|| strstr(gl_renderer, "RV770") /* Radeon RV770 */
|| strstr(gl_renderer, "RV790")) /* Radeon RV790 */
{
*vidmem = 512; /* note: HD4890 cards use 1024MB */
return CARD_ATI_RADEON_HD4800;
}
/* Radeon R740 HD4700 - midend */
if (strstr(gl_renderer, "RV740")) /* Radeon RV740 */
{
*vidmem = 512;
return CARD_ATI_RADEON_HD4700;
}
/* Radeon R730 HD4600 - midend */
if (strstr(gl_renderer, "RV730")) /* Radeon RV730 */
{
*vidmem = 512;
return CARD_ATI_RADEON_HD4600;
}
/* Radeon R710 HD4500/HD4350 - lowend */
if (strstr(gl_renderer, "RV710")) /* Radeon RV710 */
{
*vidmem = 256;
return CARD_ATI_RADEON_HD4350;
}
/* Radeon R6xx HD2900/HD3800 - highend */
if (strstr(gl_renderer, "R600")
|| strstr(gl_renderer, "RV670")
|| strstr(gl_renderer, "R680"))
{
*vidmem = 512; /* HD2900/HD3800 uses 256-1024MB */
return CARD_ATI_RADEON_HD2900;
}
/* Radeon R6xx HD2600/HD3600 - midend; HD3830 is China-only midend */
if (strstr(gl_renderer, "RV630")
|| strstr(gl_renderer, "RV635"))
{
*vidmem = 256; /* HD2600/HD3600 uses 256-512MB */
return CARD_ATI_RADEON_HD2600;
}
/* Radeon R6xx HD2350/HD2400/HD3400 - lowend */
if (strstr(gl_renderer, "RV610")
|| strstr(gl_renderer, "RV620"))
{
*vidmem = 256; /* HD2350/2400 use 256MB, HD34xx use 256-512MB */
return CARD_ATI_RADEON_HD2350;
}
/* Radeon R6xx/R7xx integrated */
if (strstr(gl_renderer, "RS780")
|| strstr(gl_renderer, "RS880"))
{
*vidmem = 128; /* 128MB */
return CARD_ATI_RADEON_HD3200;
}
/* Radeon R5xx */
if (strstr(gl_renderer, "RV530")
|| strstr(gl_renderer, "RV535")
|| strstr(gl_renderer, "RV560")
|| strstr(gl_renderer, "R520")
|| strstr(gl_renderer, "RV570")
|| strstr(gl_renderer, "R580"))
{
*vidmem = 128; /* X1600 uses 128-256MB, >=X1800 uses 256MB */
return CARD_ATI_RADEON_X1600;
}
/* Radeon R4xx + X1300/X1400/X1450/X1550/X2300 (lowend R5xx) */
if (strstr(gl_renderer, "R410")
|| strstr(gl_renderer, "R420")
|| strstr(gl_renderer, "R423")
|| strstr(gl_renderer, "R430")
|| strstr(gl_renderer, "R480")
|| strstr(gl_renderer, "R481")
|| strstr(gl_renderer, "RV410")
|| strstr(gl_renderer, "RV515")
|| strstr(gl_renderer, "RV516"))
{
*vidmem = 128; /* x700/x8*0 use 128-256MB, >=x1300 128-512MB */
return CARD_ATI_RADEON_X700;
}
/* Radeon Xpress Series - onboard, DX9b, Shader 2.0, 300-400MHz */
if (strstr(gl_renderer, "RS400")
|| strstr(gl_renderer, "RS480")
|| strstr(gl_renderer, "RS482")
|| strstr(gl_renderer, "RS485")
|| strstr(gl_renderer, "RS600")
|| strstr(gl_renderer, "RS690")
|| strstr(gl_renderer, "RS740"))
{
*vidmem = 64; /* Shared RAM, BIOS configurable, 64-256M */
return CARD_ATI_RADEON_XPRESS_200M;
}
/* Radeon R3xx */
if (strstr(gl_renderer, "R300")
|| strstr(gl_renderer, "RV350")
|| strstr(gl_renderer, "RV351")
|| strstr(gl_renderer, "RV360")
|| strstr(gl_renderer, "RV370")
|| strstr(gl_renderer, "R350")
|| strstr(gl_renderer, "R360"))
{
*vidmem = 64; /* Radeon 9500 uses 64MB, higher models use up to 256MB */
return CARD_ATI_RADEON_9500; /* Radeon 9500/9550/9600/9700/9800/X300/X550/X600 */
}
}
if (WINE_D3D9_CAPABLE(gl_info))
{
/* Radeon R7xx HD4800 - highend */
if (strstr(gl_renderer, "(R700") /* Radeon R7xx HD48xx generic renderer string */
|| strstr(gl_renderer, "(RV770") /* Radeon RV770 */
|| strstr(gl_renderer, "(RV790")) /* Radeon RV790 */
{
*vidmem = 512; /* note: HD4890 cards use 1024MB */
return CARD_ATI_RADEON_HD4800;
}
/* Radeon R740 HD4700 - midend */
if (strstr(gl_renderer, "(RV740")) /* Radeon RV740 */
{
*vidmem = 512;
return CARD_ATI_RADEON_HD4700;
}
/* Radeon R730 HD4600 - midend */
if (strstr(gl_renderer, "(RV730")) /* Radeon RV730 */
{
*vidmem = 512;
return CARD_ATI_RADEON_HD4600;
}
/* Radeon R710 HD4500/HD4350 - lowend */
if (strstr(gl_renderer, "(RV710")) /* Radeon RV710 */
{
*vidmem = 256;
return CARD_ATI_RADEON_HD4350;
}
/* Radeon R6xx HD2900/HD3800 - highend */
if (strstr(gl_renderer, "(R600")
|| strstr(gl_renderer, "(RV670")
|| strstr(gl_renderer, "(R680"))
{
*vidmem = 512; /* HD2900/HD3800 uses 256-1024MB */
return CARD_ATI_RADEON_HD2900;
}
/* Radeon R6xx HD2600/HD3600 - midend; HD3830 is China-only midend */
if (strstr(gl_renderer, "(RV630")
|| strstr(gl_renderer, "(RV635"))
{
*vidmem = 256; /* HD2600/HD3600 uses 256-512MB */
return CARD_ATI_RADEON_HD2600;
}
/* Radeon R6xx HD2300/HD2400/HD3400 - lowend */
if (strstr(gl_renderer, "(RV610")
|| strstr(gl_renderer, "(RV620"))
{
*vidmem = 256; /* HD2350/2400 use 256MB, HD34xx use 256-512MB */
return CARD_ATI_RADEON_HD2350;
}
/* Radeon R6xx/R7xx integrated */
if (strstr(gl_renderer, "(RS780")
|| strstr(gl_renderer, "(RS880"))
{
*vidmem = 128; /* 128MB */
return CARD_ATI_RADEON_HD3200;
}
}
if (WINE_D3D8_CAPABLE(gl_info))
{
*vidmem = 64; /* 8500/9000 cards use mostly 64MB, though there are 32MB and 128MB models */
return CARD_ATI_RADEON_8500; /* Radeon 8500/9000/9100/9200/9300 */
}
if (WINE_D3D7_CAPABLE(gl_info))
{
*vidmem = 32; /* There are models with up to 64MB */
return CARD_ATI_RADEON_7200; /* Radeon 7000/7100/7200/7500 */
}
*vidmem = 16; /* There are 16-32MB models */
return CARD_ATI_RAGE_128PRO;
}
static enum wined3d_pci_device select_card_nvidia_mesa(const struct wined3d_gl_info *gl_info,
const char *gl_renderer, unsigned int *vidmem)
{
FIXME_(d3d_caps)("Card selection not handled for Mesa Nouveau driver\n");
#ifndef VBOX_WITH_WDDM
if (WINE_D3D9_CAPABLE(gl_info)) return CARD_NVIDIA_GEFORCEFX_5600;
#else
/* tmp work around to disable quirk_no_np2 quirk for mesa drivers */
if (WINE_D3D9_CAPABLE(gl_info)) return CARD_NVIDIA_GEFORCE_6200;
#endif
if (WINE_D3D8_CAPABLE(gl_info)) return CARD_NVIDIA_GEFORCE3;
if (WINE_D3D7_CAPABLE(gl_info)) return CARD_NVIDIA_GEFORCE;
if (WINE_D3D6_CAPABLE(gl_info)) return CARD_NVIDIA_RIVA_TNT;
return CARD_NVIDIA_RIVA_128;
}
static enum wined3d_pci_device select_card_intel_cmn(const struct wined3d_gl_info *gl_info,
const char *gl_renderer, unsigned int *vidmem)
{
if (strstr(gl_renderer, "HD Graphics")
|| strstr(gl_renderer, "Sandybridge"))
return CARD_INTEL_SBHD;
FIXME_(d3d_caps)("Card selection not handled for Windows Intel driver\n");
return CARD_INTEL_I915G;
}
static enum wined3d_pci_device select_card_intel_mesa(const struct wined3d_gl_info *gl_info,
const char *gl_renderer, unsigned int *vidmem)
{
return select_card_intel_cmn(gl_info, gl_renderer, vidmem);
}
struct vendor_card_selection
{
enum wined3d_gl_vendor gl_vendor;
enum wined3d_pci_vendor card_vendor;
const char *description; /* Description of the card selector i.e. Apple OS/X Intel */
enum wined3d_pci_device (*select_card)(const struct wined3d_gl_info *gl_info, const char *gl_renderer,
unsigned int *vidmem );
};
static const struct vendor_card_selection vendor_card_select_table[] =
{
{GL_VENDOR_NVIDIA, HW_VENDOR_NVIDIA, "Nvidia binary driver", select_card_nvidia_binary},
{GL_VENDOR_APPLE, HW_VENDOR_NVIDIA, "Apple OSX NVidia binary driver", select_card_nvidia_binary},
{GL_VENDOR_APPLE, HW_VENDOR_ATI, "Apple OSX AMD/ATI binary driver", select_card_ati_binary},
{GL_VENDOR_APPLE, HW_VENDOR_INTEL, "Apple OSX Intel binary driver", select_card_intel_binary},
{GL_VENDOR_FGLRX, HW_VENDOR_ATI, "AMD/ATI binary driver", select_card_ati_binary},
{GL_VENDOR_MESA, HW_VENDOR_ATI, "Mesa AMD/ATI driver", select_card_ati_mesa},
{GL_VENDOR_MESA, HW_VENDOR_NVIDIA, "Mesa Nouveau driver", select_card_nvidia_mesa},
{GL_VENDOR_MESA, HW_VENDOR_INTEL, "Mesa Intel driver", select_card_intel_mesa},
{GL_VENDOR_INTEL, HW_VENDOR_INTEL, "Windows Intel binary driver", select_card_intel_cmn}
};
static enum wined3d_pci_device wined3d_guess_card(const struct wined3d_gl_info *gl_info, const char *gl_renderer,
enum wined3d_gl_vendor *gl_vendor, enum wined3d_pci_vendor *card_vendor, unsigned int *vidmem)
{
/* Above is a list of Nvidia and ATI GPUs. Both vendors have dozens of
* different GPUs with roughly the same features. In most cases GPUs from a
* certain family differ in clockspeeds, the amount of video memory and the
* number of shader pipelines.
*
* A Direct3D device object contains the PCI id (vendor + device) of the
* videocard which is used for rendering. Various applications use this
* information to get a rough estimation of the features of the card and
* some might use it for enabling 3d effects only on certain types of
* videocards. In some cases games might even use it to work around bugs
* which happen on certain videocards/driver combinations. The problem is
* that OpenGL only exposes a rendering string containing the name of the
* videocard and not the PCI id.
*
* Various games depend on the PCI id, so somehow we need to provide one.
* A simple option is to parse the renderer string and translate this to
* the right PCI id. This is a lot of work because there are more than 200
* GPUs just for Nvidia. Various cards share the same renderer string, so
* the amount of code might be 'small' but there are quite a number of
* exceptions which would make this a pain to maintain. Another way would
* be to query the PCI id from the operating system (assuming this is the
* videocard which is used for rendering which is not always the case).
* This would work but it is not very portable. Second it would not work
* well in, let's say, a remote X situation in which the amount of 3d
* features which can be used is limited.
*
* As said most games only use the PCI id to get an indication of the
* capabilities of the card. It doesn't really matter if the given id is
* the correct one if we return the id of a card with similar 3d features.
*
* The code below checks the OpenGL capabilities of a videocard and matches
* that to a certain level of Direct3D functionality. Once a card passes
* the Direct3D9 check, we know that the card (in case of Nvidia) is at
* least a GeforceFX. To give a better estimate we do a basic check on the
* renderer string but if that won't pass we return a default card. This
* way is better than maintaining a full card database as even without a
* full database we can return a card with similar features. Second the
* size of the database can be made quite small because when you know what
* type of 3d functionality a card has, you know to which GPU family the
* GPU must belong. Because of this you only have to check a small part of
* the renderer string to distinguishes between different models from that
* family.
*
* The code also selects a default amount of video memory which we will
* use for an estimation of the amount of free texture memory. In case of
* real D3D the amount of texture memory includes video memory and system
* memory (to be specific AGP memory or in case of PCIE TurboCache /
* HyperMemory). We don't know how much system memory can be addressed by
* the system but we can make a reasonable estimation about the amount of
* video memory. If the value is slightly wrong it doesn't matter as we
* didn't include AGP-like memory which makes the amount of addressable
* memory higher and second OpenGL isn't that critical it moves to system
* memory behind our backs if really needed. Note that the amount of video
* memory can be overruled using a registry setting. */
#ifndef VBOX
int i;
#else
size_t i;
#endif
for (i = 0; i < (sizeof(vendor_card_select_table) / sizeof(*vendor_card_select_table)); ++i)
{
if ((vendor_card_select_table[i].gl_vendor != *gl_vendor)
|| (vendor_card_select_table[i].card_vendor != *card_vendor))
continue;
TRACE_(d3d_caps)("Applying card_selector \"%s\".\n", vendor_card_select_table[i].description);
return vendor_card_select_table[i].select_card(gl_info, gl_renderer, vidmem);
}
FIXME_(d3d_caps)("No card selector available for GL vendor %d and card vendor %04x.\n",
*gl_vendor, *card_vendor);
/* Default to generic Nvidia hardware based on the supported OpenGL extensions. The choice
* for Nvidia was because the hardware and drivers they make are of good quality. This makes
* them a good generic choice. */
*card_vendor = HW_VENDOR_NVIDIA;
#ifndef VBOX_WITH_WDDM
if (WINE_D3D9_CAPABLE(gl_info)) return CARD_NVIDIA_GEFORCEFX_5600;
#else
/* tmp work around to disable quirk_no_np2 quirk for not-recognized drivers */
if (WINE_D3D9_CAPABLE(gl_info)) return CARD_NVIDIA_GEFORCE_6200;
#endif
if (WINE_D3D8_CAPABLE(gl_info)) return CARD_NVIDIA_GEFORCE3;
if (WINE_D3D7_CAPABLE(gl_info)) return CARD_NVIDIA_GEFORCE;
if (WINE_D3D6_CAPABLE(gl_info)) return CARD_NVIDIA_RIVA_TNT;
return CARD_NVIDIA_RIVA_128;
}
#ifndef VBOX_WITH_VMSVGA
static const struct fragment_pipeline *select_fragment_implementation(struct wined3d_adapter *adapter)
{
const struct wined3d_gl_info *gl_info = &adapter->gl_info;
int vs_selected_mode, ps_selected_mode;
select_shader_mode(gl_info, &ps_selected_mode, &vs_selected_mode);
if ((ps_selected_mode == SHADER_ARB || ps_selected_mode == SHADER_GLSL)
&& gl_info->supported[ARB_FRAGMENT_PROGRAM]) return &arbfp_fragment_pipeline;
else if (ps_selected_mode == SHADER_ATI) return &atifs_fragment_pipeline;
else if (gl_info->supported[NV_REGISTER_COMBINERS]
&& gl_info->supported[NV_TEXTURE_SHADER2]) return &nvts_fragment_pipeline;
else if (gl_info->supported[NV_REGISTER_COMBINERS]) return &nvrc_fragment_pipeline;
else return &ffp_fragment_pipeline;
}
#endif
static const shader_backend_t *select_shader_backend(struct wined3d_adapter *adapter)
{
int vs_selected_mode, ps_selected_mode;
select_shader_mode(&adapter->gl_info, &ps_selected_mode, &vs_selected_mode);
if (vs_selected_mode == SHADER_GLSL || ps_selected_mode == SHADER_GLSL) return &glsl_shader_backend;
#ifndef VBOX_WITH_VMSVGA
if (vs_selected_mode == SHADER_ARB || ps_selected_mode == SHADER_ARB) return &arb_program_shader_backend;
#endif
return &none_shader_backend;
}
#ifndef VBOX_WITH_VMSVGA
static const struct blit_shader *select_blit_implementation(struct wined3d_adapter *adapter)
{
const struct wined3d_gl_info *gl_info = &adapter->gl_info;
int vs_selected_mode, ps_selected_mode;
select_shader_mode(gl_info, &ps_selected_mode, &vs_selected_mode);
if ((ps_selected_mode == SHADER_ARB || ps_selected_mode == SHADER_GLSL)
&& gl_info->supported[ARB_FRAGMENT_PROGRAM]) return &arbfp_blit;
else return &ffp_blit;
}
#endif
#ifdef VBOX_WITH_VMSVGA
/** Checks if @a pszExtension is one of the extensions we're looking for and
* updates @a pGlInfo->supported accordingly. */
static void check_gl_extension(struct wined3d_gl_info *pGlInfo, const char *pszExtension)
{
size_t i;
TRACE_(d3d_caps)("- %s\n", debugstr_a(pszExtension));
for (i = 0; i < RT_ELEMENTS(EXTENSION_MAP); i++)
if (!strcmp(pszExtension, EXTENSION_MAP[i].extension_string))
{
TRACE_(d3d_caps)(" FOUND: %s support.\n", EXTENSION_MAP[i].extension_string);
pGlInfo->supported[EXTENSION_MAP[i].extension] = TRUE;
return;
}
}
#endif
/* Context activation is done by the caller. */
BOOL IWineD3DImpl_FillGLCaps(struct wined3d_adapter *adapter, struct VBOXVMSVGASHADERIF *pVBoxShaderIf)
{
#ifndef VBOX_WITH_VMSVGA
struct wined3d_driver_info *driver_info = &adapter->driver_info;
#endif
struct wined3d_gl_info *gl_info = &adapter->gl_info;
#ifndef VBOX_WITH_VMSVGA
const char *GL_Extensions = NULL;
const char *WGL_Extensions = NULL;
#endif
const char *gl_vendor_str, *gl_renderer_str, *gl_version_str;
#ifndef VBOX_WITH_VMSVGA
struct fragment_caps fragment_caps;
#endif
enum wined3d_gl_vendor gl_vendor;
enum wined3d_pci_vendor card_vendor;
enum wined3d_pci_device device;
GLint gl_max;
GLfloat gl_floatv[2];
unsigned i;
#ifndef VBOX_WITH_VMSVGA
HDC hdc;
#endif
unsigned int vidmem=0;
DWORD gl_version;
#ifndef VBOX_WITH_VMSVGA
size_t len;
#endif
TRACE_(d3d_caps)("(%p)\n", gl_info);
ENTER_GL();
VBOX_CHECK_GL_CALL(gl_renderer_str = (const char *)glGetString(GL_RENDERER));
TRACE_(d3d_caps)("GL_RENDERER: %s.\n", debugstr_a(gl_renderer_str));
if (!gl_renderer_str)
{
LEAVE_GL();
ERR_(d3d_caps)("Received a NULL GL_RENDERER.\n");
return FALSE;
}
VBOX_CHECK_GL_CALL(gl_vendor_str = (const char *)glGetString(GL_VENDOR));
TRACE_(d3d_caps)("GL_VENDOR: %s.\n", debugstr_a(gl_vendor_str));
if (!gl_vendor_str)
{
LEAVE_GL();
ERR_(d3d_caps)("Received a NULL GL_VENDOR.\n");
return FALSE;
}
/* Parse the GL_VERSION field into major and minor information */
VBOX_CHECK_GL_CALL(gl_version_str = (const char *)glGetString(GL_VERSION));
TRACE_(d3d_caps)("GL_VERSION: %s.\n", debugstr_a(gl_version_str));
if (!gl_version_str)
{
LEAVE_GL();
ERR_(d3d_caps)("Received a NULL GL_VERSION.\n");
return FALSE;
}
gl_version = wined3d_parse_gl_version(gl_version_str);
/*
* Initialize openGL extension related variables
* with Default values
*/
memset(gl_info->supported, 0, sizeof(gl_info->supported));
gl_info->limits.blends = 1;
gl_info->limits.buffers = 1;
gl_info->limits.textures = 1;
gl_info->limits.fragment_samplers = 1;
gl_info->limits.vertex_samplers = 0;
gl_info->limits.combined_samplers = gl_info->limits.fragment_samplers + gl_info->limits.vertex_samplers;
gl_info->limits.sampler_stages = 1;
gl_info->limits.glsl_vs_float_constants = 0;
gl_info->limits.glsl_ps_float_constants = 0;
gl_info->limits.arb_vs_float_constants = 0;
gl_info->limits.arb_vs_native_constants = 0;
gl_info->limits.arb_vs_instructions = 0;
gl_info->limits.arb_vs_temps = 0;
gl_info->limits.arb_ps_float_constants = 0;
gl_info->limits.arb_ps_local_constants = 0;
gl_info->limits.arb_ps_instructions = 0;
gl_info->limits.arb_ps_temps = 0;
/* Retrieve opengl defaults */
VBOX_CHECK_GL_CALL(glGetIntegerv(GL_MAX_CLIP_PLANES, &gl_max));
gl_info->limits.clipplanes = min(WINED3DMAXUSERCLIPPLANES, gl_max);
TRACE_(d3d_caps)("ClipPlanes support - num Planes=%d\n", gl_max);
#ifdef VBOX_VMSVGA3D_DUAL_OPENGL_PROFILE
glGetIntegerv(GL_MAX_LIGHTS, &gl_max);
if (glGetError() != GL_NO_ERROR)
{
pVBoxShaderIf->pfnSwitchInitProfile(pVBoxShaderIf, true /*fOtherProfile*/);
VBOX_CHECK_GL_CALL(glGetIntegerv(GL_MAX_LIGHTS, &gl_max));
pVBoxShaderIf->pfnSwitchInitProfile(pVBoxShaderIf, false /*fOtherProfile*/);
}
#else
VBOX_CHECK_GL_CALL(glGetIntegerv(GL_MAX_LIGHTS, &gl_max));
#endif
gl_info->limits.lights = gl_max;
TRACE_(d3d_caps)("Lights support - max lights=%d\n", gl_max);
VBOX_CHECK_GL_CALL(glGetIntegerv(GL_MAX_TEXTURE_SIZE, &gl_max));
gl_info->limits.texture_size = gl_max;
TRACE_(d3d_caps)("Maximum texture size support - max texture size=%d\n", gl_max);
#ifdef VBOX_VMSVGA3D_DUAL_OPENGL_PROFILE
glGetFloatv(GL_ALIASED_POINT_SIZE_RANGE, gl_floatv);
if (glGetError() != GL_NO_ERROR)
{
pVBoxShaderIf->pfnSwitchInitProfile(pVBoxShaderIf, true /*fOtherProfile*/);
VBOX_CHECK_GL_CALL(glGetFloatv(GL_ALIASED_POINT_SIZE_RANGE, gl_floatv));
if (glGetError() != GL_NO_ERROR)
gl_floatv[0] = gl_floatv[1] = 1;
pVBoxShaderIf->pfnSwitchInitProfile(pVBoxShaderIf, false /*fOtherProfile*/);
}
#else
VBOX_CHECK_GL_CALL(glGetFloatv(GL_ALIASED_POINT_SIZE_RANGE, gl_floatv));
#endif
gl_info->limits.pointsize_min = gl_floatv[0];
gl_info->limits.pointsize_max = gl_floatv[1];
TRACE_(d3d_caps)("Maximum point size support - max point size=%f\n", gl_floatv[1]);
/* Parse the gl supported features, in theory enabling parts of our code appropriately. */
#ifndef VBOX_WITH_VMSVGA
GL_Extensions = (const char *)glGetString(GL_EXTENSIONS);
if (!GL_Extensions)
{
LEAVE_GL();
ERR_(d3d_caps)("Received a NULL GL_EXTENSIONS.\n");
return FALSE;
}
LEAVE_GL();
TRACE_(d3d_caps)("GL_Extensions reported:\n");
#endif
gl_info->supported[WINED3D_GL_EXT_NONE] = TRUE;
gl_info->supported[VBOX_SHARED_CONTEXTS] = TRUE;
#ifdef VBOX_WITH_VMSVGA
{
void *pvEnumCtx = NULL;
char szCurExt[256];
while (pVBoxShaderIf->pfnGetNextExtension(pVBoxShaderIf, &pvEnumCtx, szCurExt, sizeof(szCurExt), false /*fOtherProfile*/))
check_gl_extension(gl_info, szCurExt);
/* The cheap way out. */
pvEnumCtx = NULL;
while (pVBoxShaderIf->pfnGetNextExtension(pVBoxShaderIf, &pvEnumCtx, szCurExt, sizeof(szCurExt), true /*fOtherProfile*/))
check_gl_extension(gl_info, szCurExt);
}
#else /* !VBOX_WITH_VMSVGA */
while (*GL_Extensions)
{
const char *start;
char current_ext[256];
while (isspace(*GL_Extensions)) ++GL_Extensions;
start = GL_Extensions;
while (!isspace(*GL_Extensions) && *GL_Extensions) ++GL_Extensions;
len = GL_Extensions - start;
if (!len || len >= sizeof(current_ext)) continue;
memcpy(current_ext, start, len);
current_ext[len] = '\0';
TRACE_(d3d_caps)("- %s\n", debugstr_a(current_ext));
for (i = 0; i < (sizeof(EXTENSION_MAP) / sizeof(*EXTENSION_MAP)); ++i)
{
if (!strcmp(current_ext, EXTENSION_MAP[i].extension_string))
{
TRACE_(d3d_caps)(" FOUND: %s support.\n", EXTENSION_MAP[i].extension_string);
gl_info->supported[EXTENSION_MAP[i].extension] = TRUE;
break;
}
}
}
#endif /* !VBOX_WITH_VMSVGA */
#ifdef VBOX_WITH_VMSVGA
# ifdef RT_OS_WINDOWS
# define OGLGETPROCADDRESS wglGetProcAddress
# elif RT_OS_DARWIN
# define OGLGETPROCADDRESS(x) MyNSGLGetProcAddress(x)
# else
extern void (*glXGetProcAddress(const GLubyte *procname))( void );
# define OGLGETPROCADDRESS(x) glXGetProcAddress((const GLubyte *)x)
# endif
#endif
/* Now work out what GL support this card really has */
#define USE_GL_FUNC(type, pfn, ext, replace) \
{ \
DWORD ver = ver_for_ext(ext); \
if (gl_info->supported[ext]) gl_info->pfn = (type)OGLGETPROCADDRESS(#pfn); \
else if (ver && ver <= gl_version) gl_info->pfn = (type)OGLGETPROCADDRESS(#replace); \
else gl_info->pfn = NULL; \
}
GL_EXT_FUNCS_GEN;
#undef USE_GL_FUNC
#ifndef VBOX_WITH_VMSVGA
#define USE_GL_FUNC(type, pfn, ext, replace) gl_info->pfn = (type)OGLGETPROCADDRESS(#pfn);
WGL_EXT_FUNCS_GEN;
#undef USE_GL_FUNC
#endif
ENTER_GL();
/* Now mark all the extensions supported which are included in the opengl core version. Do this *after*
* loading the functions, otherwise the code above will load the extension entry points instead of the
* core functions, which may not work. */
for (i = 0; i < (sizeof(EXTENSION_MAP) / sizeof(*EXTENSION_MAP)); ++i)
{
if (!gl_info->supported[EXTENSION_MAP[i].extension]
&& EXTENSION_MAP[i].version <= gl_version && EXTENSION_MAP[i].version)
{
TRACE_(d3d_caps)(" GL CORE: %s support.\n", EXTENSION_MAP[i].extension_string);
gl_info->supported[EXTENSION_MAP[i].extension] = TRUE;
}
}
if (gl_info->supported[APPLE_FENCE])
{
/* GL_NV_fence and GL_APPLE_fence provide the same functionality basically.
* The apple extension interacts with some other apple exts. Disable the NV
* extension if the apple one is support to prevent confusion in other parts
* of the code. */
gl_info->supported[NV_FENCE] = FALSE;
}
if (gl_info->supported[APPLE_FLOAT_PIXELS])
{
/* GL_APPLE_float_pixels == GL_ARB_texture_float + GL_ARB_half_float_pixel
*
* The enums are the same:
* GL_RGBA16F_ARB = GL_RGBA_FLOAT16_APPLE = 0x881A
* GL_RGB16F_ARB = GL_RGB_FLOAT16_APPLE = 0x881B
* GL_RGBA32F_ARB = GL_RGBA_FLOAT32_APPLE = 0x8814
* GL_RGB32F_ARB = GL_RGB_FLOAT32_APPLE = 0x8815
* GL_HALF_FLOAT_ARB = GL_HALF_APPLE = 0x140B
*/
if (!gl_info->supported[ARB_TEXTURE_FLOAT])
{
TRACE_(d3d_caps)(" IMPLIED: GL_ARB_texture_float support(from GL_APPLE_float_pixels.\n");
gl_info->supported[ARB_TEXTURE_FLOAT] = TRUE;
}
if (!gl_info->supported[ARB_HALF_FLOAT_PIXEL])
{
TRACE_(d3d_caps)(" IMPLIED: GL_ARB_half_float_pixel support(from GL_APPLE_float_pixels.\n");
gl_info->supported[ARB_HALF_FLOAT_PIXEL] = TRUE;
}
}
if (gl_info->supported[ARB_MAP_BUFFER_RANGE])
{
/* GL_ARB_map_buffer_range and GL_APPLE_flush_buffer_range provide the same
* functionality. Prefer the ARB extension */
gl_info->supported[APPLE_FLUSH_BUFFER_RANGE] = FALSE;
}
if (gl_info->supported[ARB_TEXTURE_CUBE_MAP])
{
TRACE_(d3d_caps)(" IMPLIED: NVIDIA (NV) Texture Gen Reflection support.\n");
gl_info->supported[NV_TEXGEN_REFLECTION] = TRUE;
}
if (!gl_info->supported[ARB_DEPTH_CLAMP] && gl_info->supported[NV_DEPTH_CLAMP])
{
TRACE_(d3d_caps)(" IMPLIED: ARB_depth_clamp support (by NV_depth_clamp).\n");
gl_info->supported[ARB_DEPTH_CLAMP] = TRUE;
}
if (!gl_info->supported[ARB_VERTEX_ARRAY_BGRA] && gl_info->supported[EXT_VERTEX_ARRAY_BGRA])
{
TRACE_(d3d_caps)(" IMPLIED: ARB_vertex_array_bgra support (by EXT_vertex_array_bgra).\n");
gl_info->supported[ARB_VERTEX_ARRAY_BGRA] = TRUE;
}
if (gl_info->supported[NV_TEXTURE_SHADER2])
{
if (gl_info->supported[NV_REGISTER_COMBINERS])
{
/* Also disable ATI_FRAGMENT_SHADER if register combiners and texture_shader2
* are supported. The nv extensions provide the same functionality as the
* ATI one, and a bit more(signed pixelformats). */
gl_info->supported[ATI_FRAGMENT_SHADER] = FALSE;
}
}
if (gl_info->supported[NV_REGISTER_COMBINERS])
{
VBOX_CHECK_GL_CALL(glGetIntegerv(GL_MAX_GENERAL_COMBINERS_NV, &gl_max));
gl_info->limits.general_combiners = gl_max;
TRACE_(d3d_caps)("Max general combiners: %d.\n", gl_max);
}
if (gl_info->supported[ARB_DRAW_BUFFERS])
{
VBOX_CHECK_GL_CALL(glGetIntegerv(GL_MAX_DRAW_BUFFERS_ARB, &gl_max));
gl_info->limits.buffers = gl_max;
TRACE_(d3d_caps)("Max draw buffers: %u.\n", gl_max);
}
if (gl_info->supported[ARB_MULTITEXTURE])
{
#ifdef VBOX_VMSVGA3D_DUAL_OPENGL_PROFILE
glGetIntegerv(GL_MAX_TEXTURE_UNITS_ARB, &gl_max);
if (glGetError() != GL_NO_ERROR)
VBOX_CHECK_GL_CALL(glGetIntegerv(GL_MAX_TEXTURE_IMAGE_UNITS, &gl_max));
#else
VBOX_CHECK_GL_CALL(glGetIntegerv(GL_MAX_TEXTURE_UNITS_ARB, &gl_max));
#endif
gl_info->limits.textures = min(MAX_TEXTURES, gl_max);
TRACE_(d3d_caps)("Max textures: %d.\n", gl_info->limits.textures);
if (gl_info->supported[ARB_FRAGMENT_PROGRAM])
{
GLint tmp;
VBOX_CHECK_GL_CALL(glGetIntegerv(GL_MAX_TEXTURE_IMAGE_UNITS_ARB, &tmp));
gl_info->limits.fragment_samplers = min(MAX_FRAGMENT_SAMPLERS, tmp);
}
else
{
gl_info->limits.fragment_samplers = max(gl_info->limits.fragment_samplers, (UINT)gl_max);
}
TRACE_(d3d_caps)("Max fragment samplers: %d.\n", gl_info->limits.fragment_samplers);
if (gl_info->supported[ARB_VERTEX_SHADER])
{
GLint tmp;
VBOX_CHECK_GL_CALL(glGetIntegerv(GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS_ARB, &tmp));
gl_info->limits.vertex_samplers = tmp;
VBOX_CHECK_GL_CALL(glGetIntegerv(GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS_ARB, &tmp));
gl_info->limits.combined_samplers = tmp;
/* Loading GLSL sampler uniforms is much simpler if we can assume that the sampler setup
* is known at shader link time. In a vertex shader + pixel shader combination this isn't
* an issue because then the sampler setup only depends on the two shaders. If a pixel
* shader is used with fixed function vertex processing we're fine too because fixed function
* vertex processing doesn't use any samplers. If fixed function fragment processing is
* used we have to make sure that all vertex sampler setups are valid together with all
* possible fixed function fragment processing setups. This is true if vsamplers + MAX_TEXTURES
* <= max_samplers. This is true on all d3d9 cards that support vtf(gf 6 and gf7 cards).
* dx9 radeon cards do not support vertex texture fetch. DX10 cards have 128 samplers, and
* dx9 is limited to 8 fixed function texture stages and 4 vertex samplers. DX10 does not have
* a fixed function pipeline anymore.
*
* So this is just a check to check that our assumption holds true. If not, write a warning
* and reduce the number of vertex samplers or probably disable vertex texture fetch. */
if (gl_info->limits.vertex_samplers && gl_info->limits.combined_samplers < 12
&& MAX_TEXTURES + gl_info->limits.vertex_samplers > gl_info->limits.combined_samplers)
{
FIXME("OpenGL implementation supports %u vertex samplers and %u total samplers.\n",
gl_info->limits.vertex_samplers, gl_info->limits.combined_samplers);
FIXME("Expected vertex samplers + MAX_TEXTURES(=8) > combined_samplers.\n");
if (gl_info->limits.combined_samplers > MAX_TEXTURES)
gl_info->limits.vertex_samplers = gl_info->limits.combined_samplers - MAX_TEXTURES;
else
gl_info->limits.vertex_samplers = 0;
}
}
else
{
gl_info->limits.combined_samplers = gl_info->limits.fragment_samplers;
}
TRACE_(d3d_caps)("Max vertex samplers: %u.\n", gl_info->limits.vertex_samplers);
TRACE_(d3d_caps)("Max combined samplers: %u.\n", gl_info->limits.combined_samplers);
}
if (gl_info->supported[ARB_VERTEX_BLEND])
{
#ifdef VBOX_VMSVGA3D_DUAL_OPENGL_PROFILE
glGetIntegerv(GL_MAX_VERTEX_UNITS_ARB, &gl_max);
if (glGetError() != GL_NO_ERROR)
{
pVBoxShaderIf->pfnSwitchInitProfile(pVBoxShaderIf, true /*fOtherProfile*/);
VBOX_CHECK_GL_CALL(glGetIntegerv(GL_MAX_VERTEX_UNITS_ARB, &gl_max));
pVBoxShaderIf->pfnSwitchInitProfile(pVBoxShaderIf, false /*fOtherProfile*/);
}
#else
VBOX_CHECK_GL_CALL(glGetIntegerv(GL_MAX_VERTEX_UNITS_ARB, &gl_max));
#endif
gl_info->limits.blends = gl_max;
TRACE_(d3d_caps)("Max blends: %u.\n", gl_info->limits.blends);
}
if (gl_info->supported[EXT_TEXTURE3D])
{
VBOX_CHECK_GL_CALL(glGetIntegerv(GL_MAX_3D_TEXTURE_SIZE_EXT, &gl_max));
gl_info->limits.texture3d_size = gl_max;
TRACE_(d3d_caps)("Max texture3D size: %d.\n", gl_info->limits.texture3d_size);
}
if (gl_info->supported[EXT_TEXTURE_FILTER_ANISOTROPIC])
{
VBOX_CHECK_GL_CALL(glGetIntegerv(GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT, &gl_max));
gl_info->limits.anisotropy = gl_max;
TRACE_(d3d_caps)("Max anisotropy: %d.\n", gl_info->limits.anisotropy);
}
if (gl_info->supported[ARB_FRAGMENT_PROGRAM])
{
#ifdef VBOX_VMSVGA3D_DUAL_OPENGL_PROFILE
GL_EXTCALL(glGetProgramivARB(GL_FRAGMENT_PROGRAM_ARB, GL_MAX_PROGRAM_ENV_PARAMETERS_ARB, &gl_max));
if (glGetError() != GL_NO_ERROR)
pVBoxShaderIf->pfnSwitchInitProfile(pVBoxShaderIf, true /*fOtherProfile*/);
#endif
VBOX_CHECK_GL_CALL(GL_EXTCALL(glGetProgramivARB(GL_FRAGMENT_PROGRAM_ARB, GL_MAX_PROGRAM_ENV_PARAMETERS_ARB, &gl_max)));
gl_info->limits.arb_ps_float_constants = gl_max;
TRACE_(d3d_caps)("Max ARB_FRAGMENT_PROGRAM float constants: %d.\n", gl_info->limits.arb_ps_float_constants);
VBOX_CHECK_GL_CALL(GL_EXTCALL(glGetProgramivARB(GL_FRAGMENT_PROGRAM_ARB, GL_MAX_PROGRAM_NATIVE_PARAMETERS_ARB, &gl_max)));
gl_info->limits.arb_ps_native_constants = gl_max;
TRACE_(d3d_caps)("Max ARB_FRAGMENT_PROGRAM native float constants: %d.\n",
gl_info->limits.arb_ps_native_constants);
VBOX_CHECK_GL_CALL(GL_EXTCALL(glGetProgramivARB(GL_FRAGMENT_PROGRAM_ARB, GL_MAX_PROGRAM_NATIVE_TEMPORARIES_ARB, &gl_max)));
gl_info->limits.arb_ps_temps = gl_max;
TRACE_(d3d_caps)("Max ARB_FRAGMENT_PROGRAM native temporaries: %d.\n", gl_info->limits.arb_ps_temps);
VBOX_CHECK_GL_CALL(GL_EXTCALL(glGetProgramivARB(GL_FRAGMENT_PROGRAM_ARB, GL_MAX_PROGRAM_NATIVE_INSTRUCTIONS_ARB, &gl_max)));
gl_info->limits.arb_ps_instructions = gl_max;
TRACE_(d3d_caps)("Max ARB_FRAGMENT_PROGRAM native instructions: %d.\n", gl_info->limits.arb_ps_instructions);
VBOX_CHECK_GL_CALL(GL_EXTCALL(glGetProgramivARB(GL_FRAGMENT_PROGRAM_ARB, GL_MAX_PROGRAM_LOCAL_PARAMETERS_ARB, &gl_max)));
gl_info->limits.arb_ps_local_constants = gl_max;
TRACE_(d3d_caps)("Max ARB_FRAGMENT_PROGRAM local parameters: %d.\n", gl_info->limits.arb_ps_instructions);
#ifdef VBOX_VMSVGA3D_DUAL_OPENGL_PROFILE
pVBoxShaderIf->pfnSwitchInitProfile(pVBoxShaderIf, false /*fOtherProfile*/);
#endif
}
if (gl_info->supported[ARB_VERTEX_PROGRAM])
{
#ifdef VBOX_VMSVGA3D_DUAL_OPENGL_PROFILE
GL_EXTCALL(glGetProgramivARB(GL_VERTEX_PROGRAM_ARB, GL_MAX_PROGRAM_ENV_PARAMETERS_ARB, &gl_max));
if (glGetError() != GL_NO_ERROR)
pVBoxShaderIf->pfnSwitchInitProfile(pVBoxShaderIf, true /*fOtherProfile*/);
#endif
VBOX_CHECK_GL_CALL(GL_EXTCALL(glGetProgramivARB(GL_VERTEX_PROGRAM_ARB, GL_MAX_PROGRAM_ENV_PARAMETERS_ARB, &gl_max)));
gl_info->limits.arb_vs_float_constants = gl_max;
TRACE_(d3d_caps)("Max ARB_VERTEX_PROGRAM float constants: %d.\n", gl_info->limits.arb_vs_float_constants);
VBOX_CHECK_GL_CALL(GL_EXTCALL(glGetProgramivARB(GL_VERTEX_PROGRAM_ARB, GL_MAX_PROGRAM_NATIVE_PARAMETERS_ARB, &gl_max)));
gl_info->limits.arb_vs_native_constants = gl_max;
TRACE_(d3d_caps)("Max ARB_VERTEX_PROGRAM native float constants: %d.\n",
gl_info->limits.arb_vs_native_constants);
VBOX_CHECK_GL_CALL(GL_EXTCALL(glGetProgramivARB(GL_VERTEX_PROGRAM_ARB, GL_MAX_PROGRAM_NATIVE_TEMPORARIES_ARB, &gl_max)));
gl_info->limits.arb_vs_temps = gl_max;
TRACE_(d3d_caps)("Max ARB_VERTEX_PROGRAM native temporaries: %d.\n", gl_info->limits.arb_vs_temps);
VBOX_CHECK_GL_CALL(GL_EXTCALL(glGetProgramivARB(GL_VERTEX_PROGRAM_ARB, GL_MAX_PROGRAM_NATIVE_INSTRUCTIONS_ARB, &gl_max)));
gl_info->limits.arb_vs_instructions = gl_max;
TRACE_(d3d_caps)("Max ARB_VERTEX_PROGRAM native instructions: %d.\n", gl_info->limits.arb_vs_instructions);
#ifdef VBOX_VMSVGA3D_DUAL_OPENGL_PROFILE
pVBoxShaderIf->pfnSwitchInitProfile(pVBoxShaderIf, false /*fOtherProfile*/);
#endif
#ifndef VBOX_WITH_VMSVGA
if (test_arb_vs_offset_limit(gl_info)) gl_info->quirks |= WINED3D_QUIRK_ARB_VS_OFFSET_LIMIT;
#endif
}
if (gl_info->supported[ARB_VERTEX_SHADER])
{
VBOX_CHECK_GL_CALL(glGetIntegerv(GL_MAX_VERTEX_UNIFORM_COMPONENTS_ARB, &gl_max));
gl_info->limits.glsl_vs_float_constants = gl_max / 4;
#ifdef VBOX_WITH_WDDM
/* AFAICT the " / 4" here comes from that we're going to use the glsl_vs/ps_float_constants to create vec4 arrays,
* thus each array element has 4 components, so the actual number of vec4 arrays is GL_MAX_VERTEX/FRAGMENT_UNIFORM_COMPONENTS_ARB / 4
* win8 Aero won't properly work with this constant < 256 in any way,
* while Intel drivers I've encountered this problem with supports vec4 arrays of size > GL_MAX_VERTEX/FRAGMENT_UNIFORM_COMPONENTS_ARB / 4
* so use it here.
* @todo: add logging
* @todo: perhaps should be movet to quirks?
* */
if (gl_info->limits.glsl_vs_float_constants < 256 && gl_max >= 256)
{
DWORD dwVersion = GetVersion();
DWORD dwMajor = (DWORD)(LOBYTE(LOWORD(dwVersion)));
DWORD dwMinor = (DWORD)(HIBYTE(LOWORD(dwVersion)));
/* tmp workaround Win8 Aero requirement for 256 */
if (dwMajor > 6 || dwMinor > 1)
{
gl_info->limits.glsl_vs_float_constants = 256;
}
}
#endif
TRACE_(d3d_caps)("Max ARB_VERTEX_SHADER float constants: %u.\n", gl_info->limits.glsl_vs_float_constants);
}
if (gl_info->supported[ARB_FRAGMENT_SHADER])
{
VBOX_CHECK_GL_CALL(glGetIntegerv(GL_MAX_FRAGMENT_UNIFORM_COMPONENTS_ARB, &gl_max));
gl_info->limits.glsl_ps_float_constants = gl_max / 4;
#ifdef VBOX_WITH_WDDM
/* AFAICT the " / 4" here comes from that we're going to use the glsl_vs/ps_float_constants to create vec4 arrays,
* thus each array element has 4 components, so the actual number of vec4 arrays is GL_MAX_VERTEX/FRAGMENT_UNIFORM_COMPONENTS_ARB / 4
* win8 Aero won't properly work with this constant < 256 in any way,
* while Intel drivers I've encountered this problem with supports vec4 arrays of size > GL_MAX_VERTEX/FRAGMENT_UNIFORM_COMPONENTS_ARB / 4
* so use it here.
* @todo: add logging
* @todo: perhaps should be movet to quirks?
* */
if (gl_info->limits.glsl_ps_float_constants < 256 && gl_max >= 256)
{
DWORD dwVersion = GetVersion();
DWORD dwMajor = (DWORD)(LOBYTE(LOWORD(dwVersion)));
DWORD dwMinor = (DWORD)(HIBYTE(LOWORD(dwVersion)));
/* tmp workaround Win8 Aero requirement for 256 */
if (dwMajor > 6 || dwMinor > 1)
{
gl_info->limits.glsl_ps_float_constants = 256;
}
}
#endif
TRACE_(d3d_caps)("Max ARB_FRAGMENT_SHADER float constants: %u.\n", gl_info->limits.glsl_ps_float_constants);
#ifdef VBOX_VMSVGA3D_DUAL_OPENGL_PROFILE
glGetIntegerv(GL_MAX_VARYING_FLOATS_ARB, &gl_max);
if (glGetError() != GL_NO_ERROR)
{
pVBoxShaderIf->pfnSwitchInitProfile(pVBoxShaderIf, true /*fOtherProfile*/);
VBOX_CHECK_GL_CALL(glGetIntegerv(GL_MAX_VARYING_FLOATS_ARB, &gl_max));
pVBoxShaderIf->pfnSwitchInitProfile(pVBoxShaderIf, false /*fOtherProfile*/);
}
#else
VBOX_CHECK_GL_CALL(glGetIntegerv(GL_MAX_VARYING_FLOATS_ARB, &gl_max));
#endif
gl_info->limits.glsl_varyings = gl_max;
TRACE_(d3d_caps)("Max GLSL varyings: %u (%u 4 component varyings).\n", gl_max, gl_max / 4);
}
if (gl_info->supported[ARB_SHADING_LANGUAGE_100])
{
const char *str = (const char *)glGetString(GL_SHADING_LANGUAGE_VERSION_ARB);
unsigned int major, minor;
TRACE_(d3d_caps)("GLSL version string: %s.\n", debugstr_a(str));
/* The format of the GLSL version string is "major.minor[.release] [vendor info]". */
sscanf(str, "%u.%u", &major, &minor);
gl_info->glsl_version = MAKEDWORD_VERSION(major, minor);
}
if (gl_info->supported[NV_LIGHT_MAX_EXPONENT])
{
#ifdef VBOX_VMSVGA3D_DUAL_OPENGL_PROFILE
glGetFloatv(GL_MAX_SHININESS_NV, &gl_info->limits.shininess);
if (glGetError() != GL_NO_ERROR)
{
pVBoxShaderIf->pfnSwitchInitProfile(pVBoxShaderIf, true /*fOtherProfile*/);
VBOX_CHECK_GL_CALL(glGetFloatv(GL_MAX_SHININESS_NV, &gl_info->limits.shininess));
pVBoxShaderIf->pfnSwitchInitProfile(pVBoxShaderIf, false /*fOtherProfile*/);
}
#else
VBOX_CHECK_GL_CALL(glGetFloatv(GL_MAX_SHININESS_NV, &gl_info->limits.shininess));
#endif
}
else
{
gl_info->limits.shininess = 128.0f;
}
if (gl_info->supported[ARB_TEXTURE_NON_POWER_OF_TWO])
{
/* If we have full NP2 texture support, disable
* GL_ARB_texture_rectangle because we will never use it.
* This saves a few redundant glDisable calls. */
gl_info->supported[ARB_TEXTURE_RECTANGLE] = FALSE;
}
if (gl_info->supported[ATI_FRAGMENT_SHADER])
{
/* Disable NV_register_combiners and fragment shader if this is supported.
* generally the NV extensions are preferred over the ATI ones, and this
* extension is disabled if register_combiners and texture_shader2 are both
* supported. So we reach this place only if we have incomplete NV dxlevel 8
* fragment processing support. */
gl_info->supported[NV_REGISTER_COMBINERS] = FALSE;
gl_info->supported[NV_REGISTER_COMBINERS2] = FALSE;
gl_info->supported[NV_TEXTURE_SHADER] = FALSE;
gl_info->supported[NV_TEXTURE_SHADER2] = FALSE;
}
if (gl_info->supported[NV_HALF_FLOAT])
{
/* GL_ARB_half_float_vertex is a subset of GL_NV_half_float. */
gl_info->supported[ARB_HALF_FLOAT_VERTEX] = TRUE;
}
if (gl_info->supported[ARB_POINT_SPRITE])
{
gl_info->limits.point_sprite_units = gl_info->limits.textures;
}
else
{
gl_info->limits.point_sprite_units = 0;
}
#ifndef VBOX_WITH_VMSVGA
checkGLcall("extension detection");
#endif
LEAVE_GL();
#ifndef VBOX_WITH_VMSVGA
adapter->fragment_pipe = select_fragment_implementation(adapter);
#endif
adapter->shader_backend = select_shader_backend(adapter);
#ifndef VBOX_WITH_VMSVGA
adapter->blitter = select_blit_implementation(adapter);
adapter->fragment_pipe->get_caps(gl_info, &fragment_caps);
gl_info->limits.texture_stages = fragment_caps.MaxTextureBlendStages;
TRACE_(d3d_caps)("Max texture stages: %u.\n", gl_info->limits.texture_stages);
/* In some cases the number of texture stages can be larger than the number
* of samplers. The GF4 for example can use only 2 samplers (no fragment
* shaders), but 8 texture stages (register combiners). */
gl_info->limits.sampler_stages = max(gl_info->limits.fragment_samplers, gl_info->limits.texture_stages);
#endif
if (gl_info->supported[ARB_FRAMEBUFFER_OBJECT])
{
gl_info->fbo_ops.glIsRenderbuffer = gl_info->glIsRenderbuffer;
gl_info->fbo_ops.glBindRenderbuffer = gl_info->glBindRenderbuffer;
gl_info->fbo_ops.glDeleteRenderbuffers = gl_info->glDeleteRenderbuffers;
gl_info->fbo_ops.glGenRenderbuffers = gl_info->glGenRenderbuffers;
gl_info->fbo_ops.glRenderbufferStorage = gl_info->glRenderbufferStorage;
gl_info->fbo_ops.glRenderbufferStorageMultisample = gl_info->glRenderbufferStorageMultisample;
gl_info->fbo_ops.glGetRenderbufferParameteriv = gl_info->glGetRenderbufferParameteriv;
gl_info->fbo_ops.glIsFramebuffer = gl_info->glIsFramebuffer;
gl_info->fbo_ops.glBindFramebuffer = gl_info->glBindFramebuffer;
gl_info->fbo_ops.glDeleteFramebuffers = gl_info->glDeleteFramebuffers;
gl_info->fbo_ops.glGenFramebuffers = gl_info->glGenFramebuffers;
gl_info->fbo_ops.glCheckFramebufferStatus = gl_info->glCheckFramebufferStatus;
gl_info->fbo_ops.glFramebufferTexture1D = gl_info->glFramebufferTexture1D;
gl_info->fbo_ops.glFramebufferTexture2D = gl_info->glFramebufferTexture2D;
gl_info->fbo_ops.glFramebufferTexture3D = gl_info->glFramebufferTexture3D;
gl_info->fbo_ops.glFramebufferRenderbuffer = gl_info->glFramebufferRenderbuffer;
gl_info->fbo_ops.glGetFramebufferAttachmentParameteriv = gl_info->glGetFramebufferAttachmentParameteriv;
gl_info->fbo_ops.glBlitFramebuffer = gl_info->glBlitFramebuffer;
gl_info->fbo_ops.glGenerateMipmap = gl_info->glGenerateMipmap;
}
else
{
if (gl_info->supported[EXT_FRAMEBUFFER_OBJECT])
{
gl_info->fbo_ops.glIsRenderbuffer = gl_info->glIsRenderbufferEXT;
gl_info->fbo_ops.glBindRenderbuffer = gl_info->glBindRenderbufferEXT;
gl_info->fbo_ops.glDeleteRenderbuffers = gl_info->glDeleteRenderbuffersEXT;
gl_info->fbo_ops.glGenRenderbuffers = gl_info->glGenRenderbuffersEXT;
gl_info->fbo_ops.glRenderbufferStorage = gl_info->glRenderbufferStorageEXT;
gl_info->fbo_ops.glGetRenderbufferParameteriv = gl_info->glGetRenderbufferParameterivEXT;
gl_info->fbo_ops.glIsFramebuffer = gl_info->glIsFramebufferEXT;
gl_info->fbo_ops.glBindFramebuffer = gl_info->glBindFramebufferEXT;
gl_info->fbo_ops.glDeleteFramebuffers = gl_info->glDeleteFramebuffersEXT;
gl_info->fbo_ops.glGenFramebuffers = gl_info->glGenFramebuffersEXT;
gl_info->fbo_ops.glCheckFramebufferStatus = gl_info->glCheckFramebufferStatusEXT;
gl_info->fbo_ops.glFramebufferTexture1D = gl_info->glFramebufferTexture1DEXT;
gl_info->fbo_ops.glFramebufferTexture2D = gl_info->glFramebufferTexture2DEXT;
gl_info->fbo_ops.glFramebufferTexture3D = gl_info->glFramebufferTexture3DEXT;
gl_info->fbo_ops.glFramebufferRenderbuffer = gl_info->glFramebufferRenderbufferEXT;
gl_info->fbo_ops.glGetFramebufferAttachmentParameteriv = gl_info->glGetFramebufferAttachmentParameterivEXT;
gl_info->fbo_ops.glGenerateMipmap = gl_info->glGenerateMipmapEXT;
}
#ifndef VBOX_WITH_VMSVGA
else if (wined3d_settings.offscreen_rendering_mode == ORM_FBO)
{
WARN_(d3d_caps)("Framebuffer objects not supported, falling back to backbuffer offscreen rendering mode.\n");
wined3d_settings.offscreen_rendering_mode = ORM_BACKBUFFER;
}
#endif
if (gl_info->supported[EXT_FRAMEBUFFER_BLIT])
{
gl_info->fbo_ops.glBlitFramebuffer = gl_info->glBlitFramebufferEXT;
}
if (gl_info->supported[EXT_FRAMEBUFFER_MULTISAMPLE])
{
gl_info->fbo_ops.glRenderbufferStorageMultisample = gl_info->glRenderbufferStorageMultisampleEXT;
}
}
#ifndef VBOX_WITH_VMSVGA
/* MRTs are currently only supported when FBOs are used. */
if (wined3d_settings.offscreen_rendering_mode != ORM_FBO)
{
gl_info->limits.buffers = 1;
}
#endif
gl_vendor = wined3d_guess_gl_vendor(gl_info, gl_vendor_str, gl_renderer_str);
card_vendor = wined3d_guess_card_vendor(gl_vendor_str, gl_renderer_str);
TRACE_(d3d_caps)("found GL_VENDOR (%s)->(0x%04x/0x%04x)\n", debugstr_a(gl_vendor_str), gl_vendor, card_vendor);
device = wined3d_guess_card(gl_info, gl_renderer_str, &gl_vendor, &card_vendor, &vidmem);
TRACE_(d3d_caps)("FOUND (fake) card: 0x%x (vendor id), 0x%x (device id)\n", card_vendor, device);
/* If we have an estimate use it, else default to 64MB; */
if(vidmem)
gl_info->vidmem = vidmem*1024*1024; /* convert from MBs to bytes */
else
gl_info->vidmem = WINE_DEFAULT_VIDMEM;
gl_info->wrap_lookup[WINED3DTADDRESS_WRAP - WINED3DTADDRESS_WRAP] = GL_REPEAT;
gl_info->wrap_lookup[WINED3DTADDRESS_MIRROR - WINED3DTADDRESS_WRAP] =
gl_info->supported[ARB_TEXTURE_MIRRORED_REPEAT] ? GL_MIRRORED_REPEAT_ARB : GL_REPEAT;
gl_info->wrap_lookup[WINED3DTADDRESS_CLAMP - WINED3DTADDRESS_WRAP] = GL_CLAMP_TO_EDGE;
gl_info->wrap_lookup[WINED3DTADDRESS_BORDER - WINED3DTADDRESS_WRAP] =
gl_info->supported[ARB_TEXTURE_BORDER_CLAMP] ? GL_CLAMP_TO_BORDER_ARB : GL_REPEAT;
gl_info->wrap_lookup[WINED3DTADDRESS_MIRRORONCE - WINED3DTADDRESS_WRAP] =
gl_info->supported[ATI_TEXTURE_MIRROR_ONCE] ? GL_MIRROR_CLAMP_TO_EDGE_ATI : GL_REPEAT;
#ifndef VBOX_WITH_VMSVGA
/* Make sure there's an active HDC else the WGL extensions will fail */
hdc = pwglGetCurrentDC();
if (hdc) {
/* Not all GL drivers might offer WGL extensions e.g. VirtualBox */
if(GL_EXTCALL(wglGetExtensionsStringARB))
WGL_Extensions = GL_EXTCALL(wglGetExtensionsStringARB(hdc));
if (NULL == WGL_Extensions) {
ERR(" WGL_Extensions returns NULL\n");
} else {
TRACE_(d3d_caps)("WGL_Extensions reported:\n");
while (*WGL_Extensions != 0x00) {
const char *Start;
char ThisExtn[256];
while (isspace(*WGL_Extensions)) WGL_Extensions++;
Start = WGL_Extensions;
while (!isspace(*WGL_Extensions) && *WGL_Extensions != 0x00) {
WGL_Extensions++;
}
len = WGL_Extensions - Start;
if (len == 0 || len >= sizeof(ThisExtn))
continue;
memcpy(ThisExtn, Start, len);
ThisExtn[len] = '\0';
TRACE_(d3d_caps)("- %s\n", debugstr_a(ThisExtn));
if (!strcmp(ThisExtn, "WGL_ARB_pixel_format")) {
gl_info->supported[WGL_ARB_PIXEL_FORMAT] = TRUE;
TRACE_(d3d_caps)("FOUND: WGL_ARB_pixel_format support\n");
}
if (!strcmp(ThisExtn, "WGL_WINE_pixel_format_passthrough")) {
gl_info->supported[WGL_WINE_PIXEL_FORMAT_PASSTHROUGH] = TRUE;
TRACE_(d3d_caps)("FOUND: WGL_WINE_pixel_format_passthrough support\n");
}
}
}
}
#endif
fixup_extensions(gl_info, gl_renderer_str, gl_vendor, card_vendor, device);
#ifndef VBOX_WITH_VMSVGA
init_driver_info(driver_info, card_vendor, device);
add_gl_compat_wrappers(gl_info);
#endif
return TRUE;
}
|