vulkan: Initial Vulkan support! This work was done by Jacob Lifshay and Mark Callow; I'm just merging it into revision control.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 1489 1490 1491 1492 1493 1494 1495 1496 1497 1498 1499 1500 1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 1513 1514 1515 1516 1517 1518 1519 1520 1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 1531 1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 1546 1547 1548 1549 1550 1551 1552 1553 1554 1555 1556 1557 1558 1559 1560 1561 1562 1563 1564 1565 1566 1567 1568 1569 1570 1571 1572 1573 1574 1575 1576 1577 1578 1579 1580 1581 1582 1583 1584 1585 1586 1587 1588 1589 1590 1591 1592 1593 1594 1595 1596 1597 1598 1599 1600 1601 1602 1603 1604 1605 1606 1607 1608 1609 1610 1611 1612 1613 1614 1615 1616 1617 1618 1619 1620 1621 1622 1623 1624 1625 1626 1627 1628 1629 1630 1631 1632 1633 1634 1635 1636 1637 1638 1639 1640 1641 1642 1643 1644 1645 1646 1647 1648 1649 1650 1651 1652 1653 1654 1655 1656 1657 1658 1659 1660 1661 1662 1663 1664 1665 1666 1667 1668 1669 1670 1671 1672 1673 1674 1675 1676 1677 1678 1679 1680 1681 1682 1683 1684 1685 1686 1687 1688 1689 1690 1691 1692 1693 1694 1695 1696 1697 1698 1699 1700 1701 1702 1703 1704 1705 1706 1707 1708 1709 1710 1711 1712 1713 1714 1715 1716 1717 1718 1719 1720 1721 1722 1723 1724 1725 1726 1727 1728 1729 1730 1731 1732 1733 1734 1735 1736 1737 1738 1739 1740 1741 1742 1743 1744 1745 1746 1747 1748 1749 1750 1751 1752 1753 1754 1755 1756 1757 1758 1759 1760 1761 1762 1763 1764 1765 1766 1767 1768 1769 1770 1771 1772 1773 1774 1775 1776 1777 1778 1779 1780 1781 1782 1783 1784 1785 1786 1787 1788 1789 1790 1791 1792 1793 1794 1795 1796 1797 1798 1799 1800 1801 1802 1803 1804 1805 1806 1807 1808 1809 1810 1811 1812 1813 1814 1815 1816 1817 1818 1819 1820 1821 1822 1823 1824 1825 1826 1827 1828 1829 1830 1831 1832 1833 1834 1835 1836 1837 1838 1839 1840 1841 1842 1843 1844 1845 1846 1847 1848 1849 1850 1851 1852 1853 1854 1855 1856 1857 1858 1859 1860 1861 1862 1863 1864 1865 1866 1867 1868 1869 1870 1871 1872 1873 1874 1875 1876 1877 1878 1879 1880 1881 1882 1883 1884 1885 1886 1887 1888 1889 1890 1891 1892 1893 1894 1895 1896 1897 1898 1899 1900 1901 1902 1903 1904 1905 1906 1907 1908 1909 1910 1911 1912 1913 1914 1915 1916 1917 1918 1919 1920 1921 1922 1923 1924 1925 1926 1927 1928 1929 1930 1931 1932 1933 1934 1935 1936 1937 1938 1939 1940 1941 1942 1943 1944 1945 1946 1947 1948 1949 1950 1951 1952 1953 1954 1955 1956 1957 1958 1959 1960 1961 1962 1963 1964 1965 1966 1967 1968 1969 1970 1971 1972 1973 1974 1975 1976 1977 1978 1979 1980 1981 1982 1983 1984 1985 1986 1987 1988 1989 1990 1991 1992 1993 1994 1995 1996 1997 1998 1999 2000 2001 2002 2003 2004 2005 2006 2007 2008 2009 2010 2011 2012 2013 2014 2015 2016 2017 2018 2019 2020 2021 2022 2023 2024 2025 2026 2027 2028 2029 2030 2031 2032 2033 2034 2035 2036 2037 2038 2039 2040 2041 2042 2043 2044 2045 2046 2047 2048 2049 2050 2051 2052 2053 2054 2055 2056 2057 2058 2059 2060 2061 2062 2063 2064 2065 2066 2067 2068 2069 2070 2071 2072 2073 2074 2075 2076 2077 2078 2079 2080 2081 2082 2083 2084 2085 2086 2087 2088 2089 2090 2091 2092 2093 2094 2095 2096 2097 2098 2099 2100 2101 2102 2103 2104 2105 2106 2107 2108 2109 2110 2111 2112 2113 2114 2115 2116 2117 2118 2119 2120 2121 2122 2123 2124 2125 2126 2127 2128 2129 2130 2131 2132 2133 2134 2135 2136 2137 2138 2139 2140 2141 2142 2143 2144 2145 2146 2147 2148 2149 2150 2151 2152 2153 2154 2155 2156 2157 2158 2159 2160 2161 2162 2163 2164 2165 2166 2167 2168 2169 2170 2171 2172 2173 2174 2175 2176 2177 2178 2179 2180 2181 2182 2183 2184 2185 2186 2187 2188 2189 2190 2191 2192 2193 2194 2195 2196 2197 2198 2199 2200 2201 2202 2203 2204 2205 2206 2207 2208 2209 2210 2211 2212 2213 2214 2215 2216 2217 2218 2219 2220 2221 2222 2223 2224 2225 2226 2227 2228 2229 2230 2231 2232 2233 2234 2235 2236 2237 2238 2239 2240 2241 2242 2243 2244 2245 2246 2247 2248 2249 2250 2251 2252 2253 2254 2255 2256 2257 2258 2259 2260 2261 2262 2263 2264 2265 2266 2267 2268 2269 2270 2271 2272 2273 2274 2275 2276 2277 2278 2279 2280 2281 2282 2283 2284 2285 2286 2287 2288 2289 2290 2291 2292 2293 2294 2295 2296 2297 2298 2299 2300 2301 2302 2303 2304 2305 2306 2307 2308 2309 2310 2311 2312 2313 2314 2315 2316 2317 2318 2319 2320 2321 2322 2323 2324 2325 2326 2327 2328 2329 2330 2331 2332 2333 2334 2335 2336 2337 2338 2339 2340 2341 2342 2343 2344 2345 2346 2347 2348 2349 2350 2351 2352 2353 2354 2355 2356 2357 2358 2359 2360 2361 2362 2363 2364 2365 2366 2367 2368 2369 2370 2371 2372 2373 2374 2375 2376 2377 2378 2379 2380 2381 2382 2383 2384 2385 2386 2387 2388 2389 2390 2391 2392 2393 2394 2395 2396 2397 2398 2399 2400 2401 2402 2403 2404 2405 2406 2407 2408 2409 2410 2411 2412 2413 2414 2415 2416 2417 2418 2419 2420 2421 2422 2423 2424 2425 2426 2427 2428 2429 2430 2431 2432 2433 2434 2435 2436 2437 2438 2439 2440 2441 2442 2443 2444 2445 2446 2447 2448 2449 2450 2451 2452 2453 2454 2455 2456 2457 2458 2459 2460 2461 2462 2463 2464 2465 2466 2467 2468 2469 2470 2471 2472 2473 2474 2475 2476 2477 2478 2479 2480 2481 2482 2483 2484 2485 2486 2487 2488 2489 2490 2491 2492 2493 2494 2495 2496 2497 2498 2499 2500 2501 2502 2503 2504 2505 2506 2507 2508 2509 2510 2511 2512 2513 2514 2515 2516 2517 2518 2519 2520 2521 2522 2523 2524 2525 2526 2527 2528 2529 2530 2531 2532 2533 2534 2535 2536 2537 2538 2539 2540 2541 2542 2543 2544 2545 2546 2547 2548 2549 2550 2551 2552 2553 2554 2555 2556 2557 2558 2559 2560 2561 2562 2563 2564 2565 2566 2567 2568 2569 2570 2571 2572 2573 2574 2575 2576 2577 2578 2579 2580 2581 2582 2583 2584 2585 2586 2587 2588 2589 2590 2591 2592 2593 2594 2595 2596 2597 2598 2599 2600 2601 2602 2603 2604 2605 2606 2607 2608 2609 2610 2611 2612 2613 2614 2615 2616 2617 2618 2619 2620 2621 2622 2623 2624 2625 2626 2627 2628 2629 2630 2631 2632 2633 2634 2635 2636 2637 2638 2639 2640 2641 2642 2643 2644 2645 2646 2647 2648 2649 2650 2651 2652 2653 2654 2655 2656 2657 2658 2659 2660 2661 2662 2663 2664 2665 2666 2667 2668 2669 2670 2671 2672 2673 2674 2675 2676 2677 2678 2679 2680 2681 2682 2683 2684 2685 2686 2687 2688 2689 2690 2691 2692 2693 2694 2695 2696 2697 2698 2699 2700 2701 2702 2703 2704 2705 2706 2707 2708 2709 2710 2711 2712 2713 2714 2715 2716 2717 2718 2719 2720 2721 2722 2723 2724 2725 2726 2727 2728 2729 2730 2731 2732 2733 2734 2735 2736 2737 2738 2739 2740 2741 2742 2743 2744 2745 2746 2747 2748 2749 2750 2751 2752 2753 2754 2755 2756 2757 2758 2759 2760 2761 2762 2763 2764 2765 2766 2767 2768 2769 2770 2771 2772 2773 2774 2775 2776 2777 2778 2779 2780 2781 2782 2783 2784 2785 2786 2787 2788 2789 2790 2791 2792 2793 2794 2795 2796 2797 2798 2799 2800 2801 2802 2803 2804 2805 2806 2807 2808 2809 2810 2811 2812 2813 2814 2815 2816 2817 2818 2819 2820 2821 2822 2823 2824 2825 2826 2827 2828 2829 2830 2831 2832 2833 2834 2835 2836 2837 2838 2839 2840 2841 2842 2843 2844 2845 2846 2847 2848 2849 2850 2851 2852 2853 2854 2855 2856 2857 2858 2859 2860 2861 2862 2863 2864 2865 2866 2867 2868 2869 2870 2871 2872 2873 2874 2875 2876 2877 2878 2879 2880 2881 2882 2883 2884 2885 2886 2887 2888 2889 2890 2891 2892 2893 2894 2895 2896 2897 2898 2899 2900 2901 2902 2903 2904 2905 2906 2907 2908 2909 2910 2911 2912 2913 2914 2915 2916 2917 2918 2919 2920 2921 2922 2923 2924 2925 2926 2927 2928 2929 2930 2931 2932 2933 2934 2935 2936 2937 2938 2939 2940 2941 2942 2943 2944 2945 2946 2947 2948 2949 2950 2951 2952 2953 2954 2955 2956 2957 2958 2959 2960 2961 2962 2963 2964 2965 2966 2967 2968 2969 2970 2971 2972 2973 2974 2975 2976 2977 2978 2979 2980 2981 2982 2983 2984 2985 2986 2987 2988 2989 2990 2991 2992 2993 2994 2995 2996 2997 2998 2999 3000 3001 3002 3003 3004 3005 3006 3007 3008 3009 3010 3011 3012 3013 3014 3015 3016 3017 3018 3019 3020 3021 3022 3023 3024 3025 3026 3027 3028 3029 3030 3031 3032 3033 3034 3035 3036 3037 3038 3039 3040 3041 3042 3043 3044 3045 3046 3047 3048 3049 3050 3051 3052 3053 3054 3055 3056 3057 3058 3059 3060 3061 3062 3063 3064 3065 3066 3067 3068 3069 3070 3071 3072 3073 3074 3075 3076 3077 3078 3079 3080 3081 3082 3083 3084 3085 3086 3087 3088 3089 3090 3091 3092 3093 3094 3095 3096 3097 3098 3099 3100 3101 3102 3103 3104 3105 3106 3107 3108 3109 3110 3111 3112 3113 3114 3115 3116 3117 3118 3119 3120 3121 3122 3123 3124 3125 3126 3127 3128 3129 3130 3131 3132 3133 3134 3135 3136 3137 3138 3139 3140 3141 3142 3143 3144 3145 3146 3147 3148 3149 3150 3151 3152 3153 3154 3155 3156 3157 3158 3159 3160 3161 3162 3163 3164 3165 3166 3167 3168 3169 3170 3171 3172 3173 3174 3175 3176 3177 3178 3179 3180 3181 3182 3183 3184 3185 3186 3187 3188 3189 3190 3191 3192 3193 3194 3195 3196 3197 3198 3199 3200 3201 3202 3203 3204 3205 3206 3207 3208 3209 3210 3211 3212 3213 3214 3215 3216 3217 3218 3219 3220 3221 3222 3223 3224 3225 3226 3227 3228 3229 3230 3231 3232 3233 3234 3235 3236 3237 3238 3239 3240 3241 3242 3243 3244 3245 3246 3247 3248 3249 3250 3251 3252 3253 3254 3255 3256 3257 3258 3259 3260 3261 3262 3263 3264 3265 3266 3267 3268 3269 3270 3271 3272 3273 3274 3275 3276 3277 3278 3279 3280 3281 3282 3283 3284 3285 3286 3287 3288 3289 3290 3291 3292 3293 3294 3295 3296 3297 3298 3299 3300 3301 3302 3303 3304 3305 3306 3307 3308 3309 3310 3311 3312 3313 3314 3315 3316 3317 3318 3319 3320 3321 3322 3323 3324 3325 3326 3327 3328 3329 3330 3331 3332 3333 3334 3335 3336 3337 3338 3339 3340 3341 3342 3343 3344 3345 3346 3347 3348 3349 3350 3351 3352 3353 3354 3355 3356 3357 3358 3359 3360 3361 3362 3363 3364 3365 3366 3367 3368 3369 3370 3371 3372 3373 3374 3375 3376 3377 3378 3379 3380 3381 3382 3383 3384 3385 3386 3387 3388 3389 3390 3391 3392 3393 3394 3395 3396 3397 3398 3399 3400 3401 3402 3403 3404 3405 3406 3407 3408 3409 3410 3411 3412 3413 3414 3415 3416 3417 3418 3419 3420 3421 3422 3423 3424 3425 3426 3427 3428 3429 3430 3431 3432 3433 3434 3435 3436 3437 3438 3439 3440 3441 3442 3443 3444 3445 3446 3447 3448 3449 3450 3451 3452 3453 3454 3455 3456 3457 3458 3459 3460 3461 3462 3463 3464 3465 3466 3467 3468 3469 3470 3471 3472 3473 3474 3475 3476 3477 3478 3479 3480 3481 3482 3483 3484 3485 3486 3487 3488 3489 3490 3491 3492 3493 3494 3495 3496 3497 3498 3499 3500 3501 3502 3503 3504 3505 3506 3507 3508 3509 3510 3511 3512 3513 3514 3515 3516 3517 3518 3519 3520 3521 3522 3523 3524 3525 3526 3527 3528 3529 3530 3531 3532 3533 3534 3535 3536 3537 3538 3539 3540 3541 3542 3543 3544 3545 3546 3547 3548 3549 3550 3551 3552 3553 3554 3555 3556 3557 3558 3559 3560 3561 3562 3563 3564 3565 3566 3567 3568 3569 3570 3571 3572 3573 3574 3575 3576 3577 3578 3579 3580 3581 3582 3583 3584 3585 3586 3587 3588 3589 3590 3591 3592 3593 3594 3595 3596 3597 3598 3599 3600 3601 3602 3603 3604 3605 3606 3607 3608 3609 3610 3611 3612 3613 3614 3615 3616 3617 3618 3619 3620 3621 3622 3623 3624 3625 3626 3627 3628 3629 3630 3631 3632 3633 3634 3635 3636 3637 3638 3639 3640 3641 3642 3643 3644 3645 3646 3647 3648 3649 3650 3651 3652 3653 3654 3655 3656 3657 3658 3659 3660 3661 3662 3663 3664 3665 3666 3667 3668 3669 3670 3671 3672 3673 3674 3675 3676 3677 3678 3679 3680 3681 3682 3683 3684 3685 3686 3687 3688 3689 3690 3691 3692 3693 3694 3695 3696 3697 3698 3699 3700 3701 3702 3703 3704 3705 3706 3707 3708 3709 3710 3711 3712 3713 3714 3715 3716 3717 3718 3719 3720 3721 3722 3723 3724 3725 3726 3727 3728 3729 3730 3731 3732 3733 3734 3735 3736 3737 3738 3739 3740 3741 3742 3743 3744 3745 3746 3747 3748 3749 3750 3751 3752 3753 3754 3755 3756 3757 3758 3759 3760 3761 3762 3763 3764 3765 3766 3767 3768 3769 3770 3771 3772 3773 3774 3775 3776 3777 3778 3779 3780 3781 3782 3783 3784 3785 3786 3787 3788 3789 3790 3791 3792 3793 3794 3795 3796 3797 3798 3799 3800 3801 3802 3803 3804 3805 3806 3807 3808 3809 3810 3811 3812 3813 3814 3815 3816 3817 3818 3819 3820 3821 3822 3823 3824 3825 3826 3827 3828 3829 3830 3831 3832 3833 3834 3835 3836 3837 3838 3839 3840 3841 3842 3843 3844 3845 3846 3847 3848 3849 3850 3851 3852 3853 3854 3855 3856 3857 3858 3859 3860 3861 3862 3863 3864 3865 3866 3867 3868 3869 3870 3871 3872 3873 3874 3875 3876 3877 3878 3879 3880 3881 3882 3883 3884 3885 3886 3887 3888 3889 3890 3891 3892 3893 3894 3895 3896 3897 3898 3899 3900 3901 3902 3903 3904 3905 3906 3907 3908 3909 3910 3911 3912 3913 3914 3915 3916 3917 3918 3919 3920 3921 3922 3923 3924 3925 3926 3927 3928 3929 3930 3931 3932 3933 3934 3935 3936 3937 3938 3939 3940 3941 3942 3943 3944 3945 3946 3947 3948 3949 3950 3951 3952 3953 3954 3955 3956 3957 3958 3959 3960 3961 3962 3963 3964 3965 3966 3967 3968 3969 3970 3971 3972 3973 3974 3975 3976 3977 3978 3979 3980 3981 3982 3983 3984 3985 3986 3987 3988 3989 3990 3991 3992 3993 3994 3995 3996 3997 3998 3999 4000 4001 4002 4003 4004 4005 4006 4007 4008 4009 4010 4011 4012 4013 4014 4015 4016 4017 4018 4019 4020 4021 4022 4023 4024 4025 4026 4027 4028 4029 4030 4031 4032 4033 4034 4035 4036 4037 4038 4039 4040 4041 4042 4043 4044 4045 4046 4047 4048 4049 4050 4051 4052 4053 4054 4055 4056 4057 4058 4059 4060 4061 4062 4063 4064 4065 4066 4067 4068 4069 4070 4071 4072 4073 4074 4075 4076 4077 4078 4079 4080 4081 4082 4083 4084 4085 4086 4087 4088 4089 4090 4091 4092 4093 4094 4095 4096 4097 4098 4099 4100 4101 4102 4103 4104 4105 4106 4107 4108 4109 4110 4111 4112 4113 4114 4115 4116 4117 4118 4119 4120 4121 4122 4123 4124 4125 4126 4127 4128 4129 4130 4131 4132 4133 4134 4135 4136 4137 4138 4139 4140 4141 4142 4143 4144 4145 4146 4147 4148 4149 4150 4151 4152 4153 4154 4155 4156 4157 4158 4159 4160 4161 4162 4163 4164 4165 4166 4167 4168 4169 4170 4171 4172 4173 4174 4175 4176 4177 4178 4179 4180 4181 4182 4183 4184 4185 4186 4187 4188 4189 4190 4191 4192 4193 4194 4195 4196 4197 4198 4199 4200 4201 4202 4203 4204 4205 4206 4207 4208 4209 4210 4211 4212 4213 4214 4215 4216 4217 4218 4219 4220 4221 4222 4223 4224 4225 4226 4227 4228 4229 4230 4231 4232 4233 4234 4235 4236 4237 4238 4239 4240 4241 4242 4243 4244 4245 4246 4247 4248 4249 4250 4251 4252 4253 4254 4255 4256 4257 4258 4259 4260 4261 4262 4263 4264 4265 4266 4267 4268 4269 4270 4271 4272 4273 4274 4275 4276 4277 4278 4279 4280 4281 4282 4283 4284 4285 4286 4287 4288 4289 4290 4291 4292 4293 4294 4295 4296 4297 4298 4299 4300 4301 4302 4303 4304 4305 4306 4307 4308 4309 4310 4311 4312 4313 4314 4315 4316 4317 4318 4319 4320 4321 4322 4323 4324 4325 4326 4327 4328 4329 4330 4331 4332 4333 4334 4335 4336 4337 4338 4339 4340 4341 4342 4343 4344 4345 4346 4347 4348 4349 4350 4351 4352 4353 4354 4355 4356 4357 4358 4359 4360 4361 4362 4363 4364 4365 4366 4367 4368 4369 4370 4371 4372 4373 4374 4375 4376 4377 4378 4379 4380 4381 4382 4383 4384 4385 4386 4387 4388 4389 4390 4391 4392 4393 4394 4395 4396 4397 4398 4399 4400 4401 4402 4403 4404 4405 4406 4407 4408 4409 4410 4411 4412 4413 4414 4415 4416 4417 4418 4419 4420 4421 4422 4423 4424 4425 4426 4427 4428 4429 4430 4431 4432 4433 4434 4435 4436 4437 4438 4439 4440 4441 4442 4443 4444 4445 4446 4447 4448 4449 4450 4451 4452 4453 4454 4455 4456 4457 4458 4459 4460 4461 4462 4463 4464 4465 4466 4467 4468 4469 4470 4471 4472 4473 4474 4475 4476 4477 4478 4479 4480 4481 4482 4483 4484 4485 4486 4487 4488 4489 4490 4491 4492 4493 4494 4495 4496 4497 4498 4499 4500 4501 4502 4503 4504 4505 4506 4507 4508 4509 4510 4511 4512 4513 4514 4515 4516 4517 4518 4519 4520 4521 4522 4523 4524 4525 4526 4527 4528 4529 4530 4531 4532 4533 4534 4535 4536 4537 4538 4539 4540 4541 4542 4543 4544 4545 4546 4547 4548 4549 4550 4551 4552 4553 4554 4555 4556 4557 4558 4559 4560 4561 4562 4563 4564 4565 4566 4567 4568 4569 4570 4571 4572 4573 4574 4575 4576 4577 4578 4579 4580 4581 4582 4583 4584 4585 4586 4587 4588 4589 4590 4591 4592 4593 4594 4595 4596 4597 4598 4599 4600 4601 4602 4603 4604 4605 4606 4607 4608 4609 4610 4611 4612 4613 4614 4615 4616 4617 4618 4619 4620 4621 4622 4623 4624 4625 4626 4627 4628 4629 4630 4631 4632 4633 4634 4635 4636 4637 4638 4639 4640 4641 4642 4643 4644 4645 4646 4647 4648 4649 4650 4651 4652 4653 4654 4655 4656 4657 4658 4659 4660 4661 4662 4663 4664 4665 4666 4667 4668 4669 4670 4671 4672 4673 4674 4675 4676 4677 4678 4679 4680 4681 4682 4683 4684 4685 4686 4687 4688 4689 4690 4691 4692 4693 4694 4695 4696 4697 4698 4699 4700 4701 4702 4703 4704 4705 4706 4707 4708 4709 4710 4711 4712 4713 4714 4715 4716 4717 4718 4719 4720 4721 4722 4723 4724 4725 4726 4727 4728 4729 4730 4731 4732 4733 4734 4735 4736 4737 4738 4739 4740 4741 4742 4743 4744 4745 4746 4747 4748 4749 4750 4751 4752 4753 4754 4755 4756 4757 4758 4759 4760 4761 4762 4763 4764 4765 4766 4767 4768 4769 4770 4771 4772 4773 4774 4775 4776 4777 4778 4779 4780 4781 4782 4783 4784 4785 4786 4787 4788 4789 4790 4791 4792 4793 4794 4795 4796 4797 4798 4799 4800 4801 4802 4803 4804 4805 4806 4807 4808 4809 4810 4811 4812 4813 4814 4815 4816 4817 4818 4819 4820 4821 4822 4823 4824 4825 4826 4827 4828 4829 4830 4831 4832 4833 4834 4835 4836 4837 4838 4839 4840 4841 4842 4843 4844 4845 4846 4847 4848 4849 4850 4851 4852 4853 4854 4855 4856 4857 4858 4859 4860 4861 4862 4863 4864 4865 4866 4867 4868 4869 4870 4871 4872 4873 4874 4875 4876 4877 4878 4879 4880 4881 4882 4883 4884 4885 4886 4887 4888 4889 4890 4891 4892 4893 4894 4895 4896 4897 4898 4899 4900 4901 4902 4903 4904 4905 4906 4907 4908 4909 4910 4911 4912 4913 4914 4915 4916 4917 4918 4919 4920 4921 4922 4923 4924 4925 4926 4927 4928 4929 4930 4931 4932 4933 4934 4935 4936 4937 4938 4939 4940 4941 4942 4943 4944 4945 4946 4947 4948 4949 4950 4951 4952 4953 4954 4955 4956 4957 4958 4959 4960 4961 4962 4963 4964 4965 4966 4967 4968 4969 4970 4971 4972 4973 4974 4975 4976 4977 4978 4979 4980 4981 4982 4983 4984 4985 4986 4987 4988 4989 4990 4991 4992 4993 4994 4995 4996 4997 4998 4999 5000 5001 5002 5003 5004 5005 5006 5007 5008 5009 5010 5011 5012 5013 5014 5015 5016 5017 5018 5019 5020 5021 5022 5023 5024 5025 5026 5027 5028 5029 5030 5031 5032 5033 5034 5035 5036 5037 5038 5039 5040 5041 5042 5043 5044 5045 5046 5047 5048 5049 5050 5051 5052 5053 5054 5055 5056 5057 5058 5059 5060 5061 5062 5063 5064 5065 5066 5067 5068 5069 5070 5071 5072 5073 5074 5075 5076 5077 5078 5079 5080 5081 5082 5083 5084 5085 5086 5087 5088 5089 5090 5091 5092 5093 5094 5095 5096 5097 5098 5099 5100 5101 5102 5103 5104 5105 5106 5107 5108 5109 5110 5111 5112 5113 5114 5115 5116 5117 5118 5119 5120 5121 5122 5123 5124 5125 5126 5127 5128 5129 5130 5131 5132 5133 5134 5135 5136 5137 5138 5139 5140 5141 5142 5143 5144 5145 5146 5147 5148 5149 5150 5151 5152 5153 5154 5155 5156 5157 5158 5159 5160 5161 5162 5163 5164 5165 5166 5167 5168 5169 5170 5171 5172 5173 5174 5175 5176 5177 5178 5179 5180 5181 5182 5183 5184 5185 5186 5187 5188 5189 5190 5191 5192 5193 5194 5195 5196 5197 5198 5199 5200 5201 5202 5203 5204 5205 5206 5207 5208 5209 5210 5211 5212 5213 5214 5215 5216 5217 5218 5219 5220 5221 5222 5223 5224 5225 5226 5227 5228 5229 5230 5231 5232 5233 5234 5235 5236 5237 5238 5239 5240 5241 5242 5243 5244 5245 5246 5247 5248 5249 5250 5251 5252 5253 5254 5255 5256 5257 5258 5259 5260 5261 5262 5263 5264 5265 5266 5267 5268 5269 5270 5271 5272 5273 5274 5275 5276 5277 5278 5279 5280 5281 5282 5283 5284 5285 5286 5287 5288 5289 5290 5291 5292 5293 5294 5295 5296 5297 5298 5299 5300 5301 5302 5303 5304 5305 5306 5307 5308 5309 5310 5311 5312 5313 5314 5315 5316 5317 5318 5319 5320 5321 5322 5323 5324 5325 5326 5327 5328 5329 5330 5331 5332 5333 5334 5335 5336 5337 5338 5339 5340 5341 5342 5343 5344 5345 5346 5347 5348 5349 5350 5351 5352 5353 5354 5355 5356 5357 5358 5359 5360 5361 5362 5363 5364 5365 5366 5367 5368 5369 5370 5371 5372 5373 5374 5375 5376 5377 5378 5379 5380 5381 5382 5383 5384 5385 5386 5387 5388 5389 5390 5391 5392 5393 5394 5395 5396 5397 5398 5399 5400 5401 5402 5403 5404 5405 5406 5407 5408 5409 5410 5411 5412 5413 5414 5415 5416 5417 5418 5419 5420 5421 5422 5423 5424 5425 5426 5427 5428 5429 5430 5431 5432 5433 5434 5435 5436 5437 5438 5439 5440 5441 5442 5443 5444 5445 5446 5447 5448 5449 5450 5451 5452 5453 5454 5455 5456 5457 5458 5459 5460 5461 5462 5463 5464 5465 5466 5467 5468 5469 5470 5471 5472 5473 5474 5475 5476 5477 5478 5479 5480 5481 5482 5483 5484 5485 5486 5487 5488 5489 5490 5491 5492 5493 5494 5495 5496 5497 5498 5499 5500 5501 5502 5503 5504 5505 5506 5507 5508 5509 5510 5511 5512 5513 5514 5515 5516 5517 5518 5519 5520 5521 5522 5523 5524 5525 5526 5527 5528 5529 5530 5531 5532 5533 5534 5535 5536 5537 5538 5539 5540 5541 5542 5543 5544 5545 5546 5547 5548 5549 5550 5551 5552 5553 5554 5555 5556 5557 5558 5559 5560 5561 5562 5563 5564 5565 5566 5567 5568 5569 5570 5571 5572 5573 5574 5575 5576 5577 5578 5579 5580 5581 5582 5583 5584 5585 5586 5587 5588 5589 5590 5591 5592 5593 5594 5595 5596 5597 5598 5599 5600 5601 5602 5603 5604 5605 5606 5607 5608 5609 5610 5611 5612 5613 5614 5615 5616 5617 5618 5619 5620 5621 5622 5623 5624 5625 5626 5627 5628 5629 5630 5631 5632 5633 5634 5635 5636 5637 5638 5639 5640 5641 5642 5643 5644 5645 5646 5647 5648 5649 5650 5651 5652 5653 5654 5655 5656 5657 5658 5659 5660 5661 5662 5663 5664 5665 5666 5667 5668 5669 5670 5671 5672 5673 5674 5675 5676 5677 5678 5679 5680 5681 5682 5683 5684 5685 5686 5687 5688 5689 5690 5691 5692 5693 5694 5695 5696 5697 5698 5699 5700 5701 5702 5703 5704 5705 5706 5707 5708 5709 5710 5711 5712 5713 5714 5715 5716 5717 5718 5719 5720 5721 5722 5723 5724 5725 5726 5727 5728 5729 5730 5731 5732 5733 5734 5735 5736 5737 5738 5739 5740 5741 5742 5743 5744 5745 5746 5747 5748 5749 5750 5751 5752 5753 5754 5755 5756 5757 5758 5759 5760 5761 5762 5763 5764 5765 5766 5767 5768 5769 5770 5771 5772 5773 5774 5775 5776 5777 5778 5779 5780 5781 5782 5783 5784 5785 5786 5787 5788 5789 5790 5791 5792 5793 5794 5795 5796 5797 5798 5799 5800 5801 5802 5803 5804 5805 5806 5807 5808 5809 5810 5811 5812 5813 5814 5815 5816 5817 5818 5819 5820 5821 5822 5823 5824 5825 5826 5827 5828 5829 5830 5831 5832 5833 5834 5835 5836 5837 5838 5839 5840 5841 5842 5843 5844 5845 5846 5847 5848 5849 5850 5851 5852 5853 5854 5855 5856 5857 5858 5859 5860 5861 5862 5863 5864 5865 5866 5867 5868 5869 5870 5871 5872 5873 5874 5875 5876 5877 5878 5879 5880 5881 5882 5883 5884 5885 5886 5887 5888 5889 5890 5891 5892 5893 5894 5895 5896 5897 5898 5899 5900 5901 5902 5903 5904 5905 5906 5907 5908 5909 5910 5911 5912 5913 5914 5915 5916 5917 5918 5919 5920 5921 5922 5923 5924 5925 5926 5927 5928 5929 5930 5931 5932 5933 5934 5935 5936 5937 5938 5939 5940 5941 5942 5943 5944 5945 5946 5947 5948 5949 5950 5951 5952 5953 5954 5955 5956 5957 5958 5959 5960 5961 5962 5963 5964 5965 5966 5967 5968 5969 5970 5971 5972 5973 5974 5975 5976 5977 5978 5979 5980 5981 5982 5983 5984 5985 5986 5987 5988 5989 5990 5991 5992 5993 5994 5995 5996 5997 5998 5999 6000 6001 6002 6003 6004 6005 6006 6007 6008 6009 6010 6011 6012 6013 6014 6015 6016 6017 6018 6019 6020 6021 6022 6023 6024 6025 6026 6027 6028 6029 6030 6031 6032 6033 6034 6035 6036 6037 6038 6039 6040 6041 6042 6043 6044 6045 6046 6047 6048 6049 6050 6051 6052 6053 6054 6055 6056 6057 6058 6059 6060 6061 6062 6063 6064 6065 6066 6067 6068 6069 6070 6071 6072 6073 6074 6075 6076 6077 6078 6079 6080 6081 6082 6083 6084 6085 6086 6087 6088 6089 6090 6091 6092 6093 6094 6095 6096 6097 6098 6099 6100 6101 6102 6103 6104 6105 6106 6107 6108 6109 6110 6111 6112 6113 6114 6115 6116 6117 6118 6119 6120 6121 6122 6123 6124 6125 6126 6127 6128 6129 6130 6131 6132 6133 6134 6135 6136 6137 6138 6139 6140 6141 6142 6143 6144 6145 6146 6147 6148 6149 6150 6151 6152 6153 6154 6155 6156 6157 6158 6159 6160 6161 6162 6163 6164 6165 6166 6167 6168 6169 6170 6171 6172 6173 6174 6175 6176 6177 6178 6179 6180 6181 6182 6183 6184 6185 6186 6187 6188 6189 6190 6191 6192 6193 6194 6195 6196 6197 6198 6199 6200 6201 6202 6203 6204 6205 6206 6207 6208 6209 6210 6211 6212 6213 6214 6215 6216 6217 6218 6219 6220 6221 6222 6223 6224 6225 6226 6227 6228 6229 6230 6231 6232 6233 6234 6235 6236 6237 6238 6239 6240 6241 6242 6243 6244 6245 6246 6247 6248 6249 6250 6251 6252 6253 6254 6255 6256 6257 6258 6259 6260 6261 6262 6263 6264 6265 6266 6267 6268 6269 6270 6271 6272 6273 6274 6275 6276 6277 6278 6279 6280 6281 6282 6283 6284 6285 6286 6287 6288 6289 6290 6291 6292 6293 6294 6295 6296 6297 6298 6299 6300 6301 6302 6303 6304 6305 6306 6307 6308 6309 6310 6311 6312 6313 6314 6315 6316 6317 6318 6319 6320 6321 6322 6323 6324 6325 6326 6327 6328 6329 6330 6331 6332 6333 6334 6335 6336 6337 6338 6339 6340 6341 6342 6343 6344 6345 6346 6347 6348 6349 6350 6351 6352 6353 6354 6355 6356 6357 6358 6359 6360 6361 6362 6363 6364 6365 6366 6367 6368 6369 6370 6371 6372 6373 6374 6375 6376 6377 6378 6379 6380 6381 6382 6383 6384 6385 6386 6387 6388 6389 6390 6391 6392 6393 6394 6395 6396 6397 6398 6399 6400 6401 6402 6403 6404 6405 6406 6407 6408 6409 6410 6411 6412 6413 6414 6415 6416 6417 6418 6419 6420 6421 6422 6423 6424 6425 6426 6427 6428 6429 6430 6431 6432 6433 6434 6435 6436 6437 6438 6439 6440 6441 6442 6443 6444 6445 6446 6447 6448 6449 6450 6451 6452 6453 6454 6455 6456 6457 6458 6459 6460 6461 6462 6463 6464 6465 6466 6467 6468 6469 6470 6471 6472 6473 6474 6475 6476 6477 6478 6479 6480 6481 6482 6483 6484 6485 6486 6487 6488 6489 6490 6491 6492 6493 6494 6495 6496 6497 6498 6499 6500 6501 6502 6503 6504 6505 6506 6507 6508 6509 6510 6511 6512 6513 6514 6515 6516 6517 6518 6519 6520 6521 6522 6523 6524 6525 6526 6527 6528 6529 6530 6531 6532 6533 6534 6535 6536 6537 6538 6539 6540 6541 6542 6543 6544 6545 6546 6547 6548 6549 6550 6551 6552 6553 6554 6555 6556 6557 6558 6559 6560 6561 6562 6563 6564 6565 6566 6567 6568 6569 6570 6571 6572 6573 6574 6575 6576 6577 6578 6579 6580 6581 6582 6583 6584 6585 6586 6587 6588 6589 6590 6591 6592 6593 6594 6595 6596 6597 6598 6599 6600 6601 6602 6603 6604 6605 6606 6607 6608 6609 6610 6611 6612 6613 6614 6615 6616 6617 6618 6619 6620 6621 6622 6623 6624 6625 6626 6627 6628 6629 6630 6631 6632 6633 6634 6635 6636 6637 6638 6639 6640 6641 6642 6643 6644 6645 6646 6647 6648 6649 6650 6651 6652 6653 6654 6655 6656 6657 6658 6659 6660 6661 6662 6663 6664 6665 6666 6667 6668 6669 6670 6671 6672 6673 6674 6675 6676 6677 6678 6679 6680 6681 6682 6683 6684 6685 6686 6687 6688 6689 6690 6691 6692 6693 6694 6695 6696 6697 6698 6699 6700 6701 6702 6703 6704 6705 6706 6707 6708 6709 6710 6711 6712 6713 6714 6715 6716 6717 6718 6719 6720 6721 6722 6723 6724 6725 6726 6727 6728 6729 6730 6731 6732 6733 6734 6735 6736 6737 6738 6739 6740 6741 6742 6743 6744 6745 6746 6747 6748 6749 6750 6751 6752 6753 6754 6755 6756 6757 6758 6759 6760 6761 6762 6763 6764 6765 6766 6767 6768 6769 6770 6771 6772 6773 6774 6775 6776 6777 6778 6779 6780 6781 6782 6783 6784 6785 6786 6787 6788 6789 6790 6791 6792 6793 6794 6795 6796 6797 6798 6799 6800 6801 6802 6803 6804 6805
diff --git a/CMakeLists.txt b/CMakeLists.txt
index ad86399..f725d59 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -20,6 +20,7 @@ include(CheckLibraryExists)
include(CheckIncludeFiles)
include(CheckIncludeFile)
include(CheckSymbolExists)
+include(CheckCSourceCompiles)
include(CheckCSourceRuns)
include(CheckCCompilerFlag)
include(CheckTypeSize)
@@ -324,9 +325,14 @@ set_option(VIDEO_COCOA "Use Cocoa video driver" ${APPLE})
set_option(DIRECTX "Use DirectX for Windows audio/video" ${WINDOWS})
set_option(RENDER_D3D "Enable the Direct3D render driver" ${WINDOWS})
set_option(VIDEO_VIVANTE "Use Vivante EGL video driver" ${UNIX_SYS})
+dep_option(VIDEO_VULKAN "Enable Vulkan surface creation" ON "ANDROID OR APPLE OR LINUX OR WINDOWS" OFF)
set_option(VIDEO_KMSDRM "Use KMS DRM video driver" ${UNIX_SYS})
dep_option(KMSDRM_SHARED "Dynamically load KMS DRM support" ON "VIDEO_KMSDRM" OFF)
+if(VIDEO_VULKAN)
+ set(VULKAN_SDK $ENV{VULKAN_SDK} CACHE PATH "Location of Vulkan headers' grandparent, e.g. /foo when headers are in /foo/include/vulkan.")
+endif()
+
# TODO: We should (should we?) respect cmake's ${BUILD_SHARED_LIBS} flag here
# The options below are for compatibility to configure's default behaviour.
set(SDL_SHARED ${SDL_SHARED_ENABLED_BY_DEFAULT} CACHE BOOL "Build a shared version of the library")
@@ -855,6 +861,22 @@ if(ANDROID)
find_library(OpenGLES2_LIBRARY GLESv2)
list(APPEND EXTRA_LIBS ${OpenGLES1_LIBRARY} ${OpenGLES2_LIBRARY})
endif()
+
+ CHECK_C_SOURCE_COMPILES("
+ #if defined(__ANDROID__) && defined(__ARM_EABI__) && !defined(__ARM_ARCH_7A__)
+ #error Vulkan doesn't work on this configuration
+ #endif
+ int main()
+ {
+ return 0;
+ }
+ " VULKAN_PASSED_ANDROID_CHECKS)
+ if(NOT VULKAN_PASSED_ANDROID_CHECKS)
+ set(VIDEO_VULKAN OFF)
+ message(STATUS "Vulkan doesn't work on this configuration")
+ else()
+ CheckVulkanHeaders()
+ endif()
endif()
CheckPTHREAD()
@@ -1020,6 +1042,7 @@ elseif(UNIX AND NOT APPLE AND NOT ANDROID)
check_include_file("fcitx/frontend.h" HAVE_FCITX_FRONTEND_H)
+ CheckVulkanHeaders()
endif()
if(INPUT_TSLIB)
@@ -1278,6 +1301,8 @@ elseif(WINDOWS)
set(SDL_VIDEO_RENDER_OGL_ES2 1)
set(HAVE_VIDEO_OPENGLES TRUE)
endif()
+
+ CheckVulkanHeaders()
endif()
if(SDL_JOYSTICK)
@@ -1419,6 +1444,13 @@ elseif(APPLE)
endif()
# Actually load the frameworks at the end so we don't duplicate include.
+ if (VIDEO_VULKAN)
+ CheckVulkanHeaders()
+ if(HAVE_VULKAN_H)
+ find_library(QUARTZCORE QuartzCore)
+ list(APPEND EXTRA_LIBS ${QUARTZCORE})
+ endif()
+ endif()
if(SDL_FRAMEWORK_COREVIDEO)
find_library(COREVIDEO CoreVideo)
list(APPEND EXTRA_LIBS ${COREVIDEO})
@@ -1498,6 +1530,10 @@ elseif(HAIKU)
CheckPTHREAD()
endif()
+if(VIDEO_VULKAN AND HAVE_VULKAN_H AND (NOT APPLE OR QUARTZCORE))
+ set(SDL_VIDEO_VULKAN_SURFACE 1)
+endif()
+
# Dummies
# configure.in does it differently:
# if not have X
diff --git a/Makefile.in b/Makefile.in
index f6d12cd..fe56652 100644
--- a/Makefile.in
+++ b/Makefile.in
@@ -112,6 +112,7 @@ HDRS = \
SDL_types.h \
SDL_version.h \
SDL_video.h \
+ SDL_vulkan.h \
begin_code.h \
close_code.h
diff --git a/VisualC/SDL/SDL_VS2008.vcproj b/VisualC/SDL/SDL_VS2008.vcproj
index fd90b81..a5ea1d0 100644
--- a/VisualC/SDL/SDL_VS2008.vcproj
+++ b/VisualC/SDL/SDL_VS2008.vcproj
@@ -52,7 +52,7 @@
Name="VCCLCompilerTool"
Optimization="0"
InlineFunctionExpansion="1"
- AdditionalIncludeDirectories="$(SolutionDir)/../include"
+ AdditionalIncludeDirectories=""$(SolutionDir)/../include";"$(VULKAN_SDK)/include""
AdditionalUsingDirectories=""
PreprocessorDefinitions="_DEBUG;_WINDOWS"
RuntimeLibrary="2"
@@ -135,7 +135,7 @@
Name="VCCLCompilerTool"
Optimization="0"
InlineFunctionExpansion="1"
- AdditionalIncludeDirectories="$(SolutionDir)/../include"
+ AdditionalIncludeDirectories=""$(SolutionDir)/../include";"$(VULKAN_SDK)/include""
AdditionalUsingDirectories=""
PreprocessorDefinitions="_DEBUG;_WINDOWS"
RuntimeLibrary="2"
@@ -216,7 +216,7 @@
<Tool
Name="VCCLCompilerTool"
InlineFunctionExpansion="1"
- AdditionalIncludeDirectories="$(SolutionDir)/../include"
+ AdditionalIncludeDirectories=""$(SolutionDir)/../include";"$(VULKAN_SDK)/include""
AdditionalUsingDirectories=""
PreprocessorDefinitions="NDEBUG;_WINDOWS"
RuntimeLibrary="2"
@@ -299,7 +299,7 @@
<Tool
Name="VCCLCompilerTool"
InlineFunctionExpansion="1"
- AdditionalIncludeDirectories="$(SolutionDir)/../include"
+ AdditionalIncludeDirectories=""$(SolutionDir)/../include";"$(VULKAN_SDK)/include""
AdditionalUsingDirectories=""
PreprocessorDefinitions="NDEBUG;_WINDOWS"
RuntimeLibrary="2"
@@ -644,6 +644,10 @@
RelativePath="..\..\include\SDL_video.h"
>
</File>
+ <File
+ RelativePath="..\..\include\SDL_vulkan.h"
+ >
+ </File>
</Filter>
<File
RelativePath="..\..\src\events\blank_cursor.h"
@@ -878,6 +882,14 @@
>
</File>
<File
+ RelativePath="..\..\src\SDL_dataqueue.c"
+ >
+ </File>
+ <File
+ RelativePath="..\..\src\SDL_dataqueue.h"
+ >
+ </File>
+ <File
RelativePath="..\..\src\haptic\windows\SDL_dinputhaptic.c"
>
</File>
@@ -1314,6 +1326,22 @@
>
</File>
<File
+ RelativePath="..\..\src\video\SDL_vulkan_internal.h"
+ >
+ </File>
+ <File
+ RelativePath="..\..\src\video\SDL_vulkan_utils.c"
+ >
+ </File>
+ <File
+ RelativePath="..\..\src\audio\wasapi\SDL_wasapi.c"
+ >
+ </File>
+ <File
+ RelativePath="..\..\src\audio\wasapi\SDL_wasapi.h"
+ >
+ </File>
+ <File
RelativePath="..\..\src\audio\SDL_wave.c"
>
</File>
@@ -1438,6 +1466,14 @@
>
</File>
<File
+ RelativePath="..\..\src\video\windows\SDL_windowsvulkan.c"
+ >
+ </File>
+ <File
+ RelativePath="..\..\src\video\windows\SDL_windowsvulkan.h"
+ >
+ </File>
+ <File
RelativePath="..\..\src\video\windows\SDL_windowswindow.c"
>
</File>
diff --git a/VisualC/SDL_VS2008.sln b/VisualC/SDL_VS2008.sln
index 5398bfb..83c3ccf 100644
--- a/VisualC/SDL_VS2008.sln
+++ b/VisualC/SDL_VS2008.sln
@@ -48,6 +48,8 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "controllermap", "tests\cont
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "tests", "tests", "{D69D5741-611F-4E14-8541-1FEE94F50B5A}"
EndProject
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "testvulkan", "tests\testvulkan\testvulkan_VS2008.vcproj", "{0D604DFD-AAB6-442C-9368-F91A344146AB}"
+EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Win32 = Debug|Win32
@@ -240,6 +242,14 @@ Global
{55812185-D13C-4022-9C81-32E0F4A08306}.Release|Win32.Build.0 = Release|Win32
{55812185-D13C-4022-9C81-32E0F4A08306}.Release|x64.ActiveCfg = Release|x64
{55812185-D13C-4022-9C81-32E0F4A08306}.Release|x64.Build.0 = Release|x64
+ {0D604DFD-AAB6-442C-9368-F91A344146AB}.Debug|Win32.ActiveCfg = Debug|Win32
+ {0D604DFD-AAB6-442C-9368-F91A344146AB}.Debug|Win32.Build.0 = Debug|Win32
+ {0D604DFD-AAB6-442C-9368-F91A344146AB}.Debug|x64.ActiveCfg = Debug|x64
+ {0D604DFD-AAB6-442C-9368-F91A344146AB}.Debug|x64.Build.0 = Debug|x64
+ {0D604DFD-AAB6-442C-9368-F91A344146AB}.Release|Win32.ActiveCfg = Release|Win32
+ {0D604DFD-AAB6-442C-9368-F91A344146AB}.Release|Win32.Build.0 = Release|Win32
+ {0D604DFD-AAB6-442C-9368-F91A344146AB}.Release|x64.ActiveCfg = Release|x64
+ {0D604DFD-AAB6-442C-9368-F91A344146AB}.Release|x64.Build.0 = Release|x64
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
@@ -265,5 +275,6 @@ Global
{E9558DFE-1961-4DD4-B09B-DD0EEFD5C315} = {D69D5741-611F-4E14-8541-1FEE94F50B5A}
{55812185-D13C-4022-9C81-32E0F4A08306} = {D69D5741-611F-4E14-8541-1FEE94F50B5A}
{26828762-C95D-4637-9CB1-7F0979523813} = {D69D5741-611F-4E14-8541-1FEE94F50B5A}
+ {0D604DFD-AAB6-442C-9368-F91A344146AB} = {D69D5741-611F-4E14-8541-1FEE94F50B5A}
EndGlobalSection
EndGlobal
diff --git a/VisualC/tests/testvulkan/testvulkan_VS2008.vcproj b/VisualC/tests/testvulkan/testvulkan_VS2008.vcproj
new file mode 100644
index 0000000..f8da23f
--- /dev/null
+++ b/VisualC/tests/testvulkan/testvulkan_VS2008.vcproj
@@ -0,0 +1,355 @@
+<?xml version="1.0" encoding="Windows-1252"?>
+<VisualStudioProject
+ ProjectType="Visual C++"
+ Version="9.00"
+ Name="testvulkan"
+ ProjectGUID="{0D604DFD-AAB6-442C-9368-F91A344146AB}"
+ RootNamespace="testvulkan"
+ TargetFrameworkVersion="131072"
+ >
+ <Platforms>
+ <Platform
+ Name="Win32"
+ />
+ <Platform
+ Name="x64"
+ />
+ </Platforms>
+ <ToolFiles>
+ </ToolFiles>
+ <Configurations>
+ <Configuration
+ Name="Debug|Win32"
+ OutputDirectory="$(SolutionDir)$(PlatformName)\$(ConfigurationName)"
+ IntermediateDirectory="$(PlatformName)\$(ConfigurationName)\"
+ ConfigurationType="1"
+ InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC70.vsprops"
+ UseOfMFC="0"
+ ATLMinimizesCRunTimeLibraryUsage="false"
+ >
+ <Tool
+ Name="VCPreBuildEventTool"
+ />
+ <Tool
+ Name="VCCustomBuildTool"
+ />
+ <Tool
+ Name="VCXMLDataGeneratorTool"
+ />
+ <Tool
+ Name="VCWebServiceProxyGeneratorTool"
+ />
+ <Tool
+ Name="VCMIDLTool"
+ PreprocessorDefinitions="_DEBUG"
+ MkTypLibCompatible="true"
+ SuppressStartupBanner="true"
+ TargetEnvironment="1"
+ TypeLibraryName=".\Debug/testvulkan.tlb"
+ />
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="0"
+ AdditionalIncludeDirectories=""$(SolutionDir)/../include";"$(VULKAN_SDK)/include""
+ AdditionalUsingDirectories=""
+ PreprocessorDefinitions="_DEBUG,WIN32,_WINDOWS,HAVE_OPENGL"
+ RuntimeLibrary="2"
+ WarningLevel="3"
+ DebugInformationFormat="1"
+ />
+ <Tool
+ Name="VCManagedResourceCompilerTool"
+ />
+ <Tool
+ Name="VCResourceCompilerTool"
+ PreprocessorDefinitions="_DEBUG"
+ Culture="1033"
+ />
+ <Tool
+ Name="VCPreLinkEventTool"
+ />
+ <Tool
+ Name="VCLinkerTool"
+ GenerateDebugInformation="true"
+ SubSystem="2"
+ />
+ <Tool
+ Name="VCALinkTool"
+ />
+ <Tool
+ Name="VCManifestTool"
+ />
+ <Tool
+ Name="VCXDCMakeTool"
+ />
+ <Tool
+ Name="VCBscMakeTool"
+ />
+ <Tool
+ Name="VCFxCopTool"
+ />
+ <Tool
+ Name="VCAppVerifierTool"
+ />
+ <Tool
+ Name="VCPostBuildEventTool"
+ />
+ </Configuration>
+ <Configuration
+ Name="Debug|x64"
+ OutputDirectory="$(SolutionDir)$(PlatformName)\$(ConfigurationName)"
+ IntermediateDirectory="$(PlatformName)\$(ConfigurationName)\"
+ ConfigurationType="1"
+ InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC70.vsprops"
+ UseOfMFC="0"
+ ATLMinimizesCRunTimeLibraryUsage="false"
+ >
+ <Tool
+ Name="VCPreBuildEventTool"
+ />
+ <Tool
+ Name="VCCustomBuildTool"
+ />
+ <Tool
+ Name="VCXMLDataGeneratorTool"
+ />
+ <Tool
+ Name="VCWebServiceProxyGeneratorTool"
+ />
+ <Tool
+ Name="VCMIDLTool"
+ PreprocessorDefinitions="_DEBUG"
+ MkTypLibCompatible="true"
+ SuppressStartupBanner="true"
+ TargetEnvironment="3"
+ TypeLibraryName=".\Debug/testvulkan.tlb"
+ />
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="0"
+ AdditionalIncludeDirectories=""$(SolutionDir)/../include";"$(VULKAN_SDK)/include""
+ AdditionalUsingDirectories=""
+ PreprocessorDefinitions="_DEBUG,WIN32,_WINDOWS,HAVE_OPENGL"
+ RuntimeLibrary="3"
+ WarningLevel="3"
+ DebugInformationFormat="1"
+ />
+ <Tool
+ Name="VCManagedResourceCompilerTool"
+ />
+ <Tool
+ Name="VCResourceCompilerTool"
+ PreprocessorDefinitions="_DEBUG"
+ Culture="1033"
+ />
+ <Tool
+ Name="VCPreLinkEventTool"
+ />
+ <Tool
+ Name="VCLinkerTool"
+ GenerateDebugInformation="true"
+ SubSystem="2"
+ />
+ <Tool
+ Name="VCALinkTool"
+ />
+ <Tool
+ Name="VCManifestTool"
+ />
+ <Tool
+ Name="VCXDCMakeTool"
+ />
+ <Tool
+ Name="VCBscMakeTool"
+ />
+ <Tool
+ Name="VCFxCopTool"
+ />
+ <Tool
+ Name="VCAppVerifierTool"
+ />
+ <Tool
+ Name="VCPostBuildEventTool"
+ />
+ </Configuration>
+ <Configuration
+ Name="Release|Win32"
+ OutputDirectory="$(SolutionDir)$(PlatformName)\$(ConfigurationName)"
+ IntermediateDirectory="$(PlatformName)\$(ConfigurationName)\"
+ ConfigurationType="1"
+ InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC70.vsprops"
+ UseOfMFC="0"
+ ATLMinimizesCRunTimeLibraryUsage="false"
+ >
+ <Tool
+ Name="VCPreBuildEventTool"
+ />
+ <Tool
+ Name="VCCustomBuildTool"
+ />
+ <Tool
+ Name="VCXMLDataGeneratorTool"
+ />
+ <Tool
+ Name="VCWebServiceProxyGeneratorTool"
+ />
+ <Tool
+ Name="VCMIDLTool"
+ PreprocessorDefinitions="NDEBUG"
+ MkTypLibCompatible="true"
+ SuppressStartupBanner="true"
+ TargetEnvironment="1"
+ TypeLibraryName=".\Release/testvulkan.tlb"
+ />
+ <Tool
+ Name="VCCLCompilerTool"
+ AdditionalIncludeDirectories=""$(SolutionDir)/../include";"$(VULKAN_SDK)/include""
+ AdditionalUsingDirectories=""
+ PreprocessorDefinitions="NDEBUG,WIN32,_WINDOWS,HAVE_OPENGL"
+ RuntimeLibrary="2"
+ WarningLevel="3"
+ />
+ <Tool
+ Name="VCManagedResourceCompilerTool"
+ />
+ <Tool
+ Name="VCResourceCompilerTool"
+ PreprocessorDefinitions="NDEBUG"
+ Culture="1033"
+ />
+ <Tool
+ Name="VCPreLinkEventTool"
+ />
+ <Tool
+ Name="VCLinkerTool"
+ SubSystem="2"
+ />
+ <Tool
+ Name="VCALinkTool"
+ />
+ <Tool
+ Name="VCManifestTool"
+ />
+ <Tool
+ Name="VCXDCMakeTool"
+ />
+ <Tool
+ Name="VCBscMakeTool"
+ />
+ <Tool
+ Name="VCFxCopTool"
+ />
+ <Tool
+ Name="VCAppVerifierTool"
+ />
+ <Tool
+ Name="VCPostBuildEventTool"
+ />
+ </Configuration>
+ <Configuration
+ Name="Release|x64"
+ OutputDirectory="$(SolutionDir)$(PlatformName)\$(ConfigurationName)"
+ IntermediateDirectory="$(PlatformName)\$(ConfigurationName)\"
+ ConfigurationType="1"
+ InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC70.vsprops"
+ UseOfMFC="0"
+ ATLMinimizesCRunTimeLibraryUsage="false"
+ >
+ <Tool
+ Name="VCPreBuildEventTool"
+ />
+ <Tool
+ Name="VCCustomBuildTool"
+ />
+ <Tool
+ Name="VCXMLDataGeneratorTool"
+ />
+ <Tool
+ Name="VCWebServiceProxyGeneratorTool"
+ />
+ <Tool
+ Name="VCMIDLTool"
+ PreprocessorDefinitions="NDEBUG"
+ MkTypLibCompatible="true"
+ SuppressStartupBanner="true"
+ TargetEnvironment="3"
+ TypeLibraryName=".\Release/testvulkan.tlb"
+ />
+ <Tool
+ Name="VCCLCompilerTool"
+ AdditionalIncludeDirectories=""$(SolutionDir)/../include";"$(VULKAN_SDK)/include""
+ AdditionalUsingDirectories=""
+ PreprocessorDefinitions="NDEBUG,WIN32,_WINDOWS,HAVE_OPENGL"
+ RuntimeLibrary="2"
+ WarningLevel="3"
+ />
+ <Tool
+ Name="VCManagedResourceCompilerTool"
+ />
+ <Tool
+ Name="VCResourceCompilerTool"
+ PreprocessorDefinitions="NDEBUG"
+ Culture="1033"
+ />
+ <Tool
+ Name="VCPreLinkEventTool"
+ />
+ <Tool
+ Name="VCLinkerTool"
+ SubSystem="2"
+ />
+ <Tool
+ Name="VCALinkTool"
+ />
+ <Tool
+ Name="VCManifestTool"
+ />
+ <Tool
+ Name="VCXDCMakeTool"
+ />
+ <Tool
+ Name="VCBscMakeTool"
+ />
+ <Tool
+ Name="VCFxCopTool"
+ />
+ <Tool
+ Name="VCAppVerifierTool"
+ />
+ <Tool
+ Name="VCPostBuildEventTool"
+ />
+ </Configuration>
+ </Configurations>
+ <References>
+ <ProjectReference
+ ReferencedProjectIdentifier="{81CE8DAF-EBB2-4761-8E45-B71ABCCA8C68}"
+ CopyLocal="false"
+ CopyLocalDependencies="false"
+ CopyLocalSatelliteAssemblies="false"
+ RelativePathToProject=".\SDL\SDL_VS2008.vcproj"
+ />
+ <ProjectReference
+ ReferencedProjectIdentifier="{DA956FD3-E142-46F2-9DD5-C78BEBB56B7A}"
+ CopyLocal="false"
+ CopyLocalDependencies="false"
+ CopyLocalSatelliteAssemblies="false"
+ RelativePathToProject=".\SDLmain\SDLmain_VS2008.vcproj"
+ />
+ <ProjectReference
+ ReferencedProjectIdentifier="{DA956FD3-E143-46F2-9FE5-C77BEBC56B1A}"
+ CopyLocal="false"
+ CopyLocalDependencies="false"
+ CopyLocalSatelliteAssemblies="false"
+ RelativePathToProject=".\SDLtest\SDLtest_VS2008.vcproj"
+ />
+ </References>
+ <Files>
+ <File
+ RelativePath="..\..\..\test\testvulkan.c"
+ >
+ </File>
+ </Files>
+ <Globals>
+ </Globals>
+</VisualStudioProject>
diff --git a/Xcode-iOS/SDL/SDL.xcodeproj/project.pbxproj b/Xcode-iOS/SDL/SDL.xcodeproj/project.pbxproj
index d1bacc1..19c4727 100755
--- a/Xcode-iOS/SDL/SDL.xcodeproj/project.pbxproj
+++ b/Xcode-iOS/SDL/SDL.xcodeproj/project.pbxproj
@@ -67,6 +67,13 @@
04F7808512FB753F00FC43C0 /* SDL_nullframebuffer.c in Sources */ = {isa = PBXBuildFile; fileRef = 04F7808312FB753F00FC43C0 /* SDL_nullframebuffer.c */; };
04FFAB8B12E23B8D00BA343D /* SDL_atomic.c in Sources */ = {isa = PBXBuildFile; fileRef = 04FFAB8912E23B8D00BA343D /* SDL_atomic.c */; };
04FFAB8C12E23B8D00BA343D /* SDL_spinlock.c in Sources */ = {isa = PBXBuildFile; fileRef = 04FFAB8A12E23B8D00BA343D /* SDL_spinlock.c */; };
+ 4D7516FB1EE1C28A00820EEA /* SDL_uikitmetalview.m in Sources */ = {isa = PBXBuildFile; fileRef = 4D7516F81EE1C28A00820EEA /* SDL_uikitmetalview.m */; };
+ 4D7516FC1EE1C28A00820EEA /* SDL_uikitvulkan.h in Headers */ = {isa = PBXBuildFile; fileRef = 4D7516F91EE1C28A00820EEA /* SDL_uikitvulkan.h */; };
+ 4D7516FD1EE1C28A00820EEA /* SDL_uikitvulkan.m in Sources */ = {isa = PBXBuildFile; fileRef = 4D7516FA1EE1C28A00820EEA /* SDL_uikitvulkan.m */; };
+ 4D7516FF1EE1C5B400820EEA /* SDL_vulkan.h in Headers */ = {isa = PBXBuildFile; fileRef = 4D7516FE1EE1C5B400820EEA /* SDL_vulkan.h */; };
+ 4D75171A1EE1D32200820EEA /* SDL_uikitmetalview.h in Headers */ = {isa = PBXBuildFile; fileRef = 4D7517191EE1D32200820EEA /* SDL_uikitmetalview.h */; };
+ 4D75171F1EE1D98200820EEA /* SDL_vulkan_internal.h in Headers */ = {isa = PBXBuildFile; fileRef = 4D75171D1EE1D98200820EEA /* SDL_vulkan_internal.h */; };
+ 4D7517201EE1D98200820EEA /* SDL_vulkan_utils.c in Sources */ = {isa = PBXBuildFile; fileRef = 4D75171E1EE1D98200820EEA /* SDL_vulkan_utils.c */; };
566726451DF72CF5001DD3DB /* SDL_dataqueue.c in Sources */ = {isa = PBXBuildFile; fileRef = 566726431DF72CF5001DD3DB /* SDL_dataqueue.c */; };
566726461DF72CF5001DD3DB /* SDL_dataqueue.h in Headers */ = {isa = PBXBuildFile; fileRef = 566726441DF72CF5001DD3DB /* SDL_dataqueue.h */; };
56A6702E18565E450007D20F /* SDL_internal.h in Headers */ = {isa = PBXBuildFile; fileRef = 56A6702D18565E450007D20F /* SDL_internal.h */; };
@@ -364,6 +371,13 @@
04F7808312FB753F00FC43C0 /* SDL_nullframebuffer.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = SDL_nullframebuffer.c; sourceTree = "<group>"; };
04FFAB8912E23B8D00BA343D /* SDL_atomic.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = SDL_atomic.c; sourceTree = "<group>"; };
04FFAB8A12E23B8D00BA343D /* SDL_spinlock.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = SDL_spinlock.c; sourceTree = "<group>"; };
+ 4D7516F81EE1C28A00820EEA /* SDL_uikitmetalview.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SDL_uikitmetalview.m; sourceTree = "<group>"; };
+ 4D7516F91EE1C28A00820EEA /* SDL_uikitvulkan.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SDL_uikitvulkan.h; sourceTree = "<group>"; };
+ 4D7516FA1EE1C28A00820EEA /* SDL_uikitvulkan.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SDL_uikitvulkan.m; sourceTree = "<group>"; };
+ 4D7516FE1EE1C5B400820EEA /* SDL_vulkan.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SDL_vulkan.h; sourceTree = "<group>"; };
+ 4D7517191EE1D32200820EEA /* SDL_uikitmetalview.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SDL_uikitmetalview.h; sourceTree = "<group>"; };
+ 4D75171D1EE1D98200820EEA /* SDL_vulkan_internal.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SDL_vulkan_internal.h; sourceTree = "<group>"; };
+ 4D75171E1EE1D98200820EEA /* SDL_vulkan_utils.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = SDL_vulkan_utils.c; sourceTree = "<group>"; };
566726431DF72CF5001DD3DB /* SDL_dataqueue.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = SDL_dataqueue.c; path = ../../src/SDL_dataqueue.c; sourceTree = "<group>"; };
566726441DF72CF5001DD3DB /* SDL_dataqueue.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = SDL_dataqueue.h; path = ../../src/SDL_dataqueue.h; sourceTree = "<group>"; };
56A6702D18565E450007D20F /* SDL_internal.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = SDL_internal.h; path = ../../src/SDL_internal.h; sourceTree = "<group>"; };
@@ -759,6 +773,8 @@
FD689F0D0E26E5D900F90B21 /* SDL_uikitevents.m */,
AABCC3921640643D00AB8930 /* SDL_uikitmessagebox.h */,
AABCC3931640643D00AB8930 /* SDL_uikitmessagebox.m */,
+ 4D7517191EE1D32200820EEA /* SDL_uikitmetalview.h */,
+ 4D7516F81EE1C28A00820EEA /* SDL_uikitmetalview.m */,
AA126AD21617C5E6005ABC8F /* SDL_uikitmodes.h */,
AA126AD31617C5E6005ABC8F /* SDL_uikitmodes.m */,
FD689F0E0E26E5D900F90B21 /* SDL_uikitopengles.h */,
@@ -771,6 +787,8 @@
FD689F130E26E5D900F90B21 /* SDL_uikitview.m */,
93CB792213FC5E5200BD3E05 /* SDL_uikitviewcontroller.h */,
93CB792513FC5F5300BD3E05 /* SDL_uikitviewcontroller.m */,
+ 4D7516F91EE1C28A00820EEA /* SDL_uikitvulkan.h */,
+ 4D7516FA1EE1C28A00820EEA /* SDL_uikitvulkan.m */,
FD689F140E26E5D900F90B21 /* SDL_uikitwindow.h */,
FD689F150E26E5D900F90B21 /* SDL_uikitwindow.m */,
);
@@ -852,6 +870,7 @@
AA7558941595D55500BBD41B /* SDL_types.h */,
AA7558951595D55500BBD41B /* SDL_version.h */,
AA7558961595D55500BBD41B /* SDL_video.h */,
+ 4D7516FE1EE1C5B400820EEA /* SDL_vulkan.h */,
);
name = "Public Headers";
path = ../../include;
@@ -1041,6 +1060,8 @@
FDA683190DF2374E00F98A1A /* SDL_surface.c */,
FDA6831A0DF2374E00F98A1A /* SDL_sysvideo.h */,
FDA6831B0DF2374E00F98A1A /* SDL_video.c */,
+ 4D75171D1EE1D98200820EEA /* SDL_vulkan_internal.h */,
+ 4D75171E1EE1D98200820EEA /* SDL_vulkan_utils.c */,
);
name = video;
path = ../../src/video;
@@ -1067,6 +1088,8 @@
buildActionMask = 2147483647;
files = (
FDA6844E0DF2374E00F98A1A /* SDL_blit.h in Headers */,
+ 4D75171A1EE1D32200820EEA /* SDL_uikitmetalview.h in Headers */,
+ 4D75171F1EE1D98200820EEA /* SDL_vulkan_internal.h in Headers */,
FDA684530DF2374E00F98A1A /* SDL_blit_auto.h in Headers */,
FDA684550DF2374E00F98A1A /* SDL_blit_copy.h in Headers */,
FDA6845D0DF2374E00F98A1A /* SDL_pixels_c.h in Headers */,
@@ -1159,8 +1182,10 @@
AA7558C61595D55500BBD41B /* SDL_touch.h in Headers */,
AA7558C71595D55500BBD41B /* SDL_types.h in Headers */,
AA7558C81595D55500BBD41B /* SDL_version.h in Headers */,
+ 4D7516FF1EE1C5B400820EEA /* SDL_vulkan.h in Headers */,
AA7558C91595D55500BBD41B /* SDL_video.h in Headers */,
AA7558CA1595D55500BBD41B /* SDL.h in Headers */,
+ 4D7516FC1EE1C28A00820EEA /* SDL_uikitvulkan.h in Headers */,
AA126AD41617C5E7005ABC8F /* SDL_uikitmodes.h in Headers */,
AA704DD6162AA90A0076D1C1 /* SDL_dropevents_c.h in Headers */,
AA9FF9511637C6E5000DF050 /* SDL_messagebox.h in Headers */,
@@ -1213,8 +1238,15 @@
attributes = {
LastUpgradeCheck = 0800;
TargetAttributes = {
+ 00B4F48B12F6A69C0084EC00 = {
+ DevelopmentTeam = UZ5V327NE3;
+ };
FAB598131BB5C1B100BE72C5 = {
CreatedOnToolsVersion = 7.1;
+ DevelopmentTeam = UZ5V327NE3;
+ };
+ FD6526620DE8FCCB002AD96B = {
+ DevelopmentTeam = UZ5V327NE3;
};
};
};
@@ -1373,6 +1405,7 @@
FD65266A0DE8FCDD002AD96B /* SDL_audiotypecvt.c in Sources */,
FD65266B0DE8FCDD002AD96B /* SDL_mixer.c in Sources */,
FD65266F0DE8FCDD002AD96B /* SDL_wave.c in Sources */,
+ 4D7516FD1EE1C28A00820EEA /* SDL_uikitvulkan.m in Sources */,
FA1DC2731C62BE65008F99A0 /* SDL_uikitclipboard.m in Sources */,
FD6526700DE8FCDD002AD96B /* SDL_cpuinfo.c in Sources */,
FD6526710DE8FCDD002AD96B /* SDL_events.c in Sources */,
@@ -1381,7 +1414,9 @@
FD6526730DE8FCDD002AD96B /* SDL_mouse.c in Sources */,
FD6526740DE8FCDD002AD96B /* SDL_quit.c in Sources */,
FD6526750DE8FCDD002AD96B /* SDL_windowevents.c in Sources */,
+ 4D7516FB1EE1C28A00820EEA /* SDL_uikitmetalview.m in Sources */,
FD6526760DE8FCDD002AD96B /* SDL_rwops.c in Sources */,
+ 4D7517201EE1D98200820EEA /* SDL_vulkan_utils.c in Sources */,
FD6526780DE8FCDD002AD96B /* SDL_error.c in Sources */,
FD65267A0DE8FCDD002AD96B /* SDL.c in Sources */,
FD65267B0DE8FCDD002AD96B /* SDL_syscond.c in Sources */,
@@ -1613,6 +1648,7 @@
GCC_WARN_MULTIPLE_DEFINITION_TYPES_FOR_SELECTOR = YES;
GCC_WARN_STRICT_SELECTOR_MATCH = YES;
GCC_WARN_UNDECLARED_SELECTOR = YES;
+ HEADER_SEARCH_PATHS = "$(VULKAN_SDK)/include";
PRODUCT_NAME = SDL2;
SKIP_INSTALL = YES;
};
@@ -1628,6 +1664,7 @@
GCC_WARN_MULTIPLE_DEFINITION_TYPES_FOR_SELECTOR = YES;
GCC_WARN_STRICT_SELECTOR_MATCH = YES;
GCC_WARN_UNDECLARED_SELECTOR = YES;
+ HEADER_SEARCH_PATHS = "$(VULKAN_SDK)/include";
PRODUCT_NAME = SDL2;
SKIP_INSTALL = YES;
};
diff --git a/Xcode/SDL/SDL.xcodeproj/project.pbxproj b/Xcode/SDL/SDL.xcodeproj/project.pbxproj
index 1a63d02..e075e15 100755
--- a/Xcode/SDL/SDL.xcodeproj/project.pbxproj
+++ b/Xcode/SDL/SDL.xcodeproj/project.pbxproj
@@ -377,6 +377,25 @@
04F7805D12FB74A200FC43C0 /* SDL_drawline.h in Headers */ = {isa = PBXBuildFile; fileRef = 04F7804512FB74A200FC43C0 /* SDL_drawline.h */; };
04F7805E12FB74A200FC43C0 /* SDL_drawpoint.c in Sources */ = {isa = PBXBuildFile; fileRef = 04F7804612FB74A200FC43C0 /* SDL_drawpoint.c */; };
04F7805F12FB74A200FC43C0 /* SDL_drawpoint.h in Headers */ = {isa = PBXBuildFile; fileRef = 04F7804712FB74A200FC43C0 /* SDL_drawpoint.h */; };
+ 4D16644B1EDD5FE8003DE88E /* SDL_vulkan.h in Headers */ = {isa = PBXBuildFile; fileRef = 4D16644A1EDD5FE8003DE88E /* SDL_vulkan.h */; settings = {ATTRIBUTES = (Public, ); }; };
+ 4D16644E1EDD6023003DE88E /* SDL_vulkan_internal.h in Headers */ = {isa = PBXBuildFile; fileRef = 4D16644C1EDD6023003DE88E /* SDL_vulkan_internal.h */; };
+ 4D16644F1EDD6023003DE88E /* SDL_vulkan_utils.c in Sources */ = {isa = PBXBuildFile; fileRef = 4D16644D1EDD6023003DE88E /* SDL_vulkan_utils.c */; };
+ 4D1664531EDD60AD003DE88E /* SDL_cocoametalview.m in Sources */ = {isa = PBXBuildFile; fileRef = 4D1664501EDD60AD003DE88E /* SDL_cocoametalview.m */; };
+ 4D1664541EDD60AD003DE88E /* SDL_cocoavulkan.h in Headers */ = {isa = PBXBuildFile; fileRef = 4D1664511EDD60AD003DE88E /* SDL_cocoavulkan.h */; };
+ 4D1664551EDD60AD003DE88E /* SDL_cocoavulkan.m in Sources */ = {isa = PBXBuildFile; fileRef = 4D1664521EDD60AD003DE88E /* SDL_cocoavulkan.m */; };
+ 4D1664561EDD61DA003DE88E /* SDL_vulkan_utils.c in Sources */ = {isa = PBXBuildFile; fileRef = 4D16644D1EDD6023003DE88E /* SDL_vulkan_utils.c */; };
+ 4D1664571EDD61F0003DE88E /* SDL_cocoametalview.m in Sources */ = {isa = PBXBuildFile; fileRef = 4D1664501EDD60AD003DE88E /* SDL_cocoametalview.m */; };
+ 4D1664581EDD61F0003DE88E /* SDL_cocoavulkan.m in Sources */ = {isa = PBXBuildFile; fileRef = 4D1664521EDD60AD003DE88E /* SDL_cocoavulkan.m */; };
+ 4D1664591EDD621B003DE88E /* SDL_vulkan_utils.c in Sources */ = {isa = PBXBuildFile; fileRef = 4D16644D1EDD6023003DE88E /* SDL_vulkan_utils.c */; };
+ 4D16645A1EDD6235003DE88E /* SDL_cocoametalview.m in Sources */ = {isa = PBXBuildFile; fileRef = 4D1664501EDD60AD003DE88E /* SDL_cocoametalview.m */; };
+ 4D16645B1EDD6235003DE88E /* SDL_cocoavulkan.m in Sources */ = {isa = PBXBuildFile; fileRef = 4D1664521EDD60AD003DE88E /* SDL_cocoavulkan.m */; };
+ 4D16645E1EDD73E0003DE88E /* Metal.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 4D16645D1EDD73E0003DE88E /* Metal.framework */; };
+ 4D16645F1EDD73FE003DE88E /* Metal.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 4D16645D1EDD73E0003DE88E /* Metal.framework */; };
+ 4D1664601EDD741F003DE88E /* Metal.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 4D16645D1EDD73E0003DE88E /* Metal.framework */; };
+ 4D1664641EDD7528003DE88E /* QuartzCore.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 4D1664611EDD74A9003DE88E /* QuartzCore.framework */; };
+ 4D1664651EDD7727003DE88E /* QuartzCore.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 4D1664611EDD74A9003DE88E /* QuartzCore.framework */; };
+ 4D1664661EDD776A003DE88E /* QuartzCore.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 4D1664611EDD74A9003DE88E /* QuartzCore.framework */; };
+ 4D7517291EE2562B00820EEA /* SDL_cocoametalview.h in Headers */ = {isa = PBXBuildFile; fileRef = 4D7517281EE2562B00820EEA /* SDL_cocoametalview.h */; };
56115BBB1DF72C6D00F47E1E /* SDL_dataqueue.c in Sources */ = {isa = PBXBuildFile; fileRef = 56115BB91DF72C6D00F47E1E /* SDL_dataqueue.c */; };
56115BBC1DF72C6D00F47E1E /* SDL_dataqueue.h in Headers */ = {isa = PBXBuildFile; fileRef = 56115BBA1DF72C6D00F47E1E /* SDL_dataqueue.h */; };
562C4AE91D8F496200AF9EBE /* AudioToolbox.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = A7381E931D8B69C300B177DD /* AudioToolbox.framework */; };
@@ -1015,6 +1034,16 @@
04F7804512FB74A200FC43C0 /* SDL_drawline.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SDL_drawline.h; sourceTree = "<group>"; };
04F7804612FB74A200FC43C0 /* SDL_drawpoint.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = SDL_drawpoint.c; sourceTree = "<group>"; };
04F7804712FB74A200FC43C0 /* SDL_drawpoint.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SDL_drawpoint.h; sourceTree = "<group>"; };
+ 4D16644A1EDD5FE8003DE88E /* SDL_vulkan.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SDL_vulkan.h; sourceTree = "<group>"; };
+ 4D16644C1EDD6023003DE88E /* SDL_vulkan_internal.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SDL_vulkan_internal.h; sourceTree = "<group>"; };
+ 4D16644D1EDD6023003DE88E /* SDL_vulkan_utils.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = SDL_vulkan_utils.c; sourceTree = "<group>"; };
+ 4D1664501EDD60AD003DE88E /* SDL_cocoametalview.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SDL_cocoametalview.m; sourceTree = "<group>"; };
+ 4D1664511EDD60AD003DE88E /* SDL_cocoavulkan.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SDL_cocoavulkan.h; sourceTree = "<group>"; };
+ 4D1664521EDD60AD003DE88E /* SDL_cocoavulkan.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SDL_cocoavulkan.m; sourceTree = "<group>"; };
+ 4D16645D1EDD73E0003DE88E /* Metal.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Metal.framework; path = System/Library/Frameworks/Metal.framework; sourceTree = SDKROOT; };
+ 4D1664611EDD74A9003DE88E /* QuartzCore.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = QuartzCore.framework; path = System/Library/Frameworks/QuartzCore.framework; sourceTree = SDKROOT; };
+ 4D4820431F0F10B400EDC31C /* SDL_vulkan.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = SDL_vulkan.h; path = ../../include/SDL_vulkan.h; sourceTree = "<group>"; };
+ 4D7517281EE2562B00820EEA /* SDL_cocoametalview.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SDL_cocoametalview.h; sourceTree = "<group>"; };
56115BB91DF72C6D00F47E1E /* SDL_dataqueue.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = SDL_dataqueue.c; path = ../../src/SDL_dataqueue.c; sourceTree = "<group>"; };
56115BBA1DF72C6D00F47E1E /* SDL_dataqueue.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = SDL_dataqueue.h; path = ../../src/SDL_dataqueue.h; sourceTree = "<group>"; };
566CDE8D148F0AC200C5A9BB /* SDL_dropevents_c.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SDL_dropevents_c.h; sourceTree = "<group>"; };
@@ -1123,6 +1152,8 @@
00D0D08410675DD9004B05EF /* CoreFoundation.framework in Frameworks */,
00D0D0D810675E46004B05EF /* Carbon.framework in Frameworks */,
00CFA89D106B4BA100758660 /* ForceFeedback.framework in Frameworks */,
+ 4D16645E1EDD73E0003DE88E /* Metal.framework in Frameworks */,
+ 4D1664651EDD7727003DE88E /* QuartzCore.framework in Frameworks */,
);
runOnlyForDeploymentPostprocessing = 0;
};
@@ -1138,6 +1169,8 @@
007317C30858E15000B2BC32 /* Carbon.framework in Frameworks */,
DB31408B17554D37006C0E22 /* ForceFeedback.framework in Frameworks */,
562C4AE91D8F496200AF9EBE /* AudioToolbox.framework in Frameworks */,
+ 4D16645F1EDD73FE003DE88E /* Metal.framework in Frameworks */,
+ 4D1664661EDD776A003DE88E /* QuartzCore.framework in Frameworks */,
);
runOnlyForDeploymentPostprocessing = 0;
};
@@ -1153,6 +1186,8 @@
DB31407217554B71006C0E22 /* Carbon.framework in Frameworks */,
DB31408D17554D3C006C0E22 /* ForceFeedback.framework in Frameworks */,
562C4AEA1D8F496300AF9EBE /* AudioToolbox.framework in Frameworks */,
+ 4D1664601EDD741F003DE88E /* Metal.framework in Frameworks */,
+ 4D1664641EDD7528003DE88E /* QuartzCore.framework in Frameworks */,
);
runOnlyForDeploymentPostprocessing = 0;
};
@@ -1221,6 +1256,7 @@
AA7557F61595D4D800BBD41B /* SDL_types.h */,
AA7557F71595D4D800BBD41B /* SDL_version.h */,
AA7557F81595D4D800BBD41B /* SDL_video.h */,
+ 4D16644A1EDD5FE8003DE88E /* SDL_vulkan.h */,
);
name = "Public Headers";
path = ../../include;
@@ -1573,6 +1609,8 @@
04BDFF7412E6671800899322 /* SDL_surface.c */,
04BDFF7512E6671800899322 /* SDL_sysvideo.h */,
04BDFF7612E6671800899322 /* SDL_video.c */,
+ 4D16644C1EDD6023003DE88E /* SDL_vulkan_internal.h */,
+ 4D16644D1EDD6023003DE88E /* SDL_vulkan_utils.c */,
);
name = video;
path = ../../src/video;
@@ -1589,6 +1627,8 @@
04BDFEC712E6671800899322 /* SDL_cocoakeyboard.m */,
AABCC38B164063D200AB8930 /* SDL_cocoamessagebox.h */,
AABCC38C164063D200AB8930 /* SDL_cocoamessagebox.m */,
+ 4D7517281EE2562B00820EEA /* SDL_cocoametalview.h */,
+ 4D1664501EDD60AD003DE88E /* SDL_cocoametalview.m */,
04BDFEC812E6671800899322 /* SDL_cocoamodes.h */,
04BDFEC912E6671800899322 /* SDL_cocoamodes.m */,
04BDFECA12E6671800899322 /* SDL_cocoamouse.h */,
@@ -1601,6 +1641,8 @@
04BDFECF12E6671800899322 /* SDL_cocoashape.m */,
04BDFED012E6671800899322 /* SDL_cocoavideo.h */,
04BDFED112E6671800899322 /* SDL_cocoavideo.m */,
+ 4D1664511EDD60AD003DE88E /* SDL_cocoavulkan.h */,
+ 4D1664521EDD60AD003DE88E /* SDL_cocoavulkan.m */,
04BDFED212E6671800899322 /* SDL_cocoawindow.h */,
04BDFED312E6671800899322 /* SDL_cocoawindow.m */,
);
@@ -1662,6 +1704,7 @@
0867D691FE84028FC02AAC07 /* SDLFramework */ = {
isa = PBXGroup;
children = (
+ 4D4820431F0F10B400EDC31C /* SDL_vulkan.h */,
F5A2EF3900C6A39A01000001 /* BUGS.txt */,
F59C70FC00D5CB5801000001 /* pkg-support */,
0153844A006D81B07F000001 /* Public Headers */,
@@ -1669,6 +1712,7 @@
034768DDFF38A45A11DB9C8B /* Products */,
BECDF66B0761BA81005FE872 /* Info-Framework.plist */,
BEC562FE0761C0E800A33029 /* Linked Frameworks */,
+ 4D16645C1EDD73E0003DE88E /* Frameworks */,
);
comments = "To build Universal Binaries, we have experimented with a variety of different options.\nThe complication is that we must retain compatibility with at least 10.2. \nThe Universal Binary defaults only work for > 10.3.9\n\nSo far, we have found:\ngcc 4.0.0 with Xcode 2.1 always links against libgcc_s. gcc 4.0.1 from Xcode 2.2 fixes this problem.\n\nBut gcc 4.0 will not work with < 10.3.9 because we continue to get an undefined symbol to _fprintf$LDBL128.\nSo we must use gcc 3.3 on PPC to accomplish 10.2 support. (But 4.0 is required for i386.)\n\nSetting the deployment target to 10.4 will disable prebinding, so for PPC, we set it less than 10.4 to preserve prebinding for legacy support.\n\nSetting the PPC SDKROOT to /Developers/SDKs/MacOSX10.2.8.sdk will link to 63.0.0 libSystem.B.dylib. Leaving it at current or 10.4u links to 88.1.2. However, as long as we are using gcc 3.3, it doesn't seem to matter as testing has demonstrated both will run. We have decided not to invoke the 10.2.8 SDK because it is not a default installed component with Xcode which will probably cause most people problems. However, rather than deleting the SDKROOT_ppc entry entirely, we have mapped it to 10.4u in case we decide we need to change this setting.\n\nTo use Altivec or SSE, we needed architecture specific flags:\nOTHER_CFLAGS_ppc\nOTHER_CFLAGS_i386\nOTHER_CFLAGS=$(OTHER_CFLAGS_($CURRENT_ARCH))\n\nThe general OTHER_CFLAGS needed to be manually mapped to architecture specific options because Xcode didn't do this automatically for us.\n\n\n";
indentWidth = 4;
@@ -1717,6 +1761,15 @@
name = "Library Source";
sourceTree = "<group>";
};
+ 4D16645C1EDD73E0003DE88E /* Frameworks */ = {
+ isa = PBXGroup;
+ children = (
+ 4D1664611EDD74A9003DE88E /* QuartzCore.framework */,
+ 4D16645D1EDD73E0003DE88E /* Metal.framework */,
+ );
+ name = Frameworks;
+ sourceTree = "<group>";
+ };
567E2F1F17C44BBB005F1892 /* filesystem */ = {
isa = PBXGroup;
children = (
@@ -1834,8 +1887,10 @@
AA7558541595D4D800BBD41B /* SDL_timer.h in Headers */,
AA7558561595D4D800BBD41B /* SDL_touch.h in Headers */,
AA7558581595D4D800BBD41B /* SDL_types.h in Headers */,
- AA75585A1595D4D800BBD41B /* SDL_version.h in Headers */,
AA75585C1595D4D800BBD41B /* SDL_video.h in Headers */,
+ AA75585A1595D4D800BBD41B /* SDL_version.h in Headers */,
+ 4D16644B1EDD5FE8003DE88E /* SDL_vulkan.h in Headers */,
+ 4D7517291EE2562B00820EEA /* SDL_cocoametalview.h in Headers */,
04BD000912E6671800899322 /* SDL_diskaudio.h in Headers */,
04BD001112E6671800899322 /* SDL_dummyaudio.h in Headers */,
04BD001912E6671800899322 /* SDL_coreaudio.h in Headers */,
@@ -1871,6 +1926,7 @@
04BD00CB12E6671800899322 /* SDL_thread_c.h in Headers */,
04BD00D812E6671800899322 /* SDL_timer_c.h in Headers */,
04BD00F312E6671800899322 /* SDL_cocoaclipboard.h in Headers */,
+ 4D1664541EDD60AD003DE88E /* SDL_cocoavulkan.h in Headers */,
04BD00F512E6671800899322 /* SDL_cocoaevents.h in Headers */,
04BD00F712E6671800899322 /* SDL_cocoakeyboard.h in Headers */,
04BD00F912E6671800899322 /* SDL_cocoamodes.h in Headers */,
@@ -1891,6 +1947,7 @@
04BD019912E6671800899322 /* SDL_shape_internals.h in Headers */,
04BD019C12E6671800899322 /* SDL_sysvideo.h in Headers */,
04BD01DC12E6671800899322 /* imKStoUCS.h in Headers */,
+ 4D16644E1EDD6023003DE88E /* SDL_vulkan_internal.h in Headers */,
04BD01DE12E6671800899322 /* SDL_x11clipboard.h in Headers */,
04BD01E012E6671800899322 /* SDL_x11dyn.h in Headers */,
04BD01E212E6671800899322 /* SDL_x11events.h in Headers */,
@@ -2325,14 +2382,6 @@
isa = PBXProject;
attributes = {
LastUpgradeCheck = 0730;
- TargetAttributes = {
- BECDF5FE0761BA81005FE872 = {
- DevelopmentTeam = EH385AYQ6F;
- };
- BECDF6BB0761BA81005FE872 = {
- DevelopmentTeam = EH385AYQ6F;
- };
- };
};
buildConfigurationList = 0073178E0858DB0500B2BC32 /* Build configuration list for PBXProject "SDL" */;
compatibilityVersion = "Xcode 3.2";
@@ -2425,12 +2474,14 @@
04BD005A12E6671800899322 /* SDL_rwops.c in Sources */,
04BD005B12E6671800899322 /* SDL_syshaptic.c in Sources */,
04BD005F12E6671800899322 /* SDL_haptic.c in Sources */,
+ 4D1664551EDD60AD003DE88E /* SDL_cocoavulkan.m in Sources */,
04BD006612E6671800899322 /* SDL_sysjoystick.c in Sources */,
04BD007012E6671800899322 /* SDL_joystick.c in Sources */,
04BD008812E6671800899322 /* SDL_sysloadso.c in Sources */,
04BD009412E6671800899322 /* SDL_syspower.c in Sources */,
04BD009612E6671800899322 /* SDL_power.c in Sources */,
04BD009C12E6671800899322 /* SDL_assert.c in Sources */,
+ 4D1664531EDD60AD003DE88E /* SDL_cocoametalview.m in Sources */,
04BD009F12E6671800899322 /* SDL_error.c in Sources */,
04BD00A212E6671800899322 /* SDL.c in Sources */,
04BD00A312E6671800899322 /* SDL_getenv.c in Sources */,
@@ -2451,6 +2502,7 @@
04BD00F612E6671800899322 /* SDL_cocoaevents.m in Sources */,
04BD00F812E6671800899322 /* SDL_cocoakeyboard.m in Sources */,
04BD00FA12E6671800899322 /* SDL_cocoamodes.m in Sources */,
+ 4D16644F1EDD6023003DE88E /* SDL_vulkan_utils.c in Sources */,
04BD00FC12E6671800899322 /* SDL_cocoamouse.m in Sources */,
04BD00FE12E6671800899322 /* SDL_cocoaopengl.m in Sources */,
04BD010012E6671800899322 /* SDL_cocoashape.m in Sources */,
@@ -2521,6 +2573,9 @@
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
+ 4D1664571EDD61F0003DE88E /* SDL_cocoametalview.m in Sources */,
+ 4D1664581EDD61F0003DE88E /* SDL_cocoavulkan.m in Sources */,
+ 4D1664561EDD61DA003DE88E /* SDL_vulkan_utils.c in Sources */,
04BD021712E6671800899322 /* SDL_atomic.c in Sources */,
04BD021812E6671800899322 /* SDL_spinlock.c in Sources */,
56F9D55C1DF73B6B00C15B5D /* SDL_dataqueue.c in Sources */,
@@ -2641,6 +2696,9 @@
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
+ 4D16645A1EDD6235003DE88E /* SDL_cocoametalview.m in Sources */,
+ 4D16645B1EDD6235003DE88E /* SDL_cocoavulkan.m in Sources */,
+ 4D1664591EDD621B003DE88E /* SDL_vulkan_utils.c in Sources */,
DB313FFE17554B71006C0E22 /* SDL_atomic.c in Sources */,
DB313FFF17554B71006C0E22 /* SDL_spinlock.c in Sources */,
56F9D55D1DF73B6C00C15B5D /* SDL_dataqueue.c in Sources */,
@@ -2810,7 +2868,10 @@
DYLIB_COMPATIBILITY_VERSION = 1.0.0;
DYLIB_CURRENT_VERSION = 7.0.0;
FRAMEWORK_VERSION = A;
- HEADER_SEARCH_PATHS = /usr/X11R6/include;
+ HEADER_SEARCH_PATHS = (
+ /usr/X11R6/include,
+ "$(VULKAN_SDK)/include",
+ );
INFOPLIST_FILE = "Info-Framework.plist";
INSTALL_PATH = "@rpath";
OTHER_LDFLAGS = "-liconv";
@@ -2833,7 +2894,10 @@
"$(GCC_PREPROCESSOR_DEFINITIONS_QUOTED_4)",
);
GCC_SYMBOLS_PRIVATE_EXTERN = YES;
- HEADER_SEARCH_PATHS = /usr/X11R6/include;
+ HEADER_SEARCH_PATHS = (
+ /usr/X11R6/include,
+ "$(VULKAN_SDK)/include",
+ );
PRODUCT_NAME = SDL2;
SKIP_INSTALL = YES;
};
@@ -2889,7 +2953,10 @@
DYLIB_COMPATIBILITY_VERSION = 1.0.0;
DYLIB_CURRENT_VERSION = 7.0.0;
FRAMEWORK_VERSION = A;
- HEADER_SEARCH_PATHS = /usr/X11R6/include;
+ HEADER_SEARCH_PATHS = (
+ /usr/X11R6/include,
+ "$(VULKAN_SDK)/include",
+ );
INFOPLIST_FILE = "Info-Framework.plist";
INSTALL_PATH = "@rpath";
OTHER_LDFLAGS = "-liconv";
@@ -2912,7 +2979,10 @@
"$(GCC_PREPROCESSOR_DEFINITIONS_QUOTED_4)",
);
GCC_SYMBOLS_PRIVATE_EXTERN = YES;
- HEADER_SEARCH_PATHS = /usr/X11R6/include;
+ HEADER_SEARCH_PATHS = (
+ /usr/X11R6/include,
+ "$(VULKAN_SDK)/include",
+ );
PRODUCT_NAME = SDL2;
SKIP_INSTALL = YES;
};
@@ -2939,7 +3009,10 @@
"$(GCC_PREPROCESSOR_DEFINITIONS_QUOTED_4)",
);
GCC_SYMBOLS_PRIVATE_EXTERN = YES;
- HEADER_SEARCH_PATHS = /usr/X11R6/include;
+ HEADER_SEARCH_PATHS = (
+ /usr/X11R6/include,
+ "$(VULKAN_SDK)/include",
+ );
INSTALL_PATH = "@rpath";
PRODUCT_NAME = SDL2;
SKIP_INSTALL = YES;
@@ -2959,7 +3032,10 @@
"$(GCC_PREPROCESSOR_DEFINITIONS_QUOTED_4)",
);
GCC_SYMBOLS_PRIVATE_EXTERN = YES;
- HEADER_SEARCH_PATHS = /usr/X11R6/include;
+ HEADER_SEARCH_PATHS = (
+ /usr/X11R6/include,
+ "$(VULKAN_SDK)/include",
+ );
INSTALL_PATH = "@rpath";
PRODUCT_NAME = SDL2;
SKIP_INSTALL = YES;
diff --git a/cmake/sdlchecks.cmake b/cmake/sdlchecks.cmake
index e2e89a2..661fd67 100644
--- a/cmake/sdlchecks.cmake
+++ b/cmake/sdlchecks.cmake
@@ -1153,6 +1153,25 @@ macro(CheckRPI)
endif(VIDEO_RPI)
endmacro(CheckRPI)
+macro(CheckVulkanHeaders)
+ if(VIDEO_VULKAN)
+ # ${VULKAN_SDK} could be unset during the first configure run with
+ # cmake-gui resulting in vulkan.h not being found. If it's been
+ # subsequently changed, unset is necessary to ensure check is run again.
+ unset(HAVE_VULKAN_H CACHE)
+ # Prefer ${VULKAN_SDK} header
+ set(CMAKE_REQUIRED_INCLUDES "${VULKAN_SDK}/include")
+ check_include_file("vulkan/vulkan.h" HAVE_VULKAN_H)
+ if(HAVE_VULKAN_H)
+ list(APPEND EXTRA_CFLAGS "-I${VULKAN_SDK}/include")
+ else()
+ # Check system includes.
+ unset(HAVE_VULKAN_H CACHE)
+ check_include_file("vulkan/vulkan.h" HAVE_VULKAN_H)
+ endif()
+ endif()
+endmacro(CheckVulkanHeaders)
+
# Requires:
# - EGL
# - PkgCheckModules
diff --git a/configure b/configure
index 6be48e5..f5c0763 100755
--- a/configure
+++ b/configure
@@ -745,6 +745,7 @@ infodir
docdir
oldincludedir
includedir
+runstatedir
localstatedir
sharedstatedir
sysconfdir
@@ -854,6 +855,7 @@ enable_video_opengl
enable_video_opengles
enable_video_opengles1
enable_video_opengles2
+enable_video_vulkan
enable_libudev
enable_dbus
enable_ime
@@ -920,6 +922,7 @@ datadir='${datarootdir}'
sysconfdir='${prefix}/etc'
sharedstatedir='${prefix}/com'
localstatedir='${prefix}/var'
+runstatedir='${localstatedir}/run'
includedir='${prefix}/include'
oldincludedir='/usr/include'
docdir='${datarootdir}/doc/${PACKAGE}'
@@ -1172,6 +1175,15 @@ do
| -silent | --silent | --silen | --sile | --sil)
silent=yes ;;
+ -runstatedir | --runstatedir | --runstatedi | --runstated \
+ | --runstate | --runstat | --runsta | --runst | --runs \
+ | --run | --ru | --r)
+ ac_prev=runstatedir ;;
+ -runstatedir=* | --runstatedir=* | --runstatedi=* | --runstated=* \
+ | --runstate=* | --runstat=* | --runsta=* | --runst=* | --runs=* \
+ | --run=* | --ru=* | --r=*)
+ runstatedir=$ac_optarg ;;
+
-sbindir | --sbindir | --sbindi | --sbind | --sbin | --sbi | --sb)
ac_prev=sbindir ;;
-sbindir=* | --sbindir=* | --sbindi=* | --sbind=* | --sbin=* \
@@ -1309,7 +1321,7 @@ fi
for ac_var in exec_prefix prefix bindir sbindir libexecdir datarootdir \
datadir sysconfdir sharedstatedir localstatedir includedir \
oldincludedir docdir infodir htmldir dvidir pdfdir psdir \
- libdir localedir mandir
+ libdir localedir mandir runstatedir
do
eval ac_val=\$$ac_var
# Remove trailing slashes.
@@ -1462,6 +1474,7 @@ Fine tuning of the installation directories:
--sysconfdir=DIR read-only single-machine data [PREFIX/etc]
--sharedstatedir=DIR modifiable architecture-independent data [PREFIX/com]
--localstatedir=DIR modifiable single-machine data [PREFIX/var]
+ --runstatedir=DIR modifiable per-process data [LOCALSTATEDIR/run]
--libdir=DIR object code libraries [EPREFIX/lib]
--includedir=DIR C header files [PREFIX/include]
--oldincludedir=DIR C header files for non-gcc [/usr/include]
@@ -1603,6 +1616,7 @@ Optional Features:
include OpenGL ES 1.1 support [[default=yes]]
--enable-video-opengles2
include OpenGL ES 2.0 support [[default=yes]]
+ --enable-video-vulkan include Vulkan surface support [[default=yes]]
--enable-libudev enable libudev support [[default=yes]]
--enable-dbus enable D-Bus support [[default=yes]]
--enable-ime enable IME support [[default=yes]]
@@ -21891,6 +21905,87 @@ $as_echo "#define SDL_VIDEO_RENDER_OGL_ES2 1" >>confdefs.h
fi
}
+# Check whether --enable-video-vulkan was given.
+if test "${enable_video_vulkan+set}" = set; then :
+ enableval=$enable_video_vulkan;
+else
+ enable_video_vulkan=yes
+fi
+
+
+CheckVulkan()
+{
+ have_vulkan_hdr=no
+ if test x$enable_video = xyes -a x$enable_video_vulkan = xyes; then
+ case "$host" in
+ *-*-androideabi*)
+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h. */
+
+ #if defined(__ANDROID__) && defined(__ARM_EABI__) && !defined(__ARM_ARCH_7A__)
+ #error Vulkan doesn't work on this configuration
+ #endif
+ int main()
+ {
+ return 0;
+ }
+
+int
+main ()
+{
+
+ enable_video_vulkan=no
+
+ ;
+ return 0;
+}
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"; then :
+
+
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+ ;;
+ *)
+ ;;
+ esac
+ if test x$enable_video_vulkan = xno; then
+ # For reasons I am totally unable to see, I get an undefined macro error if
+ # I put this in the AC_TRY_COMPILE.
+ { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: Sorry, Vulkan does not work on this configuration." >&5
+$as_echo "$as_me: WARNING: Sorry, Vulkan does not work on this configuration." >&2;}
+ fi
+ if test x$enable_video_vulkan = xyes; then
+ vsdk_include_dir="${VULKAN_SDK}/include"
+ vulkan_header="vulkan/vulkan.h"
+ save_CPPFLAGS="$CPPFLAGS"
+ CPPFLAGS="${save_CPPFLAGS} -I$vsdk_include_dir"
+ as_ac_Header=`$as_echo "ac_cv_header_$vulkan_header" | $as_tr_sh`
+ac_fn_c_check_header_mongrel "$LINENO" "$vulkan_header" "$as_ac_Header" "$ac_includes_default"
+if eval test \"x\$"$as_ac_Header"\" = x"yes"; then :
+ have_vulkan_hdr=yes
+else
+ have_vulkan_hdr=no
+fi
+
+
+ CPPFLAGS="$save_CPPFLAGS"
+ fi
+ fi
+ if test x$have_vulkan_hdr = xyes; then
+ # vulkan.h has been found in either $VULKAN_SDK/include or along the
+ # the standard include path. Unfortunately there seems no easy
+ # way to find out which, so...
+ if test -n "$VULKAN_SDK" -a -f "$vsdk_include_dir/$vulkan_header"; then
+ EXTRA_CFLAGS="$EXTRA_CFLAGS -I$vsdk_include_dir"
+ fi
+
+$as_echo "#define SDL_VIDEO_VULKAN_SURFACE 1" >>confdefs.h
+
+ SUMMARY_video="${SUMMARY_video} vulkan"
+ fi
+}
+
CheckInputEvents()
{
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for Linux 2.4 unified input interface" >&5
@@ -23637,6 +23732,7 @@ case "$host" in
CheckKMSDRM
CheckOpenGLX11
CheckOpenGLESX11
+ CheckVulkan
CheckMir
CheckWayland
CheckLibUDev
@@ -23806,6 +23902,7 @@ $as_echo "#define SDL_TIMER_UNIX 1" >>confdefs.h
CheckWINDOWS
CheckWINDOWSGL
CheckWINDOWSGLES
+ CheckVulkan
CheckDIRECTX
# Set up the core platform files
@@ -24092,6 +24189,7 @@ fi
CheckDummyAudio
CheckDLOPEN
CheckPTHREAD
+ CheckVulkan
# Set up files for the audio library
if test x$enable_audio = xyes; then
@@ -24174,6 +24272,9 @@ $as_echo "#define SDL_VIDEO_RENDER_OGL_ES2 1" >>confdefs.h
EXTRA_LDFLAGS="$EXTRA_LDFLAGS -Wl,-framework,OpenGLES"
EXTRA_LDFLAGS="$EXTRA_LDFLAGS -Wl,-framework,QuartzCore"
EXTRA_LDFLAGS="$EXTRA_LDFLAGS -Wl,-framework,UIKit"
+ if test x$ac_cv_header_vulkan_vulkan_h = xyes; then
+ EXTRA_LDFLAGS="$EXTRA_LDFLAGS -Wl,-framework,QuartzCore"
+ fi
;;
*-*-darwin* )
# This could be either full "Mac OS X", or plain "Darwin" which is
@@ -24195,6 +24296,7 @@ $as_echo "#define SDL_VIDEO_RENDER_OGL_ES2 1" >>confdefs.h
CheckX11
CheckMacGL
CheckOpenGLX11
+ CheckVulkan
CheckPTHREAD
# Set up files for the audio library
@@ -24260,6 +24362,9 @@ $as_echo "#define SDL_TIMER_UNIX 1" >>confdefs.h
EXTRA_LDFLAGS="$EXTRA_LDFLAGS -Wl,-framework,Cocoa"
EXTRA_LDFLAGS="$EXTRA_LDFLAGS -Wl,-framework,Carbon"
EXTRA_LDFLAGS="$EXTRA_LDFLAGS -Wl,-framework,IOKit"
+ if test x$ac_cv_header_vulkan_vulkan_h = xyes; then
+ EXTRA_LDFLAGS="$EXTRA_LDFLAGS -Wl,-framework,QuartzCore"
+ fi
;;
*-nacl|*-pnacl)
ARCH=nacl
diff --git a/configure.in b/configure.in
index 64a4840..f4ccc27 100644
--- a/configure.in
+++ b/configure.in
@@ -2401,6 +2401,62 @@ CheckEmscriptenGLES()
fi
}
+dnl Check to see if Vulkan surface support is desired
+AC_ARG_ENABLE(video-vulkan,
+AC_HELP_STRING([--enable-video-vulkan], [include Vulkan surface support [[default=yes]]]),
+ , enable_video_vulkan=yes)
+
+dnl Find Vulkan Header
+CheckVulkan()
+{
+ have_vulkan_hdr=no
+ if test x$enable_video = xyes -a x$enable_video_vulkan = xyes; then
+ case "$host" in
+ *-*-androideabi*)
+ AC_TRY_COMPILE([
+ #if defined(__ANDROID__) && defined(__ARM_EABI__) && !defined(__ARM_ARCH_7A__)
+ #error Vulkan doesn't work on this configuration
+ #endif
+ int main()
+ {
+ return 0;
+ }
+ ],[
+ enable_video_vulkan=no
+ ],[
+ ])
+ ;;
+ *)
+ ;;
+ esac
+ if test x$enable_video_vulkan = xno; then
+ # For reasons I am totally unable to see, I get an undefined macro error if
+ # I put this in the AC_TRY_COMPILE.
+ AC_MSG_WARN([Sorry, Vulkan does not work on this configuration.])
+ fi
+ if test x$enable_video_vulkan = xyes; then
+ vsdk_include_dir="${VULKAN_SDK}/include"
+ vulkan_header="vulkan/vulkan.h"
+ save_CPPFLAGS="$CPPFLAGS"
+ CPPFLAGS="${save_CPPFLAGS} -I$vsdk_include_dir"
+ AC_CHECK_HEADER($vulkan_header,
+ have_vulkan_hdr=yes,
+ have_vulkan_hdr=no)
+ CPPFLAGS="$save_CPPFLAGS"
+ fi
+ fi
+ if test x$have_vulkan_hdr = xyes; then
+ # vulkan.h has been found in either $VULKAN_SDK/include or along the
+ # the standard include path. Unfortunately there seems no easy
+ # way to find out which, so...
+ if test -n "$VULKAN_SDK" -a -f "$vsdk_include_dir/$vulkan_header"; then
+ EXTRA_CFLAGS="$EXTRA_CFLAGS -I$vsdk_include_dir"
+ fi
+ AC_DEFINE(SDL_VIDEO_VULKAN_SURFACE, 1, [ ])
+ SUMMARY_video="${SUMMARY_video} vulkan"
+ fi
+}
+
dnl See if we can use the new unified event interface in Linux 2.4
CheckInputEvents()
{
@@ -3230,6 +3286,7 @@ case "$host" in
CheckKMSDRM
CheckOpenGLX11
CheckOpenGLESX11
+ CheckVulkan
CheckMir
CheckWayland
CheckLibUDev
@@ -3375,6 +3432,7 @@ case "$host" in
CheckWINDOWS
CheckWINDOWSGL
CheckWINDOWSGLES
+ CheckVulkan
CheckDIRECTX
# Set up the core platform files
@@ -3559,6 +3617,7 @@ AC_HELP_STRING([--enable-render-d3d], [enable the Direct3D render driver [[defau
CheckDummyAudio
CheckDLOPEN
CheckPTHREAD
+ CheckVulkan
# Set up files for the audio library
if test x$enable_audio = xyes; then
@@ -3621,6 +3680,9 @@ AC_HELP_STRING([--enable-render-d3d], [enable the Direct3D render driver [[defau
EXTRA_LDFLAGS="$EXTRA_LDFLAGS -Wl,-framework,OpenGLES"
EXTRA_LDFLAGS="$EXTRA_LDFLAGS -Wl,-framework,QuartzCore"
EXTRA_LDFLAGS="$EXTRA_LDFLAGS -Wl,-framework,UIKit"
+ if test x$ac_cv_header_vulkan_vulkan_h = xyes; then
+ EXTRA_LDFLAGS="$EXTRA_LDFLAGS -Wl,-framework,QuartzCore"
+ fi
;;
*-*-darwin* )
# This could be either full "Mac OS X", or plain "Darwin" which is
@@ -3642,6 +3704,7 @@ AC_HELP_STRING([--enable-render-d3d], [enable the Direct3D render driver [[defau
CheckX11
CheckMacGL
CheckOpenGLX11
+ CheckVulkan
CheckPTHREAD
# Set up files for the audio library
@@ -3695,6 +3758,9 @@ AC_HELP_STRING([--enable-render-d3d], [enable the Direct3D render driver [[defau
EXTRA_LDFLAGS="$EXTRA_LDFLAGS -Wl,-framework,Cocoa"
EXTRA_LDFLAGS="$EXTRA_LDFLAGS -Wl,-framework,Carbon"
EXTRA_LDFLAGS="$EXTRA_LDFLAGS -Wl,-framework,IOKit"
+ if test x$ac_cv_header_vulkan_vulkan_h = xyes; then
+ EXTRA_LDFLAGS="$EXTRA_LDFLAGS -Wl,-framework,QuartzCore"
+ fi
;;
*-nacl|*-pnacl)
ARCH=nacl
diff --git a/debian/control b/debian/control
index a341133..020884b 100644
--- a/debian/control
+++ b/debian/control
@@ -20,6 +20,7 @@ Build-Depends: debhelper (>= 9),
libibus-1.0-dev[linux-any],
libusb2-dev [kfreebsd-any],
libusbhid-dev [kfreebsd-any],
+ libvulkan-dev,
libx11-dev,
libxcursor-dev,
libxext-dev,
diff --git a/docs/README-ios.md b/docs/README-ios.md
index 29f4170..746b4fb 100644
--- a/docs/README-ios.md
+++ b/docs/README-ios.md
@@ -7,9 +7,12 @@ Building the Simple DirectMedia Layer for iOS 5.1+
Requirements: Mac OS X 10.8 or later and the iOS 7+ SDK.
-Instructions:
-1. Open SDL.xcodeproj (located in Xcode-iOS/SDL) in Xcode.
-2. Select your desired target, and hit build.
+Instructions:
+
+1. Either download [Molten](https://moltengl.com/free-trial/) and unzip it or download the Vulkan headers from Khronos's [Vulkan-Docs](https://github.com/KhronosGroup/Vulkan-Docs/tree/1.0/src/vulkan) repo and put them in a directory hierarchy `include/vulkan`.
+2. Open SDL.xcodeproj (located in Xcode-iOS/SDL) in Xcode.
+3. Set a `VULKAN_SDK` custom path in the Xcode preferences. Select *Custom Paths* on the *Locations* tab. The value should be either the `MoltenVK` directory within the unzipped Molten package or the parent of the `include/vulkan` hierarchy.
+4. Select your desired target, and hit build.
There are three build targets:
- libSDL.a:
@@ -24,7 +27,9 @@ There are three build targets:
Build SDL for iOS from the command line
==============================================================================
-1. cd (PATH WHERE THE SDL CODE IS)/build-scripts
+1. Follow step 1 above.
+2. Either create and export a `VULKAN_SDK` environment variable with the value described in step 3 above or open Xcode, set the custom path described in step 3 above and close Xcode.
+3. cd (PATH WHERE THE SDL CODE IS)/build-scripts
2. ./iosbuild.sh
If everything goes fine, you should see a build/ios directory, inside there's
diff --git a/docs/README-linux.md b/docs/README-linux.md
index 1fe6a24..9ed2276 100644
--- a/docs/README-linux.md
+++ b/docs/README-linux.md
@@ -22,8 +22,8 @@ libxss-dev libgl1-mesa-dev libesd0-dev libdbus-1-dev libudev-dev \
libgles1-mesa-dev libgles2-mesa-dev libegl1-mesa-dev libibus-1.0-dev \
fcitx-libs-dev libsamplerate0-dev libsndio-dev
-Ubuntu 16.04 can also add "libwayland-dev libxkbcommon-dev wayland-protocols"
-to that command line for Wayland support.
+Ubuntu 16.04+ can also add "libwayland-dev libxkbcommon-dev wayland-protocols"
+to that command line for Wayland support and "libvulkan-dev" for Vulkan surface support.
Ubuntu 16.10 can also add "libmirclient-dev libxkbcommon-dev" to that command
line for Mir support.
diff --git a/docs/README-macosx.md b/docs/README-macosx.md
index 869de2e..5263cef 100644
--- a/docs/README-macosx.md
+++ b/docs/README-macosx.md
@@ -6,7 +6,19 @@ These instructions are for people using Apple's Mac OS X (pronounced
From the developer's point of view, OS X is a sort of hybrid Mac and
Unix system, and you have the option of using either traditional
-command line tools or Apple's IDE Xcode.
+command line tools or Apple's IDE Xcode.
+
+Preparation
+===========
+
+1. Either download [Molten](https://moltengl.com/free-trial/) and unzip it or download the Vulkan headers from Khronos's [Vulkan-Docs](https://github.com/KhronosGroup/Vulkan-Docs/tree/1.0/src/vulkan) repo and put them in a directory hierarchy `include/vulkan`.
+2. Set a `VULKAN_SDK` variable in one of the ways described below. Its value should be either the `MoltenVK` directory within the unzipped Molten package or the parent of the `include/vulkan` hierarchy.
+ - If you are going to use the command line, set and export a `VULKAN_SDK` environment variable in your shell's start-up file, e.g. `~/.bash_profile`.
+ - If you are going to use CMake, either set and export a `VULKAN_SDK` environment variable before running `cmake` or set the `VULKAN_SDK` variable in `cmake-gui` and press *Configure*.
+ - If you are going to use the provided Xcode projects, set a `VULKAN_SDK` custom path in Xcode's preferences. Select *Custom Paths* on the *Locations* tab of preferences.
+
+Command Line Build
+==================
To build SDL using the command line, use the standard configure and make
process:
diff --git a/docs/README-windows.md b/docs/README-windows.md
index de6e606..d133537 100644
--- a/docs/README-windows.md
+++ b/docs/README-windows.md
@@ -1,41 +1,45 @@
-Windows
-================================================================================
-
-================================================================================
-OpenGL ES 2.x support
-================================================================================
-
-SDL has support for OpenGL ES 2.x under Windows via two alternative
-implementations.
-The most straightforward method consists in running your app in a system with
-a graphic card paired with a relatively recent (as of November of 2013) driver
-which supports the WGL_EXT_create_context_es2_profile extension. Vendors known
-to ship said extension on Windows currently include nVidia and Intel.
-
-The other method involves using the ANGLE library (https://code.google.com/p/angleproject/)
-If an OpenGL ES 2.x context is requested and no WGL_EXT_create_context_es2_profile
-extension is found, SDL will try to load the libEGL.dll library provided by
-ANGLE.
-To obtain the ANGLE binaries, you can either compile from source from
-https://chromium.googlesource.com/angle/angle or copy the relevant binaries from
-a recent Chrome/Chromium install for Windows. The files you need are:
-
- * libEGL.dll
- * libGLESv2.dll
- * d3dcompiler_46.dll (supports Windows Vista or later, better shader compiler)
- or...
- * d3dcompiler_43.dll (supports Windows XP or later)
-
-If you compile ANGLE from source, you can configure it so it does not need the
-d3dcompiler_* DLL at all (for details on this, see their documentation).
-However, by default SDL will try to preload the d3dcompiler_46.dll to
-comply with ANGLE's requirements. If you wish SDL to preload d3dcompiler_43.dll (to
-support Windows XP) or to skip this step at all, you can use the
-SDL_HINT_VIDEO_WIN_D3DCOMPILER hint (see SDL_hints.h for more details).
-
-Known Bugs:
-
- * SDL_GL_SetSwapInterval is currently a no op when using ANGLE. It appears
- that there's a bug in the library which prevents the window contents from
- refreshing if this is set to anything other than the default value.
-
+Windows
+================================================================================
+
+================================================================================
+OpenGL ES 2.x support
+================================================================================
+
+SDL has support for OpenGL ES 2.x under Windows via two alternative
+implementations.
+The most straightforward method consists in running your app in a system with
+a graphic card paired with a relatively recent (as of November of 2013) driver
+which supports the WGL_EXT_create_context_es2_profile extension. Vendors known
+to ship said extension on Windows currently include nVidia and Intel.
+
+The other method involves using the ANGLE library (https://code.google.com/p/angleproject/)
+If an OpenGL ES 2.x context is requested and no WGL_EXT_create_context_es2_profile
+extension is found, SDL will try to load the libEGL.dll library provided by
+ANGLE.
+To obtain the ANGLE binaries, you can either compile from source from
+https://chromium.googlesource.com/angle/angle or copy the relevant binaries from
+a recent Chrome/Chromium install for Windows. The files you need are:
+
+ * libEGL.dll
+ * libGLESv2.dll
+ * d3dcompiler_46.dll (supports Windows Vista or later, better shader compiler)
+ or...
+ * d3dcompiler_43.dll (supports Windows XP or later)
+
+If you compile ANGLE from source, you can configure it so it does not need the
+d3dcompiler_* DLL at all (for details on this, see their documentation).
+However, by default SDL will try to preload the d3dcompiler_46.dll to
+comply with ANGLE's requirements. If you wish SDL to preload d3dcompiler_43.dll (to
+support Windows XP) or to skip this step at all, you can use the
+SDL_HINT_VIDEO_WIN_D3DCOMPILER hint (see SDL_hints.h for more details).
+
+Known Bugs:
+
+ * SDL_GL_SetSwapInterval is currently a no op when using ANGLE. It appears
+ that there's a bug in the library which prevents the window contents from
+ refreshing if this is set to anything other than the default value.
+
+Vulkan Surface Support
+==============
+
+Support for creating Vulkan surfaces is configured on by default. To disable it change the value of `SDL_VIDEO_VULKAN_SURFACE` to 0 in `SDL_config_windows`. When it is on you must install a [Vulkan SDK](https://www.lunarg.com/vulkan-sdk/) in order to build libSDL.
diff --git a/include/SDL.h b/include/SDL.h
index 4a6b453..4cd6108 100644
--- a/include/SDL.h
+++ b/include/SDL.h
@@ -56,6 +56,7 @@
#include "SDL_timer.h"
#include "SDL_version.h"
#include "SDL_video.h"
+#include "SDL_vulkan.h"
#include "begin_code.h"
/* Set up for C function definitions, even when using C++ */
diff --git a/include/SDL_config.h.cmake b/include/SDL_config.h.cmake
index 8f6d844..4998581 100644
--- a/include/SDL_config.h.cmake
+++ b/include/SDL_config.h.cmake
@@ -354,6 +354,9 @@
#cmakedefine SDL_VIDEO_OPENGL_OSMESA @SDL_VIDEO_OPENGL_OSMESA@
#cmakedefine SDL_VIDEO_OPENGL_OSMESA_DYNAMIC @SDL_VIDEO_OPENGL_OSMESA_DYNAMIC@
+/* Enable Vulkan surface support */
+#cmakedefine SDL_VIDEO_VULKAN_SURFACE @SDL_VIDEO_VULKAN_SURFACE@
+
/* Enable system power support */
#cmakedefine SDL_POWER_ANDROID @SDL_POWER_ANDROID@
#cmakedefine SDL_POWER_LINUX @SDL_POWER_LINUX@
diff --git a/include/SDL_config.h.in b/include/SDL_config.h.in
index 6e929fd..779543e 100644
--- a/include/SDL_config.h.in
+++ b/include/SDL_config.h.in
@@ -351,6 +351,9 @@
#undef SDL_VIDEO_OPENGL_OSMESA
#undef SDL_VIDEO_OPENGL_OSMESA_DYNAMIC
+/* Enable Vulkan surface support */
+#undef SDL_VIDEO_VULKAN_SURFACE
+
/* Enable system power support */
#undef SDL_POWER_LINUX
#undef SDL_POWER_WINDOWS
diff --git a/include/SDL_config_android.h b/include/SDL_config_android.h
index 0bdff66..edc3944 100644
--- a/include/SDL_config_android.h
+++ b/include/SDL_config_android.h
@@ -140,6 +140,14 @@
#define SDL_VIDEO_RENDER_OGL_ES 1
#define SDL_VIDEO_RENDER_OGL_ES2 1
+/* Enable Vulkan surface support */
+/* Android does not support Vulkan in native code using the "armeabi" ABI. */
+#if !defined(__ARM_EABI__) || defined(__ARM_ARCH_7A__)
+#define SDL_VIDEO_VULKAN_SURFACE 1
+#else
+#define SDL_VIDEO_VULKAN_SURFACE 0
+#endif
+
/* Enable system power support */
#define SDL_POWER_ANDROID 1
diff --git a/include/SDL_config_iphoneos.h b/include/SDL_config_iphoneos.h
index 7d5af2c..51bb044 100644
--- a/include/SDL_config_iphoneos.h
+++ b/include/SDL_config_iphoneos.h
@@ -139,6 +139,13 @@
#define SDL_VIDEO_RENDER_OGL_ES 1
#define SDL_VIDEO_RENDER_OGL_ES2 1
+/* Enable Vulkan surface support */
+#if !TARGET_OS_SIMULATOR && !TARGET_CPU_ARM // Only 64-bit devices have Metal
+#define SDL_VIDEO_VULKAN_SURFACE 1
+#else
+#define SDL_VIDEO_VULKAN_SURFACE 0
+#endif
+
/* Enable system power support */
#define SDL_POWER_UIKIT 1
diff --git a/include/SDL_config_macosx.h b/include/SDL_config_macosx.h
index 4b29f62..7fdd9f8 100644
--- a/include/SDL_config_macosx.h
+++ b/include/SDL_config_macosx.h
@@ -174,6 +174,14 @@
#define SDL_VIDEO_OPENGL_GLX 1
#endif
+/* enable Vulkan surface support */
+#if TARGET_CPU_X86_64
+/* Metal/MoltenVK/Vulkan not supported on 32-bit architectures. */
+#define SDL_VIDEO_VULKAN_SURFACE 1
+#else
+#define SDL_VIDEO_VULKAN_SURFACE 0
+#endif
+
/* Enable system power support */
#define SDL_POWER_MACOSX 1
diff --git a/include/SDL_config_windows.h b/include/SDL_config_windows.h
index e29a2ef..23cdd5d 100644
--- a/include/SDL_config_windows.h
+++ b/include/SDL_config_windows.h
@@ -208,6 +208,7 @@ typedef unsigned int uintptr_t;
#define SDL_VIDEO_OPENGL_EGL 1
#endif
+#define SDL_VIDEO_VULKAN_SURFACE 1
/* Enable system power support */
#define SDL_POWER_WINDOWS 1
diff --git a/include/SDL_video.h b/include/SDL_video.h
index 97b3aef..3eafb6a 100644
--- a/include/SDL_video.h
+++ b/include/SDL_video.h
@@ -233,7 +233,6 @@ typedef enum
SDL_GL_CONTEXT_RESET_LOSE_CONTEXT = 0x0001
} SDL_GLContextResetNotification;
-
/* Function prototypes */
/**
@@ -457,17 +456,32 @@ extern DECLSPEC Uint32 SDLCALL SDL_GetWindowPixelFormat(SDL_Window * window);
* ::SDL_WINDOW_HIDDEN, ::SDL_WINDOW_BORDERLESS,
* ::SDL_WINDOW_RESIZABLE, ::SDL_WINDOW_MAXIMIZED,
* ::SDL_WINDOW_MINIMIZED, ::SDL_WINDOW_INPUT_GRABBED,
- * ::SDL_WINDOW_ALLOW_HIGHDPI.
+ * ::SDL_WINDOW_ALLOW_HIGHDPI, ::SDL_WINDOW_VULKAN.
*
* \return The created window, or NULL if window creation failed.
*
* If the window is created with the SDL_WINDOW_ALLOW_HIGHDPI flag, its size
* in pixels may differ from its size in screen coordinates on platforms with
* high-DPI support (e.g. iOS and Mac OS X). Use SDL_GetWindowSize() to query
- * the client area's size in screen coordinates, and SDL_GL_GetDrawableSize()
- * or SDL_GetRendererOutputSize() to query the drawable size in pixels.
+ * the client area's size in screen coordinates, and SDL_GL_GetDrawableSize(),
+ * SDL_Vulkan_GetDrawableSize(), or SDL_GetRendererOutputSize() to query the
+ * drawable size in pixels.
+ *
+ * If the window is created with any of the SDL_WINDOW_OPENGL or
+ * SDL_WINDOW_VULKAN flags, then the corresponding LoadLibrary function
+ * (SDL_GL_LoadLibrary or SDL_Vulkan_LoadLibrary) is called and the
+ * corrensponding UnloadLibrary function is called by SDL_DestroyWindow().
+ *
+ * If SDL_WINDOW_VULKAN is specified and there isn't a working Vulkan driver,
+ * SDL_CreateWindow() will fail because SDL_Vulkan_LoadLibrary() will fail.
+ *
+ * \note On non-Apple devices, SDL requires you to either not link to the
+ * Vulkan loader or link to a dynamic library version. This limitation
+ * may be removed in a future version of SDL.
*
* \sa SDL_DestroyWindow()
+ * \sa SDL_GL_LoadLibrary()
+ * \sa SDL_Vulkan_LoadLibrary()
*/
extern DECLSPEC SDL_Window * SDLCALL SDL_CreateWindow(const char *title,
int x, int y, int w,
@@ -879,7 +893,7 @@ extern DECLSPEC float SDLCALL SDL_GetWindowBrightness(SDL_Window * window);
* \param window The window which will be made transparent or opaque
* \param opacity Opacity (0.0f - transparent, 1.0f - opaque) This will be
* clamped internally between 0.0f and 1.0f.
- *
+ *
* \return 0 on success, or -1 if setting the opacity isn't supported.
*
* \sa SDL_GetWindowOpacity()
@@ -906,7 +920,7 @@ extern DECLSPEC int SDLCALL SDL_GetWindowOpacity(SDL_Window * window, float * ou
*
* \param modal_window The window that should be modal
* \param parent_window The parent window
- *
+ *
* \return 0 on success, or -1 otherwise.
*/
extern DECLSPEC int SDLCALL SDL_SetWindowModalFor(SDL_Window * modal_window, SDL_Window * parent_window);
@@ -919,7 +933,7 @@ extern DECLSPEC int SDLCALL SDL_SetWindowModalFor(SDL_Window * modal_window, SDL
* obscured by other windows.
*
* \param window The window that should get the input focus
- *
+ *
* \return 0 on success, or -1 otherwise.
* \sa SDL_RaiseWindow()
*/
diff --git a/include/SDL_vulkan.h b/include/SDL_vulkan.h
new file mode 100644
index 0000000..f7b5191
--- /dev/null
+++ b/include/SDL_vulkan.h
@@ -0,0 +1,251 @@
+/*
+ Simple DirectMedia Layer
+ Copyright (C) 2017, Mark Callow.
+
+ This software is provided 'as-is', without any express or implied
+ warranty. In no event will the authors be held liable for any damages
+ arising from the use of this software.
+
+ Permission is granted to anyone to use this software for any purpose,
+ including commercial applications, and to alter it and redistribute it
+ freely, subject to the following restrictions:
+
+ 1. The origin of this software must not be misrepresented; you must not
+ claim that you wrote the original software. If you use this software
+ in a product, an acknowledgment in the product documentation would be
+ appreciated but is not required.
+ 2. Altered source versions must be plainly marked as such, and must not be
+ misrepresented as being the original software.
+ 3. This notice may not be removed or altered from any source distribution.
+ */
+
+/**
+ * \file SDL_vulkan.h
+ *
+ * Header file for functions to creating Vulkan surfaces on SDL windows.
+ */
+
+#ifndef SDL_vulkan_h_
+#define SDL_vulkan_h_
+
+#include "SDL_video.h"
+
+#include "begin_code.h"
+/* Set up for C function definitions, even when using C++ */
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/* Avoid including vulkan.h */
+#define VK_DEFINE_HANDLE(object) typedef struct object##_T* object;
+
+#if defined(__LP64__) || defined(_WIN64) || defined(__x86_64__) || defined(_M_X64) || defined(__ia64) || defined (_M_IA64) || defined(__aarch64__) || defined(__powerpc64__)
+#define VK_DEFINE_NON_DISPATCHABLE_HANDLE(object) typedef struct object##_T *object;
+#else
+#define VK_DEFINE_NON_DISPATCHABLE_HANDLE(object) typedef uint64_t object;
+#endif
+
+VK_DEFINE_HANDLE(VkInstance)
+VK_DEFINE_NON_DISPATCHABLE_HANDLE(VkSurfaceKHR)
+
+typedef VkInstance SDL_vulkanInstance;
+typedef VkSurfaceKHR SDL_vulkanSurface; /* for compatibility with Tizen */
+
+/**
+ * \name Vulkan support functions
+ *
+ * \note SDL_Vulkan_GetInstanceExtensions & SDL_Vulkan_CreateSurface API
+ * is compatable with Tizen's implementation of Vulkan in SDL.
+ */
+/* @{ */
+
+/**
+ * \brief Dynamically load a Vulkan loader library.
+ *
+ * \param [in] path The platform dependent Vulkan loader library name, or
+ * \c NULL to open the default Vulkan loader library.
+ *
+ * \return \c 0 on success, or \c -1 if the library couldn't be loaded.
+ *
+ * This should be done after initializing the video driver, but before
+ * creating any Vulkan windows. If no Vulkan loader library is loaded, the
+ * default library will be loaded upon creation of the first Vulkan window.
+ *
+ * \note If you specify a non-NULL \a path, you should retrieve all of the
+ * Vulkan functions used in your program from the dynamic library using
+ * \c SDL_Vulkan_GetVkGetInstanceProcAddr() unless you can guarantee
+ * \a path points to the same vulkan loader library that you linked to.
+ *
+ * \note On Apple devices, if \a path is NULL, SDL will attempt to find
+ * the vkGetInstanceProcAddr address within all the mach-o images of
+ * the current process. This is because the currently (v0.17.0)
+ * recommended MoltenVK (Vulkan on Metal) usage is as a static library.
+ * If it is not found then SDL will attempt to load \c libMoltenVK.dylib.
+ * Applications using the dylib alternative therefore do not need to do
+ * anything special when calling SDL.
+ *
+ * \note On non-Apple devices, SDL requires you to either not link to the
+ * Vulkan loader or link to a dynamic library version. This limitation
+ * may be removed in a future version of SDL.
+ *
+ * \note This function will fail if there are no working Vulkan drivers
+ * installed.
+ *
+ * \sa SDL_Vulkan_GetVkGetInstanceProcAddr()
+ * \sa SDL_Vulkan_UnloadLibrary()
+ */
+extern DECLSPEC int SDLCALL SDL_Vulkan_LoadLibrary(const char *path);
+
+/**
+ * \brief Get the address of the \c vkGetInstanceProcAddr function.
+ *
+ * \note This should be called after either calling SDL_Vulkan_LoadLibrary
+ * or creating an SDL_Window with the SDL_WINDOW_VULKAN flag.
+ */
+extern DECLSPEC void *SDLCALL SDL_Vulkan_GetVkGetInstanceProcAddr(void);
+
+/**
+ * \brief Unload the Vulkan loader library previously loaded by
+ * \c SDL_Vulkan_LoadLibrary().
+ *
+ * \sa SDL_Vulkan_LoadLibrary()
+ */
+extern DECLSPEC void SDLCALL SDL_Vulkan_UnloadLibrary(void);
+
+/**
+ * \brief Get the names of the Vulkan instance extensions needed to create
+ * a surface with \c SDL_Vulkan_CreateSurface().
+ *
+ * \param [in] window Window for which the required Vulkan instance
+ * extensions should be retrieved
+ * \param [in,out] count pointer to an \c unsigned related to the number of
+ * required Vulkan instance extensions
+ * \param [out] names \c NULL or a pointer to an array to be filled with the
+ * required Vulkan instance extensions
+ *
+ * \return \c SDL_TRUE on success, \c SDL_FALSE on error.
+ *
+ * If \a pNames is \c NULL, then the number of required Vulkan instance
+ * extensions is returned in pCount. Otherwise, \a pCount must point to a
+ * variable set to the number of elements in the \a pNames array, and on
+ * return the variable is overwritten with the number of names actually
+ * written to \a pNames. If \a pCount is less than the number of required
+ * extensions, at most \a pCount structures will be written. If \a pCount
+ * is smaller than the number of required extensions, \c SDL_FALSE will be
+ * returned instead of \c SDL_TRUE, to indicate that not all the required
+ * extensions were returned.
+ *
+ * \note The returned list of extensions will contain \c VK_KHR_surface
+ * and zero or more platform specific extensions
+ *
+ * \note The extension names queried here must be enabled when calling
+ * VkCreateInstance, otherwise surface creation will fail.
+ *
+ * \note \c window should have been created with the \c SDL_WINDOW_VULKAN flag.
+ *
+ * \code
+ * unsigned count;
+ * // get count of required extensions
+ * if(!SDL_Vulkan_GetInstanceExtensions(window, &count, NULL))
+ * handle_error();
+ *
+ * static const char *const additionalExtensions[] =
+ * {
+ * VK_EXT_DEBUG_REPORT_EXTENSION_NAME, // example additional extension
+ * };
+ * size_t additionalExtensionsCount = sizeof(additionalExtensions) / sizeof(additionalExtensions[0]);
+ * size_t extensionCount = count + additionalExtensionsCount;
+ * const char **names = malloc(sizeof(const char *) * extensionCount);
+ * if(!names)
+ * handle_error();
+ *
+ * // get names of required extensions
+ * if(!SDL_Vulkan_GetInstanceExtensions(window, &count, names))
+ * handle_error();
+ *
+ * // copy additional extensions after required extensions
+ * for(size_t i = 0; i < additionalExtensionsCount; i++)
+ * names[i + count] = additionalExtensions[i];
+ *
+ * VkInstanceCreateInfo instanceCreateInfo = {};
+ * instanceCreateInfo.enabledExtensionCount = extensionCount;
+ * instanceCreateInfo.ppEnabledExtensionNames = names;
+ * // fill in rest of instanceCreateInfo
+ *
+ * VkInstance instance;
+ * // create the Vulkan instance
+ * VkResult result = vkCreateInstance(&instanceCreateInfo, NULL, &instance);
+ * free(names);
+ * \endcode
+ *
+ * \sa SDL_Vulkan_CreateSurface()
+ */
+extern DECLSPEC SDL_bool SDLCALL SDL_Vulkan_GetInstanceExtensions(
+ SDL_Window *window,
+ unsigned *pCount,
+ const char **pNames);
+
+/**
+ * \brief Create a Vulkan rendering surface for a window.
+ *
+ * \param [in] window SDL_Window to which to attach the rendering surface.
+ * \param [in] instance handle to the Vulkan instance to use.
+ * \param [out] surface pointer to a VkSurfaceKHR handle to receive the
+ * handle of the newly created surface.
+ *
+ * \return \c SDL_TRUE on success, \c SDL_FALSE on error.
+ *
+ * \code
+ * VkInstance instance;
+ * SDL_Window *window;
+ *
+ * // create instance and window
+ *
+ * // create the Vulkan surface
+ * VkSurfaceKHR surface;
+ * if(!SDL_Vulkan_CreateSurface(window, instance, &surface))
+ * handle_error();
+ * \endcode
+ *
+ * \note \a window should have been created with the \c SDL_WINDOW_VULKAN flag.
+ *
+ * \note \a instance should have been created with the extensions returned
+ * by \c SDL_Vulkan_CreateSurface() enabled.
+ *
+ * \sa SDL_Vulkan_GetInstanceExtensions()
+ */
+extern DECLSPEC SDL_bool SDLCALL SDL_Vulkan_CreateSurface(
+ SDL_Window *window,
+ VkInstance instance,
+ VkSurfaceKHR* surface);
+
+/**
+ * \brief Get the size of a window's underlying drawable in pixels (for use
+ * with setting viewport, scissor & etc).
+ *
+ * \param window SDL_Window from which the drawable size should be queried
+ * \param w Pointer to variable for storing the width in pixels,
+ * may be NULL
+ * \param h Pointer to variable for storing the height in pixels,
+ * may be NULL
+ *
+ * This may differ from SDL_GetWindowSize() if we're rendering to a high-DPI
+ * drawable, i.e. the window was created with SDL_WINDOW_ALLOW_HIGHDPI on a
+ * platform with high-DPI support (Apple calls this "Retina"), and not disabled
+ * by the \c SDL_HINT_VIDEO_HIGHDPI_DISABLED hint.
+ *
+ * \sa SDL_GetWindowSize()
+ * \sa SDL_CreateWindow()
+ */
+extern DECLSPEC void SDLCALL SDL_Vulkan_GetDrawableSize(SDL_Window * window,
+ int *w, int *h);
+
+/* @} *//* Vulkan support functions */
+
+/* Ends C function definitions when using C++ */
+#ifdef __cplusplus
+}
+#endif
+#include "close_code.h"
+
+#endif /* SDL_vulkan_h_ */
diff --git a/src/test/SDL_test_common.c b/src/test/SDL_test_common.c
index 184a097..c9bcbaf 100644
--- a/src/test/SDL_test_common.c
+++ b/src/test/SDL_test_common.c
@@ -886,7 +886,7 @@ SDLTest_CommonInit(SDLTest_CommonState * state)
if (!state->skip_renderer
&& (state->renderdriver
- || !(state->window_flags & SDL_WINDOW_OPENGL))) {
+ || !(state->window_flags & (SDL_WINDOW_OPENGL | SDL_WINDOW_VULKAN)))) {
m = -1;
if (state->renderdriver) {
SDL_RendererInfo info;
diff --git a/src/video/SDL_sysvideo.h b/src/video/SDL_sysvideo.h
index c3ca82d..5b2bea5 100644
--- a/src/video/SDL_sysvideo.h
+++ b/src/video/SDL_sysvideo.h
@@ -26,6 +26,7 @@
#include "SDL_messagebox.h"
#include "SDL_shape.h"
#include "SDL_thread.h"
+#include "SDL_vulkan.h"
/* The SDL video driver */
@@ -262,6 +263,16 @@ struct SDL_VideoDevice
/* * * */
/*
+ * Vulkan support
+ */
+ int (*Vulkan_LoadLibrary) (_THIS, const char *path);
+ void (*Vulkan_UnloadLibrary) (_THIS);
+ SDL_bool (*Vulkan_GetInstanceExtensions) (_THIS, SDL_Window *window, unsigned *count, const char **names);
+ SDL_bool (*Vulkan_CreateSurface) (_THIS, SDL_Window *window, VkInstance instance, VkSurfaceKHR *surface);
+ void (*Vulkan_GetDrawableSize) (_THIS, SDL_Window * window, int *w, int *h);
+
+ /* * * */
+ /*
* Event manager functions
*/
void (*PumpEvents) (_THIS);
@@ -349,6 +360,17 @@ struct SDL_VideoDevice
SDL_TLSID current_glctx_tls;
/* * * */
+ /* Data used by the Vulkan drivers */
+ struct
+ {
+ void *vkGetInstanceProcAddr;
+ void *vkEnumerateInstanceExtensionProperties;
+ int loader_loaded;
+ char loader_path[256];
+ void *loader_handle;
+ } vulkan_config;
+
+ /* * * */
/* Data private to this driver */
void *driverdata;
struct SDL_GLDriverData *gl_data;
diff --git a/src/video/SDL_video.c b/src/video/SDL_video.c
index 4c6b45c..ae9d3a1 100644
--- a/src/video/SDL_video.c
+++ b/src/video/SDL_video.c
@@ -1329,7 +1329,7 @@ SDL_UpdateFullscreenMode(SDL_Window * window, SDL_bool fullscreen)
}
#define CREATE_FLAGS \
- (SDL_WINDOW_OPENGL | SDL_WINDOW_BORDERLESS | SDL_WINDOW_RESIZABLE | SDL_WINDOW_ALLOW_HIGHDPI | SDL_WINDOW_ALWAYS_ON_TOP | SDL_WINDOW_SKIP_TASKBAR | SDL_WINDOW_POPUP_MENU | SDL_WINDOW_UTILITY | SDL_WINDOW_TOOLTIP | SDL_WINDOW_VULKAN )
+ (SDL_WINDOW_OPENGL | SDL_WINDOW_BORDERLESS | SDL_WINDOW_RESIZABLE | SDL_WINDOW_ALLOW_HIGHDPI | SDL_WINDOW_ALWAYS_ON_TOP | SDL_WINDOW_SKIP_TASKBAR | SDL_WINDOW_POPUP_MENU | SDL_WINDOW_UTILITY | SDL_WINDOW_TOOLTIP | SDL_WINDOW_VULKAN)
static void
SDL_FinishWindowCreation(SDL_Window *window, Uint32 flags)
@@ -1384,7 +1384,7 @@ SDL_CreateWindow(const char *title, int x, int y, int w, int h, Uint32 flags)
/* Some platforms have OpenGL enabled by default */
#if (SDL_VIDEO_OPENGL && __MACOSX__) || __IPHONEOS__ || __ANDROID__ || __NACL__
- if (!_this->is_dummy) {
+ if (!_this->is_dummy && !(flags & SDL_WINDOW_VULKAN)) {
flags |= SDL_WINDOW_OPENGL;
}
#endif
@@ -1398,6 +1398,25 @@ SDL_CreateWindow(const char *title, int x, int y, int w, int h, Uint32 flags)
}
}
+ if(flags & SDL_WINDOW_VULKAN)
+ {
+ if(!_this->Vulkan_CreateSurface)
+ {
+ SDL_SetError("Vulkan support is either not configured in SDL "
+ "or not available in video driver");
+ return NULL;
+ }
+ if(flags & SDL_WINDOW_OPENGL)
+ {
+ SDL_SetError("Vulkan and OpenGL not supported on same window");
+ return NULL;
+ }
+ if(SDL_Vulkan_LoadLibrary(NULL) < 0)
+ {
+ return NULL;
+ }
+ }
+
/* Unless the user has specified the high-DPI disabling hint, respect the
* SDL_WINDOW_ALLOW_HIGHDPI flag.
*/
@@ -1573,6 +1592,16 @@ SDL_RecreateWindow(SDL_Window * window, Uint32 flags)
}
}
+ if ((window->flags & SDL_WINDOW_VULKAN) != (flags & SDL_WINDOW_VULKAN)) {
+ SDL_SetError("Can't change SDL_WINDOW_VULKAN window flag");
+ return -1;
+ }
+
+ if ((window->flags & SDL_WINDOW_VULKAN) && (flags & SDL_WINDOW_OPENGL)) {
+ SDL_SetError("Vulkan and OpenGL not supported on same window");
+ return -1;
+ }
+
window->flags = ((flags & CREATE_FLAGS) | SDL_WINDOW_HIDDEN);
window->last_fullscreen_flags = window->flags;
window->is_destroying = SDL_FALSE;
@@ -2632,6 +2661,9 @@ SDL_DestroyWindow(SDL_Window * window)
if (window->flags & SDL_WINDOW_OPENGL) {
SDL_GL_UnloadLibrary();
}
+ if (window->flags & SDL_WINDOW_VULKAN) {
+ SDL_Vulkan_UnloadLibrary();
+ }
display = SDL_GetDisplayForWindow(window);
if (display->fullscreen_window == window) {
@@ -3946,4 +3978,128 @@ void SDL_OnApplicationDidBecomeActive(void)
}
}
+#define NOT_A_VULKAN_WINDOW "The specified window isn't a Vulkan window."
+
+int SDL_Vulkan_LoadLibrary(const char *path)
+{
+ int retval;
+ if(!_this)
+ {
+ SDL_UninitializedVideo();
+ return -1;
+ }
+ if(_this->vulkan_config.loader_loaded)
+ {
+ if(path && SDL_strcmp(path, _this->vulkan_config.loader_path) != 0)
+ {
+ return SDL_SetError("Vulkan loader library already loaded");
+ }
+ retval = 0;
+ }
+ else
+ {
+ if(!_this->Vulkan_LoadLibrary)
+ {
+ return SDL_SetError("No Vulkan support in video driver");
+ }
+ retval = _this->Vulkan_LoadLibrary(_this, path);
+ }
+ if(retval == 0)
+ {
+ _this->vulkan_config.loader_loaded++;
+ }
+ return retval;
+}
+
+void *SDL_Vulkan_GetVkGetInstanceProcAddr(void)
+{
+ if(!_this)
+ {
+ SDL_UninitializedVideo();
+ return NULL;
+ }
+ if(!_this->vulkan_config.loader_loaded)
+ {
+ SDL_SetError("No Vulkan loader has been loaded");
+ }
+ return _this->vulkan_config.vkGetInstanceProcAddr;
+}
+
+void SDL_Vulkan_UnloadLibrary(void)
+{
+ if(!_this)
+ {
+ SDL_UninitializedVideo();
+ return;
+ }
+ if(_this->vulkan_config.loader_loaded > 0)
+ {
+ if(--_this->vulkan_config.loader_loaded > 0)
+ {
+ return;
+ }
+ if(_this->Vulkan_UnloadLibrary)
+ {
+ _this->Vulkan_UnloadLibrary(_this);
+ }
+ }
+}
+
+SDL_bool SDL_Vulkan_GetInstanceExtensions(SDL_Window *window, unsigned *count, const char **names)
+{
+ CHECK_WINDOW_MAGIC(window, SDL_FALSE);
+
+ if(!(window->flags & SDL_WINDOW_VULKAN))
+ {
+ SDL_SetError(NOT_A_VULKAN_WINDOW);
+ return SDL_FALSE;
+ }
+
+ if(!count)
+ {
+ SDL_SetError("invalid count");
+ return SDL_FALSE;
+ }
+
+ return _this->Vulkan_GetInstanceExtensions(_this, window, count, names);
+}
+
+SDL_bool SDL_Vulkan_CreateSurface(SDL_Window *window,
+ VkInstance instance,
+ VkSurfaceKHR *surface)
+{
+ CHECK_WINDOW_MAGIC(window, SDL_FALSE);
+
+ if(!(window->flags & SDL_WINDOW_VULKAN))
+ {
+ SDL_SetError(NOT_A_VULKAN_WINDOW);
+ return SDL_FALSE;
+ }
+
+ if(!instance)
+ {
+ SDL_SetError("invalid instance");
+ return SDL_FALSE;
+ }
+
+ if(!surface)
+ {
+ SDL_SetError("invalid surface");
+ return SDL_FALSE;
+ }
+
+ return _this->Vulkan_CreateSurface(_this, window, instance, surface);
+}
+
+void SDL_Vulkan_GetDrawableSize(SDL_Window * window, int *w, int *h)
+{
+ CHECK_WINDOW_MAGIC(window,);
+
+ if (_this->Vulkan_GetDrawableSize) {
+ _this->Vulkan_GetDrawableSize(_this, window, w, h);
+ } else {
+ SDL_GetWindowSize(window, w, h);
+ }
+}
+
/* vi: set ts=4 sw=4 expandtab: */
diff --git a/src/video/SDL_vulkan_internal.h b/src/video/SDL_vulkan_internal.h
new file mode 100644
index 0000000..ab68ea9
--- /dev/null
+++ b/src/video/SDL_vulkan_internal.h
@@ -0,0 +1,80 @@
+/*
+ Simple DirectMedia Layer
+ Copyright (C) 1997-2016 Sam Lantinga <slouken@libsdl.org>
+
+ This software is provided 'as-is', without any express or implied
+ warranty. In no event will the authors be held liable for any damages
+ arising from the use of this software.
+
+ Permission is granted to anyone to use this software for any purpose,
+ including commercial applications, and to alter it and redistribute it
+ freely, subject to the following restrictions:
+
+ 1. The origin of this software must not be misrepresented; you must not
+ claim that you wrote the original software. If you use this software
+ in a product, an acknowledgment in the product documentation would be
+ appreciated but is not required.
+ 2. Altered source versions must be plainly marked as such, and must not be
+ misrepresented as being the original software.
+ 3. This notice may not be removed or altered from any source distribution.
+*/
+#ifndef _SDL_vulkan_internal_h
+#define _SDL_vulkan_internal_h
+
+#include "../SDL_internal.h"
+
+#include "SDL_stdinc.h"
+
+#if defined(SDL_LOADSO_DISABLED)
+#undef SDL_VIDEO_VULKAN_SURFACE
+#define SDL_VIDEO_VULKAN_SURFACE 0
+#endif
+
+#if SDL_VIDEO_DRIVER_ANDROID
+#define VK_USE_PLATFORM_ANDROID_KHR
+#endif
+#if SDL_VIDEO_DRIVER_COCOA
+#define VK_USE_PLATFORM_MACOS_MVK
+#endif
+#if SDL_VIDEO_DRIVER_MIR
+#define VK_USE_PLATFORM_MIR_KHR
+#endif
+#if SDL_VIDEO_DRIVER_UIKIT
+#define VK_USE_PLATFORM_IOS_MVK
+#endif
+#if SDL_VIDEO_DRIVER_WAYLAND
+#define VK_USE_PLATFORM_WAYLAND_KHR
+#endif
+#if SDL_VIDEO_DRIVER_WINDOWS
+#define VK_USE_PLATFORM_WIN32_KHR
+#endif
+#if SDL_VIDEO_DRIVER_X11
+#define VK_USE_PLATFORM_XLIB_KHR
+#define VK_USE_PLATFORM_XCB_KHR
+#endif
+
+#if SDL_VIDEO_VULKAN_SURFACE
+
+/* Need vulkan.h for the following declarations. Must ensure the first
+ * inclusion of vulkan has the appropriate USE_PLATFORM defined, hence
+ * the above. */
+#define VK_NO_PROTOTYPES
+#include "vulkan/vulkan.h"
+
+extern const char *SDL_Vulkan_GetResultString(VkResult result);
+
+extern VkExtensionProperties *SDL_Vulkan_CreateInstanceExtensionsList(
+ PFN_vkEnumerateInstanceExtensionProperties vkEnumerateInstanceExtensionProperties,
+ Uint32 *extensionCount); /* free returned list with SDL_free */
+
+/* Implements functionality of SDL_Vulkan_GetInstanceExtensions for a list of
+ * names passed in nameCount and names. */
+extern SDL_bool SDL_Vulkan_GetInstanceExtensions_Helper(unsigned *userCount,
+ const char **userNames,
+ unsigned nameCount,
+ const char *const *names);
+
+#endif
+
+#endif
+/* vi: set ts=4 sw=4 expandtab: */
diff --git a/src/video/SDL_vulkan_utils.c b/src/video/SDL_vulkan_utils.c
new file mode 100644
index 0000000..d571409
--- /dev/null
+++ b/src/video/SDL_vulkan_utils.c
@@ -0,0 +1,191 @@
+/*
+ Simple DirectMedia Layer
+ Copyright (C) 1997-2016 Sam Lantinga <slouken@libsdl.org>
+
+ This software is provided 'as-is', without any express or implied
+ warranty. In no event will the authors be held liable for any damages
+ arising from the use of this software.
+
+ Permission is granted to anyone to use this software for any purpose,
+ including commercial applications, and to alter it and redistribute it
+ freely, subject to the following restrictions:
+
+ 1. The origin of this software must not be misrepresented; you must not
+ claim that you wrote the original software. If you use this software
+ in a product, an acknowledgment in the product documentation would be
+ appreciated but is not required.
+ 2. Altered source versions must be plainly marked as such, and must not be
+ misrepresented as being the original software.
+ 3. This notice may not be removed or altered from any source distribution.
+*/
+#include "../SDL_internal.h"
+
+#include "SDL_vulkan_internal.h"
+#include "SDL_error.h"
+
+#if SDL_VIDEO_VULKAN_SURFACE
+
+/* Based on the headers found in
+ * https://github.com/KhronosGroup/Vulkan-LoaderAndValidationLayers
+ */
+#if VK_HEADER_VERSION < 22
+enum
+{
+ VK_ERROR_FRAGMENTED_POOL = -12,
+};
+#endif
+#if VK_HEADER_VERSION < 38
+enum {
+ VK_ERROR_OUT_OF_POOL_MEMORY_KHR = -1000069000
+};
+#endif
+
+const char *SDL_Vulkan_GetResultString(VkResult result)
+{
+ switch((int)result)
+ {
+ case VK_SUCCESS:
+ return "VK_SUCCESS";
+ case VK_NOT_READY:
+ return "VK_NOT_READY";
+ case VK_TIMEOUT:
+ return "VK_TIMEOUT";
+ case VK_EVENT_SET:
+ return "VK_EVENT_SET";
+ case VK_EVENT_RESET:
+ return "VK_EVENT_RESET";
+ case VK_INCOMPLETE:
+ return "VK_INCOMPLETE";
+ case VK_ERROR_OUT_OF_HOST_MEMORY:
+ return "VK_ERROR_OUT_OF_HOST_MEMORY";
+ case VK_ERROR_OUT_OF_DEVICE_MEMORY:
+ return "VK_ERROR_OUT_OF_DEVICE_MEMORY";
+ case VK_ERROR_INITIALIZATION_FAILED:
+ return "VK_ERROR_INITIALIZATION_FAILED";
+ case VK_ERROR_DEVICE_LOST:
+ return "VK_ERROR_DEVICE_LOST";
+ case VK_ERROR_MEMORY_MAP_FAILED:
+ return "VK_ERROR_MEMORY_MAP_FAILED";
+ case VK_ERROR_LAYER_NOT_PRESENT:
+ return "VK_ERROR_LAYER_NOT_PRESENT";
+ case VK_ERROR_EXTENSION_NOT_PRESENT:
+ return "VK_ERROR_EXTENSION_NOT_PRESENT";
+ case VK_ERROR_FEATURE_NOT_PRESENT:
+ return "VK_ERROR_FEATURE_NOT_PRESENT";
+ case VK_ERROR_INCOMPATIBLE_DRIVER:
+ return "VK_ERROR_INCOMPATIBLE_DRIVER";
+ case VK_ERROR_TOO_MANY_OBJECTS:
+ return "VK_ERROR_TOO_MANY_OBJECTS";
+ case VK_ERROR_FORMAT_NOT_SUPPORTED:
+ return "VK_ERROR_FORMAT_NOT_SUPPORTED";
+ case VK_ERROR_FRAGMENTED_POOL:
+ return "VK_ERROR_FRAGMENTED_POOL";
+ case VK_ERROR_SURFACE_LOST_KHR:
+ return "VK_ERROR_SURFACE_LOST_KHR";
+ case VK_ERROR_NATIVE_WINDOW_IN_USE_KHR:
+ return "VK_ERROR_NATIVE_WINDOW_IN_USE_KHR";
+ case VK_SUBOPTIMAL_KHR:
+ return "VK_SUBOPTIMAL_KHR";
+ case VK_ERROR_OUT_OF_DATE_KHR:
+ return "VK_ERROR_OUT_OF_DATE_KHR";
+ case VK_ERROR_INCOMPATIBLE_DISPLAY_KHR:
+ return "VK_ERROR_INCOMPATIBLE_DISPLAY_KHR";
+ case VK_ERROR_VALIDATION_FAILED_EXT:
+ return "VK_ERROR_VALIDATION_FAILED_EXT";
+ case VK_ERROR_OUT_OF_POOL_MEMORY_KHR:
+ return "VK_ERROR_OUT_OF_POOL_MEMORY_KHR";
+ case VK_ERROR_INVALID_SHADER_NV:
+ return "VK_ERROR_INVALID_SHADER_NV";
+ case VK_RESULT_MAX_ENUM:
+ case VK_RESULT_RANGE_SIZE:
+ break;
+ }
+ if(result < 0)
+ return "VK_ERROR_<Unknown>";
+ return "VK_<Unknown>";
+}
+
+VkExtensionProperties *SDL_Vulkan_CreateInstanceExtensionsList(
+ PFN_vkEnumerateInstanceExtensionProperties vkEnumerateInstanceExtensionProperties,
+ Uint32 *extensionCount)
+{
+ Uint32 count = 0;
+ VkResult result = vkEnumerateInstanceExtensionProperties(NULL, &count, NULL);
+ VkExtensionProperties *retval;
+ if(result == VK_ERROR_INCOMPATIBLE_DRIVER)
+ {
+ SDL_SetError(
+ "You probably don't have a working Vulkan driver installed: getting Vulkan "
+ "extensions failed: vkEnumerateInstanceExtensionProperties returned %s(%d)",
+ SDL_Vulkan_GetResultString(result),
+ (int)result);
+ return NULL;
+ }
+ else if(result != VK_SUCCESS)
+ {
+ SDL_SetError(
+ "Getting Vulkan extensions failed: vkEnumerateInstanceExtensionProperties returned "
+ "%s(%d)",
+ SDL_Vulkan_GetResultString(result),
+ (int)result);
+ return NULL;
+ }
+ if(count == 0)
+ {
+ retval = SDL_calloc(1, sizeof(VkExtensionProperties)); // so we can return non-null
+ if(!retval)
+ {
+ SDL_OutOfMemory();
+ return NULL;
+ }
+ *extensionCount = 0;
+ }
+ retval = SDL_calloc(count, sizeof(VkExtensionProperties));
+ if(!retval)
+ {
+ SDL_OutOfMemory();
+ return NULL;
+ }
+ result = vkEnumerateInstanceExtensionProperties(NULL, &count, retval);
+ if(result != VK_SUCCESS)
+ {
+ SDL_SetError(
+ "Getting Vulkan extensions failed: vkEnumerateInstanceExtensionProperties returned "
+ "%s(%d)",
+ SDL_Vulkan_GetResultString(result),
+ (int)result);
+ SDL_free(retval);
+ return NULL;
+ }
+ *extensionCount = count;
+ return retval;
+}
+
+SDL_bool SDL_Vulkan_GetInstanceExtensions_Helper(unsigned *userCount,
+ const char **userNames,
+ unsigned nameCount,
+ const char *const *names)
+{
+ if(userNames)
+ {
+ unsigned int i;
+
+ if(*userCount != nameCount)
+ {
+ SDL_SetError(
+ "Count doesn't match count from previous call of SDL_Vulkan_GetInstanceExtensions");
+ return SDL_FALSE;
+ }
+ for(i = 0; i < nameCount; i++)
+ {
+ userNames[i] = names[i];
+ }
+ }
+ else
+ {
+ *userCount = nameCount;
+ }
+ return SDL_TRUE;
+}
+
+#endif
diff --git a/src/video/android/SDL_androidvideo.c b/src/video/android/SDL_androidvideo.c
index e5e70f9..d988701 100644
--- a/src/video/android/SDL_androidvideo.c
+++ b/src/video/android/SDL_androidvideo.c
@@ -40,6 +40,7 @@
#include "SDL_androidmouse.h"
#include "SDL_androidtouch.h"
#include "SDL_androidwindow.h"
+#include "SDL_androidvulkan.h"
#define ANDROID_VID_DRIVER_NAME "Android"
@@ -132,6 +133,13 @@ Android_CreateDevice(int devindex)
device->GL_SwapWindow = Android_GLES_SwapWindow;
device->GL_DeleteContext = Android_GLES_DeleteContext;
+#if SDL_VIDEO_VULKAN_SURFACE
+ device->Vulkan_LoadLibrary = Android_Vulkan_LoadLibrary;
+ device->Vulkan_UnloadLibrary = Android_Vulkan_UnloadLibrary;
+ device->Vulkan_GetInstanceExtensions = Android_Vulkan_GetInstanceExtensions;
+ device->Vulkan_CreateSurface = Android_Vulkan_CreateSurface;
+#endif
+
/* Screensaver */
device->SuspendScreenSaver = Android_SuspendScreenSaver;
diff --git a/src/video/android/SDL_androidvulkan.c b/src/video/android/SDL_androidvulkan.c
new file mode 100644
index 0000000..c8e4c88
--- /dev/null
+++ b/src/video/android/SDL_androidvulkan.c
@@ -0,0 +1,174 @@
+/*
+ Simple DirectMedia Layer
+ Copyright (C) 1997-2016 Sam Lantinga <slouken@libsdl.org>
+
+ This software is provided 'as-is', without any express or implied
+ warranty. In no event will the authors be held liable for any damages
+ arising from the use of this software.
+
+ Permission is granted to anyone to use this software for any purpose,
+ including commercial applications, and to alter it and redistribute it
+ freely, subject to the following restrictions:
+
+ 1. The origin of this software must not be misrepresented; you must not
+ claim that you wrote the original software. If you use this software
+ in a product, an acknowledgment in the product documentation would be
+ appreciated but is not required.
+ 2. Altered source versions must be plainly marked as such, and must not be
+ misrepresented as being the original software.
+ 3. This notice may not be removed or altered from any source distribution.
+*/
+
+/*
+ * @author Mark Callow, www.edgewise-consulting.com. Based on Jacob Lifshay's
+ * SDL_x11vulkan.c.
+ */
+
+#include "../../SDL_internal.h"
+
+#if SDL_VIDEO_VULKAN_SURFACE && SDL_VIDEO_DRIVER_ANDROID
+
+#include "SDL_androidvideo.h"
+#include "SDL_androidwindow.h"
+#include "SDL_assert.h"
+
+#include "SDL_loadso.h"
+#include "SDL_androidvulkan.h"
+#include "SDL_syswm.h"
+
+int Android_Vulkan_LoadLibrary(_THIS, const char *path)
+{
+ VkExtensionProperties *extensions = NULL;
+ Uint32 extensionCount = 0;
+ SDL_bool hasSurfaceExtension = SDL_FALSE;
+ SDL_bool hasAndroidSurfaceExtension = SDL_FALSE;
+ PFN_vkGetInstanceProcAddr vkGetInstanceProcAddr = NULL;
+ if(_this->vulkan_config.loader_handle)
+ return SDL_SetError("Vulkan already loaded");
+
+ /* Load the Vulkan loader library */
+ if(!path)
+ path = SDL_getenv("SDL_VULKAN_LIBRARY");
+ if(!path)
+ path = "libvulkan.so.1";
+ _this->vulkan_config.loader_handle = SDL_LoadObject(path);
+ if(!_this->vulkan_config.loader_handle)
+ return -1;
+ SDL_strlcpy(_this->vulkan_config.loader_path, path,
+ SDL_arraysize(_this->vulkan_config.loader_path));
+ vkGetInstanceProcAddr = (PFN_vkGetInstanceProcAddr)SDL_LoadFunction(
+ _this->vulkan_config.loader_handle, "vkGetInstanceProcAddr");
+ if(!vkGetInstanceProcAddr)
+ goto fail;
+ _this->vulkan_config.vkGetInstanceProcAddr = (void *)vkGetInstanceProcAddr;
+ _this->vulkan_config.vkEnumerateInstanceExtensionProperties =
+ (void *)((PFN_vkGetInstanceProcAddr)_this->vulkan_config.vkGetInstanceProcAddr)(
+ VK_NULL_HANDLE, "vkEnumerateInstanceExtensionProperties");
+ if(!_this->vulkan_config.vkEnumerateInstanceExtensionProperties)
+ goto fail;
+ extensions = SDL_Vulkan_CreateInstanceExtensionsList(
+ (PFN_vkEnumerateInstanceExtensionProperties)
+ _this->vulkan_config.vkEnumerateInstanceExtensionProperties,
+ &extensionCount);
+ if(!extensions)
+ goto fail;
+ for(Uint32 i = 0; i < extensionCount; i++)
+ {
+ if(SDL_strcmp(VK_KHR_SURFACE_EXTENSION_NAME, extensions[i].extensionName) == 0)
+ hasSurfaceExtension = SDL_TRUE;
+ else if(SDL_strcmp(VK_KHR_ANDROID_SURFACE_EXTENSION_NAME, extensions[i].extensionName) == 0)
+ hasAndroidSurfaceExtension = SDL_TRUE;
+ }
+ SDL_free(extensions);
+ if(!hasSurfaceExtension)
+ {
+ SDL_SetError("Installed Vulkan doesn't implement the "
+ VK_KHR_SURFACE_EXTENSION_NAME " extension");
+ goto fail;
+ }
+ else if(!hasAndroidSurfaceExtension)
+ {
+ SDL_SetError("Installed Vulkan doesn't implement the "
+ VK_KHR_ANDROID_SURFACE_EXTENSION_NAME "extension");
+ goto fail;
+ }
+ return 0;
+
+fail:
+ SDL_UnloadObject(_this->vulkan_config.loader_handle);
+ _this->vulkan_config.loader_handle = NULL;
+ return -1;
+}
+
+void Android_Vulkan_UnloadLibrary(_THIS)
+{
+ if(_this->vulkan_config.loader_handle)
+ {
+ SDL_UnloadObject(_this->vulkan_config.loader_handle);
+ _this->vulkan_config.loader_handle = NULL;
+ }
+}
+
+SDL_bool Android_Vulkan_GetInstanceExtensions(_THIS,
+ SDL_Window *window,
+ unsigned *count,
+ const char **names)
+{
+ static const char *const extensionsForAndroid[] = {
+ VK_KHR_SURFACE_EXTENSION_NAME, VK_KHR_ANDROID_SURFACE_EXTENSION_NAME
+ };
+ if(!_this->vulkan_config.loader_handle)
+ {
+ SDL_SetError("Vulkan is not loaded");
+ return SDL_FALSE;
+ }
+ return SDL_Vulkan_GetInstanceExtensions_Helper(
+ count, names, SDL_arraysize(extensionsForMir),
+ extensionsForAndroid);
+}
+
+SDL_bool Android_Vulkan_CreateSurface(_THIS,
+ SDL_Window *window,
+ VkInstance instance,
+ VkSurfaceKHR *surface)
+{
+ SDL_WindowData *windowData = (SDL_WindowData *)window->driverdata;
+ PFN_vkGetInstanceProcAddr vkGetInstanceProcAddr =
+ (PFN_vkGetInstanceProcAddr)_this->vulkan_config.vkGetInstanceProcAddr;
+ PFN_vkCreateAndroidSurfaceKHR vkCreateAndroidSurfaceKHR =
+ (PFN_vkCreateAndroidSurfaceKHR)vkGetInstanceProcAddr(
+ (VkInstance)instance,
+ "vkCreateAndroidSurfaceKHR");
+ VkAndroidSurfaceCreateInfoKHR createInfo = {};
+ VkResult result;
+
+ if(!_this->vulkan_config.loader_handle)
+ {
+ SDL_SetError("Vulkan is not loaded");
+ return SDL_FALSE;
+ }
+
+ if(!vkCreateAndroidSurfaceKHR)
+ {
+ SDL_SetError(VK_KHR_Android_SURFACE_EXTENSION_NAME
+ " extension is not enabled in the Vulkan instance.");
+ return SDL_FALSE;
+ }
+ createInfo.sType = VK_STRUCTURE_TYPE_Android_SURFACE_CREATE_INFO_KHR;
+ createInfo.pNext = NULL;
+ createInfo.flags = 0;
+ createInfo.window = windowData->native_window;
+ result = vkCreateAndroidSurfaceKHR(instance, &createInfo,
+ NULL, surface);
+ if(result != VK_SUCCESS)
+ {
+ SDL_SetError("vkCreateAndroidSurfaceKHR failed: %s",
+ SDL_Vulkan_GetResultString(result));
+ return SDL_FALSE;
+ }
+ return SDL_TRUE;
+}
+
+#endif
+
+/* vi: set ts=4 sw=4 expandtab: */
diff --git a/src/video/android/SDL_androidvulkan.h b/src/video/android/SDL_androidvulkan.h
new file mode 100644
index 0000000..d7d372c
--- /dev/null
+++ b/src/video/android/SDL_androidvulkan.h
@@ -0,0 +1,52 @@
+/*
+ Simple DirectMedia Layer
+ Copyright (C) 1997-2016 Sam Lantinga <slouken@libsdl.org>
+
+ This software is provided 'as-is', without any express or implied
+ warranty. In no event will the authors be held liable for any damages
+ arising from the use of this software.
+
+ Permission is granted to anyone to use this software for any purpose,
+ including commercial applications, and to alter it and redistribute it
+ freely, subject to the following restrictions:
+
+ 1. The origin of this software must not be misrepresented; you must not
+ claim that you wrote the original software. If you use this software
+ in a product, an acknowledgment in the product documentation would be
+ appreciated but is not required.
+ 2. Altered source versions must be plainly marked as such, and must not be
+ misrepresented as being the original software.
+ 3. This notice may not be removed or altered from any source distribution.
+*/
+
+/*
+ * @author Mark Callow, www.edgewise-consulting.com. Based on Jacob Lifshay's
+ * SDL_x11vulkan.h.
+ */
+
+#include "../../SDL_internal.h"
+
+#ifndef _SDL_androidvulkan_h
+#define _SDL_androidvulkan_h
+
+#include "../SDL_vulkan_internal.h"
+#include "../SDL_sysvideo.h"
+
+#if SDL_VIDEO_VULKAN_SURFACE && SDL_VIDEO_DRIVER_ANDROID
+
+int Android_Vulkan_LoadLibrary(_THIS, const char *path);
+void Android_Vulkan_UnloadLibrary(_THIS);
+SDL_bool Android_Vulkan_GetInstanceExtensions(_THIS,
+ SDL_Window *window,
+ unsigned *count,
+ const char **names);
+SDL_bool Android_Vulkan_CreateSurface(_THIS,
+ SDL_Window *window,
+ VkInstance instance,
+ VkSurfaceKHR *surface);
+
+#endif
+
+#endif /* _SDL_androidvulkan_h */
+
+/* vi: set ts=4 sw=4 expandtab: */
diff --git a/src/video/cocoa/SDL_cocoametalview.h b/src/video/cocoa/SDL_cocoametalview.h
new file mode 100644
index 0000000..be96b2b
--- /dev/null
+++ b/src/video/cocoa/SDL_cocoametalview.h
@@ -0,0 +1,61 @@
+/*
+ Simple DirectMedia Layer
+ Copyright (C) 1997-2017 Sam Lantinga <slouken@libsdl.org>
+
+ This software is provided 'as-is', without any express or implied
+ warranty. In no event will the authors be held liable for any damages
+ arising from the use of this software.
+
+ Permission is granted to anyone to use this software for any purpose,
+ including commercial applications, and to alter it and redistribute it
+ freely, subject to the following restrictions:
+
+ 1. The origin of this software must not be misrepresented; you must not
+ claim that you wrote the original software. If you use this software
+ in a product, an acknowledgment in the product documentation would be
+ appreciated but is not required.
+ 2. Altered source versions must be plainly marked as such, and must not be
+ misrepresented as being the original software.
+ 3. This notice may not be removed or altered from any source distribution.
+ */
+
+/*
+ * @author Mark Callow, www.edgewise-consulting.com.
+ *
+ * Thanks to Alex Szpakowski, @slime73 on GitHub, for his gist showing
+ * how to add a CAMetalLayer backed view.
+ */
+
+#ifndef _SDL_cocoametalview_h
+#define _SDL_cocoametalview_h
+
+#import "../SDL_sysvideo.h"
+#import "SDL_cocoawindow.h"
+
+#import <Cocoa/Cocoa.h>
+#import <Metal/Metal.h>
+#import <QuartzCore/CAMetalLayer.h>
+
+#define METALVIEW_TAG 255
+
+@interface SDL_cocoametalview : NSView {
+ NSInteger _tag;
+ bool _useHighDPI;
+}
+
+- (instancetype)initWithFrame:(NSRect)frame
+ useHighDPI:(bool)useHighDPI;
+
+/* Override superclass tag so this class can set it. */
+@property (assign, readonly) NSInteger tag;
+
+@end
+
+SDL_cocoametalview* Cocoa_Mtl_AddMetalView(SDL_Window* window);
+
+void Cocoa_Mtl_GetDrawableSize(SDL_Window * window, int * w, int * h);
+
+#endif /* _SDL_cocoametalview_h */
+
+/* vi: set ts=4 sw=4 expandtab: */
+
diff --git a/src/video/cocoa/SDL_cocoametalview.m b/src/video/cocoa/SDL_cocoametalview.m
new file mode 100644
index 0000000..64ad407
--- /dev/null
+++ b/src/video/cocoa/SDL_cocoametalview.m
@@ -0,0 +1,124 @@
+/*
+ Simple DirectMedia Layer
+ Copyright (C) 1997-2017 Sam Lantinga <slouken@libsdl.org>
+
+ This software is provided 'as-is', without any express or implied
+ warranty. In no event will the authors be held liable for any damages
+ arising from the use of this software.
+
+ Permission is granted to anyone to use this software for any purpose,
+ including commercial applications, and to alter it and redistribute it
+ freely, subject to the following restrictions:
+
+ 1. The origin of this software must not be misrepresented; you must not
+ claim that you wrote the original software. If you use this software
+ in a product, an acknowledgment in the product documentation would be
+ appreciated but is not required.
+ 2. Altered source versions must be plainly marked as such, and must not be
+ misrepresented as being the original software.
+ 3. This notice may not be removed or altered from any source distribution.
+ */
+
+/*
+ * @author Mark Callow, www.edgewise-consulting.com.
+ *
+ * Thanks to Alex Szpakowski, @slime73 on GitHub, for his gist showing
+ * how to add a CAMetalLayer backed view.
+ */
+
+/* this is (currently) only used with Vulkan. Remove this #if when that changes! */
+#if SDL_VIDEO_VULKAN_SURFACE && SDL_VIDEO_DRIVER_COCOA
+
+#import "SDL_cocoametalview.h"
+
+#include "SDL_assert.h"
+#include "SDL_loadso.h"
+#include <dlfcn.h>
+
+@implementation SDL_cocoametalview
+
+/* The synthesized getter should be called by super's viewWithTag. */
+@synthesize tag = _tag;
+
+/* Return a Metal-compatible layer. */
++ (Class)layerClass
+{
+ return [CAMetalLayer class];
+}
+
+/* Indicate the view wants to draw using a backing layer instead of drawRect. */
+-(BOOL) wantsUpdateLayer { return YES; }
+
+/* When the wantsLayer property is set to YES, this method will be invoked to
+ * return a layer instance.
+ */
+-(CALayer*) makeBackingLayer { return [self.class.layerClass layer]; }
+
+- (instancetype)initWithFrame:(NSRect)frame
+ useHighDPI:(bool)useHighDPI
+{
+ if ((self = [super initWithFrame:frame])) {
+
+ /* Allow resize. */
+ self.autoresizingMask = NSViewWidthSizable | NSViewHeightSizable;
+ _tag = METALVIEW_TAG;
+
+ _useHighDPI = useHighDPI;
+ [self updateDrawableSize];
+ }
+
+ return self;
+}
+
+/* Set the size of the metal drawables when the view is resized. */
+- (void)resizeSubviewsWithOldSize:(NSSize)oldSize {
+ [super resizeSubviewsWithOldSize:oldSize];
+ [self updateDrawableSize];
+}
+
+- (void)updateDrawableSize
+{
+ if (_useHighDPI) {
+ NSSize size = [self convertRectToBacking:[self bounds]].size;
+ /* Isn't there a better way to convert from NSSize to CGSize? */
+ CGSize cgsize = *(CGSize*)&size;
+ ((CAMetalLayer *) self.layer).drawableSize = cgsize;
+ }
+}
+
+@end
+
+SDL_cocoametalview*
+Cocoa_Mtl_AddMetalView(SDL_Window* window)
+{
+ SDL_WindowData *data = (SDL_WindowData *)window->driverdata;
+ NSView *view = data->nswindow.contentView;
+
+ SDL_cocoametalview *metalview
+ = [[SDL_cocoametalview alloc] initWithFrame:view.frame
+ useHighDPI:(window->flags & SDL_WINDOW_ALLOW_HIGHDPI)];
+ [view addSubview:metalview];
+
+ return metalview;
+}
+
+void
+Cocoa_Mtl_GetDrawableSize(SDL_Window * window, int * w, int * h)
+{
+ SDL_WindowData *data = (__bridge SDL_WindowData *)window->driverdata;
+ NSView *view = data->nswindow.contentView;
+ SDL_cocoametalview* metalview = [view viewWithTag:METALVIEW_TAG];
+ if (metalview) {
+ CAMetalLayer *layer = (CAMetalLayer*)metalview.layer;
+ assert(layer != NULL);
+ if (w)
+ *w = layer.drawableSize.width;
+ if (h)
+ *h = layer.drawableSize.height;
+ }
+}
+
+#endif
+
+/* vi: set ts=4 sw=4 expandtab: */
+
diff --git a/src/video/cocoa/SDL_cocoavideo.m b/src/video/cocoa/SDL_cocoavideo.m
index cc41863..9504a77 100644
--- a/src/video/cocoa/SDL_cocoavideo.m
+++ b/src/video/cocoa/SDL_cocoavideo.m
@@ -26,6 +26,7 @@
#include "SDL_endian.h"
#include "SDL_cocoavideo.h"
#include "SDL_cocoashape.h"
+#include "SDL_cocoavulkan.h"
#include "SDL_assert.h"
/* Initialization/Query functions */
@@ -122,6 +123,14 @@ Cocoa_CreateDevice(int devindex)
device->GL_DeleteContext = Cocoa_GL_DeleteContext;
#endif
+#if SDL_VIDEO_VULKAN_SURFACE
+ device->Vulkan_LoadLibrary = Cocoa_Vulkan_LoadLibrary;
+ device->Vulkan_UnloadLibrary = Cocoa_Vulkan_UnloadLibrary;
+ device->Vulkan_GetInstanceExtensions = Cocoa_Vulkan_GetInstanceExtensions;
+ device->Vulkan_CreateSurface = Cocoa_Vulkan_CreateSurface;
+ device->Vulkan_GetDrawableSize = Cocoa_Vulkan_GetDrawableSize;
+#endif
+
device->StartTextInput = Cocoa_StartTextInput;
device->StopTextInput = Cocoa_StopTextInput;
device->SetTextInputRect = Cocoa_SetTextInputRect;
diff --git a/src/video/cocoa/SDL_cocoavulkan.h b/src/video/cocoa/SDL_cocoavulkan.h
new file mode 100644
index 0000000..b971635
--- /dev/null
+++ b/src/video/cocoa/SDL_cocoavulkan.h
@@ -0,0 +1,55 @@
+/*
+ Simple DirectMedia Layer
+ Copyright (C) 1997-2016 Sam Lantinga <slouken@libsdl.org>
+
+ This software is provided 'as-is', without any express or implied
+ warranty. In no event will the authors be held liable for any damages
+ arising from the use of this software.
+
+ Permission is granted to anyone to use this software for any purpose,
+ including commercial applications, and to alter it and redistribute it
+ freely, subject to the following restrictions:
+
+ 1. The origin of this software must not be misrepresented; you must not
+ claim that you wrote the original software. If you use this software
+ in a product, an acknowledgment in the product documentation would be
+ appreciated but is not required.
+ 2. Altered source versions must be plainly marked as such, and must not be
+ misrepresented as being the original software.
+ 3. This notice may not be removed or altered from any source distribution.
+*/
+
+/*
+ * @author Mark Callow, www.edgewise-consulting.com. Based on Jacob Lifshay's
+ * SDL_x11vulkan.h.
+ */
+
+
+#include "../../SDL_internal.h"
+
+#ifndef _SDL_cocoavulkan_h
+#define _SDL_cocoavulkan_h
+
+#include "../SDL_vulkan_internal.h"
+#include "../SDL_sysvideo.h"
+
+#if SDL_VIDEO_VULKAN_SURFACE && SDL_VIDEO_DRIVER_COCOA
+
+int Cocoa_Vulkan_LoadLibrary(_THIS, const char *path);
+void Cocoa_Vulkan_UnloadLibrary(_THIS);
+SDL_bool Cocoa_Vulkan_GetInstanceExtensions(_THIS,
+ SDL_Window *window,
+ unsigned *count,
+ const char **names);
+SDL_bool Cocoa_Vulkan_CreateSurface(_THIS,
+ SDL_Window *window,
+ VkInstance instance,
+ VkSurfaceKHR *surface);
+
+void Cocoa_Vulkan_GetDrawableSize(_THIS, SDL_Window *window, int *w, int *h);
+
+#endif
+
+#endif /* _SDL_cocoavulkan_h */
+
+/* vi: set ts=4 sw=4 expandtab: */
diff --git a/src/video/cocoa/SDL_cocoavulkan.m b/src/video/cocoa/SDL_cocoavulkan.m
new file mode 100644
index 0000000..0f6cbd1
--- /dev/null
+++ b/src/video/cocoa/SDL_cocoavulkan.m
@@ -0,0 +1,217 @@
+/*
+ Simple DirectMedia Layer
+ Copyright (C) 1997-2016 Sam Lantinga <slouken@libsdl.org>
+
+ This software is provided 'as-is', without any express or implied
+ warranty. In no event will the authors be held liable for any damages
+ arising from the use of this software.
+
+ Permission is granted to anyone to use this software for any purpose,
+ including commercial applications, and to alter it and redistribute it
+ freely, subject to the following restrictions:
+
+ 1. The origin of this software must not be misrepresented; you must not
+ claim that you wrote the original software. If you use this software
+ in a product, an acknowledgment in the product documentation would be
+ appreciated but is not required.
+ 2. Altered source versions must be plainly marked as such, and must not be
+ misrepresented as being the original software.
+ 3. This notice may not be removed or altered from any source distribution.
+*/
+
+/*
+ * @author Mark Callow, www.edgewise-consulting.com. Based on Jacob Lifshay's
+ * SDL_x11vulkan.c.
+ */
+
+#include "../../SDL_internal.h"
+
+#if SDL_VIDEO_VULKAN_SURFACE && SDL_VIDEO_DRIVER_COCOA
+
+#include "SDL_cocoavideo.h"
+#include "SDL_cocoawindow.h"
+#include "SDL_assert.h"
+
+#include "SDL_loadso.h"
+#include "SDL_cocoametalview.h"
+#include "SDL_cocoavulkan.h"
+#include "SDL_syswm.h"
+
+#include <dlfcn.h>
+
+#define DEFAULT_MOLTENVK "libMoltenVK.dylib"
+/* Since libSDL is most likely a .dylib, need RTLD_DEFAULT not RTLD_SELF. */
+#define DEFAULT_HANDLE RTLD_DEFAULT
+
+int Cocoa_Vulkan_LoadLibrary(_THIS, const char *path)
+{
+ VkExtensionProperties *extensions = NULL;
+ Uint32 extensionCount = 0;
+ SDL_bool hasSurfaceExtension = SDL_FALSE;
+ SDL_bool hasMacOSSurfaceExtension = SDL_FALSE;
+ PFN_vkGetInstanceProcAddr vkGetInstanceProcAddr = NULL;
+ if(_this->vulkan_config.loader_handle)
+ {
+ SDL_SetError("MoltenVK/Vulkan already loaded");
+ return -1;
+ }
+
+ /* Load the Vulkan loader library */
+ if(!path)
+ path = SDL_getenv("SDL_VULKAN_LIBRARY");
+ if(!path)
+ {
+ /* MoltenVK framework, currently, v0.17.0, has a static library and is
+ * the recommended way to use the package. There is likely no object to
+ * load. */
+ vkGetInstanceProcAddr =
+ (PFN_vkGetInstanceProcAddr)dlsym(DEFAULT_HANDLE,
+ "vkGetInstanceProcAddr");
+ }
+
+ if(vkGetInstanceProcAddr)
+ {
+ _this->vulkan_config.loader_handle = DEFAULT_HANDLE;
+ }
+ else
+ {
+ if (!path)
+ {
+ /* Look for the .dylib packaged with the application instead. */
+ path = DEFAULT_MOLTENVK;
+ }
+
+ _this->vulkan_config.loader_handle = SDL_LoadObject(path);
+ if(!_this->vulkan_config.loader_handle)
+ return -1;
+ SDL_strlcpy(_this->vulkan_config.loader_path, path,
+ SDL_arraysize(_this->vulkan_config.loader_path));
+ vkGetInstanceProcAddr = (PFN_vkGetInstanceProcAddr)SDL_LoadFunction(
+ _this->vulkan_config.loader_handle, "vkGetInstanceProcAddr");
+ }
+ if(!vkGetInstanceProcAddr)
+ {
+ SDL_SetError("Failed to find %s in either executable or %s: %s",
+ "vkGetInstanceProcAddr",
+ DEFAULT_MOLTENVK,
+ (const char *) dlerror());
+ goto fail;
+ }
+
+ _this->vulkan_config.vkGetInstanceProcAddr = (void *)vkGetInstanceProcAddr;
+ _this->vulkan_config.vkEnumerateInstanceExtensionProperties =
+ (void *)((PFN_vkGetInstanceProcAddr)_this->vulkan_config.vkGetInstanceProcAddr)(
+ VK_NULL_HANDLE, "vkEnumerateInstanceExtensionProperties");
+ if(!_this->vulkan_config.vkEnumerateInstanceExtensionProperties)
+ goto fail;
+ extensions = SDL_Vulkan_CreateInstanceExtensionsList(
+ (PFN_vkEnumerateInstanceExtensionProperties)
+ _this->vulkan_config.vkEnumerateInstanceExtensionProperties,
+ &extensionCount);
+ if(!extensions)
+ goto fail;
+ for(Uint32 i = 0; i < extensionCount; i++)
+ {
+ if(SDL_strcmp(VK_KHR_SURFACE_EXTENSION_NAME, extensions[i].extensionName) == 0)
+ hasSurfaceExtension = SDL_TRUE;
+ else if(SDL_strcmp(VK_MVK_MACOS_SURFACE_EXTENSION_NAME, extensions[i].extensionName) == 0)
+ hasMacOSSurfaceExtension = SDL_TRUE;
+ }
+ SDL_free(extensions);
+ if(!hasSurfaceExtension)
+ {
+ SDL_SetError("Installed MoltenVK/Vulkan doesn't implement the "
+ VK_KHR_SURFACE_EXTENSION_NAME " extension");
+ goto fail;
+ }
+ else if(!hasMacOSSurfaceExtension)
+ {
+ SDL_SetError("Installed MoltenVK/Vulkan doesn't implement the "
+ VK_MVK_MACOS_SURFACE_EXTENSION_NAME "extension");
+ goto fail;
+ }
+ return 0;
+
+fail:
+ SDL_UnloadObject(_this->vulkan_config.loader_handle);
+ _this->vulkan_config.loader_handle = NULL;
+ return -1;
+}
+
+void Cocoa_Vulkan_UnloadLibrary(_THIS)
+{
+ if(_this->vulkan_config.loader_handle)
+ {
+ if (_this->vulkan_config.loader_handle != DEFAULT_HANDLE)
+ SDL_UnloadObject(_this->vulkan_config.loader_handle);
+ _this->vulkan_config.loader_handle = NULL;
+ }
+}
+
+SDL_bool Cocoa_Vulkan_GetInstanceExtensions(_THIS,
+ SDL_Window *window,
+ unsigned *count,
+ const char **names)
+{
+ static const char *const extensionsForCocoa[] = {
+ VK_KHR_SURFACE_EXTENSION_NAME, VK_MVK_MACOS_SURFACE_EXTENSION_NAME
+ };
+ if(!_this->vulkan_config.loader_handle)
+ {
+ SDL_SetError("Vulkan is not loaded");
+ return SDL_FALSE;
+ }
+ return SDL_Vulkan_GetInstanceExtensions_Helper(
+ count, names, SDL_arraysize(extensionsForCocoa),
+ extensionsForCocoa);
+}
+
+SDL_bool Cocoa_Vulkan_CreateSurface(_THIS,
+ SDL_Window *window,
+ VkInstance instance,
+ VkSurfaceKHR *surface)
+{
+ PFN_vkGetInstanceProcAddr vkGetInstanceProcAddr =
+ (PFN_vkGetInstanceProcAddr)_this->vulkan_config.vkGetInstanceProcAddr;
+ PFN_vkCreateMacOSSurfaceMVK vkCreateMacOSSurfaceMVK =
+ (PFN_vkCreateMacOSSurfaceMVK)vkGetInstanceProcAddr(
+ (VkInstance)instance,
+ "vkCreateMacOSSurfaceMVK");
+ VkMacOSSurfaceCreateInfoMVK createInfo = {};
+ VkResult result;
+
+ if(!_this->vulkan_config.loader_handle)
+ {
+ SDL_SetError("Vulkan is not loaded");
+ return SDL_FALSE;
+ }
+
+ if(!vkCreateMacOSSurfaceMVK)
+ {
+ SDL_SetError(VK_MVK_MACOS_SURFACE_EXTENSION_NAME
+ " extension is not enabled in the Vulkan instance.");
+ return SDL_FALSE;
+ }
+ createInfo.sType = VK_STRUCTURE_TYPE_MACOS_SURFACE_CREATE_INFO_MVK;
+ createInfo.pNext = NULL;
+ createInfo.flags = 0;
+ createInfo.pView = Cocoa_Mtl_AddMetalView(window);
+ result = vkCreateMacOSSurfaceMVK(instance, &createInfo,
+ NULL, surface);
+ if(result != VK_SUCCESS)
+ {
+ SDL_SetError("vkCreateMacOSSurfaceMVK failed: %s",
+ SDL_Vulkan_GetResultString(result));
+ return SDL_FALSE;
+ }
+ return SDL_TRUE;
+}
+
+void Cocoa_Vulkan_GetDrawableSize(_THIS, SDL_Window *window, int *w, int *h)
+{
+ Cocoa_Mtl_GetDrawableSize(window, w, h);
+}
+
+#endif
+
+/* vim: set ts=4 sw=4 expandtab: */
diff --git a/src/video/mir/SDL_mirvideo.c b/src/video/mir/SDL_mirvideo.c
index c1f2d40..767ada3 100644
--- a/src/video/mir/SDL_mirvideo.c
+++ b/src/video/mir/SDL_mirvideo.c
@@ -36,6 +36,7 @@
#include "SDL_mirmouse.h"
#include "SDL_miropengl.h"
#include "SDL_mirvideo.h"
+#include "SDL_mirvulkan.h"
#include "SDL_mirdyn.h"
@@ -232,6 +233,13 @@ MIR_CreateDevice(int device_index)
device->ShowMessageBox = NULL;
+#if SDL_VIDEO_VULKAN_SURFACE
+ device->Vulkan_LoadLibrary = MIR_Vulkan_LoadLibrary;
+ device->Vulkan_UnloadLibrary = MIR_Vulkan_UnloadLibrary;
+ device->Vulkan_GetInstanceExtensions = MIR_Vulkan_GetInstanceExtensions;
+ device->Vulkan_CreateSurface = MIR_Vulkan_CreateSurface;
+#endif
+
return device;
}
diff --git a/src/video/mir/SDL_mirvideo.h b/src/video/mir/SDL_mirvideo.h
index bd1b0f8..a065725 100644
--- a/src/video/mir/SDL_mirvideo.h
+++ b/src/video/mir/SDL_mirvideo.h
@@ -28,6 +28,7 @@
#include <EGL/egl.h>
#include <mir_toolkit/mir_client_library.h>
+#include "SDL_stdinc.h"
typedef struct MIR_Window MIR_Window;
diff --git a/src/video/mir/SDL_mirvulkan.c b/src/video/mir/SDL_mirvulkan.c
new file mode 100644
index 0000000..e81cb09
--- /dev/null
+++ b/src/video/mir/SDL_mirvulkan.c
@@ -0,0 +1,175 @@
+/*
+ Simple DirectMedia Layer
+ Copyright (C) 1997-2016 Sam Lantinga <slouken@libsdl.org>
+
+ This software is provided 'as-is', without any express or implied
+ warranty. In no event will the authors be held liable for any damages
+ arising from the use of this software.
+
+ Permission is granted to anyone to use this software for any purpose,
+ including commercial applications, and to alter it and redistribute it
+ freely, subject to the following restrictions:
+
+ 1. The origin of this software must not be misrepresented; you must not
+ claim that you wrote the original software. If you use this software
+ in a product, an acknowledgment in the product documentation would be
+ appreciated but is not required.
+ 2. Altered source versions must be plainly marked as such, and must not be
+ misrepresented as being the original software.
+ 3. This notice may not be removed or altered from any source distribution.
+*/
+
+/*
+ * @author Mark Callow, www.edgewise-consulting.com. Based on Jacob Lifshay's
+ * SDL_x11vulkan.c.
+ */
+
+#include "../../SDL_internal.h"
+
+#if SDL_VIDEO_VULKAN_SURFACE && SDL_VIDEO_DRIVER_MIR
+
+#include "SDL_mirvideo.h"
+#include "SDL_mirwindow.h"
+#include "SDL_assert.h"
+
+#include "SDL_loadso.h"
+#include "SDL_mirvulkan.h"
+#include "SDL_syswm.h"
+
+int MIR_Vulkan_LoadLibrary(_THIS, const char *path)
+{
+ VkExtensionProperties *extensions = NULL;
+ Uint32 extensionCount = 0;
+ SDL_bool hasSurfaceExtension = SDL_FALSE;
+ SDL_bool hasMIRSurfaceExtension = SDL_FALSE;
+ PFN_vkGetInstanceProcAddr vkGetInstanceProcAddr = NULL;
+ if(_this->vulkan_config.loader_handle)
+ return SDL_SetError("Vulkan already loaded");
+
+ /* Load the Vulkan loader library */
+ if(!path)
+ path = SDL_getenv("SDL_VULKAN_LIBRARY");
+ if(!path)
+ path = "libvulkan.so.1";
+ _this->vulkan_config.loader_handle = SDL_LoadObject(path);
+ if(!_this->vulkan_config.loader_handle)
+ return -1;
+ SDL_strlcpy(_this->vulkan_config.loader_path, path,
+ SDL_arraysize(_this->vulkan_config.loader_path));
+ vkGetInstanceProcAddr = (PFN_vkGetInstanceProcAddr)SDL_LoadFunction(
+ _this->vulkan_config.loader_handle, "vkGetInstanceProcAddr");
+ if(!vkGetInstanceProcAddr)
+ goto fail;
+ _this->vulkan_config.vkGetInstanceProcAddr = (void *)vkGetInstanceProcAddr;
+ _this->vulkan_config.vkEnumerateInstanceExtensionProperties =
+ (void *)((PFN_vkGetInstanceProcAddr)_this->vulkan_config.vkGetInstanceProcAddr)(
+ VK_NULL_HANDLE, "vkEnumerateInstanceExtensionProperties");
+ if(!_this->vulkan_config.vkEnumerateInstanceExtensionProperties)
+ goto fail;
+ extensions = SDL_Vulkan_CreateInstanceExtensionsList(
+ (PFN_vkEnumerateInstanceExtensionProperties)
+ _this->vulkan_config.vkEnumerateInstanceExtensionProperties,
+ &extensionCount);
+ if(!extensions)
+ goto fail;
+ for(Uint32 i = 0; i < extensionCount; i++)
+ {
+ if(SDL_strcmp(VK_KHR_SURFACE_EXTENSION_NAME, extensions[i].extensionName) == 0)
+ hasSurfaceExtension = SDL_TRUE;
+ else if(SDL_strcmp(VK_KHR_MIR_SURFACE_EXTENSION_NAME, extensions[i].extensionName) == 0)
+ hasMIRSurfaceExtension = SDL_TRUE;
+ }
+ SDL_free(extensions);
+ if(!hasSurfaceExtension)
+ {
+ SDL_SetError("Installed Vulkan doesn't implement the "
+ VK_KHR_SURFACE_EXTENSION_NAME " extension");
+ goto fail;
+ }
+ else if(!hasMIRSurfaceExtension)
+ {
+ SDL_SetError("Installed Vulkan doesn't implement the "
+ VK_KHR_MIR_SURFACE_EXTENSION_NAME "extension");
+ goto fail;
+ }
+ return 0;
+
+fail:
+ SDL_UnloadObject(_this->vulkan_config.loader_handle);
+ _this->vulkan_config.loader_handle = NULL;
+ return -1;
+}
+
+void MIR_Vulkan_UnloadLibrary(_THIS)
+{
+ if(_this->vulkan_config.loader_handle)
+ {
+ SDL_UnloadObject(_this->vulkan_config.loader_handle);
+ _this->vulkan_config.loader_handle = NULL;
+ }
+}
+
+SDL_bool MIR_Vulkan_GetInstanceExtensions(_THIS,
+ SDL_Window *window,
+ unsigned *count,
+ const char **names)
+{
+ static const char *const extensionsForMir[] = {
+ VK_KHR_SURFACE_EXTENSION_NAME, VK_KHR_MIR_SURFACE_EXTENSION_NAME
+ };
+ if(!_this->vulkan_config.loader_handle)
+ {
+ SDL_SetError("Vulkan is not loaded");
+ return SDL_FALSE;
+ }
+ return SDL_Vulkan_GetInstanceExtensions_Helper(
+ count, names, SDL_arraysize(extensionsForMir),
+ extensionsForMir);
+}
+
+SDL_bool MIR_Vulkan_CreateSurface(_THIS,
+ SDL_Window *window,
+ VkInstance instance,
+ VkSurfaceKHR *surface)
+{
+ MIR_Window *windowData = (MIR_Window *)window->driverdata;
+ PFN_vkGetInstanceProcAddr vkGetInstanceProcAddr =
+ (PFN_vkGetInstanceProcAddr)_this->vulkan_config.vkGetInstanceProcAddr;
+ PFN_vkCreateMirSurfaceKHR vkCreateMirSurfaceKHR =
+ (PFN_vkCreateMirSurfaceKHR)vkGetInstanceProcAddr(
+ (VkInstance)instance,
+ "vkCreateMirSurfaceKHR");
+ VkMirSurfaceCreateInfoKHR createInfo = {};
+ VkResult result;
+
+ if(!_this->vulkan_config.loader_handle)
+ {
+ SDL_SetError("Vulkan is not loaded");
+ return SDL_FALSE;
+ }
+
+ if(!vkCreateMirSurfaceKHR)
+ {
+ SDL_SetError(VK_KHR_MIR_SURFACE_EXTENSION_NAME
+ " extension is not enabled in the Vulkan instance.");
+ return SDL_FALSE;
+ }
+ createInfo.sType = VK_STRUCTURE_TYPE_MIR_SURFACE_CREATE_INFO_KHR;
+ createInfo.pNext = NULL;
+ createInfo.flags = 0;
+ createInfo.connection = windowData->mir_data->connection;
+ createInfo.mirSurface = windowData->window;
+ result = vkCreateMirSurfaceKHR(instance, &createInfo,
+ NULL, surface);
+ if(result != VK_SUCCESS)
+ {
+ SDL_SetError("vkCreateMirSurfaceKHR failed: %s",
+ SDL_Vulkan_GetResultString(result));
+ return SDL_FALSE;
+ }
+ return SDL_TRUE;
+}
+
+#endif
+
+/* vim: set ts=4 sw=4 expandtab: */
diff --git a/src/video/mir/SDL_mirvulkan.h b/src/video/mir/SDL_mirvulkan.h
new file mode 100644
index 0000000..42ad7cc
--- /dev/null
+++ b/src/video/mir/SDL_mirvulkan.h
@@ -0,0 +1,52 @@
+/*
+ Simple DirectMedia Layer
+ Copyright (C) 1997-2016 Sam Lantinga <slouken@libsdl.org>
+
+ This software is provided 'as-is', without any express or implied
+ warranty. In no event will the authors be held liable for any damages
+ arising from the use of this software.
+
+ Permission is granted to anyone to use this software for any purpose,
+ including commercial applications, and to alter it and redistribute it
+ freely, subject to the following restrictions:
+
+ 1. The origin of this software must not be misrepresented; you must not
+ claim that you wrote the original software. If you use this software
+ in a product, an acknowledgment in the product documentation would be
+ appreciated but is not required.
+ 2. Altered source versions must be plainly marked as such, and must not be
+ misrepresented as being the original software.
+ 3. This notice may not be removed or altered from any source distribution.
+*/
+
+/*
+ * @author Mark Callow, www.edgewise-consulting.com. Based on Jacob Lifshay's
+ * SDL_x11vulkan.h.
+ */
+
+#include "../../SDL_internal.h"
+
+#ifndef _SDL_mirvulkan_h
+#define _SDL_mirvulkan_h
+
+#include "../SDL_vulkan_internal.h"
+#include "../SDL_sysvideo.h"
+
+#if SDL_VIDEO_VULKAN_SURFACE && SDL_VIDEO_DRIVER_MIR
+
+int MIR_Vulkan_LoadLibrary(_THIS, const char *path);
+void MIR_Vulkan_UnloadLibrary(_THIS);
+SDL_bool MIR_Vulkan_GetInstanceExtensions(_THIS,
+ SDL_Window *window,
+ unsigned *count,
+ const char **names);
+SDL_bool MIR_Vulkan_CreateSurface(_THIS,
+ SDL_Window *window,
+ VkInstance instance,
+ VkSurfaceKHR *surface);
+
+#endif
+
+#endif /* _SDL_mirvulkan_h */
+
+/* vi: set ts=4 sw=4 expandtab: */
diff --git a/src/video/uikit/SDL_uikitmetalview.h b/src/video/uikit/SDL_uikitmetalview.h
new file mode 100644
index 0000000..0099f58
--- /dev/null
+++ b/src/video/uikit/SDL_uikitmetalview.h
@@ -0,0 +1,53 @@
+/*
+ Simple DirectMedia Layer
+ Copyright (C) 1997-2017 Sam Lantinga <slouken@libsdl.org>
+
+ This software is provided 'as-is', without any express or implied
+ warranty. In no event will the authors be held liable for any damages
+ arising from the use of this software.
+
+ Permission is granted to anyone to use this software for any purpose,
+ including commercial applications, and to alter it and redistribute it
+ freely, subject to the following restrictions:
+
+ 1. The origin of this software must not be misrepresented; you must not
+ claim that you wrote the original software. If you use this software
+ in a product, an acknowledgment in the product documentation would be
+ appreciated but is not required.
+ 2. Altered source versions must be plainly marked as such, and must not be
+ misrepresented as being the original software.
+ 3. This notice may not be removed or altered from any source distribution.
+ */
+
+/*
+ * @author Mark Callow, www.edgewise-consulting.com.
+ *
+ * Thanks to Alex Szpakowski, @slime73 on GitHub, for his gist showing
+ * how to add a CAMetalLayer backed view.
+ */
+
+#ifndef _SDL_uikitmetalview_h
+#define _SDL_uikitmetalview_h
+
+#import "../SDL_sysvideo.h"
+#import "SDL_uikitwindow.h"
+
+#import <UIKit/UIKit.h>
+#import <Metal/Metal.h>
+#import <QuartzCore/CAMetalLayer.h>
+
+#define METALVIEW_TAG 255
+
+@interface SDL_uikitmetalview : UIView
+
+- (instancetype)initWithFrame:(CGRect)frame
+ scale:(CGFloat)scale
+ tag:(int)tag;
+
+@end
+
+SDL_uikitmetalview* UIKit_Mtl_AddMetalView(SDL_Window* window);
+
+void UIKit_Mtl_GetDrawableSize(SDL_Window * window, int * w, int * h);
+
+#endif /* _SDL_uikitmetalview_h */
diff --git a/src/video/uikit/SDL_uikitmetalview.m b/src/video/uikit/SDL_uikitmetalview.m
new file mode 100644
index 0000000..a9d7875
--- /dev/null
+++ b/src/video/uikit/SDL_uikitmetalview.m
@@ -0,0 +1,146 @@
+/*
+ Simple DirectMedia Layer
+ Copyright (C) 1997-2017 Sam Lantinga <slouken@libsdl.org>
+
+ This software is provided 'as-is', without any express or implied
+ warranty. In no event will the authors be held liable for any damages
+ arising from the use of this software.
+
+ Permission is granted to anyone to use this software for any purpose,
+ including commercial applications, and to alter it and redistribute it
+ freely, subject to the following restrictions:
+
+ 1. The origin of this software must not be misrepresented; you must not
+ claim that you wrote the original software. If you use this software
+ in a product, an acknowledgment in the product documentation would be
+ appreciated but is not required.
+ 2. Altered source versions must be plainly marked as such, and must not be
+ misrepresented as being the original software.
+ 3. This notice may not be removed or altered from any source distribution.
+ */
+
+/*
+ * @author Mark Callow, www.edgewise-consulting.com.
+ *
+ * Thanks to Alex Szpakowski, @slime73 on GitHub, for his gist showing
+ * how to add a CAMetalLayer backed view.
+ */
+
+#include "../../SDL_internal.h"
+
+#if SDL_VIDEO_VULKAN_SURFACE && SDL_VIDEO_DRIVER_UIKIT
+
+#import "../SDL_sysvideo.h"
+#import "SDL_uikitwindow.h"
+#import "SDL_uikitmetalview.h"
+
+#include "SDL_assert.h"
+#include "SDL_loadso.h"
+#include <dlfcn.h>
+
+static void* loader_handle;
+
+@implementation SDL_uikitmetalview
+
+/* Returns a Metal-compatible layer. */
++ (Class)layerClass
+{
+ return [CAMetalLayer class];
+}
+
+- (instancetype)initWithFrame:(CGRect)frame
+ scale:(CGFloat)scale
+ tag:(int)tag
+{
+ if ((self = [super initWithFrame:frame])) {
+ /* Resize properly when rotated. */
+ self.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
+
+ /* Set the appropriate scale (for retina display support) */
+ self.contentScaleFactor = scale;
+ self.tag = tag;
+
+ [self updateDrawableSize];
+ }
+
+ return self;
+}
+
+/* Set the size of the metal drawables when the view is resized. */
+- (void)layoutSubviews
+{
+ [super layoutSubviews];
+ [self updateDrawableSize];
+}
+
+- (void)updateDrawableSize
+{
+ CGSize size = self.bounds.size;
+ size.width *= self.contentScaleFactor;
+ size.height *= self.contentScaleFactor;
+
+ ((CAMetalLayer *) self.layer).drawableSize = size;
+}
+
+@end
+
+SDL_uikitmetalview*
+UIKit_Mtl_AddMetalView(SDL_Window* window)
+{
+ SDL_WindowData *data = (__bridge SDL_WindowData *)window->driverdata;
+ SDL_uikitview *view = (SDL_uikitview*)data.uiwindow.rootViewController.view;
+ CGFloat scale = 1.0;
+
+ if (window->flags & SDL_WINDOW_ALLOW_HIGHDPI) {
+ /* Set the scale to the natural scale factor of the screen - the
+ * backing dimensions of the Metal view will match the pixel
+ * dimensions of the screen rather than the dimensions in points.
+ */
+#ifdef __IPHONE_8_0
+ if ([data.uiwindow.screen respondsToSelector:@selector(nativeScale)]) {
+ scale = data.uiwindow.screen.nativeScale;
+ } else
+#endif
+ {
+ scale = data.uiwindow.screen.scale;
+ }
+ }
+ SDL_uikitmetalview *metalview
+ = [[SDL_uikitmetalview alloc] initWithFrame:view.frame
+ scale:scale
+ tag:METALVIEW_TAG];
+#if 1
+ [view addSubview:metalview];
+#else
+ /* Sets this view as the controller's view, and adds the view to
+ * the window hierarchy.
+ *
+ * Left here for information. Not used because I suspect that for correct
+ * operation it will be necesary to copy everything from the window's
+ * current SDL_uikitview instance to the SDL_uikitview portion of the
+ * SDL_metalview. The latter would be derived from SDL_uikitview rather
+ * than UIView. */
+ [metalview setSDLWindow:window];
+#endif
+
+ return metalview;
+}
+
+void
+UIKit_Mtl_GetDrawableSize(SDL_Window * window, int * w, int * h)
+{
+ SDL_WindowData *data = (__bridge SDL_WindowData *)window->driverdata;
+ SDL_uikitview *view = (SDL_uikitview*)data.uiwindow.rootViewController.view;
+ SDL_uikitmetalview* metalview = [view viewWithTag:METALVIEW_TAG];
+ if (metalview) {
+ CAMetalLayer *layer = (CAMetalLayer*)metalview.layer;
+ assert(layer != NULL);
+ if (w)
+ *w = layer.drawableSize.width;
+ if (h)
+ *h = layer.drawableSize.height;
+ } else
+ SDL_GetWindowSize(window, w, h);
+}
+
+#endif
diff --git a/src/video/uikit/SDL_uikitvideo.m b/src/video/uikit/SDL_uikitvideo.m
index 617ce09..39969db 100644
--- a/src/video/uikit/SDL_uikitvideo.m
+++ b/src/video/uikit/SDL_uikitvideo.m
@@ -37,6 +37,7 @@
#include "SDL_uikitwindow.h"
#include "SDL_uikitopengles.h"
#include "SDL_uikitclipboard.h"
+#include "SDL_uikitvulkan.h"
#define UIKITVID_DRIVER_NAME "uikit"
@@ -123,6 +124,15 @@ UIKit_CreateDevice(int devindex)
device->GL_LoadLibrary = UIKit_GL_LoadLibrary;
device->free = UIKit_DeleteDevice;
+ #if SDL_VIDEO_VULKAN_SURFACE
+ device->Vulkan_LoadLibrary = UIKit_Vulkan_LoadLibrary;
+ device->Vulkan_UnloadLibrary = UIKit_Vulkan_UnloadLibrary;
+ device->Vulkan_GetInstanceExtensions
+ = UIKit_Vulkan_GetInstanceExtensions;
+ device->Vulkan_CreateSurface = UIKit_Vulkan_CreateSurface;
+ device->Vulkan_GetDrawableSize = UIKit_Vulkan_GetDrawableSize;
+ #endif
+
device->gl_config.accelerated = 1;
return device;
diff --git a/src/video/uikit/SDL_uikitvulkan.h b/src/video/uikit/SDL_uikitvulkan.h
new file mode 100644
index 0000000..55eeacf
--- /dev/null
+++ b/src/video/uikit/SDL_uikitvulkan.h
@@ -0,0 +1,54 @@
+/*
+ Simple DirectMedia Layer
+ Copyright (C) 1997-2016 Sam Lantinga <slouken@libsdl.org>
+
+ This software is provided 'as-is', without any express or implied
+ warranty. In no event will the authors be held liable for any damages
+ arising from the use of this software.
+
+ Permission is granted to anyone to use this software for any purpose,
+ including commercial applications, and to alter it and redistribute it
+ freely, subject to the following restrictions:
+
+ 1. The origin of this software must not be misrepresented; you must not
+ claim that you wrote the original software. If you use this software
+ in a product, an acknowledgment in the product documentation would be
+ appreciated but is not required.
+ 2. Altered source versions must be plainly marked as such, and must not be
+ misrepresented as being the original software.
+ 3. This notice may not be removed or altered from any source distribution.
+*/
+
+/*
+ * @author Mark Callow, www.edgewise-consulting.com. Based on Jacob Lifshay's
+ * SDL_x11vulkan.h.
+ */
+
+#include "../../SDL_internal.h"
+
+#ifndef _SDL_uikitvulkan_h
+#define _SDL_uikitvulkan_h
+
+#include "../SDL_vulkan_internal.h"
+#include "../SDL_sysvideo.h"
+
+#if SDL_VIDEO_VULKAN_SURFACE && SDL_VIDEO_DRIVER_UIKIT
+
+int UIKit_Vulkan_LoadLibrary(_THIS, const char *path);
+void UIKit_Vulkan_UnloadLibrary(_THIS);
+SDL_bool UIKit_Vulkan_GetInstanceExtensions(_THIS,
+ SDL_Window *window,
+ unsigned *count,
+ const char **names);
+SDL_bool UIKit_Vulkan_CreateSurface(_THIS,
+ SDL_Window *window,
+ VkInstance instance,
+ VkSurfaceKHR *surface);
+
+void UIKit_Vulkan_GetDrawableSize(_THIS, SDL_Window *window, int *w, int *h);
+
+#endif
+
+#endif /* _SDL_uikitvulkan_h */
+
+/* vi: set ts=4 sw=4 expandtab: */
diff --git a/src/video/uikit/SDL_uikitvulkan.m b/src/video/uikit/SDL_uikitvulkan.m
new file mode 100644
index 0000000..2e951f8
--- /dev/null
+++ b/src/video/uikit/SDL_uikitvulkan.m
@@ -0,0 +1,221 @@
+/*
+ Simple DirectMedia Layer
+ Copyright (C) 1997-2016 Sam Lantinga <slouken@libsdl.org>
+
+ This software is provided 'as-is', without any express or implied
+ warranty. In no event will the authors be held liable for any damages
+ arising from the use of this software.
+
+ Permission is granted to anyone to use this software for any purpose,
+ including commercial applications, and to alter it and redistribute it
+ freely, subject to the following restrictions:
+
+ 1. The origin of this software must not be misrepresented; you must not
+ claim that you wrote the original software. If you use this software
+ in a product, an acknowledgment in the product documentation would be
+ appreciated but is not required.
+ 2. Altered source versions must be plainly marked as such, and must not be
+ misrepresented as being the original software.
+ 3. This notice may not be removed or altered from any source distribution.
+*/
+
+/*
+ * @author Mark Callow, www.edgewise-consulting.com. Based on Jacob Lifshay's
+ * SDL_x11vulkan.c.
+ */
+
+#include "../../SDL_internal.h"
+
+#if SDL_VIDEO_VULKAN_SURFACE && SDL_VIDEO_DRIVER_UIKIT
+
+#include "SDL_uikitvideo.h"
+#include "SDL_uikitwindow.h"
+#include "SDL_assert.h"
+
+#include "SDL_loadso.h"
+#include "SDL_uikitvulkan.h"
+#include "SDL_uikitmetalview.h"
+#include "SDL_syswm.h"
+
+#include <dlfcn.h>
+
+#define DEFAULT_MOLTENVK "libMoltenVK.dylib"
+/* Since libSDL is static, could use RTLD_SELF. Using RTLD_DEFAULT is future
+ * proofing. */
+#define DEFAULT_HANDLE RTLD_DEFAULT
+
+int UIKit_Vulkan_LoadLibrary(_THIS, const char *path)
+{
+ VkExtensionProperties *extensions = NULL;
+ Uint32 extensionCount = 0;
+ SDL_bool hasSurfaceExtension = SDL_FALSE;
+ SDL_bool hasIOSSurfaceExtension = SDL_FALSE;
+ PFN_vkGetInstanceProcAddr vkGetInstanceProcAddr = NULL;
+
+ if(_this->vulkan_config.loader_handle)
+ return SDL_SetError("MoltenVK/Vulkan already loaded");
+
+ /* Load the Vulkan loader library */
+ if(!path)
+ path = SDL_getenv("SDL_VULKAN_LIBRARY");
+ if(!path)
+ {
+ /* MoltenVK framework, currently, v0.17.0, has a static library and is
+ * the recommended way to use the package. There is likely no object to
+ * load. */
+ vkGetInstanceProcAddr =
+ (PFN_vkGetInstanceProcAddr)dlsym(DEFAULT_HANDLE,
+ "vkGetInstanceProcAddr");
+ }
+
+ if(vkGetInstanceProcAddr)
+ {
+ _this->vulkan_config.loader_handle = DEFAULT_HANDLE;
+ }
+ else
+ {
+ if (!path)
+ {
+ /* Look for the .dylib packaged with the application instead. */
+ path = DEFAULT_MOLTENVK;
+ }
+
+ _this->vulkan_config.loader_handle = SDL_LoadObject(path);
+ if(!_this->vulkan_config.loader_handle)
+ return -1;
+ SDL_strlcpy(_this->vulkan_config.loader_path, path,
+ SDL_arraysize(_this->vulkan_config.loader_path));
+ vkGetInstanceProcAddr =
+ (PFN_vkGetInstanceProcAddr)SDL_LoadFunction(
+ _this->vulkan_config.loader_handle,
+ "vkGetInstanceProcAddr");
+ }
+ if(!vkGetInstanceProcAddr)
+ {
+ SDL_SetError("Failed to find %s in either executable or %s: %s",
+ "vkGetInstanceProcAddr",
+ DEFAULT_MOLTENVK,
+ (const char *) dlerror());
+ goto fail;
+ }
+
+ _this->vulkan_config.vkGetInstanceProcAddr = (void *)vkGetInstanceProcAddr;
+ _this->vulkan_config.vkEnumerateInstanceExtensionProperties =
+ (void *)((PFN_vkGetInstanceProcAddr)_this->vulkan_config.vkGetInstanceProcAddr)(
+ VK_NULL_HANDLE, "vkEnumerateInstanceExtensionProperties");
+ if(!_this->vulkan_config.vkEnumerateInstanceExtensionProperties)
+ {
+ SDL_SetError("No vkEnumerateInstanceExtensionProperties found.");
+ goto fail;
+ }
+ extensions = SDL_Vulkan_CreateInstanceExtensionsList(
+ (PFN_vkEnumerateInstanceExtensionProperties)
+ _this->vulkan_config.vkEnumerateInstanceExtensionProperties,
+ &extensionCount);
+ if(!extensions)
+ goto fail;
+ for(Uint32 i = 0; i < extensionCount; i++)
+ {
+ if(SDL_strcmp(VK_KHR_SURFACE_EXTENSION_NAME, extensions[i].extensionName) == 0)
+ hasSurfaceExtension = SDL_TRUE;
+ else if(SDL_strcmp(VK_MVK_IOS_SURFACE_EXTENSION_NAME, extensions[i].extensionName) == 0)
+ hasIOSSurfaceExtension = SDL_TRUE;
+ }
+ SDL_free(extensions);
+ if(!hasSurfaceExtension)
+ {
+ SDL_SetError("Installed MoltenVK/Vulkan doesn't implement the "
+ VK_KHR_SURFACE_EXTENSION_NAME " extension");
+ goto fail;
+ }
+ else if(!hasIOSSurfaceExtension)
+ {
+ SDL_SetError("Installed MoltenVK/Vulkan doesn't implement the "
+ VK_MVK_IOS_SURFACE_EXTENSION_NAME "extension");
+ goto fail;
+ }
+
+ return 0;
+
+fail:
+ _this->vulkan_config.loader_handle = NULL;
+ return -1;
+}
+
+void UIKit_Vulkan_UnloadLibrary(_THIS)
+{
+ if(_this->vulkan_config.loader_handle)
+ {
+ if (_this->vulkan_config.loader_handle != DEFAULT_HANDLE)
+ SDL_UnloadObject(_this->vulkan_config.loader_handle);
+ _this->vulkan_config.loader_handle = NULL;
+ }
+}
+
+SDL_bool UIKit_Vulkan_GetInstanceExtensions(_THIS,
+ SDL_Window *window,
+ unsigned *count,
+ const char **names)
+{
+ static const char *const extensionsForUIKit[] = {
+ VK_KHR_SURFACE_EXTENSION_NAME, VK_MVK_IOS_SURFACE_EXTENSION_NAME
+ };
+ if(!_this->vulkan_config.loader_handle)
+ {
+ SDL_SetError("Vulkan is not loaded");
+ return SDL_FALSE;
+ }
+ return SDL_Vulkan_GetInstanceExtensions_Helper(
+ count, names, SDL_arraysize(extensionsForUIKit),
+ extensionsForUIKit);
+}
+
+SDL_bool UIKit_Vulkan_CreateSurface(_THIS,
+ SDL_Window *window,
+ VkInstance instance,
+ VkSurfaceKHR *surface)
+{
+ PFN_vkGetInstanceProcAddr vkGetInstanceProcAddr =
+ (PFN_vkGetInstanceProcAddr)_this->vulkan_config.vkGetInstanceProcAddr;
+ PFN_vkCreateIOSSurfaceMVK vkCreateIOSSurfaceMVK =
+ (PFN_vkCreateIOSSurfaceMVK)vkGetInstanceProcAddr(
+ (VkInstance)instance,
+ "vkCreateIOSSurfaceMVK");
+ VkIOSSurfaceCreateInfoMVK createInfo = {};
+ VkResult result;
+
+ if(!_this->vulkan_config.loader_handle)
+ {
+ SDL_SetError("Vulkan is not loaded");
+ return SDL_FALSE;
+ }
+
+ if(!vkCreateIOSSurfaceMVK)
+ {
+ SDL_SetError(VK_MVK_IOS_SURFACE_EXTENSION_NAME
+ " extension is not enabled in the Vulkan instance.");
+ return SDL_FALSE;
+ }
+ createInfo.sType = VK_STRUCTURE_TYPE_IOS_SURFACE_CREATE_INFO_MVK;
+ createInfo.pNext = NULL;
+ createInfo.flags = 0;
+ createInfo.pView = (__bridge void *)UIKit_Mtl_AddMetalView(window);
+ result = vkCreateIOSSurfaceMVK(instance, &createInfo,
+ NULL, surface);
+ if(result != VK_SUCCESS)
+ {
+ SDL_SetError("vkCreateIOSSurfaceMVK failed: %s",
+ SDL_Vulkan_GetResultString(result));
+ return SDL_FALSE;
+ }
+ return SDL_TRUE;
+}
+
+void UIKit_Vulkan_GetDrawableSize(_THIS, SDL_Window *window, int *w, int *h)
+{
+ UIKit_Mtl_GetDrawableSize(window, w, h);
+}
+
+#endif
+
+/* vi: set ts=4 sw=4 expandtab: */
diff --git a/src/video/wayland/SDL_waylandvideo.c b/src/video/wayland/SDL_waylandvideo.c
index 0539cf6..7c936a7 100644
--- a/src/video/wayland/SDL_waylandvideo.c
+++ b/src/video/wayland/SDL_waylandvideo.c
@@ -35,6 +35,7 @@
#include "SDL_waylandmouse.h"
#include "SDL_waylandtouch.h"
#include "SDL_waylandclipboard.h"
+#include "SDL_waylandvulkan.h"
#include <sys/types.h>
#include <unistd.h>
@@ -181,6 +182,13 @@ Wayland_CreateDevice(int devindex)
device->GetClipboardText = Wayland_GetClipboardText;
device->HasClipboardText = Wayland_HasClipboardText;
+#if SDL_VIDEO_VULKAN_SURFACE
+ device->Vulkan_LoadLibrary = Wayland_Vulkan_LoadLibrary;
+ device->Vulkan_UnloadLibrary = Wayland_Vulkan_UnloadLibrary;
+ device->Vulkan_GetInstanceExtensions = Wayland_Vulkan_GetInstanceExtensions;
+ device->Vulkan_CreateSurface = Wayland_Vulkan_CreateSurface;
+#endif
+
device->free = Wayland_DeleteDevice;
return device;
diff --git a/src/video/wayland/SDL_waylandvulkan.c b/src/video/wayland/SDL_waylandvulkan.c
new file mode 100644
index 0000000..f5a9a3a
--- /dev/null
+++ b/src/video/wayland/SDL_waylandvulkan.c
@@ -0,0 +1,175 @@
+/*
+ Simple DirectMedia Layer
+ Copyright (C) 1997-2016 Sam Lantinga <slouken@libsdl.org>
+
+ This software is provided 'as-is', without any express or implied
+ warranty. In no event will the authors be held liable for any damages
+ arising from the use of this software.
+
+ Permission is granted to anyone to use this software for any purpose,
+ including commercial applications, and to alter it and redistribute it
+ freely, subject to the following restrictions:
+
+ 1. The origin of this software must not be misrepresented; you must not
+ claim that you wrote the original software. If you use this software
+ in a product, an acknowledgment in the product documentation would be
+ appreciated but is not required.
+ 2. Altered source versions must be plainly marked as such, and must not be
+ misrepresented as being the original software.
+ 3. This notice may not be removed or altered from any source distribution.
+*/
+
+/*
+ * @author Mark Callow, www.edgewise-consulting.com. Based on Jacob Lifshay's
+ * SDL_x11vulkan.c.
+ */
+
+#include "../../SDL_internal.h"
+
+#if SDL_VIDEO_VULKAN_SURFACE && SDL_VIDEO_DRIVER_WAYLAND
+
+#include "SDL_waylandvideo.h"
+#include "SDL_waylandwindow.h"
+#include "SDL_assert.h"
+
+#include "SDL_loadso.h"
+#include "SDL_waylandvulkan.h"
+#include "SDL_syswm.h"
+
+int Wayland_Vulkan_LoadLibrary(_THIS, const char *path)
+{
+ VkExtensionProperties *extensions = NULL;
+ Uint32 extensionCount = 0;
+ SDL_bool hasSurfaceExtension = SDL_FALSE;
+ SDL_bool hasWaylandSurfaceExtension = SDL_FALSE;
+ PFN_vkGetInstanceProcAddr vkGetInstanceProcAddr = NULL;
+ if(_this->vulkan_config.loader_handle)
+ return SDL_SetError("Vulkan already loaded");
+
+ /* Load the Vulkan loader library */
+ if(!path)
+ path = SDL_getenv("SDL_VULKAN_LIBRARY");
+ if(!path)
+ path = "libvulkan.so.1";
+ _this->vulkan_config.loader_handle = SDL_LoadObject(path);
+ if(!_this->vulkan_config.loader_handle)
+ return -1;
+ SDL_strlcpy(_this->vulkan_config.loader_path, path,
+ SDL_arraysize(_this->vulkan_config.loader_path));
+ vkGetInstanceProcAddr = (PFN_vkGetInstanceProcAddr)SDL_LoadFunction(
+ _this->vulkan_config.loader_handle, "vkGetInstanceProcAddr");
+ if(!vkGetInstanceProcAddr)
+ goto fail;
+ _this->vulkan_config.vkGetInstanceProcAddr = (void *)vkGetInstanceProcAddr;
+ _this->vulkan_config.vkEnumerateInstanceExtensionProperties =
+ (void *)((PFN_vkGetInstanceProcAddr)_this->vulkan_config.vkGetInstanceProcAddr)(
+ VK_NULL_HANDLE, "vkEnumerateInstanceExtensionProperties");
+ if(!_this->vulkan_config.vkEnumerateInstanceExtensionProperties)
+ goto fail;
+ extensions = SDL_Vulkan_CreateInstanceExtensionsList(
+ (PFN_vkEnumerateInstanceExtensionProperties)
+ _this->vulkan_config.vkEnumerateInstanceExtensionProperties,
+ &extensionCount);
+ if(!extensions)
+ goto fail;
+ for(Uint32 i = 0; i < extensionCount; i++)
+ {
+ if(SDL_strcmp(VK_KHR_SURFACE_EXTENSION_NAME, extensions[i].extensionName) == 0)
+ hasSurfaceExtension = SDL_TRUE;
+ else if(SDL_strcmp(VK_KHR_WAYLAND_SURFACE_EXTENSION_NAME, extensions[i].extensionName) == 0)
+ hasWaylandSurfaceExtension = SDL_TRUE;
+ }
+ SDL_free(extensions);
+ if(!hasSurfaceExtension)
+ {
+ SDL_SetError("Installed Vulkan doesn't implement the "
+ VK_KHR_SURFACE_EXTENSION_NAME " extension");
+ goto fail;
+ }
+ else if(!hasWaylandSurfaceExtension)
+ {
+ SDL_SetError("Installed Vulkan doesn't implement the "
+ VK_KHR_WAYLAND_SURFACE_EXTENSION_NAME "extension");
+ goto fail;
+ }
+ return 0;
+
+fail:
+ SDL_UnloadObject(_this->vulkan_config.loader_handle);
+ _this->vulkan_config.loader_handle = NULL;
+ return -1;
+}
+
+void Wayland_Vulkan_UnloadLibrary(_THIS)
+{
+ if(_this->vulkan_config.loader_handle)
+ {
+ SDL_UnloadObject(_this->vulkan_config.loader_handle);
+ _this->vulkan_config.loader_handle = NULL;
+ }
+}
+
+SDL_bool Wayland_Vulkan_GetInstanceExtensions(_THIS,
+ SDL_Window *window,
+ unsigned *count,
+ const char **names)
+{
+ static const char *const extensionsForWayland[] = {
+ VK_KHR_SURFACE_EXTENSION_NAME, VK_KHR_WAYLAND_SURFACE_EXTENSION_NAME
+ };
+ if(!_this->vulkan_config.loader_handle)
+ {
+ SDL_SetError("Vulkan is not loaded");
+ return SDL_FALSE;
+ }
+ return SDL_Vulkan_GetInstanceExtensions_Helper(
+ count, names, SDL_arraysize(extensionsForWayland),
+ extensionsForWayland);
+}
+
+SDL_bool Wayland_Vulkan_CreateSurface(_THIS,
+ SDL_Window *window,
+ VkInstance instance,
+ VkSurfaceKHR *surface)
+{
+ SDL_WindowData *windowData = (SDL_WindowData *)window->driverdata;
+ PFN_vkGetInstanceProcAddr vkGetInstanceProcAddr =
+ (PFN_vkGetInstanceProcAddr)_this->vulkan_config.vkGetInstanceProcAddr;
+ PFN_vkCreateWaylandSurfaceKHR vkCreateWaylandSurfaceKHR =
+ (PFN_vkCreateWaylandSurfaceKHR)vkGetInstanceProcAddr(
+ (VkInstance)instance,
+ "vkCreateWaylandSurfaceKHR");
+ VkWaylandSurfaceCreateInfoKHR createInfo = {};
+ VkResult result;
+
+ if(!_this->vulkan_config.loader_handle)
+ {
+ SDL_SetError("Vulkan is not loaded");
+ return SDL_FALSE;
+ }
+
+ if(!vkCreateWaylandSurfaceKHR)
+ {
+ SDL_SetError(VK_KHR_WAYLAND_SURFACE_EXTENSION_NAME
+ " extension is not enabled in the Vulkan instance.");
+ return SDL_FALSE;
+ }
+ createInfo.sType = VK_STRUCTURE_TYPE_WAYLAND_SURFACE_CREATE_INFO_KHR;
+ createInfo.pNext = NULL;
+ createInfo.flags = 0;
+ createInfo.display = windowData->waylandData->display;
+ createInfo.surface = windowData->surface;
+ result = vkCreateWaylandSurfaceKHR(instance, &createInfo,
+ NULL, surface);
+ if(result != VK_SUCCESS)
+ {
+ SDL_SetError("vkCreateWaylandSurfaceKHR failed: %s",
+ SDL_Vulkan_GetResultString(result));
+ return SDL_FALSE;
+ }
+ return SDL_TRUE;
+}
+
+#endif
+
+/* vim: set ts=4 sw=4 expandtab: */
diff --git a/src/video/wayland/SDL_waylandvulkan.h b/src/video/wayland/SDL_waylandvulkan.h
new file mode 100644
index 0000000..51c12c2
--- /dev/null
+++ b/src/video/wayland/SDL_waylandvulkan.h
@@ -0,0 +1,52 @@
+/*
+ Simple DirectMedia Layer
+ Copyright (C) 1997-2016 Sam Lantinga <slouken@libsdl.org>
+
+ This software is provided 'as-is', without any express or implied
+ warranty. In no event will the authors be held liable for any damages
+ arising from the use of this software.
+
+ Permission is granted to anyone to use this software for any purpose,
+ including commercial applications, and to alter it and redistribute it
+ freely, subject to the following restrictions:
+
+ 1. The origin of this software must not be misrepresented; you must not
+ claim that you wrote the original software. If you use this software
+ in a product, an acknowledgment in the product documentation would be
+ appreciated but is not required.
+ 2. Altered source versions must be plainly marked as such, and must not be
+ misrepresented as being the original software.
+ 3. This notice may not be removed or altered from any source distribution.
+*/
+
+/*
+ * @author Mark Callow, www.edgewise-consulting.com. Based on Jacob Lifshay's
+ * SDL_x11vulkan.h.
+ */
+
+#include "../../SDL_internal.h"
+
+#ifndef _SDL_waylandvulkan_h
+#define _SDL_waylandvulkan_h
+
+#include "../SDL_vulkan_internal.h"
+#include "../SDL_sysvideo.h"
+
+#if SDL_VIDEO_VULKAN_SURFACE && SDL_VIDEO_DRIVER_WAYLAND
+
+int Wayland_Vulkan_LoadLibrary(_THIS, const char *path);
+void Wayland_Vulkan_UnloadLibrary(_THIS);
+SDL_bool Wayland_Vulkan_GetInstanceExtensions(_THIS,
+ SDL_Window *window,
+ unsigned *count,
+ const char **names);
+SDL_bool Wayland_Vulkan_CreateSurface(_THIS,
+ SDL_Window *window,
+ VkInstance instance,
+ VkSurfaceKHR *surface);
+
+#endif
+
+#endif /* _SDL_waylandvulkan_h */
+
+/* vi: set ts=4 sw=4 expandtab: */
diff --git a/src/video/windows/SDL_windowsvideo.c b/src/video/windows/SDL_windowsvideo.c
index f03ebb0..bff2f4f 100644
--- a/src/video/windows/SDL_windowsvideo.c
+++ b/src/video/windows/SDL_windowsvideo.c
@@ -33,6 +33,7 @@
#include "SDL_windowsvideo.h"
#include "SDL_windowsframebuffer.h"
#include "SDL_windowsshape.h"
+#include "SDL_windowsvulkan.h"
/* Initialization/Query functions */
static int WIN_VideoInit(_THIS);
@@ -190,6 +191,13 @@ WIN_CreateDevice(int devindex)
device->GL_SwapWindow = WIN_GLES_SwapWindow;
device->GL_DeleteContext = WIN_GLES_DeleteContext;
#endif
+#if SDL_VIDEO_VULKAN_SURFACE
+ device->Vulkan_LoadLibrary = WIN_Vulkan_LoadLibrary;
+ device->Vulkan_UnloadLibrary = WIN_Vulkan_UnloadLibrary;
+ device->Vulkan_GetInstanceExtensions = WIN_Vulkan_GetInstanceExtensions;
+ device->Vulkan_CreateSurface = WIN_Vulkan_CreateSurface;
+#endif
+
device->StartTextInput = WIN_StartTextInput;
device->StopTextInput = WIN_StopTextInput;
device->SetTextInputRect = WIN_SetTextInputRect;
diff --git a/src/video/windows/SDL_windowsvulkan.c b/src/video/windows/SDL_windowsvulkan.c
new file mode 100644
index 0000000..2bd4b66
--- /dev/null
+++ b/src/video/windows/SDL_windowsvulkan.c
@@ -0,0 +1,176 @@
+/*
+ Simple DirectMedia Layer
+ Copyright (C) 1997-2016 Sam Lantinga <slouken@libsdl.org>
+
+ This software is provided 'as-is', without any express or implied
+ warranty. In no event will the authors be held liable for any damages
+ arising from the use of this software.
+
+ Permission is granted to anyone to use this software for any purpose,
+ including commercial applications, and to alter it and redistribute it
+ freely, subject to the following restrictions:
+
+ 1. The origin of this software must not be misrepresented; you must not
+ claim that you wrote the original software. If you use this software
+ in a product, an acknowledgment in the product documentation would be
+ appreciated but is not required.
+ 2. Altered source versions must be plainly marked as such, and must not be
+ misrepresented as being the original software.
+ 3. This notice may not be removed or altered from any source distribution.
+*/
+
+/*
+ * @author Mark Callow, www.edgewise-consulting.com. Based on Jacob Lifshay's
+ * SDL_x11vulkan.c.
+ */
+
+#include "../../SDL_internal.h"
+
+#if SDL_VIDEO_VULKAN_SURFACE && SDL_VIDEO_DRIVER_WINDOWS
+
+#include "SDL_windowsvideo.h"
+#include "SDL_windowswindow.h"
+#include "SDL_assert.h"
+
+#include "SDL_loadso.h"
+#include "SDL_windowsvulkan.h"
+#include "SDL_syswm.h"
+
+int WIN_Vulkan_LoadLibrary(_THIS, const char *path)
+{
+ VkExtensionProperties *extensions = NULL;
+ Uint32 extensionCount = 0;
+ Uint32 i;
+ SDL_bool hasSurfaceExtension = SDL_FALSE;
+ SDL_bool hasWin32SurfaceExtension = SDL_FALSE;
+ PFN_vkGetInstanceProcAddr vkGetInstanceProcAddr = NULL;
+ if(_this->vulkan_config.loader_handle)
+ return SDL_SetError("Vulkan already loaded");
+
+ /* Load the Vulkan loader library */
+ if(!path)
+ path = SDL_getenv("SDL_VULKAN_LIBRARY");
+ if(!path)
+ path = "vulkan-1.dll";
+ _this->vulkan_config.loader_handle = SDL_LoadObject(path);
+ if(!_this->vulkan_config.loader_handle)
+ return -1;
+ SDL_strlcpy(_this->vulkan_config.loader_path, path,
+ SDL_arraysize(_this->vulkan_config.loader_path));
+ vkGetInstanceProcAddr = (PFN_vkGetInstanceProcAddr)SDL_LoadFunction(
+ _this->vulkan_config.loader_handle, "vkGetInstanceProcAddr");
+ if(!vkGetInstanceProcAddr)
+ goto fail;
+ _this->vulkan_config.vkGetInstanceProcAddr = (void *)vkGetInstanceProcAddr;
+ _this->vulkan_config.vkEnumerateInstanceExtensionProperties =
+ (void *)((PFN_vkGetInstanceProcAddr)_this->vulkan_config.vkGetInstanceProcAddr)(
+ VK_NULL_HANDLE, "vkEnumerateInstanceExtensionProperties");
+ if(!_this->vulkan_config.vkEnumerateInstanceExtensionProperties)
+ goto fail;
+ extensions = SDL_Vulkan_CreateInstanceExtensionsList(
+ (PFN_vkEnumerateInstanceExtensionProperties)
+ _this->vulkan_config.vkEnumerateInstanceExtensionProperties,
+ &extensionCount);
+ if(!extensions)
+ goto fail;
+ for(i = 0; i < extensionCount; i++)
+ {
+ if(SDL_strcmp(VK_KHR_SURFACE_EXTENSION_NAME, extensions[i].extensionName) == 0)
+ hasSurfaceExtension = SDL_TRUE;
+ else if(SDL_strcmp(VK_KHR_WIN32_SURFACE_EXTENSION_NAME, extensions[i].extensionName) == 0)
+ hasWin32SurfaceExtension = SDL_TRUE;
+ }
+ SDL_free(extensions);
+ if(!hasSurfaceExtension)
+ {
+ SDL_SetError("Installed Vulkan doesn't implement the "
+ VK_KHR_SURFACE_EXTENSION_NAME " extension");
+ goto fail;
+ }
+ else if(!hasWin32SurfaceExtension)
+ {
+ SDL_SetError("Installed Vulkan doesn't implement the "
+ VK_KHR_WIN32_SURFACE_EXTENSION_NAME "extension");
+ goto fail;
+ }
+ return 0;
+
+fail:
+ SDL_UnloadObject(_this->vulkan_config.loader_handle);
+ _this->vulkan_config.loader_handle = NULL;
+ return -1;
+}
+
+void WIN_Vulkan_UnloadLibrary(_THIS)
+{
+ if(_this->vulkan_config.loader_handle)
+ {
+ SDL_UnloadObject(_this->vulkan_config.loader_handle);
+ _this->vulkan_config.loader_handle = NULL;
+ }
+}
+
+SDL_bool WIN_Vulkan_GetInstanceExtensions(_THIS,
+ SDL_Window *window,
+ unsigned *count,
+ const char **names)
+{
+ static const char *const extensionsForWin32[] = {
+ VK_KHR_SURFACE_EXTENSION_NAME, VK_KHR_WIN32_SURFACE_EXTENSION_NAME
+ };
+ if(!_this->vulkan_config.loader_handle)
+ {
+ SDL_SetError("Vulkan is not loaded");
+ return SDL_FALSE;
+ }
+ return SDL_Vulkan_GetInstanceExtensions_Helper(
+ count, names, SDL_arraysize(extensionsForWin32),
+ extensionsForWin32);
+}
+
+SDL_bool WIN_Vulkan_CreateSurface(_THIS,
+ SDL_Window *window,
+ VkInstance instance,
+ VkSurfaceKHR *surface)
+{
+ SDL_WindowData *windowData = (SDL_WindowData *)window->driverdata;
+ PFN_vkGetInstanceProcAddr vkGetInstanceProcAddr =
+ (PFN_vkGetInstanceProcAddr)_this->vulkan_config.vkGetInstanceProcAddr;
+ PFN_vkCreateWin32SurfaceKHR vkCreateWin32SurfaceKHR =
+ (PFN_vkCreateWin32SurfaceKHR)vkGetInstanceProcAddr(
+ (VkInstance)instance,
+ "vkCreateWin32SurfaceKHR");
+ VkWin32SurfaceCreateInfoKHR createInfo;
+ VkResult result;
+
+ if(!_this->vulkan_config.loader_handle)
+ {
+ SDL_SetError("Vulkan is not loaded");
+ return SDL_FALSE;
+ }
+
+ if(!vkCreateWin32SurfaceKHR)
+ {
+ SDL_SetError(VK_KHR_WIN32_SURFACE_EXTENSION_NAME
+ " extension is not enabled in the Vulkan instance.");
+ return SDL_FALSE;
+ }
+ createInfo.sType = VK_STRUCTURE_TYPE_WIN32_SURFACE_CREATE_INFO_KHR;
+ createInfo.pNext = NULL;
+ createInfo.flags = 0;
+ createInfo.hinstance = windowData->hinstance;
+ createInfo.hwnd = windowData->hwnd;
+ result = vkCreateWin32SurfaceKHR(instance, &createInfo,
+ NULL, surface);
+ if(result != VK_SUCCESS)
+ {
+ SDL_SetError("vkCreateWin32SurfaceKHR failed: %s",
+ SDL_Vulkan_GetResultString(result));
+ return SDL_FALSE;
+ }
+ return SDL_TRUE;
+}
+
+#endif
+
+/* vi: set ts=4 sw=4 expandtab: */
diff --git a/src/video/windows/SDL_windowsvulkan.h b/src/video/windows/SDL_windowsvulkan.h
new file mode 100644
index 0000000..82284b1
--- /dev/null
+++ b/src/video/windows/SDL_windowsvulkan.h
@@ -0,0 +1,52 @@
+/*
+ Simple DirectMedia Layer
+ Copyright (C) 1997-2016 Sam Lantinga <slouken@libsdl.org>
+
+ This software is provided 'as-is', without any express or implied
+ warranty. In no event will the authors be held liable for any damages
+ arising from the use of this software.
+
+ Permission is granted to anyone to use this software for any purpose,
+ including commercial applications, and to alter it and redistribute it
+ freely, subject to the following restrictions:
+
+ 1. The origin of this software must not be misrepresented; you must not
+ claim that you wrote the original software. If you use this software
+ in a product, an acknowledgment in the product documentation would be
+ appreciated but is not required.
+ 2. Altered source versions must be plainly marked as such, and must not be
+ misrepresented as being the original software.
+ 3. This notice may not be removed or altered from any source distribution.
+*/
+
+/*
+ * @author Mark Callow, www.edgewise-consulting.com. Based on Jacob Lifshay's
+ * SDL_x11vulkan.h.
+ */
+
+#include "../../SDL_internal.h"
+
+#ifndef _SDL_windowsvulkan_h
+#define _SDL_windowsvulkan_h
+
+#include "../SDL_vulkan_internal.h"
+#include "../SDL_sysvideo.h"
+
+#if SDL_VIDEO_VULKAN_SURFACE && SDL_VIDEO_DRIVER_WINDOWS
+
+int WIN_Vulkan_LoadLibrary(_THIS, const char *path);
+void WIN_Vulkan_UnloadLibrary(_THIS);
+SDL_bool WIN_Vulkan_GetInstanceExtensions(_THIS,
+ SDL_Window *window,
+ unsigned *count,
+ const char **names);
+SDL_bool WIN_Vulkan_CreateSurface(_THIS,
+ SDL_Window *window,
+ VkInstance instance,
+ VkSurfaceKHR *surface);
+
+#endif
+
+#endif /* _SDL_windowsvulkan_h */
+
+/* vi: set ts=4 sw=4 expandtab: */
diff --git a/src/video/x11/SDL_x11video.c b/src/video/x11/SDL_x11video.c
index 0a73e29..a84dbde 100644
--- a/src/video/x11/SDL_x11video.c
+++ b/src/video/x11/SDL_x11video.c
@@ -40,6 +40,8 @@
#include "SDL_x11opengles.h"
#endif
+#include "SDL_x11vulkan.h"
+
/* Initialization/Query functions */
static int X11_VideoInit(_THIS);
static void X11_VideoQuit(_THIS);
@@ -107,6 +109,9 @@ static void
X11_DeleteDevice(SDL_VideoDevice * device)
{
SDL_VideoData *data = (SDL_VideoData *) device->driverdata;
+ if (device->vulkan_config.loader_handle) {
+ device->Vulkan_UnloadLibrary(device);
+ }
if (data->display) {
X11_XCloseDisplay(data->display);
}
@@ -291,6 +296,13 @@ X11_CreateDevice(int devindex)
device->free = X11_DeleteDevice;
+#if SDL_VIDEO_VULKAN_SURFACE
+ device->Vulkan_LoadLibrary = X11_Vulkan_LoadLibrary;
+ device->Vulkan_UnloadLibrary = X11_Vulkan_UnloadLibrary;
+ device->Vulkan_GetInstanceExtensions = X11_Vulkan_GetInstanceExtensions;
+ device->Vulkan_CreateSurface = X11_Vulkan_CreateSurface;
+#endif
+
return device;
}
diff --git a/src/video/x11/SDL_x11video.h b/src/video/x11/SDL_x11video.h
index 7df549e..1b11aeb 100644
--- a/src/video/x11/SDL_x11video.h
+++ b/src/video/x11/SDL_x11video.h
@@ -68,6 +68,7 @@
#include "SDL_x11mouse.h"
#include "SDL_x11opengl.h"
#include "SDL_x11window.h"
+#include "SDL_x11vulkan.h"
/* Private display data */
@@ -140,6 +141,12 @@ typedef struct SDL_VideoData
KeyCode filter_code;
Time filter_time;
+#if SDL_VIDEO_VULKAN_SURFACE
+ /* Vulkan variables only valid if _this->vulkan_config.loader_handle is not NULL */
+ void *vulkan_xlib_xcb_library;
+ PFN_XGetXCBConnection vulkan_XGetXCBConnection;
+#endif
+
} SDL_VideoData;
extern SDL_bool X11_UseDirectColorVisuals(void);
diff --git a/src/video/x11/SDL_x11vulkan.c b/src/video/x11/SDL_x11vulkan.c
new file mode 100644
index 0000000..3cba300
--- /dev/null
+++ b/src/video/x11/SDL_x11vulkan.c
@@ -0,0 +1,239 @@
+/*
+ Simple DirectMedia Layer
+ Copyright (C) 1997-2016 Sam Lantinga <slouken@libsdl.org>
+
+ This software is provided 'as-is', without any express or implied
+ warranty. In no event will the authors be held liable for any damages
+ arising from the use of this software.
+
+ Permission is granted to anyone to use this software for any purpose,
+ including commercial applications, and to alter it and redistribute it
+ freely, subject to the following restrictions:
+
+ 1. The origin of this software must not be misrepresented; you must not
+ claim that you wrote the original software. If you use this software
+ in a product, an acknowledgment in the product documentation would be
+ appreciated but is not required.
+ 2. Altered source versions must be plainly marked as such, and must not be
+ misrepresented as being the original software.
+ 3. This notice may not be removed or altered from any source distribution.
+*/
+#include "../../SDL_internal.h"
+
+#if SDL_VIDEO_VULKAN_SURFACE && SDL_VIDEO_DRIVER_X11
+
+#include "SDL_x11video.h"
+#include "SDL_assert.h"
+
+#include "SDL_loadso.h"
+#include "SDL_x11vulkan.h"
+
+#include <X11/Xlib.h>
+//#include <xcb/xcb.h>
+typedef uint32_t xcb_window_t;
+typedef uint32_t xcb_visualid_t;
+
+int X11_Vulkan_LoadLibrary(_THIS, const char *path)
+{
+ SDL_VideoData *videoData = (SDL_VideoData *)_this->driverdata;
+ VkExtensionProperties *extensions = NULL;
+ Uint32 extensionCount = 0;
+ SDL_bool hasSurfaceExtension = SDL_FALSE;
+ SDL_bool hasXlibSurfaceExtension = SDL_FALSE;
+ SDL_bool hasXCBSurfaceExtension = SDL_FALSE;
+ PFN_vkGetInstanceProcAddr vkGetInstanceProcAddr = NULL;
+ Uint32 i;
+ if(_this->vulkan_config.loader_handle)
+ return SDL_SetError("Vulkan already loaded");
+
+ /* Load the Vulkan loader library */
+ if(!path)
+ path = SDL_getenv("SDL_VULKAN_LIBRARY");
+ if(!path)
+ path = "libvulkan.so.1";
+ _this->vulkan_config.loader_handle = SDL_LoadObject(path);
+ if(!_this->vulkan_config.loader_handle)
+ return -1;
+ SDL_strlcpy(_this->vulkan_config.loader_path, path, SDL_arraysize(_this->vulkan_config.loader_path));
+ vkGetInstanceProcAddr = (PFN_vkGetInstanceProcAddr)SDL_LoadFunction(
+ _this->vulkan_config.loader_handle, "vkGetInstanceProcAddr");
+ if(!vkGetInstanceProcAddr)
+ goto fail;
+ _this->vulkan_config.vkGetInstanceProcAddr = (void *)vkGetInstanceProcAddr;
+ _this->vulkan_config.vkEnumerateInstanceExtensionProperties =
+ (void *)((PFN_vkGetInstanceProcAddr)_this->vulkan_config.vkGetInstanceProcAddr)(
+ VK_NULL_HANDLE, "vkEnumerateInstanceExtensionProperties");
+ if(!_this->vulkan_config.vkEnumerateInstanceExtensionProperties)
+ goto fail;
+ extensions = SDL_Vulkan_CreateInstanceExtensionsList(
+ (PFN_vkEnumerateInstanceExtensionProperties)
+ _this->vulkan_config.vkEnumerateInstanceExtensionProperties,
+ &extensionCount);
+ if(!extensions)
+ goto fail;
+ for(i = 0; i < extensionCount; i++)
+ {
+ if(SDL_strcmp(VK_KHR_SURFACE_EXTENSION_NAME, extensions[i].extensionName) == 0)
+ hasSurfaceExtension = SDL_TRUE;
+ else if(SDL_strcmp(VK_KHR_XCB_SURFACE_EXTENSION_NAME, extensions[i].extensionName) == 0)
+ hasXCBSurfaceExtension = SDL_TRUE;
+ else if(SDL_strcmp(VK_KHR_XLIB_SURFACE_EXTENSION_NAME, extensions[i].extensionName) == 0)
+ hasXlibSurfaceExtension = SDL_TRUE;
+ }
+ SDL_free(extensions);
+ if(!hasSurfaceExtension)
+ {
+ SDL_SetError("Installed Vulkan doesn't implement the "
+ VK_KHR_SURFACE_EXTENSION_NAME " extension");
+ goto fail;
+ }
+ if(hasXlibSurfaceExtension)
+ {
+ videoData->vulkan_xlib_xcb_library = NULL;
+ }
+ else if(!hasXCBSurfaceExtension)
+ {
+ SDL_SetError("Installed Vulkan doesn't implement either the "
+ VK_KHR_XCB_SURFACE_EXTENSION_NAME "extension or the "
+ VK_KHR_XLIB_SURFACE_EXTENSION_NAME " extension");
+ goto fail;
+ }
+ else
+ {
+ const char *libX11XCBLibraryName = SDL_getenv("SDL_X11_XCB_LIBRARY");
+ if(!libX11XCBLibraryName)
+ libX11XCBLibraryName = "libX11-xcb.so";
+ videoData->vulkan_xlib_xcb_library = SDL_LoadObject(libX11XCBLibraryName);
+ if(!videoData->vulkan_xlib_xcb_library)
+ goto fail;
+ videoData->vulkan_XGetXCBConnection =
+ SDL_LoadFunction(videoData->vulkan_xlib_xcb_library, "XGetXCBConnection");
+ if(!videoData->vulkan_XGetXCBConnection)
+ {
+ SDL_UnloadObject(videoData->vulkan_xlib_xcb_library);
+ goto fail;
+ }
+ }
+ return 0;
+
+fail:
+ SDL_UnloadObject(_this->vulkan_config.loader_handle);
+ _this->vulkan_config.loader_handle = NULL;
+ return -1;
+}
+
+void X11_Vulkan_UnloadLibrary(_THIS)
+{
+ SDL_VideoData *videoData = (SDL_VideoData *)_this->driverdata;
+ if(_this->vulkan_config.loader_handle)
+ {
+ if(videoData->vulkan_xlib_xcb_library)
+ SDL_UnloadObject(videoData->vulkan_xlib_xcb_library);
+ SDL_UnloadObject(_this->vulkan_config.loader_handle);
+ _this->vulkan_config.loader_handle = NULL;
+ }
+}
+
+SDL_bool X11_Vulkan_GetInstanceExtensions(_THIS,
+ SDL_Window *window,
+ unsigned *count,
+ const char **names)
+{
+ SDL_VideoData *videoData = (SDL_VideoData *)_this->driverdata;
+ if(!_this->vulkan_config.loader_handle)
+ {
+ SDL_SetError("Vulkan is not loaded");
+ return SDL_FALSE;
+ }
+ if(videoData->vulkan_xlib_xcb_library)
+ {
+ static const char *const extensionsForXCB[] = {
+ VK_KHR_SURFACE_EXTENSION_NAME, VK_KHR_XCB_SURFACE_EXTENSION_NAME,
+ };
+ return SDL_Vulkan_GetInstanceExtensions_Helper(
+ count, names, SDL_arraysize(extensionsForXCB), extensionsForXCB);
+ }
+ else
+ {
+ static const char *const extensionsForXlib[] = {
+ VK_KHR_SURFACE_EXTENSION_NAME, VK_KHR_XLIB_SURFACE_EXTENSION_NAME,
+ };
+ return SDL_Vulkan_GetInstanceExtensions_Helper(
+ count, names, SDL_arraysize(extensionsForXlib), extensionsForXlib);
+ }
+}
+
+SDL_bool X11_Vulkan_CreateSurface(_THIS,
+ SDL_Window *window,
+ VkInstance instance,
+ VkSurfaceKHR *surface)
+{
+ SDL_VideoData *videoData = (SDL_VideoData *)_this->driverdata;
+ SDL_WindowData *windowData = (SDL_WindowData *)window->driverdata;
+ PFN_vkGetInstanceProcAddr vkGetInstanceProcAddr;
+ if(!_this->vulkan_config.loader_handle)
+ {
+ SDL_SetError("Vulkan is not loaded");
+ return SDL_FALSE;
+ }
+ vkGetInstanceProcAddr = (PFN_vkGetInstanceProcAddr)_this->vulkan_config.vkGetInstanceProcAddr;
+ if(videoData->vulkan_xlib_xcb_library)
+ {
+ PFN_vkCreateXcbSurfaceKHR vkCreateXcbSurfaceKHR =
+ (PFN_vkCreateXcbSurfaceKHR)vkGetInstanceProcAddr((VkInstance)instance,
+ "vkCreateXcbSurfaceKHR");
+ VkXcbSurfaceCreateInfoKHR createInfo = {};
+ VkResult result;
+ if(!vkCreateXcbSurfaceKHR)
+ {
+ SDL_SetError(VK_KHR_XCB_SURFACE_EXTENSION_NAME
+ " extension is not enabled in the Vulkan instance.");
+ return SDL_FALSE;
+ }
+ createInfo.sType = VK_STRUCTURE_TYPE_XCB_SURFACE_CREATE_INFO_KHR;
+ createInfo.connection = videoData->vulkan_XGetXCBConnection(videoData->display);
+ if(!createInfo.connection)
+ {
+ SDL_SetError("XGetXCBConnection failed");
+ return SDL_FALSE;
+ }
+ createInfo.window = (xcb_window_t)windowData->xwindow;
+ result = vkCreateXcbSurfaceKHR(instance, &createInfo,
+ NULL, surface);
+ if(result != VK_SUCCESS)
+ {
+ SDL_SetError("vkCreateXcbSurfaceKHR failed: %s", SDL_Vulkan_GetResultString(result));
+ return SDL_FALSE;
+ }
+ return SDL_TRUE;
+ }
+ else
+ {
+ PFN_vkCreateXlibSurfaceKHR vkCreateXlibSurfaceKHR =
+ (PFN_vkCreateXlibSurfaceKHR)vkGetInstanceProcAddr((VkInstance)instance,
+ "vkCreateXlibSurfaceKHR");
+ VkXlibSurfaceCreateInfoKHR createInfo = {};
+ VkResult result;
+ if(!vkCreateXlibSurfaceKHR)
+ {
+ SDL_SetError(VK_KHR_XLIB_SURFACE_EXTENSION_NAME
+ " extension is not enabled in the Vulkan instance.");
+ return SDL_FALSE;
+ }
+ createInfo.sType = VK_STRUCTURE_TYPE_XLIB_SURFACE_CREATE_INFO_KHR;
+ createInfo.dpy = videoData->display;
+ createInfo.window = (xcb_window_t)windowData->xwindow;
+ result = vkCreateXlibSurfaceKHR(instance, &createInfo,
+ NULL, surface);
+ if(result != VK_SUCCESS)
+ {
+ SDL_SetError("vkCreateXlibSurfaceKHR failed: %s", SDL_Vulkan_GetResultString(result));
+ return SDL_FALSE;
+ }
+ return SDL_TRUE;
+ }
+}
+
+#endif
+
+/* vim: set ts=4 sw=4 expandtab: */
diff --git a/src/video/x11/SDL_x11vulkan.h b/src/video/x11/SDL_x11vulkan.h
new file mode 100644
index 0000000..d028473
--- /dev/null
+++ b/src/video/x11/SDL_x11vulkan.h
@@ -0,0 +1,48 @@
+/*
+ Simple DirectMedia Layer
+ Copyright (C) 1997-2016 Sam Lantinga <slouken@libsdl.org>
+
+ This software is provided 'as-is', without any express or implied
+ warranty. In no event will the authors be held liable for any damages
+ arising from the use of this software.
+
+ Permission is granted to anyone to use this software for any purpose,
+ including commercial applications, and to alter it and redistribute it
+ freely, subject to the following restrictions:
+
+ 1. The origin of this software must not be misrepresented; you must not
+ claim that you wrote the original software. If you use this software
+ in a product, an acknowledgment in the product documentation would be
+ appreciated but is not required.
+ 2. Altered source versions must be plainly marked as such, and must not be
+ misrepresented as being the original software.
+ 3. This notice may not be removed or altered from any source distribution.
+*/
+#include "../../SDL_internal.h"
+
+#ifndef _SDL_x11vulkan_h
+#define _SDL_x11vulkan_h
+
+#include "../SDL_vulkan_internal.h"
+
+#if SDL_VIDEO_VULKAN_SURFACE && SDL_VIDEO_DRIVER_X11
+
+typedef struct xcb_connection_t xcb_connection_t;
+typedef xcb_connection_t *(*PFN_XGetXCBConnection)(Display *dpy);
+
+int X11_Vulkan_LoadLibrary(_THIS, const char *path);
+void X11_Vulkan_UnloadLibrary(_THIS);
+SDL_bool X11_Vulkan_GetInstanceExtensions(_THIS,
+ SDL_Window *window,
+ unsigned *count,
+ const char **names);
+SDL_bool X11_Vulkan_CreateSurface(_THIS,
+ SDL_Window *window,
+ VkInstance instance,
+ VkSurfaceKHR *surface);
+
+#endif
+
+#endif /* _SDL_x11vulkan_h */
+
+/* vi: set ts=4 sw=4 expandtab: */
diff --git a/test/Makefile.in b/test/Makefile.in
index 53c2d34..0ac70e9 100644
--- a/test/Makefile.in
+++ b/test/Makefile.in
@@ -66,6 +66,7 @@ TARGETS = \
testdisplayinfo$(EXE) \
testqsort$(EXE) \
controllermap$(EXE) \
+ testvulkan$(EXE) \
all: Makefile $(TARGETS) copydatafiles
@@ -289,6 +290,9 @@ testcustomcursor$(EXE): $(srcdir)/testcustomcursor.c
controllermap$(EXE): $(srcdir)/controllermap.c
$(CC) -o $@ $^ $(CFLAGS) $(LIBS)
+testvulkan$(EXE): $(srcdir)/testvulkan.c
+ $(CC) -o $@ $^ $(CFLAGS) $(LIBS)
+
clean:
rm -f $(TARGETS)
diff --git a/test/configure b/test/configure
index 61c32fb..79ba9ce 100755
--- a/test/configure
+++ b/test/configure
@@ -195,7 +195,8 @@ test -x / || exit 1"
as_suggested=" as_lineno_1=";as_suggested=$as_suggested$LINENO;as_suggested=$as_suggested" as_lineno_1a=\$LINENO
as_lineno_2=";as_suggested=$as_suggested$LINENO;as_suggested=$as_suggested" as_lineno_2a=\$LINENO
eval 'test \"x\$as_lineno_1'\$as_run'\" != \"x\$as_lineno_2'\$as_run'\" &&
- test \"x\`expr \$as_lineno_1'\$as_run' + 1\`\" = \"x\$as_lineno_2'\$as_run'\"' || exit 1"
+ test \"x\`expr \$as_lineno_1'\$as_run' + 1\`\" = \"x\$as_lineno_2'\$as_run'\"' || exit 1
+test \$(( 1 + 1 )) = 2 || exit 1"
if (eval "$as_required") 2>/dev/null; then :
as_have_required=yes
else
@@ -582,9 +583,47 @@ PACKAGE_BUGREPORT=
PACKAGE_URL=
ac_unique_file="README"
+# Factoring default headers for most tests.
+ac_includes_default="\
+#include <stdio.h>
+#ifdef HAVE_SYS_TYPES_H
+# include <sys/types.h>
+#endif
+#ifdef HAVE_SYS_STAT_H
+# include <sys/stat.h>
+#endif
+#ifdef STDC_HEADERS
+# include <stdlib.h>
+# include <stddef.h>
+#else
+# ifdef HAVE_STDLIB_H
+# include <stdlib.h>
+# endif
+#endif
+#ifdef HAVE_STRING_H
+# if !defined STDC_HEADERS && defined HAVE_MEMORY_H
+# include <memory.h>
+# endif
+# include <string.h>
+#endif
+#ifdef HAVE_STRINGS_H
+# include <strings.h>
+#endif
+#ifdef HAVE_INTTYPES_H
+# include <inttypes.h>
+#endif
+#ifdef HAVE_STDINT_H
+# include <stdint.h>
+#endif
+#ifdef HAVE_UNISTD_H
+# include <unistd.h>
+#endif"
+
ac_subst_vars='LTLIBOBJS
LIBOBJS
SDL_TTF_LIB
+EGREP
+GREP
XLIB
GLES2LIB
GLESLIB
@@ -637,6 +676,7 @@ infodir
docdir
oldincludedir
includedir
+runstatedir
localstatedir
sharedstatedir
sysconfdir
@@ -717,6 +757,7 @@ datadir='${datarootdir}'
sysconfdir='${prefix}/etc'
sharedstatedir='${prefix}/com'
localstatedir='${prefix}/var'
+runstatedir='${localstatedir}/run'
includedir='${prefix}/include'
oldincludedir='/usr/include'
docdir='${datarootdir}/doc/${PACKAGE}'
@@ -969,6 +1010,15 @@ do
| -silent | --silent | --silen | --sile | --sil)
silent=yes ;;
+ -runstatedir | --runstatedir | --runstatedi | --runstated \
+ | --runstate | --runstat | --runsta | --runst | --runs \
+ | --run | --ru | --r)
+ ac_prev=runstatedir ;;
+ -runstatedir=* | --runstatedir=* | --runstatedi=* | --runstated=* \
+ | --runstate=* | --runstat=* | --runsta=* | --runst=* | --runs=* \
+ | --run=* | --ru=* | --r=*)
+ runstatedir=$ac_optarg ;;
+
-sbindir | --sbindir | --sbindi | --sbind | --sbin | --sbi | --sb)
ac_prev=sbindir ;;
-sbindir=* | --sbindir=* | --sbindi=* | --sbind=* | --sbin=* \
@@ -1106,7 +1156,7 @@ fi
for ac_var in exec_prefix prefix bindir sbindir libexecdir datarootdir \
datadir sysconfdir sharedstatedir localstatedir includedir \
oldincludedir docdir infodir htmldir dvidir pdfdir psdir \
- libdir localedir mandir
+ libdir localedir mandir runstatedir
do
eval ac_val=\$$ac_var
# Remove trailing slashes.
@@ -1259,6 +1309,7 @@ Fine tuning of the installation directories:
--sysconfdir=DIR read-only single-machine data [PREFIX/etc]
--sharedstatedir=DIR modifiable architecture-independent data [PREFIX/com]
--localstatedir=DIR modifiable single-machine data [PREFIX/var]
+ --runstatedir=DIR modifiable per-process data [LOCALSTATEDIR/run]
--libdir=DIR object code libraries [EPREFIX/lib]
--includedir=DIR C header files [PREFIX/include]
--oldincludedir=DIR C header files for non-gcc [/usr/include]
@@ -1563,6 +1614,124 @@ fi
as_fn_set_status $ac_retval
} # ac_fn_c_try_cpp
+
+# ac_fn_c_check_header_mongrel LINENO HEADER VAR INCLUDES
+# -------------------------------------------------------
+# Tests whether HEADER exists, giving a warning if it cannot be compiled using
+# the include files in INCLUDES and setting the cache variable VAR
+# accordingly.
+ac_fn_c_check_header_mongrel ()
+{
+ as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
+ if eval \${$3+:} false; then :
+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5
+$as_echo_n "checking for $2... " >&6; }
+if eval \${$3+:} false; then :
+ $as_echo_n "(cached) " >&6
+fi
+eval ac_res=\$$3
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5
+$as_echo "$ac_res" >&6; }
+else
+ # Is the header compilable?
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking $2 usability" >&5
+$as_echo_n "checking $2 usability... " >&6; }
+cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h. */
+$4
+#include <$2>
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"; then :
+ ac_header_compiler=yes
+else
+ ac_header_compiler=no
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_header_compiler" >&5
+$as_echo "$ac_header_compiler" >&6; }
+
+# Is the header present?
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking $2 presence" >&5
+$as_echo_n "checking $2 presence... " >&6; }
+cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h. */
+#include <$2>
+_ACEOF
+if ac_fn_c_try_cpp "$LINENO"; then :
+ ac_header_preproc=yes
+else
+ ac_header_preproc=no
+fi
+rm -f conftest.err conftest.i conftest.$ac_ext
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_header_preproc" >&5
+$as_echo "$ac_header_preproc" >&6; }
+
+# So? What about this header?
+case $ac_header_compiler:$ac_header_preproc:$ac_c_preproc_warn_flag in #((
+ yes:no: )
+ { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: accepted by the compiler, rejected by the preprocessor!" >&5
+$as_echo "$as_me: WARNING: $2: accepted by the compiler, rejected by the preprocessor!" >&2;}
+ { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: proceeding with the compiler's result" >&5
+$as_echo "$as_me: WARNING: $2: proceeding with the compiler's result" >&2;}
+ ;;
+ no:yes:* )
+ { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: present but cannot be compiled" >&5
+$as_echo "$as_me: WARNING: $2: present but cannot be compiled" >&2;}
+ { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: check for missing prerequisite headers?" >&5
+$as_echo "$as_me: WARNING: $2: check for missing prerequisite headers?" >&2;}
+ { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: see the Autoconf documentation" >&5
+$as_echo "$as_me: WARNING: $2: see the Autoconf documentation" >&2;}
+ { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: section \"Present But Cannot Be Compiled\"" >&5
+$as_echo "$as_me: WARNING: $2: section \"Present But Cannot Be Compiled\"" >&2;}
+ { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: proceeding with the compiler's result" >&5
+$as_echo "$as_me: WARNING: $2: proceeding with the compiler's result" >&2;}
+ ;;
+esac
+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5
+$as_echo_n "checking for $2... " >&6; }
+if eval \${$3+:} false; then :
+ $as_echo_n "(cached) " >&6
+else
+ eval "$3=\$ac_header_compiler"
+fi
+eval ac_res=\$$3
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5
+$as_echo "$ac_res" >&6; }
+fi
+ eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno
+
+} # ac_fn_c_check_header_mongrel
+
+# ac_fn_c_check_header_compile LINENO HEADER VAR INCLUDES
+# -------------------------------------------------------
+# Tests whether HEADER exists and can be compiled using the include files in
+# INCLUDES, setting the cache variable VAR accordingly.
+ac_fn_c_check_header_compile ()
+{
+ as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5
+$as_echo_n "checking for $2... " >&6; }
+if eval \${$3+:} false; then :
+ $as_echo_n "(cached) " >&6
+else
+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h. */
+$4
+#include <$2>
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"; then :
+ eval "$3=yes"
+else
+ eval "$3=no"
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+fi
+eval ac_res=\$$3
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5
+$as_echo "$ac_res" >&6; }
+ eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno
+
+} # ac_fn_c_check_header_compile
cat >config.log <<_ACEOF
This file contains any messages produced by compilers while
running configure, to aid debugging if configure makes a mistake.
@@ -3919,6 +4088,289 @@ fi
+have_vulkan_hdr=no
+vsdk_include_dir="${VULKAN_SDK}/include"
+vulkan_header="vulkan/vulkan.h"
+save_CPPFLAGS="$CPPFLAGS"
+CPPFLAGS="${save_CPPFLAGS} -I$vsdk_include_dir"
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for grep that handles long lines and -e" >&5
+$as_echo_n "checking for grep that handles long lines and -e... " >&6; }
+if ${ac_cv_path_GREP+:} false; then :
+ $as_echo_n "(cached) " >&6
+else
+ if test -z "$GREP"; then
+ ac_path_GREP_found=false
+ # Loop through the user's path and test for each of PROGNAME-LIST
+ as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH$PATH_SEPARATOR/usr/xpg4/bin
+do
+ IFS=$as_save_IFS
+ test -z "$as_dir" && as_dir=.
+ for ac_prog in grep ggrep; do
+ for ac_exec_ext in '' $ac_executable_extensions; do
+ ac_path_GREP="$as_dir/$ac_prog$ac_exec_ext"
+ as_fn_executable_p "$ac_path_GREP" || continue
+# Check for GNU ac_path_GREP and select it if it is found.
+ # Check for GNU $ac_path_GREP
+case `"$ac_path_GREP" --version 2>&1` in
+*GNU*)
+ ac_cv_path_GREP="$ac_path_GREP" ac_path_GREP_found=:;;
+*)
+ ac_count=0
+ $as_echo_n 0123456789 >"conftest.in"
+ while :
+ do
+ cat "conftest.in" "conftest.in" >"conftest.tmp"
+ mv "conftest.tmp" "conftest.in"
+ cp "conftest.in" "conftest.nl"
+ $as_echo 'GREP' >> "conftest.nl"
+ "$ac_path_GREP" -e 'GREP$' -e '-(cannot match)-' < "conftest.nl" >"conftest.out" 2>/dev/null || break
+ diff "conftest.out" "conftest.nl" >/dev/null 2>&1 || break
+ as_fn_arith $ac_count + 1 && ac_count=$as_val
+ if test $ac_count -gt ${ac_path_GREP_max-0}; then
+ # Best one so far, save it but keep looking for a better one
+ ac_cv_path_GREP="$ac_path_GREP"
+ ac_path_GREP_max=$ac_count
+ fi
+ # 10*(2^10) chars as input seems more than enough
+ test $ac_count -gt 10 && break
+ done
+ rm -f conftest.in conftest.tmp conftest.nl conftest.out;;
+esac
+
+ $ac_path_GREP_found && break 3
+ done
+ done
+ done
+IFS=$as_save_IFS
+ if test -z "$ac_cv_path_GREP"; then
+ as_fn_error $? "no acceptable grep could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" "$LINENO" 5
+ fi
+else
+ ac_cv_path_GREP=$GREP
+fi
+
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_path_GREP" >&5
+$as_echo "$ac_cv_path_GREP" >&6; }
+ GREP="$ac_cv_path_GREP"
+
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for egrep" >&5
+$as_echo_n "checking for egrep... " >&6; }
+if ${ac_cv_path_EGREP+:} false; then :
+ $as_echo_n "(cached) " >&6
+else
+ if echo a | $GREP -E '(a|b)' >/dev/null 2>&1
+ then ac_cv_path_EGREP="$GREP -E"
+ else
+ if test -z "$EGREP"; then
+ ac_path_EGREP_found=false
+ # Loop through the user's path and test for each of PROGNAME-LIST
+ as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH$PATH_SEPARATOR/usr/xpg4/bin
+do
+ IFS=$as_save_IFS
+ test -z "$as_dir" && as_dir=.
+ for ac_prog in egrep; do
+ for ac_exec_ext in '' $ac_executable_extensions; do
+ ac_path_EGREP="$as_dir/$ac_prog$ac_exec_ext"
+ as_fn_executable_p "$ac_path_EGREP" || continue
+# Check for GNU ac_path_EGREP and select it if it is found.
+ # Check for GNU $ac_path_EGREP
+case `"$ac_path_EGREP" --version 2>&1` in
+*GNU*)
+ ac_cv_path_EGREP="$ac_path_EGREP" ac_path_EGREP_found=:;;
+*)
+ ac_count=0
+ $as_echo_n 0123456789 >"conftest.in"
+ while :
+ do
+ cat "conftest.in" "conftest.in" >"conftest.tmp"
+ mv "conftest.tmp" "conftest.in"
+ cp "conftest.in" "conftest.nl"
+ $as_echo 'EGREP' >> "conftest.nl"
+ "$ac_path_EGREP" 'EGREP$' < "conftest.nl" >"conftest.out" 2>/dev/null || break
+ diff "conftest.out" "conftest.nl" >/dev/null 2>&1 || break
+ as_fn_arith $ac_count + 1 && ac_count=$as_val
+ if test $ac_count -gt ${ac_path_EGREP_max-0}; then
+ # Best one so far, save it but keep looking for a better one
+ ac_cv_path_EGREP="$ac_path_EGREP"
+ ac_path_EGREP_max=$ac_count
+ fi
+ # 10*(2^10) chars as input seems more than enough
+ test $ac_count -gt 10 && break
+ done
+ rm -f conftest.in conftest.tmp conftest.nl conftest.out;;
+esac
+
+ $ac_path_EGREP_found && break 3
+ done
+ done
+ done
+IFS=$as_save_IFS
+ if test -z "$ac_cv_path_EGREP"; then
+ as_fn_error $? "no acceptable egrep could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" "$LINENO" 5
+ fi
+else
+ ac_cv_path_EGREP=$EGREP
+fi
+
+ fi
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_path_EGREP" >&5
+$as_echo "$ac_cv_path_EGREP" >&6; }
+ EGREP="$ac_cv_path_EGREP"
+
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for ANSI C header files" >&5
+$as_echo_n "checking for ANSI C header files... " >&6; }
+if ${ac_cv_header_stdc+:} false; then :
+ $as_echo_n "(cached) " >&6
+else
+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h. */
+#include <stdlib.h>
+#include <stdarg.h>
+#include <string.h>
+#include <float.h>
+
+int
+main ()
+{
+
+ ;
+ return 0;
+}
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"; then :
+ ac_cv_header_stdc=yes
+else
+ ac_cv_header_stdc=no
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+
+if test $ac_cv_header_stdc = yes; then
+ # SunOS 4.x string.h does not declare mem*, contrary to ANSI.
+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h. */
+#include <string.h>
+
+_ACEOF
+if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |
+ $EGREP "memchr" >/dev/null 2>&1; then :
+
+else
+ ac_cv_header_stdc=no
+fi
+rm -f conftest*
+
+fi
+
+if test $ac_cv_header_stdc = yes; then
+ # ISC 2.0.2 stdlib.h does not declare free, contrary to ANSI.
+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h. */
+#include <stdlib.h>
+
+_ACEOF
+if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |
+ $EGREP "free" >/dev/null 2>&1; then :
+
+else
+ ac_cv_header_stdc=no
+fi
+rm -f conftest*
+
+fi
+
+if test $ac_cv_header_stdc = yes; then
+ # /bin/cc in Irix-4.0.5 gets non-ANSI ctype macros unless using -ansi.
+ if test "$cross_compiling" = yes; then :
+ :
+else
+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h. */
+#include <ctype.h>
+#include <stdlib.h>
+#if ((' ' & 0x0FF) == 0x020)
+# define ISLOWER(c) ('a' <= (c) && (c) <= 'z')
+# define TOUPPER(c) (ISLOWER(c) ? 'A' + ((c) - 'a') : (c))
+#else
+# define ISLOWER(c) \
+ (('a' <= (c) && (c) <= 'i') \
+ || ('j' <= (c) && (c) <= 'r') \
+ || ('s' <= (c) && (c) <= 'z'))
+# define TOUPPER(c) (ISLOWER(c) ? ((c) | 0x40) : (c))
+#endif
+
+#define XOR(e, f) (((e) && !(f)) || (!(e) && (f)))
+int
+main ()
+{
+ int i;
+ for (i = 0; i < 256; i++)
+ if (XOR (islower (i), ISLOWER (i))
+ || toupper (i) != TOUPPER (i))
+ return 2;
+ return 0;
+}
+_ACEOF
+if ac_fn_c_try_run "$LINENO"; then :
+
+else
+ ac_cv_header_stdc=no
+fi
+rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \
+ conftest.$ac_objext conftest.beam conftest.$ac_ext
+fi
+
+fi
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_header_stdc" >&5
+$as_echo "$ac_cv_header_stdc" >&6; }
+if test $ac_cv_header_stdc = yes; then
+
+$as_echo "#define STDC_HEADERS 1" >>confdefs.h
+
+fi
+
+# On IRIX 5.3, sys/types and inttypes.h are conflicting.
+for ac_header in sys/types.h sys/stat.h stdlib.h string.h memory.h strings.h \
+ inttypes.h stdint.h unistd.h
+do :
+ as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh`
+ac_fn_c_check_header_compile "$LINENO" "$ac_header" "$as_ac_Header" "$ac_includes_default
+"
+if eval test \"x\$"$as_ac_Header"\" = x"yes"; then :
+ cat >>confdefs.h <<_ACEOF
+#define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1
+_ACEOF
+
+fi
+
+done
+
+
+as_ac_Header=`$as_echo "ac_cv_header_$vulkan_header" | $as_tr_sh`
+ac_fn_c_check_header_mongrel "$LINENO" "$vulkan_header" "$as_ac_Header" "$ac_includes_default"
+if eval test \"x\$"$as_ac_Header"\" = x"yes"; then :
+ have_vulkan_hdr=yes
+else
+ have_vulkan_hdr=no
+fi
+
+
+CPPFLAGS="$save_CPPFLAGS"
+if test x$have_vulkan_hdr = xyes; then
+ # vulkan.h has been found in either $VULKAN_SDK/include or along the
+ # the standard include path. Unfortunately there seems no easy
+ # way to find out which, so...
+ if test -n "$VULKAN_SDK" -a -f "$vsdk_include_dir/$vulkan_header"; then
+ CFLAGS="$CFLAGS -I$vsdk_include_dir"
+ fi
+fi
+
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for TTF_Init in -lSDL2_ttf" >&5
$as_echo_n "checking for TTF_Init in -lSDL2_ttf... " >&6; }
if ${ac_cv_lib_SDL2_ttf_TTF_Init+:} false; then :
diff --git a/test/configure.in b/test/configure.in
index fd3f302..6c5574b 100644
--- a/test/configure.in
+++ b/test/configure.in
@@ -179,6 +179,25 @@ AC_SUBST(GLESLIB)
AC_SUBST(GLES2LIB)
AC_SUBST(XLIB)
+dnl Check for Vulkan Header
+have_vulkan_hdr=no
+vsdk_include_dir="${VULKAN_SDK}/include"
+vulkan_header="vulkan/vulkan.h"
+save_CPPFLAGS="$CPPFLAGS"
+CPPFLAGS="${save_CPPFLAGS} -I$vsdk_include_dir"
+AC_CHECK_HEADER($vulkan_header,
+ have_vulkan_hdr=yes,
+ have_vulkan_hdr=no)
+CPPFLAGS="$save_CPPFLAGS"
+if test x$have_vulkan_hdr = xyes; then
+ # vulkan.h has been found in either $VULKAN_SDK/include or along the
+ # the standard include path. Unfortunately there seems no easy
+ # way to find out which, so...
+ if test -n "$VULKAN_SDK" -a -f "$vsdk_include_dir/$vulkan_header"; then
+ CFLAGS="$CFLAGS -I$vsdk_include_dir"
+ fi
+fi
+
dnl Check for SDL_ttf
AC_CHECK_LIB(SDL2_ttf, TTF_Init, have_SDL_ttf=yes)
if test x$have_SDL_ttf = xyes; then
diff --git a/test/testvulkan.c b/test/testvulkan.c
new file mode 100644
index 0000000..7eeec7b
--- /dev/null
+++ b/test/testvulkan.c
@@ -0,0 +1,1195 @@
+/*
+ Copyright (C) 1997-2016 Sam Lantinga <slouken@libsdl.org>
+
+ This software is provided 'as-is', without any express or implied
+ warranty. In no event will the authors be held liable for any damages
+ arising from the use of this software.
+
+ Permission is granted to anyone to use this software for any purpose,
+ including commercial applications, and to alter it and redistribute it
+ freely.
+*/
+#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
+#include <math.h>
+
+#ifndef UINT64_MAX /* VS2008 */
+#define UINT64_MAX 18446744073709551615
+#endif
+
+#include "SDL_test_common.h"
+
+#if defined(__ANDROID__) && defined(__ARM_EABI__) && !defined(__ARM_ARCH_7A__)
+
+int main(int argc, char *argv[])
+{
+ SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "No Vulkan support on this system\n");
+ return 1;
+}
+
+#else
+
+#define VK_NO_PROTOTYPES
+#include "vulkan/vulkan.h"
+
+#define VULKAN_FUNCTIONS() \
+ VULKAN_DEVICE_FUNCTION(vkAcquireNextImageKHR) \
+ VULKAN_DEVICE_FUNCTION(vkAllocateCommandBuffers) \
+ VULKAN_DEVICE_FUNCTION(vkBeginCommandBuffer) \
+ VULKAN_DEVICE_FUNCTION(vkCmdClearColorImage) \
+ VULKAN_DEVICE_FUNCTION(vkCmdPipelineBarrier) \
+ VULKAN_DEVICE_FUNCTION(vkCreateCommandPool) \
+ VULKAN_DEVICE_FUNCTION(vkCreateFence) \
+ VULKAN_DEVICE_FUNCTION(vkCreateImageView) \
+ VULKAN_DEVICE_FUNCTION(vkCreateSemaphore) \
+ VULKAN_DEVICE_FUNCTION(vkCreateSwapchainKHR) \
+ VULKAN_DEVICE_FUNCTION(vkDestroyCommandPool) \
+ VULKAN_DEVICE_FUNCTION(vkDestroyDevice) \
+ VULKAN_DEVICE_FUNCTION(vkDestroyFence) \
+ VULKAN_DEVICE_FUNCTION(vkDestroyImageView) \
+ VULKAN_DEVICE_FUNCTION(vkDestroySemaphore) \
+ VULKAN_DEVICE_FUNCTION(vkDestroySwapchainKHR) \
+ VULKAN_DEVICE_FUNCTION(vkDeviceWaitIdle) \
+ VULKAN_DEVICE_FUNCTION(vkEndCommandBuffer) \
+ VULKAN_DEVICE_FUNCTION(vkFreeCommandBuffers) \
+ VULKAN_DEVICE_FUNCTION(vkGetDeviceQueue) \
+ VULKAN_DEVICE_FUNCTION(vkGetFenceStatus) \
+ VULKAN_DEVICE_FUNCTION(vkGetSwapchainImagesKHR) \
+ VULKAN_DEVICE_FUNCTION(vkQueuePresentKHR) \
+ VULKAN_DEVICE_FUNCTION(vkQueueSubmit) \
+ VULKAN_DEVICE_FUNCTION(vkResetCommandBuffer) \
+ VULKAN_DEVICE_FUNCTION(vkResetFences) \
+ VULKAN_DEVICE_FUNCTION(vkWaitForFences) \
+ VULKAN_GLOBAL_FUNCTION(vkCreateInstance) \
+ VULKAN_GLOBAL_FUNCTION(vkEnumerateInstanceExtensionProperties) \
+ VULKAN_GLOBAL_FUNCTION(vkEnumerateInstanceLayerProperties) \
+ VULKAN_INSTANCE_FUNCTION(vkCreateDevice) \
+ VULKAN_INSTANCE_FUNCTION(vkDestroyInstance) \
+ VULKAN_INSTANCE_FUNCTION(vkDestroySurfaceKHR) \
+ VULKAN_INSTANCE_FUNCTION(vkEnumerateDeviceExtensionProperties) \
+ VULKAN_INSTANCE_FUNCTION(vkEnumeratePhysicalDevices) \
+ VULKAN_INSTANCE_FUNCTION(vkGetDeviceProcAddr) \
+ VULKAN_INSTANCE_FUNCTION(vkGetPhysicalDeviceFeatures) \
+ VULKAN_INSTANCE_FUNCTION(vkGetPhysicalDeviceProperties) \
+ VULKAN_INSTANCE_FUNCTION(vkGetPhysicalDeviceQueueFamilyProperties) \
+ VULKAN_INSTANCE_FUNCTION(vkGetPhysicalDeviceSurfaceCapabilitiesKHR) \
+ VULKAN_INSTANCE_FUNCTION(vkGetPhysicalDeviceSurfaceFormatsKHR) \
+ VULKAN_INSTANCE_FUNCTION(vkGetPhysicalDeviceSurfacePresentModesKHR) \
+ VULKAN_INSTANCE_FUNCTION(vkGetPhysicalDeviceSurfaceSupportKHR)
+
+#define VULKAN_DEVICE_FUNCTION(name) static PFN_##name name = NULL;
+#define VULKAN_GLOBAL_FUNCTION(name) static PFN_##name name = NULL;
+#define VULKAN_INSTANCE_FUNCTION(name) static PFN_##name name = NULL;
+VULKAN_FUNCTIONS()
+#undef VULKAN_DEVICE_FUNCTION
+#undef VULKAN_GLOBAL_FUNCTION
+#undef VULKAN_INSTANCE_FUNCTION
+static PFN_vkGetInstanceProcAddr vkGetInstanceProcAddr = NULL;
+
+/* Based on the headers found in
+ * https://github.com/KhronosGroup/Vulkan-LoaderAndValidationLayers
+ */
+#if VK_HEADER_VERSION < 22
+enum
+{
+ VK_ERROR_FRAGMENTED_POOL = -12,
+};
+#endif
+#if VK_HEADER_VERSION < 38
+enum {
+ VK_ERROR_OUT_OF_POOL_MEMORY_KHR = -1000069000
+};
+#endif
+
+static const char *getVulkanResultString(VkResult result)
+{
+ switch((int)result)
+ {
+ case VK_SUCCESS:
+ return "VK_SUCCESS";
+ case VK_NOT_READY:
+ return "VK_NOT_READY";
+ case VK_TIMEOUT:
+ return "VK_TIMEOUT";
+ case VK_EVENT_SET:
+ return "VK_EVENT_SET";
+ case VK_EVENT_RESET:
+ return "VK_EVENT_RESET";
+ case VK_INCOMPLETE:
+ return "VK_INCOMPLETE";
+ case VK_ERROR_OUT_OF_HOST_MEMORY:
+ return "VK_ERROR_OUT_OF_HOST_MEMORY";
+ case VK_ERROR_OUT_OF_DEVICE_MEMORY:
+ return "VK_ERROR_OUT_OF_DEVICE_MEMORY";
+ case VK_ERROR_INITIALIZATION_FAILED:
+ return "VK_ERROR_INITIALIZATION_FAILED";
+ case VK_ERROR_DEVICE_LOST:
+ return "VK_ERROR_DEVICE_LOST";
+ case VK_ERROR_MEMORY_MAP_FAILED:
+ return "VK_ERROR_MEMORY_MAP_FAILED";
+ case VK_ERROR_LAYER_NOT_PRESENT:
+ return "VK_ERROR_LAYER_NOT_PRESENT";
+ case VK_ERROR_EXTENSION_NOT_PRESENT:
+ return "VK_ERROR_EXTENSION_NOT_PRESENT";
+ case VK_ERROR_FEATURE_NOT_PRESENT:
+ return "VK_ERROR_FEATURE_NOT_PRESENT";
+ case VK_ERROR_INCOMPATIBLE_DRIVER:
+ return "VK_ERROR_INCOMPATIBLE_DRIVER";
+ case VK_ERROR_TOO_MANY_OBJECTS:
+ return "VK_ERROR_TOO_MANY_OBJECTS";
+ case VK_ERROR_FORMAT_NOT_SUPPORTED:
+ return "VK_ERROR_FORMAT_NOT_SUPPORTED";
+ case VK_ERROR_FRAGMENTED_POOL:
+ return "VK_ERROR_FRAGMENTED_POOL";
+ case VK_ERROR_SURFACE_LOST_KHR:
+ return "VK_ERROR_SURFACE_LOST_KHR";
+ case VK_ERROR_NATIVE_WINDOW_IN_USE_KHR:
+ return "VK_ERROR_NATIVE_WINDOW_IN_USE_KHR";
+ case VK_SUBOPTIMAL_KHR:
+ return "VK_SUBOPTIMAL_KHR";
+ case VK_ERROR_OUT_OF_DATE_KHR:
+ return "VK_ERROR_OUT_OF_DATE_KHR";
+ case VK_ERROR_INCOMPATIBLE_DISPLAY_KHR:
+ return "VK_ERROR_INCOMPATIBLE_DISPLAY_KHR";
+ case VK_ERROR_VALIDATION_FAILED_EXT:
+ return "VK_ERROR_VALIDATION_FAILED_EXT";
+ case VK_ERROR_OUT_OF_POOL_MEMORY_KHR:
+ return "VK_ERROR_OUT_OF_POOL_MEMORY_KHR";
+ case VK_ERROR_INVALID_SHADER_NV:
+ return "VK_ERROR_INVALID_SHADER_NV";
+ case VK_RESULT_MAX_ENUM:
+ case VK_RESULT_RANGE_SIZE:
+ break;
+ }
+ if(result < 0)
+ return "VK_ERROR_<Unknown>";
+ return "VK_<Unknown>";
+}
+
+typedef struct VulkanContext
+{
+ VkInstance instance;
+ VkDevice device;
+ VkSurfaceKHR surface;
+ VkSwapchainKHR swapchain;
+ VkPhysicalDeviceProperties physicalDeviceProperties;
+ VkPhysicalDeviceFeatures physicalDeviceFeatures;
+ uint32_t graphicsQueueFamilyIndex;
+ uint32_t presentQueueFamilyIndex;
+ VkPhysicalDevice physicalDevice;
+ VkQueue graphicsQueue;
+ VkQueue presentQueue;
+ VkSemaphore imageAvailableSemaphore;
+ VkSemaphore renderingFinishedSemaphore;
+ VkSurfaceCapabilitiesKHR surfaceCapabilities;
+ VkSurfaceFormatKHR *surfaceFormats;
+ uint32_t surfaceFormatsAllocatedCount;
+ uint32_t surfaceFormatsCount;
+ uint32_t swapchainDesiredImageCount;
+ VkSurfaceFormatKHR surfaceFormat;
+ VkExtent2D swapchainSize;
+ VkCommandPool commandPool;
+ uint32_t swapchainImageCount;
+ VkImage *swapchainImages;
+ VkCommandBuffer *commandBuffers;
+ VkFence *fences;
+} VulkanContext;
+
+static SDLTest_CommonState *state;
+static VulkanContext vulkanContext = {0};
+
+static void shutdownVulkan(void);
+
+/* Call this instead of exit(), so we can clean up SDL: atexit() is evil. */
+static void quit(int rc)
+{
+ shutdownVulkan();
+ SDLTest_CommonQuit(state);
+ exit(rc);
+}
+
+static void loadGlobalFunctions(void)
+{
+ vkGetInstanceProcAddr = SDL_Vulkan_GetVkGetInstanceProcAddr();
+ if(!vkGetInstanceProcAddr)
+ {
+ SDL_LogError(SDL_LOG_CATEGORY_APPLICATION,
+ "SDL_Vulkan_GetVkGetInstanceProcAddr(): %s\n",
+ SDL_GetError());
+ quit(2);
+ }
+
+#define VULKAN_DEVICE_FUNCTION(name)
+#define VULKAN_GLOBAL_FUNCTION(name) \
+ name = (PFN_##name)vkGetInstanceProcAddr(VK_NULL_HANDLE, #name); \
+ if(!name) \
+ { \
+ SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, \
+ "vkGetInstanceProcAddr(VK_NULL_HANDLE, \"" #name "\") failed\n"); \
+ quit(2); \
+ }
+#define VULKAN_INSTANCE_FUNCTION(name)
+ VULKAN_FUNCTIONS()
+#undef VULKAN_DEVICE_FUNCTION
+#undef VULKAN_GLOBAL_FUNCTION
+#undef VULKAN_INSTANCE_FUNCTION
+}
+
+static void createInstance(void)
+{
+ VkApplicationInfo appInfo = {0};
+ VkInstanceCreateInfo instanceCreateInfo = {0};
+ const char **extensions = NULL;
+ unsigned extensionCount = 0;
+ VkResult result;
+
+
+ appInfo.sType = VK_STRUCTURE_TYPE_APPLICATION_INFO;
+ appInfo.apiVersion = VK_API_VERSION_1_0;
+ instanceCreateInfo.sType = VK_STRUCTURE_TYPE_INSTANCE_CREATE_INFO;
+ instanceCreateInfo.pApplicationInfo = &appInfo;
+ if(!SDL_Vulkan_GetInstanceExtensions(state->windows[0], &extensionCount, NULL))
+ {
+ SDL_LogError(SDL_LOG_CATEGORY_APPLICATION,
+ "SDL_Vulkan_GetInstanceExtensions(): %s\n",
+ SDL_GetError());
+ quit(2);
+ }
+ extensions = SDL_malloc(sizeof(const char *) * extensionCount);
+ if(!extensions)
+ {
+ SDL_OutOfMemory();
+ quit(2);
+ }
+ if(!SDL_Vulkan_GetInstanceExtensions(state->windows[0], &extensionCount, extensions))
+ {
+ SDL_free((void*)extensions);
+ SDL_LogError(SDL_LOG_CATEGORY_APPLICATION,
+ "SDL_Vulkan_GetInstanceExtensions(): %s\n",
+ SDL_GetError());
+ quit(2);
+ }
+ instanceCreateInfo.enabledExtensionCount = extensionCount;
+ instanceCreateInfo.ppEnabledExtensionNames = extensions;
+ result = vkCreateInstance(&instanceCreateInfo, NULL, &vulkanContext.instance);
+ SDL_free((void*)extensions);
+ if(result != VK_SUCCESS)
+ {
+ vulkanContext.instance = VK_NULL_HANDLE;
+ SDL_LogError(SDL_LOG_CATEGORY_APPLICATION,
+ "vkCreateInstance(): %s\n",
+ getVulkanResultString(result));
+ quit(2);
+ }
+}
+
+static void loadInstanceFunctions(void)
+{
+#define VULKAN_DEVICE_FUNCTION(name)
+#define VULKAN_GLOBAL_FUNCTION(name)
+#define VULKAN_INSTANCE_FUNCTION(name) \
+ name = (PFN_##name)vkGetInstanceProcAddr(vulkanContext.instance, #name); \
+ if(!name) \
+ { \
+ SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, \
+ "vkGetInstanceProcAddr(instance, \"" #name "\") failed\n"); \
+ quit(2); \
+ }
+ VULKAN_FUNCTIONS()
+#undef VULKAN_DEVICE_FUNCTION
+#undef VULKAN_GLOBAL_FUNCTION
+#undef VULKAN_INSTANCE_FUNCTION
+}
+
+static void createSurface(void)
+{
+ if(!SDL_Vulkan_CreateSurface(state->windows[0],
+ vulkanContext.instance,
+ &vulkanContext.surface))
+ {
+ vulkanContext.surface = VK_NULL_HANDLE;
+ SDL_LogError(
+ SDL_LOG_CATEGORY_APPLICATION, "SDL_Vulkan_CreateSurface(): %s\n", SDL_GetError());
+ quit(2);
+ }
+}
+
+static void findPhysicalDevice(void)
+{
+ uint32_t physicalDeviceCount = 0;
+ VkPhysicalDevice *physicalDevices;
+ VkQueueFamilyProperties *queueFamiliesProperties = NULL;
+ uint32_t queueFamiliesPropertiesAllocatedSize = 0;
+ VkExtensionProperties *deviceExtensions = NULL;
+ uint32_t deviceExtensionsAllocatedSize = 0;
+ uint32_t physicalDeviceIndex;
+
+ VkResult result =
+ vkEnumeratePhysicalDevices(vulkanContext.instance, &physicalDeviceCount, NULL);
+ if(result != VK_SUCCESS)
+ {
+ SDL_LogError(SDL_LOG_CATEGORY_APPLICATION,
+ "vkEnumeratePhysicalDevices(): %s\n",
+ getVulkanResultString(result));
+ quit(2);
+ }
+ if(physicalDeviceCount == 0)
+ {
+ SDL_LogError(SDL_LOG_CATEGORY_APPLICATION,
+ "vkEnumeratePhysicalDevices(): no physical devices\n");
+ quit(2);
+ }
+ physicalDevices = SDL_malloc(sizeof(VkPhysicalDevice) * physicalDeviceCount);
+ if(!physicalDevices)
+ {
+ SDL_OutOfMemory();
+ quit(2);
+ }
+ result =
+ vkEnumeratePhysicalDevices(vulkanContext.instance, &physicalDeviceCount, physicalDevices);
+ if(result != VK_SUCCESS)
+ {
+ SDL_free(physicalDevices);
+ SDL_LogError(SDL_LOG_CATEGORY_APPLICATION,
+ "vkEnumeratePhysicalDevices(): %s\n",
+ getVulkanResultString(result));
+ quit(2);
+ }
+ vulkanContext.physicalDevice = NULL;
+ for(physicalDeviceIndex = 0; physicalDeviceIndex < physicalDeviceCount;
+ physicalDeviceIndex++)
+ {
+ uint32_t queueFamiliesCount = 0;
+ uint32_t queueFamilyIndex;
+ uint32_t deviceExtensionCount = 0;
+ SDL_bool hasSwapchainExtension = SDL_FALSE;
+ uint32_t i;
+
+
+ VkPhysicalDevice physicalDevice = physicalDevices[physicalDeviceIndex];
+ vkGetPhysicalDeviceProperties(physicalDevice, &vulkanContext.physicalDeviceProperties);
+ if(VK_VERSION_MAJOR(vulkanContext.physicalDeviceProperties.apiVersion) < 1)
+ continue;
+ vkGetPhysicalDeviceFeatures(physicalDevice, &vulkanContext.physicalDeviceFeatures);
+ vkGetPhysicalDeviceQueueFamilyProperties(physicalDevice, &queueFamiliesCount, NULL);
+ if(queueFamiliesCount == 0)
+ continue;
+ if(queueFamiliesPropertiesAllocatedSize < queueFamiliesCount)
+ {
+ SDL_free(queueFamiliesProperties);
+ queueFamiliesPropertiesAllocatedSize = queueFamiliesCount;
+ queueFamiliesProperties =
+ SDL_malloc(sizeof(VkQueueFamilyProperties) * queueFamiliesPropertiesAllocatedSize);
+ if(!queueFamiliesProperties)
+ {
+ SDL_free(physicalDevices);
+ SDL_free(deviceExtensions);
+ SDL_OutOfMemory();
+ quit(2);
+ }
+ }
+ vkGetPhysicalDeviceQueueFamilyProperties(
+ physicalDevice, &queueFamiliesCount, queueFamiliesProperties);
+ vulkanContext.graphicsQueueFamilyIndex = queueFamiliesCount;
+ vulkanContext.presentQueueFamilyIndex = queueFamiliesCount;
+ for(queueFamilyIndex = 0; queueFamilyIndex < queueFamiliesCount;
+ queueFamilyIndex++)
+ {
+ VkBool32 supported = 0;
+
+ if(queueFamiliesProperties[queueFamilyIndex].queueCount == 0)
+ continue;
+ if(queueFamiliesProperties[queueFamilyIndex].queueFlags & VK_QUEUE_GRAPHICS_BIT)
+ vulkanContext.graphicsQueueFamilyIndex = queueFamilyIndex;
+ result = vkGetPhysicalDeviceSurfaceSupportKHR(
+ physicalDevice, queueFamilyIndex, vulkanContext.surface, &supported);
+ if(result != VK_SUCCESS)
+ {
+ SDL_free(physicalDevices);
+ SDL_free(queueFamiliesProperties);
+ SDL_free(deviceExtensions);
+ SDL_LogError(SDL_LOG_CATEGORY_APPLICATION,
+ "vkGetPhysicalDeviceSurfaceSupportKHR(): %s\n",
+ getVulkanResultString(result));
+ quit(2);
+ }
+ if(supported)
+ {
+ vulkanContext.presentQueueFamilyIndex = queueFamilyIndex;
+ if(queueFamiliesProperties[queueFamilyIndex].queueFlags & VK_QUEUE_GRAPHICS_BIT)
+ break; // use this queue because it can present and do graphics
+ }
+ }
+ if(vulkanContext.graphicsQueueFamilyIndex == queueFamiliesCount) // no good queues found
+ continue;
+ if(vulkanContext.presentQueueFamilyIndex == queueFamiliesCount) // no good queues found
+ continue;
+ result =
+ vkEnumerateDeviceExtensionProperties(physicalDevice, NULL, &deviceExtensionCount, NULL);
+ if(result != VK_SUCCESS)
+ {
+ SDL_free(physicalDevices);
+ SDL_free(queueFamiliesProperties);
+ SDL_free(deviceExtensions);
+ SDL_LogError(SDL_LOG_CATEGORY_APPLICATION,
+ "vkEnumerateDeviceExtensionProperties(): %s\n",
+ getVulkanResultString(result));
+ quit(2);
+ }
+ if(deviceExtensionCount == 0)
+ continue;
+ if(deviceExtensionsAllocatedSize < deviceExtensionCount)
+ {
+ SDL_free(deviceExtensions);
+ deviceExtensionsAllocatedSize = deviceExtensionCount;
+ deviceExtensions =
+ SDL_malloc(sizeof(VkExtensionProperties) * deviceExtensionsAllocatedSize);
+ if(!deviceExtensions)
+ {
+ SDL_free(physicalDevices);
+ SDL_free(queueFamiliesProperties);
+ SDL_OutOfMemory();
+ quit(2);
+ }
+ }
+ result = vkEnumerateDeviceExtensionProperties(
+ physicalDevice, NULL, &deviceExtensionCount, deviceExtensions);
+ if(result != VK_SUCCESS)
+ {
+ SDL_free(physicalDevices);
+ SDL_free(queueFamiliesProperties);
+ SDL_free(deviceExtensions);
+ SDL_LogError(SDL_LOG_CATEGORY_APPLICATION,
+ "vkEnumerateDeviceExtensionProperties(): %s\n",
+ getVulkanResultString(result));
+ quit(2);
+ }
+ for(i = 0; i < deviceExtensionCount; i++)
+ {
+ if(0 == SDL_strcmp(deviceExtensions[i].extensionName, VK_KHR_SWAPCHAIN_EXTENSION_NAME))
+ {
+ hasSwapchainExtension = SDL_TRUE;
+ break;
+ }
+ }
+ if(!hasSwapchainExtension)
+ continue;
+ vulkanContext.physicalDevice = physicalDevice;
+ break;
+ }
+ SDL_free(physicalDevices);
+ SDL_free(queueFamiliesProperties);
+ SDL_free(deviceExtensions);
+ if(!vulkanContext.physicalDevice)
+ {
+ SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Vulkan: no viable physical devices found");
+ quit(2);
+ }
+}
+
+static void createDevice(void)
+{
+ VkDeviceQueueCreateInfo deviceQueueCreateInfo[1] = {0};
+ static const float queuePriority[] = {1.0f};
+ VkDeviceCreateInfo deviceCreateInfo = {0};
+ static const char *const deviceExtensionNames[] = {
+ VK_KHR_SWAPCHAIN_EXTENSION_NAME,
+ };
+ VkResult result;
+
+ deviceQueueCreateInfo->sType = VK_STRUCTURE_TYPE_DEVICE_QUEUE_CREATE_INFO;
+ deviceQueueCreateInfo->queueFamilyIndex = vulkanContext.graphicsQueueFamilyIndex;
+ deviceQueueCreateInfo->queueCount = 1;
+ deviceQueueCreateInfo->pQueuePriorities = &queuePriority[0];
+
+ deviceCreateInfo.sType = VK_STRUCTURE_TYPE_DEVICE_CREATE_INFO;
+ deviceCreateInfo.queueCreateInfoCount = 1;
+ deviceCreateInfo.pQueueCreateInfos = deviceQueueCreateInfo;
+ deviceCreateInfo.pEnabledFeatures = NULL;
+ deviceCreateInfo.enabledExtensionCount = SDL_arraysize(deviceExtensionNames);
+ deviceCreateInfo.ppEnabledExtensionNames = deviceExtensionNames;
+ result = vkCreateDevice(
+ vulkanContext.physicalDevice, &deviceCreateInfo, NULL, &vulkanContext.device);
+ if(result != VK_SUCCESS)
+ {
+ vulkanContext.device = VK_NULL_HANDLE;
+ SDL_LogError(
+ SDL_LOG_CATEGORY_APPLICATION, "vkCreateDevice(): %s\n", getVulkanResultString(result));
+ quit(2);
+ }
+}
+
+static void loadDeviceFunctions(void)
+{
+#define VULKAN_DEVICE_FUNCTION(name) \
+ name = (PFN_##name)vkGetDeviceProcAddr(vulkanContext.device, #name); \
+ if(!name) \
+ { \
+ SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, \
+ "vkGetDeviceProcAddr(device, \"" #name "\") failed\n"); \
+ quit(2); \
+ }
+#define VULKAN_GLOBAL_FUNCTION(name)
+#define VULKAN_INSTANCE_FUNCTION(name)
+ VULKAN_FUNCTIONS()
+#undef VULKAN_DEVICE_FUNCTION
+#undef VULKAN_GLOBAL_FUNCTION
+#undef VULKAN_INSTANCE_FUNCTION
+}
+
+#undef VULKAN_FUNCTIONS
+
+static void getQueues(void)
+{
+ vkGetDeviceQueue(vulkanContext.device,
+ vulkanContext.graphicsQueueFamilyIndex,
+ 0,
+ &vulkanContext.graphicsQueue);
+ if(vulkanContext.graphicsQueueFamilyIndex != vulkanContext.presentQueueFamilyIndex)
+ vkGetDeviceQueue(vulkanContext.device,
+ vulkanContext.presentQueueFamilyIndex,
+ 0,
+ &vulkanContext.presentQueue);
+ else
+ vulkanContext.presentQueue = vulkanContext.graphicsQueue;
+}
+
+static void createSemaphore(VkSemaphore *semaphore)
+{
+ VkResult result;
+
+ VkSemaphoreCreateInfo createInfo = {0};
+ createInfo.sType = VK_STRUCTURE_TYPE_SEMAPHORE_CREATE_INFO;
+ result = vkCreateSemaphore(vulkanContext.device, &createInfo, NULL, semaphore);
+ if(result != VK_SUCCESS)
+ {
+ *semaphore = VK_NULL_HANDLE;
+ SDL_LogError(SDL_LOG_CATEGORY_APPLICATION,
+ "vkCreateSemaphore(): %s\n",
+ getVulkanResultString(result));
+ quit(2);
+ }
+}
+
+static void createSemaphores(void)
+{
+ createSemaphore(&vulkanContext.imageAvailableSemaphore);
+ createSemaphore(&vulkanContext.renderingFinishedSemaphore);
+}
+
+static void getSurfaceCaps(void)
+{
+ VkResult result = vkGetPhysicalDeviceSurfaceCapabilitiesKHR(
+ vulkanContext.physicalDevice, vulkanContext.surface, &vulkanContext.surfaceCapabilities);
+ if(result != VK_SUCCESS)
+ {
+ SDL_LogError(SDL_LOG_CATEGORY_APPLICATION,
+ "vkGetPhysicalDeviceSurfaceCapabilitiesKHR(): %s\n",
+ getVulkanResultString(result));
+ quit(2);
+ }
+
+ // check surface usage
+ if(!(vulkanContext.surfaceCapabilities.supportedUsageFlags & VK_IMAGE_USAGE_TRANSFER_DST_BIT))
+ {
+ SDL_LogError(SDL_LOG_CATEGORY_APPLICATION,
+ "Vulkan surface doesn't support VK_IMAGE_USAGE_TRANSFER_DST_BIT\n");
+ quit(2);
+ }
+}
+
+static void getSurfaceFormats(void)
+{
+ VkResult result = vkGetPhysicalDeviceSurfaceFormatsKHR(vulkanContext.physicalDevice,
+ vulkanContext.surface,
+ &vulkanContext.surfaceFormatsCount,
+ NULL);
+ if(result != VK_SUCCESS)
+ {
+ vulkanContext.surfaceFormatsCount = 0;
+ SDL_LogError(SDL_LOG_CATEGORY_APPLICATION,
+ "vkGetPhysicalDeviceSurfaceFormatsKHR(): %s\n",
+ getVulkanResultString(result));
+ quit(2);
+ }
+ if(vulkanContext.surfaceFormatsCount > vulkanContext.surfaceFormatsAllocatedCount)
+ {
+ vulkanContext.surfaceFormatsAllocatedCount = vulkanContext.surfaceFormatsCount;
+ SDL_free(vulkanContext.surfaceFormats);
+ vulkanContext.surfaceFormats =
+ SDL_malloc(sizeof(VkSurfaceFormatKHR) * vulkanContext.surfaceFormatsAllocatedCount);
+ if(!vulkanContext.surfaceFormats)
+ {
+ vulkanContext.surfaceFormatsCount = 0;
+ SDL_OutOfMemory();
+ quit(2);
+ }
+ }
+ result = vkGetPhysicalDeviceSurfaceFormatsKHR(vulkanContext.physicalDevice,
+ vulkanContext.surface,
+ &vulkanContext.surfaceFormatsCount,
+ vulkanContext.surfaceFormats);
+ if(result != VK_SUCCESS)
+ {
+ vulkanContext.surfaceFormatsCount = 0;
+ SDL_LogError(SDL_LOG_CATEGORY_APPLICATION,
+ "vkGetPhysicalDeviceSurfaceFormatsKHR(): %s\n",
+ getVulkanResultString(result));
+ quit(2);
+ }
+}
+
+static void getSwapchainImages(void)
+{
+ VkResult result;
+
+ SDL_free(vulkanContext.swapchainImages);
+ vulkanContext.swapchainImages = NULL;
+ result = vkGetSwapchainImagesKHR(
+ vulkanContext.device, vulkanContext.swapchain, &vulkanContext.swapchainImageCount, NULL);
+ if(result != VK_SUCCESS)
+ {
+ vulkanContext.swapchainImageCount = 0;
+ SDL_LogError(SDL_LOG_CATEGORY_APPLICATION,
+ "vkGetSwapchainImagesKHR(): %s\n",
+ getVulkanResultString(result));
+ quit(2);
+ }
+ vulkanContext.swapchainImages = SDL_malloc(sizeof(VkImage) * vulkanContext.swapchainImageCount);
+ if(!vulkanContext.swapchainImages)
+ {
+ SDL_OutOfMemory();
+ quit(2);
+ }
+ result = vkGetSwapchainImagesKHR(vulkanContext.device,
+ vulkanContext.swapchain,
+ &vulkanContext.swapchainImageCount,
+ vulkanContext.swapchainImages);
+ if(result != VK_SUCCESS)
+ {
+ SDL_free(vulkanContext.swapchainImages);
+ vulkanContext.swapchainImages = NULL;
+ vulkanContext.swapchainImageCount = 0;
+ SDL_LogError(SDL_LOG_CATEGORY_APPLICATION,
+ "vkGetSwapchainImagesKHR(): %s\n",
+ getVulkanResultString(result));
+ quit(2);
+ }
+}
+
+static SDL_bool createSwapchain(void)
+{
+ uint32_t i;
+ int w, h;
+ VkSwapchainCreateInfoKHR createInfo = {0};
+ VkResult result;
+
+ // pick an image count
+ vulkanContext.swapchainDesiredImageCount = vulkanContext.surfaceCapabilities.minImageCount + 1;
+ if(vulkanContext.swapchainDesiredImageCount > vulkanContext.surfaceCapabilities.maxImageCount
+ && vulkanContext.surfaceCapabilities.maxImageCount > 0)
+ vulkanContext.swapchainDesiredImageCount = vulkanContext.surfaceCapabilities.maxImageCount;
+
+ // pick a format
+ if(vulkanContext.surfaceFormatsCount == 1
+ && vulkanContext.surfaceFormats[0].format == VK_FORMAT_UNDEFINED)
+ {
+ // aren't any preferred formats, so we pick
+ vulkanContext.surfaceFormat.colorSpace = VK_COLORSPACE_SRGB_NONLINEAR_KHR;
+ vulkanContext.surfaceFormat.format = VK_FORMAT_R8G8B8A8_UNORM;
+ }
+ else
+ {
+ vulkanContext.surfaceFormat = vulkanContext.surfaceFormats[0];
+ for(i = 0; i < vulkanContext.surfaceFormatsCount; i++)
+ {
+ if(vulkanContext.surfaceFormats[i].format == VK_FORMAT_R8G8B8A8_UNORM)
+ {
+ vulkanContext.surfaceFormat = vulkanContext.surfaceFormats[i];
+ break;
+ }
+ }
+ }
+
+ // get size
+ SDL_GL_GetDrawableSize(state->windows[0], &w, &h);
+ vulkanContext.swapchainSize.width = w;
+ vulkanContext.swapchainSize.height = h;
+ if(w == 0 || h == 0)
+ return SDL_FALSE;
+
+ createInfo.sType = VK_STRUCTURE_TYPE_SWAPCHAIN_CREATE_INFO_KHR;
+ createInfo.surface = vulkanContext.surface;
+ createInfo.minImageCount = vulkanContext.swapchainDesiredImageCount;
+ createInfo.imageFormat = vulkanContext.surfaceFormat.format;
+ createInfo.imageColorSpace = vulkanContext.surfaceFormat.colorSpace;
+ createInfo.imageExtent = vulkanContext.swapchainSize;
+ createInfo.imageArrayLayers = 1;
+ createInfo.imageUsage = VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT | VK_IMAGE_USAGE_TRANSFER_DST_BIT;
+ createInfo.imageSharingMode = VK_SHARING_MODE_EXCLUSIVE;
+ createInfo.preTransform = vulkanContext.surfaceCapabilities.currentTransform;
+ createInfo.compositeAlpha = VK_COMPOSITE_ALPHA_OPAQUE_BIT_KHR;
+ createInfo.presentMode = VK_PRESENT_MODE_FIFO_KHR;
+ createInfo.clipped = VK_TRUE;
+ createInfo.oldSwapchain = vulkanContext.swapchain;
+ result =
+ vkCreateSwapchainKHR(vulkanContext.device, &createInfo, NULL, &vulkanContext.swapchain);
+ if(createInfo.oldSwapchain)
+ vkDestroySwapchainKHR(vulkanContext.device, createInfo.oldSwapchain, NULL);
+ if(result != VK_SUCCESS)
+ {
+ vulkanContext.swapchain = VK_NULL_HANDLE;
+ SDL_LogError(SDL_LOG_CATEGORY_APPLICATION,
+ "vkCreateSwapchainKHR(): %s\n",
+ getVulkanResultString(result));
+ quit(2);
+ }
+ getSwapchainImages();
+ return SDL_TRUE;
+}
+
+static void destroySwapchain(void)
+{
+ if(vulkanContext.swapchain)
+ vkDestroySwapchainKHR(vulkanContext.device, vulkanContext.swapchain, NULL);
+ vulkanContext.swapchain = VK_NULL_HANDLE;
+ SDL_free(vulkanContext.swapchainImages);
+ vulkanContext.swapchainImages = NULL;
+}
+
+static void destroyCommandBuffers(void)
+{
+ if(vulkanContext.commandBuffers)
+ vkFreeCommandBuffers(vulkanContext.device,
+ vulkanContext.commandPool,
+ vulkanContext.swapchainImageCount,
+ vulkanContext.commandBuffers);
+ SDL_free(vulkanContext.commandBuffers);
+ vulkanContext.commandBuffers = NULL;
+}
+
+static void destroyCommandPool(void)
+{
+ if(vulkanContext.commandPool)
+ vkDestroyCommandPool(vulkanContext.device, vulkanContext.commandPool, NULL);
+ vulkanContext.commandPool = VK_NULL_HANDLE;
+}
+
+static void createCommandPool(void)
+{
+ VkResult result;
+
+ VkCommandPoolCreateInfo createInfo = {0};
+ createInfo.sType = VK_STRUCTURE_TYPE_COMMAND_POOL_CREATE_INFO;
+ createInfo.flags =
+ VK_COMMAND_POOL_CREATE_RESET_COMMAND_BUFFER_BIT | VK_COMMAND_POOL_CREATE_TRANSIENT_BIT;
+ createInfo.queueFamilyIndex = vulkanContext.graphicsQueueFamilyIndex;
+ result =
+ vkCreateCommandPool(vulkanContext.device, &createInfo, NULL, &vulkanContext.commandPool);
+ if(result != VK_SUCCESS)
+ {
+ vulkanContext.commandPool = VK_NULL_HANDLE;
+ SDL_LogError(SDL_LOG_CATEGORY_APPLICATION,
+ "vkCreateCommandPool(): %s\n",
+ getVulkanResultString(result));
+ quit(2);
+ }
+}
+
+static void createCommandBuffers(void)
+{
+ VkResult result;
+
+ VkCommandBufferAllocateInfo allocateInfo = {0};
+ allocateInfo.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_ALLOCATE_INFO;
+ allocateInfo.commandPool = vulkanContext.commandPool;
+ allocateInfo.level = VK_COMMAND_BUFFER_LEVEL_PRIMARY;
+ allocateInfo.commandBufferCount = vulkanContext.swapchainImageCount;
+ vulkanContext.commandBuffers =
+ SDL_malloc(sizeof(VkCommandBuffer) * vulkanContext.swapchainImageCount);
+ result =
+ vkAllocateCommandBuffers(vulkanContext.device, &allocateInfo, vulkanContext.commandBuffers);
+ if(result != VK_SUCCESS)
+ {
+ SDL_free(vulkanContext.commandBuffers);
+ vulkanContext.commandBuffers = NULL;
+ SDL_LogError(SDL_LOG_CATEGORY_APPLICATION,
+ "vkAllocateCommandBuffers(): %s\n",
+ getVulkanResultString(result));
+ quit(2);
+ }
+}
+
+static void createFences(void)
+{
+ uint32_t i;
+
+ vulkanContext.fences = SDL_malloc(sizeof(VkFence) * vulkanContext.swapchainImageCount);
+ if(!vulkanContext.fences)
+ {
+ SDL_OutOfMemory();
+ quit(2);
+ }
+ for(i = 0; i < vulkanContext.swapchainImageCount; i++)
+ {
+ VkResult result;
+
+ VkFenceCreateInfo createInfo = {0};
+ createInfo.sType = VK_STRUCTURE_TYPE_FENCE_CREATE_INFO;
+ createInfo.flags = VK_FENCE_CREATE_SIGNALED_BIT;
+ result =
+ vkCreateFence(vulkanContext.device, &createInfo, NULL, &vulkanContext.fences[i]);
+ if(result != VK_SUCCESS)
+ {
+ for(; i > 0; i--)
+ {
+ vkDestroyFence(vulkanContext.device, vulkanContext.fences[i - 1], NULL);
+ }
+ SDL_free(vulkanContext.fences);
+ vulkanContext.fences = NULL;
+ SDL_LogError(SDL_LOG_CATEGORY_APPLICATION,
+ "vkCreateFence(): %s\n",
+ getVulkanResultString(result));
+ quit(2);
+ }
+ }
+}
+
+static void destroyFences(void)
+{
+ uint32_t i;
+
+ if(!vulkanContext.fences)
+ return;
+ for(i = 0; i < vulkanContext.swapchainImageCount; i++)
+ {
+ vkDestroyFence(vulkanContext.device, vulkanContext.fences[i], NULL);
+ }
+ SDL_free(vulkanContext.fences);
+ vulkanContext.fences = NULL;
+}
+
+static void recordPipelineImageBarrier(VkCommandBuffer commandBuffer,
+ VkAccessFlags sourceAccessMask,
+ VkAccessFlags destAccessMask,
+ VkImageLayout sourceLayout,
+ VkImageLayout destLayout,
+ VkImage image)
+{
+ VkImageMemoryBarrier barrier = {0};
+ barrier.sType = VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER;
+ barrier.srcAccessMask = sourceAccessMask;
+ barrier.dstAccessMask = destAccessMask;
+ barrier.oldLayout = sourceLayout;
+ barrier.newLayout = destLayout;
+ barrier.srcQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED;
+ barrier.dstQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED;
+ barrier.image = image;
+ barrier.subresourceRange.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT;
+ barrier.subresourceRange.baseMipLevel = 0;
+ barrier.subresourceRange.levelCount = 1;
+ barrier.subresourceRange.baseArrayLayer = 0;
+ barrier.subresourceRange.layerCount = 1;
+ vkCmdPipelineBarrier(commandBuffer,
+ VK_PIPELINE_STAGE_TRANSFER_BIT,
+ VK_PIPELINE_STAGE_TRANSFER_BIT,
+ 0,
+ 0,
+ NULL,
+ 0,
+ NULL,
+ 1,
+ &barrier);
+}
+
+static void rerecordCommandBuffer(uint32_t frameIndex, const VkClearColorValue *clearColor)
+{
+ VkCommandBuffer commandBuffer = vulkanContext.commandBuffers[frameIndex];
+ VkImage image = vulkanContext.swapchainImages[frameIndex];
+ VkCommandBufferBeginInfo beginInfo = {0};
+ VkImageSubresourceRange clearRange = {0};
+
+ VkResult result = vkResetCommandBuffer(commandBuffer, 0);
+ if(result != VK_SUCCESS)
+ {
+ SDL_LogError(SDL_LOG_CATEGORY_APPLICATION,
+ "vkResetCommandBuffer(): %s\n",
+ getVulkanResultString(result));
+ quit(2);
+ }
+ beginInfo.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO;
+ beginInfo.flags = VK_COMMAND_BUFFER_USAGE_SIMULTANEOUS_USE_BIT;
+ result = vkBeginCommandBuffer(commandBuffer, &beginInfo);
+ if(result != VK_SUCCESS)
+ {
+ SDL_LogError(SDL_LOG_CATEGORY_APPLICATION,
+ "vkBeginCommandBuffer(): %s\n",
+ getVulkanResultString(result));
+ quit(2);
+ }
+ recordPipelineImageBarrier(commandBuffer,
+ 0,
+ VK_ACCESS_TRANSFER_WRITE_BIT,
+ VK_IMAGE_LAYOUT_UNDEFINED,
+ VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL,
+ image);
+ clearRange.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT;
+ clearRange.baseMipLevel = 0;
+ clearRange.levelCount = 1;
+ clearRange.baseArrayLayer = 0;
+ clearRange.layerCount = 1;
+ vkCmdClearColorImage(
+ commandBuffer, image, VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, clearColor, 1, &clearRange);
+ recordPipelineImageBarrier(commandBuffer,
+ VK_ACCESS_TRANSFER_WRITE_BIT,
+ VK_ACCESS_MEMORY_READ_BIT,
+ VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL,
+ VK_IMAGE_LAYOUT_PRESENT_SRC_KHR,
+ image);
+ result = vkEndCommandBuffer(commandBuffer);
+ if(result != VK_SUCCESS)
+ {
+ SDL_LogError(SDL_LOG_CATEGORY_APPLICATION,
+ "vkEndCommandBuffer(): %s\n",
+ getVulkanResultString(result));
+ quit(2);
+ }
+}
+
+static void destroySwapchainAndSwapchainSpecificStuff(SDL_bool doDestroySwapchain)
+{
+ destroyFences();
+ destroyCommandBuffers();
+ destroyCommandPool();
+ if(doDestroySwapchain)
+ destroySwapchain();
+}
+
+static SDL_bool createNewSwapchainAndSwapchainSpecificStuff(void)
+{
+ destroySwapchainAndSwapchainSpecificStuff(SDL_FALSE);
+ getSurfaceCaps();
+ getSurfaceFormats();
+ if(!createSwapchain())
+ return SDL_FALSE;
+ createCommandPool();
+ createCommandBuffers();
+ createFences();
+ return SDL_TRUE;
+}
+
+static void initVulkan(void)
+{
+ SDL_Vulkan_LoadLibrary(NULL);
+ SDL_memset(&vulkanContext, 0, sizeof(VulkanContext));
+ loadGlobalFunctions();
+ createInstance();
+ loadInstanceFunctions();
+ createSurface();
+ findPhysicalDevice();
+ createDevice();
+ loadDeviceFunctions();
+ getQueues();
+ createSemaphores();
+ createNewSwapchainAndSwapchainSpecificStuff();
+}
+
+static void shutdownVulkan(void)
+{
+ if(vulkanContext.device && vkDeviceWaitIdle)
+ vkDeviceWaitIdle(vulkanContext.device);
+ destroySwapchainAndSwapchainSpecificStuff(SDL_TRUE);
+ if(vulkanContext.imageAvailableSemaphore && vkDestroySemaphore)
+ vkDestroySemaphore(vulkanContext.device, vulkanContext.imageAvailableSemaphore, NULL);
+ if(vulkanContext.renderingFinishedSemaphore && vkDestroySemaphore)
+ vkDestroySemaphore(vulkanContext.device, vulkanContext.renderingFinishedSemaphore, NULL);
+ if(vulkanContext.device && vkDestroyDevice)
+ vkDestroyDevice(vulkanContext.device, NULL);
+ if(vulkanContext.surface && vkDestroySurfaceKHR)
+ vkDestroySurfaceKHR(vulkanContext.instance, vulkanContext.surface, NULL);
+ if(vulkanContext.instance && vkDestroyInstance)
+ vkDestroyInstance(vulkanContext.instance, NULL);
+ SDL_free(vulkanContext.surfaceFormats);
+ SDL_Vulkan_UnloadLibrary();
+}
+
+static SDL_bool render(void)
+{
+ uint32_t frameIndex;
+ VkResult result;
+ double currentTime;
+ VkClearColorValue clearColor = {0};
+ VkPipelineStageFlags waitDestStageMask = VK_PIPELINE_STAGE_TRANSFER_BIT;
+ VkSubmitInfo submitInfo = {0};
+ VkPresentInfoKHR presentInfo = {0};
+ int w, h;
+
+ if(!vulkanContext.swapchain)
+ {
+ SDL_bool retval = createNewSwapchainAndSwapchainSpecificStuff();
+ if(!retval)
+ SDL_Delay(100);
+ return retval;
+ }
+ result = vkAcquireNextImageKHR(vulkanContext.device,
+ vulkanContext.swapchain,
+ UINT64_MAX,
+ vulkanContext.imageAvailableSemaphore,
+ VK_NULL_HANDLE,
+ &frameIndex);
+ if(result == VK_ERROR_OUT_OF_DATE_KHR)
+ return createNewSwapchainAndSwapchainSpecificStuff();
+ if(result != VK_SUBOPTIMAL_KHR && result != VK_SUCCESS)
+ {
+ SDL_LogError(SDL_LOG_CATEGORY_APPLICATION,
+ "vkAcquireNextImageKHR(): %s\n",
+ getVulkanResultString(result));
+ quit(2);
+ }
+ result = vkWaitForFences(
+ vulkanContext.device, 1, &vulkanContext.fences[frameIndex], VK_FALSE, UINT64_MAX);
+ if(result != VK_SUCCESS)
+ {
+ SDL_LogError(
+ SDL_LOG_CATEGORY_APPLICATION, "vkWaitForFences(): %s\n", getVulkanResultString(result));
+ quit(2);
+ }
+ result = vkResetFences(vulkanContext.device, 1, &vulkanContext.fences[frameIndex]);
+ if(result != VK_SUCCESS)
+ {
+ SDL_LogError(
+ SDL_LOG_CATEGORY_APPLICATION, "vkResetFences(): %s\n", getVulkanResultString(result));
+ quit(2);
+ }
+ currentTime = (double)SDL_GetPerformanceCounter() / SDL_GetPerformanceFrequency();
+ clearColor.float32[0] = (float)(0.5 + 0.5 * SDL_sin(currentTime));
+ clearColor.float32[1] = (float)(0.5 + 0.5 * SDL_sin(currentTime + M_PI * 2 / 3));
+ clearColor.float32[2] = (float)(0.5 + 0.5 * SDL_sin(currentTime + M_PI * 4 / 3));
+ clearColor.float32[3] = 1;
+ rerecordCommandBuffer(frameIndex, &clearColor);
+ submitInfo.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO;
+ submitInfo.waitSemaphoreCount = 1;
+ submitInfo.pWaitSemaphores = &vulkanContext.imageAvailableSemaphore;
+ submitInfo.pWaitDstStageMask = &waitDestStageMask;
+ submitInfo.commandBufferCount = 1;
+ submitInfo.pCommandBuffers = &vulkanContext.commandBuffers[frameIndex];
+ submitInfo.signalSemaphoreCount = 1;
+ submitInfo.pSignalSemaphores = &vulkanContext.renderingFinishedSemaphore;
+ result = vkQueueSubmit(
+ vulkanContext.graphicsQueue, 1, &submitInfo, vulkanContext.fences[frameIndex]);
+ if(result != VK_SUCCESS)
+ {
+ SDL_LogError(
+ SDL_LOG_CATEGORY_APPLICATION, "vkQueueSubmit(): %s\n", getVulkanResultString(result));
+ quit(2);
+ }
+ presentInfo.sType = VK_STRUCTURE_TYPE_PRESENT_INFO_KHR;
+ presentInfo.waitSemaphoreCount = 1;
+ presentInfo.pWaitSemaphores = &vulkanContext.renderingFinishedSemaphore;
+ presentInfo.swapchainCount = 1;
+ presentInfo.pSwapchains = &vulkanContext.swapchain;
+ presentInfo.pImageIndices = &frameIndex;
+ result = vkQueuePresentKHR(vulkanContext.presentQueue, &presentInfo);
+ if(result == VK_ERROR_OUT_OF_DATE_KHR || result == VK_SUBOPTIMAL_KHR)
+ {
+ return createNewSwapchainAndSwapchainSpecificStuff();
+ }
+ if(result != VK_SUCCESS)
+ {
+ SDL_LogError(SDL_LOG_CATEGORY_APPLICATION,
+ "vkQueuePresentKHR(): %s\n",
+ getVulkanResultString(result));
+ quit(2);
+ }
+ SDL_GL_GetDrawableSize(state->windows[0], &w, &h);
+ if(w != (int)vulkanContext.swapchainSize.width || h != (int)vulkanContext.swapchainSize.height)
+ {
+ return createNewSwapchainAndSwapchainSpecificStuff();
+ }
+ return SDL_TRUE;
+}
+
+int main(int argc, char *argv[])
+{
+ int fsaa, accel;
+ int i, done;
+ SDL_DisplayMode mode;
+ SDL_Event event;
+ Uint32 then, now, frames;
+ int dw, dh;
+
+ /* Enable standard application logging */
+ SDL_LogSetPriority(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO);
+
+ /* Initialize parameters */
+ fsaa = 0;
+ accel = -1;
+
+ /* Initialize test framework */
+ state = SDLTest_CommonCreateState(argv, SDL_INIT_VIDEO);
+ if(!state)
+ {
+ return 1;
+ }
+ for(i = 1; i < argc;)
+ {
+ int consumed;
+
+ consumed = SDLTest_CommonArg(state, i);
+ if(consumed < 0)
+ {
+ SDL_Log("Usage: %s %s\n", argv[0], SDLTest_CommonUsage(state));
+ quit(1);
+ }
+ i += consumed;
+ }
+
+ /* Set Vulkan parameters */
+ state->window_flags |= SDL_WINDOW_VULKAN;
+ state->num_windows = 1;
+ state->skip_renderer = 1;
+
+ if(!SDLTest_CommonInit(state))
+ {
+ quit(2);
+ }
+
+ SDL_GetCurrentDisplayMode(0, &mode);
+ SDL_Log("Screen BPP : %d\n", SDL_BITSPERPIXEL(mode.format));
+ SDL_GetWindowSize(state->windows[0], &dw, &dh);
+ SDL_Log("Window Size : %d,%d\n", dw, dh);
+ SDL_GL_GetDrawableSize(state->windows[0], &dw, &dh);
+ SDL_Log("Draw Size : %d,%d\n", dw, dh);
+ SDL_Log("\n");
+
+ initVulkan();
+
+ /* Main render loop */
+ frames = 0;
+ then = SDL_GetTicks();
+ done = 0;
+ while(!done)
+ {
+ /* Check for events */
+ ++frames;
+ while(SDL_PollEvent(&event))
+ {
+ SDLTest_CommonEvent(state, &event, &done);
+ }
+
+ if(!done)
+ render();
+ }
+
+ /* Print out some timing information */
+ now = SDL_GetTicks();
+ if(now > then)
+ {
+ SDL_Log("%2.2f frames per second\n", ((double)frames * 1000) / (now - then));
+ }
+ quit(0);
+ return 0;
+}
+
+#endif