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
|
/*========================== begin_copyright_notice ============================
Copyright (C) 2017-2021 Intel Corporation
SPDX-License-Identifier: MIT
============================= end_copyright_notice ===========================*/
// Built-in image functions
// These values need to match the runtime equivalent
#define CLK_ADDRESS_NONE 0x00
#define CLK_ADDRESS_CLAMP 0x01
#define CLK_ADDRESS_CLAMP_TO_EDGE 0x02
#define CLK_ADDRESS_REPEAT 0x03
#define CLK_ADDRESS_MIRRORED_REPEAT 0x04
#define CLK_NORMALIZED_COORDS_FALSE 0x00
#define CLK_NORMALIZED_COORDS_TRUE 0x08
#define CLK_FILTER_NEAREST 0x00
#define CLK_FILTER_LINEAR 0x10
#include "../Headers/spirv.h"
__spirv_Sampler __translate_sampler_initializer(uint sampler)
{
return __builtin_astype((ulong)sampler, __spirv_Sampler);
}
#ifdef __IGC_BUILD__
__attribute__((inline)) float4 __flush_denormals(float4 in)
{
//temporary fix, since SKL+ support denormal values we need to flush those values to zero after LOAD instructions.
//AND r6, r8, 0x807fffff;
//UCMP.eq p0, r6, r8;
//(p0) AND r8, r8, 0x80000000;
int4 floatDenorm = (int4)0x807fffff;
int4 signBit = (int4)0x80000000;
float4 temp = as_float4(as_int4(in) & floatDenorm);
return (as_int4(temp) == as_int4(in)) ? as_float4(as_int4(in) & signBit) : in;
}
#endif
// Image Instructions
// ImageSampleExplicitLod samples an image using an explicit level of detail.
float4 SPIRV_OVERLOADABLE SPIRV_BUILTIN(ImageSampleExplicitLod, _v4f32_img2d_ro_v2f32_i32_f32, _Rfloat4)(__spirv_SampledImage_2D SampledImage, float2 Coordinate, int ImageOperands, float Lod)
{
int image_id = (int)__builtin_IB_get_image(SampledImage);
int sampler_id = (int)__builtin_IB_get_sampler(SampledImage);
float2 snappedCoords = Coordinate;
if (__builtin_IB_get_snap_wa_reqd(sampler_id) != 0)
{
snappedCoords.x = (Coordinate.x < 0) ? -1.0f : Coordinate.x;
snappedCoords.y = (Coordinate.y < 0) ? -1.0f : Coordinate.y;
}
return __builtin_IB_OCL_2d_sample_l(image_id, sampler_id, snappedCoords, Lod);
}
float4 SPIRV_OVERLOADABLE SPIRV_BUILTIN(ImageSampleExplicitLod, _v4f32_img2d_ro_v2i32_i32_f32, _Rfloat4)(__spirv_SampledImage_2D SampledImage, int2 Coordinate, int ImageOperands, float Lod)
{
float2 floatCoords = convert_float2(Coordinate);
return SPIRV_BUILTIN(ImageSampleExplicitLod, _v4f32_img2d_ro_v2f32_i32_f32, _Rfloat4)(SampledImage, floatCoords, ImageOperands, Lod);
}
uint4 OVERLOADABLE __spirv_ImageSampleExplicitLod_Ruint4(__spirv_SampledImage_2D SampledImage, float2 Coordinate, int ImageOperands, float Lod)
{
int image_id = (int)__builtin_IB_get_image(SampledImage);
int sampler_id = (int)__builtin_IB_get_sampler(SampledImage);
if (Lod == 0.0f)
{
// Even though this is a SPIRV builtin, the runtime still patches OCL C enum values for the addressing mode.
if ((__builtin_IB_get_address_mode(sampler_id) & 0x07) == CLK_ADDRESS_CLAMP)
{
float2 coords = Coordinate;
if (CLK_NORMALIZED_COORDS_TRUE == __builtin_IB_is_normalized_coords(sampler_id))
{
float2 dim = SPIRV_BUILTIN(ConvertUToF, _v2f32_v2i32, _Rfloat2)(
(uint2)(__builtin_IB_get_image_width(image_id), __builtin_IB_get_image_height(image_id)));
coords = coords * dim;
}
int2 intCoords = SPIRV_BUILTIN(ConvertFToS, _v2i32_v2f32, _Rint2)(SPIRV_OCL_BUILTIN(floor, _v2f32, )(coords));
return __builtin_IB_OCL_2d_ldui(image_id, intCoords, 0);
}
else
{
return as_uint4(__builtin_IB_OCL_2d_sample_l(image_id, sampler_id, Coordinate, 0.0f));
}
}
else
{
if (0 != __builtin_IB_get_snap_wa_reqd(sampler_id))
{
Coordinate.x = (Coordinate.x < 0) ? -1.0f : Coordinate.x;
Coordinate.y = (Coordinate.y < 0) ? -1.0f : Coordinate.y;
}
return as_uint4(__builtin_IB_OCL_2d_sample_l(image_id, sampler_id, Coordinate, Lod));
}
}
int4 SPIRV_OVERLOADABLE SPIRV_BUILTIN(ImageSampleExplicitLod, _v4i32_img2d_ro_v2f32_i32_f32, _Rint4)(__spirv_SampledImage_2D SampledImage, float2 Coordinate, int ImageOperands, float Lod)
{
uint4 res = __spirv_ImageSampleExplicitLod_Ruint4(SampledImage, Coordinate, ImageOperands, Lod);
return as_int4(res);
}
uint4 OVERLOADABLE __spirv_ImageSampleExplicitLod_Ruint4(__spirv_SampledImage_2D SampledImage, int2 Coordinate, int ImageOperands, float Lod)
{
int image_id = (int)__builtin_IB_get_image(SampledImage);
int sampler_id = (int)__builtin_IB_get_sampler(SampledImage);
// "Snap workaround" - path
if ((__builtin_IB_get_address_mode(sampler_id) & 0x07) == CLK_ADDRESS_CLAMP_TO_EDGE)
{
float2 floatCoords = convert_float2((Coordinate));
return as_uint4(__builtin_IB_OCL_2d_sample_l(image_id, sampler_id, floatCoords, Lod));
}
else
{
float float_lod = SPIRV_BUILTIN(ConvertFToS, _i32_f32, _Rint)(Lod);
return __builtin_IB_OCL_2d_ldui(image_id, Coordinate, float_lod);
}
}
int4 SPIRV_OVERLOADABLE SPIRV_BUILTIN(ImageSampleExplicitLod, _v4i32_img2d_ro_v2i32_i32_f32, _Rint4)(__spirv_SampledImage_2D SampledImage, int2 Coordinate, int ImageOperands, float Lod)
{
uint4 res = __spirv_ImageSampleExplicitLod_Ruint4(SampledImage, Coordinate, ImageOperands, Lod);
return as_int4(res);
}
#ifdef cl_khr_fp16
half4 SPIRV_OVERLOADABLE SPIRV_BUILTIN(ImageSampleExplicitLod, _v4f16_img2d_ro_v2f32_i32_f32, _Rhalf4)(__spirv_SampledImage_2D SampledImage, float2 Coordinate, int ImageOperands, float Lod)
{
float4 res = SPIRV_BUILTIN(ImageSampleExplicitLod, _v4f32_img2d_ro_v2f32_i32_f32, _Rfloat4)(SampledImage, Coordinate, ImageOperands, Lod);
return SPIRV_BUILTIN(FConvert, _v4f16_v4f32, _Rhalf4)(res);
}
half4 SPIRV_OVERLOADABLE SPIRV_BUILTIN(ImageSampleExplicitLod, _v4f16_img2d_ro_v2i32_i32_f32, _Rhalf4)(__spirv_SampledImage_2D SampledImage, int2 Coordinate, int ImageOperands, float Lod)
{
float4 res = SPIRV_BUILTIN(ImageSampleExplicitLod, _v4f32_img2d_ro_v2i32_i32_f32, _Rfloat4)(SampledImage, Coordinate, ImageOperands, Lod);
return SPIRV_BUILTIN(FConvert, _v4f16_v4f32, _Rhalf4)(res);
}
#endif // cl_khr_fp16
float4 OVERLOADABLE __spirv_ImageSampleExplicitLod_Rfloat4(__spirv_SampledImage_3D SampledImage, float3 Coordinate, int ImageOperands, float Lod)
{
int image_id = (int)__builtin_IB_get_image(SampledImage);
int sampler_id = (int)__builtin_IB_get_sampler(SampledImage);
float3 snappedCoords = Coordinate;
if (__builtin_IB_get_snap_wa_reqd(sampler_id) != 0)
{
snappedCoords.x = (Coordinate.x < 0) ? -1.0f : Coordinate.x;
snappedCoords.y = (Coordinate.y < 0) ? -1.0f : Coordinate.y;
snappedCoords.z = (Coordinate.z < 0) ? -1.0f : Coordinate.z;
}
return __builtin_IB_OCL_3d_sample_l(image_id, sampler_id, snappedCoords, Lod);
}
float4 SPIRV_OVERLOADABLE SPIRV_BUILTIN(ImageSampleExplicitLod, _v4f32_img3d_ro_v4f32_i32_f32, _Rfloat4)(__spirv_SampledImage_3D SampledImage, float4 Coordinate, int ImageOperands, float Lod)
{
return __spirv_ImageSampleExplicitLod_Rfloat4(SampledImage, Coordinate.xyz, ImageOperands, Lod);
}
float4 OVERLOADABLE __spirv_ImageSampleExplicitLod_Rfloat4(__spirv_SampledImage_3D SampledImage, int3 Coordinate, int ImageOperands, float Lod)
{
float3 floatCoords = convert_float3(Coordinate);
return __spirv_ImageSampleExplicitLod_Rfloat4(SampledImage, floatCoords, ImageOperands, Lod);
}
float4 SPIRV_OVERLOADABLE SPIRV_BUILTIN(ImageSampleExplicitLod, _v4f32_img3d_ro_v4i32_i32_f32, _Rfloat4)(__spirv_SampledImage_3D SampledImage, int4 Coordinate, int ImageOperands, float Lod)
{
return __spirv_ImageSampleExplicitLod_Rfloat4(SampledImage, Coordinate.xyz, ImageOperands, Lod);
}
uint4 OVERLOADABLE __spirv_ImageSampleExplicitLod_Ruint4(__spirv_SampledImage_3D SampledImage, float3 Coordinate, int ImageOperands, float Lod)
{
int image_id = (int)__builtin_IB_get_image(SampledImage);
int sampler_id = (int)__builtin_IB_get_sampler(SampledImage);
if (Lod == 0.0f)
{
if ((__builtin_IB_get_address_mode(sampler_id) & 0x07) == CLK_ADDRESS_CLAMP)
{
if (CLK_NORMALIZED_COORDS_TRUE == __builtin_IB_is_normalized_coords(sampler_id))
{
float3 dim = (float3)((float)__builtin_IB_get_image_width(image_id), (float)__builtin_IB_get_image_height(image_id), (float)__builtin_IB_get_image_depth(image_id));
Coordinate = Coordinate * dim;
}
int3 intCoords = SPIRV_BUILTIN(ConvertFToS, _v3i32_v3f32, _Rint3)(SPIRV_OCL_BUILTIN(floor, _v3f32, )(Coordinate));
return __builtin_IB_OCL_3d_ldui(image_id, intCoords, 0);
}
else
{
return as_uint4(__builtin_IB_OCL_3d_sample_l(image_id, sampler_id, Coordinate, 0.0f));
}
}
else
{
if (0 != __builtin_IB_get_snap_wa_reqd(sampler_id))
{
Coordinate.x = (Coordinate.x < 0) ? -1.0f : Coordinate.x;
Coordinate.y = (Coordinate.y < 0) ? -1.0f : Coordinate.y;
Coordinate.z = (Coordinate.z < 0) ? -1.0f : Coordinate.z;
}
return as_uint4(__builtin_IB_OCL_3d_sample_l(image_id, sampler_id, Coordinate, Lod));
}
}
uint4 OVERLOADABLE __spirv_ImageSampleExplicitLod_Ruint4(__spirv_SampledImage_3D SampledImage, float4 Coordinate, int ImageOperands, float Lod)
{
return __spirv_ImageSampleExplicitLod_Ruint4(SampledImage, Coordinate.xyz, ImageOperands, Lod);
}
int4 OVERLOADABLE __spirv_ImageSampleExplicitLod_Rint4(__spirv_SampledImage_3D SampledImage, float3 Coordinate, int ImageOperands, float Lod)
{
uint4 res = __spirv_ImageSampleExplicitLod_Ruint4(SampledImage, Coordinate, ImageOperands, Lod);
return as_int4(res);
}
int4 SPIRV_OVERLOADABLE SPIRV_BUILTIN(ImageSampleExplicitLod, _v4i32_img3d_ro_v4f32_i32_f32, _Rint4)(__spirv_SampledImage_3D SampledImage, float4 Coordinate, int ImageOperands, float Lod)
{
uint4 res = __spirv_ImageSampleExplicitLod_Ruint4(SampledImage, Coordinate.xyz, ImageOperands, Lod);
return as_int4(res);
}
uint4 OVERLOADABLE __spirv_ImageSampleExplicitLod_Ruint4(__spirv_SampledImage_3D SampledImage, int3 Coordinate, int ImageOperands, float Lod)
{
int image_id = (int)__builtin_IB_get_image(SampledImage);
int sampler_id = (int)__builtin_IB_get_sampler(SampledImage);
if ((__builtin_IB_get_address_mode(sampler_id) & 0x07) == CLK_ADDRESS_CLAMP_TO_EDGE)
{
float3 floatCoords = convert_float3(Coordinate);
return as_uint4(__builtin_IB_OCL_3d_sample_l(image_id, sampler_id, floatCoords, Lod));
}
else
{
int int_lod = SPIRV_BUILTIN(ConvertFToS, _i32_f32, _Rint)(Lod);
return __builtin_IB_OCL_3d_ldui(image_id, Coordinate, int_lod);
}
}
uint4 OVERLOADABLE __spirv_ImageSampleExplicitLod_Ruint4(__spirv_SampledImage_3D SampledImage, int4 Coordinate, int ImageOperands, float Lod)
{
return __spirv_ImageSampleExplicitLod_Ruint4(SampledImage, Coordinate.xyz, ImageOperands, Lod);
}
int4 OVERLOADABLE __spirv_ImageSampleExplicitLod_Rint4(__spirv_SampledImage_3D SampledImage, int3 Coordinate, int ImageOperands, float Lod)
{
uint4 res = __spirv_ImageSampleExplicitLod_Ruint4(SampledImage, Coordinate, ImageOperands, Lod);
return as_int4(res);
}
int4 SPIRV_OVERLOADABLE SPIRV_BUILTIN(ImageSampleExplicitLod, _v4i32_img3d_ro_v4i32_i32_f32, _Rint4)(__spirv_SampledImage_3D SampledImage, int4 Coordinate, int ImageOperands, float Lod)
{
return __spirv_ImageSampleExplicitLod_Rint4(SampledImage, Coordinate.xyz, ImageOperands, Lod);
}
#ifdef cl_khr_fp16
half4 OVERLOADABLE __spirv_ImageSampleExplicitLod_Rhalf4(__spirv_SampledImage_3D SampledImage, float3 Coordinate, int ImageOperands, float Lod)
{
float4 res = __spirv_ImageSampleExplicitLod_Rfloat4(SampledImage, Coordinate, ImageOperands, Lod);
return SPIRV_BUILTIN(FConvert, _v4f16_v4f32, _Rhalf4)(res);
}
half4 SPIRV_OVERLOADABLE SPIRV_BUILTIN(ImageSampleExplicitLod, _v4f16_img3d_ro_v4f32_i32_f32, _Rhalf4)(__spirv_SampledImage_3D SampledImage, float4 Coordinate, int ImageOperands, float Lod)
{
return __spirv_ImageSampleExplicitLod_Rhalf4(SampledImage, Coordinate.xyz, ImageOperands, Lod);
}
half4 OVERLOADABLE __spirv_ImageSampleExplicitLod_Rhalf4(__spirv_SampledImage_3D SampledImage, int3 Coordinate, int ImageOperands, float Lod)
{
float4 res = __spirv_ImageSampleExplicitLod_Rfloat4(SampledImage, Coordinate, ImageOperands, Lod);
return SPIRV_BUILTIN(FConvert, _v4f16_v4f32, _Rhalf4)(res);
}
half4 SPIRV_OVERLOADABLE SPIRV_BUILTIN(ImageSampleExplicitLod, _v4f16_img3d_ro_v4i32_i32_f32, _Rhalf4)(__spirv_SampledImage_3D SampledImage, int4 Coordinate, int ImageOperands, float Lod)
{
return __spirv_ImageSampleExplicitLod_Rhalf4(SampledImage, Coordinate.xyz, ImageOperands, Lod);
}
#endif // cl_khr_fp16
float4 OVERLOADABLE __spirv_ImageSampleExplicitLod_Rfloat4(__spirv_SampledImage_2D_array SampledImage, float3 Coordinate, int ImageOperands, float Lod)
{
int image_id = (int)__builtin_IB_get_image(SampledImage);
int sampler_id = (int)__builtin_IB_get_sampler(SampledImage);
if (__builtin_IB_get_snap_wa_reqd(sampler_id) != 0)
{
Coordinate.x = (Coordinate.x < 0) ? -1.0f : Coordinate.x;
Coordinate.y = (Coordinate.y < 0) ? -1.0f : Coordinate.y;
}
return __builtin_IB_OCL_2darr_sample_l(image_id, sampler_id, Coordinate, Lod);
}
float4 SPIRV_OVERLOADABLE SPIRV_BUILTIN(ImageSampleExplicitLod, _v4f32_img2d_array_ro_v4f32_i32_f32, _Rfloat4)(__spirv_SampledImage_2D_array SampledImage, float4 Coordinate, int ImageOperands, float Lod)
{
return __spirv_ImageSampleExplicitLod_Rfloat4(SampledImage, Coordinate.xyz, ImageOperands, Lod);
}
float4 OVERLOADABLE __spirv_ImageSampleExplicitLod_Rfloat4(__spirv_SampledImage_2D_array SampledImage, int3 Coordinate, int ImageOperands, float Lod)
{
float3 floatCoords = convert_float3(Coordinate);
return __spirv_ImageSampleExplicitLod_Rfloat4(SampledImage, floatCoords, ImageOperands, Lod);
}
float4 SPIRV_OVERLOADABLE SPIRV_BUILTIN(ImageSampleExplicitLod, _v4f32_img2d_array_ro_v4i32_i32_f32, _Rfloat4)(__spirv_SampledImage_2D_array SampledImage, int4 Coordinate, int ImageOperands, float Lod)
{
return __spirv_ImageSampleExplicitLod_Rfloat4(SampledImage, Coordinate.xyz, ImageOperands, Lod);
}
uint4 OVERLOADABLE __spirv_ImageSampleExplicitLod_Ruint4(__spirv_SampledImage_2D_array SampledImage, float3 Coordinate, int ImageOperands, float Lod)
{
int image_id = (int)__builtin_IB_get_image(SampledImage);
int sampler_id = (int)__builtin_IB_get_sampler(SampledImage);
if (Lod == 0.0f)
{
int dt = __builtin_IB_get_image2d_array_size(image_id);
float layer = SPIRV_OCL_BUILTIN(fclamp, _f32_f32_f32, )(SPIRV_OCL_BUILTIN(rint, _f32, )(Coordinate.z), 0.0f, (float)(dt - 1));
if ((__builtin_IB_get_address_mode(sampler_id) & 0x07) == CLK_ADDRESS_CLAMP)
{
float2 tmpCoords = Coordinate.xy;
if (CLK_NORMALIZED_COORDS_TRUE == __builtin_IB_is_normalized_coords(sampler_id))
{
float2 dim = SPIRV_BUILTIN(ConvertUToF, _v2f32_v2i32, _Rfloat2)((uint2)(__builtin_IB_get_image_width(image_id), __builtin_IB_get_image_height(image_id)));
tmpCoords = Coordinate.xy * dim;
}
int3 intCoords = SPIRV_BUILTIN(ConvertFToS, _v3i32_v3f32, _Rint3)((float3)(SPIRV_OCL_BUILTIN(floor, _v2f32, )(tmpCoords), layer));
return __builtin_IB_OCL_2darr_ldui(image_id, intCoords, 0);
}
else
{
if (0 != __builtin_IB_get_snap_wa_reqd(sampler_id))
{
Coordinate.x = (Coordinate.x < 0) ? -1.0f : Coordinate.x;
Coordinate.y = (Coordinate.y < 0) ? -1.0f : Coordinate.y;
}
return as_uint4(__builtin_IB_OCL_2darr_sample_l(image_id, sampler_id, Coordinate, 0.0f));
}
}
else
{
if (0 != __builtin_IB_get_snap_wa_reqd(sampler_id))
{
Coordinate.x = (Coordinate.x < 0) ? -1.0f : Coordinate.x;
Coordinate.y = (Coordinate.y < 0) ? -1.0f : Coordinate.y;
}
return as_uint4(__builtin_IB_OCL_2darr_sample_l(image_id, sampler_id, Coordinate, Lod));
}
}
uint4 OVERLOADABLE __spirv_ImageSampleExplicitLod_Ruint4(__spirv_SampledImage_2D_array SampledImage, float4 Coordinate, int ImageOperands, float Lod)
{
return __spirv_ImageSampleExplicitLod_Ruint4(SampledImage, Coordinate.xyz, ImageOperands, Lod);
}
int4 OVERLOADABLE __spirv_ImageSampleExplicitLod_Rint4(__spirv_SampledImage_2D_array SampledImage, float3 Coordinate, int ImageOperands, float Lod)
{
uint4 res = __spirv_ImageSampleExplicitLod_Ruint4(SampledImage, Coordinate, ImageOperands, Lod);
return as_int4(res);
}
int4 SPIRV_OVERLOADABLE SPIRV_BUILTIN(ImageSampleExplicitLod, _v4i32_img2d_array_ro_v4f32_i32_f32, _Rint4)(__spirv_SampledImage_2D_array SampledImage, float4 Coordinate, int ImageOperands, float Lod)
{
return __spirv_ImageSampleExplicitLod_Rint4(SampledImage, Coordinate.xyz, ImageOperands, Lod);
}
uint4 OVERLOADABLE __spirv_ImageSampleExplicitLod_Ruint4(__spirv_SampledImage_2D_array SampledImage, int3 Coordinate, int ImageOperands, float Lod)
{
int image_id = (int)__builtin_IB_get_image(SampledImage);
int sampler_id = (int)__builtin_IB_get_sampler(SampledImage);
// "Snap workaround" - path
if ((__builtin_IB_get_address_mode(sampler_id) & 0x07) == CLK_ADDRESS_CLAMP_TO_EDGE)
{
int dt = __builtin_IB_get_image2d_array_size(image_id);
float layer = SPIRV_OCL_BUILTIN(fclamp, _f32_f32_f32, )(SPIRV_OCL_BUILTIN(rint, _f32, )((float)Coordinate.z), 0.0f, (float)(dt - 1));
float2 floatCoords = SPIRV_BUILTIN(ConvertSToF, _v2f32_v2i32, _Rfloat2)(Coordinate.xy);
return as_uint4(__builtin_IB_OCL_2darr_sample_l(image_id, sampler_id, (float3)(floatCoords, layer), Lod));
}
else
{
float float_lod = SPIRV_BUILTIN(ConvertFToS, _i32_f32, _Rint)(Lod);
int dt = __builtin_IB_get_image2d_array_size(image_id);
float layer = SPIRV_OCL_BUILTIN(fclamp, _f32_f32_f32, )(SPIRV_OCL_BUILTIN(rint, _f32, )((float)Coordinate.z), 0.0f, (float)(dt - 1));
return __builtin_IB_OCL_2darr_ldui(image_id, (int3)(Coordinate.xy, (int)layer), float_lod);
}
}
uint4 OVERLOADABLE __spirv_ImageSampleExplicitLod_Ruint4(__spirv_SampledImage_2D_array SampledImage, int4 Coordinate, int ImageOperands, float Lod)
{
return __spirv_ImageSampleExplicitLod_Ruint4(SampledImage, Coordinate.xyz, ImageOperands, Lod);
}
int4 OVERLOADABLE __spirv_ImageSampleExplicitLod_Rint4(__spirv_SampledImage_2D_array SampledImage, int3 Coordinate, int ImageOperands, float Lod)
{
uint4 res = __spirv_ImageSampleExplicitLod_Ruint4(SampledImage, Coordinate, ImageOperands, Lod);
return as_int4(res);
}
int4 SPIRV_OVERLOADABLE SPIRV_BUILTIN(ImageSampleExplicitLod, _v4i32_img2d_array_ro_v4i32_i32_f32, _Rint4)(__spirv_SampledImage_2D_array SampledImage, int4 Coordinate, int ImageOperands, float Lod)
{
return __spirv_ImageSampleExplicitLod_Rint4(SampledImage, Coordinate.xyz, ImageOperands, Lod);
}
#ifdef cl_khr_fp16
half4 OVERLOADABLE __spirv_ImageSampleExplicitLod_Rhalf4(__spirv_SampledImage_2D_array SampledImage, float3 Coordinate, int ImageOperands, float Lod)
{
float4 res = __spirv_ImageSampleExplicitLod_Rfloat4(SampledImage, Coordinate, ImageOperands, Lod);
return SPIRV_BUILTIN(FConvert, _v4f16_v4f32, _Rhalf4)(res);
}
half4 SPIRV_OVERLOADABLE SPIRV_BUILTIN(ImageSampleExplicitLod, _v4f16_img2d_array_ro_v4f32_i32_f32, _Rhalf4)(__spirv_SampledImage_2D_array SampledImage, float4 Coordinate, int ImageOperands, float Lod)
{
return __spirv_ImageSampleExplicitLod_Rhalf4(SampledImage, Coordinate.xyz, ImageOperands, Lod);
}
half4 OVERLOADABLE __spirv_ImageSampleExplicitLod_Rhalf4(__spirv_SampledImage_2D_array SampledImage, int3 Coordinate, int ImageOperands, float Lod)
{
float4 res = __spirv_ImageSampleExplicitLod_Rfloat4(SampledImage, Coordinate, ImageOperands, Lod);
return SPIRV_BUILTIN(FConvert, _v4f16_v4f32, _Rhalf4)(res);
}
half4 SPIRV_OVERLOADABLE SPIRV_BUILTIN(ImageSampleExplicitLod, _v4f16_img2d_array_ro_v4i32_i32_f32, _Rhalf4)(__spirv_SampledImage_2D_array SampledImage, int4 Coordinate, int ImageOperands, float Lod)
{
return __spirv_ImageSampleExplicitLod_Rhalf4(SampledImage, Coordinate.xyz, ImageOperands, Lod);
}
#endif // cl_khr_fp16
float4 SPIRV_OVERLOADABLE SPIRV_BUILTIN(ImageSampleExplicitLod, _v4f32_img1d_ro_f32_i32_f32, _Rfloat4)(__spirv_SampledImage_1D SampledImage, float Coordinate, int ImageOperands, float Lod)
{
int image_id = (int)__builtin_IB_get_image(SampledImage);
int sampler_id = (int)__builtin_IB_get_sampler(SampledImage);
float snappedCoords = Coordinate;
if (__builtin_IB_get_snap_wa_reqd(sampler_id) != 0)
{
snappedCoords = (Coordinate < 0) ? -1.0f : Coordinate;
}
return __builtin_IB_OCL_1d_sample_l(image_id, sampler_id, snappedCoords, Lod);
}
float4 SPIRV_OVERLOADABLE SPIRV_BUILTIN(ImageSampleExplicitLod, _v4f32_img1d_ro_i32_i32_f32, _Rfloat4)(__spirv_SampledImage_1D SampledImage, int Coordinate, int ImageOperands, float Lod)
{
int image_id = (int)__builtin_IB_get_image(SampledImage);
int sampler_id = (int)__builtin_IB_get_sampler(SampledImage);
if ((__builtin_IB_get_address_mode(sampler_id) & 0x07) == CLK_ADDRESS_CLAMP_TO_EDGE)
{
float floatCoords = convert_float((Coordinate));
return __builtin_IB_OCL_1d_sample_l(image_id, sampler_id, floatCoords, Lod);
}
else
{
float4 res = __builtin_IB_OCL_1d_ld(image_id, Coordinate, 0);
return __flush_denormals(res);
}
}
uint4 OVERLOADABLE __spirv_ImageSampleExplicitLod_Ruint4(__spirv_SampledImage_1D SampledImage, float Coordinate, int ImageOperands, float Lod)
{
int image_id = (int)__builtin_IB_get_image(SampledImage);
int sampler_id = (int)__builtin_IB_get_sampler(SampledImage);
// TODO: Why do we go through 3D builtins for 1D image?
float4 Coordinate4 = (float4)(Coordinate, 0, 0, 0);
if (Lod == 0.0f)
{
if ((__builtin_IB_get_address_mode(sampler_id) & 0x07) == CLK_ADDRESS_CLAMP)
{
if (CLK_NORMALIZED_COORDS_TRUE == __builtin_IB_is_normalized_coords(sampler_id))
{
float4 dim = SPIRV_BUILTIN(ConvertUToF, _v4f32_v4i32, _Rfloat4)(
(uint4)(__builtin_IB_get_image_width(image_id), __builtin_IB_get_image_height(image_id), __builtin_IB_get_image_depth(image_id), 0));
Coordinate4 = Coordinate4 * dim;
}
int4 intCoords = SPIRV_BUILTIN(ConvertFToS, _v4i32_v4f32, _Rint4)(SPIRV_OCL_BUILTIN(floor, _v4f32, )(Coordinate4));
return __builtin_IB_OCL_3d_ldui(image_id, intCoords.xyz, 0);
}
else
{
return as_uint4(__builtin_IB_OCL_3d_sample_l(image_id, sampler_id, Coordinate4.xyz, 0.0f));
}
}
else
{
if (0 != __builtin_IB_get_snap_wa_reqd(sampler_id))
{
Coordinate4.x = (Coordinate4.x < 0) ? -1.0f : Coordinate4.x;
Coordinate4.y = (Coordinate4.y < 0) ? -1.0f : Coordinate4.y;
Coordinate4.z = (Coordinate4.z < 0) ? -1.0f : Coordinate4.z;
}
return as_uint4(__builtin_IB_OCL_3d_sample_l(image_id, sampler_id, Coordinate4.xyz, Lod));
}
}
int4 SPIRV_OVERLOADABLE SPIRV_BUILTIN(ImageSampleExplicitLod, _v4i32_img1d_ro_f32_i32_f32, _Rint4)(__spirv_SampledImage_1D SampledImage, float Coordinate, int ImageOperands, float Lod)
{
uint4 res = __spirv_ImageSampleExplicitLod_Ruint4(SampledImage, Coordinate, ImageOperands, Lod);
return as_int4(res);
}
uint4 OVERLOADABLE __spirv_ImageSampleExplicitLod_Ruint4(__spirv_SampledImage_1D SampledImage, int Coordinate, int ImageOperands, float Lod)
{
int image_id = (int)__builtin_IB_get_image(SampledImage);
int sampler_id = (int)__builtin_IB_get_sampler(SampledImage);
if ((__builtin_IB_get_address_mode(sampler_id) & 0x07) == CLK_ADDRESS_CLAMP_TO_EDGE)
{
float floatCoords = convert_float((Coordinate));
return as_uint4(__builtin_IB_OCL_1d_sample_l(image_id, sampler_id, floatCoords, Lod));
}
else
{
float float_lod = SPIRV_BUILTIN(ConvertFToS, _i32_f32, _Rint)(Lod);
return __builtin_IB_OCL_1d_ldui(image_id, Coordinate, float_lod);
}
}
int4 SPIRV_OVERLOADABLE SPIRV_BUILTIN(ImageSampleExplicitLod, _v4i32_img1d_ro_i32_i32_f32, _Rint4)(__spirv_SampledImage_1D SampledImage, int Coordinate, int ImageOperands, float Lod)
{
uint4 res = __spirv_ImageSampleExplicitLod_Ruint4(SampledImage, Coordinate, ImageOperands, Lod);
return as_int4(res);
}
#ifdef cl_khr_fp16
half4 SPIRV_OVERLOADABLE SPIRV_BUILTIN(ImageSampleExplicitLod, _v4f16_img1d_ro_f32_i32_f32, _Rhalf4)(__spirv_SampledImage_1D SampledImage, float Coordinate, int ImageOperands, float Lod)
{
float4 res = SPIRV_BUILTIN(ImageSampleExplicitLod, _v4f32_img1d_ro_f32_i32_f32, _Rfloat4)(SampledImage, Coordinate, ImageOperands, Lod);
return SPIRV_BUILTIN(FConvert, _v4f16_v4f32, _Rhalf4)(res);
}
half4 SPIRV_OVERLOADABLE SPIRV_BUILTIN(ImageSampleExplicitLod, _v4f16_img1d_ro_i32_i32_f32, _Rhalf4)(__spirv_SampledImage_1D SampledImage, int Coordinate, int ImageOperands, float Lod)
{
float4 res = SPIRV_BUILTIN(ImageSampleExplicitLod, _v4f32_img1d_ro_i32_i32_f32, _Rfloat4)(SampledImage, Coordinate, ImageOperands, Lod);
return SPIRV_BUILTIN(FConvert, _v4f16_v4f32, _Rhalf4)(res);
}
#endif // cl_khr_fp16
float4 SPIRV_OVERLOADABLE SPIRV_BUILTIN(ImageSampleExplicitLod, _v4f32_img1d_array_ro_v2f32_i32_f32, _Rfloat4)(__spirv_SampledImage_1D_array SampledImage, float2 Coordinate, int ImageOperands, float Lod)
{
int image_id = (int)__builtin_IB_get_image(SampledImage);
int sampler_id = (int)__builtin_IB_get_sampler(SampledImage);
float2 snappedCoords = Coordinate;
if (__builtin_IB_get_snap_wa_reqd(sampler_id) != 0)
{
snappedCoords.x = (Coordinate.x < 0) ? -1.0f : Coordinate.x;
snappedCoords.y = (Coordinate.y < 0) ? -1.0f : Coordinate.y;
}
// Array coordinate is not 'snapped'
return __builtin_IB_OCL_1darr_sample_l(image_id, sampler_id, (float2)(snappedCoords.x, Coordinate.y), Lod);
}
float4 SPIRV_OVERLOADABLE SPIRV_BUILTIN(ImageSampleExplicitLod, _v4f32_img1d_array_ro_v2i32_i32_f32, _Rfloat4)(__spirv_SampledImage_1D_array SampledImage, int2 Coordinate, int ImageOperands, float Lod)
{
float2 floatCoords = convert_float2(Coordinate);
return SPIRV_BUILTIN(ImageSampleExplicitLod, _v4f32_img1d_array_ro_v2f32_i32_f32, _Rfloat4)(SampledImage, floatCoords, ImageOperands, Lod);
}
uint4 OVERLOADABLE __spirv_ImageSampleExplicitLod_Ruint4(__spirv_SampledImage_1D_array SampledImage, float2 Coordinate, int ImageOperands, float Lod)
{
int image_id = (int)__builtin_IB_get_image(SampledImage);
int sampler_id = (int)__builtin_IB_get_sampler(SampledImage);
if (Lod == 0.0f)
{
int dt = __builtin_IB_get_image1d_array_size(image_id);
float layer = SPIRV_OCL_BUILTIN(fclamp, _f32_f32_f32, )(SPIRV_OCL_BUILTIN(rint, _f32, )(Coordinate.y), 0.0f, (float)(dt - 1));
if ((__builtin_IB_get_address_mode(sampler_id) & 0x07) == CLK_ADDRESS_CLAMP)
{
float tmpCoords = Coordinate.x;
if (CLK_NORMALIZED_COORDS_TRUE == __builtin_IB_is_normalized_coords(sampler_id))
{
float width = (float)(__builtin_IB_get_image_width(image_id));
tmpCoords = (float)(width * Coordinate.x);
}
int2 intCoords = SPIRV_BUILTIN(ConvertFToS, _v2i32_v2f32, _Rint2)((float2)(SPIRV_OCL_BUILTIN(floor, _f32, )(tmpCoords), layer));
return __builtin_IB_OCL_1darr_ldui(image_id, intCoords, 0);
}
else
{
if (0 != __builtin_IB_get_snap_wa_reqd(sampler_id))
{
Coordinate.x = (Coordinate.x < 0) ? -1.0f : Coordinate.x;
}
return as_uint4(__builtin_IB_OCL_1darr_sample_l(image_id, sampler_id, Coordinate.xy, 0.0f));
}
}
else
{
if (0 != __builtin_IB_get_snap_wa_reqd(sampler_id))
{
Coordinate.x = (Coordinate.x < 0) ? -1.0f : Coordinate.x;
}
return as_uint4(__builtin_IB_OCL_1darr_sample_l(image_id, sampler_id, Coordinate.xy, Lod));
}
}
int4 SPIRV_OVERLOADABLE SPIRV_BUILTIN(ImageSampleExplicitLod, _v4i32_img1d_array_ro_v2f32_i32_f32, _Rint4)(__spirv_SampledImage_1D_array SampledImage, float2 Coordinate, int ImageOperands, float Lod)
{
uint4 res = __spirv_ImageSampleExplicitLod_Ruint4(SampledImage, Coordinate, ImageOperands, Lod);
return as_int4(res);
}
uint4 OVERLOADABLE __spirv_ImageSampleExplicitLod_Ruint4(__spirv_SampledImage_1D_array SampledImage, int2 Coordinate, int ImageOperands, float Lod)
{
int image_id = (int)__builtin_IB_get_image(SampledImage);
int sampler_id = (int)__builtin_IB_get_sampler(SampledImage);
// "Snap workaround" - path
if ((__builtin_IB_get_address_mode(sampler_id) & 0x07) == CLK_ADDRESS_CLAMP_TO_EDGE)
{
int dt = __builtin_IB_get_image1d_array_size(image_id);
float layer = SPIRV_OCL_BUILTIN(fclamp, _f32_f32_f32, )(SPIRV_OCL_BUILTIN(rint, _f32, )((float)Coordinate.y), 0.0f, (float)(dt - 1));
float floatCoords = SPIRV_BUILTIN(ConvertSToF, _f32_i32, _Rfloat)(Coordinate.x);
return as_uint4(__builtin_IB_OCL_1darr_sample_l(image_id, sampler_id, (float2)(floatCoords, layer), Lod));
}
else
{
float float_lod = SPIRV_BUILTIN(ConvertFToS, _i32_f32, _Rint)(Lod);
int dt = __builtin_IB_get_image1d_array_size(image_id);
float layer = SPIRV_OCL_BUILTIN(fclamp, _f32_f32_f32, )(SPIRV_OCL_BUILTIN(rint, _f32, )((float)Coordinate.y), 0.0f, (float)(dt - 1));
return __builtin_IB_OCL_1darr_ldui(image_id, (int2)(Coordinate.x, (int)layer), float_lod);
}
}
int4 SPIRV_OVERLOADABLE SPIRV_BUILTIN(ImageSampleExplicitLod, _v4i32_img1d_array_ro_v2i32_i32_f32, _Rint4)(__spirv_SampledImage_1D_array SampledImage, int2 Coordinate, int ImageOperands, float Lod)
{
uint4 res = __spirv_ImageSampleExplicitLod_Ruint4(SampledImage, Coordinate, ImageOperands, Lod);
return as_int4(res);
}
#ifdef cl_khr_fp16
half4 SPIRV_OVERLOADABLE SPIRV_BUILTIN(ImageSampleExplicitLod, _v4f16_img1d_array_ro_v2f32_i32_f32, _Rhalf4)(__spirv_SampledImage_1D_array SampledImage, float2 Coordinate, int ImageOperands, float Lod)
{
float4 res = SPIRV_BUILTIN(ImageSampleExplicitLod, _v4f32_img1d_array_ro_v2f32_i32_f32, _Rfloat4)(SampledImage, Coordinate, ImageOperands, Lod);
return SPIRV_BUILTIN(FConvert, _v4f16_v4f32, _Rhalf4)(res);
}
half4 SPIRV_OVERLOADABLE SPIRV_BUILTIN(ImageSampleExplicitLod, _v4f16_img1d_array_ro_v2i32_i32_f32, _Rhalf4)(__spirv_SampledImage_1D_array SampledImage, int2 Coordinate, int ImageOperands, float Lod)
{
float4 res = SPIRV_BUILTIN(ImageSampleExplicitLod, _v4f32_img1d_array_ro_v2i32_i32_f32, _Rfloat4)(SampledImage, Coordinate, ImageOperands, Lod);
return SPIRV_BUILTIN(FConvert, _v4f16_v4f32, _Rhalf4)(res);
}
#endif // cl_khr_fp16
float4 SPIRV_OVERLOADABLE SPIRV_BUILTIN(ImageSampleExplicitLod, _v4f32_img2d_depth_ro_v2f32_i32_f32, _Rfloat4)(__spirv_SampledImage_2D_depth SampledImage, float2 Coordinate, int ImageOperands, float Lod)
{
int image_id = (int)__builtin_IB_get_image(SampledImage);
int sampler_id = (int)__builtin_IB_get_sampler(SampledImage);
float2 snappedCoords = Coordinate;
if (__builtin_IB_get_snap_wa_reqd(sampler_id) != 0)
{
snappedCoords.x = (Coordinate.x < 0) ? -1.0f : Coordinate.x;
snappedCoords.y = (Coordinate.y < 0) ? -1.0f : Coordinate.y;
}
return __builtin_IB_OCL_2d_sample_l(image_id, sampler_id, snappedCoords, Lod);
}
float4 SPIRV_OVERLOADABLE SPIRV_BUILTIN(ImageSampleExplicitLod, _v4f32_img2d_depth_ro_v2i32_i32_f32, _Rfloat4)(__spirv_SampledImage_2D_depth SampledImage, int2 Coordinate, int ImageOperands, float Lod)
{
float2 floatCoords = convert_float2(Coordinate);
return SPIRV_BUILTIN(ImageSampleExplicitLod, _v4f32_img2d_depth_ro_v2f32_i32_f32, _Rfloat4)(SampledImage, floatCoords, ImageOperands, Lod);
}
float4 SPIRV_OVERLOADABLE SPIRV_BUILTIN(ImageSampleExplicitLod, _v4f32_img2d_array_depth_ro_v4f32_i32_f32, _Rfloat4)(__spirv_SampledImage_2D_array_depth SampledImage, float4 Coordinate, int ImageOperands, float Lod)
{
int image_id = (int)__builtin_IB_get_image(SampledImage);
int sampler_id = (int)__builtin_IB_get_sampler(SampledImage);
float4 snappedCoords = Coordinate;
if (__builtin_IB_get_snap_wa_reqd(sampler_id) != 0)
{
snappedCoords.x = (Coordinate.x < 0) ? -1.0f : Coordinate.x;
snappedCoords.y = (Coordinate.y < 0) ? -1.0f : Coordinate.y;
snappedCoords.z = (Coordinate.z < 0) ? -1.0f : Coordinate.z;
}
return __builtin_IB_OCL_2darr_sample_l(image_id, sampler_id, (float3)(snappedCoords.xy, Coordinate.z), Lod);
}
float4 SPIRV_OVERLOADABLE SPIRV_BUILTIN(ImageSampleExplicitLod, _v4f32_img2d_array_depth_ro_v4i32_i32_f32, _Rfloat4)(__spirv_SampledImage_2D_array_depth SampledImage, int4 Coordinate, int ImageOperands, float Lod)
{
float4 floatCoords = convert_float4(Coordinate);
return SPIRV_BUILTIN(ImageSampleExplicitLod, _v4f32_img2d_array_depth_ro_v4f32_i32_f32, _Rfloat4)(SampledImage, floatCoords, ImageOperands, Lod);
}
// Gradient overloads
float4 SPIRV_OVERLOADABLE SPIRV_BUILTIN(ImageSampleExplicitLod, _v4f32_img2d_ro_v2f32_i32_v2f32_v2f32, _Rfloat4)(
__spirv_SampledImage_2D SampledImage,
float2 Coordinate,
int ImageOperands,
float2 dx,
float2 dy)
{
int image_id = (int)__builtin_IB_get_image(SampledImage);
int sampler_id = (int)__builtin_IB_get_sampler(SampledImage);
if (__builtin_IB_get_snap_wa_reqd(sampler_id) != 0)
{
Coordinate.x = (Coordinate.x < 0) ? -1.0f : Coordinate.x;
Coordinate.y = (Coordinate.y < 0) ? -1.0f : Coordinate.y;
}
return __builtin_IB_OCL_2d_sample_d(image_id, sampler_id, Coordinate.xy, dx, dy);
}
#ifdef cl_khr_fp16
half4 SPIRV_OVERLOADABLE SPIRV_BUILTIN(ImageSampleExplicitLod, _v4f16_img2d_ro_v2f32_i32_v2f32_v2f32, _Rhalf4)(
__spirv_SampledImage_2D SampledImage,
float2 Coordinate,
int ImageOperands,
float2 dx,
float2 dy)
{
return convert_half4(SPIRV_BUILTIN(ImageSampleExplicitLod, _v4f32_img2d_ro_v2f32_i32_v2f32_v2f32, _Rfloat4)(SampledImage, Coordinate, ImageOperands, dx, dy));
}
#endif // cl_khr_fp16
uint4 OVERLOADABLE __spirv_ImageSampleExplicitLod_Ruint4(
__spirv_SampledImage_2D SampledImage,
float2 Coordinate,
int ImageOperands,
float2 dx,
float2 dy)
{
return as_uint4(SPIRV_BUILTIN(ImageSampleExplicitLod, _v4f32_img2d_ro_v2f32_i32_v2f32_v2f32, _Rfloat4)(SampledImage, Coordinate, ImageOperands, dx, dy));
}
int4 SPIRV_OVERLOADABLE SPIRV_BUILTIN(ImageSampleExplicitLod, _v4i32_img2d_ro_v2f32_i32_v2f32_v2f32, _Rint4)(
__spirv_SampledImage_2D SampledImage,
float2 Coordinate,
int ImageOperands,
float2 dx,
float2 dy)
{
return as_int4(SPIRV_BUILTIN(ImageSampleExplicitLod, _v4f32_img2d_ro_v2f32_i32_v2f32_v2f32, _Rfloat4)(SampledImage, Coordinate, ImageOperands, dx, dy));
}
float4 OVERLOADABLE __spirv_ImageSampleExplicitLod_Rfloat4(
__spirv_SampledImage_3D SampledImage,
float3 Coordinate,
int ImageOperands,
float3 dx,
float3 dy)
{
int image_id = (int)__builtin_IB_get_image(SampledImage);
int sampler_id = (int)__builtin_IB_get_sampler(SampledImage);
if (__builtin_IB_get_snap_wa_reqd(sampler_id) != 0)
{
Coordinate.x = (Coordinate.x < 0) ? -1.0f : Coordinate.x;
Coordinate.y = (Coordinate.y < 0) ? -1.0f : Coordinate.y;
Coordinate.z = (Coordinate.z < 0) ? -1.0f : Coordinate.z;
}
return __builtin_IB_OCL_3d_sample_d(image_id, sampler_id, Coordinate, dx, dy);
}
float4 SPIRV_OVERLOADABLE SPIRV_BUILTIN(ImageSampleExplicitLod, _v4f32_img3d_ro_v4f32_i32_v4f32_v4f32, _Rfloat4)(
__spirv_SampledImage_3D SampledImage,
float4 Coordinate,
int ImageOperands,
float4 dx,
float4 dy)
{
return __spirv_ImageSampleExplicitLod_Rfloat4(SampledImage, Coordinate.xyz, ImageOperands, dx.xyz, dy.xyz);
}
#ifdef cl_khr_fp16
half4 OVERLOADABLE __spirv_ImageSampleExplicitLod_Rhalf4(
__spirv_SampledImage_3D SampledImage,
float3 Coordinate,
int ImageOperands,
float3 dx,
float3 dy)
{
int image_id = (int)__builtin_IB_get_image(SampledImage);
int sampler_id = (int)__builtin_IB_get_sampler(SampledImage);
if (__builtin_IB_get_snap_wa_reqd(sampler_id) != 0)
{
Coordinate.x = (Coordinate.x < 0) ? -1.0f : Coordinate.x;
Coordinate.y = (Coordinate.y < 0) ? -1.0f : Coordinate.y;
Coordinate.z = (Coordinate.z < 0) ? -1.0f : Coordinate.z;
}
float4 res = __builtin_IB_OCL_3d_sample_d(image_id, sampler_id, Coordinate, dx, dy);
return SPIRV_BUILTIN(FConvert, _v4f16_v4f32, _Rhalf4)(res);
}
half4 SPIRV_OVERLOADABLE SPIRV_BUILTIN(ImageSampleExplicitLod, _v4f16_img3d_ro_v4f32_i32_v4f32_v4f32, _Rhalf4)(
__spirv_SampledImage_3D SampledImage,
float4 Coordinate,
int ImageOperands,
float4 dx,
float4 dy)
{
return __spirv_ImageSampleExplicitLod_Rhalf4(SampledImage, Coordinate.xyz, ImageOperands, dx.xyz, dy.xyz);
}
#endif // cl_khr_fp16
uint4 OVERLOADABLE __spirv_ImageSampleExplicitLod_Ruint4(
__spirv_SampledImage_3D SampledImage,
float3 Coordinate,
int ImageOperands,
float3 dx,
float3 dy)
{
return as_uint4(__spirv_ImageSampleExplicitLod_Rfloat4(SampledImage, Coordinate, ImageOperands, dx, dy));
}
uint4 OVERLOADABLE __spirv_ImageSampleExplicitLod_Ruint4(
__spirv_SampledImage_3D SampledImage,
float4 Coordinate,
int ImageOperands,
float4 dx,
float4 dy)
{
return __spirv_ImageSampleExplicitLod_Ruint4(SampledImage, Coordinate.xyz, ImageOperands, dx.xyz, dy.xyz);
}
int4 OVERLOADABLE __spirv_ImageSampleExplicitLod_Rint4(
__spirv_SampledImage_3D SampledImage,
float3 Coordinate,
int ImageOperands,
float3 dx,
float3 dy)
{
return as_int4(__spirv_ImageSampleExplicitLod_Rfloat4(SampledImage, Coordinate, ImageOperands, dx, dy));
}
int4 SPIRV_OVERLOADABLE SPIRV_BUILTIN(ImageSampleExplicitLod, _v4i32_img3d_ro_v4f32_i32_v4f32_v4f32, _Rint4)(
__spirv_SampledImage_3D SampledImage,
float4 Coordinate,
int ImageOperands,
float4 dx,
float4 dy)
{
return __spirv_ImageSampleExplicitLod_Rint4(SampledImage, Coordinate.xyz, ImageOperands, dx.xyz, dy.xyz);
}
ushort4 OVERLOADABLE __spirv_ImageSampleExplicitLod_Rushort4(__spirv_SampledImage_3D SampledImage, float3 Coordinate, int ImageOperands, float3 dx, float3 dy)
{
return convert_ushort4(__spirv_ImageSampleExplicitLod_Ruint4(SampledImage, Coordinate, ImageOperands, dx, dy));
}
short4 OVERLOADABLE __spirv_ImageSampleExplicitLod_Rshort4(__spirv_SampledImage_3D SampledImage, float3 Coordinate, int ImageOperands, float3 dx, float3 dy)
{
return convert_short4(__spirv_ImageSampleExplicitLod_Rint4(SampledImage, Coordinate, ImageOperands, dx, dy));
}
uchar4 OVERLOADABLE __spirv_ImageSampleExplicitLod_Ruchar4(__spirv_SampledImage_3D SampledImage, float3 Coordinate, int ImageOperands, float3 dx, float3 dy)
{
return convert_uchar4(__spirv_ImageSampleExplicitLod_Ruint4(SampledImage, Coordinate, ImageOperands, dx, dy));
}
char4 OVERLOADABLE __spirv_ImageSampleExplicitLod_Rchar4(__spirv_SampledImage_3D SampledImage, float3 Coordinate, int ImageOperands, float3 dx, float3 dy)
{
return convert_char4(__spirv_ImageSampleExplicitLod_Rint4(SampledImage, Coordinate, ImageOperands, dx, dy));
}
float4 SPIRV_OVERLOADABLE SPIRV_BUILTIN(ImageSampleExplicitLod, _v4f32_img2d_array_ro_v4f32_i32_v2f32_v2f32, _Rfloat4)(
__spirv_SampledImage_2D SampledImage,
float4 Coordinate,
int ImageOperands,
float2 dx,
float2 dy)
{
int image_id = (int)__builtin_IB_get_image(SampledImage);
int sampler_id = (int)__builtin_IB_get_sampler(SampledImage);
if (__builtin_IB_get_snap_wa_reqd(sampler_id) != 0)
{
Coordinate.x = (Coordinate.x < 0) ? -1.0f : Coordinate.x;
Coordinate.y = (Coordinate.y < 0) ? -1.0f : Coordinate.y;
}
return __builtin_IB_OCL_2darr_sample_d(image_id, sampler_id, Coordinate.xyz, dx, dy);
}
uint4 OVERLOADABLE __spirv_ImageSampleExplicitLod_Ruint4(
__spirv_SampledImage_2D SampledImage,
float4 Coordinate,
int ImageOperands,
float2 dx,
float2 dy)
{
return as_uint4(SPIRV_BUILTIN(ImageSampleExplicitLod, _v4f32_img2d_array_ro_v4f32_i32_v2f32_v2f32, _Rfloat4)(SampledImage, Coordinate, ImageOperands, dx, dy));
}
int4 SPIRV_OVERLOADABLE SPIRV_BUILTIN(ImageSampleExplicitLod, _v4i32_img2d_array_ro_v4f32_i32_v2f32_v2f32, _Rint4)(
__spirv_SampledImage_2D SampledImage,
float4 Coordinate,
int ImageOperands,
float2 dx,
float2 dy)
{
return as_int4(SPIRV_BUILTIN(ImageSampleExplicitLod, _v4f32_img2d_array_ro_v4f32_i32_v2f32_v2f32, _Rfloat4)(SampledImage, Coordinate, ImageOperands, dx, dy));
}
float4 SPIRV_OVERLOADABLE SPIRV_BUILTIN(ImageSampleExplicitLod, _v4f32_img1d_ro_f32_i32_f32_f32, _Rfloat4)(
__spirv_SampledImage_1D SampledImage,
float Coordinate,
int ImageOperands,
float dx,
float dy)
{
int image_id = (int)__builtin_IB_get_image(SampledImage);
int sampler_id = (int)__builtin_IB_get_sampler(SampledImage);
if (__builtin_IB_get_snap_wa_reqd(sampler_id) != 0)
{
Coordinate = (Coordinate < 0) ? -1.0f : Coordinate;
}
return __builtin_IB_OCL_1d_sample_d(image_id, sampler_id, Coordinate, dx, dy);
}
#ifdef cl_khr_fp16
half4 SPIRV_OVERLOADABLE SPIRV_BUILTIN(ImageSampleExplicitLod, _v4f16_img1d_ro_f32_i32_f32_f32, _Rhalf4)(
__spirv_SampledImage_1D SampledImage,
float Coordinate,
int ImageOperands,
float dx,
float dy)
{
return convert_half4(SPIRV_BUILTIN(ImageSampleExplicitLod, _v4f32_img1d_ro_f32_i32_f32_f32, _Rfloat4)(SampledImage, Coordinate, ImageOperands, dx, dy));
}
#endif // cl_khr_fp16
uint4 OVERLOADABLE __spirv_ImageSampleExplicitLod_Ruint4(
__spirv_SampledImage_1D SampledImage,
float Coordinate,
int ImageOperands,
float dx,
float dy)
{
return as_uint4(SPIRV_BUILTIN(ImageSampleExplicitLod, _v4f32_img1d_ro_f32_i32_f32_f32, _Rfloat4)(SampledImage, Coordinate, ImageOperands, dx, dy));
}
int4 SPIRV_OVERLOADABLE SPIRV_BUILTIN(ImageSampleExplicitLod, _v4i32_img1d_ro_f32_i32_f32_f32, _Rint4)(
__spirv_SampledImage_1D SampledImage,
float Coordinate,
int ImageOperands,
float dx,
float dy)
{
return as_int4(SPIRV_BUILTIN(ImageSampleExplicitLod, _v4f32_img1d_ro_f32_i32_f32_f32, _Rfloat4)(SampledImage, Coordinate, ImageOperands, dx, dy));
}
float4 SPIRV_OVERLOADABLE SPIRV_BUILTIN(ImageSampleExplicitLod, _v4f32_img1d_array_ro_v2f32_i32_f32_f32, _Rfloat4)(
__spirv_SampledImage_1D_array SampledImage,
float2 Coordinate,
int ImageOperands,
float dx,
float dy)
{
int image_id = (int)__builtin_IB_get_image(SampledImage);
int sampler_id = (int)__builtin_IB_get_sampler(SampledImage);
if (__builtin_IB_get_snap_wa_reqd(sampler_id) != 0)
{
Coordinate.x = (Coordinate.x < 0) ? -1.0f : Coordinate.x;
}
return __builtin_IB_OCL_1darr_sample_d(image_id, sampler_id, Coordinate, dx, dy);
}
uint4 OVERLOADABLE __spirv_ImageSampleExplicitLod_Ruint4(
__spirv_SampledImage_1D_array SampledImage,
float2 Coordinate,
int ImageOperands,
float dx,
float dy)
{
return as_uint4(SPIRV_BUILTIN(ImageSampleExplicitLod, _v4f32_img1d_array_ro_v2f32_i32_f32_f32, _Rfloat4)(SampledImage, Coordinate, ImageOperands, dx, dy));
}
int4 SPIRV_OVERLOADABLE SPIRV_BUILTIN(ImageSampleExplicitLod, _v4i32_img1d_array_ro_v2f32_i32_f32_f32, _Rint4)(
__spirv_SampledImage_1D_array SampledImage,
float2 Coordinate,
int ImageOperands,
float dx,
float dy)
{
return as_int4(SPIRV_BUILTIN(ImageSampleExplicitLod, _v4f32_img1d_array_ro_v2f32_i32_f32_f32, _Rfloat4)(SampledImage, Coordinate, ImageOperands, dx, dy));
}
float4 SPIRV_OVERLOADABLE SPIRV_BUILTIN(ImageSampleExplicitLod, _v4f32_img2d_depth_ro_v2f32_i32_v2f32_v2f32, _Rfloat4)(
__spirv_SampledImage_2D_depth SampledImage,
float2 Coordinate,
int ImageOperands,
float2 dx,
float2 dy)
{
int image_id = (int)__builtin_IB_get_image(SampledImage);
int sampler_id = (int)__builtin_IB_get_sampler(SampledImage);
if (__builtin_IB_get_snap_wa_reqd(sampler_id) != 0)
{
Coordinate.x = (Coordinate.x < 0) ? -1.0f : Coordinate.x;
Coordinate.y = (Coordinate.y < 0) ? -1.0f : Coordinate.y;
}
return __builtin_IB_OCL_2d_sample_d(image_id, sampler_id, Coordinate, dx, dy);
}
float4 SPIRV_OVERLOADABLE SPIRV_BUILTIN(ImageSampleExplicitLod, _v4f32_img2d_array_depth_ro_v4f32_i32_v2f32_v2f32, _Rfloat4)(
__spirv_SampledImage_2D_array_depth SampledImage,
float4 Coordinate,
int ImageOperands,
float2 dx,
float2 dy)
{
int image_id = (int)__builtin_IB_get_image(SampledImage);
int sampler_id = (int)__builtin_IB_get_sampler(SampledImage);
if (__builtin_IB_get_snap_wa_reqd(sampler_id) != 0)
{
Coordinate.x = (Coordinate.x < 0) ? -1.0f : Coordinate.x;
Coordinate.y = (Coordinate.y < 0) ? -1.0f : Coordinate.y;
}
return __builtin_IB_OCL_2darr_sample_d(image_id, sampler_id, Coordinate.xyz, dx, dy);
}
// Image SampleExplicitLod SYCL Bindless
#define DefaultImageOperands 2
#define DefaultLod 0.f
#define DEF_SYCL_BINDLESS_SAMPLED_IMAGE_EXPLICIT_LOD_S_C_TY(DIM, ARRAY, COORD_DIM, RET_TYPE, LOAD_TYPE) \
RET_TYPE##4 OVERLOADABLE __spirv_ImageSampleExplicitLod_R##RET_TYPE##4(__spirv_SampledImage_##DIM##D##ARRAY Image, float##COORD_DIM Coordinate, int ImageOperands, float Lod) \
{ \
return convert_##RET_TYPE##4(__spirv_ImageSampleExplicitLod_R##LOAD_TYPE(Image, Coordinate, ImageOperands, Lod)); \
} \
RET_TYPE##4 OVERLOADABLE __spirv_ImageSampleExplicitLod_R##RET_TYPE##4(__spirv_SampledImage_##DIM##D##ARRAY Image, int##COORD_DIM Coordinate, int ImageOperands, float Lod) \
{ \
return convert_##RET_TYPE##4(__spirv_ImageSampleExplicitLod_R##LOAD_TYPE(Image, Coordinate, ImageOperands, Lod)); \
}
#define DEF_SYCL_BINDLESS_SAMPLED_IMAGE_EXPLICIT_LOD_S_C(DIM, ARRAY, COORD_DIM) \
DEF_SYCL_BINDLESS_SAMPLED_IMAGE_EXPLICIT_LOD_S_C_TY(DIM, ARRAY, COORD_DIM, char, int4) \
DEF_SYCL_BINDLESS_SAMPLED_IMAGE_EXPLICIT_LOD_S_C_TY(DIM, ARRAY, COORD_DIM, uchar, uint4) \
DEF_SYCL_BINDLESS_SAMPLED_IMAGE_EXPLICIT_LOD_S_C_TY(DIM, ARRAY, COORD_DIM, short, int4) \
DEF_SYCL_BINDLESS_SAMPLED_IMAGE_EXPLICIT_LOD_S_C_TY(DIM, ARRAY, COORD_DIM, ushort, uint4)
#define DEF_SYCL_BINDLESS_SAMPLED_IMAGE_EXPLICIT_LOD_DX_DY_S_C_TY(DIM, RET_TYPE, LOAD_TYPE, COORD_DIM) \
RET_TYPE##4 OVERLOADABLE __spirv_ImageSampleExplicitLod_R##RET_TYPE##4(__spirv_SampledImage_##DIM##D Image, float##COORD_DIM Coordinate, int ImageOperands, float##COORD_DIM dx, float##COORD_DIM dy) \
{ \
return convert_##RET_TYPE##4(__spirv_ImageSampleExplicitLod_R##LOAD_TYPE(Image, Coordinate, ImageOperands, dx, dy)); \
}
#define DEF_SYCL_BINDLESS_SAMPLED_IMAGE_EXPLICIT_LOD_DX_DY_S_C(DIM, COORD_DIM) \
DEF_SYCL_BINDLESS_SAMPLED_IMAGE_EXPLICIT_LOD_DX_DY_S_C_TY(DIM, char, int4, COORD_DIM) \
DEF_SYCL_BINDLESS_SAMPLED_IMAGE_EXPLICIT_LOD_DX_DY_S_C_TY(DIM, short, int4, COORD_DIM) \
DEF_SYCL_BINDLESS_SAMPLED_IMAGE_EXPLICIT_LOD_DX_DY_S_C_TY(DIM, uchar, uint4, COORD_DIM) \
DEF_SYCL_BINDLESS_SAMPLED_IMAGE_EXPLICIT_LOD_DX_DY_S_C_TY(DIM, ushort, uint4, COORD_DIM)
#if defined(__USE_KHRONOS_SPIRV_TRANSLATOR__)
DEF_SYCL_BINDLESS_SAMPLED_IMAGE_EXPLICIT_LOD_S_C(3, , 3)
DEF_SYCL_BINDLESS_SAMPLED_IMAGE_EXPLICIT_LOD_S_C(2, , 2)
DEF_SYCL_BINDLESS_SAMPLED_IMAGE_EXPLICIT_LOD_S_C(2, _array, 3)
DEF_SYCL_BINDLESS_SAMPLED_IMAGE_EXPLICIT_LOD_S_C(1, , )
DEF_SYCL_BINDLESS_SAMPLED_IMAGE_EXPLICIT_LOD_S_C(1, _array, 2)
DEF_SYCL_BINDLESS_SAMPLED_IMAGE_EXPLICIT_LOD_DX_DY_S_C(2, 2)
DEF_SYCL_BINDLESS_SAMPLED_IMAGE_EXPLICIT_LOD_DX_DY_S_C(1, )
#endif // defined(__USE_KHRONOS_SPIRV_TRANSLATOR__)
#define DEF_SYCL_BINDLESS_SAMPLED_IMAGE_EXPLICIT_LOD_TY(DIM, ARRAY, RET_TYPE, LOAD_TYPE, COORD_DIM) \
RET_TYPE##4 OVERLOADABLE __spirv_ImageSampleExplicitLod_R##RET_TYPE##4(__spirv_SampledImage_##DIM##D##ARRAY Image, float##COORD_DIM Coordinate, int ImageOperands) \
{ \
return __spirv_ImageSampleExplicitLod_R##RET_TYPE##4(Image, Coordinate, ImageOperands, DefaultLod); \
} \
RET_TYPE##4 OVERLOADABLE __spirv_ImageSampleExplicitLod_R##RET_TYPE##4(__spirv_SampledImage_##DIM##D##ARRAY Image, int##COORD_DIM Coordinate, int ImageOperands) \
{ \
return __spirv_ImageSampleExplicitLod_R##RET_TYPE##4(Image, Coordinate, ImageOperands, DefaultLod); \
} \
RET_TYPE##4 OVERLOADABLE __spirv_ImageSampleExplicitLod_R##RET_TYPE##4(__spirv_SampledImage_##DIM##D##ARRAY Image, float##COORD_DIM Coordinate) \
{ \
return __spirv_ImageSampleExplicitLod_R##RET_TYPE##4(Image, Coordinate, DefaultImageOperands, DefaultLod); \
} \
RET_TYPE##4 OVERLOADABLE __spirv_ImageSampleExplicitLod_R##RET_TYPE##4(__spirv_SampledImage_##DIM##D##ARRAY Image, int##COORD_DIM Coordinate) \
{ \
return __spirv_ImageSampleExplicitLod_R##RET_TYPE##4(Image, Coordinate, DefaultImageOperands, DefaultLod); \
} \
RET_TYPE##2 OVERLOADABLE __spirv_ImageSampleExplicitLod_R##RET_TYPE##2(__spirv_SampledImage_##DIM##D##ARRAY Image, float##COORD_DIM Coordinate, int ImageOperands, float Lod) \
{ \
return convert_##RET_TYPE##2(__spirv_ImageSampleExplicitLod_R##LOAD_TYPE(Image, Coordinate, ImageOperands, Lod).xy); \
} \
RET_TYPE##2 OVERLOADABLE __spirv_ImageSampleExplicitLod_R##RET_TYPE##2(__spirv_SampledImage_##DIM##D##ARRAY Image, int##COORD_DIM Coordinate, int ImageOperands, float Lod) \
{ \
return convert_##RET_TYPE##2(__spirv_ImageSampleExplicitLod_R##LOAD_TYPE(Image, Coordinate, ImageOperands, Lod).xy); \
} \
RET_TYPE##2 OVERLOADABLE __spirv_ImageSampleExplicitLod_R##RET_TYPE##2(__spirv_SampledImage_##DIM##D##ARRAY Image, float##COORD_DIM Coordinate, int ImageOperands) \
{ \
return __spirv_ImageSampleExplicitLod_R##RET_TYPE##2(Image, Coordinate, ImageOperands, DefaultLod); \
} \
RET_TYPE##2 OVERLOADABLE __spirv_ImageSampleExplicitLod_R##RET_TYPE##2(__spirv_SampledImage_##DIM##D##ARRAY Image, int##COORD_DIM Coordinate, int ImageOperands) \
{ \
return __spirv_ImageSampleExplicitLod_R##RET_TYPE##2(Image, Coordinate, ImageOperands, DefaultLod); \
} \
RET_TYPE##2 OVERLOADABLE __spirv_ImageSampleExplicitLod_R##RET_TYPE##2(__spirv_SampledImage_##DIM##D##ARRAY Image, float##COORD_DIM Coordinate) \
{ \
return __spirv_ImageSampleExplicitLod_R##RET_TYPE##2(Image, Coordinate, DefaultImageOperands, DefaultLod); \
} \
RET_TYPE##2 OVERLOADABLE __spirv_ImageSampleExplicitLod_R##RET_TYPE##2(__spirv_SampledImage_##DIM##D##ARRAY Image, int##COORD_DIM Coordinate) \
{ \
return __spirv_ImageSampleExplicitLod_R##RET_TYPE##2(Image, Coordinate, DefaultImageOperands, DefaultLod); \
} \
RET_TYPE OVERLOADABLE __spirv_ImageSampleExplicitLod_R##RET_TYPE(__spirv_SampledImage_##DIM##D##ARRAY Image, float##COORD_DIM Coordinate, int ImageOperands, float Lod) \
{ \
return convert_##RET_TYPE(__spirv_ImageSampleExplicitLod_R##LOAD_TYPE(Image, Coordinate, ImageOperands, Lod).x); \
} \
RET_TYPE OVERLOADABLE __spirv_ImageSampleExplicitLod_R##RET_TYPE(__spirv_SampledImage_##DIM##D##ARRAY Image, int##COORD_DIM Coordinate, int ImageOperands, float Lod) \
{ \
return convert_##RET_TYPE(__spirv_ImageSampleExplicitLod_R##LOAD_TYPE(Image, Coordinate, ImageOperands, Lod).x); \
} \
RET_TYPE OVERLOADABLE __spirv_ImageSampleExplicitLod_R##RET_TYPE(__spirv_SampledImage_##DIM##D##ARRAY Image, float##COORD_DIM Coordinate, int ImageOperands) \
{ \
return __spirv_ImageSampleExplicitLod_R##RET_TYPE(Image, Coordinate, ImageOperands, DefaultLod); \
} \
RET_TYPE OVERLOADABLE __spirv_ImageSampleExplicitLod_R##RET_TYPE(__spirv_SampledImage_##DIM##D##ARRAY Image, int##COORD_DIM Coordinate, int ImageOperands) \
{ \
return __spirv_ImageSampleExplicitLod_R##RET_TYPE(Image, Coordinate, ImageOperands, DefaultLod); \
} \
RET_TYPE OVERLOADABLE __spirv_ImageSampleExplicitLod_R##RET_TYPE(__spirv_SampledImage_##DIM##D##ARRAY Image, float##COORD_DIM Coordinate) \
{ \
return __spirv_ImageSampleExplicitLod_R##RET_TYPE(Image, Coordinate, DefaultImageOperands, DefaultLod); \
} \
RET_TYPE OVERLOADABLE __spirv_ImageSampleExplicitLod_R##RET_TYPE(__spirv_SampledImage_##DIM##D##ARRAY Image, int##COORD_DIM Coordinate) \
{ \
return __spirv_ImageSampleExplicitLod_R##RET_TYPE(Image, Coordinate, DefaultImageOperands, DefaultLod); \
}
#define DEF_SYCL_BINDLESS_SAMPLED_IMAGE_EXPLICIT_LOD_DX_DY_TY(DIM, RET_TYPE, LOAD_TYPE, COORD_DIM) \
RET_TYPE##2 OVERLOADABLE __spirv_ImageSampleExplicitLod_R##RET_TYPE##2(__spirv_SampledImage_##DIM##D Image, float##COORD_DIM Coordinate, int ImageOperands, float##COORD_DIM dx, float##COORD_DIM dy) \
{ \
return convert_##RET_TYPE##2(__spirv_ImageSampleExplicitLod_R##LOAD_TYPE(Image, Coordinate, ImageOperands, dx, dy).xy); \
} \
RET_TYPE OVERLOADABLE __spirv_ImageSampleExplicitLod_R##RET_TYPE(__spirv_SampledImage_##DIM##D Image, float##COORD_DIM Coordinate, int ImageOperands, float##COORD_DIM dx, float##COORD_DIM dy) \
{ \
return convert_##RET_TYPE(__spirv_ImageSampleExplicitLod_R##LOAD_TYPE(Image, Coordinate, ImageOperands, dx, dy).x); \
}
#define DEF_SYCL_BINDLESS_SAMPLED_IMAGE_EXPLICIT_LOD(DIM, ARRAY, COORD_DIM) \
DEF_SYCL_BINDLESS_SAMPLED_IMAGE_EXPLICIT_LOD_TY(DIM, ARRAY, char, int4, COORD_DIM) \
DEF_SYCL_BINDLESS_SAMPLED_IMAGE_EXPLICIT_LOD_TY(DIM, ARRAY, short, int4, COORD_DIM) \
DEF_SYCL_BINDLESS_SAMPLED_IMAGE_EXPLICIT_LOD_TY(DIM, ARRAY, int, int4, COORD_DIM) \
DEF_SYCL_BINDLESS_SAMPLED_IMAGE_EXPLICIT_LOD_TY(DIM, ARRAY, uchar, uint4, COORD_DIM) \
DEF_SYCL_BINDLESS_SAMPLED_IMAGE_EXPLICIT_LOD_TY(DIM, ARRAY, ushort, uint4, COORD_DIM) \
DEF_SYCL_BINDLESS_SAMPLED_IMAGE_EXPLICIT_LOD_TY(DIM, ARRAY, uint, uint4, COORD_DIM) \
DEF_SYCL_BINDLESS_SAMPLED_IMAGE_EXPLICIT_LOD_TY(DIM, ARRAY, float, float4, COORD_DIM)
#define DEF_SYCL_BINDLESS_SAMPLED_IMAGE_EXPLICIT_LOD_DX_DY(DIM, COORD_DIM) \
DEF_SYCL_BINDLESS_SAMPLED_IMAGE_EXPLICIT_LOD_DX_DY_TY(DIM, char, int4, COORD_DIM) \
DEF_SYCL_BINDLESS_SAMPLED_IMAGE_EXPLICIT_LOD_DX_DY_TY(DIM, short, int4, COORD_DIM) \
DEF_SYCL_BINDLESS_SAMPLED_IMAGE_EXPLICIT_LOD_DX_DY_TY(DIM, int, int4, COORD_DIM) \
DEF_SYCL_BINDLESS_SAMPLED_IMAGE_EXPLICIT_LOD_DX_DY_TY(DIM, uchar, uint4, COORD_DIM) \
DEF_SYCL_BINDLESS_SAMPLED_IMAGE_EXPLICIT_LOD_DX_DY_TY(DIM, ushort, uint4, COORD_DIM) \
DEF_SYCL_BINDLESS_SAMPLED_IMAGE_EXPLICIT_LOD_DX_DY_TY(DIM, uint, uint4, COORD_DIM) \
DEF_SYCL_BINDLESS_SAMPLED_IMAGE_EXPLICIT_LOD_DX_DY_TY(DIM, float, float4, COORD_DIM)
#define DEF_SYCL_BINDLESS_SAMPLED_IMAGE_EXPLICIT_LOD_HALF(DIM, ARRAY, COORD_DIM) \
DEF_SYCL_BINDLESS_SAMPLED_IMAGE_EXPLICIT_LOD_TY(DIM, ARRAY, half, half4, COORD_DIM)
#define DEF_SYCL_BINDLESS_SAMPLED_IMAGE_EXPLICIT_LOD_DX_DY_HALF(DIM, COORD_DIM) \
DEF_SYCL_BINDLESS_SAMPLED_IMAGE_EXPLICIT_LOD_DX_DY_TY(DIM, half, half4, COORD_DIM)
#if defined(__USE_KHRONOS_SPIRV_TRANSLATOR__)
DEF_SYCL_BINDLESS_SAMPLED_IMAGE_EXPLICIT_LOD(3, , 3)
DEF_SYCL_BINDLESS_SAMPLED_IMAGE_EXPLICIT_LOD(2, , 2)
DEF_SYCL_BINDLESS_SAMPLED_IMAGE_EXPLICIT_LOD(2, _array, 3)
DEF_SYCL_BINDLESS_SAMPLED_IMAGE_EXPLICIT_LOD(1, , )
DEF_SYCL_BINDLESS_SAMPLED_IMAGE_EXPLICIT_LOD(1, _array, 2)
DEF_SYCL_BINDLESS_SAMPLED_IMAGE_EXPLICIT_LOD_DX_DY(2, 2)
DEF_SYCL_BINDLESS_SAMPLED_IMAGE_EXPLICIT_LOD_DX_DY(1, )
#ifdef cl_khr_fp16
DEF_SYCL_BINDLESS_SAMPLED_IMAGE_EXPLICIT_LOD_HALF(3, , 3)
DEF_SYCL_BINDLESS_SAMPLED_IMAGE_EXPLICIT_LOD_HALF(2, , 2)
DEF_SYCL_BINDLESS_SAMPLED_IMAGE_EXPLICIT_LOD_HALF(2, _array, 3)
DEF_SYCL_BINDLESS_SAMPLED_IMAGE_EXPLICIT_LOD_HALF(1, , )
DEF_SYCL_BINDLESS_SAMPLED_IMAGE_EXPLICIT_LOD_HALF(1, _array, 2)
DEF_SYCL_BINDLESS_SAMPLED_IMAGE_EXPLICIT_LOD_DX_DY_HALF(2, 2)
DEF_SYCL_BINDLESS_SAMPLED_IMAGE_EXPLICIT_LOD_DX_DY_HALF(1, )
#endif // cl_khr_fp16
#endif // defined(__USE_KHRONOS_SPIRV_TRANSLATOR__)
#undef DefaultImageOperands
#undef DefaultLod
// Image Read
#define DEF_IMAGE_READ_2D(ACC_QUAL) \
uint4 OVERLOADABLE __spirv_ImageRead_Ruint4(global Img2d_##ACC_QUAL* Image, int2 Coordinate) \
{ \
int id = (int)__builtin_astype(Image, __global void*); \
return __builtin_IB_OCL_2d_ldui(id, Coordinate, 0); \
} \
uint4 OVERLOADABLE __spirv_ImageRead_Ruint4(global Img2d_##ACC_QUAL* Image, int2 Coordinate, int ImageOperands) \
{ \
return __spirv_ImageRead_Ruint4(Image, Coordinate); \
} \
int4 SPIRV_OVERLOADABLE SPIRV_BUILTIN(ImageRead, _v4i32_img2d_##ACC_QUAL##_v2i32, _Rint4)(global Img2d_##ACC_QUAL* Image, int2 Coordinate) \
{ \
uint4 res = __spirv_ImageRead_Ruint4(Image, Coordinate); \
return as_int4(res); \
} \
int4 SPIRV_OVERLOADABLE SPIRV_BUILTIN(ImageRead, _v4i32_img2d_##ACC_QUAL##_v2i32_i32, _Rint4)(global Img2d_##ACC_QUAL* Image, int2 Coordinate, int ImageOperands) \
{ \
return SPIRV_BUILTIN(ImageRead, _v4i32_img2d_##ACC_QUAL##_v2i32, _Rint4)(Image, Coordinate); \
} \
float4 SPIRV_OVERLOADABLE SPIRV_BUILTIN(ImageRead, _v4f32_img2d_##ACC_QUAL##_v2i32, _Rfloat4)(global Img2d_##ACC_QUAL* Image, int2 Coordinate) \
{ \
int id = (int)__builtin_astype(Image, __global void*); \
float4 res = __builtin_IB_OCL_2d_ld(id, Coordinate, 0); \
return __flush_denormals(res); \
} \
float4 SPIRV_OVERLOADABLE SPIRV_BUILTIN(ImageRead, _v4f32_img2d_##ACC_QUAL##_v2i32_i32, _Rfloat4)(global Img2d_##ACC_QUAL* Image, int2 Coordinate, int ImageOperands) \
{ \
return SPIRV_BUILTIN(ImageRead, _v4f32_img2d_##ACC_QUAL##_v2i32, _Rfloat4)(Image, Coordinate); \
}
#define DEF_IMAGE_READ_3D(ACC_QUAL) \
uint4 OVERLOADABLE __spirv_ImageRead_Ruint4(global Img3d_##ACC_QUAL* Image, int3 Coordinate) \
{ \
int id = (int)__builtin_astype(Image, __global void*); \
return __builtin_IB_OCL_3d_ldui( id, Coordinate, 0); \
} \
uint4 OVERLOADABLE __spirv_ImageRead_Ruint4(global Img3d_##ACC_QUAL* Image, int4 Coordinate) \
{ \
return __spirv_ImageRead_Ruint4(Image, Coordinate.xyz); \
} \
uint4 OVERLOADABLE __spirv_ImageRead_Ruint4(global Img3d_##ACC_QUAL* Image, int3 Coordinate, int ImageOperands) \
{ \
return __spirv_ImageRead_Ruint4(Image, Coordinate); \
} \
uint4 OVERLOADABLE __spirv_ImageRead_Ruint4(global Img3d_##ACC_QUAL* Image, int4 Coordinate, int ImageOperands) \
{ \
return __spirv_ImageRead_Ruint4(Image, Coordinate.xyz); \
} \
int4 OVERLOADABLE __spirv_ImageRead_Rint4(global Img3d_##ACC_QUAL* Image, int3 Coordinate) \
{ \
uint4 res = __spirv_ImageRead_Ruint4(Image, Coordinate); \
return as_int4(res); \
} \
int4 SPIRV_OVERLOADABLE SPIRV_BUILTIN(ImageRead, _v4i32_img3d_##ACC_QUAL##_v4i32, _Rint4)(global Img3d_##ACC_QUAL* Image, int4 Coordinate) \
{ \
return __spirv_ImageRead_Rint4(Image, Coordinate.xyz); \
} \
int4 OVERLOADABLE __spirv_ImageRead_Rint4(global Img3d_##ACC_QUAL* Image, int3 Coordinate, int ImageOperands) \
{ \
return __spirv_ImageRead_Rint4(Image, Coordinate); \
} \
int4 SPIRV_OVERLOADABLE SPIRV_BUILTIN(ImageRead, _v4i32_img3d_##ACC_QUAL##_v4i32_i32, _Rint4)(global Img3d_##ACC_QUAL* Image, int4 Coordinate, int ImageOperands) \
{ \
return __spirv_ImageRead_Rint4(Image, Coordinate.xyz); \
} \
float4 OVERLOADABLE __spirv_ImageRead_Rfloat4(global Img3d_##ACC_QUAL* Image, int3 Coordinate) \
{ \
int id = (int)__builtin_astype(Image, __global void*); \
float4 res = __builtin_IB_OCL_3d_ld(id, Coordinate, 0); \
return __flush_denormals(res); \
} \
float4 SPIRV_OVERLOADABLE SPIRV_BUILTIN(ImageRead, _v4f32_img3d_##ACC_QUAL##_v4i32, _Rfloat4)(global Img3d_##ACC_QUAL* Image, int4 Coordinate) \
{ \
return __spirv_ImageRead_Rfloat4(Image, Coordinate.xyz); \
} \
float4 OVERLOADABLE __spirv_ImageRead_Rfloat4(global Img3d_##ACC_QUAL* Image, int3 Coordinate, int ImageOperands) \
{ \
return __spirv_ImageRead_Rfloat4(Image, Coordinate); \
} \
float4 SPIRV_OVERLOADABLE SPIRV_BUILTIN(ImageRead, _v4f32_img3d_##ACC_QUAL##_v4i32_i32, _Rfloat4)(global Img3d_##ACC_QUAL* Image, int4 Coordinate, int ImageOperands) \
{ \
return __spirv_ImageRead_Rfloat4(Image, Coordinate.xyz); \
}
#define DEF_IMAGE_READ_2D_ARRAY(ACC_QUAL) \
uint4 OVERLOADABLE __spirv_ImageRead_Ruint4(global Img2d_array_##ACC_QUAL* Image, int3 Coordinate) \
{ \
int id = (int)__builtin_astype(Image, __global void*); \
return __builtin_IB_OCL_2darr_ldui(id, Coordinate, 0); \
} \
uint4 OVERLOADABLE __spirv_ImageRead_Ruint4(global Img2d_array_##ACC_QUAL* Image, int4 Coordinate) \
{ \
return __spirv_ImageRead_Ruint4(Image, Coordinate.xyz); \
} \
uint4 OVERLOADABLE __spirv_ImageRead_Ruint4(global Img2d_array_##ACC_QUAL* Image, int3 Coordinate, int ImageOperands) \
{ \
return __spirv_ImageRead_Ruint4(Image, Coordinate); \
} \
uint4 OVERLOADABLE __spirv_ImageRead_Ruint4(global Img2d_array_##ACC_QUAL* Image, int4 Coordinate, int ImageOperands) \
{ \
return __spirv_ImageRead_Ruint4(Image, Coordinate.xyz); \
} \
int4 OVERLOADABLE __spirv_ImageRead_Rint4(global Img2d_array_##ACC_QUAL* Image, int3 Coordinate) \
{ \
uint4 res = __spirv_ImageRead_Ruint4(Image, Coordinate); \
return as_int4(res); \
} \
int4 OVERLOADABLE __spirv_ImageRead_Rint4(global Img2d_array_##ACC_QUAL* Image, int3 Coordinate, int ImageOperands) \
{ \
return __spirv_ImageRead_Rint4(Image, Coordinate); \
} \
int4 SPIRV_OVERLOADABLE SPIRV_BUILTIN(ImageRead, _v4i32_img2d_array_##ACC_QUAL##_v4i32, _Rint4)(global Img2d_array_##ACC_QUAL* Image, int4 Coordinate) \
{ \
return __spirv_ImageRead_Rint4(Image, Coordinate.xyz); \
} \
int4 SPIRV_OVERLOADABLE SPIRV_BUILTIN(ImageRead, _v4i32_img2d_array_##ACC_QUAL##_v4i32_i32, _Rint4)(global Img2d_array_##ACC_QUAL* Image, int4 Coordinate, int ImageOperands) \
{ \
return SPIRV_BUILTIN(ImageRead, _v4i32_img2d_array_##ACC_QUAL##_v4i32, _Rint4)(Image, Coordinate); \
} \
float4 OVERLOADABLE __spirv_ImageRead_Rfloat4(global Img2d_array_##ACC_QUAL* Image, int3 Coordinate) \
{ \
int id = (int)__builtin_astype(Image, __global void*); \
float4 res = __builtin_IB_OCL_2darr_ld(id, Coordinate, 0); \
return __flush_denormals(res); \
} \
float4 OVERLOADABLE __spirv_ImageRead_Rfloat4(global Img2d_array_##ACC_QUAL* Image, int3 Coordinate, int ImageOperands) \
{ \
return __spirv_ImageRead_Rfloat4(Image, Coordinate); \
} \
float4 SPIRV_OVERLOADABLE SPIRV_BUILTIN(ImageRead, _v4f32_img2d_array_##ACC_QUAL##_v4i32, _Rfloat4)(global Img2d_array_##ACC_QUAL* Image, int4 Coordinate) \
{ \
return __spirv_ImageRead_Rfloat4(Image, Coordinate.xyz); \
} \
float4 SPIRV_OVERLOADABLE SPIRV_BUILTIN(ImageRead, _v4f32_img2d_array_##ACC_QUAL##_v4i32_i32, _Rfloat4)(global Img2d_array_##ACC_QUAL* Image, int4 Coordinate, int ImageOperands) \
{ \
return SPIRV_BUILTIN(ImageRead, _v4f32_img2d_array_##ACC_QUAL##_v4i32, _Rfloat4)(Image, Coordinate); \
}
#define DEF_IMAGE_READ_1D(ACC_QUAL) \
uint4 OVERLOADABLE __spirv_ImageRead_Ruint4(global Img1d_##ACC_QUAL* Image, int Coordinate) \
{ \
int id = (int)__builtin_astype(Image, __global void*); \
return __builtin_IB_OCL_1d_ldui( id, Coordinate, 0); \
} \
uint4 OVERLOADABLE __spirv_ImageRead_Ruint4(global Img1d_##ACC_QUAL* Image, int Coordinate, int ImageOperands) \
{ \
return __spirv_ImageRead_Ruint4(Image, Coordinate); \
} \
int4 SPIRV_OVERLOADABLE SPIRV_BUILTIN(ImageRead, _v4i32_img1d_##ACC_QUAL##_i32, _Rint4)(global Img1d_##ACC_QUAL* Image, int Coordinate) \
{ \
uint4 res = __spirv_ImageRead_Ruint4(Image, Coordinate); \
return as_int4(res); \
} \
int4 SPIRV_OVERLOADABLE SPIRV_BUILTIN(ImageRead, _v4i32_img1d_##ACC_QUAL##_i32_i32, _Rint4)(global Img1d_##ACC_QUAL* Image, int Coordinate, int ImageOperands) \
{ \
return SPIRV_BUILTIN(ImageRead, _v4i32_img1d_##ACC_QUAL##_i32, _Rint4)(Image, Coordinate); \
} \
float4 SPIRV_OVERLOADABLE SPIRV_BUILTIN(ImageRead, _v4f32_img1d_##ACC_QUAL##_i32, _Rfloat4)(global Img1d_##ACC_QUAL* Image, int Coordinate) \
{ \
int id = (int)__builtin_astype(Image, __global void*); \
float4 res = __builtin_IB_OCL_1d_ld(id, Coordinate, 0); \
return __flush_denormals(res); \
} \
float4 SPIRV_OVERLOADABLE SPIRV_BUILTIN(ImageRead, _v4f32_img1d_##ACC_QUAL##_i32_i32, _Rfloat4)(global Img1d_##ACC_QUAL* Image, int Coordinate, int ImageOperands) \
{ \
return SPIRV_BUILTIN(ImageRead, _v4f32_img1d_##ACC_QUAL##_i32, _Rfloat4)(Image, Coordinate); \
}
#define DEF_IMAGE_READ_1D_BUFFER(ACC_QUAL) \
uint4 OVERLOADABLE __spirv_ImageRead_Ruint4(global Img1d_buffer_##ACC_QUAL* Image, int Coordinate) \
{ \
int id = (int)__builtin_astype(Image, __global void*); \
return __builtin_IB_OCL_1d_ldui( id, Coordinate, 0); \
} \
uint4 OVERLOADABLE __spirv_ImageRead_Ruint4(global Img1d_buffer_##ACC_QUAL* Image, int Coordinate, int ImageOperands) \
{ \
return __spirv_ImageRead_Ruint4(Image, Coordinate); \
} \
int4 SPIRV_OVERLOADABLE SPIRV_BUILTIN(ImageRead, _v4i32_img1d_buffer_##ACC_QUAL##_i32, _Rint4)(global Img1d_buffer_##ACC_QUAL* Image, int Coordinate) \
{ \
uint4 res = __spirv_ImageRead_Ruint4(Image, Coordinate); \
return as_int4(res); \
} \
int4 SPIRV_OVERLOADABLE SPIRV_BUILTIN(ImageRead, _v4i32_img1d_buffer_##ACC_QUAL##_i32_i32, _Rint4)(global Img1d_buffer_##ACC_QUAL* Image, int Coordinate, int ImageOperands) \
{ \
return SPIRV_BUILTIN(ImageRead, _v4i32_img1d_buffer_##ACC_QUAL##_i32, _Rint4)(Image, Coordinate); \
} \
float4 SPIRV_OVERLOADABLE SPIRV_BUILTIN(ImageRead, _v4f32_img1d_buffer_##ACC_QUAL##_i32, _Rfloat4)(global Img1d_buffer_##ACC_QUAL* Image, int Coordinate) \
{ \
int id = (int)__builtin_astype(Image, __global void*); \
float4 res = __builtin_IB_OCL_1d_ld(id, Coordinate, 0); \
return __flush_denormals(res); \
} \
float4 SPIRV_OVERLOADABLE SPIRV_BUILTIN(ImageRead, _v4f32_img1d_buffer_##ACC_QUAL##_i32_i32, _Rfloat4)(global Img1d_buffer_##ACC_QUAL* Image, int Coordinate, int ImageOperands) \
{ \
return SPIRV_BUILTIN(ImageRead, _v4f32_img1d_buffer_##ACC_QUAL##_i32, _Rfloat4)(Image, Coordinate); \
}
#define DEF_IMAGE_READ_1D_ARRAY(ACC_QUAL) \
uint4 OVERLOADABLE __spirv_ImageRead_Ruint4(global Img1d_array_##ACC_QUAL* Image, int2 Coordinate) \
{ \
int id = (int)__builtin_astype(Image, __global void*); \
return __builtin_IB_OCL_1darr_ldui( id, Coordinate, 0); \
} \
uint4 OVERLOADABLE __spirv_ImageRead_Ruint4(global Img1d_array_##ACC_QUAL* Image, int2 Coordinate, int ImageOperands) \
{ \
return __spirv_ImageRead_Ruint4(Image, Coordinate); \
} \
int4 SPIRV_OVERLOADABLE SPIRV_BUILTIN(ImageRead, _v4i32_img1d_array_##ACC_QUAL##_v2i32, _Rint4)(global Img1d_array_##ACC_QUAL* Image, int2 Coordinate) \
{ \
uint4 res = __spirv_ImageRead_Ruint4(Image, Coordinate); \
return as_int4(res); \
} \
int4 SPIRV_OVERLOADABLE SPIRV_BUILTIN(ImageRead, _v4i32_img1d_array_##ACC_QUAL##_v2i32_i32, _Rint4)(global Img1d_array_##ACC_QUAL* Image, int2 Coordinate, int ImageOperands) \
{ \
return SPIRV_BUILTIN(ImageRead, _v4i32_img1d_array_##ACC_QUAL##_v2i32, _Rint4)(Image, Coordinate); \
} \
float4 SPIRV_OVERLOADABLE SPIRV_BUILTIN(ImageRead, _v4f32_img1d_array_##ACC_QUAL##_v2i32, _Rfloat4)(global Img1d_array_##ACC_QUAL* Image, int2 Coordinate) \
{ \
int id = (int)__builtin_astype(Image, __global void*); \
float4 res = __builtin_IB_OCL_1darr_ld(id, Coordinate, 0); \
return __flush_denormals(res); \
} \
float4 SPIRV_OVERLOADABLE SPIRV_BUILTIN(ImageRead, _v4f32_img1d_array_##ACC_QUAL##_v2i32_i32, _Rfloat4)(global Img1d_array_##ACC_QUAL* Image, int2 Coordinate, int ImageOprands) \
{ \
return SPIRV_BUILTIN(ImageRead, _v4f32_img1d_array_##ACC_QUAL##_v2i32, _Rfloat4)(Image, Coordinate); \
}
#define DEF_IMAGE_READ_2D_DEPTH(ACC_QUAL) \
float SPIRV_OVERLOADABLE SPIRV_BUILTIN(ImageRead, _f32_img2d_depth_##ACC_QUAL##_v2i32, _Rfloat)(global Img2d_depth_##ACC_QUAL* Image, int2 Coordinate) \
{ \
int id = (int)__builtin_astype(Image, __global void*); \
float4 res = __builtin_IB_OCL_2d_ld(id, Coordinate, 0); \
return __flush_denormals(res).x; \
}
#define DEF_IMAGE_READ_2D_ARRAY_DEPTH(ACC_QUAL) \
float SPIRV_OVERLOADABLE SPIRV_BUILTIN(ImageRead, _f32_img2d_array_depth_##ACC_QUAL##_v4i32, _Rfloat)(global Img2d_array_depth_##ACC_QUAL* Image, int4 Coordinate) \
{ \
int id = (int)__builtin_astype(Image, __global void*); \
float4 res = __builtin_IB_OCL_2darr_ld(id, Coordinate.xyz, 0); \
return __flush_denormals(res).x; \
}
DEF_IMAGE_READ_2D(ro)
DEF_IMAGE_READ_2D(rw)
DEF_IMAGE_READ_3D(ro)
DEF_IMAGE_READ_3D(rw)
DEF_IMAGE_READ_2D_ARRAY(ro)
DEF_IMAGE_READ_2D_ARRAY(rw)
DEF_IMAGE_READ_1D(ro)
DEF_IMAGE_READ_1D(rw)
DEF_IMAGE_READ_1D_BUFFER(ro)
DEF_IMAGE_READ_1D_BUFFER(rw)
DEF_IMAGE_READ_1D_ARRAY(ro)
DEF_IMAGE_READ_1D_ARRAY(rw)
DEF_IMAGE_READ_2D_DEPTH(ro)
DEF_IMAGE_READ_2D_DEPTH(rw)
DEF_IMAGE_READ_2D_ARRAY_DEPTH(ro)
DEF_IMAGE_READ_2D_ARRAY_DEPTH(rw)
#ifdef cl_khr_fp16
#define DEF_HALF_IMAGE_READ(IMAGE_TYPE, COORDS_TYPE, COORDS_TYPE_ABBR) \
half4 SPIRV_OVERLOADABLE SPIRV_BUILTIN(ImageRead, _v4f16_img##IMAGE_TYPE##_##COORDS_TYPE_ABBR, _Rhalf4)(global Img##IMAGE_TYPE* Image, COORDS_TYPE Coordinate) \
{ \
return SPIRV_BUILTIN(FConvert, _v4f16_v4f32, _Rhalf4)(SPIRV_BUILTIN(ImageRead, _v4f32_img##IMAGE_TYPE##_##COORDS_TYPE_ABBR, _Rfloat4)(Image, Coordinate)); \
}
DEF_HALF_IMAGE_READ(2d_ro, int2, v2i32)
DEF_HALF_IMAGE_READ(2d_rw, int2, v2i32)
DEF_HALF_IMAGE_READ(3d_ro, int4, v4i32)
DEF_HALF_IMAGE_READ(3d_rw, int4, v4i32)
DEF_HALF_IMAGE_READ(2d_array_ro, int4, v4i32)
DEF_HALF_IMAGE_READ(2d_array_rw, int4, v4i32)
DEF_HALF_IMAGE_READ(1d_ro, int, i32)
DEF_HALF_IMAGE_READ(1d_rw, int, i32)
DEF_HALF_IMAGE_READ(1d_buffer_ro, int, i32)
DEF_HALF_IMAGE_READ(1d_buffer_rw, int, i32)
DEF_HALF_IMAGE_READ(1d_array_ro, int2, v2i32)
DEF_HALF_IMAGE_READ(1d_array_rw, int2, v2i32)
#define DEF_HALF_IMAGE_READ_COORD3(IMAGE_TYPE) \
half4 OVERLOADABLE __spirv_ImageRead_Rhalf4(global Img##IMAGE_TYPE* Image, int3 Coordinate) \
{ \
return SPIRV_BUILTIN(FConvert, _v4f16_v4f32, _Rhalf4)(__spirv_ImageRead_Rfloat4(Image, Coordinate)); \
}
DEF_HALF_IMAGE_READ_COORD3(2d_array_ro)
DEF_HALF_IMAGE_READ_COORD3(2d_array_rw)
DEF_HALF_IMAGE_READ_COORD3(3d_ro)
DEF_HALF_IMAGE_READ_COORD3(3d_rw)
#endif // cl_khr_fp16
// Image Read SYCL Bindless Unsampled
#define DEF_SYCL_BINDLESS_UNSAMPLED_IMAGE_READ_TY(DIM, ARRAY_ACC_QUAL, COORD_DIM, TY) \
TY OVERLOADABLE __spirv_ImageRead_R##TY(global Img##DIM##d_##ARRAY_ACC_QUAL* Image, int##COORD_DIM Coordinate) \
{ \
return __spirv_ImageRead_R##TY##4(Image, Coordinate).x; \
} \
TY OVERLOADABLE __spirv_ImageRead_R##TY(global Img##DIM##d_##ARRAY_ACC_QUAL* Image, int##COORD_DIM Coordinate, int ImageOperands) \
{ \
return __spirv_ImageRead_R##TY(Image, Coordinate); \
} \
TY##2 OVERLOADABLE __spirv_ImageRead_R##TY##2(global Img##DIM##d_##ARRAY_ACC_QUAL* Image, int##COORD_DIM Coordinate) \
{ \
return __spirv_ImageRead_R##TY##4(Image, Coordinate).xy; \
} \
TY##2 OVERLOADABLE __spirv_ImageRead_R##TY##2(global Img##DIM##d_##ARRAY_ACC_QUAL* Image, int##COORD_DIM Coordinate, int ImageOperands) \
{ \
return __spirv_ImageRead_R##TY##2(Image, Coordinate); \
}
#define DEF_SYCL_BINDLESS_UNSAMPLED_IMAGE_READ(DIM, ARRAY_ACC_QUAL, COORD_DIM) \
DEF_SYCL_BINDLESS_UNSAMPLED_IMAGE_READ_TY(DIM, ARRAY_ACC_QUAL, COORD_DIM, int ) \
DEF_SYCL_BINDLESS_UNSAMPLED_IMAGE_READ_TY(DIM, ARRAY_ACC_QUAL, COORD_DIM, uint ) \
DEF_SYCL_BINDLESS_UNSAMPLED_IMAGE_READ_TY(DIM, ARRAY_ACC_QUAL, COORD_DIM, float)
#define DEF_SYCL_BINDLESS_UNSAMPLED_IMAGE_READ_HALF(DIM, ARRAY_ACC_QUAL, COORD_DIM) \
DEF_SYCL_BINDLESS_UNSAMPLED_IMAGE_READ_TY(DIM, ARRAY_ACC_QUAL, COORD_DIM, half ) \
#define DEF_SYCL_BINDLESS_UNSAMPLED_IMAGE_READ_S_C(DIM, ARRAY_ACC_QUAL, COORD_DIM, TY, UNSIGNED) \
TY OVERLOADABLE __spirv_ImageRead_R##TY(global Img##DIM##d_##ARRAY_ACC_QUAL* Image, int##COORD_DIM Coordinate) \
{ \
return convert_##TY(__spirv_ImageRead_R##UNSIGNED##int(Image, Coordinate)); \
} \
TY OVERLOADABLE __spirv_ImageRead_R##TY(global Img##DIM##d_##ARRAY_ACC_QUAL* Image, int##COORD_DIM Coordinate, int ImageOperands) \
{ \
return __spirv_ImageRead_R##TY(Image, Coordinate); \
} \
TY##2 OVERLOADABLE __spirv_ImageRead_R##TY##2(global Img##DIM##d_##ARRAY_ACC_QUAL* Image, int##COORD_DIM Coordinate) \
{ \
return convert_##TY##2(__spirv_ImageRead_R##UNSIGNED##int2(Image, Coordinate)); \
} \
TY##2 OVERLOADABLE __spirv_ImageRead_R##TY##2(global Img##DIM##d_##ARRAY_ACC_QUAL* Image, int##COORD_DIM Coordinate, int ImageOperands) \
{ \
return __spirv_ImageRead_R##TY##2(Image, Coordinate); \
} \
TY##4 OVERLOADABLE __spirv_ImageRead_R##TY##4(global Img##DIM##d_##ARRAY_ACC_QUAL* Image, int##COORD_DIM Coordinate) \
{ \
return convert_##TY##4(__spirv_ImageRead_R##UNSIGNED##int4(Image, Coordinate)); \
} \
TY##4 OVERLOADABLE __spirv_ImageRead_R##TY##4(global Img##DIM##d_##ARRAY_ACC_QUAL* Image, int##COORD_DIM Coordinate, int ImageOperands) \
{ \
return __spirv_ImageRead_R##TY##4(Image, Coordinate); \
}
#define DEF_SYCL_BINDLESS_UNSAMPLED_IMAGE_READ_SC(DIM, ARRAY_ACC_QUAL, COORD_DIM) \
DEF_SYCL_BINDLESS_UNSAMPLED_IMAGE_READ_S_C(DIM, ARRAY_ACC_QUAL, COORD_DIM, short, ) \
DEF_SYCL_BINDLESS_UNSAMPLED_IMAGE_READ_S_C(DIM, ARRAY_ACC_QUAL, COORD_DIM, ushort, u) \
DEF_SYCL_BINDLESS_UNSAMPLED_IMAGE_READ_S_C(DIM, ARRAY_ACC_QUAL, COORD_DIM, char, ) \
DEF_SYCL_BINDLESS_UNSAMPLED_IMAGE_READ_S_C(DIM, ARRAY_ACC_QUAL, COORD_DIM, uchar, u)
#if defined(__USE_KHRONOS_SPIRV_TRANSLATOR__)
DEF_SYCL_BINDLESS_UNSAMPLED_IMAGE_READ(1, ro, )
DEF_SYCL_BINDLESS_UNSAMPLED_IMAGE_READ(1, rw, )
DEF_SYCL_BINDLESS_UNSAMPLED_IMAGE_READ(1, array_ro, 2)
DEF_SYCL_BINDLESS_UNSAMPLED_IMAGE_READ(1, array_rw, 2)
DEF_SYCL_BINDLESS_UNSAMPLED_IMAGE_READ(2, ro, 2)
DEF_SYCL_BINDLESS_UNSAMPLED_IMAGE_READ(2, rw, 2)
DEF_SYCL_BINDLESS_UNSAMPLED_IMAGE_READ(2, array_ro, 3)
DEF_SYCL_BINDLESS_UNSAMPLED_IMAGE_READ(2, array_rw, 3)
DEF_SYCL_BINDLESS_UNSAMPLED_IMAGE_READ(3, ro, 3)
DEF_SYCL_BINDLESS_UNSAMPLED_IMAGE_READ(3, rw, 3)
DEF_SYCL_BINDLESS_UNSAMPLED_IMAGE_READ_SC(1, ro, )
DEF_SYCL_BINDLESS_UNSAMPLED_IMAGE_READ_SC(1, rw, )
DEF_SYCL_BINDLESS_UNSAMPLED_IMAGE_READ_SC(1, array_ro, 2)
DEF_SYCL_BINDLESS_UNSAMPLED_IMAGE_READ_SC(1, array_rw, 2)
DEF_SYCL_BINDLESS_UNSAMPLED_IMAGE_READ_SC(2, ro, 2)
DEF_SYCL_BINDLESS_UNSAMPLED_IMAGE_READ_SC(2, rw, 2)
DEF_SYCL_BINDLESS_UNSAMPLED_IMAGE_READ_SC(2, array_ro, 3)
DEF_SYCL_BINDLESS_UNSAMPLED_IMAGE_READ_SC(2, array_rw, 3)
DEF_SYCL_BINDLESS_UNSAMPLED_IMAGE_READ_SC(3, ro, 3)
DEF_SYCL_BINDLESS_UNSAMPLED_IMAGE_READ_SC(3, rw, 3)
#ifdef cl_khr_fp16
DEF_SYCL_BINDLESS_UNSAMPLED_IMAGE_READ_HALF(1, ro, )
DEF_SYCL_BINDLESS_UNSAMPLED_IMAGE_READ_HALF(1, rw, )
DEF_SYCL_BINDLESS_UNSAMPLED_IMAGE_READ_HALF(1, array_ro, 2)
DEF_SYCL_BINDLESS_UNSAMPLED_IMAGE_READ_HALF(1, array_rw, 2)
DEF_SYCL_BINDLESS_UNSAMPLED_IMAGE_READ_HALF(2, ro, 2)
DEF_SYCL_BINDLESS_UNSAMPLED_IMAGE_READ_HALF(2, rw, 2)
DEF_SYCL_BINDLESS_UNSAMPLED_IMAGE_READ_HALF(2, array_ro, 3)
DEF_SYCL_BINDLESS_UNSAMPLED_IMAGE_READ_HALF(2, array_rw, 3)
DEF_SYCL_BINDLESS_UNSAMPLED_IMAGE_READ_HALF(3, ro, 3)
DEF_SYCL_BINDLESS_UNSAMPLED_IMAGE_READ_HALF(3, rw, 3)
#endif // cl_khr_fp16
#endif // defined(__USE_KHRONOS_SPIRV_TRANSLATOR__)
// Image Read MSAA
int4 SPIRV_OVERLOADABLE SPIRV_BUILTIN(ImageRead, _v4i32_img2d_msaa_ro_v2i32_i32_i32, _Rint4)(global Img2d_msaa_ro* Image, int2 Coordinate, int ImageOperands, int Sample)
{
int id = (int)__builtin_astype(Image, __global void*);
float4 mcs = __builtin_IB_OCL_2d_ldmcs(id, Coordinate);
return as_int4(__builtin_IB_OCL_2d_ld2dmsui(id, Coordinate, Sample, mcs));
}
float4 SPIRV_OVERLOADABLE SPIRV_BUILTIN(ImageRead, _v4f32_img2d_msaa_ro_v2i32_i32_i32, _Rfloat4)(global Img2d_msaa_ro* Image, int2 Coordinate, int ImageOperands, int Sample)
{
int id = (int)__builtin_astype(Image, __global void*);
float4 mcs = __builtin_IB_OCL_2d_ldmcs(id, Coordinate);
float4 res = __builtin_IB_OCL_2d_ld2dms(id, Coordinate, Sample, mcs);
return __flush_denormals(res);
}
int4 SPIRV_OVERLOADABLE SPIRV_BUILTIN(ImageRead, _v4i32_img2d_array_msaa_ro_v4i32_i32_i32, _Rint4)(global Img2d_array_msaa_ro* Image, int4 Coordinate, int ImageOperands, int Sample)
{
int id = (int)__builtin_astype(Image, __global void*);
float4 mcs = __builtin_IB_OCL_2darr_ldmcs(id, Coordinate);
return as_int4(__builtin_IB_OCL_2darr_ld2dmsui(id, Coordinate, Sample, mcs));
}
float4 SPIRV_OVERLOADABLE SPIRV_BUILTIN(ImageRead, _v4f32_img2d_array_msaa_ro_v4i32_i32_i32, _Rfloat4)(global Img2d_array_msaa_ro* Image, int4 Coordinate, int ImageOperands, int Sample)
{
int id = (int)__builtin_astype(Image, __global void*);
float4 mcs = __builtin_IB_OCL_2darr_ldmcs(id, Coordinate);
float4 res = __builtin_IB_OCL_2darr_ld2dms(id, Coordinate, Sample, mcs);
return __flush_denormals(res);
}
float SPIRV_OVERLOADABLE SPIRV_BUILTIN(ImageRead, _f32_img2d_msaa_depth_ro_v2i32_i32_i32, _Rfloat)(global Img2d_msaa_depth_ro* Image, int2 Coordinate, int ImageOperands, int Sample)
{
int id = (int)__builtin_astype(Image, __global void*);
float4 mcs = __builtin_IB_OCL_2d_ldmcs(id, Coordinate);
float4 res = __builtin_IB_OCL_2d_ld2dms(id, Coordinate, Sample, mcs);
return __flush_denormals(res).x;
}
float SPIRV_OVERLOADABLE SPIRV_BUILTIN(ImageRead, _f32_img2d_array_msaa_depth_ro_v4i32_i32_i32, _Rfloat)(global Img2d_array_msaa_depth_ro* Image, int4 Coordinate, int ImageOperands, int Sample)
{
int id = (int)__builtin_astype(Image, __global void*);
float4 mcs = __builtin_IB_OCL_2darr_ldmcs(id, Coordinate);
float4 res = __builtin_IB_OCL_2darr_ld2dms(id, Coordinate, Sample, mcs);
return __flush_denormals(res).x;
}
// Image Write
#define DEF_IMAGE_WRITE_2D(ACC_QUAL) \
void OVERLOADABLE __spirv_ImageWrite(global Img2d_##ACC_QUAL* Image, int2 Coordinate, uint Texel) \
{ \
int id = (int)__builtin_astype(Image, __global void*); \
__builtin_IB_write_2d_u1i(id, Coordinate, Texel, 0); \
} \
void OVERLOADABLE __spirv_ImageWrite(global Img2d_##ACC_QUAL* Image, int2 Coordinate, uint2 Texel) \
{ \
int id = (int)__builtin_astype(Image, __global void*); \
__builtin_IB_write_2d_u2i(id, Coordinate, Texel, 0); \
} \
void OVERLOADABLE __spirv_ImageWrite(global Img2d_##ACC_QUAL* Image, int2 Coordinate, uint4 Texel) \
{ \
int id = (int)__builtin_astype(Image, __global void*); \
__builtin_IB_write_2d_u4i(id, Coordinate, Texel, 0); \
} \
void SPIRV_OVERLOADABLE SPIRV_BUILTIN(ImageWrite, _img2d_##ACC_QUAL##_v2i32_v4i32, )(global Img2d_##ACC_QUAL* Image, int2 Coordinate, int4 Texel) \
{ \
__spirv_ImageWrite(Image, Coordinate, as_uint4(Texel)); \
} \
void SPIRV_OVERLOADABLE SPIRV_BUILTIN(ImageWrite, _img2d_##ACC_QUAL##_v2i32_v4f32, )(global Img2d_##ACC_QUAL* Image, int2 Coordinate, float4 Texel) \
{ \
__spirv_ImageWrite(Image, Coordinate, as_uint4(Texel)); \
} \
void OVERLOADABLE __spirv_ImageWrite(global Img2d_##ACC_QUAL* Image, int2 Coordinate, uint4 Texel, int ImageOperands) \
{ \
__spirv_ImageWrite(Image, Coordinate, Texel); \
} \
void SPIRV_OVERLOADABLE SPIRV_BUILTIN(ImageWrite, _img2d_##ACC_QUAL##_v2i32_v4i32_i32, )(global Img2d_##ACC_QUAL* Image, int2 Coordinate, int4 Texel, int ImageOperands) \
{ \
SPIRV_BUILTIN(ImageWrite, _img2d_##ACC_QUAL##_v2i32_v4i32, )(Image, Coordinate, Texel); \
} \
void SPIRV_OVERLOADABLE SPIRV_BUILTIN(ImageWrite, _img2d_##ACC_QUAL##_v2i32_v4f32_i32, )(global Img2d_##ACC_QUAL* Image, int2 Coordinate, float4 Texel, int ImageOperands) \
{ \
SPIRV_BUILTIN(ImageWrite, _img2d_##ACC_QUAL##_v2i32_v4f32, )(Image, Coordinate, Texel); \
}
#define DEF_IMAGE_WRITE_2D_ARRAY(ACC_QUAL) \
void OVERLOADABLE __spirv_ImageWrite(global Img2d_array_##ACC_QUAL* Image, int3 Coordinate, uint Texel) \
{ \
int id = (int)__builtin_astype(Image, __global void*); \
__builtin_IB_write_2darr_u1i(id, Coordinate, Texel, 0); \
} \
void OVERLOADABLE __spirv_ImageWrite(global Img2d_array_##ACC_QUAL* Image, int3 Coordinate, uint2 Texel) \
{ \
int id = (int)__builtin_astype(Image, __global void*); \
__builtin_IB_write_2darr_u2i(id, Coordinate, Texel, 0); \
} \
void OVERLOADABLE __spirv_ImageWrite(global Img2d_array_##ACC_QUAL* Image, int3 Coordinate, uint4 Texel) \
{ \
int id = (int)__builtin_astype(Image, __global void*); \
__builtin_IB_write_2darr_u4i(id, Coordinate, Texel, 0); \
} \
void OVERLOADABLE __spirv_ImageWrite(global Img2d_array_##ACC_QUAL* Image, int4 Coordinate, uint4 Texel) \
{ \
__spirv_ImageWrite(Image, Coordinate.xyz, Texel); \
} \
void OVERLOADABLE __spirv_ImageWrite(global Img2d_array_##ACC_QUAL* Image, int3 Coordinate, int4 Texel) \
{ \
__spirv_ImageWrite(Image, Coordinate, as_uint4(Texel)); \
} \
void SPIRV_OVERLOADABLE SPIRV_BUILTIN(ImageWrite, _img2d_array_##ACC_QUAL##_v4i32_v4i32, )(global Img2d_array_##ACC_QUAL* Image, int4 Coordinate, int4 Texel) \
{ \
__spirv_ImageWrite(Image, Coordinate.xyz, Texel); \
} \
void OVERLOADABLE __spirv_ImageWrite(global Img2d_array_##ACC_QUAL* Image, int3 Coordinate, float4 Texel) \
{ \
__spirv_ImageWrite(Image, Coordinate, as_uint4(Texel)); \
} \
void SPIRV_OVERLOADABLE SPIRV_BUILTIN(ImageWrite, _img2d_array_##ACC_QUAL##_v4i32_v4f32, )(global Img2d_array_##ACC_QUAL* Image, int4 Coordinate, float4 Texel) \
{ \
__spirv_ImageWrite(Image, Coordinate.xyz, Texel); \
} \
void OVERLOADABLE __spirv_ImageWrite(global Img2d_array_##ACC_QUAL* Image, int3 Coordinate, uint4 Texel, int ImageOperands) \
{ \
__spirv_ImageWrite(Image, Coordinate, Texel); \
} \
void OVERLOADABLE __spirv_ImageWrite(global Img2d_array_##ACC_QUAL* Image, int4 Coordinate, uint4 Texel, int ImageOperands) \
{ \
__spirv_ImageWrite(Image, Coordinate, Texel); \
} \
void OVERLOADABLE __spirv_ImageWrite(global Img2d_array_##ACC_QUAL* Image, int3 Coordinate, int4 Texel, int ImageOperands) \
{ \
__spirv_ImageWrite(Image, Coordinate, Texel); \
} \
void SPIRV_OVERLOADABLE SPIRV_BUILTIN(ImageWrite, _img2d_array_##ACC_QUAL##_v4i32_v4i32_i32, )(global Img2d_array_##ACC_QUAL* Image, int4 Coordinate, int4 Texel, int ImageOperands) \
{ \
SPIRV_BUILTIN(ImageWrite, _img2d_array_##ACC_QUAL##_v4i32_v4i32, )(Image, Coordinate, Texel); \
} \
void OVERLOADABLE __spirv_ImageWrite(global Img2d_array_##ACC_QUAL* Image, int3 Coordinate, float4 Texel, int ImageOperands) \
{ \
__spirv_ImageWrite(Image, Coordinate, Texel); \
} \
void SPIRV_OVERLOADABLE SPIRV_BUILTIN(ImageWrite, _img2d_array_##ACC_QUAL##_v4i32_v4f32_i32, )(global Img2d_array_##ACC_QUAL* Image, int4 Coordinate, float4 Texel, int ImageOperands) \
{ \
SPIRV_BUILTIN(ImageWrite, _img2d_array_##ACC_QUAL##_v4i32_v4f32, )(Image, Coordinate, Texel); \
}
#define DEF_IMAGE_WRITE_1D(ACC_QUAL) \
void OVERLOADABLE __spirv_ImageWrite(global Img1d_##ACC_QUAL* Image, int Coordinate, uint Texel) \
{ \
int id = (int)__builtin_astype(Image, __global void*); \
__builtin_IB_write_1d_u1i(id, Coordinate, Texel, 0); \
} \
void OVERLOADABLE __spirv_ImageWrite(global Img1d_##ACC_QUAL* Image, int Coordinate, uint2 Texel) \
{ \
int id = (int)__builtin_astype(Image, __global void*); \
__builtin_IB_write_1d_u2i(id, Coordinate, Texel, 0); \
} \
void OVERLOADABLE __spirv_ImageWrite(global Img1d_##ACC_QUAL* Image, int Coordinate, uint4 Texel) \
{ \
int id = (int)__builtin_astype(Image, __global void*); \
__builtin_IB_write_1d_u4i(id, Coordinate, Texel, 0); \
} \
void SPIRV_OVERLOADABLE SPIRV_BUILTIN(ImageWrite, _img1d_##ACC_QUAL##_i32_v4i32, )(global Img1d_##ACC_QUAL* Image, int Coordinate, int4 Texel) \
{ \
__spirv_ImageWrite(Image, Coordinate, as_uint4(Texel)); \
} \
void SPIRV_OVERLOADABLE SPIRV_BUILTIN(ImageWrite, _img1d_##ACC_QUAL##_i32_v4f32, )(global Img1d_##ACC_QUAL* Image, int Coordinate, float4 Texel) \
{ \
__spirv_ImageWrite(Image, Coordinate, as_uint4(Texel)); \
} \
void OVERLOADABLE __spirv_ImageWrite(global Img1d_##ACC_QUAL* Image, int Coordinate, uint4 Texel, int ImageOperands) \
{ \
__spirv_ImageWrite(Image, Coordinate, Texel); \
} \
void SPIRV_OVERLOADABLE SPIRV_BUILTIN(ImageWrite, _img1d_##ACC_QUAL##_i32_v4i32_i32, )(global Img1d_##ACC_QUAL* Image, int Coordinate, int4 Texel, int ImageOperands) \
{ \
SPIRV_BUILTIN(ImageWrite, _img1d_##ACC_QUAL##_i32_v4i32, )(Image, Coordinate, Texel); \
} \
void SPIRV_OVERLOADABLE SPIRV_BUILTIN(ImageWrite, _img1d_##ACC_QUAL##_i32_v4f32_i32, )(global Img1d_##ACC_QUAL* Image, int Coordinate, float4 Texel, int ImageOperands) \
{ \
SPIRV_BUILTIN(ImageWrite, _img1d_##ACC_QUAL##_i32_v4f32, )(Image, Coordinate, Texel); \
}
#define DEF_IMAGE_WRITE_1D_BUFFER(ACC_QUAL) \
void OVERLOADABLE __spirv_ImageWrite(global Img1d_buffer_##ACC_QUAL* Image, int Coordinate, uint4 Texel) \
{ \
int id = (int)__builtin_astype(Image, __global void*); \
__builtin_IB_write_1d_u4i(id, Coordinate, Texel, 0); \
} \
void SPIRV_OVERLOADABLE SPIRV_BUILTIN(ImageWrite, _img1d_buffer_##ACC_QUAL##_i32_v4i32, )(global Img1d_buffer_##ACC_QUAL* Image, int Coordinate, int4 Texel) \
{ \
__spirv_ImageWrite(Image, Coordinate, as_uint4(Texel)); \
} \
void SPIRV_OVERLOADABLE SPIRV_BUILTIN(ImageWrite, _img1d_buffer_##ACC_QUAL##_i32_v4f32, )(global Img1d_buffer_##ACC_QUAL* Image, int Coordinate, float4 Texel) \
{ \
__spirv_ImageWrite(Image, Coordinate, as_uint4(Texel)); \
} \
void OVERLOADABLE __spirv_ImageWrite(global Img1d_buffer_##ACC_QUAL* Image, int Coordinate, uint4 Texel, int ImageOperands) \
{ \
__spirv_ImageWrite(Image, Coordinate, Texel); \
} \
void SPIRV_OVERLOADABLE SPIRV_BUILTIN(ImageWrite, _img1d_buffer_##ACC_QUAL##_i32_v4i32_i32, )(global Img1d_buffer_##ACC_QUAL* Image, int Coordinate, int4 Texel, int ImageOperands) \
{ \
SPIRV_BUILTIN(ImageWrite, _img1d_buffer_##ACC_QUAL##_i32_v4i32, )(Image, Coordinate, Texel); \
} \
void SPIRV_OVERLOADABLE SPIRV_BUILTIN(ImageWrite, _img1d_buffer_##ACC_QUAL##_i32_v4f32_i32, )(global Img1d_buffer_##ACC_QUAL* Image, int Coordinate, float4 Texel, int ImageOperands) \
{ \
SPIRV_BUILTIN(ImageWrite, _img1d_buffer_##ACC_QUAL##_i32_v4f32, )(Image, Coordinate, Texel); \
}
#define DEF_IMAGE_WRITE_1D_ARRAY(ACC_QUAL) \
void OVERLOADABLE __spirv_ImageWrite(global Img1d_array_##ACC_QUAL* Image, int2 Coordinate, uint Texel) \
{ \
int id = (int)__builtin_astype(Image, __global void*); \
__builtin_IB_write_1darr_u1i(id, Coordinate, Texel, 0); \
} \
void OVERLOADABLE __spirv_ImageWrite(global Img1d_array_##ACC_QUAL* Image, int2 Coordinate, uint2 Texel) \
{ \
int id = (int)__builtin_astype(Image, __global void*); \
__builtin_IB_write_1darr_u2i(id, Coordinate, Texel, 0); \
} \
void OVERLOADABLE __spirv_ImageWrite(global Img1d_array_##ACC_QUAL* Image, int2 Coordinate, uint4 Texel) \
{ \
int id = (int)__builtin_astype(Image, __global void*); \
__builtin_IB_write_1darr_u4i(id, Coordinate, Texel, 0); \
} \
void SPIRV_OVERLOADABLE SPIRV_BUILTIN(ImageWrite, _img1d_array_##ACC_QUAL##_v2i32_v4i32, )(global Img1d_array_##ACC_QUAL* Image, int2 Coordinate, int4 Texel) \
{ \
__spirv_ImageWrite(Image, Coordinate, as_uint4(Texel)); \
} \
void SPIRV_OVERLOADABLE SPIRV_BUILTIN(ImageWrite, _img1d_array_##ACC_QUAL##_v2i32_v4f32, )(global Img1d_array_##ACC_QUAL* Image, int2 Coordinate, float4 Texel) \
{ \
__spirv_ImageWrite(Image, Coordinate, as_uint4(Texel)); \
} \
void OVERLOADABLE __spirv_ImageWrite(global Img1d_array_##ACC_QUAL* Image, int2 Coordinate, uint4 Texel, int ImageOperands) \
{ \
__spirv_ImageWrite(Image, Coordinate, Texel); \
} \
void SPIRV_OVERLOADABLE SPIRV_BUILTIN(ImageWrite, _img1d_array_##ACC_QUAL##_v2i32_v4i32_i32, )(global Img1d_array_##ACC_QUAL* Image, int2 Coordinate, int4 Texel, int ImageOperands) \
{ \
SPIRV_BUILTIN(ImageWrite, _img1d_array_##ACC_QUAL##_v2i32_v4i32, )(Image, Coordinate, Texel); \
} \
void SPIRV_OVERLOADABLE SPIRV_BUILTIN(ImageWrite, _img1d_array_##ACC_QUAL##_v2i32_v4f32_i32, )(global Img1d_array_##ACC_QUAL* Image, int2 Coordinate, float4 Texel, int ImageOperands) \
{ \
SPIRV_BUILTIN(ImageWrite, _img1d_array_##ACC_QUAL##_v2i32_v4f32, )(Image, Coordinate, Texel); \
}
#define DEF_IMAGE_WRITE_2D_DEPTH(ACC_QUAL) \
void SPIRV_OVERLOADABLE SPIRV_BUILTIN(ImageWrite, _img2d_depth_##ACC_QUAL##_v2i32_f32, )(global Img2d_depth_##ACC_QUAL * Image, int2 Coordinate, float Texel) \
{ \
int id = (int)__builtin_astype(Image, __global void*); \
__builtin_IB_write_2d_u4i(id, Coordinate, (uint4)(as_uint(Texel), 0, 0, 0), 0); \
} \
void SPIRV_OVERLOADABLE SPIRV_BUILTIN(ImageWrite, _img2d_depth_##ACC_QUAL##_v2i32_f32_i32, )(global Img2d_depth_##ACC_QUAL * Image, int2 Coordinate, float Texel, int ImageOperands) \
{ \
SPIRV_BUILTIN(ImageWrite, _img2d_depth_##ACC_QUAL##_v2i32_f32, )(Image, Coordinate, Texel); \
}
#define DEF_IMAGE_WRITE_2D_ARRAY_DEPTH(ACC_QUAL) \
void SPIRV_OVERLOADABLE SPIRV_BUILTIN(ImageWrite, _img2d_array_depth_##ACC_QUAL##_v4i32_f32, )(global Img2d_array_depth_##ACC_QUAL * Image, int4 Coordinate, float Texel) \
{ \
int id = (int)__builtin_astype(Image, __global void*); \
__builtin_IB_write_2darr_u4i(id, Coordinate.xyz, (uint4)(as_uint(Texel), 0, 0, 0), 0); \
} \
void SPIRV_OVERLOADABLE SPIRV_BUILTIN(ImageWrite, _img2d_array_depth_##ACC_QUAL##_v4i32_f32_i32, )(global Img2d_array_depth_##ACC_QUAL * Image, int4 Coordinate, float Texel, int ImageOperands) \
{ \
SPIRV_BUILTIN(ImageWrite, _img2d_array_depth_##ACC_QUAL##_v4i32_f32, )(Image, Coordinate, Texel); \
}
#define DEF_IMAGE_WRITE_3D(ACC_QUAL) \
void OVERLOADABLE __spirv_ImageWrite(global Img3d_##ACC_QUAL* Image, int3 Coordinate, uint Texel) \
{ \
int id = (int)__builtin_astype(Image, __global void*); \
__builtin_IB_write_3d_u1i(id, Coordinate, Texel, 0); \
} \
void OVERLOADABLE __spirv_ImageWrite(global Img3d_##ACC_QUAL* Image, int3 Coordinate, uint2 Texel) \
{ \
int id = (int)__builtin_astype(Image, __global void*); \
__builtin_IB_write_3d_u2i(id, Coordinate, Texel, 0); \
} \
void OVERLOADABLE __spirv_ImageWrite(global Img3d_##ACC_QUAL* Image, int3 Coordinate, uint4 Texel) \
{ \
int id = (int)__builtin_astype(Image, __global void*); \
__builtin_IB_write_3d_u4i(id, Coordinate, Texel, 0); \
} \
void OVERLOADABLE __spirv_ImageWrite(global Img3d_##ACC_QUAL* Image, int4 Coordinate, uint4 Texel) \
{ \
__spirv_ImageWrite(Image, Coordinate.xyz, Texel); \
} \
void OVERLOADABLE __spirv_ImageWrite(global Img3d_##ACC_QUAL* Image, int3 Coordinate, int4 Texel) \
{ \
__spirv_ImageWrite(Image, Coordinate, as_uint4(Texel)); \
} \
void SPIRV_OVERLOADABLE SPIRV_BUILTIN(ImageWrite, _img3d_##ACC_QUAL##_v4i32_v4i32, )(global Img3d_##ACC_QUAL* Image, int4 Coordinate, int4 Texel) \
{ \
__spirv_ImageWrite(Image, Coordinate, as_uint4(Texel)); \
} \
void OVERLOADABLE __spirv_ImageWrite(global Img3d_##ACC_QUAL* Image, int3 Coordinate, float4 Texel) \
{ \
__spirv_ImageWrite(Image, Coordinate, as_uint4(Texel)); \
} \
void SPIRV_OVERLOADABLE SPIRV_BUILTIN(ImageWrite, _img3d_##ACC_QUAL##_v4i32_v4f32, )(global Img3d_##ACC_QUAL* Image, int4 Coordinate, float4 Texel) \
{ \
__spirv_ImageWrite(Image, Coordinate, as_uint4(Texel)); \
} \
void OVERLOADABLE __spirv_ImageWrite(global Img3d_##ACC_QUAL* Image, int3 Coordinate, uint4 Texel, int ImageOperands) \
{ \
__spirv_ImageWrite(Image, Coordinate, Texel); \
} \
void OVERLOADABLE __spirv_ImageWrite(global Img3d_##ACC_QUAL* Image, int4 Coordinate, uint4 Texel, int ImageOperands) \
{ \
__spirv_ImageWrite(Image, Coordinate, Texel); \
} \
void OVERLOADABLE __spirv_ImageWrite(global Img3d_##ACC_QUAL* Image, int3 Coordinate, int4 Texel, int ImageOperands) \
{ \
__spirv_ImageWrite(Image, Coordinate, Texel); \
} \
void SPIRV_OVERLOADABLE SPIRV_BUILTIN(ImageWrite, _img3d_##ACC_QUAL##_v4i32_v4i32_i32, )(global Img3d_##ACC_QUAL* Image, int4 Coordinate, int4 Texel, int ImageOperands) \
{ \
__spirv_ImageWrite(Image, Coordinate.xyz, Texel); \
} \
void OVERLOADABLE __spirv_ImageWrite(global Img3d_##ACC_QUAL* Image, int3 Coordinate, float4 Texel, int ImageOperands) \
{ \
__spirv_ImageWrite(Image, Coordinate, Texel); \
} \
void SPIRV_OVERLOADABLE SPIRV_BUILTIN(ImageWrite, _img3d_##ACC_QUAL##_v4i32_v4f32_i32, )(global Img3d_##ACC_QUAL* Image, int4 Coordinate, float4 Texel, int ImageOperands) \
{ \
__spirv_ImageWrite(Image, Coordinate.xyz, Texel); \
}
DEF_IMAGE_WRITE_2D(wo)
DEF_IMAGE_WRITE_2D(rw)
DEF_IMAGE_WRITE_2D_ARRAY(wo)
DEF_IMAGE_WRITE_2D_ARRAY(rw)
DEF_IMAGE_WRITE_1D(wo)
DEF_IMAGE_WRITE_1D(rw)
DEF_IMAGE_WRITE_1D_BUFFER(wo)
DEF_IMAGE_WRITE_1D_BUFFER(rw)
DEF_IMAGE_WRITE_1D_ARRAY(wo)
DEF_IMAGE_WRITE_1D_ARRAY(rw)
DEF_IMAGE_WRITE_2D_DEPTH(wo)
DEF_IMAGE_WRITE_2D_DEPTH(rw)
DEF_IMAGE_WRITE_2D_ARRAY_DEPTH(wo)
DEF_IMAGE_WRITE_2D_ARRAY_DEPTH(rw)
DEF_IMAGE_WRITE_3D(wo)
DEF_IMAGE_WRITE_3D(rw)
// Level of details versions
#define DEF_IMAGE_WRITE_LOD(IMAGE_TYPE, IMAGE_TYPE_ABBR, COORDS_TYPE, COORDS_TYPE_ABBR, COORDS_XYZ) \
void OVERLOADABLE __spirv_ImageWrite(global Img##IMAGE_TYPE* Image, COORDS_TYPE Coordinate, uint4 Texel, int ImageOperands, int Lod) \
{ \
int id = (int)__builtin_astype(Image, __global void*); \
__builtin_IB_write_##IMAGE_TYPE_ABBR##_u4i(id, Coordinate COORDS_XYZ, Texel, Lod); \
} \
void SPIRV_OVERLOADABLE SPIRV_BUILTIN(ImageWrite, _img##IMAGE_TYPE##_##COORDS_TYPE_ABBR##_v4i32_i32_i32, )(global Img##IMAGE_TYPE* Image, COORDS_TYPE Coordinate, int4 Texel, int ImageOperands, int Lod) \
{ \
__spirv_ImageWrite(Image, Coordinate, as_uint4(Texel), ImageOperands, Lod); \
} \
void SPIRV_OVERLOADABLE SPIRV_BUILTIN(ImageWrite, _img##IMAGE_TYPE##_##COORDS_TYPE_ABBR##_v4f32_i32_i32, )(global Img##IMAGE_TYPE* Image, COORDS_TYPE Coordinate, float4 Texel, int ImageOperands, int Lod) \
{ \
__spirv_ImageWrite(Image, Coordinate, as_uint4(Texel), ImageOperands, Lod); \
}
DEF_IMAGE_WRITE_LOD(2d_wo, 2d, int2, v2i32, )
DEF_IMAGE_WRITE_LOD(1d_wo, 1d, int, i32, )
DEF_IMAGE_WRITE_LOD(1d_array_wo, 1darr, int2, v2i32, )
DEF_IMAGE_WRITE_LOD(2d_array_wo, 2darr, int3, v3i32, )
DEF_IMAGE_WRITE_LOD(2d_array_wo, 2darr, int4, v4i32, .xyz)
DEF_IMAGE_WRITE_LOD(3d_wo, 3d, int3, v3i32, ) // old_mangling variants are unused. They could be removed when old_mangling is deprecated.
DEF_IMAGE_WRITE_LOD(3d_wo, 3d, int4, v4i32, .xyz)
void SPIRV_OVERLOADABLE SPIRV_BUILTIN(ImageWrite, _img2d_depth_wo_v2i32_f32_i32_i32, )(global Img2d_depth_wo* Image, int2 Coordinate, float Texel, int ImageOperands, int Lod)
{
int id = (int)__builtin_astype(Image, __global void*);
__builtin_IB_write_2d_f(id, Coordinate, Texel, Lod);
}
void SPIRV_OVERLOADABLE SPIRV_BUILTIN(ImageWrite, _img2d_array_depth_wo_v4i32_f32_i32_i32, )(global Img2d_array_depth_wo* Image, int4 Coordinate, float Texel, int ImageOperands, int Lod)
{
int id = (int)__builtin_astype(Image, __global void*);
__builtin_IB_write_2darr_f(id, Coordinate, Texel, Lod);
}
#ifdef cl_khr_fp16
#define DEF_HALF_IMAGE_WRITE(IMAGE_TYPE, COORDS_TYPE, COORDS_TYPE_ABBR) \
void SPIRV_OVERLOADABLE SPIRV_BUILTIN(ImageWrite, _img##IMAGE_TYPE##_##COORDS_TYPE_ABBR##_v4f16, )(global Img##IMAGE_TYPE* Image, COORDS_TYPE Coordinate, half4 Texel) \
{ \
SPIRV_BUILTIN(ImageWrite, _img##IMAGE_TYPE##_##COORDS_TYPE_ABBR##_v4f32, )(Image, Coordinate, SPIRV_BUILTIN(FConvert, _v4f32_v4f16, _Rfloat4)(Texel)); \
} \
void OVERLOADABLE __spirv_ImageWrite(global Img##IMAGE_TYPE* Image, COORDS_TYPE Coordinate, half4 Texel, int ImageOperands) \
{ \
SPIRV_BUILTIN(ImageWrite, _img##IMAGE_TYPE##_##COORDS_TYPE_ABBR##_v4f16, )(Image, Coordinate, Texel); \
}
DEF_HALF_IMAGE_WRITE(2d_wo, int2, v2i32)
DEF_HALF_IMAGE_WRITE(2d_rw, int2, v2i32)
DEF_HALF_IMAGE_WRITE(3d_wo, int4, v4i32)
DEF_HALF_IMAGE_WRITE(3d_rw, int4, v4i32)
DEF_HALF_IMAGE_WRITE(2d_array_wo, int4, v4i32)
DEF_HALF_IMAGE_WRITE(2d_array_rw, int4, v4i32)
DEF_HALF_IMAGE_WRITE(1d_wo, int, i32)
DEF_HALF_IMAGE_WRITE(1d_rw, int, i32)
DEF_HALF_IMAGE_WRITE(1d_buffer_wo, int, i32)
DEF_HALF_IMAGE_WRITE(1d_buffer_rw, int, i32)
DEF_HALF_IMAGE_WRITE(1d_array_wo, int2, v2i32)
DEF_HALF_IMAGE_WRITE(1d_array_rw, int2, v2i32)
#define DEF_HALF_IMAGE_WRITE_COORD3(IMAGE_TYPE) \
void OVERLOADABLE __spirv_ImageWrite(global Img##IMAGE_TYPE* Image, int3 Coordinate, half4 Texel) \
{ \
__spirv_ImageWrite(Image, Coordinate, SPIRV_BUILTIN(FConvert, _v4f32_v4f16, _Rfloat4)(Texel)); \
} \
void OVERLOADABLE __spirv_ImageWrite(global Img##IMAGE_TYPE* Image, int3 Coordinate, half4 Texel, int ImageOperands) \
{ \
__spirv_ImageWrite(Image, Coordinate, Texel); \
}
DEF_HALF_IMAGE_WRITE_COORD3(2d_array_wo)
DEF_HALF_IMAGE_WRITE_COORD3(2d_array_rw)
DEF_HALF_IMAGE_WRITE_COORD3(3d_wo)
DEF_HALF_IMAGE_WRITE_COORD3(3d_rw)
#endif // cl_khr_fp16
// Image Write SYCL Bindless Unsampled
#define DEF_SYCL_BINDLESS_UNSAMPLED_IMAGE_WRITE_TY(DIM, ARRAY_ACC_QUAL, COORD_DIM, TY) \
void OVERLOADABLE __spirv_ImageWrite(global Img##DIM##d_##ARRAY_ACC_QUAL* Image, int##COORD_DIM Coordinate, TY color) \
{ \
__spirv_ImageWrite(Image, Coordinate, as_uint(color)); \
} \
void OVERLOADABLE __spirv_ImageWrite(global Img##DIM##d_##ARRAY_ACC_QUAL* Image, int##COORD_DIM Coordinate, TY color, int ImageOperands) \
{ \
__spirv_ImageWrite(Image, Coordinate, color); \
} \
void OVERLOADABLE __spirv_ImageWrite(global Img##DIM##d_##ARRAY_ACC_QUAL* Image, int##COORD_DIM Coordinate, TY##2 color) \
{ \
__spirv_ImageWrite(Image, Coordinate, as_uint2(color)); \
} \
void OVERLOADABLE __spirv_ImageWrite(global Img##DIM##d_##ARRAY_ACC_QUAL* Image, int##COORD_DIM Coordinate, TY##2 color, int ImageOperands) \
{ \
__spirv_ImageWrite(Image, Coordinate, color); \
}
#define DEF_SYCL_BINDLESS_UNSAMPLED_IMAGE_WRITE_OP(DIM, ARRAY_ACC_QUAL, COORD_DIM, TY) \
void OVERLOADABLE __spirv_ImageWrite(global Img##DIM##d_##ARRAY_ACC_QUAL* Image, int##COORD_DIM Coordinate, TY color, int ImageOperands) \
{ \
__spirv_ImageWrite(Image, Coordinate, color); \
} \
void OVERLOADABLE __spirv_ImageWrite(global Img##DIM##d_##ARRAY_ACC_QUAL* Image, int##COORD_DIM Coordinate, TY##2 color, int ImageOperands) \
{ \
__spirv_ImageWrite(Image, Coordinate, color); \
}
#define DEF_SYCL_BINDLESS_UNSAMPLED_IMAGE_WRITE(DIM, ARRAY_ACC_QUAL, COORD_DIM) \
DEF_SYCL_BINDLESS_UNSAMPLED_IMAGE_WRITE_TY(DIM, ARRAY_ACC_QUAL, COORD_DIM, int) \
DEF_SYCL_BINDLESS_UNSAMPLED_IMAGE_WRITE_TY(DIM, ARRAY_ACC_QUAL, COORD_DIM, float) \
DEF_SYCL_BINDLESS_UNSAMPLED_IMAGE_WRITE_OP(DIM, ARRAY_ACC_QUAL, COORD_DIM, uint)
#define DEF_SYCL_BINDLESS_UNSAMPLED_IMAGE_WRITE_S_C(DIM, ARRAY_ACC_QUAL, COORD_DIM, TY, UNSIGNED) \
void OVERLOADABLE __spirv_ImageWrite(global Img##DIM##d_##ARRAY_ACC_QUAL* Image, int##COORD_DIM Coordinate, TY color) \
{ \
__spirv_ImageWrite(Image, Coordinate, convert_##UNSIGNED##int(color)); \
} \
void OVERLOADABLE __spirv_ImageWrite(global Img##DIM##d_##ARRAY_ACC_QUAL* Image, int##COORD_DIM Coordinate, TY color, int ImageOperands) \
{ \
return __spirv_ImageWrite(Image, Coordinate, color); \
} \
void OVERLOADABLE __spirv_ImageWrite(global Img##DIM##d_##ARRAY_ACC_QUAL* Image, int##COORD_DIM Coordinate, TY##2 color) \
{ \
__spirv_ImageWrite(Image, Coordinate, convert_##UNSIGNED##int2(color)); \
} \
void OVERLOADABLE __spirv_ImageWrite(global Img##DIM##d_##ARRAY_ACC_QUAL* Image, int##COORD_DIM Coordinate, TY##2 color, int ImageOperands) \
{ \
return __spirv_ImageWrite(Image, Coordinate, color); \
} \
void OVERLOADABLE __spirv_ImageWrite(global Img##DIM##d_##ARRAY_ACC_QUAL* Image, int##COORD_DIM Coordinate, TY##4 color) \
{ \
__spirv_ImageWrite(Image, Coordinate, convert_##UNSIGNED##int4(color)); \
} \
void OVERLOADABLE __spirv_ImageWrite(global Img##DIM##d_##ARRAY_ACC_QUAL* Image, int##COORD_DIM Coordinate, TY##4 color, int ImageOperands) \
{ \
return __spirv_ImageWrite(Image, Coordinate, color); \
}
#define DEF_SYCL_BINDLESS_UNSAMPLED_IMAGE_WRITE_SC(DIM, ARRAY_ACC_QUAL, COORD_DIM) \
DEF_SYCL_BINDLESS_UNSAMPLED_IMAGE_WRITE_S_C(DIM, ARRAY_ACC_QUAL, COORD_DIM, short, ) \
DEF_SYCL_BINDLESS_UNSAMPLED_IMAGE_WRITE_S_C(DIM, ARRAY_ACC_QUAL, COORD_DIM, ushort, u) \
DEF_SYCL_BINDLESS_UNSAMPLED_IMAGE_WRITE_S_C(DIM, ARRAY_ACC_QUAL, COORD_DIM, char, ) \
DEF_SYCL_BINDLESS_UNSAMPLED_IMAGE_WRITE_S_C(DIM, ARRAY_ACC_QUAL, COORD_DIM, uchar, u)
#if defined(__USE_KHRONOS_SPIRV_TRANSLATOR__)
DEF_SYCL_BINDLESS_UNSAMPLED_IMAGE_WRITE(1, wo, )
DEF_SYCL_BINDLESS_UNSAMPLED_IMAGE_WRITE(1, rw, )
DEF_SYCL_BINDLESS_UNSAMPLED_IMAGE_WRITE(1, array_wo, 2)
DEF_SYCL_BINDLESS_UNSAMPLED_IMAGE_WRITE(1, array_rw, 2)
DEF_SYCL_BINDLESS_UNSAMPLED_IMAGE_WRITE(2, wo, 2)
DEF_SYCL_BINDLESS_UNSAMPLED_IMAGE_WRITE(2, rw, 2)
DEF_SYCL_BINDLESS_UNSAMPLED_IMAGE_WRITE(2, array_wo, 3)
DEF_SYCL_BINDLESS_UNSAMPLED_IMAGE_WRITE(2, array_rw, 3)
DEF_SYCL_BINDLESS_UNSAMPLED_IMAGE_WRITE(3, wo, 3)
DEF_SYCL_BINDLESS_UNSAMPLED_IMAGE_WRITE(3, rw, 3)
DEF_SYCL_BINDLESS_UNSAMPLED_IMAGE_WRITE_SC(1, wo, )
DEF_SYCL_BINDLESS_UNSAMPLED_IMAGE_WRITE_SC(1, rw, )
DEF_SYCL_BINDLESS_UNSAMPLED_IMAGE_WRITE_SC(1, array_wo, 2)
DEF_SYCL_BINDLESS_UNSAMPLED_IMAGE_WRITE_SC(1, array_rw, 2)
DEF_SYCL_BINDLESS_UNSAMPLED_IMAGE_WRITE_SC(2, wo, 2)
DEF_SYCL_BINDLESS_UNSAMPLED_IMAGE_WRITE_SC(2, rw, 2)
DEF_SYCL_BINDLESS_UNSAMPLED_IMAGE_WRITE_SC(2, array_wo, 3)
DEF_SYCL_BINDLESS_UNSAMPLED_IMAGE_WRITE_SC(2, array_rw, 3)
DEF_SYCL_BINDLESS_UNSAMPLED_IMAGE_WRITE_SC(3, wo, 3)
DEF_SYCL_BINDLESS_UNSAMPLED_IMAGE_WRITE_SC(3, rw, 3)
#ifdef cl_khr_fp16
#define DEF_SYCL_BINDLESS_UNSAMPLED_IMAGE_WRITE_HALF_1_2(DIM, ARRAY_ACC_QUAL, COORD_DIM) \
void OVERLOADABLE __spirv_ImageWrite(global Img##DIM##d_##ARRAY_ACC_QUAL* Image, int##COORD_DIM Coordinate, half Texel) \
{ \
__spirv_ImageWrite(Image, Coordinate, SPIRV_BUILTIN(FConvert, _v1f32_v1f16, _Rfloat)(Texel)); \
} \
void OVERLOADABLE __spirv_ImageWrite(global Img##DIM##d_##ARRAY_ACC_QUAL* Image, int##COORD_DIM Coordinate, half2 Texel) \
{ \
__spirv_ImageWrite(Image, Coordinate, SPIRV_BUILTIN(FConvert, _v2f32_v2f16, _Rfloat2)(Texel)); \
}
#define DEF_SYCL_BINDLESS_UNSAMPLED_IMAGE_WRITE_HALF(DIM, ARRAY_ACC_QUAL, COORD_DIM) \
DEF_SYCL_BINDLESS_UNSAMPLED_IMAGE_WRITE_HALF_1_2(DIM, ARRAY_ACC_QUAL, COORD_DIM) \
DEF_SYCL_BINDLESS_UNSAMPLED_IMAGE_WRITE_OP(DIM, ARRAY_ACC_QUAL, COORD_DIM, half)
DEF_SYCL_BINDLESS_UNSAMPLED_IMAGE_WRITE_HALF(1, wo, )
DEF_SYCL_BINDLESS_UNSAMPLED_IMAGE_WRITE_HALF(1, rw, )
DEF_SYCL_BINDLESS_UNSAMPLED_IMAGE_WRITE_HALF(1, array_wo, 2)
DEF_SYCL_BINDLESS_UNSAMPLED_IMAGE_WRITE_HALF(1, array_rw, 2)
DEF_SYCL_BINDLESS_UNSAMPLED_IMAGE_WRITE_HALF(2, wo, 2)
DEF_SYCL_BINDLESS_UNSAMPLED_IMAGE_WRITE_HALF(2, rw, 2)
DEF_SYCL_BINDLESS_UNSAMPLED_IMAGE_WRITE_HALF(2, array_wo, 3)
DEF_SYCL_BINDLESS_UNSAMPLED_IMAGE_WRITE_HALF(2, array_rw, 3)
DEF_SYCL_BINDLESS_UNSAMPLED_IMAGE_WRITE_HALF(3, wo, 3)
DEF_SYCL_BINDLESS_UNSAMPLED_IMAGE_WRITE_HALF(3, rw, 3)
#endif // cl_khr_fp16
#endif // defined(__USE_KHRONOS_SPIRV_TRANSLATOR__)
// Image Query
// From the SPIR spec. Runtime returns values that match SPIR enum
// values but SPIRV enum values start at 0.
#define CLK_SNORM_INT8 0x10D0
#define CLK_R 0x10B0
// ------------------------OpImageQueryFormat------------------------
// Query the image format of an image created with an Unknown Image Format.
// ------------------------OpImageQueryOrder------------------------
// Query the channel order of an image created with an Unknown Image Format.
#define DEF_IMAGE_QUERY_BUILTINS_BASE(IMAGE_TYPE, ACC_QUAL) \
uint SPIRV_OVERLOADABLE SPIRV_BUILTIN(ImageQueryFormat, _img##IMAGE_TYPE##_##ACC_QUAL, )(global Img##IMAGE_TYPE##_##ACC_QUAL* Image) \
{ \
int id = (int)__builtin_astype(Image, __global void*); \
return __builtin_IB_get_image_channel_data_type(id) - CLK_SNORM_INT8; \
} \
uint SPIRV_OVERLOADABLE SPIRV_BUILTIN(ImageQueryOrder, _img##IMAGE_TYPE##_##ACC_QUAL, )(global Img##IMAGE_TYPE##_##ACC_QUAL* Image) \
{ \
int id = (int)__builtin_astype(Image, __global void*); \
return __builtin_IB_get_image_channel_order( id ) - CLK_R; \
}
#define DEF_IMAGE_QUERY_BUILTINS(IMAGE_TYPE) \
DEF_IMAGE_QUERY_BUILTINS_BASE(IMAGE_TYPE, ro) \
DEF_IMAGE_QUERY_BUILTINS_BASE(IMAGE_TYPE, wo) \
DEF_IMAGE_QUERY_BUILTINS_BASE(IMAGE_TYPE, rw)
DEF_IMAGE_QUERY_BUILTINS(2d)
DEF_IMAGE_QUERY_BUILTINS(3d)
DEF_IMAGE_QUERY_BUILTINS(1d)
DEF_IMAGE_QUERY_BUILTINS(1d_buffer)
DEF_IMAGE_QUERY_BUILTINS(1d_array)
DEF_IMAGE_QUERY_BUILTINS(2d_array)
DEF_IMAGE_QUERY_BUILTINS(2d_depth)
DEF_IMAGE_QUERY_BUILTINS(2d_array_depth)
DEF_IMAGE_QUERY_BUILTINS_BASE(2d_msaa, ro)
DEF_IMAGE_QUERY_BUILTINS_BASE(2d_array_msaa, ro)
DEF_IMAGE_QUERY_BUILTINS_BASE(2d_msaa_depth, ro)
DEF_IMAGE_QUERY_BUILTINS_BASE(2d_array_msaa_depth, ro)
// Query image size helper functions
uint __intel_query_image_size_Ruint(int id)
{
return __builtin_IB_get_image_width(id);
}
uint2 __intel_query_arrayed_image_size_Ruint2(int id)
{
uint width = __builtin_IB_get_image_width(id);
uint elements = __builtin_IB_get_image1d_array_size(id);
return (uint2)(width, elements);
}
uint2 __intel_query_image_size_Ruint2(int id)
{
uint width = __builtin_IB_get_image_width(id);
uint height = __builtin_IB_get_image_height(id);
return (uint2)(width, height);
}
uint3 __intel_query_arrayed_image_size_Ruint3(int id)
{
uint width = __builtin_IB_get_image_width(id);
uint height = __builtin_IB_get_image_height(id);
uint elements = __builtin_IB_get_image2d_array_size(id);
return (uint3)(width, height, elements);
}
uint3 __intel_query_image_size_Ruint3(int id)
{
uint width = __builtin_IB_get_image_width(id);
uint height = __builtin_IB_get_image_height(id);
uint depth = __builtin_IB_get_image_depth(id);
return (uint3)(width, height, depth);
}
// ------------------------OpImageQuerySize------------------------
// Query the dimensions of Image, with no level of detail.
// ------------------------OpImageQuerySizeLod------------------------
// Query the dimensions of Image for mipmap level for Level of Detail.
#define DEF_IMAGE_QUERY_SIZE_BASE(IMAGE_TYPE, INTRINSIC, ACC_QUAL, VEC_SIZE, VEC_SIZE_ABBR) \
int##VEC_SIZE SPIRV_OVERLOADABLE SPIRV_BUILTIN(ImageQuerySize, _##VEC_SIZE_ABBR##i32_img##IMAGE_TYPE##_##ACC_QUAL, _Rint##VEC_SIZE)(global Img##IMAGE_TYPE##_##ACC_QUAL* Image) \
{ \
int id = (int)__builtin_astype(Image, __global void*); \
return as_int##VEC_SIZE(INTRINSIC##_Ruint##VEC_SIZE(id)); \
} \
long##VEC_SIZE SPIRV_OVERLOADABLE SPIRV_BUILTIN(ImageQuerySize, _##VEC_SIZE_ABBR##i64_img##IMAGE_TYPE##_##ACC_QUAL, _Rlong##VEC_SIZE)(global Img##IMAGE_TYPE##_##ACC_QUAL* Image) \
{ \
uint##VEC_SIZE result = as_uint##VEC_SIZE(SPIRV_BUILTIN(ImageQuerySize, _##VEC_SIZE_ABBR##i32_img##IMAGE_TYPE##_##ACC_QUAL, _Rint##VEC_SIZE)(Image)); \
return as_long##VEC_SIZE(SPIRV_BUILTIN(UConvert, _##VEC_SIZE_ABBR##i64_##VEC_SIZE_ABBR##i32, _Rulong##VEC_SIZE)(result)); \
} \
int##VEC_SIZE SPIRV_OVERLOADABLE SPIRV_BUILTIN(ImageQuerySizeLod, _##VEC_SIZE_ABBR##i32_img##IMAGE_TYPE##_##ACC_QUAL##_i32, _Rint##VEC_SIZE)(global Img##IMAGE_TYPE##_##ACC_QUAL* Image, int Lod) \
{ \
return SPIRV_BUILTIN(ImageQuerySize, _##VEC_SIZE_ABBR##i32_img##IMAGE_TYPE##_##ACC_QUAL, _Rint##VEC_SIZE)(Image); \
} \
long##VEC_SIZE SPIRV_OVERLOADABLE SPIRV_BUILTIN(ImageQuerySizeLod, _##VEC_SIZE_ABBR##i64_img##IMAGE_TYPE##_##ACC_QUAL##_i32, _Rlong##VEC_SIZE)(global Img##IMAGE_TYPE##_##ACC_QUAL* Image, int Lod) \
{ \
uint##VEC_SIZE result = as_uint##VEC_SIZE(SPIRV_BUILTIN(ImageQuerySizeLod, _##VEC_SIZE_ABBR##i32_img##IMAGE_TYPE##_##ACC_QUAL##_i32, _Rint##VEC_SIZE)(Image, Lod)); \
return as_long##VEC_SIZE(SPIRV_BUILTIN(UConvert, _##VEC_SIZE_ABBR##i64_##VEC_SIZE_ABBR##i32, _Rulong##VEC_SIZE)(result)); \
}
#define DEF_IMAGE_QUERY_SIZE(IMAGE_TYPE, INTRINSIC, VEC_SIZE, VEC_SIZE_ABBR) \
DEF_IMAGE_QUERY_SIZE_BASE(IMAGE_TYPE, INTRINSIC, ro, VEC_SIZE, VEC_SIZE_ABBR) \
DEF_IMAGE_QUERY_SIZE_BASE(IMAGE_TYPE, INTRINSIC, wo, VEC_SIZE, VEC_SIZE_ABBR) \
DEF_IMAGE_QUERY_SIZE_BASE(IMAGE_TYPE, INTRINSIC, rw, VEC_SIZE, VEC_SIZE_ABBR)
DEF_IMAGE_QUERY_SIZE(1d, __intel_query_image_size, , )
DEF_IMAGE_QUERY_SIZE(1d_buffer, __intel_query_image_size, , )
DEF_IMAGE_QUERY_SIZE(1d_array, __intel_query_arrayed_image_size, 2, v2)
DEF_IMAGE_QUERY_SIZE(2d, __intel_query_image_size, 2, v2)
DEF_IMAGE_QUERY_SIZE(2d_depth, __intel_query_image_size, 2, v2)
DEF_IMAGE_QUERY_SIZE(2d_array, __intel_query_arrayed_image_size, 3, v3)
DEF_IMAGE_QUERY_SIZE(2d_array_depth, __intel_query_arrayed_image_size, 3, v3)
DEF_IMAGE_QUERY_SIZE(3d, __intel_query_image_size, 3, v3)
// MSAA image query size
DEF_IMAGE_QUERY_SIZE_BASE(2d_msaa, __intel_query_image_size, ro, 2, v2)
DEF_IMAGE_QUERY_SIZE_BASE(2d_msaa_depth, __intel_query_image_size, ro, 2, v2)
DEF_IMAGE_QUERY_SIZE_BASE(2d_array_msaa, __intel_query_arrayed_image_size, ro, 3, v3)
DEF_IMAGE_QUERY_SIZE_BASE(2d_array_msaa_depth, __intel_query_arrayed_image_size, ro, 3, v3)
// ------------------------OpImageQueryLevels------------------------
// Query the number of mipmap levels accessible through Image.
#define DEF_IMAGE_QUERY_LEVELS_BASE(IMAGE_TYPE, ACC_QUAL) \
uint SPIRV_OVERLOADABLE SPIRV_BUILTIN(ImageQueryLevels, _img##IMAGE_TYPE##_##ACC_QUAL, )(global Img##IMAGE_TYPE##_##ACC_QUAL* Image) \
{ \
int id = (int)__builtin_astype(Image, __global void*); \
return __builtin_IB_get_image_num_mip_levels(id); \
}
#define DEF_IMAGE_QUERY_LEVELS(IMAGE_TYPE) \
DEF_IMAGE_QUERY_LEVELS_BASE(IMAGE_TYPE, ro) \
DEF_IMAGE_QUERY_LEVELS_BASE(IMAGE_TYPE, wo) \
DEF_IMAGE_QUERY_LEVELS_BASE(IMAGE_TYPE, rw)
DEF_IMAGE_QUERY_LEVELS(1d)
DEF_IMAGE_QUERY_LEVELS(2d)
DEF_IMAGE_QUERY_LEVELS(3d)
DEF_IMAGE_QUERY_LEVELS(1d_array)
DEF_IMAGE_QUERY_LEVELS(2d_array)
DEF_IMAGE_QUERY_LEVELS(2d_depth)
DEF_IMAGE_QUERY_LEVELS(2d_array_depth)
// ------------------------OpImageQuerySamples------------------------
// Query the number of samples available per texel fetch in a multisample image.
#define DEF_IMAGE_QUERY_SAMPLES(IMAGE_TYPE) \
uint SPIRV_OVERLOADABLE SPIRV_BUILTIN(ImageQuerySamples, _img##IMAGE_TYPE##_ro, )(global Img##IMAGE_TYPE##_ro* Image) \
{ \
int id = (int)__builtin_astype(Image, __global void*); \
return __builtin_IB_get_image_num_samples(id); \
}
DEF_IMAGE_QUERY_SAMPLES(2d_msaa)
DEF_IMAGE_QUERY_SAMPLES(2d_array_msaa)
DEF_IMAGE_QUERY_SAMPLES(2d_msaa_depth)
DEF_IMAGE_QUERY_SAMPLES(2d_array_msaa_depth)
|