Knowledge

Standard Portable Intermediate Representation

Source 📝

35: 595:
SPIR-V can be extended by writing extensions to add semantics, or reserving ranges of the token values for the party's use. Vendors can independently add desired semantics to SPIR-V. Additional sets of extended instruction sets can be provided in separate specifications. Multiple sets can be imported
671:
As a format, however, SPIR-V has some limitations for cross-compilation, including the requirement that every SPIR-V module have at least one entry-point symbol. This prevents the format from being easily used for separate compilation, where complex shaders could be assembled by a series of partial
210:
The purposes of SPIR-V are to natively represent the primitives needed by compute and graphics; to separate high-level language from the interface to compute and graphics drivers; to be the distribution form, or distribute fully compiled binaries; to be a fully self-contained specification; and to
620:
The SPIR-V specification states the rules that must be followed to have a valid SPIR-V module. This allows for offline validation. Drivers are not obligated to handle invalid SPIR-V modules. In testing, conformance testing verifies that drivers behave correctly when consuming valid SPIR-V, while
629:
SPIR-V can express calls to functions in a different compilation unit. The standard version of SPIR-V uses this feature for OpenCL compute kernels, but not for shader stages, which the graphical APIs want fully linked into a single SPIR-V module. There are extensions available to allow tools to
647:
SPIR-V has been used to help deal with multiple versions of source-level languages. For example, the multiple versions of OpenGL Shading Language (GLSL) require distribution of multiple versions of shaders, due to implementations that are pegged to a specific older version of GLSL, such as for
638:
A SPIR-V module is used by a client API to support that module's features, which are classified through capabilities, and declared early in the module. A validator can confirm that the module uses only its declared capabilities, and a client API can reject modules that declare unsupported
611:
Graphical shaders use structured control flow in SPIR-V to state how control flow nests. This helps in defining divergence and reconvergence of control flow on parallel execution environments. Specialization reduces the number of variants of a shader that need to be distributed.
587:(SSA) form. Data structures retain high-level hierarchical representation. It is not lossy like previous byte-code or virtual machine-like intermediate representations used for graphical shaders. This allows closer to optimum performance on the target devices. 463:
SPIR-V 1.0 is a new version of SPIR announced in March 2015, and released on November 16, 2015. The SPIR family now includes a true cross-API standard that is fully defined by Khronos with native support for shader and kernel features.
995: 508:
along with Provisional OpenCL 2.2. SPIR-V 1.1 added support for OpenCL C++, initializer/finalizer function execution modes, named barriers, subgroup execution, program scope pipes and pipe storage.
652:
and Apple's OpenGL implementation. One of the notable use cases of SPIR-V is its ability to be used as an interchange format between GLSL versions, using tools maintained by the
451:. The final SPIR 1.2 specification was released at HiPEAC 2014 on January 21, 2014. On August 11, 2014, a provisional specification for SPIR 2.0 was released at 159: 274:
In target platforms, ingesting SPIR-V removes the need to build a high-level language source compiler into device drivers, which reduces driver complexity.
1449: 1020: 943: 918: 447:. A provisional specification for SPIR 1.0 was announced in 2012. On July 22, 2013, a provisional specification SPIR 1.2 was announced at 702: 1162: 1065: 774: 1442: 1212: 1341: 996:"Khronos Group Introduces New Vulkan Hardware Driver API and SPIR-V Intermediate Language Shared by Vulkan and OpenCL 2.1" 833: 596:
without issue, as extended instructions are used by specifying the ID of the set and of the instruction within the set.
784: 1435: 1187: 523:
along with OpenCL 2.2. SPIR-V 1.2 added support for runtime specialization of key tuning parameters in OpenCL 2.2.
444: 315: 309: 114: 1602: 1483: 1087: 672:
compile steps followed by a linking step. This runs counter to the stated goals of some SPIR-V tools such as
243: 685: 267: 247: 227: 66: 1291: 851: 1607: 1047:"SPIRV-LLVM-Translator: A tool and a library for bi-directional translation between SPIR-V and LLVM IR" 579:
SPIR-V is a high-level intermediate language, exchanged in binary form. Functions are represented by a
969: 712: 691: 250:) using SPIRV-Cross, so that these languages can be interconverted. It also has paths to and/or from 1422: 584: 1021:"Khronos Releases OpenCL 2.1 and SPIR-V 1.0 Specifications for Heterogeneous Parallel Programming" 892: 808: 1366: 696: 235: 223: 1134: 538:. SPIR-V 1.3 Added support for subgroup operations and enables enhanced compiler optimizations. 211:
support multiple APIs. It is also used as an intermediate target for cross-compilation tools.
17: 1316: 1237: 717: 470:
Support for ingestion of SPIR-V is incorporated in the core specification of OpenCL 2.1, the
155: 119: 1109:"SPIR - The Industry Open Standard Intermediate Language for Parallel Compute and Graphics" 8: 944:"Khronos Releases SPIR 1.2 Specification for Portable Encoding of OpenCL Device Programs" 1046: 580: 104: 773:
Terzo, Olivier; Djemame, Karim; Scionti, Alberto; Pezuela, Clara (10 September 2019).
780: 219: 92: 919:"Khronos @ SIGGRAPH 2013: OpenGL 4.4, OpenCL 2.0, & OpenCL 1.2 SPIR Announced" 467:
A separate program by the Khronos Group allows for interconversion with LLVM IR.
707: 202:
Interchange format in place of DXIL, beginning support from Shader Model 7 on.
182: 97: 1390: 1267: 869: 1596: 1458: 653: 198:
On September 19th 2024, Microsoft has announced plans to adopt SPIR-V as the
192: 163: 47: 744: 676:, which aims to provide full linking functionality for SPIR-V binary code. 535: 471: 215: 170: 1427: 282:
SPIR was originally introduced in 2011 and SPIR-V was introduced in 2015.
195:, and has since replaced the original SPIR, which was introduced in 2012. 130: 231: 42: 1571: 1549: 1544: 1473: 605: 239: 185:. It is also used as an interchange language for cross compilation. 1561: 452: 448: 1566: 1534: 809:"DirectX Adopting SPIR-V as the Interchange Format of the Future" 199: 1108: 1576: 1539: 1518: 1503: 1498: 1493: 1488: 1417: 475: 255: 251: 178: 174: 167: 166:. It is used in multiple execution environments, including the 1581: 1554: 1188:"Google Open-Sources 'Amber' Multi-API Shader Test Framework" 649: 621:
validators verify that front-ends properly generate SPIR-V.
520: 505: 263: 191:
is a new version of SPIR which was introduced in 2015 by the
776:
Heterogeneous Computing Architectures: Challenges and Vision
34: 1513: 1478: 630:
temporarily use partially linked shaders and also kernels.
259: 772: 664:, and cross-compiling to SPIR-V to different GLSL targets 443:
SPIR prior to the 2015 SPIR-V release was based on the
893:"Khronos SPIR For OpenCL Brings Binary Compatibility" 642: 745:"Khronos SPIR-V Registry - The Khronos Group Inc" 1594: 1213:"SPIR-V Specification: Structured Control Flow" 852:"HLSL as a First Class Vulkan Shading Language" 768: 766: 764: 1443: 1342:"SPIR-V Specification: Language Capabilities" 961: 148:Standard Portable Intermediate Representation 910: 761: 1457: 1450: 1436: 1066:"OpenCL A State of the Union (IWOCL 2016)" 739: 737: 735: 733: 366:Supported Language & Feature Supported 33: 1088:"OpenCL State of the Nation (IWOCL 2017)" 993: 987: 1262: 1260: 1258: 1157: 1155: 806: 1367:"OpenGL / OpenGL ES Reference Compiler" 1085: 1063: 890: 884: 730: 703:Tungsten Graphics Shader Infrastructure 14: 1595: 891:Larabel, Michael (12 September 2012). 438: 72:SPIR-V 1.6 / December 16, 2021 1431: 1255: 1152: 1132: 967: 916: 807:Bieneman, Chris (19 September 2024). 1317:"SPIR-V Extension for Visual Studio" 970:"Khronos Announces OpenCL SPIR 2.0" 24: 994:Parkerson, Stuart (4 March 2015). 25: 1619: 1411: 643:SPIR-V for GLSL Cross-Compilation 590: 445:LLVM Intermediate Representation 421: 418: 234:into several shading languages ( 1383: 1359: 1334: 1309: 1284: 1230: 1205: 1180: 1126: 1101: 1079: 1064:Trevett, Neil (18 April 2016). 1057: 1039: 1013: 874:, The Khronos Group, 2019-09-06 633: 214:For example, SPIR-V allows the 968:Smith, Ryan (11 August 2014). 936: 862: 844: 826: 800: 326:Round-trip lossless conversion 13: 1: 1086:Trevett, Neil (16 May 2017). 723: 656:for compiling GLSL to SPIR-V 615: 917:Smith, Ryan (22 July 2013). 455:. SPIR-V does not use LLVM. 177:compute API, to represent a 7: 1135:"An Introduction to SPIR-V" 686:High-Level Shading Language 679: 574: 277: 10: 1624: 1238:"Specialization Constants" 624: 608:, SwiftShader, and Amber. 599: 205: 1527: 1466: 713:Parallel Thread Execution 692:Cg (programming language) 458: 125: 113: 103: 91: 87: 65: 61: 53: 41: 32: 871:KhronosGroup/SPIRV-Cross 585:static single assignment 697:OpenGL Shading Language 583:of basic blocks, using 1000:App Developer Magazine 813:DirectX Developer Blog 415:Graphics API Ingestion 1603:Compiler construction 1292:"Shader Fundamentals" 718:ARB assembly language 406:OpenCL 2.0 Extension 403:OpenCL 1.2 Extension 156:intermediate language 120:Intermediate language 74:; 2 years ago 1423:SPIR-V specification 1418:Khronos SPIR webpage 1053:. The Khronos Group. 660:, optimizing SPIR-V 534:Released along with 409:OpenCL 2.1/2.2 Core 341:Metadata/Intrinsics 338:Metadata/Intrinsics 323:100% Khronos defined 553:September 13, 2020 483: 439:LLVM-based versions 350:Graphics Constructs 287: 29: 1027:. 16 November 2015 858:. 15 January 2020. 604:Debuggers include 581:control-flow graph 563:December 16, 2021 481: 385:OpenCL C 1.2 / 2.X 334:Compute Constructs 285: 160:parallel computing 27: 1608:Shading languages 1590: 1589: 1133:Kessenich, John. 1113:The Khronos Group 948:The Khronos Group 856:The Khronos Group 572: 571: 436: 435: 145: 144: 16:(Redirected from 1615: 1452: 1445: 1438: 1429: 1428: 1405: 1404: 1402: 1401: 1387: 1381: 1380: 1378: 1377: 1363: 1357: 1356: 1354: 1352: 1338: 1332: 1331: 1329: 1327: 1321:saschawillems.de 1313: 1307: 1306: 1304: 1302: 1288: 1282: 1281: 1279: 1278: 1264: 1253: 1252: 1250: 1248: 1234: 1228: 1227: 1225: 1223: 1209: 1203: 1202: 1200: 1198: 1184: 1178: 1177: 1175: 1173: 1159: 1150: 1149: 1147: 1145: 1139: 1130: 1124: 1123: 1121: 1120: 1105: 1099: 1098: 1092: 1083: 1077: 1076: 1070: 1061: 1055: 1054: 1043: 1037: 1036: 1034: 1032: 1017: 1011: 1010: 1008: 1006: 991: 985: 984: 982: 980: 965: 959: 958: 956: 955: 940: 934: 933: 931: 929: 914: 908: 907: 905: 903: 888: 882: 881: 880: 879: 866: 860: 859: 848: 842: 841: 834:"Shader modules" 830: 824: 823: 821: 819: 804: 798: 797: 795: 793: 770: 759: 758: 756: 755: 741: 675: 667: 663: 659: 658:glslangValidator 484: 482:SPIR-V Releases 480: 399:OpenCL Ingestion 305:LLVM Interaction 288: 286:SPIR and SPIR-V 284: 230:. SPIR-V can be 220:shading language 162:and graphics by 141: 138: 136: 134: 132: 93:Operating system 82: 80: 75: 37: 30: 26: 21: 1623: 1622: 1618: 1617: 1616: 1614: 1613: 1612: 1593: 1592: 1591: 1586: 1523: 1462: 1456: 1414: 1409: 1408: 1399: 1397: 1389: 1388: 1384: 1375: 1373: 1371:www.khronos.org 1365: 1364: 1360: 1350: 1348: 1340: 1339: 1335: 1325: 1323: 1315: 1314: 1310: 1300: 1298: 1290: 1289: 1285: 1276: 1274: 1266: 1265: 1256: 1246: 1244: 1236: 1235: 1231: 1221: 1219: 1211: 1210: 1206: 1196: 1194: 1186: 1185: 1181: 1171: 1169: 1161: 1160: 1153: 1143: 1141: 1137: 1131: 1127: 1118: 1116: 1107: 1106: 1102: 1090: 1084: 1080: 1068: 1062: 1058: 1045: 1044: 1040: 1030: 1028: 1025:www.Khronos.org 1019: 1018: 1014: 1004: 1002: 992: 988: 978: 976: 966: 962: 953: 951: 942: 941: 937: 927: 925: 915: 911: 901: 899: 889: 885: 877: 875: 868: 867: 863: 850: 849: 845: 838:Vulkan Tutorial 832: 831: 827: 817: 815: 805: 801: 791: 789: 787: 771: 762: 753: 751: 749:www.khronos.org 743: 742: 731: 726: 682: 673: 665: 661: 657: 645: 636: 627: 618: 602: 593: 577: 498:April 18, 2016 461: 441: 430:OpenGL 4.6 Core 280: 273: 208: 129: 83: 78: 76: 73: 54:Initial release 23: 22: 15: 12: 11: 5: 1621: 1611: 1610: 1605: 1588: 1587: 1585: 1584: 1579: 1574: 1569: 1564: 1559: 1558: 1557: 1552: 1547: 1537: 1531: 1529: 1525: 1524: 1522: 1521: 1516: 1511: 1506: 1501: 1496: 1491: 1486: 1481: 1476: 1470: 1468: 1464: 1463: 1455: 1454: 1447: 1440: 1432: 1426: 1425: 1420: 1413: 1412:External links 1410: 1407: 1406: 1395:www.github.com 1391:"SPIR-V Cross" 1382: 1358: 1333: 1308: 1283: 1272:www.github.com 1268:"SPIR-V Tools" 1254: 1229: 1204: 1179: 1151: 1125: 1100: 1078: 1056: 1038: 1012: 986: 960: 935: 909: 883: 861: 843: 825: 799: 785: 760: 728: 727: 725: 722: 721: 720: 715: 710: 708:Compute kernel 705: 700: 694: 689: 681: 678: 644: 641: 639:capabilities. 635: 632: 626: 623: 617: 614: 601: 598: 592: 589: 576: 573: 570: 569: 567: 564: 560: 559: 557: 554: 550: 549: 547: 544: 540: 539: 532: 529: 528:March 7, 2018 525: 524: 517: 514: 510: 509: 502: 499: 495: 494: 491: 488: 460: 457: 440: 437: 434: 433: 432: 431: 428: 423: 420: 417: 411: 410: 407: 404: 401: 395: 394: 393: 392: 389: 386: 381: 380: 379: 376: 371: 368: 362: 361: 358: 355: 352: 346: 345: 342: 339: 336: 330: 329: 328: 327: 324: 319: 313: 307: 301: 300: 297: 294: 291: 279: 276: 207: 204: 143: 142: 127: 123: 122: 117: 111: 110: 109:Cross-platform 107: 101: 100: 98:Cross-platform 95: 89: 88: 85: 84: 71: 69: 67:Stable release 63: 62: 59: 58: 55: 51: 50: 45: 39: 38: 9: 6: 4: 3: 2: 1620: 1609: 1606: 1604: 1601: 1600: 1598: 1583: 1580: 1578: 1575: 1573: 1570: 1568: 1565: 1563: 1560: 1556: 1553: 1551: 1548: 1546: 1543: 1542: 1541: 1538: 1536: 1533: 1532: 1530: 1526: 1520: 1517: 1515: 1512: 1510: 1507: 1505: 1502: 1500: 1497: 1495: 1492: 1490: 1487: 1485: 1482: 1480: 1477: 1475: 1472: 1471: 1469: 1465: 1460: 1459:Khronos Group 1453: 1448: 1446: 1441: 1439: 1434: 1433: 1430: 1424: 1421: 1419: 1416: 1415: 1396: 1392: 1386: 1372: 1368: 1362: 1347: 1343: 1337: 1322: 1318: 1312: 1297: 1293: 1287: 1273: 1269: 1263: 1261: 1259: 1243: 1239: 1233: 1218: 1214: 1208: 1193: 1189: 1183: 1168: 1164: 1163:"SPIRV-Guide" 1158: 1156: 1136: 1129: 1114: 1110: 1104: 1096: 1089: 1082: 1074: 1073:Khronos Group 1067: 1060: 1052: 1048: 1042: 1026: 1022: 1016: 1001: 997: 990: 975: 971: 964: 949: 945: 939: 924: 920: 913: 898: 894: 887: 873: 872: 865: 857: 853: 847: 839: 835: 829: 814: 810: 803: 788: 786:9780429680038 782: 779:. CRC Press. 778: 777: 769: 767: 765: 750: 746: 740: 738: 736: 734: 729: 719: 716: 714: 711: 709: 706: 704: 701: 698: 695: 693: 690: 687: 684: 683: 677: 669: 655: 654:Khronos Group 651: 640: 631: 622: 613: 609: 607: 597: 591:Extensibility 588: 586: 582: 568: 565: 562: 561: 558: 555: 552: 551: 548: 545: 542: 541: 537: 533: 530: 527: 526: 522: 518: 515: 513:May 16, 2017 512: 511: 507: 503: 500: 497: 496: 492: 489: 486: 485: 479: 478:version 4.6. 477: 473: 468: 465: 456: 454: 453:SIGGRAPH 2014 450: 449:SIGGRAPH 2013 446: 429: 426: 425: 424: 416: 413: 412: 408: 405: 402: 400: 397: 396: 390: 387: 384: 383: 382: 377: 374: 373: 372: 370:OpenCL C 1.2 369: 367: 364: 363: 359: 356: 353: 351: 348: 347: 343: 340: 337: 335: 332: 331: 325: 322: 321: 320: 317: 314: 311: 308: 306: 303: 302: 298: 295: 292: 290: 289: 283: 275: 271: 269: 265: 261: 257: 253: 249: 245: 241: 237: 233: 229: 225: 221: 217: 212: 203: 201: 196: 194: 193:Khronos Group 190: 186: 184: 180: 176: 172: 169: 165: 164:Khronos Group 161: 157: 153: 149: 140: 128: 124: 121: 118: 116: 112: 108: 106: 102: 99: 96: 94: 90: 86: 70: 68: 64: 60: 56: 52: 49: 48:Khronos Group 46: 44: 40: 36: 31: 19: 1508: 1398:. Retrieved 1394: 1385: 1374:. Retrieved 1370: 1361: 1349:. Retrieved 1345: 1336: 1324:. Retrieved 1320: 1311: 1299:. Retrieved 1296:informit.com 1295: 1286: 1275:. Retrieved 1271: 1245:. Retrieved 1241: 1232: 1220:. Retrieved 1216: 1207: 1195:. Retrieved 1192:phoronix.com 1191: 1182: 1170:. Retrieved 1166: 1142:. Retrieved 1128: 1117:. Retrieved 1115:. 2014-01-20 1112: 1103: 1094: 1081: 1072: 1059: 1050: 1041: 1029:. Retrieved 1024: 1015: 1003:. Retrieved 999: 989: 977:. Retrieved 973: 963: 952:. Retrieved 950:. 2014-01-20 947: 938: 926:. Retrieved 922: 912: 900:. Retrieved 896: 886: 876:, retrieved 870: 864: 855: 846: 837: 828: 818:19 September 816:. Retrieved 812: 802: 790:. Retrieved 775: 752:. Retrieved 748: 670: 646: 637: 634:Capabilities 628: 619: 610: 603: 594: 578: 543:May 7, 2019 519:Released at 504:Released at 469: 466: 462: 442: 414: 398: 378:OpenCL C 2.0 375:OpenCL C 1.2 365: 349: 333: 318:version 3.4 312:version 3.2 304: 281: 272: 222:, including 213: 209: 197: 188: 187: 171:graphics API 151: 147: 146: 43:Developer(s) 1346:khronos.org 1242:veldrid.dev 1217:khronos.org 1031:16 November 666:spirv-cross 299:SPIR-V 1.X 218:to use any 1597:Categories 1400:2020-10-01 1376:2020-10-01 1277:2020-10-01 1167:github.com 1119:2019-08-05 954:2019-08-05 878:2019-09-08 754:2024-01-16 724:References 674:spirv-link 616:Validation 536:Vulkan 1.1 521:IWOCL 2017 506:IWOCL 2016 472:Vulkan API 427:Vulkan 1.X 388:OpenCL C++ 232:decompiled 216:Vulkan API 79:2021-12-16 1572:OpenSL ES 1461:Standards 1140:. Khronos 974:Anandtech 923:Anandtech 662:spirv-opt 650:WebGL 1.0 606:RenderDoc 296:SPIR 2.0 293:SPIR 1.2 137:/registry 1562:OpenKODE 1528:Inactive 897:Phoronix 680:See also 575:Features 490:Version 278:Versions 200:Direct3D 173:and the 154:) is an 133:.khronos 105:Platform 1567:OpenMAX 1535:COLLADA 1351:24 June 1326:24 June 1301:24 June 1247:24 June 1222:24 June 1197:24 June 1172:24 June 1144:25 July 1005:5 April 979:5 April 928:5 April 902:25 July 792:24 June 625:Linking 600:Shaders 360:Native 344:Native 316:LLVM IR 310:LLVM IR 240:GLSL ES 206:Purpose 139:/SPIR-V 126:Website 77: ( 1577:OpenWF 1540:OpenGL 1519:Vulkan 1504:OpenXR 1499:OpenVX 1494:OpenVG 1489:OpenCL 1467:Active 1051:GitHub 783:  699:(GLSL) 688:(HLSL) 493:Notes 476:OpenGL 474:, and 459:SPIR-V 266:, and 256:OpenCL 252:WebGPU 189:SPIR-V 183:kernel 179:shader 175:OpenCL 168:Vulkan 28:SPIR-V 18:SPIR-V 1582:WebCL 1555:WebGL 1138:(PDF) 1095:IWOCL 1091:(PDF) 1069:(PDF) 487:Date 1514:SYCL 1509:SPIR 1484:NNEF 1479:glTF 1353:2022 1328:2022 1303:2022 1249:2022 1224:2022 1199:2022 1174:2022 1146:2015 1033:2015 1007:2015 981:2015 930:2015 904:2015 820:2024 794:2022 781:ISBN 566:1.6 556:1.5 546:1.4 531:1.3 516:1.2 501:1.1 391:GLSL 268:Rust 260:SYCL 248:HLSL 236:GLSL 228:HLSL 226:and 224:GLSL 158:for 152:SPIR 135:.org 115:Type 57:2015 1474:EGL 357:No 354:No 264:C++ 244:MSL 181:or 131:www 1599:: 1550:SC 1545:ES 1393:. 1369:. 1344:. 1319:. 1294:. 1270:. 1257:^ 1240:. 1215:. 1190:. 1165:. 1154:^ 1111:. 1093:. 1071:. 1049:. 1023:. 998:. 972:. 946:. 921:. 895:. 854:. 836:. 811:. 763:^ 747:. 732:^ 668:. 422:— 419:— 270:. 262:, 258:, 254:, 246:, 242:, 238:, 1451:e 1444:t 1437:v 1403:. 1379:. 1355:. 1330:. 1305:. 1280:. 1251:. 1226:. 1201:. 1176:. 1148:. 1122:. 1097:. 1075:. 1035:. 1009:. 983:. 957:. 932:. 906:. 840:. 822:. 796:. 757:. 150:( 81:) 20:)

Index

SPIR-V

Developer(s)
Khronos Group
Stable release
Operating system
Cross-platform
Platform
Type
Intermediate language
www.khronos.org/registry/SPIR-V
intermediate language
parallel computing
Khronos Group
Vulkan
graphics API
OpenCL
shader
kernel
Khronos Group
Direct3D
Vulkan API
shading language
GLSL
HLSL
decompiled
GLSL
GLSL ES
MSL
HLSL

Text is available under the Creative Commons Attribution-ShareAlike License. Additional terms may apply.