Remove gles2 vita render
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
diff --git a/CMakeLists.txt b/CMakeLists.txt
index ef53c71..358f32f 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -2118,7 +2118,6 @@ elseif(VITA)
if(HAVE_PIGS_IN_BLANKET_H)
set(SDL_VIDEO_OPENGL_ES2 1)
- set(SDL_VIDEO_RENDER_VITA_GLES2 1)
list(APPEND EXTRA_LIBS
pib
)
diff --git a/include/SDL_config.h.cmake b/include/SDL_config.h.cmake
index 78d3c6a..0446547 100644
--- a/include/SDL_config.h.cmake
+++ b/include/SDL_config.h.cmake
@@ -416,7 +416,6 @@
#cmakedefine SDL_VIDEO_RENDER_OGL_ES2 @SDL_VIDEO_RENDER_OGL_ES2@
#cmakedefine SDL_VIDEO_RENDER_DIRECTFB @SDL_VIDEO_RENDER_DIRECTFB@
#cmakedefine SDL_VIDEO_RENDER_METAL @SDL_VIDEO_RENDER_METAL@
-#cmakedefine SDL_VIDEO_RENDER_VITA_GLES2 @SDL_VIDEO_RENDER_VITA_GLES2@
#cmakedefine SDL_VIDEO_RENDER_VITA_GXM @SDL_VIDEO_RENDER_VITA_GXM@
/* Enable OpenGL support */
diff --git a/src/render/vitagles2/SDL_gles2funcs.h b/src/render/vitagles2/SDL_gles2funcs.h
deleted file mode 100644
index 94cfb87..0000000
--- a/src/render/vitagles2/SDL_gles2funcs.h
+++ /dev/null
@@ -1,77 +0,0 @@
-/*
- Simple DirectMedia Layer
- Copyright (C) 1997-2020 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.
-*/
-
-SDL_PROC(void, glActiveTexture, (GLenum))
-SDL_PROC(void, glAttachShader, (GLuint, GLuint))
-SDL_PROC(void, glBindAttribLocation, (GLuint, GLuint, const char *))
-SDL_PROC(void, glBindTexture, (GLenum, GLuint))
-SDL_PROC(void, glBlendEquationSeparate, (GLenum, GLenum))
-SDL_PROC(void, glBlendFuncSeparate, (GLenum, GLenum, GLenum, GLenum))
-SDL_PROC(void, glClear, (GLbitfield))
-SDL_PROC(void, glClearColor, (GLclampf, GLclampf, GLclampf, GLclampf))
-SDL_PROC(void, glCompileShader, (GLuint))
-SDL_PROC(GLuint, glCreateProgram, (void))
-SDL_PROC(GLuint, glCreateShader, (GLenum))
-SDL_PROC(void, glDeleteProgram, (GLuint))
-SDL_PROC(void, glDeleteShader, (GLuint))
-SDL_PROC(void, glDeleteTextures, (GLsizei, const GLuint *))
-SDL_PROC(void, glDisable, (GLenum))
-SDL_PROC(void, glDisableVertexAttribArray, (GLuint))
-SDL_PROC(void, glDrawArrays, (GLenum, GLint, GLsizei))
-SDL_PROC(void, glEnable, (GLenum))
-SDL_PROC(void, glEnableVertexAttribArray, (GLuint))
-SDL_PROC(void, glFinish, (void))
-SDL_PROC(void, glGenFramebuffers, (GLsizei, GLuint *))
-SDL_PROC(void, glGenTextures, (GLsizei, GLuint *))
-SDL_PROC(void, glGetBooleanv, (GLenum, GLboolean *))
-SDL_PROC(const GLubyte *, glGetString, (GLenum))
-SDL_PROC(GLenum, glGetError, (void))
-SDL_PROC(void, glGetIntegerv, (GLenum, GLint *))
-SDL_PROC(void, glGetProgramiv, (GLuint, GLenum, GLint *))
-SDL_PROC(void, glGetShaderInfoLog, (GLuint, GLsizei, GLsizei *, char *))
-SDL_PROC(void, glGetShaderiv, (GLuint, GLenum, GLint *))
-SDL_PROC(GLint, glGetUniformLocation, (GLuint, const char *))
-SDL_PROC(void, glLinkProgram, (GLuint))
-SDL_PROC(void, glPixelStorei, (GLenum, GLint))
-SDL_PROC(void, glReadPixels, (GLint, GLint, GLsizei, GLsizei, GLenum, GLenum, GLvoid*))
-SDL_PROC(void, glScissor, (GLint, GLint, GLsizei, GLsizei))
-SDL_PROC(void, glShaderBinary, (GLsizei, const GLuint *, GLenum, const void *, GLsizei))
-SDL_PROC(void, glShaderSource, (GLuint, GLsizei, const GLchar* const*, const GLint *))
-SDL_PROC(void, glTexImage2D, (GLenum, GLint, GLint, GLsizei, GLsizei, GLint, GLenum, GLenum, const void *))
-SDL_PROC(void, glTexParameteri, (GLenum, GLenum, GLint))
-SDL_PROC(void, glTexSubImage2D, (GLenum, GLint, GLint, GLint, GLsizei, GLsizei, GLenum, GLenum, const GLvoid *))
-SDL_PROC(void, glUniform1i, (GLint, GLint))
-SDL_PROC(void, glUniform4f, (GLint, GLfloat, GLfloat, GLfloat, GLfloat))
-SDL_PROC(void, glUniformMatrix4fv, (GLint, GLsizei, GLboolean, const GLfloat *))
-SDL_PROC(void, glUseProgram, (GLuint))
-SDL_PROC(void, glVertexAttribPointer, (GLuint, GLint, GLenum, GLboolean, GLsizei, const void *))
-SDL_PROC(void, glViewport, (GLint, GLint, GLsizei, GLsizei))
-SDL_PROC(void, glBindFramebuffer, (GLenum, GLuint))
-SDL_PROC(void, glFramebufferTexture2D, (GLenum, GLenum, GLenum, GLuint, GLint))
-SDL_PROC(GLenum, glCheckFramebufferStatus, (GLenum))
-SDL_PROC(void, glDeleteFramebuffers, (GLsizei, const GLuint *))
-SDL_PROC(GLint, glGetAttribLocation, (GLuint, const GLchar *))
-SDL_PROC(void, glGetProgramInfoLog, (GLuint, GLsizei, GLsizei*, GLchar*))
-SDL_PROC(void, glGenBuffers, (GLsizei, GLuint *))
-SDL_PROC(void, glDeleteBuffers, (GLsizei, const GLuint *))
-SDL_PROC(void, glBindBuffer, (GLenum, GLuint))
-SDL_PROC(void, glBufferData, (GLenum, GLsizeiptr, const GLvoid *, GLenum))
-SDL_PROC(void, glBufferSubData, (GLenum, GLintptr, GLsizeiptr, const GLvoid *))
diff --git a/src/render/vitagles2/SDL_render_gles2vita.c b/src/render/vitagles2/SDL_render_gles2vita.c
deleted file mode 100644
index 97a23ce..0000000
--- a/src/render/vitagles2/SDL_render_gles2vita.c
+++ /dev/null
@@ -1,2107 +0,0 @@
-/*
- Simple DirectMedia Layer
- Copyright (C) 1997-2020 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_RENDER_VITA_GLES2 && !SDL_RENDER_DISABLED
-
-#include "SDL_assert.h"
-#include "SDL_hints.h"
-#include "SDL_opengles2.h"
-#include "../SDL_sysrender.h"
-#include "../../video/SDL_blit.h"
-#include "SDL_shaders_gles2vita.h"
-
-//#include <psp2/gxm.h>
-//#include <psp2/types.h>
-//#include <psp2/kernel/sysmem.h>
-
-/* To prevent unnecessary window recreation,
- * these should match the defaults selected in SDL_GL_ResetAttributes
- */
-#define RENDERER_CONTEXT_MAJOR 2
-#define RENDERER_CONTEXT_MINOR 0
-
-/* Used to re-create the window with OpenGL ES capability */
-extern int SDL_RecreateWindow(SDL_Window * window, Uint32 flags);
-
-/*************************************************************************************************
- * Context structures *
- *************************************************************************************************/
-
-typedef struct VITA_GLES2_FBOList VITA_GLES2_FBOList;
-
-struct VITA_GLES2_FBOList
-{
- Uint32 w, h;
- GLuint FBO;
- VITA_GLES2_FBOList *next;
-};
-
-typedef struct VITA_GLES2_TextureData
-{
- GLenum texture;
- GLenum texture_type;
- GLenum pixel_format;
- GLenum pixel_type;
- void *pixel_data;
- int pitch;
- /* YUV texture support */
- SDL_bool yuv;
- SDL_bool nv12;
- GLenum texture_v;
- GLenum texture_u;
- VITA_GLES2_FBOList *fbo;
-} VITA_GLES2_TextureData;
-
-typedef struct VITA_GLES2_ShaderCacheEntry
-{
- GLuint id;
- VITA_GLES2_ShaderType type;
- const VITA_GLES2_ShaderInstance *instance;
- int references;
- struct VITA_GLES2_ShaderCacheEntry *prev;
- struct VITA_GLES2_ShaderCacheEntry *next;
-} VITA_GLES2_ShaderCacheEntry;
-
-typedef struct VITA_GLES2_ShaderCache
-{
- int count;
- VITA_GLES2_ShaderCacheEntry *head;
-} VITA_GLES2_ShaderCache;
-
-typedef struct VITA_GLES2_ProgramCacheEntry
-{
- GLuint id;
- VITA_GLES2_ShaderCacheEntry *vertex_shader;
- VITA_GLES2_ShaderCacheEntry *fragment_shader;
- GLuint uniform_locations[16];
- Uint32 color;
- GLfloat projection[4][4];
- struct VITA_GLES2_ProgramCacheEntry *prev;
- struct VITA_GLES2_ProgramCacheEntry *next;
-} VITA_GLES2_ProgramCacheEntry;
-
-typedef struct VITA_GLES2_ProgramCache
-{
- int count;
- VITA_GLES2_ProgramCacheEntry *head;
- VITA_GLES2_ProgramCacheEntry *tail;
-} VITA_GLES2_ProgramCache;
-
-typedef enum
-{
- VITA_GLES2_ATTRIBUTE_POSITION = 0,
- VITA_GLES2_ATTRIBUTE_TEXCOORD = 1,
- VITA_GLES2_ATTRIBUTE_ANGLE = 2,
- VITA_GLES2_ATTRIBUTE_CENTER = 3,
-} VITA_GLES2_Attribute;
-
-typedef enum
-{
- VITA_GLES2_UNIFORM_PROJECTION,
- VITA_GLES2_UNIFORM_TEXTURE,
- VITA_GLES2_UNIFORM_COLOR,
- VITA_GLES2_UNIFORM_TEXTURE_U,
- VITA_GLES2_UNIFORM_TEXTURE_V
-} VITA_GLES2_Uniform;
-
-typedef enum
-{
- VITA_GLES2_IMAGESOURCE_INVALID,
- VITA_GLES2_IMAGESOURCE_SOLID,
- VITA_GLES2_IMAGESOURCE_TEXTURE_ABGR,
- VITA_GLES2_IMAGESOURCE_TEXTURE_ARGB,
- VITA_GLES2_IMAGESOURCE_TEXTURE_RGB,
- VITA_GLES2_IMAGESOURCE_TEXTURE_BGR,
- VITA_GLES2_IMAGESOURCE_TEXTURE_YUV,
- VITA_GLES2_IMAGESOURCE_TEXTURE_NV12,
- VITA_GLES2_IMAGESOURCE_TEXTURE_NV21,
- VITA_GLES2_IMAGESOURCE_TEXTURE_EXTERNAL_OES
-} VITA_GLES2_ImageSource;
-
-typedef struct
-{
- SDL_Rect viewport;
- SDL_bool viewport_dirty;
- SDL_Texture *texture;
- SDL_Texture *target;
- SDL_BlendMode blend;
- SDL_bool cliprect_enabled_dirty;
- SDL_bool cliprect_enabled;
- SDL_bool cliprect_dirty;
- SDL_Rect cliprect;
- SDL_bool texturing;
- SDL_bool is_copy_ex;
- Uint32 color;
- Uint32 clear_color;
- int drawablew;
- int drawableh;
- VITA_GLES2_ProgramCacheEntry *program;
- GLfloat projection[4][4];
-} VITA_GLES2_DrawStateCache;
-
-typedef struct VITA_GLES2_RenderData
-{
- SDL_GLContext *context;
-
- SDL_bool debug_enabled;
-
-#define SDL_PROC(ret,func,params) ret (APIENTRY *func) params;
-#include "SDL_gles2funcs.h"
-#undef SDL_PROC
-
- VITA_GLES2_FBOList *framebuffers;
- GLuint window_framebuffer;
-
- int shader_format_count;
- GLenum *shader_formats;
- VITA_GLES2_ShaderCache shader_cache;
- VITA_GLES2_ProgramCache program_cache;
- Uint8 clear_r, clear_g, clear_b, clear_a;
-
- GLuint vertex_buffers[8];
- size_t vertex_buffer_size[8];
- int current_vertex_buffer;
- VITA_GLES2_DrawStateCache drawstate;
-} VITA_GLES2_RenderData;
-
-#define VITA_GLES2_MAX_CACHED_PROGRAMS 8
-
-static const float inv255f = 1.0f / 255.0f;
-
-
-SDL_FORCE_INLINE const char*
-GL_TranslateError (GLenum error)
-{
-#define GL_ERROR_TRANSLATE(e) case e: return #e;
- switch (error) {
- GL_ERROR_TRANSLATE(GL_INVALID_ENUM)
- GL_ERROR_TRANSLATE(GL_INVALID_VALUE)
- GL_ERROR_TRANSLATE(GL_INVALID_OPERATION)
- GL_ERROR_TRANSLATE(GL_OUT_OF_MEMORY)
- GL_ERROR_TRANSLATE(GL_NO_ERROR)
- default:
- return "UNKNOWN";
-}
-#undef GL_ERROR_TRANSLATE
-}
-
-SDL_FORCE_INLINE void
-GL_ClearErrors(SDL_Renderer *renderer)
-{
- VITA_GLES2_RenderData *data = (VITA_GLES2_RenderData *) renderer->driverdata;
-
- if (!data->debug_enabled) {
- return;
- }
- while (data->glGetError() != GL_NO_ERROR) {
- /* continue; */
- }
-}
-
-SDL_FORCE_INLINE int
-GL_CheckAllErrors (const char *prefix, SDL_Renderer *renderer, const char *file, int line, const char *function)
-{
- VITA_GLES2_RenderData *data = (VITA_GLES2_RenderData *) renderer->driverdata;
- int ret = 0;
-
- if (!data->debug_enabled) {
- return 0;
- }
- /* check gl errors (can return multiple errors) */
- for (;;) {
- GLenum error = data->glGetError();
- if (error != GL_NO_ERROR) {
- if (prefix == NULL || prefix[0] == '\0') {
- prefix = "generic";
- }
- SDL_SetError("%s: %s (%d): %s %s (0x%X)", prefix, file, line, function, GL_TranslateError(error), error);
- ret = -1;
- } else {
- break;
- }
- }
- return ret;
-}
-
-#if 0
-#define GL_CheckError(prefix, renderer)
-#else
-#define GL_CheckError(prefix, renderer) GL_CheckAllErrors(prefix, renderer, SDL_FILE, SDL_LINE, SDL_FUNCTION)
-#endif
-
-/*************************************************************************************************
- * Renderer state APIs *
- *************************************************************************************************/
-
-static int VITA_GLES2_LoadFunctions(VITA_GLES2_RenderData * data)
-{
-#define SDL_PROC(ret,func,params) data->func=func;
-#include "SDL_gles2funcs.h"
-#undef SDL_PROC
- return 0;
-}
-
-static VITA_GLES2_FBOList *
-VITA_GLES2_GetFBO(VITA_GLES2_RenderData *data, Uint32 w, Uint32 h)
-{
- VITA_GLES2_FBOList *result = data->framebuffers;
- while ((result) && ((result->w != w) || (result->h != h)) ) {
- result = result->next;
- }
- if (result == NULL) {
- result = SDL_malloc(sizeof(VITA_GLES2_FBOList));
- result->w = w;
- result->h = h;
- data->glGenFramebuffers(1, &result->FBO);
- result->next = data->framebuffers;
- data->framebuffers = result;
- }
- return result;
-}
-
-static int
-VITA_GLES2_ActivateRenderer(SDL_Renderer * renderer)
-{
- VITA_GLES2_RenderData *data = (VITA_GLES2_RenderData *)renderer->driverdata;
-
- if (SDL_GL_GetCurrentContext() != data->context) {
- /* Null out the current program to ensure we set it again */
- data->drawstate.program = NULL;
-
- if (SDL_GL_MakeCurrent(renderer->window, data->context) < 0) {
- return -1;
- }
- }
-
- GL_ClearErrors(renderer);
-
- return 0;
-}
-
-static void
-VITA_GLES2_WindowEvent(SDL_Renderer * renderer, const SDL_WindowEvent *event)
-{
- VITA_GLES2_RenderData *data = (VITA_GLES2_RenderData *)renderer->driverdata;
-
- if (event->event == SDL_WINDOWEVENT_MINIMIZED) {
- /* According to Apple documentation, we need to finish drawing NOW! */
- data->glFinish();
- }
-}
-
-static int
-VITA_GLES2_GetOutputSize(SDL_Renderer * renderer, int *w, int *h)
-{
- SDL_GL_GetDrawableSize(renderer->window, w, h);
- return 0;
-}
-
-static GLenum GetBlendFunc(SDL_BlendFactor factor)
-{
- switch (factor) {
- case SDL_BLENDFACTOR_ZERO:
- return GL_ZERO;
- case SDL_BLENDFACTOR_ONE:
- return GL_ONE;
- case SDL_BLENDFACTOR_SRC_COLOR:
- return GL_SRC_COLOR;
- case SDL_BLENDFACTOR_ONE_MINUS_SRC_COLOR:
- return GL_ONE_MINUS_SRC_COLOR;
- case SDL_BLENDFACTOR_SRC_ALPHA:
- return GL_SRC_ALPHA;
- case SDL_BLENDFACTOR_ONE_MINUS_SRC_ALPHA:
- return GL_ONE_MINUS_SRC_ALPHA;
- case SDL_BLENDFACTOR_DST_COLOR:
- return GL_DST_COLOR;
- case SDL_BLENDFACTOR_ONE_MINUS_DST_COLOR:
- return GL_ONE_MINUS_DST_COLOR;
- case SDL_BLENDFACTOR_DST_ALPHA:
- return GL_DST_ALPHA;
- case SDL_BLENDFACTOR_ONE_MINUS_DST_ALPHA:
- return GL_ONE_MINUS_DST_ALPHA;
- default:
- return GL_INVALID_ENUM;
- }
-}
-
-static GLenum GetBlendEquation(SDL_BlendOperation operation)
-{
- switch (operation) {
- case SDL_BLENDOPERATION_ADD:
- return GL_FUNC_ADD;
- case SDL_BLENDOPERATION_SUBTRACT:
- return GL_FUNC_SUBTRACT;
- case SDL_BLENDOPERATION_REV_SUBTRACT:
- return GL_FUNC_REVERSE_SUBTRACT;
- default:
- return GL_INVALID_ENUM;
- }
-}
-
-static SDL_bool
-VITA_GLES2_SupportsBlendMode(SDL_Renderer * renderer, SDL_BlendMode blendMode)
-{
- SDL_BlendFactor srcColorFactor = SDL_GetBlendModeSrcColorFactor(blendMode);
- SDL_BlendFactor srcAlphaFactor = SDL_GetBlendModeSrcAlphaFactor(blendMode);
- SDL_BlendOperation colorOperation = SDL_GetBlendModeColorOperation(blendMode);
- SDL_BlendFactor dstColorFactor = SDL_GetBlendModeDstColorFactor(blendMode);
- SDL_BlendFactor dstAlphaFactor = SDL_GetBlendModeDstAlphaFactor(blendMode);
- SDL_BlendOperation alphaOperation = SDL_GetBlendModeAlphaOperation(blendMode);
-
- if (GetBlendFunc(srcColorFactor) == GL_INVALID_ENUM ||
- GetBlendFunc(srcAlphaFactor) == GL_INVALID_ENUM ||
- GetBlendEquation(colorOperation) == GL_INVALID_ENUM ||
- GetBlendFunc(dstColorFactor) == GL_INVALID_ENUM ||
- GetBlendFunc(dstAlphaFactor) == GL_INVALID_ENUM ||
- GetBlendEquation(alphaOperation) == GL_INVALID_ENUM) {
- return SDL_FALSE;
- }
- return SDL_TRUE;
-}
-
-
-static void
-VITA_GLES2_EvictShader(VITA_GLES2_RenderData *data, VITA_GLES2_ShaderCacheEntry *entry)
-{
- /* Unlink the shader from the cache */
- if (entry->next) {
- entry->next->prev = entry->prev;
- }
- if (entry->prev) {
- entry->prev->next = entry->next;
- }
- if (data->shader_cache.head == entry) {
- data->shader_cache.head = entry->next;
- }
- --data->shader_cache.count;
-
- /* Deallocate the shader */
- data->glDeleteShader(entry->id);
- SDL_free(entry);
-}
-
-static VITA_GLES2_ProgramCacheEntry *
-VITA_GLES2_CacheProgram(VITA_GLES2_RenderData *data, VITA_GLES2_ShaderCacheEntry *vertex,
- VITA_GLES2_ShaderCacheEntry *fragment)
-{
- VITA_GLES2_ProgramCacheEntry *entry;
- VITA_GLES2_ShaderCacheEntry *shaderEntry;
- GLint linkSuccessful;
-
- /* Check if we've already cached this program */
- entry = data->program_cache.head;
- while (entry) {
- if (entry->vertex_shader == vertex && entry->fragment_shader == fragment) {
- break;
- }
- entry = entry->next;
- }
- if (entry) {
- if (data->program_cache.head != entry) {
- if (entry->next) {
- entry->next->prev = entry->prev;
- }
- if (entry->prev) {
- entry->prev->next = entry->next;
- }
- entry->prev = NULL;
- entry->next = data->program_cache.head;
- data->program_cache.head->prev = entry;
- data->program_cache.head = entry;
- }
- return entry;
- }
-
- /* Create a program cache entry */
- entry = (VITA_GLES2_ProgramCacheEntry *)SDL_calloc(1, sizeof(VITA_GLES2_ProgramCacheEntry));
- if (!entry) {
- SDL_OutOfMemory();
- return NULL;
- }
- entry->vertex_shader = vertex;
- entry->fragment_shader = fragment;
-
- /* Create the program and link it */
- entry->id = data->glCreateProgram();
- data->glAttachShader(entry->id, vertex->id);
- data->glAttachShader(entry->id, fragment->id);
- data->glBindAttribLocation(entry->id, VITA_GLES2_ATTRIBUTE_POSITION, "a_position");
- data->glBindAttribLocation(entry->id, VITA_GLES2_ATTRIBUTE_TEXCOORD, "a_texCoord");
- data->glBindAttribLocation(entry->id, VITA_GLES2_ATTRIBUTE_ANGLE, "a_angle");
- data->glBindAttribLocation(entry->id, VITA_GLES2_ATTRIBUTE_CENTER, "a_center");
- data->glLinkProgram(entry->id);
- data->glGetProgramiv(entry->id, GL_LINK_STATUS, &linkSuccessful);
- if (!linkSuccessful) {
- data->glDeleteProgram(entry->id);
- SDL_free(entry);
- SDL_SetError("Failed to link shader program");
- return NULL;
- }
-
- /* Predetermine locations of uniform variables */
- entry->uniform_locations[VITA_GLES2_UNIFORM_PROJECTION] =
- data->glGetUniformLocation(entry->id, "u_projection");
- entry->uniform_locations[VITA_GLES2_UNIFORM_TEXTURE_V] =
- data->glGetUniformLocation(entry->id, "u_texture_v");
- entry->uniform_locations[VITA_GLES2_UNIFORM_TEXTURE_U] =
- data->glGetUniformLocation(entry->id, "u_texture_u");
- entry->uniform_locations[VITA_GLES2_UNIFORM_TEXTURE] =
- data->glGetUniformLocation(entry->id, "u_texture");
- entry->uniform_locations[VITA_GLES2_UNIFORM_COLOR] =
- data->glGetUniformLocation(entry->id, "u_color");
-
- entry->color = 0;
-
- data->glUseProgram(entry->id);
- if (entry->uniform_locations[VITA_GLES2_UNIFORM_TEXTURE_V] != -1) {
- data->glUniform1i(entry->uniform_locations[VITA_GLES2_UNIFORM_TEXTURE_V], 2); /* always texture unit 2. */
- }
- if (entry->uniform_locations[VITA_GLES2_UNIFORM_TEXTURE_U] != -1) {
- data->glUniform1i(entry->uniform_locations[VITA_GLES2_UNIFORM_TEXTURE_U], 1); /* always texture unit 1. */
- }
- if (entry->uniform_locations[VITA_GLES2_UNIFORM_TEXTURE] != -1) {
- data->glUniform1i(entry->uniform_locations[VITA_GLES2_UNIFORM_TEXTURE], 0); /* always texture unit 0. */
- }
- if (entry->uniform_locations[VITA_GLES2_UNIFORM_PROJECTION] != -1) {
- data->glUniformMatrix4fv(entry->uniform_locations[VITA_GLES2_UNIFORM_PROJECTION], 1, GL_FALSE, (GLfloat *)entry->projection);
- }
- if (entry->uniform_locations[VITA_GLES2_UNIFORM_COLOR] != -1) {
- data->glUniform4f(entry->uniform_locations[VITA_GLES2_UNIFORM_COLOR], 0.0f, 0.0f, 0.0f, 0.0f);
- }
-
- /* Cache the linked program */
- if (data->program_cache.head) {
- entry->next = data->program_cache.head;
- data->program_cache.head->prev = entry;
- } else {
- data->program_cache.tail = entry;
- }
- data->program_cache.head = entry;
- ++data->program_cache.count;
-
- /* Increment the refcount of the shaders we're using */
- ++vertex->references;
- ++fragment->references;
-
- /* Evict the last entry from the cache if we exceed the limit */
- if (data->program_cache.count > VITA_GLES2_MAX_CACHED_PROGRAMS) {
- shaderEntry = data->program_cache.tail->vertex_shader;
- if (--shaderEntry->references <= 0) {
- VITA_GLES2_EvictShader(data, shaderEntry);
- }
- shaderEntry = data->program_cache.tail->fragment_shader;
- if (--shaderEntry->references <= 0) {
- VITA_GLES2_EvictShader(data, shaderEntry);
- }
- data->glDeleteProgram(data->program_cache.tail->id);
- data->program_cache.tail = data->program_cache.tail->prev;
- if (data->program_cache.tail != NULL) {
- SDL_free(data->program_cache.tail->next);
- data->program_cache.tail->next = NULL;
- }
- --data->program_cache.count;
- }
- return entry;
-}
-
-static VITA_GLES2_ShaderCacheEntry *
-VITA_GLES2_CacheShader(VITA_GLES2_RenderData *data, VITA_GLES2_ShaderType type)
-{
- const VITA_GLES2_Shader *shader;
- const VITA_GLES2_ShaderInstance *instance = NULL;
- VITA_GLES2_ShaderCacheEntry *entry = NULL;
- GLint compileSuccessful = GL_FALSE;
- int i, j;
-
- /* Find the corresponding shader */
- shader = VITA_GLES2_GetShader(type);
- if (!shader) {
- SDL_SetError("No shader matching the requested characteristics was found");
- return NULL;
- }
-
- /* Find a matching shader instance that's supported on this hardware */
- for (i = 0; i < shader->instance_count && !instance; ++i) {
- for (j = 0; j < data->shader_format_count && !instance; ++j) {
- if (!shader->instances[i]) {
- continue;
- }
- if (shader->instances[i]->format != data->shader_formats[j]) {
- continue;
- }
- instance = shader->instances[i];
- }
- }
- if (!instance) {
- SDL_SetError("The specified shader cannot be loaded on the current platform");
- return NULL;
- }
-
- /* Check if we've already cached this shader */
- entry = data->shader_cache.head;
- while (entry) {
- if (entry->instance == instance) {
- break;
- }
- entry = entry->next;
- }
- if (entry) {
- return entry;
- }
-
- /* Create a shader cache entry */
- entry = (VITA_GLES2_ShaderCacheEntry *)SDL_calloc(1, sizeof(VITA_GLES2_ShaderCacheEntry));
- if (!entry) {
- SDL_OutOfMemory();
- return NULL;
- }
- entry->type = type;
- entry->instance = instance;
-
- /* Compile or load the selected shader instance */
- entry->id = data->glCreateShader(instance->type);
- if (instance->format == (GLenum)-1) {
- data->glShaderSource(entry->id, 1, (const char **)(char *)&instance->data, NULL);
- data->glCompileShader(entry->id);
- data->glGetShaderiv(entry->id, GL_COMPILE_STATUS, &compileSuccessful);
- } else {
- data->glShaderBinary(1, &entry->id, instance->format, instance->data, instance->length);
- compileSuccessful = GL_TRUE;
- }
- if (!compileSuccessful) {
- SDL_bool isstack = SDL_FALSE;
- char *info = NULL;
- int length = 0;
-
- data->glGetShaderiv(entry->id, GL_INFO_LOG_LENGTH, &length);
- if (length > 0) {
- info = SDL_small_alloc(char, length, &isstack);
- if (info) {
- data->glGetShaderInfoLog(entry->id, length, &length, info);
- }
- }
- if (info) {
- SDL_SetError("Failed to load the shader: %s", info);
- SDL_small_free(info, isstack);
- } else {
- SDL_SetError("Failed to load the shader");
- }
- data->glDeleteShader(entry->id);
- SDL_free(entry);
- return NULL;
- }
-
- /* Link the shader entry in at the front of the cache */
- if (data->shader_cache.head) {
- entry->next = data->shader_cache.head;
- data->shader_cache.head->prev = entry;
- }
- data->shader_cache.head = entry;
- ++data->shader_cache.count;
- return entry;
-}
-
-static int
-VITA_GLES2_SelectProgram(VITA_GLES2_RenderData *data, VITA_GLES2_ImageSource source, int w, int h)
-{
- VITA_GLES2_ShaderCacheEntry *vertex = NULL;
- VITA_GLES2_ShaderCacheEntry *fragment = NULL;
- VITA_GLES2_ShaderType vtype, ftype;
- VITA_GLES2_ProgramCacheEntry *program;
-
- /* Select an appropriate shader pair for the specified modes */
- vtype = VITA_GLES2_SHADER_VERTEX_DEFAULT;
- switch (source) {
- case VITA_GLES2_IMAGESOURCE_SOLID:
- ftype = VITA_GLES2_SHADER_FRAGMENT_SOLID_SRC;
- break;
- case VITA_GLES2_IMAGESOURCE_TEXTURE_ABGR:
- ftype = VITA_GLES2_SHADER_FRAGMENT_TEXTURE_ABGR_SRC;
- break;
- case VITA_GLES2_IMAGESOURCE_TEXTURE_ARGB:
- ftype = VITA_GLES2_SHADER_FRAGMENT_TEXTURE_ARGB_SRC;
- break;
- case VITA_GLES2_IMAGESOURCE_TEXTURE_RGB:
- ftype = VITA_GLES2_SHADER_FRAGMENT_TEXTURE_RGB_SRC;
- break;
- case VITA_GLES2_IMAGESOURCE_TEXTURE_BGR:
- ftype = VITA_GLES2_SHADER_FRAGMENT_TEXTURE_BGR_SRC;
- break;
- case VITA_GLES2_IMAGESOURCE_TEXTURE_YUV:
- switch (SDL_GetYUVConversionModeForResolution(w, h)) {
- case SDL_YUV_CONVERSION_JPEG:
- ftype = VITA_GLES2_SHADER_FRAGMENT_TEXTURE_YUV_JPEG_SRC;
- break;
- case SDL_YUV_CONVERSION_BT601:
- ftype = VITA_GLES2_SHADER_FRAGMENT_TEXTURE_YUV_BT601_SRC;
- break;
- case SDL_YUV_CONVERSION_BT709:
- ftype = VITA_GLES2_SHADER_FRAGMENT_TEXTURE_YUV_BT709_SRC;
- break;
- default:
- SDL_SetError("Unsupported YUV conversion mode: %d\n", SDL_GetYUVConversionModeForResolution(w, h));
- goto fault;
- }
- break;
- case VITA_GLES2_IMAGESOURCE_TEXTURE_NV12:
- switch (SDL_GetYUVConversionModeForResolution(w, h)) {
- case SDL_YUV_CONVERSION_JPEG:
- ftype = VITA_GLES2_SHADER_FRAGMENT_TEXTURE_NV12_JPEG_SRC;
- break;
- case SDL_YUV_CONVERSION_BT601:
- ftype = VITA_GLES2_SHADER_FRAGMENT_TEXTURE_NV12_BT601_SRC;
- break;
- case SDL_YUV_CONVERSION_BT709:
- ftype = VITA_GLES2_SHADER_FRAGMENT_TEXTURE_NV12_BT709_SRC;
- break;
- default:
- SDL_SetError("Unsupported YUV conversion mode: %d\n", SDL_GetYUVConversionModeForResolution(w, h));
- goto fault;
- }
- break;
- case VITA_GLES2_IMAGESOURCE_TEXTURE_NV21:
- switch (SDL_GetYUVConversionModeForResolution(w, h)) {
- case SDL_YUV_CONVERSION_JPEG:
- ftype = VITA_GLES2_SHADER_FRAGMENT_TEXTURE_NV21_JPEG_SRC;
- break;
- case SDL_YUV_CONVERSION_BT601:
- ftype = VITA_GLES2_SHADER_FRAGMENT_TEXTURE_NV21_BT601_SRC;
- break;
- case SDL_YUV_CONVERSION_BT709:
- ftype = VITA_GLES2_SHADER_FRAGMENT_TEXTURE_NV21_BT709_SRC;
- break;
- default:
- SDL_SetError("Unsupported YUV conversion mode: %d\n", SDL_GetYUVConversionModeForResolution(w, h));
- goto fault;
- }
- break;
- case VITA_GLES2_IMAGESOURCE_TEXTURE_EXTERNAL_OES:
- ftype = VITA_GLES2_SHADER_FRAGMENT_TEXTURE_EXTERNAL_OES_SRC;
- break;
- default:
- goto fault;
- }
-
- /* Load the requested shaders */
- vertex = VITA_GLES2_CacheShader(data, vtype);
- if (!vertex) {
- goto fault;
- }
- fragment = VITA_GLES2_CacheShader(data, ftype);
- if (!fragment) {
- goto fault;
- }
-
- /* Check if we need to change programs at all */
- if (data->drawstate.program &&
- data->drawstate.program->vertex_shader == vertex &&
- data->drawstate.program->fragment_shader == fragment) {
- return 0;
- }
-
- /* Generate a matching program */
- program = VITA_GLES2_CacheProgram(data, vertex, fragment);
- if (!program) {
- goto fault;
- }
-
- /* Select that program in OpenGL */
- data->glUseProgram(program->id);
-
- /* Set the current program */
- data->drawstate.program = program;
-
- /* Clean up and return */
- return 0;
-fault:
- if (vertex && vertex->references <= 0) {
- VITA_GLES2_EvictShader(data, vertex);
- }
- if (fragment && fragment->references <= 0) {
- VITA_GLES2_EvictShader(data, fragment);
- }
- data->drawstate.program = NULL;
- return -1;
-}
-
-static int
-VITA_GLES2_QueueSetViewport(SDL_Renderer * renderer, SDL_RenderCommand *cmd)
-{
- return 0; /* nothing to do in this backend. */
-}
-
-static int
-VITA_GLES2_QueueDrawPoints(SDL_Renderer * renderer, SDL_RenderCommand *cmd, const SDL_FPoint * points, int count)
-{
-
- GLfloat *verts = (GLfloat *) SDL_AllocateRenderVertices(renderer, count * 2 * sizeof (GLfloat), 4, &cmd->data.draw.first);
-
- int i;
-
- if (!verts) {
- return -1;
- }
-
- cmd->data.draw.count = count;
- for (i = 0; i < count; i++) {
- *(verts++) = 0.5f + points[i].x;
- *(verts++) = 0.5f + points[i].y;
- }
-
- return 0;
-}
-
-static int
-VITA_GLES2_QueueFillRects(SDL_Renderer * renderer, SDL_RenderCommand *cmd, const SDL_FRect * rects, int count)
-{
- GLfloat *verts = (GLfloat *) SDL_AllocateRenderVertices(renderer, count * 8 * sizeof (GLfloat), 4, &cmd->data.draw.first);
-
- int i;
-
- if (!verts) {
- return -1;
- }
-
- cmd->data.draw.count = count;
-
- for (i = 0; i < count; i++) {
- const SDL_FRect *rect = &rects[i];
- const GLfloat minx = rect->x;
- const GLfloat maxx = rect->x + rect->w;
- const GLfloat miny = rect->y;
- const GLfloat maxy = rect->y + rect->h;
- *(verts++) = minx;
- *(verts++) = miny;
- *(verts++) = maxx;
- *(verts++) = miny;
- *(verts++) = minx;
- *(verts++) = maxy;
- *(verts++) = maxx;
- *(verts++) = maxy;
- }
-
- return 0;
-}
-
-static int
-VITA_GLES2_QueueCopy(SDL_Renderer * renderer, SDL_RenderCommand *cmd, SDL_Texture * texture,
- const SDL_Rect * srcrect, const SDL_FRect * dstrect)
-{
- GLfloat minx, miny, maxx, maxy;
- GLfloat minu, maxu, minv, maxv;
- GLfloat *verts = (GLfloat *) SDL_AllocateRenderVertices(renderer, 16 * sizeof (GLfloat), 4, &cmd->data.draw.first);
-
- if (!verts) {
- return -1;
- }
-
- cmd->data.draw.count = 1;
-
- minx = dstrect->x;
- miny = dstrect->y;
- maxx = dstrect->x + dstrect->w;
- maxy = dstrect->y + dstrect->h;
-
- minu = (GLfloat) srcrect->x / texture->w;
- maxu = (GLfloat) (srcrect->x + srcrect->w) / texture->w;
- minv = (GLfloat) srcrect->y / texture->h;
- maxv = (GLfloat) (srcrect->y + srcrect->h) / texture->h;
-
- *(verts++) = minx;
- *(verts++) = miny;
- *(verts++) = maxx;
- *(verts++) = miny;
- *(verts++) = minx;
- *(verts++) = maxy;
- *(verts++) = maxx;
- *(verts++) = maxy;
-
- *(verts++) = minu;
- *(verts++) = minv;
- *(verts++) = maxu;
- *(verts++) = minv;
- *(verts++) = minu;
- *(verts++) = maxv;
- *(verts++) = maxu;
- *(verts++) = maxv;
-
- return 0;
-}
-
-static int
-VITA_GLES2_QueueCopyEx(SDL_Renderer * renderer, SDL_RenderCommand *cmd, SDL_Texture * texture,
- const SDL_Rect * srcquad, const SDL_FRect * dstrect,
- const double angle, const SDL_FPoint *center, const SDL_RendererFlip flip)
-{
- /* render expects cos value - 1 (see VITA_GLES2_VertexSrc_Default_) */
- const float radian_angle = (float)(M_PI * (360.0 - angle) / 180.0);
- const GLfloat s = (GLfloat) SDL_sin(radian_angle);
- const GLfloat c = (GLfloat) SDL_cos(radian_angle) - 1.0f;
- const GLfloat centerx = center->x + dstrect->x;
- const GLfloat centery = center->y + dstrect->y;
- GLfloat minx, miny, maxx, maxy;
- GLfloat minu, maxu, minv, maxv;
- GLfloat *verts = (GLfloat *) SDL_AllocateRenderVertices(renderer, 32 * sizeof (GLfloat), 4, &cmd->data.draw.first);
-
- if (!verts) {
- return -1;
- }
-
- if (flip & SDL_FLIP_HORIZONTAL) {
- minx = dstrect->x + dstrect->w;
- maxx = dstrect->x;
- } else {
- minx = dstrect->x;
- maxx = dstrect->x + dstrect->w;
- }
-
- if (flip & SDL_FLIP_VERTICAL) {
- miny = dstrect->y + dstrect->h;
- maxy = dstrect->y;
- } else {
- miny = dstrect->y;
- maxy = dstrect->y + dstrect->h;
- }
-
- minu = ((GLfloat) srcquad->x) / ((GLfloat) texture->w);
- maxu = ((GLfloat) (srcquad->x + srcquad->w)) / ((GLfloat) texture->w);
- minv = ((GLfloat) srcquad->y) / ((GLfloat) texture->h);
- maxv = ((GLfloat) (srcquad->y + srcquad->h)) / ((GLfloat) texture->h);
-
-
- cmd->data.draw.count = 1;
-
- *(verts++) = minx;
- *(verts++) = miny;
- *(verts++) = maxx;
- *(verts++) = miny;
- *(verts++) = minx;
- *(verts++) = maxy;
- *(verts++) = maxx;
- *(verts++) = maxy;
-
- *(verts++) = minu;
- *(verts++) = minv;
- *(verts++) = maxu;
- *(verts++) = minv;
- *(verts++) = minu;
- *(verts++) = maxv;
- *(verts++) = maxu;
- *(verts++) = maxv;
-
- *(verts++) = s;
- *(verts++) = c;
- *(verts++) = s;
- *(verts++) = c;
- *(verts++) = s;
- *(verts++) = c;
- *(verts++) = s;
- *(verts++) = c;
-
- *(verts++) = centerx;
- *(verts++) = centery;
- *(verts++) = centerx;
- *(verts++) = centery;
- *(verts++) = centerx;
- *(verts++) = centery;
- *(verts++) = centerx;
- *(verts++) = centery;
-
- return 0;
-}
-
-static int
-SetDrawState(VITA_GLES2_RenderData *data, const SDL_RenderCommand *cmd, const VITA_GLES2_ImageSource imgsrc)
-{
- const SDL_bool was_copy_ex = data->drawstate.is_copy_ex;
- const SDL_bool is_copy_ex = (cmd->command == SDL_RENDERCMD_COPY_EX);
- SDL_Texture *texture = cmd->data.draw.texture;
- const SDL_BlendMode blend = cmd->data.draw.blend;
- VITA_GLES2_ProgramCacheEntry *program;
-
- SDL_assert((texture != NULL) == (imgsrc != VITA_GLES2_IMAGESOURCE_SOLID));
-
- if (data->drawstate.viewport_dirty) {
- const SDL_Rect *viewport = &data->drawstate.viewport;
- data->glViewport(viewport->x,
- data->drawstate.target ? viewport->y : (data->drawstate.drawableh - viewport->y - viewport->h),
- viewport->w, viewport->h);
- if (viewport->w && viewport->h) {
- data->drawstate.projection[0][0] = 2.0f / viewport->w;
- data->drawstate.projection[1][1] = (data->drawstate.target ? 2.0f : -2.0f) / viewport->h;
- data->drawstate.projection[3][1] = data->drawstate.target ? -1.0f : 1.0f;
- }
- data->drawstate.viewport_dirty = SDL_FALSE;
- }
-
- if (data->drawstate.cliprect_enabled_dirty) {
- if (!data->drawstate.cliprect_enabled) {
- data->glDisable(GL_SCISSOR_TEST);
- } else {
- data->glEnable(GL_SCISSOR_TEST);
- }
- data->drawstate.cliprect_enabled_dirty = SDL_FALSE;
- }
-
- if (data->drawstate.cliprect_enabled && data->drawstate.cliprect_dirty) {
- const SDL_Rect *viewport = &data->drawstate.viewport;
- const SDL_Rect *rect = &data->drawstate.cliprect;
- data->glScissor(viewport->x + rect->x,
- data->drawstate.target ? viewport->y + rect->y : data->drawstate.drawableh - viewport->y - rect->y - rect->h,
- rect->w, rect->h);
- data->drawstate.cliprect_dirty = SDL_FALSE;
- }
-
- if (texture != data->drawstate.texture) {
- if ((texture != NULL) != data->drawstate.texturing) {
- if (texture == NULL) {
- data->glDisableVertexAttribArray((GLenum) VITA_GLES2_ATTRIBUTE_TEXCOORD);
- data->drawstate.texturing = SDL_FALSE;
- } else {
- data->glEnableVertexAttribArray((GLenum) VITA_GLES2_ATTRIBUTE_TEXCOORD);
- data->drawstate.texturing = SDL_TRUE;
- }
- }
-
- if (texture) {
- VITA_GLES2_TextureData *tdata = (VITA_GLES2_TextureData *) texture->driverdata;
- if (tdata->yuv) {
- data->glActiveTexture(GL_TEXTURE2);
- data->glBindTexture(tdata->texture_type, tdata->texture_v);
-
- data->glActiveTexture(GL_TEXTURE1);
- data->glBindTexture(tdata->texture_type, tdata->texture_u);
-
- data->glActiveTexture(GL_TEXTURE0);
- } else if (tdata->nv12) {
- data->glActiveTexture(GL_TEXTURE1);
- data->glBindTexture(tdata->texture_type, tdata->texture_u);
-
- data->glActiveTexture(GL_TEXTURE0);
- }
- data->glBindTexture(tdata->texture_type, tdata->texture);
- }
-
- data->drawstate.texture = texture;
- }
-
- if (texture) {
- data->glVertexAttribPointer(VITA_GLES2_ATTRIBUTE_TEXCOORD, 2, GL_FLOAT, GL_FALSE, 0, (const GLvoid *) (cmd->data.draw.first + (sizeof (GLfloat) * 8)));
- }
-
- if (VITA_GLES2_SelectProgram(data, imgsrc, texture ? texture->w : 0, texture ? texture->h : 0) < 0) {
- return -1;
- }
-
- program = data->drawstate.program;
-
- if (program->uniform_locations[VITA_GLES2_UNIFORM_PROJECTION] != -1) {
- if (SDL_memcmp(program->projection, data->drawstate.projection, sizeof (data->drawstate.projection)) != 0) {
- data->glUniformMatrix4fv(program->uniform_locations[VITA_GLES2_UNIFORM_PROJECTION], 1, GL_FALSE, (GLfloat *)data->drawstate.projection);
- SDL_memcpy(program->projection, data->drawstate.projection, sizeof (data->drawstate.projection));
- }
- }
-
- if (program->uniform_locations[VITA_GLES2_UNIFORM_COLOR] != -1) {
- if (data->drawstate.color != program->color) {
- const Uint8 r = (data->drawstate.color >> 16) & 0xFF;
- const Uint8 g = (data->drawstate.color >> 8) & 0xFF;
- const Uint8 b = (data->drawstate.color >> 0) & 0xFF;
- const Uint8 a = (data->drawstate.color >> 24) & 0xFF;
- data->glUniform4f(program->uniform_locations[VITA_GLES2_UNIFORM_COLOR], r * inv255f, g * inv255f, b * inv255f, a * inv255f);
- program->color = data->drawstate.color;
- }
- }
-
- if (blend != data->drawstate.blend) {
- if (blend == SDL_BLENDMODE_NONE) {
- data->glDisable(GL_BLEND);
- } else {
- data->glEnable(GL_BLEND);
- data->glBlendFuncSeparate(GetBlendFunc(SDL_GetBlendModeSrcColorFactor(blend)),
- GetBlendFunc(SDL_GetBlendModeDstColorFactor(blend)),
- GetBlendFunc(SDL_GetBlendModeSrcAlphaFactor(blend)),
- GetBlendFunc(SDL_GetBlendModeDstAlphaFactor(blend)));
- data->glBlendEquationSeparate(GetBlendEquation(SDL_GetBlendModeColorOperation(blend)),
- GetBlendEquation(SDL_GetBlendModeAlphaOperation(blend)));
- }
- data->drawstate.blend = blend;
- }
-
- /* all drawing commands use this */
- data->glVertexAttribPointer(VITA_GLES2_ATTRIBUTE_POSITION, 2, GL_FLOAT, GL_FALSE, 0, (const GLvoid *) cmd->data.draw.first);
-
- if (is_copy_ex != was_copy_ex) {
- if (is_copy_ex) {
- data->glEnableVertexAttribArray((GLenum) VITA_GLES2_ATTRIBUTE_ANGLE);
- data->glEnableVertexAttribArray((GLenum) VITA_GLES2_ATTRIBUTE_CENTER);
- } else {
- data->glDisableVertexAttribArray((GLenum) VITA_GLES2_ATTRIBUTE_ANGLE);
- data->glDisableVertexAttribArray((GLenum) VITA_GLES2_ATTRIBUTE_CENTER);
- }
- data->drawstate.is_copy_ex = is_copy_ex;
- }
-
- if (is_copy_ex) {
- data->glVertexAttribPointer(VITA_GLES2_ATTRIBUTE_ANGLE, 2, GL_FLOAT, GL_FALSE, 0, (const GLvoid *) (cmd->data.draw.first + (sizeof (GLfloat) * 16)));
- data->glVertexAttribPointer(VITA_GLES2_ATTRIBUTE_CENTER, 2, GL_FLOAT, GL_FALSE, 0, (const GLvoid *) (cmd->data.draw.first + (sizeof (GLfloat) * 24)));
- }
-
- return 0;
-}
-
-static int
-SetCopyState(SDL_Renderer *renderer, const SDL_RenderCommand *cmd)
-{
- VITA_GLES2_RenderData *data = (VITA_GLES2_RenderData *) renderer->driverdata;
- VITA_GLES2_ImageSource sourceType = VITA_GLES2_IMAGESOURCE_TEXTURE_ABGR;
- SDL_Texture *texture = cmd->data.draw.texture;
-
- /* Pick an appropriate shader */
- if (renderer->target) {
- /* Check if we need to do color mapping between the source and render target textures */
- if (renderer->target->format != texture->format) {
- switch (texture->format) {
- case SDL_PIXELFORMAT_ARGB8888:
- switch (renderer->target->format) {
- case SDL_PIXELFORMAT_ABGR8888:
- case SDL_PIXELFORMAT_BGR888:
- sourceType = VITA_GLES2_IMAGESOURCE_TEXTURE_ARGB;
- break;
- case SDL_PIXELFORMAT_RGB888:
- sourceType = VITA_GLES2_IMAGESOURCE_TEXTURE_ABGR;
- break;
- }
- break;
- case SDL_PIXELFORMAT_ABGR8888:
- switch (renderer->target->format) {
- case SDL_PIXELFORMAT_ARGB8888:
- case SDL_PIXELFORMAT_RGB888:
- sourceType = VITA_GLES2_IMAGESOURCE_TEXTURE_ARGB;
- break;
- case SDL_PIXELFORMAT_BGR888:
- sourceType = VITA_GLES2_IMAGESOURCE_TEXTURE_ABGR;
- break;
- }
- break;
- case SDL_PIXELFORMAT_RGB888:
- switch (renderer->target->format) {
- case SDL_PIXELFORMAT_ABGR8888:
- sourceType = VITA_GLES2_IMAGESOURCE_TEXTURE_ARGB;
- break;
- case SDL_PIXELFORMAT_ARGB8888:
- sourceType = VITA_GLES2_IMAGESOURCE_TEXTURE_BGR;
- break;
- case SDL_PIXELFORMAT_BGR888:
- sourceType = VITA_GLES2_IMAGESOURCE_TEXTURE_ARGB;
- break;
- }
- break;
- case SDL_PIXELFORMAT_BGR888:
- switch (renderer->target->format) {
- case SDL_PIXELFORMAT_ABGR8888:
- sourceType = VITA_GLES2_IMAGESOURCE_TEXTURE_BGR;
- break;
- case SDL_PIXELFORMAT_ARGB8888:
- sourceType = VITA_GLES2_IMAGESOURCE_TEXTURE_RGB;
- break;
- case SDL_PIXELFORMAT_RGB888:
- sourceType = VITA_GLES2_IMAGESOURCE_TEXTURE_ARGB;
- break;
- }
- break;
- case SDL_PIXELFORMAT_IYUV:
- case SDL_PIXELFORMAT_YV12:
- sourceType = VITA_GLES2_IMAGESOURCE_TEXTURE_YUV;
- break;
- case SDL_PIXELFORMAT_NV12:
- sourceType = VITA_GLES2_IMAGESOURCE_TEXTURE_NV12;
- break;
- case SDL_PIXELFORMAT_NV21:
- sourceType = VITA_GLES2_IMAGESOURCE_TEXTURE_NV21;
- break;
- case SDL_PIXELFORMAT_EXTERNAL_OES:
- sourceType = VITA_GLES2_IMAGESOURCE_TEXTURE_EXTERNAL_OES;
- break;
- default:
- return SDL_SetError("Unsupported texture format");
- }
- } else {
- sourceType = VITA_GLES2_IMAGESOURCE_TEXTURE_ABGR; /* Texture formats match, use the non color mapping shader (even if the formats are not ABGR) */
- }
- } else {
- switch (texture->format) {
- case SDL_PIXELFORMAT_ARGB8888:
- sourceType = VITA_GLES2_IMAGESOURCE_TEXTURE_ARGB;
- break;
- case SDL_PIXELFORMAT_ABGR8888:
- sourceType = VITA_GLES2_IMAGESOURCE_TEXTURE_ABGR;
- break;
- case SDL_PIXELFORMAT_RGB888:
- sourceType = VITA_GLES2_IMAGESOURCE_TEXTURE_RGB;
- break;
- case SDL_PIXELFORMAT_BGR888:
- sourceType = VITA_GLES2_IMAGESOURCE_TEXTURE_BGR;
- break;
- case SDL_PIXELFORMAT_IYUV:
- case SDL_PIXELFORMAT_YV12:
- sourceType = VITA_GLES2_IMAGESOURCE_TEXTURE_YUV;
- break;
- case SDL_PIXELFORMAT_NV12:
- sourceType = VITA_GLES2_IMAGESOURCE_TEXTURE_NV12;
- break;
- case SDL_PIXELFORMAT_NV21:
- sourceType = VITA_GLES2_IMAGESOURCE_TEXTURE_NV21;
- break;
- case SDL_PIXELFORMAT_EXTERNAL_OES:
- sourceType = VITA_GLES2_IMAGESOURCE_TEXTURE_EXTERNAL_OES;
- break;
- default:
- return SDL_SetError("Unsupported texture format");
- }
- }
-
- return SetDrawState(data, cmd, sourceType);
-}
-
-static int
-VITA_GLES2_RunCommandQueue(SDL_Renderer * renderer, SDL_RenderCommand *cmd, void *vertices, size_t vertsize)
-{
- VITA_GLES2_RenderData *data = (VITA_GLES2_RenderData *) renderer->driverdata;
- const SDL_bool colorswap = (renderer->target && (renderer->target->format == SDL_PIXELFORMAT_ARGB8888 || renderer->target->format == SDL_PIXELFORMAT_RGB888));
- const int vboidx = data->current_vertex_buffer;
- const GLuint vbo = data->vertex_buffers[vboidx];
- size_t i;
-
- if (VITA_GLES2_ActivateRenderer(renderer) < 0) {
- return -1;
- }
-
- data->drawstate.target = renderer->target;
- if (!data->drawstate.target) {
- SDL_GL_GetDrawableSize(renderer->window, &data->drawstate.drawablew, &data->drawstate.drawableh);
- }
-
- /* upload the new VBO data for this set of commands. */
- /* NULL/zero vertices could happen SetRenderTarget is the first render command */
- if (vertsize > 0 && vertices != NULL)
- {
- data->glBindBuffer(GL_ARRAY_BUFFER, vbo);
- if (data->vertex_buffer_size[vboidx] < vertsize) {
- data->glBufferData(GL_ARRAY_BUFFER, vertsize, vertices, GL_DYNAMIC_DRAW);
- data->vertex_buffer_size[vboidx] = vertsize;
- } else {
- data->glBufferSubData(GL_ARRAY_BUFFER, 0, vertsize, vertices);
- }
- }
-
- /* cycle through a few VBOs so the GL has some time with the data before we replace it. */
- data->current_vertex_buffer++;
- if (data->current_vertex_buffer >= SDL_arraysize(data->vertex_buffers)) {
- data->current_vertex_buffer = 0;
- }
-
- data->glDisable(GL_DEPTH_TEST);
- data->glDisable(GL_CULL_FACE);
-
- while (cmd) {
- switch (cmd->command) {
- case SDL_RENDERCMD_SETDRAWCOLOR: {
- const Uint8 r = colorswap ? cmd->data.color.b : cmd->data.color.r;
- const Uint8 g = cmd->data.color.g;
- const Uint8 b = colorswap ? cmd->data.color.r : cmd->data.color.b;
- const Uint8 a = cmd->data.color.a;
- data->drawstate.color = ((a << 24) | (r << 16) | (g << 8) | b);
- break;
- }
-
- case SDL_RENDERCMD_SETVIEWPORT: {
- SDL_Rect *viewport = &data->drawstate.viewport;
- if (SDL_memcmp(viewport, &cmd->data.viewport.rect, sizeof (SDL_Rect)) != 0) {
- SDL_memcpy(viewport, &cmd->data.viewport.rect, sizeof (SDL_Rect));
- data->drawstate.viewport_dirty = SDL_TRUE;
- }
- break;
- }
-
- case SDL_RENDERCMD_SETCLIPRECT: {
- const SDL_Rect *rect = &cmd->data.cliprect.rect;
- if (data->drawstate.cliprect_enabled != cmd->data.cliprect.enabled) {
- data->drawstate.cliprect_enabled = cmd->data.cliprect.enabled;
- data->drawstate.cliprect_enabled_dirty = SDL_TRUE;
- }
-
- if (SDL_memcmp(&data->drawstate.cliprect, rect, sizeof (SDL_Rect)) != 0) {
- SDL_memcpy(&data->drawstate.cliprect, rect, sizeof (SDL_Rect));
- data->drawstate.cliprect_dirty = SDL_TRUE;
- }
- break;
- }
-
- case SDL_RENDERCMD_CLEAR: {
- const Uint8 r = colorswap ? cmd->data.color.b : cmd->data.color.r;
- const Uint8 g = cmd->data.color.g;
- const Uint8 b = colorswap ? cmd->data.color.r : cmd->data.color.b;
- const Uint8 a = cmd->data.color.a;
- const Uint32 color = ((a << 24) | (r << 16) | (g << 8) | b);
- if (color != data->drawstate.clear_color) {
- const GLfloat fr = ((GLfloat) r) * inv255f;
- const GLfloat fg = ((GLfloat) g) * inv255f;
- const GLfloat fb = ((GLfloat) b) * inv255f;
- const GLfloat fa = ((GLfloat) a) * inv255f;
- data->glClearColor(fr, fg, fb, fa);
- data->drawstate.clear_color = color;
- }
-
- if (data->drawstate.cliprect_enabled || data->drawstate.cliprect_enabled_dirty) {
- data->glDisable(GL_SCISSOR_TEST);
- data->drawstate.cliprect_enabled_dirty = data->drawstate.cliprect_enabled;
- }
-
- data->glClear(GL_COLOR_BUFFER_BIT);
- break;
- }
-
- case SDL_RENDERCMD_DRAW_POINTS: {
- if (SetDrawState(data, cmd, VITA_GLES2_IMAGESOURCE_SOLID) == 0) {
- data->glDrawArrays(GL_POINTS, 0, (GLsizei) cmd->data.draw.count);
- }
- break;
- }
-
- case SDL_RENDERCMD_DRAW_LINES: {
- const GLfloat *verts = (GLfloat *) (((Uint8 *) vertices) + cmd->data.draw.first);
- const size_t count = cmd->data.draw.count;
- if (SetDrawState(data, cmd, VITA_GLES2_IMAGESOURCE_SOLID) == 0) {
- if (count > 2 && (verts[0] == verts[(count-1)*2]) && (verts[1] == verts[(count*2)-1])) {
- /* GL_LINE_LOOP takes care of the final segment */
- data->glDrawArrays(GL_LINE_LOOP, 0, (GLsizei) (count - 1));
- } else {
- data->glDrawArrays(GL_LINE_STRIP, 0, (GLsizei) count);
- /* We need to close the endpoint of the line */
- data->glDrawArrays(GL_POINTS, (GLsizei) (count - 1), 1);
- }
- }
- break;
- }
-
- case SDL_RENDERCMD_FILL_RECTS: {
- const size_t count = cmd->data.draw.count;
- size_t offset = 0;
- if (SetDrawState(data, cmd, VITA_GLES2_IMAGESOURCE_SOLID) == 0) {
- for (i = 0; i < count; ++i, offset += 4) {
- data->glDrawArrays(GL_TRIANGLE_STRIP, (GLsizei) offset, 4);
- }
- }
- break;
- }
-
- case SDL_RENDERCMD_COPY:
- case SDL_RENDERCMD_COPY_EX: {
- if (SetCopyState(renderer, cmd) == 0) {
- data->glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
- }
- break;
- }
-
- case SDL_RENDERCMD_NO_OP:
- break;
- }
-
- cmd = cmd->next;
- }
-
- return GL_CheckError("", renderer);
-}
-
-static void
-VITA_GLES2_DestroyRenderer(SDL_Renderer *renderer)
-{
- VITA_GLES2_RenderData *data = (VITA_GLES2_RenderData *)renderer->driverdata;
-
- /* Deallocate everything */
- if (data) {
- VITA_GLES2_ActivateRenderer(renderer);
-
- {
- VITA_GLES2_ShaderCacheEntry *entry;
- VITA_GLES2_ShaderCacheEntry *next;
- entry = data->shader_cache.head;
- while (entry) {
- data->glDeleteShader(entry->id);
- next = entry->next;
- SDL_free(entry);
- entry = next;
- }
- }
- {
- VITA_GLES2_ProgramCacheEntry *entry;
- VITA_GLES2_ProgramCacheEntry *next;
- entry = data->program_cache.head;
- while (entry) {
- data->glDeleteProgram(entry->id);
- next = entry->next;
- SDL_free(entry);
- entry = next;
- }
- }
-
- if (data->context) {
- while (data->framebuffers) {
- VITA_GLES2_FBOList *nextnode = data->framebuffers->next;
- data->glDeleteFramebuffers(1, &data->framebuffers->FBO);
- GL_CheckError("", renderer);
- SDL_free(data->framebuffers);
- data->framebuffers = nextnode;
- }
-
- data->glDeleteBuffers(SDL_arraysize(data->vertex_buffers), data->vertex_buffers);
- GL_CheckError("", renderer);
-
- SDL_GL_DeleteContext(data->context);
- }
-
- SDL_free(data->shader_formats);
- SDL_free(data);
- }
- SDL_free(renderer);
-}
-
-static int
-VITA_GLES2_CreateTexture(SDL_Renderer *renderer, SDL_Texture *texture)
-{
- VITA_GLES2_RenderData *renderdata = (VITA_GLES2_RenderData *)renderer->driverdata;
- VITA_GLES2_TextureData *data;
- GLenum format;
- GLenum type;
- GLenum scaleMode;
-
- VITA_GLES2_ActivateRenderer(renderer);
-
- renderdata->drawstate.texture = NULL; /* we trash this state. */
-
- /* Determine the corresponding GLES texture format params */
- switch (texture->format)
- {
- case SDL_PIXELFORMAT_ARGB8888:
- case SDL_PIXELFORMAT_ABGR8888:
- case SDL_PIXELFORMAT_RGB888:
- case SDL_PIXELFORMAT_BGR888:
- format = GL_RGBA;
- type = GL_UNSIGNED_BYTE;
- break;
- case SDL_PIXELFORMAT_IYUV:
- case SDL_PIXELFORMAT_YV12:
- case SDL_PIXELFORMAT_NV12:
- case SDL_PIXELFORMAT_NV21:
- format = GL_LUMINANCE;
- type = GL_UNSIGNED_BYTE;
- break;
- default:
- return SDL_SetError("Texture format not supported");
- }
-
- if (texture->format == SDL_PIXELFORMAT_EXTERNAL_OES &&
- texture->access != SDL_TEXTUREACCESS_STATIC) {
- return SDL_SetError("Unsupported texture access for SDL_PIXELFORMAT_EXTERNAL_OES");
- }
-
- /* Allocate a texture struct */
- data = (VITA_GLES2_TextureData *)SDL_calloc(1, sizeof(VITA_GLES2_TextureData));
- if (!data) {
- return SDL_OutOfMemory();
- }
- data->texture = 0;
- data->texture_type = GL_TEXTURE_2D;
- data->pixel_format = format;
- data->pixel_type = type;
- data->yuv = ((texture->format == SDL_PIXELFORMAT_IYUV) || (texture->format == SDL_PIXELFORMAT_YV12));
- data->nv12 = ((texture->format == SDL_PIXELFORMAT_NV12) || (texture->format == SDL_PIXELFORMAT_NV21));
- data->texture_u = 0;
- data->texture_v = 0;
- scaleMode = (texture->scaleMode == SDL_ScaleModeNearest) ? GL_NEAREST : GL_LINEAR;
-
- /* Allocate a blob for image renderdata */
- if (texture->access == SDL_TEXTUREACCESS_STREAMING) {
- size_t size;
- data->pitch = texture->w * SDL_BYTESPERPIXEL(texture->format);
- size = texture->h * data->pitch;
- if (data->yuv) {
- /* Need to add size for the U and V planes */
- size += 2 * ((texture->h + 1) / 2) * ((data->pitch + 1) / 2);
- } else if (data->nv12) {
- /* Need to add size for the U/V plane */
- size += 2 * ((texture->h + 1) / 2) * ((data->pitch + 1) / 2);
- }
- data->pixel_data = SDL_calloc(1, size);
- if (!data->pixel_data) {
- SDL_free(data);
- return SDL_OutOfMemory();
- }
- }
-
- /* Allocate the texture */
- GL_CheckError("", renderer);
-
- if (data->yuv) {
- renderdata->glGenTextures(1, &data->texture_v);
- if (GL_CheckError("glGenTexures()", renderer) < 0) {
- return -1;
- }
- renderdata->glActiveTexture(GL_TEXTURE2);
- renderdata->glBindTexture(data->texture_type, data->texture_v);
- renderdata->glTexParameteri(data->texture_type, GL_TEXTURE_MIN_FILTER, scaleMode);
- renderdata->glTexParameteri(data->texture_type, GL_TEXTURE_MAG_FILTER, scaleMode);
- renderdata->glTexParameteri(data->texture_type, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
- renderdata->glTexParameteri(data->texture_type, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
- renderdata->glTexImage2D(data->texture_type, 0, format, (texture->w + 1) / 2, (texture->h + 1) / 2, 0, format, type, NULL);
-
- renderdata->glGenTextures(1, &data->texture_u);
- if (GL_CheckError("glGenTexures()", renderer) < 0) {
- return -1;
- }
- renderdata->glActiveTexture(GL_TEXTURE1);
- renderdata->glBindTexture(data->texture_type, data->texture_u);
- renderdata->glTexParameteri(data->texture_type, GL_TEXTURE_MIN_FILTER, scaleMode);
- renderdata->glTexParameteri(data->texture_type, GL_TEXTURE_MAG_FILTER, scaleMode);
- renderdata->glTexParameteri(data->texture_type, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
- renderdata->glTexParameteri(data->texture_type, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
- renderdata->glTexImage2D(data->texture_type, 0, format, (texture->w + 1) / 2, (texture->h + 1) / 2, 0, format, type, NULL);
- if (GL_CheckError("glTexImage2D()", renderer) < 0) {
- return -1;
- }
- } else if (data->nv12) {
- renderdata->glGenTextures(1, &data->texture_u);
- if (GL_CheckError("glGenTexures()", renderer) < 0) {
- return -1;
- }
- renderdata->glActiveTexture(GL_TEXTURE1);
- renderdata->glBindTexture(data->texture_type, data->texture_u);
- renderdata->glTexParameteri(data->texture_type, GL_TEXTURE_MIN_FILTER, scaleMode);
- renderdata->glTexParameteri(data->texture_type, GL_TEXTURE_MAG_FILTER, scaleMode);
- renderdata->glTexParameteri(data->texture_type, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
- renderdata->glTexParameteri(data->texture_type, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
- renderdata->glTexImage2D(data->texture_type, 0, GL_LUMINANCE_ALPHA, (texture->w + 1) / 2, (texture->h + 1) / 2, 0, GL_LUMINANCE_ALPHA, GL_UNSIGNED_BYTE, NULL);
- if (GL_CheckError("glTexImage2D()", renderer) < 0) {
- return -1;
- }
- }
-
- renderdata->glGenTextures(1, &data->texture);
- if (GL_CheckError("glGenTexures()", renderer) < 0) {
- return -1;
- }
- texture->driverdata = data;
- renderdata->glActiveTexture(GL_TEXTURE0);
- renderdata->glBindTexture(data->texture_type, data->texture);
- renderdata->glTexParameteri(data->texture_type, GL_TEXTURE_MIN_FILTER, scaleMode);
- renderdata->glTexParameteri(data->texture_type, GL_TEXTURE_MAG_FILTER, scaleMode);
- renderdata->glTexParameteri(data->texture_type, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
- renderdata->glTexParameteri(data->texture_type, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
- if (texture->format != SDL_PIXELFORMAT_EXTERNAL_OES) {
- renderdata->glTexImage2D(data->texture_type, 0, format, texture->w, texture->h, 0, format, type, NULL);
- if (GL_CheckError("glTexImage2D()", renderer) < 0) {
- return -1;
- }
- }
-
- if (texture->access == SDL_TEXTUREACCESS_TARGET) {
- data->fbo = VITA_GLES2_GetFBO(renderer->driverdata, texture->w, texture->h);
- } else {
- data->fbo = NULL;
- }
-
- return GL_CheckError("", renderer);
-}
-
-static int
-VITA_GLES2_TexSubImage2D(VITA_GLES2_RenderData *data, GLenum target, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *pixels, GLint pitch, GLint bpp)
-{
- Uint8 *blob = NULL;
- Uint8 *src;
- int src_pitch;
- int y;
-
- if ((width == 0) || (height == 0) || (bpp == 0)) {
- return 0; /* nothing to do */
- }
-
- /* Reformat the texture data into a tightly packed array */
- src_pitch = width * bpp;
- src = (Uint8 *)pixels;
- if (pitch != src_pitch) {
- blob = (Uint8 *)SDL_malloc(src_pitch * height);
- if (!blob) {
- return SDL_OutOfMemory();
- }
- src = blob;
- for (y = 0; y < height; ++y)
- {
- SDL_memcpy(src, pixels, src_pitch);
- src += src_pitch;
- pixels = (Uint8 *)pixels + pitch;
- }
- src = blob;
- }
-
- data->glTexSubImage2D(target, 0, xoffset, yoffset, width, height, format, type, src);
- if (blob) {
- SDL_free(blob);
- }
- return 0;
-}
-
-static int
-VITA_GLES2_UpdateTexture(SDL_Renderer *renderer, SDL_Texture *texture, const SDL_Rect *rect,
- const void *pixels, int pitch)
-{
- VITA_GLES2_RenderData *data = (VITA_GLES2_RenderData *)renderer->driverdata;
- VITA_GLES2_TextureData *tdata = (VITA_GLES2_TextureData *)texture->driverdata;
-
- VITA_GLES2_ActivateRenderer(renderer);
-
- /* Bail out if we're supposed to update an empty rectangle */
- if (rect->w <= 0 || rect->h <= 0) {
- return 0;
- }
-
- data->drawstate.texture = NULL; /* we trash this state. */
-
- /* Create a texture subimage with the supplied data */
- data->glBindTexture(tdata->texture_type, tdata->texture);
- VITA_GLES2_TexSubImage2D(data, tdata->texture_type,
- rect->x,
- rect->y,
- rect->w,
- rect->h,
- tdata->pixel_format,
- tdata->pixel_type,
- pixels, pitch, SDL_BYTESPERPIXEL(texture->format));
-
- if (tdata->yuv) {
- /* Skip to the correct offset into the next texture */
- pixels = (const void*)((const Uint8*)pixels + rect->h * pitch);
- if (texture->format == SDL_PIXELFORMAT_YV12) {
- data->glBindTexture(tdata->texture_type, tdata->texture_v);
- } else {
- data->glBindTexture(tdata->texture_type, tdata->texture_u);
- }
- VITA_GLES2_TexSubImage2D(data, tdata->texture_type,
- rect->x / 2,
- rect->y / 2,
- (rect->w + 1) / 2,
- (rect->h + 1) / 2,
- tdata->pixel_format,
- tdata->pixel_type,
- pixels, (pitch + 1) / 2, 1);
-
-
- /* Skip to the correct offset into the next texture */
- pixels = (const void*)((const Uint8*)pixels + ((rect->h + 1) / 2) * ((pitch + 1)/2));
- if (texture->format == SDL_PIXELFORMAT_YV12) {
- data->glBindTexture(tdata->texture_type, tdata->texture_u);
- } else {
- data->glBindTexture(tdata->texture_type, tdata->texture_v);
- }
- VITA_GLES2_TexSubImage2D(data, tdata->texture_type,
- rect->x / 2,
- rect->y / 2,
- (rect->w + 1) / 2,
- (rect->h + 1) / 2,
- tdata->pixel_format,
- tdata->pixel_type,
- pixels, (pitch + 1) / 2, 1);
- } else if (tdata->nv12) {
- /* Skip to the correct offset into the next texture */
- pixels = (const void*)((const Uint8*)pixels + rect->h * pitch);
- data->glBindTexture(tdata->texture_type, tdata->texture_u);
- VITA_GLES2_TexSubImage2D(data, tdata->texture_type,
- rect->x / 2,
- rect->y / 2,
- (rect->w + 1) / 2,
- (rect->h + 1) / 2,
- GL_LUMINANCE_ALPHA,
- GL_UNSIGNED_BYTE,
- pixels, 2 * ((pitch + 1) / 2), 2);
- }
-
- return GL_CheckError("glTexSubImage2D()", renderer);
-}
-
-static int
-VITA_GLES2_UpdateTextureYUV(SDL_Renderer * renderer, SDL_Texture * texture,
- const SDL_Rect * rect,
- const Uint8 *Yplane, int Ypitch,
- const Uint8 *Uplane, int Upitch,
- const Uint8 *Vplane, int Vpitch)
-{
- VITA_GLES2_RenderData *data = (VITA_GLES2_RenderData *)renderer->driverdata;
- VITA_GLES2_TextureData *tdata = (VITA_GLES2_TextureData *)texture->driverdata;
-
- VITA_GLES2_ActivateRenderer(renderer);
-
- /* Bail out if we're supposed to update an empty rectangle */
- if (rect->w <= 0 || rect->h <= 0) {
- return 0;
- }
-
- data->drawstate.texture = NULL; /* we trash this state. */
-
- data->glBindTexture(tdata->texture_type, tdata->texture_v);
- VITA_GLES2_TexSubImage2D(data, tdata->texture_type,
- rect->x / 2,
- rect->y / 2,
- (rect->w + 1) / 2,
- (rect->h + 1) / 2,
- tdata->pixel_format,
- tdata->pixel_type,
- Vplane, Vpitch, 1);
-
- data->glBindTexture(tdata->texture_type, tdata->texture_u);
- VITA_GLES2_TexSubImage2D(data, tdata->texture_type,
- rect->x / 2,
- rect->y / 2,
- (rect->w + 1) / 2,
- (rect->h + 1) / 2,
- tdata->pixel_format,
- tdata->pixel_type,
- Uplane, Upitch, 1);
-
- data->glBindTexture(tdata->texture_type, tdata->texture);
- VITA_GLES2_TexSubImage2D(data, tdata->texture_type,
- rect->x,
- rect->y,
- rect->w,
- rect->h,
- tdata->pixel_format,
- tdata->pixel_type,
- Yplane, Ypitch, 1);
-
- return GL_CheckError("glTexSubImage2D()", renderer);
-}
-
-static int
-VITA_GLES2_LockTexture(SDL_Renderer *renderer, SDL_Texture *texture, const SDL_Rect *rect,
- void **pixels, int *pitch)
-{
- VITA_GLES2_TextureData *tdata = (VITA_GLES2_TextureData *)texture->driverdata;
-
- /* Retrieve the buffer/pitch for the specified region */
- *pixels = (Uint8 *)tdata->pixel_data +
- (tdata->pitch * rect->y) +
- (rect->x * SDL_BYTESPERPIXEL(texture->format));
- *pitch = tdata->pitch;
-
- return 0;
-}
-
-static void
-VITA_GLES2_UnlockTexture(SDL_Renderer *renderer, SDL_Texture *texture)
-{
- VITA_GLES2_TextureData *tdata = (VITA_GLES2_TextureData *)texture->driverdata;
- SDL_Rect rect;
-
- /* We do whole texture updates, at least for now */
- rect.x = 0;
- rect.y = 0;
- rect.w = texture->w;
- rect.h = texture->h;
- VITA_GLES2_UpdateTexture(renderer, texture, &rect, tdata->pixel_data, tdata->pitch);
-}
-
-static void
-VITA_GLES2_SetTextureScaleMode(SDL_Renderer * renderer, SDL_Texture * texture, SDL_ScaleMode scaleMode)
-{
- VITA_GLES2_RenderData *renderdata = (VITA_GLES2_RenderData *) renderer->driverdata;
- VITA_GLES2_TextureData *data = (VITA_GLES2_TextureData *) texture->driverdata;
- GLenum glScaleMode = (scaleMode == SDL_ScaleModeNearest) ? GL_NEAREST : GL_LINEAR;
-
- if (data->yuv) {
- renderdata->glActiveTexture(GL_TEXTURE2);
- renderdata->glBindTexture(data->texture_type, data->texture_v);
- renderdata->glTexParameteri(data->texture_type, GL_TEXTURE_MIN_FILTER, glScaleMode);
- renderdata->glTexParameteri(data->texture_type, GL_TEXTURE_MAG_FILTER, glScaleMode);
-
- renderdata->glActiveTexture(GL_TEXTURE1);
- renderdata->glBindTexture(data->texture_type, data->texture_u);
- renderdata->glTexParameteri(data->texture_type, GL_TEXTURE_MIN_FILTER, glScaleMode);
- renderdata->glTexParameteri(data->texture_type, GL_TEXTURE_MAG_FILTER, glScaleMode);
- } else if (data->nv12) {
- renderdata->glActiveTexture(GL_TEXTURE1);
- renderdata->glBindTexture(data->texture_type, data->texture_u);
- renderdata->glTexParameteri(data->texture_type, GL_TEXTURE_MIN_FILTER, glScaleMode);
- renderdata->glTexParameteri(data->texture_type, GL_TEXTURE_MAG_FILTER, glScaleMode);
- }
-
- renderdata->glActiveTexture(GL_TEXTURE0);
- renderdata->glBindTexture(data->texture_type, data->texture);
- renderdata->glTexParameteri(data->texture_type, GL_TEXTURE_MIN_FILTER, glScaleMode);
- renderdata->glTexParameteri(data->texture_type, GL_TEXTURE_MAG_FILTER, glScaleMode);
-}
-
-static int
-VITA_GLES2_SetRenderTarget(SDL_Renderer * renderer, SDL_Texture * texture)
-{
- VITA_GLES2_RenderData *data = (VITA_GLES2_RenderData *) renderer->driverdata;
- VITA_GLES2_TextureData *texturedata = NULL;
- GLenum status;
-
- data->drawstate.viewport_dirty = SDL_TRUE;
-
- if (texture == NULL) {
- data->glBindFramebuffer(GL_FRAMEBUFFER, data->window_framebuffer);
- } else {
- texturedata = (VITA_GLES2_TextureData *) texture->driverdata;
- data->glBindFramebuffer(GL_FRAMEBUFFER, texturedata->fbo->FBO);
- /* TODO: check if texture pixel format allows this operation */
- data->glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, texturedata->texture_type, texturedata->texture, 0);
- /* Check FBO status */
- status = data->glCheckFramebufferStatus(GL_FRAMEBUFFER);
- if (status != GL_FRAMEBUFFER_COMPLETE) {
- return SDL_SetError("glFramebufferTexture2D() failed");
- }
- }
- return 0;
-}
-
-static void
-VITA_GLES2_DestroyTexture(SDL_Renderer *renderer, SDL_Texture *texture)
-{
- VITA_GLES2_RenderData *data = (VITA_GLES2_RenderData *)renderer->driverdata;
- VITA_GLES2_TextureData *tdata = (VITA_GLES2_TextureData *)texture->driverdata;
-
- VITA_GLES2_ActivateRenderer(renderer);
-
- if (data->drawstate.texture == texture) {
- data->drawstate.texture = NULL;
- }
- if (data->drawstate.target == texture) {
- data->drawstate.target = NULL;
- }
-
- /* Destroy the texture */
- if (tdata) {
- data->glDeleteTextures(1, &tdata->texture);
- if (tdata->texture_v) {
- data->glDeleteTextures(1, &tdata->texture_v);
- }
- if (tdata->texture_u) {
- data->glDeleteTextures(1, &tdata->texture_u);
- }
- SDL_free(tdata->pixel_data);
- SDL_free(tdata);
- texture->driverdata = NULL;
- }
-}
-
-static int
-VITA_GLES2_RenderReadPixels(SDL_Renderer * renderer, const SDL_Rect * rect,
- Uint32 pixel_format, void * pixels, int pitch)
-{
- VITA_GLES2_RenderData *data = (VITA_GLES2_RenderData *)renderer->driverdata;
- Uint32 temp_format = renderer->target ? renderer->target->format : SDL_PIXELFORMAT_ABGR8888;
- size_t buflen;
- void *temp_pixels;
- int temp_pitch;
- Uint8 *src, *dst, *tmp;
- int w, h, length, rows;
- int status;
-
- temp_pitch = rect->w * SDL_BYTESPERPIXEL(temp_format);
- buflen = rect->h * temp_pitch;
- if (buflen == 0) {
- return 0; /* nothing to do. */
- }
-
- temp_pixels = SDL_malloc(buflen);
- if (!temp_pixels) {
- return SDL_OutOfMemory();
- }
-
- SDL_GetRendererOutputSize(renderer, &w, &h);
-
- data->glReadPixels(rect->x, renderer->target ? rect->y : (h-rect->y)-rect->h,
- rect->w, rect->h, GL_RGBA, GL_UNSIGNED_BYTE, temp_pixels);
- if (GL_CheckError("glReadPixels()", renderer) < 0) {
- return -1;
- }
-
- /* Flip the rows to be top-down if necessary */
- if (!renderer->target) {
- SDL_bool isstack;
- length = rect->w * SDL_BYTESPERPIXEL(temp_format);
- src = (Uint8*)temp_pixels + (rect->h-1)*temp_pitch;
- dst = (Uint8*)temp_pixels;
- tmp = SDL_small_alloc(Uint8, length, &isstack);
- rows = rect->h / 2;
- while (rows--) {
- SDL_memcpy(tmp, dst, length);
- SDL_memcpy(dst, src, length);
- SDL_memcpy(src, tmp, length);
- dst += temp_pitch;
- src -= temp_pitch;
- }
- SDL_small_free(tmp, isstack);
- }
-
- status = SDL_ConvertPixels(rect->w, rect->h,
- temp_format, temp_pixels, temp_pitch,
- pixel_format, pixels, pitch);
- SDL_free(temp_pixels);
-
- return status;
-}
-
-static void
-VITA_GLES2_RenderPresent(SDL_Renderer *renderer)
-{
- /* Tell the video driver to swap buffers */
- SDL_GL_SwapWindow(renderer->window);
-}
-
-
-/*************************************************************************************************
- * Bind/unbinding of textures
- *************************************************************************************************/
-static int VITA_GLES2_BindTexture (SDL_Renderer * renderer, SDL_Texture *texture, float *texw, float *texh);
-static int VITA_GLES2_UnbindTexture (SDL_Renderer * renderer, SDL_Texture *texture);
-
-static int VITA_GLES2_BindTexture (SDL_Renderer * renderer, SDL_Texture *texture, float *texw, float *texh)
-{
- VITA_GLES2_RenderData *data = (VITA_GLES2_RenderData *)renderer->driverdata;
- VITA_GLES2_TextureData *texturedata = (VITA_GLES2_TextureData *)texture->driverdata;
- VITA_GLES2_ActivateRenderer(renderer);
-
- data->glBindTexture(texturedata->texture_type, texturedata->texture);
- data->drawstate.texture = texture;
-
- if (texw) {
- *texw = 1.0;
- }
- if (texh) {
- *texh = 1.0;
- }
-
- return 0;
-}
-
-static int VITA_GLES2_UnbindTexture (SDL_Renderer * renderer, SDL_Texture *texture)
-{
- VITA_GLES2_RenderData *data = (VITA_GLES2_RenderData *)renderer->driverdata;
- VITA_GLES2_TextureData *texturedata = (VITA_GLES2_TextureData *)texture->driverdata;
- VITA_GLES2_ActivateRenderer(renderer);
-
- data->glBindTexture(texturedata->texture_type, 0);
- data->drawstate.texture = NULL;
-
- return 0;
-}
-
-
-/*************************************************************************************************
- * Renderer instantiation *
- *************************************************************************************************/
-
-static SDL_Renderer *
-VITA_GLES2_CreateRenderer(SDL_Window *window, Uint32 flags)
-{
- SDL_Renderer *renderer;
- VITA_GLES2_RenderData *data;
- GLint nFormats;
- GLboolean hasCompiler;
- GLint window_framebuffer;
- GLint value;
- Uint32 window_flags = 0;
-
- window_flags = SDL_GetWindowFlags(window);
-
- if (!(window_flags & SDL_WINDOW_OPENGL)) {
- if (SDL_RecreateWindow(window, window_flags | SDL_WINDOW_OPENGL) < 0) {
- goto error;
- }
- }
-
- /* Create the renderer struct */
- renderer = (SDL_Renderer *)SDL_calloc(1, sizeof(SDL_Renderer));
- if (!renderer) {
- SDL_OutOfMemory();
- goto error;
- }
-
- data = (VITA_GLES2_RenderData *)SDL_calloc(1, sizeof(VITA_GLES2_RenderData));
- if (!data) {
- SDL_free(renderer);
- SDL_OutOfMemory();
- goto error;
- }
-
- renderer->info = VITA_GLES2_RenderDriver.info;
- renderer->info.flags = (SDL_RENDERER_ACCELERATED | SDL_RENDERER_TARGETTEXTURE);
- renderer->driverdata = data;
- renderer->window = window;
-
- /* Create an OpenGL ES 2.0 context */
- data->context = SDL_GL_CreateContext(window);
- if (!data->context) {
- SDL_free(renderer);
- SDL_free(data);
- goto error;
- }
- if (SDL_GL_MakeCurrent(window, data->context) < 0) {
- SDL_GL_DeleteContext(data->context);
- SDL_free(renderer);
- SDL_free(data);
- goto error;
- }
-
- if (VITA_GLES2_LoadFunctions(data) < 0) {
- SDL_GL_DeleteContext(data->context);
- SDL_free(renderer);
- SDL_free(data);
- goto error;
- }
-
- if (flags & SDL_RENDERER_PRESENTVSYNC) {
- SDL_GL_SetSwapInterval(1);
- } else {
- SDL_GL_SetSwapInterval(0);
- }
-
- if (SDL_GL_GetSwapInterval() > 0) {
- renderer->info.flags |= SDL_RENDERER_PRESENTVSYNC;
- }
-
- /* Check for debug output support */
- if (SDL_GL_GetAttribute(SDL_GL_CONTEXT_FLAGS, &value) == 0 &&
- (value & SDL_GL_CONTEXT_DEBUG_FLAG)) {
- data->debug_enabled = SDL_TRUE;
- }
-
- value = 0;
- data->glGetIntegerv(GL_MAX_TEXTURE_SIZE, &value);
- renderer->info.max_texture_width = value;
- value = 0;
- data->glGetIntegerv(GL_MAX_TEXTURE_SIZE, &value);
- renderer->info.max_texture_height = value;
-
- data->glGetIntegerv(GL_NUM_SHADER_BINARY_FORMATS, &nFormats);
- hasCompiler = GL_TRUE;
- if (hasCompiler) {
- ++nFormats;
- }
-
- data->shader_formats = (GLenum *)SDL_calloc(nFormats, sizeof(GLenum));
- if (!data->shader_formats) {
- VITA_GLES2_DestroyRenderer(renderer);
- SDL_OutOfMemory();
- goto error;
- }
- data->shader_format_count = nFormats;
- data->glGetIntegerv(GL_SHADER_BINARY_FORMATS, (GLint *)data->shader_formats);
- if (hasCompiler) {
- data->shader_formats[nFormats - 1] = (GLenum)-1;
- }
-
- /* we keep a few of these and cycle through them, so data can live for a few frames. */
- data->glGenBuffers(SDL_arraysize(data->vertex_buffers), data->vertex_buffers);
-
- data->framebuffers = NULL;
- data->glGetIntegerv(GL_FRAMEBUFFER_BINDING, &window_framebuffer);
- data->window_framebuffer = (GLuint)window_framebuffer;
-
- /* Populate the function pointers for the module */
- renderer->WindowEvent = VITA_GLES2_WindowEvent;
- renderer->GetOutputSize = VITA_GLES2_GetOutputSize;
- renderer->SupportsBlendMode = VITA_GLES2_SupportsBlendMode;
- renderer->CreateTexture = VITA_GLES2_CreateTexture;
- renderer->UpdateTexture = VITA_GLES2_UpdateTexture;
- renderer->UpdateTextureYUV = VITA_GLES2_UpdateTextureYUV;
- renderer->LockTexture = VITA_GLES2_LockTexture;
- renderer->UnlockTexture = VITA_GLES2_UnlockTexture;
- renderer->SetTextureScaleMode = VITA_GLES2_SetTextureScaleMode;
- renderer->SetRenderTarget = VITA_GLES2_SetRenderTarget;
-
- renderer->QueueSetViewport = VITA_GLES2_QueueSetViewport;
- renderer->QueueSetDrawColor = VITA_GLES2_QueueSetViewport; /* SetViewport and SetDrawColor are (currently) no-ops. */
- renderer->QueueDrawPoints = VITA_GLES2_QueueDrawPoints;
- renderer->QueueDrawLines = VITA_GLES2_QueueDrawPoints; /* lines and points queue vertices the same way. */
- renderer->QueueFillRects = VITA_GLES2_QueueFillRects;
- renderer->QueueCopy = VITA_GLES2_QueueCopy;
- renderer->QueueCopyEx = VITA_GLES2_QueueCopyEx;
- renderer->RunCommandQueue = VITA_GLES2_RunCommandQueue;
- renderer->RenderReadPixels = VITA_GLES2_RenderReadPixels;
- renderer->RenderPresent = VITA_GLES2_RenderPresent;
- renderer->DestroyTexture = VITA_GLES2_DestroyTexture;
- renderer->DestroyRenderer = VITA_GLES2_DestroyRenderer;
- renderer->GL_BindTexture = VITA_GLES2_BindTexture;
- renderer->GL_UnbindTexture = VITA_GLES2_UnbindTexture;
-
-// TODO. See shaders
-// renderer->info.texture_formats[renderer->info.num_texture_formats++] = SDL_PIXELFORMAT_YV12;
-// renderer->info.texture_formats[renderer->info.num_texture_formats++] = SDL_PIXELFORMAT_IYUV;
-// renderer->info.texture_formats[renderer->info.num_texture_formats++] = SDL_PIXELFORMAT_NV12;
-// renderer->info.texture_formats[renderer->info.num_texture_formats++] = SDL_PIXELFORMAT_NV21;
-
- /* Set up parameters for rendering */
- data->glActiveTexture(GL_TEXTURE0);
- data->glPixelStorei(GL_PACK_ALIGNMENT, 1);
- data->glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
-
- data->glEnableVertexAttribArray(VITA_GLES2_ATTRIBUTE_POSITION);
- data->glDisableVertexAttribArray(VITA_GLES2_ATTRIBUTE_TEXCOORD);
-
- data->glClearColor(1.0f, 1.0f, 1.0f, 1.0f);
-
- data->drawstate.blend = SDL_BLENDMODE_INVALID;
- data->drawstate.color = 0xFFFFFFFF;
- data->drawstate.clear_color = 0xFFFFFFFF;
- data->drawstate.projection[3][0] = -1.0f;
- data->drawstate.projection[3][3] = 1.0f;
-
- GL_CheckError("", renderer);
-
- return renderer;
-
-error:
- return NULL;
-}
-
-SDL_RenderDriver VITA_GLES2_RenderDriver = {
- VITA_GLES2_CreateRenderer,
- {
- "VITA gles2",
- (SDL_RENDERER_ACCELERATED | SDL_RENDERER_PRESENTVSYNC | SDL_RENDERER_TARGETTEXTURE),
- 4,
- {
- SDL_PIXELFORMAT_ARGB8888,
- SDL_PIXELFORMAT_ABGR8888,
- SDL_PIXELFORMAT_RGB888,
- SDL_PIXELFORMAT_BGR888
- },
- 0,
- 0
- }
-};
-
-#endif /* SDL_VIDEO_RENDER_VITA_GLES2 && !SDL_RENDER_DISABLED */
-
-/* vi: set ts=4 sw=4 expandtab: */
diff --git a/src/render/vitagles2/SDL_shaders_gles2vita.c b/src/render/vitagles2/SDL_shaders_gles2vita.c
deleted file mode 100644
index 87ad13d..0000000
--- a/src/render/vitagles2/SDL_shaders_gles2vita.c
+++ /dev/null
@@ -1,563 +0,0 @@
-/*
- Simple DirectMedia Layer
- Copyright (C) 1997-2020 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_RENDER_VITA_GLES2 && !SDL_RENDER_DISABLED
-
-#include "SDL_video.h"
-#include "SDL_opengles2.h"
-#include "SDL_shaders_gles2vita.h"
-#include "SDL_stdinc.h"
-
-/* While Vita is gles2-compliant, shaders should be in Cg format, not glsl */
-
-/*************************************************************************************************
- * Vertex/fragment shader source *
- *************************************************************************************************/
-/* Notes on a_angle:
- * It is a vector containing sin and cos for rotation matrix
- * To get correct rotation for most cases when a_angle is disabled cos
- value is decremented by 1.0 to get proper output with 0.0 which is
- default value
-*/
-static const Uint8 VITA_GLES2_VertexSrc_Default_[] = " \
- struct _Output { \
- float2 v_texCoord : TEXCOORD0; \
- float4 position : POSITION; \
- float pointsize : PSIZE; \
- }; \
-\
- _Output main( \
- uniform float4x4 u_projection, \
- float2 a_position, \
- float2 a_texCoord, \
- float2 a_angle, \
- float2 a_center \
- ) \
- { \
- _Output OUT; \
-\
- float s = a_angle[0]; \
- float c = a_angle[1] + 1.0; \
- float2x2 rotationMatrix = float2x2(c, s, -s, c); \
- float2 position = mul((a_position - a_center) + a_center, rotationMatrix); \
-\
- OUT.v_texCoord = a_texCoord; \
- OUT.position = mul(float4(position, 0.0, 1.0), u_projection);\
- OUT.pointsize = 1.0; \
- return OUT; \
- } \
-";
-
-static const Uint8 VITA_GLES2_FragmentSrc_SolidSrc_[] = " \
- float4 main(uniform float4 u_color : COLOR) : COLOR \
- { \
- return u_color; \
- } \
-";
-
-static const Uint8 VITA_GLES2_FragmentSrc_TextureABGRSrc_[] = " \
- float4 main(uniform sampler2D u_texture, uniform float4 u_color : COLOR, float2 v_texCoord : TEXCOORD0 ) : COLOR \
- { \
- float4 color = tex2D(u_texture, v_texCoord); \
- return color * u_color; \
- } \
-";
-
-/* ARGB to ABGR conversion */
-static const Uint8 VITA_GLES2_FragmentSrc_TextureARGBSrc_[] = " \
- float4 main(uniform sampler2D u_texture, uniform float4 u_color : COLOR, float2 v_texCoord : TEXCOORD0 ) : COLOR \
- { \
- float4 abgr = tex2D(u_texture, v_texCoord); \
- float4 color = abgr; \
- color.r = abgr.b; \
- color.b = abgr.r; \
- return color * u_color; \
- } \
-";
-
-/* RGB to ABGR conversion */
-static const Uint8 VITA_GLES2_FragmentSrc_TextureRGBSrc_[] = " \
- float4 main(uniform sampler2D u_texture, uniform float4 u_color : COLOR, float2 v_texCoord : TEXCOORD0 ) : COLOR \
- { \
- float4 abgr = tex2D(u_texture, v_texCoord); \
- float4 color = abgr; \
- color.r = abgr.b; \
- color.b = abgr.r; \
- color.a = 1.0; \
- return color * u_color; \
- } \
-";
-
-/* BGR to ABGR conversion */
-static const Uint8 VITA_GLES2_FragmentSrc_TextureBGRSrc_[] = " \
- float4 main(uniform sampler2D u_texture, uniform float4 u_color : COLOR, float2 v_texCoord : TEXCOORD0 ) : COLOR \
- { \
- float4 abgr = tex2D(u_texture, v_texCoord); \
- float4 color = abgr; \
- color.a = 1.0; \
- return color * u_color; \
- } \
-";
-
-// VITA : TODO
-
-#define JPEG_SHADER_CONSTANTS \
-"// YUV offset \n" \
-"const vec3 offset = vec3(0, -0.501960814, -0.501960814);\n" \
-"\n" \
-"// RGB coefficients \n" \
-"const mat3 matrix = mat3( 1, 1, 1,\n" \
-" 0, -0.3441, 1.772,\n" \
-" 1.402, -0.7141, 0);\n" \
-
-#define BT601_SHADER_CONSTANTS \
-"// YUV offset \n" \
-"const vec3 offset = vec3(-0.0627451017, -0.501960814, -0.501960814);\n" \
-"\n" \
-"// RGB coefficients \n" \
-"const mat3 matrix = mat3( 1.1644, 1.1644, 1.1644,\n" \
-" 0, -0.3918, 2.0172,\n" \
-" 1.596, -0.813, 0);\n" \
-
-#define BT709_SHADER_CONSTANTS \
-"// YUV offset \n" \
-"const vec3 offset = vec3(-0.0627451017, -0.501960814, -0.501960814);\n" \
-"\n" \
-"// RGB coefficients \n" \
-"const mat3 matrix = mat3( 1.1644, 1.1644, 1.1644,\n" \
-" 0, -0.2132, 2.1124,\n" \
-" 1.7927, -0.5329, 0);\n" \
-
-
-#define YUV_SHADER_PROLOGUE \
-"precision mediump float;\n" \
-"uniform sampler2D u_texture;\n" \
-"uniform sampler2D u_texture_u;\n" \
-"uniform sampler2D u_texture_v;\n" \
-"uniform vec4 u_color;\n" \
-"varying vec2 v_texCoord;\n" \
-"\n" \
-
-#define YUV_SHADER_BODY \
-"\n" \
-"void main()\n" \
-"{\n" \
-" mediump vec3 yuv;\n" \
-" lowp vec3 rgb;\n" \
-"\n" \
-" // Get the YUV values \n" \
-" yuv.x = texture2D(u_texture, v_texCoord).r;\n" \
-" yuv.y = texture2D(u_texture_u, v_texCoord).r;\n" \
-" yuv.z = texture2D(u_texture_v, v_texCoord).r;\n" \
-"\n" \
-" // Do the color transform \n" \
-" yuv += offset;\n" \
-" rgb = matrix * yuv;\n" \
-"\n" \
-" // That was easy. :) \n" \
-" gl_FragColor = vec4(rgb, 1);\n" \
-" gl_FragColor *= u_color;\n" \
-"}" \
-
-#define NV12_SHADER_BODY \
-"\n" \
-"void main()\n" \
-"{\n" \
-" mediump vec3 yuv;\n" \
-" lowp vec3 rgb;\n" \
-"\n" \
-" // Get the YUV values \n" \
-" yuv.x = texture2D(u_texture, v_texCoord).r;\n" \
-" yuv.yz = texture2D(u_texture_u, v_texCoord).ra;\n" \
-"\n" \
-" // Do the color transform \n" \
-" yuv += offset;\n" \
-" rgb = matrix * yuv;\n" \
-"\n" \
-" // That was easy. :) \n" \
-" gl_FragColor = vec4(rgb, 1);\n" \
-" gl_FragColor *= u_color;\n" \
-"}" \
-
-#define NV21_SHADER_BODY \
-"\n" \
-"void main()\n" \
-"{\n" \
-" mediump vec3 yuv;\n" \
-" lowp vec3 rgb;\n" \
-"\n" \
-" // Get the YUV values \n" \
-" yuv.x = texture2D(u_texture, v_texCoord).r;\n" \
-" yuv.yz = texture2D(u_texture_u, v_texCoord).ar;\n" \
-"\n" \
-" // Do the color transform \n" \
-" yuv += offset;\n" \
-" rgb = matrix * yuv;\n" \
-"\n" \
-" // That was easy. :) \n" \
-" gl_FragColor = vec4(rgb, 1);\n" \
-" gl_FragColor *= u_color;\n" \
-"}" \
-
-/* YUV to ABGR conversion */
-static const Uint8 VITA_GLES2_FragmentSrc_TextureYUVJPEGSrc_[] = \
- YUV_SHADER_PROLOGUE \
- JPEG_SHADER_CONSTANTS \
- YUV_SHADER_BODY \
-;
-static const Uint8 VITA_GLES2_FragmentSrc_TextureYUVBT601Src_[] = \
- YUV_SHADER_PROLOGUE \
- BT601_SHADER_CONSTANTS \
- YUV_SHADER_BODY \
-;
-static const Uint8 VITA_GLES2_FragmentSrc_TextureYUVBT709Src_[] = \
- YUV_SHADER_PROLOGUE \
- BT709_SHADER_CONSTANTS \
- YUV_SHADER_BODY \
-;
-
-/* NV12 to ABGR conversion */
-static const Uint8 VITA_GLES2_FragmentSrc_TextureNV12JPEGSrc_[] = \
- YUV_SHADER_PROLOGUE \
- JPEG_SHADER_CONSTANTS \
- NV12_SHADER_BODY \
-;
-static const Uint8 VITA_GLES2_FragmentSrc_TextureNV12BT601Src_[] = \
- YUV_SHADER_PROLOGUE \
- BT601_SHADER_CONSTANTS \
- NV12_SHADER_BODY \
-;
-static const Uint8 VITA_GLES2_FragmentSrc_TextureNV12BT709Src_[] = \
- YUV_SHADER_PROLOGUE \
- BT709_SHADER_CONSTANTS \
- NV12_SHADER_BODY \
-;
-
-/* NV21 to ABGR conversion */
-static const Uint8 VITA_GLES2_FragmentSrc_TextureNV21JPEGSrc_[] = \
- YUV_SHADER_PROLOGUE \
- JPEG_SHADER_CONSTANTS \
- NV21_SHADER_BODY \
-;
-static const Uint8 VITA_GLES2_FragmentSrc_TextureNV21BT601Src_[] = \
- YUV_SHADER_PROLOGUE \
- BT601_SHADER_CONSTANTS \
- NV21_SHADER_BODY \
-;
-static const Uint8 VITA_GLES2_FragmentSrc_TextureNV21BT709Src_[] = \
- YUV_SHADER_PROLOGUE \
- BT709_SHADER_CONSTANTS \
- NV21_SHADER_BODY \
-;
-
-/* Custom Android video format texture */
-static const Uint8 VITA_GLES2_FragmentSrc_TextureExternalOESSrc_[] = " \
- #extension GL_OES_EGL_image_external : require\n\
- precision mediump float; \
- uniform samplerExternalOES u_texture; \
- uniform vec4 u_color; \
- varying vec2 v_texCoord; \
- \
- void main() \
- { \
- gl_FragColor = texture2D(u_texture, v_texCoord); \
- gl_FragColor *= u_color; \
- } \
-";
-
-static const VITA_GLES2_ShaderInstance VITA_GLES2_VertexSrc_Default = {
- GL_VERTEX_SHADER,
- VITA_GLES2_SOURCE_SHADER,
- sizeof(VITA_GLES2_VertexSrc_Default_),
- VITA_GLES2_VertexSrc_Default_
-};
-
-static const VITA_GLES2_ShaderInstance VITA_GLES2_FragmentSrc_SolidSrc = {
- GL_FRAGMENT_SHADER,
- VITA_GLES2_SOURCE_SHADER,
- sizeof(VITA_GLES2_FragmentSrc_SolidSrc_),
- VITA_GLES2_FragmentSrc_SolidSrc_
-};
-
-static const VITA_GLES2_ShaderInstance VITA_GLES2_FragmentSrc_TextureABGRSrc = {
- GL_FRAGMENT_SHADER,
- VITA_GLES2_SOURCE_SHADER,
- sizeof(VITA_GLES2_FragmentSrc_TextureABGRSrc_),
- VITA_GLES2_FragmentSrc_TextureABGRSrc_
-};
-
-static const VITA_GLES2_ShaderInstance VITA_GLES2_FragmentSrc_TextureARGBSrc = {
- GL_FRAGMENT_SHADER,
- VITA_GLES2_SOURCE_SHADER,
- sizeof(VITA_GLES2_FragmentSrc_TextureARGBSrc_),
- VITA_GLES2_FragmentSrc_TextureARGBSrc_
-};
-
-static const VITA_GLES2_ShaderInstance VITA_GLES2_FragmentSrc_TextureRGBSrc = {
- GL_FRAGMENT_SHADER,
- VITA_GLES2_SOURCE_SHADER,
- sizeof(VITA_GLES2_FragmentSrc_TextureRGBSrc_),
- VITA_GLES2_FragmentSrc_TextureRGBSrc_
-};
-
-static const VITA_GLES2_ShaderInstance VITA_GLES2_FragmentSrc_TextureBGRSrc = {
- GL_FRAGMENT_SHADER,
- VITA_GLES2_SOURCE_SHADER,
- sizeof(VITA_GLES2_FragmentSrc_TextureBGRSrc_),
- VITA_GLES2_FragmentSrc_TextureBGRSrc_
-};
-
-static const VITA_GLES2_ShaderInstance VITA_GLES2_FragmentSrc_TextureYUVJPEGSrc = {
- GL_FRAGMENT_SHADER,
- VITA_GLES2_SOURCE_SHADER,
- sizeof(VITA_GLES2_FragmentSrc_TextureYUVJPEGSrc_),
- VITA_GLES2_FragmentSrc_TextureYUVJPEGSrc_
-};
-
-static const VITA_GLES2_ShaderInstance VITA_GLES2_FragmentSrc_TextureYUVBT601Src = {
- GL_FRAGMENT_SHADER,
- VITA_GLES2_SOURCE_SHADER,
- sizeof(VITA_GLES2_FragmentSrc_TextureYUVBT601Src_),
- VITA_GLES2_FragmentSrc_TextureYUVBT601Src_
-};
-
-static const VITA_GLES2_ShaderInstance VITA_GLES2_FragmentSrc_TextureYUVBT709Src = {
- GL_FRAGMENT_SHADER,
- VITA_GLES2_SOURCE_SHADER,
- sizeof(VITA_GLES2_FragmentSrc_TextureYUVBT709Src_),
- VITA_GLES2_FragmentSrc_TextureYUVBT709Src_
-};
-
-static const VITA_GLES2_ShaderInstance VITA_GLES2_FragmentSrc_TextureNV12JPEGSrc = {
- GL_FRAGMENT_SHADER,
- VITA_GLES2_SOURCE_SHADER,
- sizeof(VITA_GLES2_FragmentSrc_TextureNV12JPEGSrc_),
- VITA_GLES2_FragmentSrc_TextureNV12JPEGSrc_
-};
-
-static const VITA_GLES2_ShaderInstance VITA_GLES2_FragmentSrc_TextureNV12BT601Src = {
- GL_FRAGMENT_SHADER,
- VITA_GLES2_SOURCE_SHADER,
- sizeof(VITA_GLES2_FragmentSrc_TextureNV12BT601Src_),
- VITA_GLES2_FragmentSrc_TextureNV12BT601Src_
-};
-
-static const VITA_GLES2_ShaderInstance VITA_GLES2_FragmentSrc_TextureNV21BT709Src = {
- GL_FRAGMENT_SHADER,
- VITA_GLES2_SOURCE_SHADER,
- sizeof(VITA_GLES2_FragmentSrc_TextureNV21BT709Src_),
- VITA_GLES2_FragmentSrc_TextureNV21BT709Src_
-};
-
-static const VITA_GLES2_ShaderInstance VITA_GLES2_FragmentSrc_TextureNV21JPEGSrc = {
- GL_FRAGMENT_SHADER,
- VITA_GLES2_SOURCE_SHADER,
- sizeof(VITA_GLES2_FragmentSrc_TextureNV21JPEGSrc_),
- VITA_GLES2_FragmentSrc_TextureNV21JPEGSrc_
-};
-
-static const VITA_GLES2_ShaderInstance VITA_GLES2_FragmentSrc_TextureNV21BT601Src = {
- GL_FRAGMENT_SHADER,
- VITA_GLES2_SOURCE_SHADER,
- sizeof(VITA_GLES2_FragmentSrc_TextureNV21BT601Src_),
- VITA_GLES2_FragmentSrc_TextureNV21BT601Src_
-};
-
-static const VITA_GLES2_ShaderInstance VITA_GLES2_FragmentSrc_TextureNV12BT709Src = {
- GL_FRAGMENT_SHADER,
- VITA_GLES2_SOURCE_SHADER,
- sizeof(VITA_GLES2_FragmentSrc_TextureNV12BT709Src_),
- VITA_GLES2_FragmentSrc_TextureNV12BT709Src_
-};
-
-static const VITA_GLES2_ShaderInstance VITA_GLES2_FragmentSrc_TextureExternalOESSrc = {
- GL_FRAGMENT_SHADER,
- VITA_GLES2_SOURCE_SHADER,
- sizeof(VITA_GLES2_FragmentSrc_TextureExternalOESSrc_),
- VITA_GLES2_FragmentSrc_TextureExternalOESSrc_
-};
-
-
-/*************************************************************************************************
- * Vertex/fragment shader definitions *
- *************************************************************************************************/
-
-static VITA_GLES2_Shader VITA_GLES2_VertexShader_Default = {
- 1,
- {
- &VITA_GLES2_VertexSrc_Default
- }
-};
-
-static VITA_GLES2_Shader VITA_GLES2_FragmentShader_SolidSrc = {
- 1,
- {
- &VITA_GLES2_FragmentSrc_SolidSrc
- }
-};
-
-static VITA_GLES2_Shader VITA_GLES2_FragmentShader_TextureABGRSrc = {
- 1,
- {
- &VITA_GLES2_FragmentSrc_TextureABGRSrc
- }
-};
-
-static VITA_GLES2_Shader VITA_GLES2_FragmentShader_TextureARGBSrc = {
- 1,
- {
- &VITA_GLES2_FragmentSrc_TextureARGBSrc
- }
-};
-
-static VITA_GLES2_Shader VITA_GLES2_FragmentShader_TextureRGBSrc = {
- 1,
- {
- &VITA_GLES2_FragmentSrc_TextureRGBSrc
- }
-};
-
-static VITA_GLES2_Shader VITA_GLES2_FragmentShader_TextureBGRSrc = {
- 1,
- {
- &VITA_GLES2_FragmentSrc_TextureBGRSrc
- }
-};
-
-static VITA_GLES2_Shader VITA_GLES2_FragmentShader_TextureYUVJPEGSrc = {
- 1,
- {
- &VITA_GLES2_FragmentSrc_TextureYUVJPEGSrc
- }
-};
-
-static VITA_GLES2_Shader VITA_GLES2_FragmentShader_TextureYUVBT601Src = {
- 1,
- {
- &VITA_GLES2_FragmentSrc_TextureYUVBT601Src
- }
-};
-
-static VITA_GLES2_Shader VITA_GLES2_FragmentShader_TextureYUVBT709Src = {
- 1,
- {
- &VITA_GLES2_FragmentSrc_TextureYUVBT709Src
- }
-};
-
-static VITA_GLES2_Shader VITA_GLES2_FragmentShader_TextureNV12JPEGSrc = {
- 1,
- {
- &VITA_GLES2_FragmentSrc_TextureNV12JPEGSrc
- }
-};
-
-static VITA_GLES2_Shader VITA_GLES2_FragmentShader_TextureNV12BT601Src = {
- 1,
- {
- &VITA_GLES2_FragmentSrc_TextureNV12BT601Src
- }
-};
-
-static VITA_GLES2_Shader VITA_GLES2_FragmentShader_TextureNV12BT709Src = {
- 1,
- {
- &VITA_GLES2_FragmentSrc_TextureNV12BT709Src
- }
-};
-
-static VITA_GLES2_Shader VITA_GLES2_FragmentShader_TextureNV21JPEGSrc = {
- 1,
- {
- &VITA_GLES2_FragmentSrc_TextureNV21JPEGSrc
- }
-};
-
-static VITA_GLES2_Shader VITA_GLES2_FragmentShader_TextureNV21BT601Src = {
- 1,
- {
- &VITA_GLES2_FragmentSrc_TextureNV21BT601Src
- }
-};
-
-static VITA_GLES2_Shader VITA_GLES2_FragmentShader_TextureNV21BT709Src = {
- 1,
- {
- &VITA_GLES2_FragmentSrc_TextureNV21BT709Src
- }
-};
-
-static VITA_GLES2_Shader VITA_GLES2_FragmentShader_TextureExternalOESSrc = {
- 1,
- {
- &VITA_GLES2_FragmentSrc_TextureExternalOESSrc
- }
-};
-
-
-/*************************************************************************************************
- * Shader selector *
- *************************************************************************************************/
-
-const VITA_GLES2_Shader *VITA_GLES2_GetShader(VITA_GLES2_ShaderType type)
-{
- switch (type) {
- case VITA_GLES2_SHADER_VERTEX_DEFAULT:
- return &VITA_GLES2_VertexShader_Default;
- case VITA_GLES2_SHADER_FRAGMENT_SOLID_SRC:
- return &VITA_GLES2_FragmentShader_SolidSrc;
- case VITA_GLES2_SHADER_FRAGMENT_TEXTURE_ABGR_SRC:
- return &VITA_GLES2_FragmentShader_TextureABGRSrc;
- case VITA_GLES2_SHADER_FRAGMENT_TEXTURE_ARGB_SRC:
- return &VITA_GLES2_FragmentShader_TextureARGBSrc;
- case VITA_GLES2_SHADER_FRAGMENT_TEXTURE_RGB_SRC:
- return &VITA_GLES2_FragmentShader_TextureRGBSrc;
- case VITA_GLES2_SHADER_FRAGMENT_TEXTURE_BGR_SRC:
- return &VITA_GLES2_FragmentShader_TextureBGRSrc;
- case VITA_GLES2_SHADER_FRAGMENT_TEXTURE_YUV_JPEG_SRC:
- return &VITA_GLES2_FragmentShader_TextureYUVJPEGSrc;
- case VITA_GLES2_SHADER_FRAGMENT_TEXTURE_YUV_BT601_SRC:
- return &VITA_GLES2_FragmentShader_TextureYUVBT601Src;
- case VITA_GLES2_SHADER_FRAGMENT_TEXTURE_YUV_BT709_SRC:
- return &VITA_GLES2_FragmentShader_TextureYUVBT709Src;
- case VITA_GLES2_SHADER_FRAGMENT_TEXTURE_NV12_JPEG_SRC:
- return &VITA_GLES2_FragmentShader_TextureNV12JPEGSrc;
- case VITA_GLES2_SHADER_FRAGMENT_TEXTURE_NV12_BT601_SRC:
- return &VITA_GLES2_FragmentShader_TextureNV12BT601Src;
- case VITA_GLES2_SHADER_FRAGMENT_TEXTURE_NV12_BT709_SRC:
- return &VITA_GLES2_FragmentShader_TextureNV12BT709Src;
- case VITA_GLES2_SHADER_FRAGMENT_TEXTURE_NV21_JPEG_SRC:
- return &VITA_GLES2_FragmentShader_TextureNV21JPEGSrc;
- case VITA_GLES2_SHADER_FRAGMENT_TEXTURE_NV21_BT601_SRC:
- return &VITA_GLES2_FragmentShader_TextureNV21BT601Src;
- case VITA_GLES2_SHADER_FRAGMENT_TEXTURE_NV21_BT709_SRC:
- return &VITA_GLES2_FragmentShader_TextureNV21BT709Src;
- case VITA_GLES2_SHADER_FRAGMENT_TEXTURE_EXTERNAL_OES_SRC:
- return &VITA_GLES2_FragmentShader_TextureExternalOESSrc;
- default:
- return NULL;
- }
-}
-
-#endif /* SDL_VIDEO_RENDER_VITA_GLES2 && !SDL_RENDER_DISABLED */
-
-/* vi: set ts=4 sw=4 expandtab: */
diff --git a/src/render/vitagles2/SDL_shaders_gles2vita.h b/src/render/vitagles2/SDL_shaders_gles2vita.h
deleted file mode 100644
index dd70915..0000000
--- a/src/render/vitagles2/SDL_shaders_gles2vita.h
+++ /dev/null
@@ -1,70 +0,0 @@
-/*
- Simple DirectMedia Layer
- Copyright (C) 1997-2020 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_shaders_gles2vita_h_
-#define SDL_shaders_gles2vita_h_
-
-#if SDL_VIDEO_RENDER_VITA_GLES2
-
-typedef struct VITA_GLES2_ShaderInstance
-{
- GLenum type;
- GLenum format;
- int length;
- const void *data;
-} VITA_GLES2_ShaderInstance;
-
-typedef struct VITA_GLES2_Shader
-{
- int instance_count;
- const VITA_GLES2_ShaderInstance *instances[4];
-} VITA_GLES2_Shader;
-
-typedef enum
-{
- VITA_GLES2_SHADER_VERTEX_DEFAULT,
- VITA_GLES2_SHADER_FRAGMENT_SOLID_SRC,
- VITA_GLES2_SHADER_FRAGMENT_TEXTURE_ABGR_SRC,
- VITA_GLES2_SHADER_FRAGMENT_TEXTURE_ARGB_SRC,
- VITA_GLES2_SHADER_FRAGMENT_TEXTURE_BGR_SRC,
- VITA_GLES2_SHADER_FRAGMENT_TEXTURE_RGB_SRC,
- VITA_GLES2_SHADER_FRAGMENT_TEXTURE_YUV_JPEG_SRC,
- VITA_GLES2_SHADER_FRAGMENT_TEXTURE_YUV_BT601_SRC,
- VITA_GLES2_SHADER_FRAGMENT_TEXTURE_YUV_BT709_SRC,
- VITA_GLES2_SHADER_FRAGMENT_TEXTURE_NV12_JPEG_SRC,
- VITA_GLES2_SHADER_FRAGMENT_TEXTURE_NV12_BT601_SRC,
- VITA_GLES2_SHADER_FRAGMENT_TEXTURE_NV12_BT709_SRC,
- VITA_GLES2_SHADER_FRAGMENT_TEXTURE_NV21_JPEG_SRC,
- VITA_GLES2_SHADER_FRAGMENT_TEXTURE_NV21_BT601_SRC,
- VITA_GLES2_SHADER_FRAGMENT_TEXTURE_NV21_BT709_SRC,
- VITA_GLES2_SHADER_FRAGMENT_TEXTURE_EXTERNAL_OES_SRC
-} VITA_GLES2_ShaderType;
-
-#define VITA_GLES2_SOURCE_SHADER (GLenum)-1
-
-const VITA_GLES2_Shader *VITA_GLES2_GetShader(VITA_GLES2_ShaderType type);
-
-#endif /* SDL_VIDEO_RENDER_VITA_GLES2 */
-
-#endif /* SDL_shaders_gles2vita_h_ */
-
-/* vi: set ts=4 sw=4 expandtab: */