Remove vita2d render, add raw gxm 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 2866 2867 2868 2869 2870 2871 2872 2873 2874 2875 2876 2877 2878 2879 2880 2881 2882 2883 2884 2885 2886 2887 2888 2889 2890 2891 2892 2893 2894 2895 2896 2897 2898 2899 2900 2901 2902 2903 2904 2905 2906 2907 2908 2909 2910 2911 2912 2913 2914 2915 2916 2917 2918 2919 2920 2921 2922 2923 2924 2925 2926 2927 2928 2929 2930 2931 2932 2933 2934 2935 2936 2937 2938 2939 2940 2941 2942 2943 2944 2945 2946 2947 2948 2949 2950 2951 2952 2953 2954 2955 2956 2957 2958 2959 2960 2961 2962 2963 2964 2965 2966 2967 2968 2969 2970 2971 2972 2973 2974 2975 2976 2977 2978 2979 2980 2981 2982 2983 2984 2985 2986 2987 2988 2989 2990 2991 2992 2993 2994 2995 2996 2997 2998 2999 3000 3001 3002 3003 3004 3005 3006 3007 3008 3009 3010 3011 3012 3013 3014 3015 3016 3017 3018 3019 3020 3021 3022 3023 3024 3025 3026 3027 3028 3029 3030 3031 3032 3033 3034 3035 3036 3037 3038 3039 3040 3041 3042 3043 3044 3045 3046 3047 3048 3049 3050 3051 3052 3053 3054 3055 3056 3057 3058 3059 3060 3061 3062 3063 3064 3065 3066 3067 3068 3069 3070 3071 3072 3073 3074 3075 3076 3077 3078 3079 3080 3081 3082 3083 3084 3085 3086 3087 3088 3089 3090 3091 3092 3093 3094 3095 3096 3097 3098 3099 3100 3101 3102 3103 3104 3105 3106 3107 3108 3109 3110 3111 3112 3113 3114 3115 3116 3117 3118 3119 3120 3121 3122 3123 3124 3125 3126 3127 3128 3129 3130 3131 3132 3133 3134 3135 3136 3137 3138 3139 3140 3141 3142 3143 3144 3145 3146 3147 3148 3149 3150 3151 3152 3153 3154 3155 3156 3157 3158 3159 3160 3161 3162 3163 3164 3165 3166 3167 3168 3169 3170 3171 3172 3173 3174 3175 3176 3177 3178 3179 3180 3181 3182 3183 3184 3185 3186 3187 3188 3189 3190 3191 3192 3193 3194 3195 3196 3197 3198 3199 3200 3201 3202 3203 3204 3205 3206 3207 3208 3209 3210 3211 3212 3213 3214 3215 3216 3217 3218 3219 3220 3221 3222 3223 3224 3225 3226 3227 3228 3229 3230 3231 3232 3233 3234 3235 3236 3237 3238 3239 3240 3241 3242 3243 3244 3245 3246 3247 3248 3249 3250 3251 3252 3253 3254 3255 3256 3257 3258 3259 3260 3261 3262 3263 3264 3265 3266 3267 3268 3269 3270 3271 3272 3273 3274 3275 3276 3277 3278 3279 3280 3281 3282 3283 3284 3285 3286 3287 3288 3289 3290 3291 3292 3293 3294 3295 3296 3297 3298 3299 3300 3301 3302 3303 3304 3305 3306 3307 3308 3309 3310 3311 3312 3313 3314 3315 3316 3317 3318 3319 3320 3321 3322 3323 3324 3325 3326 3327 3328 3329 3330 3331 3332 3333 3334 3335 3336 3337 3338 3339 3340 3341 3342 3343 3344 3345 3346 3347 3348 3349 3350 3351 3352 3353 3354 3355 3356 3357 3358 3359 3360 3361 3362 3363 3364 3365 3366 3367 3368 3369 3370 3371 3372 3373 3374 3375 3376 3377 3378 3379 3380 3381 3382 3383 3384 3385 3386 3387 3388 3389 3390 3391 3392 3393 3394 3395 3396 3397 3398 3399 3400 3401 3402 3403 3404 3405 3406 3407 3408 3409 3410 3411 3412 3413 3414 3415 3416 3417 3418 3419 3420 3421 3422 3423 3424 3425 3426 3427 3428 3429 3430 3431 3432 3433 3434 3435 3436 3437 3438 3439 3440 3441 3442 3443 3444 3445 3446 3447 3448 3449 3450 3451 3452 3453 3454 3455 3456 3457 3458 3459 3460 3461 3462 3463 3464 3465 3466 3467 3468 3469 3470 3471 3472 3473 3474 3475 3476 3477 3478 3479 3480 3481 3482 3483 3484 3485 3486 3487 3488 3489 3490 3491 3492 3493 3494 3495 3496 3497 3498 3499 3500 3501 3502 3503 3504 3505 3506 3507 3508 3509 3510 3511 3512 3513 3514 3515 3516 3517 3518 3519 3520 3521 3522 3523 3524 3525 3526 3527 3528 3529 3530 3531 3532 3533 3534 3535 3536 3537 3538 3539 3540 3541 3542 3543 3544 3545 3546 3547 3548 3549 3550 3551 3552 3553 3554 3555 3556 3557 3558 3559 3560 3561 3562 3563 3564 3565 3566 3567 3568 3569 3570 3571 3572 3573 3574 3575 3576 3577 3578 3579 3580 3581 3582 3583 3584 3585 3586 3587 3588 3589 3590 3591 3592 3593 3594 3595 3596 3597 3598 3599 3600 3601 3602 3603 3604 3605 3606 3607 3608 3609 3610 3611 3612 3613 3614 3615 3616 3617 3618 3619 3620 3621 3622 3623 3624 3625 3626 3627 3628 3629 3630 3631 3632 3633 3634 3635 3636 3637 3638 3639 3640 3641 3642 3643 3644 3645 3646 3647 3648 3649 3650 3651 3652 3653 3654 3655 3656 3657 3658 3659 3660 3661 3662 3663 3664 3665 3666 3667 3668 3669 3670 3671 3672 3673 3674 3675 3676 3677 3678 3679 3680 3681 3682 3683 3684 3685 3686 3687 3688 3689 3690 3691 3692 3693 3694 3695 3696 3697 3698 3699 3700 3701 3702 3703 3704 3705 3706 3707 3708 3709 3710 3711 3712 3713 3714 3715 3716 3717 3718 3719 3720 3721 3722 3723 3724 3725 3726 3727 3728 3729 3730 3731 3732 3733 3734 3735 3736 3737 3738 3739 3740 3741 3742 3743 3744 3745 3746 3747 3748 3749 3750 3751 3752 3753 3754 3755 3756 3757 3758 3759 3760 3761 3762 3763 3764 3765 3766 3767 3768 3769 3770 3771 3772 3773 3774 3775 3776 3777 3778 3779
diff --git a/Makefile.vita.vita2d.dolce b/Makefile.vita.vita2d.dolce
deleted file mode 100644
index 4325b4a..0000000
--- a/Makefile.vita.vita2d.dolce
+++ /dev/null
@@ -1,58 +0,0 @@
-# Based on port by xerpi
-# Makefile to build the SDL library
-
-TARGET_LIB = libSDL2.a
-
-SOURCES = \
- src/*.c \
- src/atomic/*.c \
- src/audio/*.c \
- src/audio/vita/*.c \
- src/cpuinfo/*.c \
- src/events/*.c \
- src/file/*.c \
- src/haptic/*.c \
- src/haptic/dummy/*.c \
- src/joystick/*.c \
- src/joystick/vita/*.c \
- src/loadso/dummy/*.c \
- src/power/*.c \
- src/power/vita/*.c \
- src/filesystem/vita/*.c \
- src/render/*.c \
- src/render/software/*.c \
- src/render/vita2d/*.c \
- src/sensor/*.c \
- src/sensor/dummy/*.c \
- src/stdlib/*.c \
- src/thread/*.c \
- src/thread/generic/SDL_systls.c \
- src/thread/vita/*.c \
- src/timer/*.c \
- src/timer/vita/*.c \
- src/video/*.c \
- src/video/vita/*.c \
- src/video/yuv2rgb/*.c \
-
-OBJS = $(shell echo $(SOURCES) | sed -e 's,\.c,\.o,g')
-
-PREFIX = arm-dolce-eabi
-CC = $(PREFIX)-gcc
-AR = $(PREFIX)-ar
-CFLAGS = -g -Wl,-q -Wall -O3 -Iinclude \
- -D__VITA__ -D__ARM_ARCH=7 -D__ARM_ARCH_7A__ \
- -mfpu=neon -mcpu=cortex-a9 -mfloat-abi=hard
-ASFLAGS = $(CFLAGS)
-
-$(TARGET_LIB): $(OBJS)
- $(AR) rcs $@ $^
-
-clean:
- @rm -f $(TARGET_LIB) $(OBJS)
-
-install: $(TARGET_LIB)
- @mkdir -p "$(DOLCESDK)/arm-dolce-eabi/lib"
- @cp $(TARGET_LIB) $(DOLCESDK)/arm-dolce-eabi/lib
- @mkdir -p "$(DOLCESDK)/arm-dolce-eabi/include/SDL2"
- @cp include/*.h "$(DOLCESDK)/arm-dolce-eabi/include/SDL2"
- @echo "Installed!"
diff --git a/include/SDL_config_vita.h b/include/SDL_config_vita.h
index 5c14b50..6b12108 100644
--- a/include/SDL_config_vita.h
+++ b/include/SDL_config_vita.h
@@ -140,8 +140,7 @@
//#define SDL_VIDEO_RENDER_VITA_GLES2 1
-//#define SDL_VIDEO_RENDER_VITA_GXM 1
-#define SDL_VIDEO_RENDER_VITA_VITA2D 1
+#define SDL_VIDEO_RENDER_VITA_GXM 1
#if defined(SDL_VIDEO_RENDER_VITA_GLES2) || defined(SDL_VIDEO_RENDER_VITA_GXM)
#define SDL_VIDEO_OPENGL_ES2 1
diff --git a/src/render/SDL_render.c b/src/render/SDL_render.c
index 40f7f5a..b5cf9c5 100644
--- a/src/render/SDL_render.c
+++ b/src/render/SDL_render.c
@@ -110,9 +110,6 @@ static const SDL_RenderDriver *render_drivers[] = {
#if SDL_VIDEO_RENDER_VITA_GXM
&VITA_GXM_RenderDriver,
#endif
-#if SDL_VIDEO_RENDER_VITA_VITA2D
- &VITA_VITA2D_RenderDriver,
-#endif
#if SDL_VIDEO_RENDER_SW
&SW_RenderDriver
#endif
diff --git a/src/render/SDL_sysrender.h b/src/render/SDL_sysrender.h
index 31bdb8e..8441108 100644
--- a/src/render/SDL_sysrender.h
+++ b/src/render/SDL_sysrender.h
@@ -252,7 +252,6 @@ extern SDL_RenderDriver PSP_RenderDriver;
extern SDL_RenderDriver SW_RenderDriver;
extern SDL_RenderDriver VITA_GLES2_RenderDriver;
extern SDL_RenderDriver VITA_GXM_RenderDriver;
-extern SDL_RenderDriver VITA_VITA2D_RenderDriver;
/* Blend mode functions */
extern SDL_BlendFactor SDL_GetBlendModeSrcColorFactor(SDL_BlendMode blendMode);
diff --git a/src/render/vita2d/SDL_render_vita_vita2d.c b/src/render/vita2d/SDL_render_vita_vita2d.c
deleted file mode 100644
index 8e49f94..0000000
--- a/src/render/vita2d/SDL_render_vita_vita2d.c
+++ /dev/null
@@ -1,713 +0,0 @@
-/*
- Simple DirectMedia Layer
- Copyright (C) 1997-2015 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_VITA2D
-
-#include "SDL_hints.h"
-#include "../SDL_sysrender.h"
-
-#include <psp2/types.h>
-#include <psp2/display.h>
-#include <psp2/gxm.h>
-#include <psp2/kernel/processmgr.h>
-#include <stdio.h>
-#include <string.h>
-#include <math.h>
-#include <stdarg.h>
-#include <stdlib.h>
-
-#include <vita2d.h>
-
-#define sceKernelDcacheWritebackAll() (void)0
-
-/* VITA renderer implementation, based on the vita2d lib */
-
-extern int SDL_RecreateWindow(SDL_Window *window, Uint32 flags);
-
-static SDL_Renderer *VITA_VITA2D_CreateRenderer(SDL_Window *window, Uint32 flags);
-static void VITA_VITA2D_WindowEvent(SDL_Renderer *renderer, const SDL_WindowEvent *event);
-static SDL_bool VITA_VITA2D_SupportsBlendMode(SDL_Renderer * renderer, SDL_BlendMode blendMode);
-static int VITA_VITA2D_CreateTexture(SDL_Renderer *renderer, SDL_Texture *texture);
-static int VITA_VITA2D_UpdateTexture(SDL_Renderer *renderer, SDL_Texture *texture,
- const SDL_Rect *rect, const void *pixels, int pitch);
-static int VITA_VITA2D_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);
-
-static int VITA_VITA2D_LockTexture(SDL_Renderer *renderer, SDL_Texture *texture,
- const SDL_Rect *rect, void **pixels, int *pitch);
-
-static void VITA_VITA2D_UnlockTexture(SDL_Renderer *renderer,
- SDL_Texture *texture);
-
-static void VITA_VITA2D_SetTextureScaleMode(SDL_Renderer * renderer, SDL_Texture * texture, SDL_ScaleMode scaleMode);
-
-static int VITA_VITA2D_SetRenderTarget(SDL_Renderer *renderer,
- SDL_Texture *texture);
-
-static int VITA_VITA2D_QueueSetViewport(SDL_Renderer * renderer, SDL_RenderCommand *cmd);
-
-static int VITA_VITA2D_QueueSetDrawColor(SDL_Renderer * renderer, SDL_RenderCommand *cmd);
-
-static int VITA_VITA2D_RenderClear(SDL_Renderer *renderer);
-
-static int VITA_VITA2D_QueueDrawPoints(SDL_Renderer * renderer, SDL_RenderCommand *cmd, const SDL_FPoint * points, int count);
-
-static int VITA_VITA2D_RenderDrawPoints(SDL_Renderer *renderer,
- const SDL_FPoint *points, int count);
-
-static int VITA_VITA2D_RenderDrawLines(SDL_Renderer *renderer,
- const SDL_FPoint *points, int count);
-
-static int VITA_VITA2D_QueueFillRects(SDL_Renderer * renderer, SDL_RenderCommand *cmd, const SDL_FRect * rects, int count);
-
-static int VITA_VITA2D_RenderFillRects(SDL_Renderer *renderer,
- const SDL_FRect *rects, int count);
-
-static int VITA_VITA2D_QueueCopy(SDL_Renderer * renderer, SDL_RenderCommand *cmd, SDL_Texture * texture,
- const SDL_Rect * srcrect, const SDL_FRect * dstrect);
-
-static int VITA_VITA2D_RunCommandQueue(SDL_Renderer * renderer, SDL_RenderCommand *cmd, void *vertices, size_t vertsize);
-
-static int VITA_VITA2D_RenderReadPixels(SDL_Renderer *renderer, const SDL_Rect *rect,
- Uint32 pixel_format, void *pixels, int pitch);
-
-static int VITA_VITA2D_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);
-
-static void VITA_VITA2D_RenderPresent(SDL_Renderer *renderer);
-static void VITA_VITA2D_DestroyTexture(SDL_Renderer *renderer, SDL_Texture *texture);
-static void VITA_VITA2D_DestroyRenderer(SDL_Renderer *renderer);
-
-
-SDL_RenderDriver VITA_VITA2D_RenderDriver = {
- .CreateRenderer = VITA_VITA2D_CreateRenderer,
- .info = {
- .name = "VITA",
- .flags = SDL_RENDERER_ACCELERATED | SDL_RENDERER_PRESENTVSYNC,
- .num_texture_formats = 1,
- .texture_formats = {
- [0] = SDL_PIXELFORMAT_ABGR8888,
- },
- .max_texture_width = 1024,
- .max_texture_height = 1024,
- }
-};
-
-#define VITA_VITA2D_SCREEN_WIDTH 960
-#define VITA_VITA2D_SCREEN_HEIGHT 544
-
-#define VITA_VITA2D_FRAME_BUFFER_WIDTH 1024
-#define VITA_VITA2D_FRAME_BUFFER_SIZE (VITA_VITA2D_FRAME_BUFFER_WIDTH*VITA_VITA2D_SCREEN_HEIGHT)
-
-#define COL5650(r,g,b,a) ((r>>3) | ((g>>2)<<5) | ((b>>3)<<11))
-#define COL5551(r,g,b,a) ((r>>3) | ((g>>3)<<5) | ((b>>3)<<10) | (a>0?0x7000:0))
-#define COL4444(r,g,b,a) ((r>>4) | ((g>>4)<<4) | ((b>>4)<<8) | ((a>>4)<<12))
-#define COL8888(r,g,b,a) ((r) | ((g)<<8) | ((b)<<16) | ((a)<<24))
-
-typedef struct
-{
- void *frontbuffer;
- void *backbuffer;
- SDL_bool initialized;
- SDL_bool displayListAvail;
- unsigned int psm;
- unsigned int bpp;
- SDL_bool vsync;
- unsigned int currentColor;
- int currentBlendMode;
-
-} VITA_VITA2D_RenderData;
-
-
-typedef struct
-{
- vita2d_texture *tex;
- unsigned int pitch;
- unsigned int w;
- unsigned int h;
-} VITA_VITA2D_TextureData;
-
-typedef struct
-{
- SDL_Rect srcRect;
- SDL_FRect dstRect;
-} VITA_VITA2D_CopyData;
-
-void
-StartDrawing(SDL_Renderer *renderer)
-{
- VITA_VITA2D_RenderData *data = (VITA_VITA2D_RenderData *) renderer->driverdata;
- if(data->displayListAvail)
- return;
-
- vita2d_start_drawing();
-
- data->displayListAvail = SDL_TRUE;
-}
-
-SDL_Renderer *
-VITA_VITA2D_CreateRenderer(SDL_Window *window, Uint32 flags)
-{
-
- SDL_Renderer *renderer;
- VITA_VITA2D_RenderData *data;
-
- renderer = (SDL_Renderer *) SDL_calloc(1, sizeof(*renderer));
- if (!renderer) {
- SDL_OutOfMemory();
- return NULL;
- }
-
- data = (VITA_VITA2D_RenderData *) SDL_calloc(1, sizeof(*data));
- if (!data) {
- VITA_VITA2D_DestroyRenderer(renderer);
- SDL_OutOfMemory();
- return NULL;
- }
-
- renderer->WindowEvent = VITA_VITA2D_WindowEvent;
- renderer->SupportsBlendMode = VITA_VITA2D_SupportsBlendMode;
- renderer->CreateTexture = VITA_VITA2D_CreateTexture;
- renderer->UpdateTexture = VITA_VITA2D_UpdateTexture;
- renderer->UpdateTextureYUV = VITA_VITA2D_UpdateTextureYUV;
- renderer->LockTexture = VITA_VITA2D_LockTexture;
- renderer->UnlockTexture = VITA_VITA2D_UnlockTexture;
- renderer->SetTextureScaleMode = VITA_VITA2D_SetTextureScaleMode;
- renderer->SetRenderTarget = VITA_VITA2D_SetRenderTarget;
- renderer->QueueSetViewport = VITA_VITA2D_QueueSetViewport;
- renderer->QueueSetDrawColor = VITA_VITA2D_QueueSetDrawColor;
- renderer->QueueDrawPoints = VITA_VITA2D_QueueDrawPoints;
- renderer->QueueDrawLines = VITA_VITA2D_QueueDrawPoints; // lines and points queue the same way.
- renderer->QueueFillRects = VITA_VITA2D_QueueFillRects;
- renderer->QueueCopy = VITA_VITA2D_QueueCopy;
- renderer->QueueCopyEx = VITA_VITA2D_QueueCopyEx;
- renderer->RunCommandQueue = VITA_VITA2D_RunCommandQueue;
- renderer->RenderReadPixels = VITA_VITA2D_RenderReadPixels;
- renderer->RenderPresent = VITA_VITA2D_RenderPresent;
- renderer->DestroyTexture = VITA_VITA2D_DestroyTexture;
- renderer->DestroyRenderer = VITA_VITA2D_DestroyRenderer;
- renderer->info = VITA_VITA2D_RenderDriver.info;
- renderer->info.flags = (SDL_RENDERER_ACCELERATED | SDL_RENDERER_TARGETTEXTURE);
- renderer->driverdata = data;
- renderer->window = window;
-
- if (data->initialized != SDL_FALSE)
- return 0;
- data->initialized = SDL_TRUE;
-
- if (flags & SDL_RENDERER_PRESENTVSYNC) {
- data->vsync = SDL_TRUE;
- } else {
- data->vsync = SDL_FALSE;
- }
-
- vita2d_init();
- vita2d_set_vblank_wait(data->vsync);
-
- return renderer;
-}
-
-static void
-VITA_VITA2D_WindowEvent(SDL_Renderer *renderer, const SDL_WindowEvent *event)
-{
-
-}
-
-static SDL_bool
-VITA_VITA2D_SupportsBlendMode(SDL_Renderer * renderer, SDL_BlendMode blendMode)
-{
- return SDL_FALSE;
-}
-
-static int
-VITA_VITA2D_CreateTexture(SDL_Renderer *renderer, SDL_Texture *texture)
-{
- VITA_VITA2D_TextureData* vita_texture = (VITA_VITA2D_TextureData*) SDL_calloc(1, sizeof(*vita_texture));
-
- if(!vita_texture)
- return -1;
-
- vita_texture->tex = vita2d_create_empty_texture(texture->w, texture->h);
-
- if(!vita_texture->tex)
- {
- SDL_free(vita_texture);
- return SDL_OutOfMemory();
- }
-
- texture->driverdata = vita_texture;
-
- VITA_VITA2D_SetTextureScaleMode(renderer, texture, texture->scaleMode);
-
- vita_texture->w = vita2d_texture_get_width(vita_texture->tex);
- vita_texture->h = vita2d_texture_get_height(vita_texture->tex);
- vita_texture->pitch = vita2d_texture_get_stride(vita_texture->tex);
-
- return 0;
-}
-
-
-static int
-VITA_VITA2D_UpdateTexture(SDL_Renderer *renderer, SDL_Texture *texture,
- const SDL_Rect *rect, const void *pixels, int pitch)
-{
- const Uint8 *src;
- Uint8 *dst;
- int row, length,dpitch;
- src = pixels;
-
- VITA_VITA2D_LockTexture(renderer, texture, rect, (void **)&dst, &dpitch);
- length = rect->w * SDL_BYTESPERPIXEL(texture->format);
- if (length == pitch && length == dpitch) {
- SDL_memcpy(dst, src, length*rect->h);
- } else {
- for (row = 0; row < rect->h; ++row) {
- SDL_memcpy(dst, src, length);
- src += pitch;
- dst += dpitch;
- }
- }
-
- sceKernelDcacheWritebackAll();
- return 0;
-}
-
-static int
-VITA_VITA2D_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)
-{
- return 0;
-}
-
-static int
-VITA_VITA2D_LockTexture(SDL_Renderer *renderer, SDL_Texture *texture,
- const SDL_Rect *rect, void **pixels, int *pitch)
-{
- VITA_VITA2D_TextureData *vita_texture = (VITA_VITA2D_TextureData *) texture->driverdata;
-
- *pixels =
- (void *) ((Uint8 *) vita2d_texture_get_datap(vita_texture->tex)
- + (rect->y * vita_texture->pitch) + rect->x * SDL_BYTESPERPIXEL(texture->format));
- *pitch = vita_texture->pitch;
- return 0;
-}
-
-static void
-VITA_VITA2D_UnlockTexture(SDL_Renderer *renderer, SDL_Texture *texture)
-{
- // no needs to update texture data on ps vita. VITA_VITA2D_LockTexture
- // already return a pointer to the vita2d texture pixels buffer.
- // This really improve framerate when using lock/unlock.
-
- /*
- VITA_VITA2D_TextureData *vita_texture = (VITA_VITA2D_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_VITA2D_UpdateTexture(renderer, texture, &rect, vita_texture->data, vita_texture->pitch);
- */
-}
-
-static void
-VITA_VITA2D_SetTextureScaleMode(SDL_Renderer * renderer, SDL_Texture * texture, SDL_ScaleMode scaleMode)
-{
- VITA_VITA2D_TextureData *vita_texture = (VITA_VITA2D_TextureData *) texture->driverdata;
-
- /*
- set texture filtering according to scaleMode
- suported hint values are nearest (0, default) or linear (1)
- vitaScaleMode is either SCE_GXM_TEXTURE_FILTER_POINT (good for tile-map)
- or SCE_GXM_TEXTURE_FILTER_LINEAR (good for scaling)
- */
-
- int vitaScaleMode = (scaleMode == SDL_ScaleModeNearest
- ? SCE_GXM_TEXTURE_FILTER_POINT
- : SCE_GXM_TEXTURE_FILTER_LINEAR);
- vita2d_texture_set_filters(vita_texture->tex, vitaScaleMode, vitaScaleMode);
-
- return;
-}
-
-static int
-VITA_VITA2D_SetRenderTarget(SDL_Renderer *renderer, SDL_Texture *texture)
-{
- return 0;
-}
-
-static int
-VITA_VITA2D_QueueSetViewport(SDL_Renderer * renderer, SDL_RenderCommand *cmd)
-{
- return 0;
-}
-
-static int
-VITA_VITA2D_QueueSetDrawColor(SDL_Renderer * renderer, SDL_RenderCommand *cmd)
-{
- return 0;
-}
-
-
-static void
-VITA_VITA2D_SetBlendMode(SDL_Renderer *renderer, int blendMode)
-{
- /*VITA_VITA2D_RenderData *data = (VITA_VITA2D_RenderData *) renderer->driverdata;
- if (blendMode != data-> currentBlendMode) {
- switch (blendMode) {
- case SDL_BLENDMODE_NONE:
- sceGuTexFunc(GU_TFX_REPLACE, GU_TCC_RGBA);
- sceGuDisable(GU_BLEND);
- break;
- case SDL_BLENDMODE_BLEND:
- sceGuTexFunc(GU_TFX_MODULATE , GU_TCC_RGBA);
- sceGuEnable(GU_BLEND);
- sceGuBlendFunc(GU_ADD, GU_SRC_ALPHA, GU_ONE_MINUS_SRC_ALPHA, 0, 0 );
- break;
- case SDL_BLENDMODE_ADD:
- sceGuTexFunc(GU_TFX_MODULATE , GU_TCC_RGBA);
- sceGuEnable(GU_BLEND);
- sceGuBlendFunc(GU_ADD, GU_SRC_ALPHA, GU_FIX, 0, 0x00FFFFFF );
- break;
- case SDL_BLENDMODE_MOD:
- sceGuTexFunc(GU_TFX_MODULATE , GU_TCC_RGBA);
- sceGuEnable(GU_BLEND);
- sceGuBlendFunc( GU_ADD, GU_FIX, GU_SRC_COLOR, 0, 0);
- break;
- }
- data->currentBlendMode = blendMode;
- }*/
-}
-
-
-
-static int
-VITA_VITA2D_RenderClear(SDL_Renderer *renderer)
-{
- int color = renderer->a << 24 | renderer->b << 16 | renderer->g << 8 | renderer->r;
- vita2d_set_clear_color(color);
-
- vita2d_clear_screen();
-
- return 0;
-}
-
-static int
-VITA_VITA2D_QueueDrawPoints(SDL_Renderer * renderer, SDL_RenderCommand *cmd, const SDL_FPoint * points, int count)
-{
- const size_t vertlen = (sizeof (float) * 2) * count;
- float *verts = (float *) SDL_AllocateRenderVertices(renderer, vertlen, 0, &cmd->data.draw.first);
- if (!verts) {
- return -1;
- }
- cmd->data.draw.count = count;
- SDL_memcpy(verts, points, vertlen);
- return 0;
-}
-
-static int
-VITA_VITA2D_RenderDrawPoints(SDL_Renderer *renderer, const SDL_FPoint *points,
- int count)
-{
- int color = renderer->a << 24 | renderer->b << 16 | renderer->g << 8 | renderer->r;
- int i;
-
- for (i = 0; i < count; ++i) {
- vita2d_draw_pixel(points[i].x, points[i].y, color);
- }
-
- return 0;
-}
-
-static int
-VITA_VITA2D_RenderDrawLines(SDL_Renderer *renderer, const SDL_FPoint *points,
- int count)
-{
- int color = renderer->a << 24 | renderer->b << 16 | renderer->g << 8 | renderer->r;
- int i;
-
- for (i = 0; i < count; ++i) {
- if (i < count -1) {
- vita2d_draw_line(points[i].x, points[i].y, points[i+1].x, points[i+1].y, color);
- }
- }
-
- return 0;
-}
-
-static int
-VITA_VITA2D_QueueFillRects(SDL_Renderer * renderer, SDL_RenderCommand *cmd, const SDL_FRect * rects, int count)
-{
- const size_t outLen = count * sizeof (SDL_FRect);
- SDL_FRect *outRects = (SDL_FRect *) SDL_AllocateRenderVertices(renderer, outLen, 0, &cmd->data.draw.first);
-
- if (!outRects) {
- return -1;
- }
- cmd->data.draw.count = count;
- SDL_memcpy(outRects, rects, outLen);
-
- return 0;
-}
-
-static int
-VITA_VITA2D_RenderFillRects(SDL_Renderer *renderer, const SDL_FRect *rects,
- int count)
-{
- int color = renderer->a << 24 | renderer->b << 16 | renderer->g << 8 | renderer->r;
- int i;
-
- for (i = 0; i < count; ++i) {
- const SDL_FRect *rect = &rects[i];
-
- vita2d_draw_rectangle(rect->x, rect->y, rect->w, rect->h, color);
- }
-
- return 0;
-}
-
-
-#define PI 3.14159265358979f
-
-#define radToDeg(x) ((x)*180.f/PI)
-#define degToRad(x) ((x)*PI/180.f)
-
-float MathAbs(float x)
-{
- return (x < 0) ? -x : x;
-}
-
-void MathSincos(float r, float *s, float *c)
-{
- *s = sinf(r);
- *c = cosf(r);
-}
-
-void Swap(float *a, float *b)
-{
- float n=*a;
- *a = *b;
- *b = n;
-}
-
-static int
-VITA_VITA2D_QueueCopy(SDL_Renderer * renderer, SDL_RenderCommand *cmd, SDL_Texture * texture,
- const SDL_Rect * srcrect, const SDL_FRect * dstrect)
-{
- const size_t outLen = sizeof (VITA_VITA2D_CopyData);
- VITA_VITA2D_CopyData *outData = (VITA_VITA2D_CopyData *) SDL_AllocateRenderVertices(renderer, outLen, 0, &cmd->data.draw.first);
-
- if (!outData) {
- return -1;
- }
- cmd->data.draw.count = 1;
-
- SDL_memcpy(&outData->srcRect, srcrect, sizeof(SDL_Rect));
- SDL_memcpy(&outData->dstRect, dstrect, sizeof(SDL_FRect));
-
- Uint8 r, g, b, a;
- SDL_GetTextureColorMod(texture, &r, &g, &b);
- SDL_GetTextureAlphaMod(texture, &a);
-
- cmd->data.draw.r = r;
- cmd->data.draw.g = g;
- cmd->data.draw.b = b;
- cmd->data.draw.a = a;
- cmd->data.draw.blend = renderer->blendMode;
-
- return 0;
-}
-
-
-static int
-VITA_VITA2D_RunCommandQueue(SDL_Renderer * renderer, SDL_RenderCommand *cmd, void *vertices, size_t vertsize)
-{
- StartDrawing(renderer);
-
- while (cmd) {
- switch (cmd->command) {
- case SDL_RENDERCMD_SETDRAWCOLOR: {
- break;
- }
-
- case SDL_RENDERCMD_SETVIEWPORT: {
- break;
- }
-
- case SDL_RENDERCMD_SETCLIPRECT: {
- break;
- }
-
- case SDL_RENDERCMD_CLEAR: {
- VITA_VITA2D_RenderClear(renderer);
- break;
- }
-
- case SDL_RENDERCMD_DRAW_POINTS: {
- const size_t count = cmd->data.draw.count;
- const size_t first = cmd->data.draw.first;
- const SDL_FPoint *points = (SDL_FPoint *) (((Uint8 *) vertices) + first);
- VITA_VITA2D_RenderDrawPoints(renderer, points, count);
- break;
- }
-
- case SDL_RENDERCMD_DRAW_LINES: {
- const size_t count = cmd->data.draw.count;
- const size_t first = cmd->data.draw.first;
- const SDL_FPoint *points = (SDL_FPoint *) (((Uint8 *) vertices) + first);
-
- VITA_VITA2D_RenderDrawLines(renderer, points, count);
- break;
- }
-
- case SDL_RENDERCMD_FILL_RECTS: {
- const size_t count = cmd->data.draw.count;
- const size_t first = cmd->data.draw.first;
- const SDL_FRect *rects = (SDL_FRect *) (((Uint8 *) vertices) + first);
-
- VITA_VITA2D_RenderFillRects(renderer, rects, count);
- break;
- }
-
- case SDL_RENDERCMD_COPY: {
- const size_t first = cmd->data.draw.first;
- const VITA_VITA2D_CopyData *copyData = (VITA_VITA2D_CopyData *) (((Uint8 *) vertices) + first);
-
- VITA_VITA2D_TextureData *vita_texture = (VITA_VITA2D_TextureData *) cmd->data.draw.texture->driverdata;
-
- const SDL_Rect *srcrect = ©Data->srcRect;
- const SDL_FRect *dstrect = ©Data->dstRect;
-
- float scaleX = dstrect->w == srcrect->w ? 1 : (float)(dstrect->w/srcrect->w);
- float scaleY = dstrect->h == srcrect->h ? 1 : (float)(dstrect->h/srcrect->h);
-
- Uint8 r, g, b, a;
- r = cmd->data.draw.r;
- g = cmd->data.draw.g;
- b = cmd->data.draw.b;
- a = cmd->data.draw.a;
-
- VITA_VITA2D_SetBlendMode(renderer, cmd->data.draw.blend);
-
- if(r == 255 && g == 255 && b == 255 && a == 255)
- {
- vita2d_draw_texture_part_scale(vita_texture->tex, dstrect->x, dstrect->y,
- srcrect->x, srcrect->y, srcrect->w, srcrect->h, scaleX, scaleY);
- } else {
- vita2d_draw_texture_tint_part_scale(vita_texture->tex, dstrect->x, dstrect->y,
- srcrect->x, srcrect->y, srcrect->w, srcrect->h, scaleX, scaleY, (a << 24) + (b << 16) + (g << 8) + r);
- }
-
- break;
- }
-
- case SDL_RENDERCMD_COPY_EX: {
- break;
- }
-
- case SDL_RENDERCMD_NO_OP:
- break;
- }
-
- cmd = cmd->next;
- }
-
- return 0;
-}
-
-static int
-VITA_VITA2D_RenderReadPixels(SDL_Renderer *renderer, const SDL_Rect *rect,
- Uint32 pixel_format, void *pixels, int pitch)
-{
- return 0;
-}
-
-static int
-VITA_VITA2D_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)
-{
- return 0;
-}
-
-static void
-VITA_VITA2D_RenderPresent(SDL_Renderer *renderer)
-{
- VITA_VITA2D_RenderData *data = (VITA_VITA2D_RenderData *) renderer->driverdata;
- if(!data->displayListAvail)
- return;
-
- vita2d_end_drawing();
- vita2d_wait_rendering_done();
- vita2d_swap_buffers();
-
- data->displayListAvail = SDL_FALSE;
-}
-
-static void
-VITA_VITA2D_DestroyTexture(SDL_Renderer *renderer, SDL_Texture *texture)
-{
- VITA_VITA2D_RenderData *renderdata = (VITA_VITA2D_RenderData *) renderer->driverdata;
- VITA_VITA2D_TextureData *vita_texture = (VITA_VITA2D_TextureData *) texture->driverdata;
-
- if (renderdata == 0)
- return;
-
- if(vita_texture == 0)
- return;
-
- vita2d_wait_rendering_done();
- vita2d_free_texture(vita_texture->tex);
- SDL_free(vita_texture);
- texture->driverdata = NULL;
-}
-
-static void
-VITA_VITA2D_DestroyRenderer(SDL_Renderer *renderer)
-{
- VITA_VITA2D_RenderData *data = (VITA_VITA2D_RenderData *) renderer->driverdata;
- if (data) {
- if (!data->initialized)
- return;
-
- vita2d_fini();
-
- data->initialized = SDL_FALSE;
- data->displayListAvail = SDL_FALSE;
- SDL_free(data);
- }
- SDL_free(renderer);
-}
-
-#endif /* SDL_VIDEO_RENDER_VITA_VITA2D */
-
-/* vi: set ts=4 sw=4 expandtab: */
-
diff --git a/src/render/vitagxm/SDL_render_vita_gxm.c b/src/render/vitagxm/SDL_render_vita_gxm.c
new file mode 100644
index 0000000..ae0f6ac
--- /dev/null
+++ b/src/render/vitagxm/SDL_render_vita_gxm.c
@@ -0,0 +1,958 @@
+/*
+ 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_GXM
+
+#include "SDL_hints.h"
+#include "../SDL_sysrender.h"
+#include "SDL_log.h"
+
+#include <stdio.h>
+#include <string.h>
+#include <math.h>
+#include <stdarg.h>
+#include <stdlib.h>
+
+#include "SDL_render_vita_gxm_types.h"
+#include "SDL_render_vita_gxm_tools.h"
+#include "SDL_render_vita_gxm_memory.h"
+
+static SDL_Renderer *VITA_GXM_CreateRenderer(SDL_Window *window, Uint32 flags);
+
+static void VITA_GXM_WindowEvent(SDL_Renderer *renderer, const SDL_WindowEvent *event);
+
+static SDL_bool VITA_GXM_SupportsBlendMode(SDL_Renderer * renderer, SDL_BlendMode blendMode);
+
+static int VITA_GXM_CreateTexture(SDL_Renderer *renderer, SDL_Texture *texture);
+
+static int VITA_GXM_UpdateTexture(SDL_Renderer *renderer, SDL_Texture *texture,
+ const SDL_Rect *rect, const void *pixels, int pitch);
+
+static int VITA_GXM_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);
+
+static int VITA_GXM_LockTexture(SDL_Renderer *renderer, SDL_Texture *texture,
+ const SDL_Rect *rect, void **pixels, int *pitch);
+
+static void VITA_GXM_UnlockTexture(SDL_Renderer *renderer,
+ SDL_Texture *texture);
+
+static void VITA_GXM_SetTextureScaleMode(SDL_Renderer * renderer, SDL_Texture * texture, SDL_ScaleMode scaleMode);
+
+static int VITA_GXM_SetRenderTarget(SDL_Renderer *renderer,
+ SDL_Texture *texture);
+
+
+static int VITA_GXM_QueueSetViewport(SDL_Renderer * renderer, SDL_RenderCommand *cmd);
+
+static int VITA_GXM_QueueSetDrawColor(SDL_Renderer * renderer, SDL_RenderCommand *cmd);
+
+
+static int VITA_GXM_QueueDrawPoints(SDL_Renderer * renderer, SDL_RenderCommand *cmd, const SDL_FPoint * points, int count);
+static int VITA_GXM_QueueDrawLines(SDL_Renderer * renderer, SDL_RenderCommand *cmd, const SDL_FPoint * points, int count);
+
+static int VITA_GXM_QueueCopy(SDL_Renderer * renderer, SDL_RenderCommand *cmd, SDL_Texture * texture,
+ const SDL_Rect * srcrect, const SDL_FRect * dstrect);
+
+static int VITA_GXM_QueueCopyEx(SDL_Renderer * renderer, SDL_RenderCommand *cmd, SDL_Texture * texture,
+ const SDL_Rect * srcrect, const SDL_FRect * dstrect,
+ const double angle, const SDL_FPoint *center, const SDL_RendererFlip flip);
+
+static int VITA_GXM_RenderClear(SDL_Renderer *renderer, SDL_RenderCommand *cmd);
+
+static int VITA_GXM_RenderDrawPoints(SDL_Renderer *renderer, const SDL_RenderCommand *cmd);
+
+static int VITA_GXM_RenderDrawLines(SDL_Renderer *renderer, const SDL_RenderCommand *cmd);
+
+static int VITA_GXM_QueueFillRects(SDL_Renderer * renderer, SDL_RenderCommand *cmd, const SDL_FRect * rects, int count);
+
+static int VITA_GXM_RenderFillRects(SDL_Renderer *renderer, const SDL_RenderCommand *cmd);
+
+
+static int VITA_GXM_RunCommandQueue(SDL_Renderer * renderer, SDL_RenderCommand *cmd, void *vertices, size_t vertsize);
+
+static int VITA_GXM_RenderReadPixels(SDL_Renderer *renderer, const SDL_Rect *rect,
+ Uint32 pixel_format, void *pixels, int pitch);
+
+
+static void VITA_GXM_RenderPresent(SDL_Renderer *renderer);
+static void VITA_GXM_DestroyTexture(SDL_Renderer *renderer, SDL_Texture *texture);
+static void VITA_GXM_DestroyRenderer(SDL_Renderer *renderer);
+
+
+SDL_RenderDriver VITA_GXM_RenderDriver = {
+ .CreateRenderer = VITA_GXM_CreateRenderer,
+ .info = {
+ .name = "VITA gxm",
+ .flags = SDL_RENDERER_ACCELERATED | SDL_RENDERER_PRESENTVSYNC,
+ .num_texture_formats = 1,
+ .texture_formats = {
+ [0] = SDL_PIXELFORMAT_ABGR8888, // TODO: support more formats? ARGB8888 should be enough?
+ },
+ .max_texture_width = 1024,
+ .max_texture_height = 1024,
+ }
+};
+
+void
+StartDrawing(SDL_Renderer *renderer)
+{
+ VITA_GXM_RenderData *data = (VITA_GXM_RenderData *) renderer->driverdata;
+ if(data->drawing)
+ return;
+
+ // reset blend mode
+ data->currentBlendMode = SDL_BLENDMODE_BLEND;
+ fragment_programs *in = &data->blendFragmentPrograms.blend_mode_blend;
+ data->colorFragmentProgram = in->color;
+ data->textureFragmentProgram = in->texture;
+ data->textureTintFragmentProgram = in->textureTint;
+
+ sceGxmBeginScene(
+ data->gxm_context,
+ 0,
+ data->renderTarget,
+ NULL,
+ NULL,
+ data->displayBufferSync[data->backBufferIndex],
+ &data->displaySurface[data->backBufferIndex],
+ &data->depthSurface
+ );
+
+ unset_clip_rectangle(data);
+
+ data->drawing = SDL_TRUE;
+}
+
+SDL_Renderer *
+VITA_GXM_CreateRenderer(SDL_Window *window, Uint32 flags)
+{
+ SDL_Renderer *renderer;
+ VITA_GXM_RenderData *data;
+
+ renderer = (SDL_Renderer *) SDL_calloc(1, sizeof(*renderer));
+ if (!renderer) {
+ SDL_OutOfMemory();
+ return NULL;
+ }
+
+ data = (VITA_GXM_RenderData *) SDL_calloc(1, sizeof(VITA_GXM_RenderData));
+ if (!data) {
+ VITA_GXM_DestroyRenderer(renderer);
+ SDL_OutOfMemory();
+ return NULL;
+ }
+
+ renderer->WindowEvent = VITA_GXM_WindowEvent;
+ renderer->SupportsBlendMode = VITA_GXM_SupportsBlendMode;
+ renderer->CreateTexture = VITA_GXM_CreateTexture;
+ renderer->UpdateTexture = VITA_GXM_UpdateTexture;
+ renderer->UpdateTextureYUV = VITA_GXM_UpdateTextureYUV;
+ renderer->LockTexture = VITA_GXM_LockTexture;
+ renderer->UnlockTexture = VITA_GXM_UnlockTexture;
+ renderer->SetTextureScaleMode = VITA_GXM_SetTextureScaleMode;
+ renderer->SetRenderTarget = VITA_GXM_SetRenderTarget;
+ renderer->QueueSetViewport = VITA_GXM_QueueSetViewport;
+ renderer->QueueSetDrawColor = VITA_GXM_QueueSetDrawColor;
+ renderer->QueueDrawPoints = VITA_GXM_QueueDrawPoints;
+ renderer->QueueDrawLines = VITA_GXM_QueueDrawLines;
+ renderer->QueueFillRects = VITA_GXM_QueueFillRects;
+ renderer->QueueCopy = VITA_GXM_QueueCopy;
+ renderer->QueueCopyEx = VITA_GXM_QueueCopyEx;
+ renderer->RunCommandQueue = VITA_GXM_RunCommandQueue;
+ renderer->RenderReadPixels = VITA_GXM_RenderReadPixels;
+ renderer->RenderPresent = VITA_GXM_RenderPresent;
+ renderer->DestroyTexture = VITA_GXM_DestroyTexture;
+ renderer->DestroyRenderer = VITA_GXM_DestroyRenderer;
+
+ renderer->info = VITA_GXM_RenderDriver.info;
+ renderer->info.flags = (SDL_RENDERER_ACCELERATED | SDL_RENDERER_TARGETTEXTURE);
+ renderer->driverdata = data;
+ renderer->window = window;
+
+ if (data->initialized != SDL_FALSE)
+ return 0;
+ data->initialized = SDL_TRUE;
+
+ if (flags & SDL_RENDERER_PRESENTVSYNC) {
+ data->displayData.wait_vblank = SDL_TRUE;
+ } else {
+ data->displayData.wait_vblank = SDL_FALSE;
+ }
+
+ if (gxm_init(renderer) != 0)
+ {
+ return NULL;
+ }
+
+ return renderer;
+}
+
+static void
+VITA_GXM_WindowEvent(SDL_Renderer *renderer, const SDL_WindowEvent *event)
+{
+}
+
+static SDL_bool
+VITA_GXM_SupportsBlendMode(SDL_Renderer * renderer, SDL_BlendMode blendMode)
+{
+ // only for custom modes. we build all modes on init, so no custom modes, sorry
+ return SDL_FALSE;
+}
+
+static int
+VITA_GXM_CreateTexture(SDL_Renderer *renderer, SDL_Texture *texture)
+{
+ VITA_GXM_RenderData *data = (VITA_GXM_RenderData *) renderer->driverdata;
+ VITA_GXM_TextureData* vita_texture = (VITA_GXM_TextureData*) SDL_calloc(1, sizeof(VITA_GXM_TextureData));
+
+ if (!vita_texture) {
+ return SDL_OutOfMemory();
+ }
+
+ vita_texture->tex = create_gxm_texture(data, texture->w, texture->h, SCE_GXM_TEXTURE_FORMAT_A8B8G8R8, 0); // TODO: rendertarget support, other formats
+
+ if (!vita_texture->tex) {
+ SDL_free(vita_texture);
+ return SDL_OutOfMemory();
+ }
+
+ texture->driverdata = vita_texture;
+
+ VITA_GXM_SetTextureScaleMode(renderer, texture, texture->scaleMode);
+
+ vita_texture->w = gxm_texture_get_width(vita_texture->tex);
+ vita_texture->h = gxm_texture_get_height(vita_texture->tex);
+ vita_texture->pitch = gxm_texture_get_stride(vita_texture->tex);
+
+ return 0;
+}
+
+
+static int
+VITA_GXM_UpdateTexture(SDL_Renderer *renderer, SDL_Texture *texture,
+ const SDL_Rect *rect, const void *pixels, int pitch)
+{
+ const Uint8 *src;
+ Uint8 *dst;
+ int row, length,dpitch;
+ src = pixels;
+
+ VITA_GXM_LockTexture(renderer, texture, rect, (void **)&dst, &dpitch);
+ length = rect->w * SDL_BYTESPERPIXEL(texture->format);
+ if (length == pitch && length == dpitch) {
+ SDL_memcpy(dst, src, length*rect->h);
+ } else {
+ for (row = 0; row < rect->h; ++row) {
+ SDL_memcpy(dst, src, length);
+ src += pitch;
+ dst += dpitch;
+ }
+ }
+
+ return 0;
+}
+
+static int
+VITA_GXM_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)
+{
+ return 0;
+}
+
+static int
+VITA_GXM_LockTexture(SDL_Renderer *renderer, SDL_Texture *texture,
+ const SDL_Rect *rect, void **pixels, int *pitch)
+{
+ VITA_GXM_TextureData *vita_texture = (VITA_GXM_TextureData *) texture->driverdata;
+
+ *pixels =
+ (void *) ((Uint8 *) gxm_texture_get_datap(vita_texture->tex)
+ + (rect->y * vita_texture->pitch) + rect->x * SDL_BYTESPERPIXEL(texture->format));
+ *pitch = vita_texture->pitch;
+ return 0;
+}
+
+static void
+VITA_GXM_UnlockTexture(SDL_Renderer *renderer, SDL_Texture *texture)
+{
+ // No need to update texture data on ps vita.
+ // VITA_GXM_LockTexture already returns a pointer to the texture pixels buffer.
+ // This really improves framerate when using lock/unlock.
+}
+
+static void
+VITA_GXM_SetTextureScaleMode(SDL_Renderer * renderer, SDL_Texture * texture, SDL_ScaleMode scaleMode)
+{
+ VITA_GXM_TextureData *vita_texture = (VITA_GXM_TextureData *) texture->driverdata;
+
+ /*
+ set texture filtering according to scaleMode
+ suported hint values are nearest (0, default) or linear (1)
+ vitaScaleMode is either SCE_GXM_TEXTURE_FILTER_POINT (good for tile-map)
+ or SCE_GXM_TEXTURE_FILTER_LINEAR (good for scaling)
+ */
+
+ int vitaScaleMode = (scaleMode == SDL_ScaleModeNearest
+ ? SCE_GXM_TEXTURE_FILTER_POINT
+ : SCE_GXM_TEXTURE_FILTER_LINEAR);
+ gxm_texture_set_filters(vita_texture->tex, vitaScaleMode, vitaScaleMode);
+
+ return;
+}
+
+static int
+VITA_GXM_SetRenderTarget(SDL_Renderer *renderer, SDL_Texture *texture)
+{
+ return 0; // TODO
+}
+
+static void
+VITA_GXM_SetBlendMode(SDL_Renderer *renderer, int blendMode)
+{
+ VITA_GXM_RenderData *data = (VITA_GXM_RenderData *) renderer->driverdata;
+ if (blendMode != data->currentBlendMode)
+ {
+ fragment_programs *in = &data->blendFragmentPrograms.blend_mode_blend;
+
+ switch (blendMode)
+ {
+ case SDL_BLENDMODE_NONE:
+ in = &data->blendFragmentPrograms.blend_mode_none;
+ break;
+ case SDL_BLENDMODE_BLEND:
+ in = &data->blendFragmentPrograms.blend_mode_blend;
+ break;
+ case SDL_BLENDMODE_ADD:
+ in = &data->blendFragmentPrograms.blend_mode_add;
+ break;
+ case SDL_BLENDMODE_MOD:
+ in = &data->blendFragmentPrograms.blend_mode_mod;
+ break;
+ case SDL_BLENDMODE_MUL:
+ in = &data->blendFragmentPrograms.blend_mode_mul;
+ break;
+ }
+ data->colorFragmentProgram = in->color;
+ data->textureFragmentProgram = in->texture;
+ data->textureTintFragmentProgram = in->textureTint;
+ data->currentBlendMode = blendMode;
+ }
+}
+
+static int
+VITA_GXM_QueueSetViewport(SDL_Renderer * renderer, SDL_RenderCommand *cmd)
+{
+ return 0; // TODO
+}
+
+static int
+VITA_GXM_QueueSetDrawColor(SDL_Renderer * renderer, SDL_RenderCommand *cmd)
+{
+ VITA_GXM_RenderData *data = (VITA_GXM_RenderData *) renderer->driverdata;
+
+ const Uint8 r = cmd->data.color.r;
+ const Uint8 g = cmd->data.color.g;
+ const Uint8 b = cmd->data.color.b;
+ const Uint8 a = cmd->data.color.a;
+ data->drawstate.color = ((a << 24) | (b << 16) | (g << 8) | r);
+
+ return 0;
+}
+
+static int
+VITA_GXM_QueueDrawPoints(SDL_Renderer * renderer, SDL_RenderCommand *cmd, const SDL_FPoint * points, int count)
+{
+ VITA_GXM_RenderData *data = (VITA_GXM_RenderData *) renderer->driverdata;
+
+ int color = data->drawstate.color;
+
+ color_vertex *vertex = (color_vertex *)pool_memalign(
+ data,
+ count * sizeof(color_vertex),
+ sizeof(color_vertex)
+ );
+
+ cmd->data.draw.first = (size_t)vertex;
+ cmd->data.draw.count = count;
+
+ for (int i = 0; i < count; i++)
+ {
+ vertex[i].x = points[i].x;
+ vertex[i].y = points[i].y;
+ vertex[i].z = +0.5f;
+ vertex[i].color = color;
+ }
+ return 0;
+}
+
+static int
+VITA_GXM_QueueDrawLines(SDL_Renderer * renderer, SDL_RenderCommand *cmd, const SDL_FPoint * points, int count)
+{
+ VITA_GXM_RenderData *data = (VITA_GXM_RenderData *) renderer->driverdata;
+ int color = data->drawstate.color;
+
+ color_vertex *vertex = (color_vertex *)pool_memalign(
+ data,
+ (count-1) * 2 * sizeof(color_vertex),
+ sizeof(color_vertex)
+ );
+
+ cmd->data.draw.first = (size_t)vertex;
+ cmd->data.draw.count = (count-1) * 2;
+
+ for (int i = 0; i < count - 1; i++)
+ {
+ vertex[i*2].x = points[i].x;
+ vertex[i*2].y = points[i].y;
+ vertex[i*2].z = +0.5f;
+ vertex[i*2].color = color;
+
+ vertex[i*2+1].x = points[i+1].x;
+ vertex[i*2+1].y = points[i+1].y;
+ vertex[i*2+1].z = +0.5f;
+ vertex[i*2+1].color = color;
+ }
+
+ return 0;
+}
+
+static int
+VITA_GXM_QueueFillRects(SDL_Renderer * renderer, SDL_RenderCommand *cmd, const SDL_FRect * rects, int count)
+{
+ VITA_GXM_RenderData *data = (VITA_GXM_RenderData *) renderer->driverdata;
+
+ cmd->data.draw.count = count;
+ int color = data->drawstate.color;
+
+ color_vertex *vertices = (color_vertex *)pool_memalign(
+ data,
+ 4 * count * sizeof(color_vertex), // 4 vertices * count
+ sizeof(color_vertex));
+
+ for (int i =0; i < count; i++)
+ {
+ const SDL_FRect *rect = &rects[i];
+
+ vertices[4*i+0].x = rect->x;
+ vertices[4*i+0].y = rect->y;
+ vertices[4*i+0].z = +0.5f;
+ vertices[4*i+0].color = color;
+
+ vertices[4*i+1].x = rect->x + rect->w;
+ vertices[4*i+1].y = rect->y;
+ vertices[4*i+1].z = +0.5f;
+ vertices[4*i+1].color = color;
+
+ vertices[4*i+2].x = rect->x;
+ vertices[4*i+2].y = rect->y + rect->h;
+ vertices[4*i+2].z = +0.5f;
+ vertices[4*i+2].color = color;
+
+ vertices[4*i+3].x = rect->x + rect->w;
+ vertices[4*i+3].y = rect->y + rect->h;
+ vertices[4*i+3].z = +0.5f;
+ vertices[4*i+3].color = color;
+ }
+
+ cmd->data.draw.first = (size_t)vertices;
+
+ return 0;
+}
+
+
+#define PI 3.14159265358979f
+
+#define degToRad(x) ((x)*PI/180.f)
+
+void MathSincos(float r, float *s, float *c)
+{
+ *s = sinf(r);
+ *c = cosf(r);
+}
+
+void Swap(float *a, float *b)
+{
+ float n=*a;
+ *a = *b;
+ *b = n;
+}
+
+static int
+VITA_GXM_QueueCopy(SDL_Renderer * renderer, SDL_RenderCommand *cmd, SDL_Texture * texture,
+ const SDL_Rect * srcrect, const SDL_FRect * dstrect)
+{
+
+ VITA_GXM_RenderData *data = (VITA_GXM_RenderData *) renderer->driverdata;
+
+ Uint8 r, g, b, a;
+ SDL_GetTextureColorMod(texture, &r, &g, &b);
+ SDL_GetTextureAlphaMod(texture, &a);
+
+ cmd->data.draw.r = r;
+ cmd->data.draw.g = g;
+ cmd->data.draw.b = b;
+ cmd->data.draw.a = a;
+ cmd->data.draw.blend = renderer->blendMode;
+
+ cmd->data.draw.count = 1;
+
+ texture_vertex *vertices = (texture_vertex *)pool_memalign(
+ data,
+ 4 * sizeof(texture_vertex), // 4 vertices
+ sizeof(texture_vertex));
+
+ cmd->data.draw.first = (size_t)vertices;
+ cmd->data.draw.texture = texture;
+
+ const float u0 = (float)srcrect->x / (float)texture->w;
+ const float v0 = (float)srcrect->y / (float)texture->h;
+ const float u1 = (float)(srcrect->x + srcrect->w) / (float)texture->w;
+ const float v1 = (float)(srcrect->y + srcrect->h) / (float)texture->h;
+
+ vertices[0].x = dstrect->x;
+ vertices[0].y = dstrect->y;
+ vertices[0].z = +0.5f;
+ vertices[0].u = u0;
+ vertices[0].v = v0;
+
+ vertices[1].x = dstrect->x + dstrect->w;
+ vertices[1].y = dstrect->y;
+ vertices[1].z = +0.5f;
+ vertices[1].u = u1;
+ vertices[1].v = v0;
+
+ vertices[2].x = dstrect->x;
+ vertices[2].y = dstrect->y + dstrect->h;
+ vertices[2].z = +0.5f;
+ vertices[2].u = u0;
+ vertices[2].v = v1;
+
+ vertices[3].x = dstrect->x + dstrect->w;
+ vertices[3].y = dstrect->y + dstrect->h;
+ vertices[3].z = +0.5f;
+ vertices[3].u = u1;
+ vertices[3].v = v1;
+
+ return 0;
+}
+
+static int
+VITA_GXM_QueueCopyEx(SDL_Renderer * renderer, SDL_RenderCommand *cmd, SDL_Texture * texture,
+ const SDL_Rect * srcrect, const SDL_FRect * dstrect,
+ const double angle, const SDL_FPoint *center, const SDL_RendererFlip flip)
+{
+ VITA_GXM_RenderData *data = (VITA_GXM_RenderData *) renderer->driverdata;
+
+ Uint8 r, g, b, a;
+ SDL_GetTextureColorMod(texture, &r, &g, &b);
+ SDL_GetTextureAlphaMod(texture, &a);
+
+ cmd->data.draw.r = r;
+ cmd->data.draw.g = g;
+ cmd->data.draw.b = b;
+ cmd->data.draw.a = a;
+ cmd->data.draw.blend = renderer->blendMode;
+
+ cmd->data.draw.count = 1;
+
+ texture_vertex *vertices = (texture_vertex *)pool_memalign(
+ data,
+ 4 * sizeof(texture_vertex), // 4 vertices
+ sizeof(texture_vertex));
+
+ cmd->data.draw.first = (size_t)vertices;
+ cmd->data.draw.texture = texture;
+
+ float u0 = (float)srcrect->x / (float)texture->w;
+ float v0 = (float)srcrect->y / (float)texture->h;
+ float u1 = (float)(srcrect->x + srcrect->w) / (float)texture->w;
+ float v1 = (float)(srcrect->y + srcrect->h) / (float)texture->h;
+
+ if (flip & SDL_FLIP_VERTICAL) {
+ Swap(&v0, &v1);
+ }
+
+ if (flip & SDL_FLIP_HORIZONTAL) {
+ Swap(&u0, &u1);
+ }
+
+ const float centerx = center->x;
+ const float centery = center->y;
+ const float x = dstrect->x + centerx;
+ const float y = dstrect->y + centery;
+ const float width = dstrect->w - centerx;
+ const float height = dstrect->h - centery;
+ float s, c;
+
+ MathSincos(degToRad(angle), &s, &c);
+
+ const float cw = c * width;
+ const float sw = s * width;
+ const float ch = c * height;
+ const float sh = s * height;
+
+ vertices[0].x = x - cw + sh;
+ vertices[0].y = y - sw - ch;
+ vertices[0].z = +0.5f;
+ vertices[0].u = u0;
+ vertices[0].v = v0;
+
+ vertices[1].x = x + cw + sh;
+ vertices[1].y = y + sw - ch;
+ vertices[1].z = +0.5f;
+ vertices[1].u = u1;
+ vertices[1].v = v0;
+
+
+ vertices[2].x = x - cw - sh;
+ vertices[2].y = y - sw + ch;
+ vertices[2].z = +0.5f;
+ vertices[2].u = u0;
+ vertices[2].v = v1;
+
+ vertices[3].x = x + cw - sh;
+ vertices[3].y = y + sw + ch;
+ vertices[3].z = +0.5f;
+ vertices[3].u = u1;
+ vertices[3].v = v1;
+
+ return 0;
+}
+
+
+static int
+VITA_GXM_RenderClear(SDL_Renderer *renderer, SDL_RenderCommand *cmd)
+{
+ VITA_GXM_RenderData *data = (VITA_GXM_RenderData *) renderer->driverdata;
+
+ float clear_color[4];
+ clear_color[0] = (cmd->data.color.r)/255.0f;
+ clear_color[1] = (cmd->data.color.g)/255.0f;
+ clear_color[2] = (cmd->data.color.b)/255.0f;
+ clear_color[3] = (cmd->data.color.a)/255.0f;
+
+ // set clear shaders
+ sceGxmSetVertexProgram(data->gxm_context, data->clearVertexProgram);
+ sceGxmSetFragmentProgram(data->gxm_context, data->clearFragmentProgram);
+
+ // set the clear color
+ void *color_buffer;
+ sceGxmReserveFragmentDefaultUniformBuffer(data->gxm_context, &color_buffer);
+ sceGxmSetUniformDataF(color_buffer, data->clearClearColorParam, 0, 4, clear_color);
+
+ // draw the clear triangle
+ sceGxmSetVertexStream(data->gxm_context, 0, data->clearVertices);
+ sceGxmDraw(data->gxm_context, SCE_GXM_PRIMITIVE_TRIANGLES, SCE_GXM_INDEX_FORMAT_U16, data->linearIndices, 3);
+
+ return 0;
+}
+
+
+static int
+VITA_GXM_RenderDrawPoints(SDL_Renderer *renderer, const SDL_RenderCommand *cmd)
+{
+ VITA_GXM_RenderData *data = (VITA_GXM_RenderData *) renderer->driverdata;
+
+ sceGxmSetVertexProgram(data->gxm_context, data->colorVertexProgram);
+ sceGxmSetFragmentProgram(data->gxm_context, data->colorFragmentProgram);
+
+ void *vertexDefaultBuffer;
+ sceGxmReserveVertexDefaultUniformBuffer(data->gxm_context, &vertexDefaultBuffer);
+ sceGxmSetUniformDataF(vertexDefaultBuffer, data->colorWvpParam, 0, 16, data->ortho_matrix);
+
+ sceGxmSetVertexStream(data->gxm_context, 0, (const void*)cmd->data.draw.first);
+
+ sceGxmSetFrontPolygonMode(data->gxm_context, SCE_GXM_POLYGON_MODE_POINT);
+ sceGxmDraw(data->gxm_context, SCE_GXM_PRIMITIVE_POINTS, SCE_GXM_INDEX_FORMAT_U16, data->linearIndices, cmd->data.draw.count);
+ sceGxmSetFrontPolygonMode(data->gxm_context, SCE_GXM_POLYGON_MODE_TRIANGLE_FILL);
+
+ return 0;
+}
+
+static int
+VITA_GXM_RenderDrawLines(SDL_Renderer *renderer, const SDL_RenderCommand *cmd)
+{
+ VITA_GXM_RenderData *data = (VITA_GXM_RenderData *) renderer->driverdata;
+
+ sceGxmSetVertexProgram(data->gxm_context, data->colorVertexProgram);
+ sceGxmSetFragmentProgram(data->gxm_context, data->colorFragmentProgram);
+
+ void *vertexDefaultBuffer;
+
+ sceGxmReserveVertexDefaultUniformBuffer(data->gxm_context, &vertexDefaultBuffer);
+
+ sceGxmSetUniformDataF(vertexDefaultBuffer, data->colorWvpParam, 0, 16, data->ortho_matrix);
+
+ sceGxmSetVertexStream(data->gxm_context, 0, (const void*)cmd->data.draw.first);
+
+ sceGxmSetFrontPolygonMode(data->gxm_context, SCE_GXM_POLYGON_MODE_LINE);
+ sceGxmDraw(data->gxm_context, SCE_GXM_PRIMITIVE_LINES, SCE_GXM_INDEX_FORMAT_U16, data->linearIndices, cmd->data.draw.count);
+ sceGxmSetFrontPolygonMode(data->gxm_context, SCE_GXM_POLYGON_MODE_TRIANGLE_FILL);
+ return 0;
+}
+
+
+static int
+VITA_GXM_RenderFillRects(SDL_Renderer *renderer, const SDL_RenderCommand *cmd)
+{
+ VITA_GXM_RenderData *data = (VITA_GXM_RenderData *) renderer->driverdata;
+
+ sceGxmSetVertexProgram(data->gxm_context, data->colorVertexProgram);
+ sceGxmSetFragmentProgram(data->gxm_context, data->colorFragmentProgram);
+
+ void *vertexDefaultBuffer;
+ sceGxmReserveVertexDefaultUniformBuffer(data->gxm_context, &vertexDefaultBuffer);
+ sceGxmSetUniformDataF(vertexDefaultBuffer, data->colorWvpParam, 0, 16, data->ortho_matrix);
+
+ sceGxmSetVertexStream(data->gxm_context, 0, (const void*)cmd->data.draw.first);
+ sceGxmDraw(data->gxm_context, SCE_GXM_PRIMITIVE_TRIANGLE_STRIP, SCE_GXM_INDEX_FORMAT_U16, data->linearIndices, 4 * cmd->data.draw.count);
+
+ return 0;
+}
+
+
+
+static int
+VITA_GXM_RunCommandQueue(SDL_Renderer * renderer, SDL_RenderCommand *cmd, void *vertices, size_t vertsize)
+{
+ StartDrawing(renderer);
+ VITA_GXM_RenderData *data = (VITA_GXM_RenderData *) renderer->driverdata;
+
+ while (cmd) {
+ switch (cmd->command) {
+ case SDL_RENDERCMD_SETDRAWCOLOR: {
+ 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 (cmd->data.cliprect.enabled)
+ {
+ set_clip_rectangle(data, rect->x, rect->y, rect->w, rect->h);
+ }
+ else
+ {
+ unset_clip_rectangle(data);
+ }
+ break;
+ }
+
+ case SDL_RENDERCMD_CLEAR: {
+ VITA_GXM_RenderClear(renderer, cmd);
+ break;
+ }
+
+ case SDL_RENDERCMD_DRAW_POINTS: {
+ VITA_GXM_SetBlendMode(renderer, cmd->data.draw.blend);
+ VITA_GXM_RenderDrawPoints(renderer, cmd);
+ break;
+ }
+
+ case SDL_RENDERCMD_DRAW_LINES: {
+ VITA_GXM_SetBlendMode(renderer, cmd->data.draw.blend);
+ VITA_GXM_RenderDrawLines(renderer, cmd);
+ break;
+ }
+
+ case SDL_RENDERCMD_FILL_RECTS: {
+ VITA_GXM_SetBlendMode(renderer, cmd->data.draw.blend);
+ VITA_GXM_RenderFillRects(renderer, cmd);
+ break;
+ }
+
+ case SDL_RENDERCMD_COPY:
+ case SDL_RENDERCMD_COPY_EX: {
+ SDL_BlendMode blend;
+ SDL_GetTextureBlendMode(cmd->data.draw.texture, &blend);
+ VITA_GXM_SetBlendMode(renderer, blend);
+
+ Uint8 r, g, b, a;
+ r = cmd->data.draw.r;
+ g = cmd->data.draw.g;
+ b = cmd->data.draw.b;
+ a = cmd->data.draw.a;
+
+ sceGxmSetVertexProgram(data->gxm_context, data->textureVertexProgram);
+
+ if(r == 255 && g == 255 && b == 255 && a == 255)
+ {
+ sceGxmSetFragmentProgram(data->gxm_context, data->textureFragmentProgram);
+ }
+ else
+ {
+ sceGxmSetFragmentProgram(data->gxm_context, data->textureTintFragmentProgram);
+ void *texture_tint_color_buffer;
+ sceGxmReserveFragmentDefaultUniformBuffer(data->gxm_context, &texture_tint_color_buffer);
+
+ float *tint_color = pool_memalign(
+ data,
+ 4 * sizeof(float), // RGBA
+ sizeof(float)
+ );
+
+ tint_color[0] = r / 255.0f;
+ tint_color[1] = g / 255.0f;
+ tint_color[2] = b / 255.0f;
+ tint_color[3] = a / 255.0f;
+
+ sceGxmSetUniformDataF(texture_tint_color_buffer, data->textureTintColorParam, 0, 4, tint_color);
+
+ }
+
+ void *vertex_wvp_buffer;
+ sceGxmReserveVertexDefaultUniformBuffer(data->gxm_context, &vertex_wvp_buffer);
+ sceGxmSetUniformDataF(vertex_wvp_buffer, data->textureWvpParam, 0, 16, data->ortho_matrix);
+
+ VITA_GXM_TextureData *vita_texture = (VITA_GXM_TextureData *) cmd->data.draw.texture->driverdata;
+
+ sceGxmSetFragmentTexture(data->gxm_context, 0, &vita_texture->tex->gxm_tex);
+
+ sceGxmSetVertexStream(data->gxm_context, 0, (const void*)cmd->data.draw.first);
+ sceGxmDraw(data->gxm_context, SCE_GXM_PRIMITIVE_TRIANGLE_STRIP, SCE_GXM_INDEX_FORMAT_U16, data->linearIndices, 4 * cmd->data.draw.count);
+
+ break;
+ }
+
+ case SDL_RENDERCMD_NO_OP:
+ break;
+ }
+
+ cmd = cmd->next;
+ }
+
+ return 0;
+}
+
+static int
+VITA_GXM_RenderReadPixels(SDL_Renderer *renderer, const SDL_Rect *rect,
+ Uint32 pixel_format, void *pixels, int pitch)
+{
+ SceDisplayFrameBuf framebuf;
+ SDL_memset(&framebuf, 0x00, sizeof(SceDisplayFrameBuf));
+ sceDisplayGetFrameBuf(&framebuf, SCE_DISPLAY_SETBUF_IMMEDIATE);
+
+ // TODO
+ //pixels = framebuf.base;
+
+ return 0;
+
+}
+
+
+static void
+VITA_GXM_RenderPresent(SDL_Renderer *renderer)
+{
+ VITA_GXM_RenderData *data = (VITA_GXM_RenderData *) renderer->driverdata;
+
+ if(!data->drawing)
+ return;
+
+ sceGxmEndScene(data->gxm_context, NULL, NULL);
+ sceGxmFinish(data->gxm_context);
+
+ data->displayData.address = data->displayBufferData[data->backBufferIndex];
+
+ sceGxmDisplayQueueAddEntry(
+ data->displayBufferSync[data->frontBufferIndex], // OLD fb
+ data->displayBufferSync[data->backBufferIndex], // NEW fb
+ &data->displayData
+ );
+
+ // update buffer indices
+ data->frontBufferIndex = data->backBufferIndex;
+ data->backBufferIndex = (data->backBufferIndex + 1) % VITA_GXM_BUFFERS;
+ data->pool_index = 0;
+ data->drawing = SDL_FALSE;
+}
+
+static void
+VITA_GXM_DestroyTexture(SDL_Renderer *renderer, SDL_Texture *texture)
+{
+ VITA_GXM_RenderData *data = (VITA_GXM_RenderData *) renderer->driverdata;
+ VITA_GXM_TextureData *vita_texture = (VITA_GXM_TextureData *) texture->driverdata;
+
+ if (data == 0)
+ return;
+
+ if(vita_texture == 0)
+ return;
+
+ if(vita_texture->tex == 0)
+ return;
+
+ sceGxmFinish(data->gxm_context);
+
+ if (vita_texture->tex->gxm_rendertarget) {
+ sceGxmDestroyRenderTarget(vita_texture->tex->gxm_rendertarget);
+ }
+
+ if (vita_texture->tex->depth_UID) {
+ gpu_free(vita_texture->tex->depth_UID);
+ }
+
+ if (vita_texture->tex->palette_UID) {
+ gpu_free(vita_texture->tex->palette_UID);
+ }
+
+ gpu_free(vita_texture->tex->data_UID);
+ SDL_free(vita_texture->tex);
+ SDL_free(vita_texture);
+
+ texture->driverdata = NULL;
+}
+
+static void
+VITA_GXM_DestroyRenderer(SDL_Renderer *renderer)
+{
+ VITA_GXM_RenderData *data = (VITA_GXM_RenderData *) renderer->driverdata;
+ if (data) {
+ if (!data->initialized)
+ return;
+
+ gxm_finish(renderer);
+
+ data->initialized = SDL_FALSE;
+ data->drawing = SDL_FALSE;
+ SDL_free(data);
+ }
+ SDL_free(renderer);
+}
+
+#endif /* SDL_VIDEO_RENDER_VITA_GXM */
+
+/* vi: set ts=4 sw=4 expandtab: */
diff --git a/src/render/vitagxm/SDL_render_vita_gxm_memory.c b/src/render/vitagxm/SDL_render_vita_gxm_memory.c
new file mode 100644
index 0000000..edb3e50
--- /dev/null
+++ b/src/render/vitagxm/SDL_render_vita_gxm_memory.c
@@ -0,0 +1,117 @@
+/*
+ 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_GXM
+
+#include "SDL_render_vita_gxm_memory.h"
+
+void *
+gpu_alloc(SceKernelMemBlockType type, unsigned int size, unsigned int alignment, unsigned int attribs, SceUID *uid)
+{
+ void *mem;
+
+ if (type == SCE_KERNEL_MEMBLOCK_TYPE_USER_CDRAM_RW) {
+ size = ALIGN(size, 256*1024);
+ } else {
+ size = ALIGN(size, 4*1024);
+ }
+
+ *uid = sceKernelAllocMemBlock("gpu_mem", type, size, NULL);
+
+ if (*uid < 0)
+ return NULL;
+
+ if (sceKernelGetMemBlockBase(*uid, &mem) < 0)
+ return NULL;
+
+ if (sceGxmMapMemory(mem, size, attribs) < 0)
+ return NULL;
+
+ return mem;
+}
+
+void
+gpu_free(SceUID uid)
+{
+ void *mem = NULL;
+ if (sceKernelGetMemBlockBase(uid, &mem) < 0)
+ return;
+ sceGxmUnmapMemory(mem);
+ sceKernelFreeMemBlock(uid);
+}
+
+void *
+vertex_usse_alloc(unsigned int size, SceUID *uid, unsigned int *usse_offset)
+{
+ void *mem = NULL;
+
+ size = ALIGN(size, 4096);
+ *uid = sceKernelAllocMemBlock("vertex_usse", SCE_KERNEL_MEMBLOCK_TYPE_USER_RW_UNCACHE, size, NULL);
+
+ if (sceKernelGetMemBlockBase(*uid, &mem) < 0)
+ return NULL;
+ if (sceGxmMapVertexUsseMemory(mem, size, usse_offset) < 0)
+ return NULL;
+
+ return mem;
+}
+
+void
+vertex_usse_free(SceUID uid)
+{
+ void *mem = NULL;
+ if (sceKernelGetMemBlockBase(uid, &mem) < 0)
+ return;
+ sceGxmUnmapVertexUsseMemory(mem);
+ sceKernelFreeMemBlock(uid);
+}
+
+void *
+fragment_usse_alloc(unsigned int size, SceUID *uid, unsigned int *usse_offset)
+{
+ void *mem = NULL;
+
+ size = ALIGN(size, 4096);
+ *uid = sceKernelAllocMemBlock("fragment_usse", SCE_KERNEL_MEMBLOCK_TYPE_USER_RW_UNCACHE, size, NULL);
+
+ if (sceKernelGetMemBlockBase(*uid, &mem) < 0)
+ return NULL;
+ if (sceGxmMapFragmentUsseMemory(mem, size, usse_offset) < 0)
+ return NULL;
+
+ return mem;
+}
+
+void
+fragment_usse_free(SceUID uid)
+{
+ void *mem = NULL;
+ if (sceKernelGetMemBlockBase(uid, &mem) < 0)
+ return;
+ sceGxmUnmapFragmentUsseMemory(mem);
+ sceKernelFreeMemBlock(uid);
+}
+
+#endif /* SDL_VIDEO_RENDER_VITA_GXM */
+
+/* vi: set ts=4 sw=4 expandtab: */
diff --git a/src/render/vitagxm/SDL_render_vita_gxm_memory.h b/src/render/vitagxm/SDL_render_vita_gxm_memory.h
new file mode 100644
index 0000000..d1989ff
--- /dev/null
+++ b/src/render/vitagxm/SDL_render_vita_gxm_memory.h
@@ -0,0 +1,40 @@
+/*
+ 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.
+*/
+
+#ifndef SDL_RENDER_VITA_GXM_MEMORY_H
+#define SDL_RENDER_VITA_GXM_MEMORY_H
+
+#include <psp2/gxm.h>
+#include <psp2/types.h>
+#include <psp2/kernel/sysmem.h>
+
+#define ALIGN(x, a) (((x) + ((a) - 1)) & ~((a) - 1))
+
+void *gpu_alloc(SceKernelMemBlockType type, unsigned int size, unsigned int alignment, unsigned int attribs, SceUID *uid);
+void gpu_free(SceUID uid);
+void *vertex_usse_alloc(unsigned int size, SceUID *uid, unsigned int *usse_offset);
+void vertex_usse_free(SceUID uid);
+void *fragment_usse_alloc(unsigned int size, SceUID *uid, unsigned int *usse_offset);
+void fragment_usse_free(SceUID uid);
+
+#endif /* SDL_RENDER_VITA_GXM_MEMORY_H */
+
+/* vi: set ts=4 sw=4 expandtab: */
diff --git a/src/render/vitagxm/SDL_render_vita_gxm_shaders.h b/src/render/vitagxm/SDL_render_vita_gxm_shaders.h
new file mode 100644
index 0000000..9d13e42
--- /dev/null
+++ b/src/render/vitagxm/SDL_render_vita_gxm_shaders.h
@@ -0,0 +1,313 @@
+/*
+ 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.
+*/
+
+#ifndef SDL_RENDER_VITA_GXM_SHADERS_H
+#define SDL_RENDER_VITA_GXM_SHADERS_H
+
+#include <psp2/gxm.h>
+
+#define gxm_shader_clear_f_size 232
+static const unsigned char gxm_shader_clear_f[gxm_shader_clear_f_size] = {
+ 0x47, 0x58, 0x50, 0x00, 0x01, 0x05, 0x50, 0x03,
+ 0xe8, 0x00, 0x00, 0x00, 0xa2, 0x55, 0x22, 0x3e,
+ 0xc6, 0x7e, 0x77, 0xf1, 0x01, 0x00, 0x18, 0x00,
+ 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
+ 0xa4, 0x00, 0x00, 0x00, 0x70, 0x00, 0x00, 0x00,
+ 0x02, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x01, 0x00, 0x02, 0x00, 0x00, 0x00,
+ 0x74, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x68, 0x00, 0x00, 0x00, 0x64, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
+ 0x5c, 0x00, 0x00, 0x00, 0xc0, 0x3d, 0x03, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x50, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x50, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x40, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x38, 0x00, 0x00, 0x00,
+ 0x01, 0x00, 0x00, 0x00, 0x30, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x04,
+ 0x00, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x07, 0x44, 0xfa, 0x02, 0x80, 0x19, 0xf0,
+ 0x7e, 0x0d, 0x80, 0x40, 0x0e, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x04, 0x00, 0x10, 0x00, 0x00, 0x00,
+ 0x01, 0xe4, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x75, 0x43, 0x6c, 0x65,
+ 0x61, 0x72, 0x43, 0x6f, 0x6c, 0x6f, 0x72, 0x00,
+};
+
+#define gxm_shader_clear_v_size 252
+static const unsigned char gxm_shader_clear_v[gxm_shader_clear_v_size] = {
+ 0x47, 0x58, 0x50, 0x00, 0x01, 0x05, 0x50, 0x03,
+ 0xfa, 0x00, 0x00, 0x00, 0xdc, 0x25, 0x34, 0x74,
+ 0x53, 0x4a, 0x7a, 0x5b, 0x04, 0x00, 0x19, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
+ 0xb8, 0x00, 0x00, 0x00, 0x70, 0x00, 0x00, 0x00,
+ 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x01, 0x00, 0x04, 0x00, 0x00, 0x00,
+ 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x74, 0x00, 0x00, 0x00, 0x70, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x78, 0x00, 0x00, 0x00, 0xc0, 0x3d, 0x03, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x6c, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x64, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x5c, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x54, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x4c, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x04,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x44, 0xfa,
+ 0x01, 0x00, 0x04, 0x90, 0x85, 0x11, 0xa5, 0x08,
+ 0x01, 0x80, 0x56, 0x90, 0x81, 0x11, 0x83, 0x08,
+ 0x00, 0x00, 0x20, 0xa0, 0x00, 0x50, 0x27, 0xfb,
+ 0x10, 0x00, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00,
+ 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x61, 0x50, 0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f,
+ 0x6e, 0x00, 0x00, 0x00,
+};
+
+#define gxm_shader_color_f_size 212
+static const unsigned char gxm_shader_color_f[gxm_shader_color_f_size] = {
+ 0x47, 0x58, 0x50, 0x00, 0x01, 0x05, 0x50, 0x03,
+ 0xd4, 0x00, 0x00, 0x00, 0x9c, 0xd6, 0x9b, 0xf7,
+ 0x78, 0x00, 0x5d, 0x31, 0x01, 0x10, 0x18, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0xac, 0x00, 0x00, 0x00, 0x70, 0x00, 0x00, 0x00,
+ 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x01, 0x00, 0x02, 0x00, 0x00, 0x00,
+ 0x84, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x78, 0x00, 0x00, 0x00, 0x74, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x6c, 0x00, 0x00, 0x00, 0xc0, 0x3d, 0x03, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x60, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x58, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x50, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x48, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x40, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x04,
+ 0x01, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
+ 0x0f, 0xa0, 0xd0, 0x0e, 0x00, 0x00, 0x00, 0x00,
+ 0x30, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x07, 0x44, 0xfa, 0x02, 0x80, 0x19, 0xa0,
+ 0x7e, 0x0d, 0x80, 0x40,
+};
+
+#define gxm_shader_color_v_size 344
+static const unsigned char gxm_shader_color_v[gxm_shader_color_v_size] = {
+ 0x47, 0x58, 0x50, 0x00, 0x01, 0x05, 0x50, 0x03,
+ 0x55, 0x01, 0x00, 0x00, 0x2e, 0x35, 0x0f, 0x26,
+ 0x23, 0x46, 0x37, 0xbb, 0x00, 0x00, 0x19, 0x00,
+ 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
+ 0xe8, 0x00, 0x00, 0x00, 0x70, 0x00, 0x00, 0x00,
+ 0x08, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x01, 0x00, 0x09, 0x00, 0x00, 0x00,
+ 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x74, 0x00, 0x00, 0x00, 0x70, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
+ 0xa0, 0x00, 0x00, 0x00, 0xc0, 0x3d, 0x03, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x94, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x94, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x84, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x7c, 0x00, 0x00, 0x00,
+ 0x01, 0x00, 0x00, 0x00, 0x74, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0xf7, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x00, 0x08,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x44, 0xfa,
+ 0x80, 0x00, 0x08, 0x83, 0x21, 0x1d, 0x80, 0x38,
+ 0x02, 0x80, 0x81, 0xaf, 0x9c, 0x0d, 0xc0, 0x40,
+ 0x0e, 0x86, 0xb9, 0xff, 0xbc, 0x0d, 0xc0, 0x40,
+ 0x04, 0x11, 0x49, 0xcf, 0x80, 0x8f, 0xb1, 0x18,
+ 0x02, 0x11, 0x45, 0xcf, 0x80, 0x8f, 0xb1, 0x18,
+ 0x00, 0x11, 0x01, 0xc0, 0x81, 0x81, 0xb1, 0x18,
+ 0x01, 0xd1, 0x42, 0xc0, 0x81, 0x81, 0xb1, 0x18,
+ 0x00, 0x00, 0x20, 0xa0, 0x00, 0x50, 0x27, 0xfb,
+ 0x0e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x00,
+ 0x30, 0x00, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00,
+ 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x2a, 0x00, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00,
+ 0x01, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
+ 0x21, 0x00, 0x00, 0x00, 0x01, 0xe4, 0x00, 0x00,
+ 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x61, 0x50, 0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f,
+ 0x6e, 0x00, 0x61, 0x43, 0x6f, 0x6c, 0x6f, 0x72,
+ 0x00, 0x77, 0x76, 0x70, 0x00, 0x00, 0x00, 0x00,
+};
+
+#define gxm_shader_texture_f_size 256
+static const unsigned char gxm_shader_texture_f[gxm_shader_texture_f_size] = {
+ 0x47, 0x58, 0x50, 0x00, 0x01, 0x05, 0x50, 0x03,
+ 0x00, 0x01, 0x00, 0x00, 0x2f, 0x18, 0xe0, 0x2b,
+ 0x1f, 0x21, 0x47, 0x49, 0x01, 0x08, 0x18, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
+ 0xa4, 0x00, 0x00, 0x00, 0x70, 0x00, 0x00, 0x00,
+ 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x01, 0x00, 0x01, 0x00, 0x00, 0x00,
+ 0x84, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x78, 0x00, 0x00, 0x00, 0x74, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x64, 0x00, 0x00, 0x00, 0xc0, 0x3d, 0x03, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x58, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x50, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x48, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x40, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x38, 0x00, 0x00, 0x00,
+ 0x44, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x04,
+ 0x01, 0x00, 0x01, 0x00, 0x04, 0x00, 0x00, 0x00,
+ 0x00, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x40, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x07, 0x44, 0xfa, 0x30, 0x00, 0x00, 0x00,
+ 0x02, 0x04, 0x02, 0x00, 0x01, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x02, 0x03, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x74, 0x65, 0x78, 0x00,
+};
+
+#define gxm_shader_texture_tint_f_size 324
+static const unsigned char gxm_shader_texture_tint_f[gxm_shader_texture_tint_f_size] = {
+ 0x47, 0x58, 0x50, 0x00, 0x01, 0x05, 0x50, 0x03,
+ 0x43, 0x01, 0x00, 0x00, 0x44, 0x2f, 0x5d, 0xfe,
+ 0x9e, 0xda, 0xf8, 0x6f, 0x05, 0x08, 0x18, 0x00,
+ 0x00, 0x00, 0x00, 0x10, 0x01, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00,
+ 0xcc, 0x00, 0x00, 0x00, 0x70, 0x00, 0x00, 0x00,
+ 0x04, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x01, 0x00, 0x05, 0x00, 0x00, 0x00,
+ 0x84, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x78, 0x00, 0x00, 0x00, 0x74, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
+ 0x84, 0x00, 0x00, 0x00, 0xc0, 0x3d, 0x03, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x78, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x78, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x68, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x60, 0x00, 0x00, 0x00,
+ 0x01, 0x00, 0x00, 0x00, 0x58, 0x00, 0x00, 0x00,
+ 0x7c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x04,
+ 0x01, 0x00, 0x01, 0x00, 0x04, 0x00, 0x00, 0x00,
+ 0x00, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0xc0, 0x00, 0x00, 0x00, 0x30, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x07, 0x44, 0xfa, 0x00, 0x00, 0x00, 0x00,
+ 0x40, 0x09, 0x00, 0xf8, 0x02, 0x80, 0x99, 0xff,
+ 0xbc, 0x0d, 0xc0, 0x40, 0x02, 0x80, 0xb9, 0xaf,
+ 0xbc, 0x0d, 0x80, 0x40, 0x7c, 0x0f, 0x04, 0x00,
+ 0x86, 0x47, 0xa4, 0x10, 0x0e, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x04, 0x00, 0x40, 0x00, 0x00, 0x00,
+ 0x01, 0xe4, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x3b, 0x00, 0x00, 0x00,
+ 0x02, 0x04, 0x01, 0x00, 0x01, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x01, 0x03, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x75, 0x54, 0x69, 0x6e,
+ 0x74, 0x43, 0x6f, 0x6c, 0x6f, 0x72, 0x00, 0x74,
+ 0x65, 0x78, 0x00, 0x00,
+};
+
+#define gxm_shader_texture_v_size 344
+static const unsigned char gxm_shader_texture_v[gxm_shader_texture_v_size] = {
+ 0x47, 0x58, 0x50, 0x00, 0x01, 0x05, 0x50, 0x03,
+ 0x58, 0x01, 0x00, 0x00, 0xa3, 0x36, 0x7b, 0x62,
+ 0x1b, 0x80, 0x1c, 0xb0, 0x00, 0x00, 0x19, 0x00,
+ 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
+ 0xe8, 0x00, 0x00, 0x00, 0x70, 0x00, 0x00, 0x00,
+ 0x08, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x01, 0x00, 0x09, 0x00, 0x00, 0x00,
+ 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x74, 0x00, 0x00, 0x00, 0x70, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
+ 0xa0, 0x00, 0x00, 0x00, 0xc0, 0x3d, 0x03, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x94, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x94, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x84, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x7c, 0x00, 0x00, 0x00,
+ 0x01, 0x00, 0x00, 0x00, 0x74, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x37, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x06,
+ 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x44, 0xfa,
+ 0x80, 0x00, 0x08, 0x83, 0x21, 0x0d, 0x80, 0x38,
+ 0x02, 0x80, 0x81, 0xaf, 0x9c, 0x0d, 0xc0, 0x40,
+ 0x0e, 0x86, 0xb9, 0xff, 0xbc, 0x0d, 0xc0, 0x40,
+ 0x04, 0x11, 0x49, 0xcf, 0x80, 0x8f, 0xb1, 0x18,
+ 0x02, 0x11, 0x45, 0xcf, 0x80, 0x8f, 0xb1, 0x18,
+ 0x00, 0x11, 0x01, 0xc0, 0x81, 0x81, 0xb1, 0x18,
+ 0x01, 0xd1, 0x42, 0xc0, 0x81, 0x81, 0xb1, 0x18,
+ 0x00, 0x00, 0x20, 0xa0, 0x00, 0x50, 0x27, 0xfb,
+ 0x0e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x00,
+ 0x30, 0x00, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00,
+ 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x2a, 0x00, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00,
+ 0x01, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
+ 0x24, 0x00, 0x00, 0x00, 0x01, 0xe4, 0x00, 0x00,
+ 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x61, 0x50, 0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f,
+ 0x6e, 0x00, 0x61, 0x54, 0x65, 0x78, 0x63, 0x6f,
+ 0x6f, 0x72, 0x64, 0x00, 0x77, 0x76, 0x70, 0x00,
+};
+
+
+static const SceGxmProgram *const clearVertexProgramGxp = (const SceGxmProgram*)gxm_shader_clear_v;
+static const SceGxmProgram *const clearFragmentProgramGxp = (const SceGxmProgram *)gxm_shader_clear_f;
+static const SceGxmProgram *const colorVertexProgramGxp = (const SceGxmProgram *)gxm_shader_color_v;
+static const SceGxmProgram *const colorFragmentProgramGxp = (const SceGxmProgram *)gxm_shader_color_f;
+static const SceGxmProgram *const textureVertexProgramGxp = (const SceGxmProgram *)gxm_shader_texture_v;
+static const SceGxmProgram *const textureFragmentProgramGxp = (const SceGxmProgram *)gxm_shader_texture_f;
+static const SceGxmProgram *const textureTintFragmentProgramGxp = (const SceGxmProgram *)gxm_shader_texture_tint_f;
+
+#endif // SDL_RENDER_VITA_GXM_SHADERS_H
+
+/* vi: set ts=4 sw=4 expandtab: */
diff --git a/src/render/vitagxm/SDL_render_vita_gxm_tools.c b/src/render/vitagxm/SDL_render_vita_gxm_tools.c
new file mode 100644
index 0000000..7b0185a
--- /dev/null
+++ b/src/render/vitagxm/SDL_render_vita_gxm_tools.c
@@ -0,0 +1,1147 @@
+/*
+ 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_GXM
+
+#include "SDL_hints.h"
+#include "../SDL_sysrender.h"
+#include "SDL_log.h"
+
+#include <psp2/kernel/processmgr.h>
+#include <psp2/appmgr.h>
+#include <psp2/display.h>
+#include <psp2/gxm.h>
+#include <psp2/types.h>
+#include <psp2/kernel/sysmem.h>
+
+#include <stdio.h>
+#include <string.h>
+#include <math.h>
+#include <stdarg.h>
+#include <stdlib.h>
+
+#include "SDL_render_vita_gxm_tools.h"
+#include "SDL_render_vita_gxm_types.h"
+#include "SDL_render_vita_gxm_memory.h"
+#include "SDL_render_vita_gxm_shaders.h"
+
+static void
+init_orthographic_matrix(float *m, float left, float right, float bottom, float top, float near, float far)
+{
+ m[0x0] = 2.0f/(right-left);
+ m[0x4] = 0.0f;
+ m[0x8] = 0.0f;
+ m[0xC] = -(right+left)/(right-left);
+
+ m[0x1] = 0.0f;
+ m[0x5] = 2.0f/(top-bottom);
+ m[0x9] = 0.0f;
+ m[0xD] = -(top+bottom)/(top-bottom);
+
+ m[0x2] = 0.0f;
+ m[0x6] = 0.0f;
+ m[0xA] = -2.0f/(far-near);
+ m[0xE] = (far+near)/(far-near);
+
+ m[0x3] = 0.0f;
+ m[0x7] = 0.0f;
+ m[0xB] = 0.0f;
+ m[0xF] = 1.0f;
+}
+
+
+static void *
+patcher_host_alloc(void *user_data, unsigned int size)
+{
+ (void)user_data;
+ void *mem = SDL_malloc(size);
+ return mem;
+}
+
+static void
+patcher_host_free(void *user_data, void *mem)
+{
+ (void)user_data;
+ SDL_free(mem);
+}
+
+void *
+pool_malloc(VITA_GXM_RenderData *data, unsigned int size)
+{
+
+ if ((data->pool_index + size) < VITA_GXM_POOL_SIZE) {
+ void *addr = (void *)((unsigned int)data->pool_addr + data->pool_index);
+ data->pool_index += size;
+ return addr;
+ }
+ SDL_LogError(SDL_LOG_CATEGORY_RENDER, "POOL OVERFLOW\n");
+ return NULL;
+}
+
+void *
+pool_memalign(VITA_GXM_RenderData *data, unsigned int size, unsigned int alignment)
+{
+ unsigned int new_index = (data->pool_index + alignment - 1) & ~(alignment - 1);
+ if ((new_index + size) < VITA_GXM_POOL_SIZE) {
+ void *addr = (void *)((unsigned int)data->pool_addr + new_index);
+ data->pool_index = new_index + size;
+ return addr;
+ }
+ SDL_LogError(SDL_LOG_CATEGORY_RENDER, "POOL OVERFLOW\n");
+ return NULL;
+}
+
+static int
+tex_format_to_bytespp(SceGxmTextureFormat format)
+{
+ switch (format & 0x9f000000U) {
+ case SCE_GXM_TEXTURE_BASE_FORMAT_U8:
+ case SCE_GXM_TEXTURE_BASE_FORMAT_S8:
+ case SCE_GXM_TEXTURE_BASE_FORMAT_P8:
+ return 1;
+ case SCE_GXM_TEXTURE_BASE_FORMAT_U4U4U4U4:
+ case SCE_GXM_TEXTURE_BASE_FORMAT_U8U3U3U2:
+ case SCE_GXM_TEXTURE_BASE_FORMAT_U1U5U5U5:
+ case SCE_GXM_TEXTURE_BASE_FORMAT_U5U6U5:
+ case SCE_GXM_TEXTURE_BASE_FORMAT_S5S5U6:
+ case SCE_GXM_TEXTURE_BASE_FORMAT_U8U8:
+ case SCE_GXM_TEXTURE_BASE_FORMAT_S8S8:
+ return 2;
+ case SCE_GXM_TEXTURE_BASE_FORMAT_U8U8U8:
+ case SCE_GXM_TEXTURE_BASE_FORMAT_S8S8S8:
+ return 3;
+ case SCE_GXM_TEXTURE_BASE_FORMAT_U8U8U8U8:
+ case SCE_GXM_TEXTURE_BASE_FORMAT_S8S8S8S8:
+ case SCE_GXM_TEXTURE_BASE_FORMAT_F32:
+ case SCE_GXM_TEXTURE_BASE_FORMAT_U32:
+ case SCE_GXM_TEXTURE_BASE_FORMAT_S32:
+ default:
+ return 4;
+ }
+}
+
+static void
+display_callback(const void *callback_data)
+{
+ SceDisplayFrameBuf framebuf;
+ const VITA_GXM_DisplayData *display_data = (const VITA_GXM_DisplayData *)callback_data;
+
+ SDL_memset(&framebuf, 0x00, sizeof(SceDisplayFrameBuf));
+ framebuf.size = sizeof(SceDisplayFrameBuf);
+ framebuf.base = display_data->address;
+ framebuf.pitch = VITA_GXM_SCREEN_STRIDE;
+ framebuf.pixelformat = VITA_GXM_PIXEL_FORMAT;
+ framebuf.width = VITA_GXM_SCREEN_WIDTH;
+ framebuf.height = VITA_GXM_SCREEN_HEIGHT;
+ sceDisplaySetFrameBuf(&framebuf, SCE_DISPLAY_SETBUF_NEXTFRAME);
+
+ if (display_data->wait_vblank) {
+ sceDisplayWaitVblankStart();
+ }
+}
+
+static void
+free_fragment_programs(VITA_GXM_RenderData *data, fragment_programs *out)
+{
+ sceGxmShaderPatcherReleaseFragmentProgram(data->shaderPatcher, out->color);
+ sceGxmShaderPatcherReleaseFragmentProgram(data->shaderPatcher, out->texture);
+ sceGxmShaderPatcherReleaseFragmentProgram(data->shaderPatcher, out->textureTint);
+}
+
+static void
+make_fragment_programs(VITA_GXM_RenderData *data, fragment_programs *out,
+ const SceGxmBlendInfo *blend_info)
+{
+ int err;
+
+ err = sceGxmShaderPatcherCreateFragmentProgram(
+ data->shaderPatcher,
+ data->colorFragmentProgramId,
+ SCE_GXM_OUTPUT_REGISTER_FORMAT_UCHAR4,
+ 0,
+ blend_info,
+ colorVertexProgramGxp,
+ &out->color
+ );
+
+ if (err != SCE_OK) {
+ SDL_LogError(SDL_LOG_CATEGORY_RENDER, "Patcher create fragment failed: %d\n", err);
+ return;
+ }
+
+ err = sceGxmShaderPatcherCreateFragmentProgram(
+ data->shaderPatcher,
+ data->textureFragmentProgramId,
+ SCE_GXM_OUTPUT_REGISTER_FORMAT_UCHAR4,
+ 0,
+ blend_info,
+ textureVertexProgramGxp,
+ &out->texture
+ );
+
+ if (err != SCE_OK) {
+ SDL_LogError(SDL_LOG_CATEGORY_RENDER, "Patcher create fragment failed: %d\n", err);
+ return;
+ }
+
+ err = sceGxmShaderPatcherCreateFragmentProgram(
+ data->shaderPatcher,
+ data->textureTintFragmentProgramId,
+ SCE_GXM_OUTPUT_REGISTER_FORMAT_UCHAR4,
+ 0,
+ blend_info,
+ textureVertexProgramGxp,
+ &out->textureTint
+ );
+
+ if (err != SCE_OK) {
+ SDL_LogError(SDL_LOG_CATEGORY_RENDER, "Patcher create fragment failed: %d\n", err);
+ return;
+ }
+}
+
+
+static void
+set_stencil_mask(VITA_GXM_RenderData *data, float x, float y, float w, float h)
+{
+ color_vertex *vertices = (color_vertex *)pool_memalign(
+ data,
+ 4 * sizeof(color_vertex), // 4 vertices
+ sizeof(color_vertex)
+ );
+
+ vertices[0].x = x;
+ vertices[0].y = y;
+ vertices[0].z = +0.5f;
+ vertices[0].color = 0;
+
+ vertices[1].x = x + w;
+ vertices[1].y = y;
+ vertices[1].z = +0.5f;
+ vertices[1].color = 0;
+
+ vertices[2].x = x;
+ vertices[2].y = y + h;
+ vertices[2].z = +0.5f;
+ vertices[2].color = 0;
+
+ vertices[3].x = x + w;
+ vertices[3].y = y + h;
+ vertices[3].z = +0.5f;
+ vertices[3].color = 0;
+
+ sceGxmSetVertexProgram(data->gxm_context, data->colorVertexProgram);
+ sceGxmSetFragmentProgram(data->gxm_context, data->colorFragmentProgram);
+
+ void *vertexDefaultBuffer;
+ sceGxmReserveVertexDefaultUniformBuffer(data->gxm_context, &vertexDefaultBuffer);
+ sceGxmSetUniformDataF(vertexDefaultBuffer, data->colorWvpParam, 0, 16, data->ortho_matrix);
+
+ sceGxmSetVertexStream(data->gxm_context, 0, vertices);
+ sceGxmDraw(data->gxm_context, SCE_GXM_PRIMITIVE_TRIANGLE_STRIP, SCE_GXM_INDEX_FORMAT_U16, data->linearIndices, 4);
+}
+
+
+void
+set_clip_rectangle(VITA_GXM_RenderData *data, int x_min, int y_min, int x_max, int y_max)
+{
+ if(data->drawing) {
+ // clear the stencil buffer to 0
+ sceGxmSetFrontStencilFunc(
+ data->gxm_context,
+ SCE_GXM_STENCIL_FUNC_NEVER,
+ SCE_GXM_STENCIL_OP_ZERO,
+ SCE_GXM_STENCIL_OP_ZERO,
+ SCE_GXM_STENCIL_OP_ZERO,
+ 0xFF,
+ 0xFF
+ );
+
+ set_stencil_mask(data, 0, 0, VITA_GXM_SCREEN_WIDTH, VITA_GXM_SCREEN_HEIGHT);
+
+ // set the stencil to 1 in the desired region
+ sceGxmSetFrontStencilFunc(
+ data->gxm_context,
+ SCE_GXM_STENCIL_FUNC_NEVER,
+ SCE_GXM_STENCIL_OP_REPLACE,
+ SCE_GXM_STENCIL_OP_REPLACE,
+ SCE_GXM_STENCIL_OP_REPLACE,
+ 0xFF,
+ 0xFF
+ );
+
+ set_stencil_mask(data, x_min, y_min, x_max - x_min, y_max - y_min);
+
+ // set the stencil function to only accept pixels where the stencil is 1
+ sceGxmSetFrontStencilFunc(
+ data->gxm_context,
+ SCE_GXM_STENCIL_FUNC_EQUAL,
+ SCE_GXM_STENCIL_OP_KEEP,
+ SCE_GXM_STENCIL_OP_KEEP,
+ SCE_GXM_STENCIL_OP_KEEP,
+ 0xFF,
+ 0xFF
+ );
+ }
+}
+
+void
+unset_clip_rectangle(VITA_GXM_RenderData *data)
+{
+ sceGxmSetFrontStencilFunc(
+ data->gxm_context,
+ SCE_GXM_STENCIL_FUNC_ALWAYS,
+ SCE_GXM_STENCIL_OP_KEEP,
+ SCE_GXM_STENCIL_OP_KEEP,
+ SCE_GXM_STENCIL_OP_KEEP,
+ 0xFF,
+ 0xFF
+ );
+}
+
+int
+gxm_init(SDL_Renderer *renderer)
+{
+ unsigned int i, x, y;
+ int err;
+
+ VITA_GXM_RenderData *data = (VITA_GXM_RenderData *) renderer->driverdata;
+
+ SceGxmInitializeParams initializeParams;
+ SDL_memset(&initializeParams, 0, sizeof(SceGxmInitializeParams));
+ initializeParams.flags = 0;
+ initializeParams.displayQueueMaxPendingCount = VITA_GXM_PENDING_SWAPS;
+ initializeParams.displayQueueCallback = display_callback;
+ initializeParams.displayQueueCallbackDataSize = sizeof(VITA_GXM_DisplayData);
+ initializeParams.parameterBufferSize = SCE_GXM_DEFAULT_PARAMETER_BUFFER_SIZE;
+
+ err = sceGxmInitialize(&initializeParams);
+
+ if (err != SCE_OK) {
+ SDL_LogError(SDL_LOG_CATEGORY_RENDER, "gxm init failed: %d\n", err);
+ return err;
+ }
+
+ // allocate ring buffer memory using default sizes
+ void *vdmRingBuffer = gpu_alloc(
+ SCE_KERNEL_MEMBLOCK_TYPE_USER_RW_UNCACHE,
+ SCE_GXM_DEFAULT_VDM_RING_BUFFER_SIZE,
+ 4,
+ SCE_GXM_MEMORY_ATTRIB_READ,
+ &data->vdmRingBufferUid);
+
+ void *vertexRingBuffer = gpu_alloc(
+ SCE_KERNEL_MEMBLOCK_TYPE_USER_RW_UNCACHE,
+ SCE_GXM_DEFAULT_VERTEX_RING_BUFFER_SIZE,
+ 4,
+ SCE_GXM_MEMORY_ATTRIB_READ,
+ &data->vertexRingBufferUid);
+
+ void *fragmentRingBuffer = gpu_alloc(
+ SCE_KERNEL_MEMBLOCK_TYPE_USER_RW_UNCACHE,
+ SCE_GXM_DEFAULT_FRAGMENT_RING_BUFFER_SIZE,
+ 4,
+ SCE_GXM_MEMORY_ATTRIB_READ,
+ &data->fragmentRingBufferUid);
+
+ unsigned int fragmentUsseRingBufferOffset;
+ void *fragmentUsseRingBuffer = fragment_usse_alloc(
+ SCE_GXM_DEFAULT_FRAGMENT_USSE_RING_BUFFER_SIZE,
+ &data->fragmentUsseRingBufferUid,
+ &fragmentUsseRingBufferOffset);
+
+ SDL_memset(&data->contextParams, 0, sizeof(SceGxmContextParams));
+ data->contextParams.hostMem = SDL_malloc(SCE_GXM_MINIMUM_CONTEXT_HOST_MEM_SIZE);
+ data->contextParams.hostMemSize = SCE_GXM_MINIMUM_CONTEXT_HOST_MEM_SIZE;
+ data->contextParams.vdmRingBufferMem = vdmRingBuffer;
+ data->contextParams.vdmRingBufferMemSize = SCE_GXM_DEFAULT_VDM_RING_BUFFER_SIZE;
+ data->contextParams.vertexRingBufferMem = vertexRingBuffer;
+ data->contextParams.vertexRingBufferMemSize = SCE_GXM_DEFAULT_VERTEX_RING_BUFFER_SIZE;
+ data->contextParams.fragmentRingBufferMem = fragmentRingBuffer;
+ data->contextParams.fragmentRingBufferMemSize = SCE_GXM_DEFAULT_FRAGMENT_RING_BUFFER_SIZE;
+ data->contextParams.fragmentUsseRingBufferMem = fragmentUsseRingBuffer;
+ data->contextParams.fragmentUsseRingBufferMemSize = SCE_GXM_DEFAULT_FRAGMENT_USSE_RING_BUFFER_SIZE;
+ data->contextParams.fragmentUsseRingBufferOffset = fragmentUsseRingBufferOffset;
+
+ err = sceGxmCreateContext(&data->contextParams, &data->gxm_context);
+ if (err != SCE_OK) {
+ SDL_LogError(SDL_LOG_CATEGORY_RENDER, "create context failed: %d\n", err);
+ return err;
+ }
+
+ // set up parameters
+ SceGxmRenderTargetParams renderTargetParams;
+ SDL_memset(&renderTargetParams, 0, sizeof(SceGxmRenderTargetParams));
+ renderTargetParams.flags = 0;
+ renderTargetParams.width = VITA_GXM_SCREEN_WIDTH;
+ renderTargetParams.height = VITA_GXM_SCREEN_HEIGHT;
+ renderTargetParams.scenesPerFrame = 1;
+ renderTargetParams.multisampleMode = 0;
+ renderTargetParams.multisampleLocations = 0;
+ renderTargetParams.driverMemBlock = -1; // Invalid UID
+
+ // create the render target
+ err = sceGxmCreateRenderTarget(&renderTargetParams, &data->renderTarget);
+ if (err != SCE_OK) {
+ SDL_LogError(SDL_LOG_CATEGORY_RENDER, "render target creation failed: %d\n", err);
+ return err;
+ }
+
+ // allocate memory and sync objects for display buffers
+ for (i = 0; i < VITA_GXM_BUFFERS; i++) {
+
+ // allocate memory for display
+ data->displayBufferData[i] = gpu_alloc(
+ SCE_KERNEL_MEMBLOCK_TYPE_USER_CDRAM_RW,
+ 4 * VITA_GXM_SCREEN_STRIDE * VITA_GXM_SCREEN_HEIGHT,
+ SCE_GXM_COLOR_SURFACE_ALIGNMENT,
+ SCE_GXM_MEMORY_ATTRIB_READ | SCE_GXM_MEMORY_ATTRIB_WRITE,
+ &data->displayBufferUid[i]);
+
+ // memset the buffer to black
+ for (y = 0; y < VITA_GXM_SCREEN_HEIGHT; y++) {
+ unsigned int *row = (unsigned int *)data->displayBufferData[i] + y * VITA_GXM_SCREEN_STRIDE;
+ for (x = 0; x < VITA_GXM_SCREEN_WIDTH; x++) {
+ row[x] = 0xff000000;
+ }
+ }
+
+ // initialize a color surface for this display buffer
+ err = sceGxmColorSurfaceInit(
+ &data->displaySurface[i],
+ VITA_GXM_COLOR_FORMAT,
+ SCE_GXM_COLOR_SURFACE_LINEAR,
+ SCE_GXM_COLOR_SURFACE_SCALE_NONE,
+ SCE_GXM_OUTPUT_REGISTER_SIZE_32BIT,
+ VITA_GXM_SCREEN_WIDTH,
+ VITA_GXM_SCREEN_HEIGHT,
+ VITA_GXM_SCREEN_STRIDE,
+ data->displayBufferData[i]
+ );
+
+ if (err != SCE_OK) {
+ SDL_LogError(SDL_LOG_CATEGORY_RENDER, "color surface init failed: %d\n", err);
+ return err;
+ }
+
+
+ // create a sync object that we will associate with this buffer
+ err = sceGxmSyncObjectCreate(&data->displayBufferSync[i]);
+ if (err != SCE_OK) {
+ SDL_LogError(SDL_LOG_CATEGORY_RENDER, "sync object creation failed: %d\n", err);
+ return err;
+ }
+
+ }
+
+ // compute the memory footprint of the depth buffer
+ const unsigned int alignedWidth = ALIGN(VITA_GXM_SCREEN_WIDTH, SCE_GXM_TILE_SIZEX);
+ const unsigned int alignedHeight = ALIGN(VITA_GXM_SCREEN_HEIGHT, SCE_GXM_TILE_SIZEY);
+
+ unsigned int sampleCount = alignedWidth * alignedHeight;
+ unsigned int depthStrideInSamples = alignedWidth;
+
+ // allocate the depth buffer
+ data->depthBufferData = gpu_alloc(
+ SCE_KERNEL_MEMBLOCK_TYPE_USER_RW_UNCACHE,
+ 4 * sampleCount,
+ SCE_GXM_DEPTHSTENCIL_SURFACE_ALIGNMENT,
+ SCE_GXM_MEMORY_ATTRIB_READ | SCE_GXM_MEMORY_ATTRIB_WRITE,
+ &data->depthBufferUid);
+
+ // allocate the stencil buffer
+ data->stencilBufferData = gpu_alloc(
+ SCE_KERNEL_MEMBLOCK_TYPE_USER_RW_UNCACHE,
+ 4 * sampleCount,
+ SCE_GXM_DEPTHSTENCIL_SURFACE_ALIGNMENT,
+ SCE_GXM_MEMORY_ATTRIB_READ | SCE_GXM_MEMORY_ATTRIB_WRITE,
+ &data->stencilBufferUid);
+
+ // create the SceGxmDepthStencilSurface structure
+ err = sceGxmDepthStencilSurfaceInit(
+ &data->depthSurface,
+ SCE_GXM_DEPTH_STENCIL_FORMAT_S8D24,
+ SCE_GXM_DEPTH_STENCIL_SURFACE_TILED,
+ depthStrideInSamples,
+ data->depthBufferData,
+ data->stencilBufferData);
+
+ // set the stencil test reference (this is currently assumed to always remain 1 after here for region clipping)
+ sceGxmSetFrontStencilRef(data->gxm_context, 1);
+
+
+ // set the stencil function (this wouldn't actually be needed, as the set clip rectangle function has to call this at the begginning of every scene)
+ sceGxmSetFrontStencilFunc(
+ data->gxm_context,
+ SCE_GXM_STENCIL_FUNC_ALWAYS,
+ SCE_GXM_STENCIL_OP_KEEP,
+ SCE_GXM_STENCIL_OP_KEEP,
+ SCE_GXM_STENCIL_OP_KEEP,
+ 0xFF,
+ 0xFF);
+
+ // set buffer sizes for this sample
+ const unsigned int patcherBufferSize = 64*1024;
+ const unsigned int patcherVertexUsseSize = 64*1024;
+ const unsigned int patcherFragmentUsseSize = 64*1024;
+
+ // allocate memory for buffers and USSE code
+ void *patcherBuffer = gpu_alloc(
+ SCE_KERNEL_MEMBLOCK_TYPE_USER_RW_UNCACHE,
+ patcherBufferSize,
+ 4,
+ SCE_GXM_MEMORY_ATTRIB_READ | SCE_GXM_MEMORY_ATTRIB_WRITE,
+ &data->patcherBufferUid);
+
+ unsigned int patcherVertexUsseOffset;
+ void *patcherVertexUsse = vertex_usse_alloc(
+ patcherVertexUsseSize,
+ &data->patcherVertexUsseUid,
+ &patcherVertexUsseOffset);
+
+ unsigned int patcherFragmentUsseOffset;
+ void *patcherFragmentUsse = fragment_usse_alloc(
+ patcherFragmentUsseSize,
+ &data->patcherFragmentUsseUid,
+ &patcherFragmentUsseOffset);
+
+ // create a shader patcher
+ SceGxmShaderPatcherParams patcherParams;
+ SDL_memset(&patcherParams, 0, sizeof(SceGxmShaderPatcherParams));
+ patcherParams.userData = NULL;
+ patcherParams.hostAllocCallback = &patcher_host_alloc;
+ patcherParams.hostFreeCallback = &patcher_host_free;
+ patcherParams.bufferAllocCallback = NULL;
+ patcherParams.bufferFreeCallback = NULL;
+ patcherParams.bufferMem = patcherBuffer;
+ patcherParams.bufferMemSize = patcherBufferSize;
+ patcherParams.vertexUsseAllocCallback = NULL;
+ patcherParams.vertexUsseFreeCallback = NULL;
+ patcherParams.vertexUsseMem = patcherVertexUsse;
+ patcherParams.vertexUsseMemSize = patcherVertexUsseSize;
+ patcherParams.vertexUsseOffset = patcherVertexUsseOffset;
+ patcherParams.fragmentUsseAllocCallback = NULL;
+ patcherParams.fragmentUsseFreeCallback = NULL;
+ patcherParams.fragmentUsseMem = patcherFragmentUsse;
+ patcherParams.fragmentUsseMemSize = patcherFragmentUsseSize;
+ patcherParams.fragmentUsseOffset = patcherFragmentUsseOffset;
+
+ err = sceGxmShaderPatcherCreate(&patcherParams, &data->shaderPatcher);
+ if (err != SCE_OK) {
+ SDL_LogError(SDL_LOG_CATEGORY_RENDER, "shader patcher creation failed: %d\n", err);
+ return err;
+ }
+
+
+ // check the shaders
+ err = sceGxmProgramCheck(clearVertexProgramGxp);
+ if (err != SCE_OK) {
+ SDL_LogError(SDL_LOG_CATEGORY_RENDER, "check program (clear vertex) failed: %d\n", err);
+ return err;
+ }
+
+ err = sceGxmProgramCheck(clearFragmentProgramGxp);
+ if (err != SCE_OK) {
+ SDL_LogError(SDL_LOG_CATEGORY_RENDER, "check program (clear fragment) failed: %d\n", err);
+ return err;
+ }
+
+ err = sceGxmProgramCheck(colorVertexProgramGxp);
+ if (err != SCE_OK) {
+ SDL_LogError(SDL_LOG_CATEGORY_RENDER, "check program (color vertex) failed: %d\n", err);
+ return err;
+ }
+
+ err = sceGxmProgramCheck(colorFragmentProgramGxp);
+ if (err != SCE_OK) {
+ SDL_LogError(SDL_LOG_CATEGORY_RENDER, "check program (color fragment) failed: %d\n", err);
+ return err;
+ }
+
+ err = sceGxmProgramCheck(textureVertexProgramGxp);
+ if (err != SCE_OK) {
+ SDL_LogError(SDL_LOG_CATEGORY_RENDER, "check program (texture vertex) failed: %d\n", err);
+ return err;
+ }
+
+ err = sceGxmProgramCheck(textureFragmentProgramGxp);
+ if (err != SCE_OK) {
+ SDL_LogError(SDL_LOG_CATEGORY_RENDER, "check program (texture fragment) failed: %d\n", err);
+ return err;
+ }
+
+ err = sceGxmProgramCheck(textureTintFragmentProgramGxp);
+ if (err != SCE_OK) {
+ SDL_LogError(SDL_LOG_CATEGORY_RENDER, "check program (texture tint fragment) failed: %d\n", err);
+ return err;
+ }
+
+ // register programs with the patcher
+ err = sceGxmShaderPatcherRegisterProgram(data->shaderPatcher, clearVertexProgramGxp, &data->clearVertexProgramId);
+ if (err != SCE_OK) {
+ SDL_LogError(SDL_LOG_CATEGORY_RENDER, "register program (clear vertex) failed: %d\n", err);
+ return err;
+ }
+
+ err = sceGxmShaderPatcherRegisterProgram(data->shaderPatcher, clearFragmentProgramGxp, &data->clearFragmentProgramId);
+ if (err != SCE_OK) {
+ SDL_LogError(SDL_LOG_CATEGORY_RENDER, "register program (clear fragment) failed: %d\n", err);
+ return err;
+ }
+
+ err = sceGxmShaderPatcherRegisterProgram(data->shaderPatcher, colorVertexProgramGxp, &data->colorVertexProgramId);
+ if (err != SCE_OK) {
+ SDL_LogError(SDL_LOG_CATEGORY_RENDER, "register program (color vertex) failed: %d\n", err);
+ return err;
+ }
+
+ err = sceGxmShaderPatcherRegisterProgram(data->shaderPatcher, colorFragmentProgramGxp, &data->colorFragmentProgramId);
+ if (err != SCE_OK) {
+ SDL_LogError(SDL_LOG_CATEGORY_RENDER, "register program (color fragment) failed: %d\n", err);
+ return err;
+ }
+
+ err = sceGxmShaderPatcherRegisterProgram(data->shaderPatcher, textureVertexProgramGxp, &data->textureVertexProgramId);
+ if (err != SCE_OK) {
+ SDL_LogError(SDL_LOG_CATEGORY_RENDER, "register program (texture vertex) failed: %d\n", err);
+ return err;
+ }
+
+ err = sceGxmShaderPatcherRegisterProgram(data->shaderPatcher, textureFragmentProgramGxp, &data->textureFragmentProgramId);
+ if (err != SCE_OK) {
+ SDL_LogError(SDL_LOG_CATEGORY_RENDER, "register program (texture fragment) failed: %d\n", err);
+ return err;
+ }
+
+ err = sceGxmShaderPatcherRegisterProgram(data->shaderPatcher, textureTintFragmentProgramGxp, &data->textureTintFragmentProgramId);
+ if (err != SCE_OK) {
+ SDL_LogError(SDL_LOG_CATEGORY_RENDER, "register program (texture tint fragment) failed: %d\n", err);
+ return err;
+ }
+
+ // Fill SceGxmBlendInfo
+ static const SceGxmBlendInfo blend_info_none = {
+ .colorFunc = SCE_GXM_BLEND_FUNC_NONE,
+ .alphaFunc = SCE_GXM_BLEND_FUNC_NONE,
+ .colorSrc = SCE_GXM_BLEND_FACTOR_ZERO,
+ .colorDst = SCE_GXM_BLEND_FACTOR_ZERO,
+ .alphaSrc = SCE_GXM_BLEND_FACTOR_ZERO,
+ .alphaDst = SCE_GXM_BLEND_FACTOR_ZERO,
+ .colorMask = SCE_GXM_COLOR_MASK_ALL
+ };
+
+ static const SceGxmBlendInfo blend_info_blend = {
+ .colorFunc = SCE_GXM_BLEND_FUNC_ADD,
+ .alphaFunc = SCE_GXM_BLEND_FUNC_ADD,
+ .colorSrc = SCE_GXM_BLEND_FACTOR_SRC_ALPHA,
+ .colorDst = SCE_GXM_BLEND_FACTOR_ONE_MINUS_SRC_ALPHA,
+ .alphaSrc = SCE_GXM_BLEND_FACTOR_ONE,
+ .alphaDst = SCE_GXM_BLEND_FACTOR_ONE_MINUS_SRC_ALPHA,
+ .colorMask = SCE_GXM_COLOR_MASK_ALL
+ };
+
+ static const SceGxmBlendInfo blend_info_add = {
+ .colorFunc = SCE_GXM_BLEND_FUNC_ADD,
+ .alphaFunc = SCE_GXM_BLEND_FUNC_ADD,
+ .colorSrc = SCE_GXM_BLEND_FACTOR_SRC_ALPHA,
+ .colorDst = SCE_GXM_BLEND_FACTOR_ONE,
+ .alphaSrc = SCE_GXM_BLEND_FACTOR_ZERO,
+ .alphaDst = SCE_GXM_BLEND_FACTOR_ONE,
+ .colorMask = SCE_GXM_COLOR_MASK_ALL
+ };
+
+ static const SceGxmBlendInfo blend_info_mod = {
+ .colorFunc = SCE_GXM_BLEND_FUNC_ADD,
+ .alphaFunc = SCE_GXM_BLEND_FUNC_ADD,
+
+ .colorSrc = SCE_GXM_BLEND_FACTOR_ZERO,
+ .colorDst = SCE_GXM_BLEND_FACTOR_SRC_COLOR,
+
+ .alphaSrc = SCE_GXM_BLEND_FACTOR_ZERO,
+ .alphaDst = SCE_GXM_BLEND_FACTOR_ONE,
+ .colorMask = SCE_GXM_COLOR_MASK_ALL
+ };
+
+ static const SceGxmBlendInfo blend_info_mul = {
+ .colorFunc = SCE_GXM_BLEND_FUNC_ADD,
+ .alphaFunc = SCE_GXM_BLEND_FUNC_ADD,
+ .colorSrc = SCE_GXM_BLEND_FACTOR_DST_COLOR,
+ .colorDst = SCE_GXM_BLEND_FACTOR_ONE_MINUS_SRC_ALPHA,
+ .alphaSrc = SCE_GXM_BLEND_FACTOR_DST_ALPHA,
+ .alphaDst = SCE_GXM_BLEND_FACTOR_ONE_MINUS_SRC_ALPHA,
+ .colorMask = SCE_GXM_COLOR_MASK_ALL
+ };
+
+ // get attributes by name to create vertex format bindings
+ const SceGxmProgramParameter *paramClearPositionAttribute = sceGxmProgramFindParameterByName(clearVertexProgramGxp, "aPosition");
+
+ // create clear vertex format
+ SceGxmVertexAttribute clearVertexAttributes[1];
+ SceGxmVertexStream clearVertexStreams[1];
+ clearVertexAttributes[0].streamIndex = 0;
+ clearVertexAttributes[0].offset = 0;
+ clearVertexAttributes[0].format = SCE_GXM_ATTRIBUTE_FORMAT_F32;
+ clearVertexAttributes[0].componentCount = 2;
+ clearVertexAttributes[0].regIndex = sceGxmProgramParameterGetResourceIndex(paramClearPositionAttribute);
+ clearVertexStreams[0].stride = sizeof(clear_vertex);
+ clearVertexStreams[0].indexSource = SCE_GXM_INDEX_SOURCE_INDEX_16BIT;
+
+ // create clear programs
+ err = sceGxmShaderPatcherCreateVertexProgram(
+ data->shaderPatcher,
+ data->clearVertexProgramId,
+ clearVertexAttributes,
+ 1,
+ clearVertexStreams,
+ 1,
+ &data->clearVertexProgram
+ );
+ if (err != SCE_OK) {
+ SDL_LogError(SDL_LOG_CATEGORY_RENDER, "create program (clear vertex) failed: %d\n", err);
+ return err;
+ }
+
+ err = sceGxmShaderPatcherCreateFragmentProgram(
+ data->shaderPatcher,
+ data->clearFragmentProgramId,
+ SCE_GXM_OUTPUT_REGISTER_FORMAT_UCHAR4,
+ 0,
+ NULL,
+ clearVertexProgramGxp,
+ &data->clearFragmentProgram
+ );
+ if (err != SCE_OK) {
+ SDL_LogError(SDL_LOG_CATEGORY_RENDER, "create program (clear fragment) failed: %d\n", err);
+ return err;
+ }
+
+ // create the clear triangle vertex/index data
+ data->clearVertices = (clear_vertex *)gpu_alloc(
+ SCE_KERNEL_MEMBLOCK_TYPE_USER_RW_UNCACHE,
+ 3*sizeof(clear_vertex),
+ 4,
+ SCE_GXM_MEMORY_ATTRIB_READ,
+ &data->clearVerticesUid
+ );
+
+ // Allocate a 64k * 2 bytes = 128 KiB buffer and store all possible
+ // 16-bit indices in linear ascending order, so we can use this for
+ // all drawing operations where we don't want to use indexing.
+ data->linearIndices = (uint16_t *)gpu_alloc(
+ SCE_KERNEL_MEMBLOCK_TYPE_USER_RW_UNCACHE,
+ UINT16_MAX*sizeof(uint16_t),
+ sizeof(uint16_t),
+ SCE_GXM_MEMORY_ATTRIB_READ,
+ &data->linearIndicesUid
+ );
+
+ for (uint32_t i=0; i<=UINT16_MAX; ++i)
+ {
+ data->linearIndices[i] = i;
+ }
+
+ data->clearVertices[0].x = -1.0f;
+ data->clearVertices[0].y = -1.0f;
+ data->clearVertices[1].x = 3.0f;
+ data->clearVertices[1].y = -1.0f;
+ data->clearVertices[2].x = -1.0f;
+ data->clearVertices[2].y = 3.0f;
+
+ const SceGxmProgramParameter *paramColorPositionAttribute = sceGxmProgramFindParameterByName(colorVertexProgramGxp, "aPosition");
+
+ const SceGxmProgramParameter *paramColorColorAttribute = sceGxmProgramFindParameterByName(colorVertexProgramGxp, "aColor");
+
+ // create color vertex format
+ SceGxmVertexAttribute colorVertexAttributes[2];
+ SceGxmVertexStream colorVertexStreams[1];
+ /* x,y,z: 3 float 32 bits */
+ colorVertexAttributes[0].streamIndex = 0;
+ colorVertexAttributes[0].offset = 0;
+ colorVertexAttributes[0].format = SCE_GXM_ATTRIBUTE_FORMAT_F32;
+ colorVertexAttributes[0].componentCount = 3; // (x, y, z)
+ colorVertexAttributes[0].regIndex = sceGxmProgramParameterGetResourceIndex(paramColorPositionAttribute);
+ /* color: 4 unsigned char = 32 bits */
+ colorVertexAttributes[1].streamIndex = 0;
+ colorVertexAttributes[1].offset = 12; // (x, y, z) * 4 = 12 bytes
+ colorVertexAttributes[1].format = SCE_GXM_ATTRIBUTE_FORMAT_U8N;
+ colorVertexAttributes[1].componentCount = 4; // (color)
+ colorVertexAttributes[1].regIndex = sceGxmProgramParameterGetResourceIndex(paramColorColorAttribute);
+ // 16 bit (short) indices
+ colorVertexStreams[0].stride = sizeof(color_vertex);
+ colorVertexStreams[0].indexSource = SCE_GXM_INDEX_SOURCE_INDEX_16BIT;
+
+ // create color shaders
+ err = sceGxmShaderPatcherCreateVertexProgram(
+ data->shaderPatcher,
+ data->colorVertexProgramId,
+ colorVertexAttributes,
+ 2,
+ colorVertexStreams,
+ 1,
+ &data->colorVertexProgram
+ );
+ if (err != SCE_OK) {
+ SDL_LogError(SDL_LOG_CATEGORY_RENDER, "create program (color vertex) failed: %d\n", err);
+ return err;
+ }
+
+ const SceGxmProgramParameter *paramTexturePositionAttribute = sceGxmProgramFindParameterByName(textureVertexProgramGxp, "aPosition");
+ const SceGxmProgramParameter *paramTextureTexcoordAttribute = sceGxmProgramFindParameterByName(textureVertexProgramGxp, "aTexcoord");
+
+ // create texture vertex format
+ SceGxmVertexAttribute textureVertexAttributes[2];
+ SceGxmVertexStream textureVertexStreams[1];
+ /* x,y,z: 3 float 32 bits */
+ textureVertexAttributes[0].streamIndex = 0;
+ textureVertexAttributes[0].offset = 0;
+ textureVertexAttributes[0].format = SCE_GXM_ATTRIBUTE_FORMAT_F32;
+ textureVertexAttributes[0].componentCount = 3; // (x, y, z)
+ textureVertexAttributes[0].regIndex = sceGxmProgramParameterGetResourceIndex(paramTexturePositionAttribute);
+ /* u,v: 2 floats 32 bits */
+ textureVertexAttributes[1].streamIndex = 0;
+ textureVertexAttributes[1].offset = 12; // (x, y, z) * 4 = 12 bytes
+ textureVertexAttributes[1].format = SCE_GXM_ATTRIBUTE_FORMAT_F32;
+ textureVertexAttributes[1].componentCount = 2; // (u, v)
+ textureVertexAttributes[1].regIndex = sceGxmProgramParameterGetResourceIndex(paramTextureTexcoordAttribute);
+ // 16 bit (short) indices
+ textureVertexStreams[0].stride = sizeof(texture_vertex);
+ textureVertexStreams[0].indexSource = SCE_GXM_INDEX_SOURCE_INDEX_16BIT;
+
+ // create texture shaders
+ err = sceGxmShaderPatcherCreateVertexProgram(
+ data->shaderPatcher,
+ data->textureVertexProgramId,
+ textureVertexAttributes,
+ 2,
+ textureVertexStreams,
+ 1,
+ &data->textureVertexProgram
+ );
+ if (err != SCE_OK) {
+ SDL_LogError(SDL_LOG_CATEGORY_RENDER, "create program (texture vertex) failed: %d\n", err);
+ return err;
+ }
+
+ // Create variations of the fragment program based on blending mode
+ make_fragment_programs(data, &data->blendFragmentPrograms.blend_mode_none, &blend_info_none);
+ make_fragment_programs(data, &data->blendFragmentPrograms.blend_mode_blend, &blend_info_blend);
+ make_fragment_programs(data, &data->blendFragmentPrograms.blend_mode_add, &blend_info_add);
+ make_fragment_programs(data, &data->blendFragmentPrograms.blend_mode_mod, &blend_info_mod);
+ make_fragment_programs(data, &data->blendFragmentPrograms.blend_mode_mul, &blend_info_mul);
+
+ // Default to blend blending mode
+ fragment_programs *in = &data->blendFragmentPrograms.blend_mode_blend;
+
+ data->colorFragmentProgram = in->color;
+ data->textureFragmentProgram = in->texture;
+ data->textureTintFragmentProgram = in->textureTint;
+
+ // find vertex uniforms by name and cache parameter information
+ data->clearClearColorParam = (SceGxmProgramParameter *)sceGxmProgramFindParameterByName(clearFragmentProgramGxp, "uClearColor");
+ data->colorWvpParam = (SceGxmProgramParameter *)sceGxmProgramFindParameterByName(colorVertexProgramGxp, "wvp");
+ data->textureWvpParam = (SceGxmProgramParameter *)sceGxmProgramFindParameterByName(textureVertexProgramGxp, "wvp");
+ data->textureTintColorParam = (SceGxmProgramParameter *)sceGxmProgramFindParameterByName(textureTintFragmentProgramGxp, "uTintColor");
+
+ // Allocate memory for the memory pool
+ data->pool_addr = gpu_alloc(
+ SCE_KERNEL_MEMBLOCK_TYPE_USER_RW,
+ VITA_GXM_POOL_SIZE,
+ sizeof(void *),
+ SCE_GXM_MEMORY_ATTRIB_READ,
+ &data->poolUid
+ );
+
+ init_orthographic_matrix(data->ortho_matrix, 0.0f, VITA_GXM_SCREEN_WIDTH, VITA_GXM_SCREEN_HEIGHT, 0.0f, 0.0f, 1.0f);
+
+ data->backBufferIndex = 0;
+ data->frontBufferIndex = 0;
+ data->pool_index = 0;
+
+ return 0;
+}
+
+void gxm_finish(SDL_Renderer *renderer)
+{
+ VITA_GXM_RenderData *data = (VITA_GXM_RenderData *) renderer->driverdata;
+
+ // wait until rendering is done
+ sceGxmFinish(data->gxm_context);
+
+ // clean up allocations
+ sceGxmShaderPatcherReleaseFragmentProgram(data->shaderPatcher, data->clearFragmentProgram);
+ sceGxmShaderPatcherReleaseVertexProgram(data->shaderPatcher, data->clearVertexProgram);
+ sceGxmShaderPatcherReleaseVertexProgram(data->shaderPatcher, data->colorVertexProgram);
+ sceGxmShaderPatcherReleaseVertexProgram(data->shaderPatcher, data->textureVertexProgram);
+
+
+ free_fragment_programs(data, &data->blendFragmentPrograms.blend_mode_none);
+ free_fragment_programs(data, &data->blendFragmentPrograms.blend_mode_blend);
+ free_fragment_programs(data, &data->blendFragmentPrograms.blend_mode_add);
+ free_fragment_programs(data, &data->blendFragmentPrograms.blend_mode_mod);
+ free_fragment_programs(data, &data->blendFragmentPrograms.blend_mode_mul);
+
+ gpu_free(data->linearIndicesUid);
+ gpu_free(data->clearVerticesUid);
+
+ // wait until display queue is finished before deallocating display buffers
+ sceGxmDisplayQueueFinish();
+
+ // clean up display queue
+ gpu_free(data->depthBufferUid);
+
+ for (size_t i = 0; i < VITA_GXM_BUFFERS; i++)
+ {
+ // clear the buffer then deallocate
+ SDL_memset(data->displayBufferData[i], 0, VITA_GXM_SCREEN_HEIGHT * VITA_GXM_SCREEN_STRIDE * 4);
+ gpu_free(data->displayBufferUid[i]);
+
+ // destroy the sync object
+ sceGxmSyncObjectDestroy(data->displayBufferSync[i]);
+ }
+
+ // free the depth and stencil buffer
+ gpu_free(data->depthBufferUid);
+ gpu_free(data->stencilBufferUid);
+
+ // unregister programs and destroy shader patcher
+ sceGxmShaderPatcherUnregisterProgram(data->shaderPatcher, data->clearFragmentProgramId);
+ sceGxmShaderPatcherUnregisterProgram(data->shaderPatcher, data->clearVertexProgramId);
+ sceGxmShaderPatcherUnregisterProgram(data->shaderPatcher, data->colorFragmentProgramId);
+ sceGxmShaderPatcherUnregisterProgram(data->shaderPatcher, data->colorVertexProgramId);
+ sceGxmShaderPatcherUnregisterProgram(data->shaderPatcher, data->textureFragmentProgramId);
+ sceGxmShaderPatcherUnregisterProgram(data->shaderPatcher, data->textureTintFragmentProgramId);
+ sceGxmShaderPatcherUnregisterProgram(data->shaderPatcher, data->textureVertexProgramId);
+
+ sceGxmShaderPatcherDestroy(data->shaderPatcher);
+ fragment_usse_free(data->patcherFragmentUsseUid);
+ vertex_usse_free(data->patcherVertexUsseUid);
+ gpu_free(data->patcherBufferUid);
+
+ // destroy the render target
+ sceGxmDestroyRenderTarget(data->renderTarget);
+
+ // destroy the gxm context
+ sceGxmDestroyContext(data->gxm_context);
+ fragment_usse_free(data->fragmentUsseRingBufferUid);
+ gpu_free(data->fragmentRingBufferUid);
+ gpu_free(data->vertexRingBufferUid);
+ gpu_free(data->vdmRingBufferUid);
+ SDL_free(data->contextParams.hostMem);
+
+ gpu_free(data->poolUid);
+
+ // terminate libgxm
+ sceGxmTerminate();
+}
+
+// textures
+
+void
+free_gxm_texture(gxm_texture *texture)
+{
+ if (texture) {
+ if (texture->gxm_rendertarget) {
+ sceGxmDestroyRenderTarget(texture->gxm_rendertarget);
+ }
+ if (texture->depth_UID) {
+ gpu_free(texture->depth_UID);
+ }
+ if (texture->palette_UID) {
+ gpu_free(texture->palette_UID);
+ }
+ gpu_free(texture->data_UID);
+ SDL_free(texture);
+ }
+}
+
+SceGxmTextureFormat
+gxm_texture_get_format(const gxm_texture *texture)
+{
+ return sceGxmTextureGetFormat(&texture->gxm_tex);
+}
+
+unsigned int
+gxm_texture_get_width(const gxm_texture *texture)
+{
+ return sceGxmTextureGetWidth(&texture->gxm_tex);
+}
+
+unsigned int
+gxm_texture_get_height(const gxm_texture *texture)
+{
+ return sceGxmTextureGetHeight(&texture->gxm_tex);
+}
+
+unsigned int
+gxm_texture_get_stride(const gxm_texture *texture)
+{
+ return ((gxm_texture_get_width(texture) + 7) & ~7)
+ * tex_format_to_bytespp(gxm_texture_get_format(texture));
+}
+
+void *
+gxm_texture_get_datap(const gxm_texture *texture)
+{
+ return sceGxmTextureGetData(&texture->gxm_tex);
+}
+
+gxm_texture *
+create_gxm_texture(VITA_GXM_RenderData *data, unsigned int w, unsigned int h, SceGxmTextureFormat format, unsigned int isRenderTarget)
+{
+ format = SCE_GXM_TEXTURE_FORMAT_A8B8G8R8;
+ gxm_texture *texture = SDL_malloc(sizeof(gxm_texture));
+ if (!texture)
+ return NULL;
+
+ const int tex_size = ((w + 7) & ~ 7) * h * tex_format_to_bytespp(format);
+
+ /* Allocate a GPU buffer for the texture */
+ void *texture_data = gpu_alloc(
+ SCE_KERNEL_MEMBLOCK_TYPE_USER_CDRAM_RW,
+ tex_size,
+ SCE_GXM_TEXTURE_ALIGNMENT,
+ SCE_GXM_MEMORY_ATTRIB_READ | SCE_GXM_MEMORY_ATTRIB_WRITE,
+ &texture->data_UID
+ );
+
+ if (!texture_data) {
+ free(texture);
+ return NULL;
+ }
+
+ /* Clear the texture */
+ SDL_memset(texture_data, 0, tex_size);
+
+ /* Create the gxm texture */
+ sceGxmTextureInitLinear( &texture->gxm_tex, texture_data, format, w, h, 0);
+
+ if ((format & 0x9f000000U) == SCE_GXM_TEXTURE_BASE_FORMAT_P8) {
+ const int pal_size = 256 * sizeof(uint32_t);
+
+ void *texture_palette = gpu_alloc(
+ SCE_KERNEL_MEMBLOCK_TYPE_USER_CDRAM_RW,
+ pal_size,
+ SCE_GXM_PALETTE_ALIGNMENT,
+ SCE_GXM_MEMORY_ATTRIB_READ,
+ &texture->palette_UID);
+
+ if (!texture_palette) {
+ texture->palette_UID = 0;
+ free_gxm_texture(texture);
+ return NULL;
+ }
+
+ SDL_memset(texture_palette, 0, pal_size);
+
+ sceGxmTextureSetPalette(&texture->gxm_tex, texture_palette);
+ } else {
+ texture->palette_UID = 0;
+ }
+
+ if (isRenderTarget) {
+
+ int err = sceGxmColorSurfaceInit(
+ &texture->gxm_colorsurface,
+ SCE_GXM_COLOR_FORMAT_A8B8G8R8,
+ SCE_GXM_COLOR_SURFACE_LINEAR,
+ SCE_GXM_COLOR_SURFACE_SCALE_NONE,
+ SCE_GXM_OUTPUT_REGISTER_SIZE_32BIT,
+ w,
+ h,
+ w,
+ texture_data
+ );
+
+ if (err < 0) {
+ free_gxm_texture(texture);
+ SDL_LogError(SDL_LOG_CATEGORY_RENDER, "color surface init failed: %d\n", err);
+ return NULL;
+ }
+
+ // create the depth/stencil surface
+ const uint32_t alignedWidth = ALIGN(w, SCE_GXM_TILE_SIZEX);
+ const uint32_t alignedHeight = ALIGN(h, SCE_GXM_TILE_SIZEY);
+ uint32_t sampleCount = alignedWidth*alignedHeight;
+ uint32_t depthStrideInSamples = alignedWidth;
+
+ // allocate it
+ void *depthBufferData = gpu_alloc(
+ SCE_KERNEL_MEMBLOCK_TYPE_USER_RW_UNCACHE,
+ 4*sampleCount,
+ SCE_GXM_DEPTHSTENCIL_SURFACE_ALIGNMENT,
+ SCE_GXM_MEMORY_ATTRIB_READ | SCE_GXM_MEMORY_ATTRIB_WRITE,
+ &texture->depth_UID);
+
+ // create the SceGxmDepthStencilSurface structure
+ err = sceGxmDepthStencilSurfaceInit(
+ &texture->gxm_depthstencil,
+ SCE_GXM_DEPTH_STENCIL_FORMAT_S8D24,
+ SCE_GXM_DEPTH_STENCIL_SURFACE_TILED,
+ depthStrideInSamples,
+ depthBufferData,
+ NULL);
+
+ if (err < 0) {
+ free_gxm_texture(texture);
+ SDL_LogError(SDL_LOG_CATEGORY_RENDER, "depth stencil init failed: %d\n", err);
+ return NULL;
+ }
+
+ SceGxmRenderTarget *tgt = NULL;
+
+ // set up parameters
+ SceGxmRenderTargetParams renderTargetParams;
+ memset(&renderTargetParams, 0, sizeof(SceGxmRenderTargetParams));
+ renderTargetParams.flags = 0;
+ renderTargetParams.width = w;
+ renderTargetParams.height = h;
+ renderTargetParams.scenesPerFrame = 1;
+ renderTargetParams.multisampleMode = SCE_GXM_MULTISAMPLE_NONE;
+ renderTargetParams.multisampleLocations = 0;
+ renderTargetParams.driverMemBlock = -1;
+
+ // create the render target
+ err = sceGxmCreateRenderTarget(&renderTargetParams, &tgt);
+
+ texture->gxm_rendertarget = tgt;
+
+ if (err < 0) {
+ free_gxm_texture(texture);
+ SDL_LogError(SDL_LOG_CATEGORY_RENDER, "create render target failed: %d\n", err);
+ return NULL;
+ }
+
+ }
+
+ return texture;
+}
+
+void
+gxm_texture_set_filters(gxm_texture *texture, SceGxmTextureFilter min_filter, SceGxmTextureFilter mag_filter)
+{
+ sceGxmTextureSetMinFilter(&texture->gxm_tex, min_filter);
+ sceGxmTextureSetMagFilter(&texture->gxm_tex, mag_filter);
+}
+
+#endif /* SDL_VIDEO_RENDER_VITA_GXM */
+
+/* vi: set ts=4 sw=4 expandtab: */
diff --git a/src/render/vitagxm/SDL_render_vita_gxm_tools.h b/src/render/vitagxm/SDL_render_vita_gxm_tools.h
new file mode 100644
index 0000000..5787e4d
--- /dev/null
+++ b/src/render/vitagxm/SDL_render_vita_gxm_tools.h
@@ -0,0 +1,61 @@
+/*
+ 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.
+*/
+
+#ifndef SDL_RENDER_VITA_GXM_TOOLS_H
+#define SDL_RENDER_VITA_GXM_TOOLS_H
+
+#include "../../SDL_internal.h"
+
+#include "SDL_hints.h"
+#include "../SDL_sysrender.h"
+
+#include <psp2/kernel/processmgr.h>
+#include <psp2/appmgr.h>
+#include <psp2/display.h>
+#include <psp2/gxm.h>
+#include <psp2/types.h>
+#include <psp2/kernel/sysmem.h>
+
+#include "SDL_render_vita_gxm_types.h"
+
+void *pool_malloc(VITA_GXM_RenderData *data, unsigned int size);
+void *pool_memalign(VITA_GXM_RenderData *data, unsigned int size, unsigned int alignment);
+
+void set_clip_rectangle(VITA_GXM_RenderData *data, int x_min, int y_min, int x_max, int y_max);
+void unset_clip_rectangle(VITA_GXM_RenderData *data);
+
+int gxm_init(SDL_Renderer *renderer);
+void gxm_finish(SDL_Renderer *renderer);
+
+gxm_texture *create_gxm_texture(VITA_GXM_RenderData *data, unsigned int w, unsigned int h, SceGxmTextureFormat format, unsigned int isRenderTarget);
+void free_gxm_texture(gxm_texture *texture);
+
+void gxm_texture_set_filters(gxm_texture *texture, SceGxmTextureFilter min_filter, SceGxmTextureFilter mag_filter);
+SceGxmTextureFormat gxm_texture_get_format(const gxm_texture *texture);
+
+unsigned int gxm_texture_get_width(const gxm_texture *texture);
+unsigned int gxm_texture_get_height(const gxm_texture *texture);
+unsigned int gxm_texture_get_stride(const gxm_texture *texture);
+void *gxm_texture_get_datap(const gxm_texture *texture);
+
+#endif /* SDL_RENDER_VITA_GXM_TOOLS_H */
+
+/* vi: set ts=4 sw=4 expandtab: */
diff --git a/src/render/vitagxm/SDL_render_vita_gxm_types.h b/src/render/vitagxm/SDL_render_vita_gxm_types.h
new file mode 100644
index 0000000..cc4e5f2
--- /dev/null
+++ b/src/render/vitagxm/SDL_render_vita_gxm_types.h
@@ -0,0 +1,194 @@
+/*
+ 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.
+*/
+
+#ifndef SDL_RENDER_VITA_GXM_TYPES_H
+#define SDL_RENDER_VITA_GXM_TYPES_H
+
+#include "../../SDL_internal.h"
+
+#include "SDL_hints.h"
+#include "../SDL_sysrender.h"
+
+#include <psp2/kernel/processmgr.h>
+#include <psp2/appmgr.h>
+#include <psp2/display.h>
+#include <psp2/gxm.h>
+#include <psp2/types.h>
+#include <psp2/kernel/sysmem.h>
+
+#include <string.h>
+
+#define VITA_GXM_SCREEN_WIDTH 960
+#define VITA_GXM_SCREEN_HEIGHT 544
+#define VITA_GXM_SCREEN_STRIDE 960
+
+#define VITA_GXM_COLOR_FORMAT SCE_GXM_COLOR_FORMAT_A8B8G8R8
+#define VITA_GXM_PIXEL_FORMAT SCE_DISPLAY_PIXELFORMAT_A8B8G8R8
+
+#define VITA_GXM_BUFFERS 3
+#define VITA_GXM_PENDING_SWAPS 2
+#define VITA_GXM_POOL_SIZE 2 * 1024 * 1024
+
+typedef struct
+{
+ void *address;
+ Uint8 wait_vblank;
+} VITA_GXM_DisplayData;
+
+typedef struct clear_vertex {
+ float x;
+ float y;
+} clear_vertex;
+
+typedef struct color_vertex {
+ float x;
+ float y;
+ float z;
+ unsigned int color;
+} color_vertex;
+
+typedef struct texture_vertex {
+ float x;
+ float y;
+ float z;
+ float u;
+ float v;
+} texture_vertex;
+
+typedef struct gxm_texture {
+ SceGxmTexture gxm_tex;
+ SceUID data_UID;
+ SceUID palette_UID;
+ SceGxmRenderTarget *gxm_rendertarget;
+ SceGxmColorSurface gxm_colorsurface;
+ SceGxmDepthStencilSurface gxm_depthstencil;
+ SceUID depth_UID;
+} gxm_texture;
+
+typedef struct fragment_programs {
+ SceGxmFragmentProgram *color;
+ SceGxmFragmentProgram *texture;
+ SceGxmFragmentProgram *textureTint;
+} fragment_programs;
+
+typedef struct blend_fragment_programs {
+ fragment_programs blend_mode_none;
+ fragment_programs blend_mode_blend;
+ fragment_programs blend_mode_add;
+ fragment_programs blend_mode_mod;
+ fragment_programs blend_mode_mul;
+} blend_fragment_programs;
+
+typedef struct
+{
+ SDL_Rect viewport;
+ SDL_bool viewport_dirty;
+ SDL_Texture *texture;
+ SDL_Texture *target;
+ Uint32 color;
+} gxm_drawstate_cache;
+
+typedef struct
+{
+ SDL_bool initialized;
+ SDL_bool drawing;
+
+ unsigned int psm;
+ unsigned int bpp;
+
+ int currentBlendMode;
+
+ VITA_GXM_DisplayData displayData;
+
+ SceUID vdmRingBufferUid;
+ SceUID vertexRingBufferUid;
+ SceUID fragmentRingBufferUid;
+ SceUID fragmentUsseRingBufferUid;
+ SceGxmContextParams contextParams;
+ SceGxmContext *gxm_context;
+ SceGxmRenderTarget *renderTarget;
+ SceUID displayBufferUid[VITA_GXM_BUFFERS];
+ void *displayBufferData[VITA_GXM_BUFFERS];
+ SceGxmColorSurface displaySurface[VITA_GXM_BUFFERS];
+ SceGxmSyncObject *displayBufferSync[VITA_GXM_BUFFERS];
+
+ SceUID depthBufferUid;
+ SceUID stencilBufferUid;
+ SceGxmDepthStencilSurface depthSurface;
+ void *depthBufferData;
+ void *stencilBufferData;
+
+ unsigned int backBufferIndex;
+ unsigned int frontBufferIndex;
+
+ void* pool_addr;
+ SceUID poolUid;
+ unsigned int pool_index;
+
+ float ortho_matrix[4*4];
+
+ SceGxmVertexProgram *colorVertexProgram;
+ SceGxmFragmentProgram *colorFragmentProgram;
+ SceGxmVertexProgram *textureVertexProgram;
+ SceGxmFragmentProgram *textureFragmentProgram;
+ SceGxmFragmentProgram *textureTintFragmentProgram;
+ SceGxmProgramParameter *clearClearColorParam;
+ SceGxmProgramParameter *colorWvpParam;
+ SceGxmProgramParameter *textureWvpParam;
+ SceGxmProgramParameter *textureTintColorParam;
+
+ SceGxmShaderPatcher *shaderPatcher;
+ SceGxmVertexProgram *clearVertexProgram;
+ SceGxmFragmentProgram *clearFragmentProgram;
+
+ SceGxmShaderPatcherId clearVertexProgramId;
+ SceGxmShaderPatcherId clearFragmentProgramId;
+ SceGxmShaderPatcherId colorVertexProgramId;
+ SceGxmShaderPatcherId colorFragmentProgramId;
+ SceGxmShaderPatcherId textureVertexProgramId;
+ SceGxmShaderPatcherId textureFragmentProgramId;
+ SceGxmShaderPatcherId textureTintFragmentProgramId;
+
+ SceUID patcherBufferUid;
+ SceUID patcherVertexUsseUid;
+ SceUID patcherFragmentUsseUid;
+
+ SceUID clearVerticesUid;
+ SceUID linearIndicesUid;
+ clear_vertex *clearVertices;
+ uint16_t *linearIndices;
+
+ blend_fragment_programs blendFragmentPrograms;
+
+ gxm_drawstate_cache drawstate;
+} VITA_GXM_RenderData;
+
+typedef struct
+{
+ gxm_texture *tex;
+ unsigned int pitch;
+ unsigned int w;
+ unsigned int h;
+} VITA_GXM_TextureData;
+
+#endif /* SDL_RENDER_VITA_GXM_TYPES_H */
+
+/* vi: set ts=4 sw=4 expandtab: */
diff --git a/src/render/vitagxm/shader_src/clear_f.cg b/src/render/vitagxm/shader_src/clear_f.cg
new file mode 100644
index 0000000..6d8fb3b
--- /dev/null
+++ b/src/render/vitagxm/shader_src/clear_f.cg
@@ -0,0 +1,4 @@
+float4 main( uniform float4 uClearColor) : COLOR
+{
+ return uClearColor;
+}
diff --git a/src/render/vitagxm/shader_src/clear_v.cg b/src/render/vitagxm/shader_src/clear_v.cg
new file mode 100644
index 0000000..ee5aa9f
--- /dev/null
+++ b/src/render/vitagxm/shader_src/clear_v.cg
@@ -0,0 +1,4 @@
+float4 main(float2 aPosition) : POSITION
+{
+ return float4(aPosition, 1.f, 1.f);
+}
diff --git a/src/render/vitagxm/shader_src/color_f.cg b/src/render/vitagxm/shader_src/color_f.cg
new file mode 100644
index 0000000..dc87c2a
--- /dev/null
+++ b/src/render/vitagxm/shader_src/color_f.cg
@@ -0,0 +1,4 @@
+float4 main(float4 vColor : COLOR)
+{
+ return vColor;
+}
diff --git a/src/render/vitagxm/shader_src/color_v.cg b/src/render/vitagxm/shader_src/color_v.cg
new file mode 100644
index 0000000..f608797
--- /dev/null
+++ b/src/render/vitagxm/shader_src/color_v.cg
@@ -0,0 +1,11 @@
+void main(
+ float3 aPosition,
+ float4 aColor,
+ uniform float4x4 wvp,
+ float4 out vPosition : POSITION,
+ float4 out vColor : COLOR
+)
+{
+ vPosition = mul(float4(aPosition, 1.f), wvp);
+ vColor = aColor;
+}
diff --git a/src/render/vitagxm/shader_src/texture_f.cg b/src/render/vitagxm/shader_src/texture_f.cg
new file mode 100644
index 0000000..232ee85
--- /dev/null
+++ b/src/render/vitagxm/shader_src/texture_f.cg
@@ -0,0 +1,4 @@
+float4 main(float2 vTexcoord : TEXCOORD0, uniform sampler2D tex)
+{
+ return tex2D(tex, vTexcoord);
+}
diff --git a/src/render/vitagxm/shader_src/texture_tint_f.cg b/src/render/vitagxm/shader_src/texture_tint_f.cg
new file mode 100644
index 0000000..8b12a80
--- /dev/null
+++ b/src/render/vitagxm/shader_src/texture_tint_f.cg
@@ -0,0 +1,4 @@
+float4 main( float2 vTexcoord : TEXCOORD0, uniform sampler2D tex, uniform float4 uTintColor)
+{
+ return tex2D(tex, vTexcoord) * uTintColor;
+}
diff --git a/src/render/vitagxm/shader_src/texture_v.cg b/src/render/vitagxm/shader_src/texture_v.cg
new file mode 100644
index 0000000..42e7df9
--- /dev/null
+++ b/src/render/vitagxm/shader_src/texture_v.cg
@@ -0,0 +1,11 @@
+void main(
+ float3 aPosition,
+ float2 aTexcoord,
+ uniform float4x4 wvp,
+ float4 out vPosition : POSITION,
+ float2 out vTexcoord : TEXCOORD0
+)
+{
+ vPosition = mul(float4(aPosition, 1.f), wvp);
+ vTexcoord = aTexcoord;
+}