Knowledge

Standard Portable Intermediate Representation

Source 📝

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

Index


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
WebGPU

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