DirectX Adopting SPIR-V as the Interchange Format of the Future



 DirectX Developer Blog:

Today the Direct3D and HLSL teams are excited to share some insight into the next big step for GPU programmability. Once Shader Model 7 is released, DirectX 12 will accept shaders compiled to SPIR-V™. The HLSL team is committed to open development processes and collaborating with The Khronos® Group and LLVM Project. We’re sharing this information at the beginning of our multi-year development process so that we can be transparent about this transition from the start. We are working with the Khronos SPIR™ and Vulkan® working groups to ensure that this transition benefits the whole development ecosystem.

Embracing Open Technologies and Standards​

It is our mission that HLSL be the best language for compiling graphics and compute shaders for any device or GPU runtime API. To support that goal, the HLSL team is actively embracing open technologies and collaborating with industry standards. We will continue to adopt and support the best open-source tools available while contributing our own innovations to make Direct3D and other Microsoft technologies best in class.

CollabCorgie.png

Adapted from “Corgis working as a team”. (n.d.).

In the 8 years since Shader Model 6.0 was first introduced, Direct3D and HLSL have grown considerably in both features and adoption. Releasing DXC on GitHub and the tremendous contributions from open-source collaborators and partners played a significant role in expanding HLSL’s user base to include Vulkan and Metal developers. As a result of this expansion, the team is focusing on developing HLSL support in Clang to enable us to keep up with industry demand for openness and new features. As we look end to end at the best way to support the full spectrum of our users, we are working hard to support HLSL for both DXIL and SPIR-V with Clang and LLVM.

To better enable HLSL’s Vulkan support, the HLSL team is now participating in The Khronos Group’s SPIR and Vulkan working groups. This direct participation will allow smoother collaboration and more rapid adoption of Vulkan features. We believe this will ensure that HLSL is the best language for writing shaders for every GPU runtime environment.

HLSL is a key shading language used widely across the industry, and Khronos warmly welcomes Microsoft’s participation and embrace of the SPIR-V open standard, which will benefit HLSL, Direct3D, and the entire graphics ecosystem. Khronos will work to ensure that SPIR-V continues to evolve and remains responsive to the needs of all its client APIs and languages, now including DX12 and HLSL. — Neil Trevett, Khronos Group President.

One example of our commitment to supporting the industry is our strong partnership with Google to develop core HLSL language features, like operator overloading, as well as features to expose Vulkan functionality, like inline SPIR-V. We greatly value this ongoing partnership and will continue to work with Google and other partners in the future.

Since 2017 our collaboration on a SPIR-V backend for DXC has yielded an industrial strength shader compiler benefiting graphics developers everywhere. We are excited to see Microsoft adopt SPIR-V as the shader intermediate language for Direct3D. We look forward to delivering future language and hardware features to developers at greater velocity and with less fuss. — David Neto, Chrome team at Google

The Road to Replacing DXIL​

WeDontNeedDXIL-1024x576.png

Adapted from, “Where we’re going we don’t need roads,” Robert Zemeckis, “Back to the Future”, 1985

Shader Model 6 and its successors have dramatically extended the capabilities of Direct3D. Features like ray tracing and work graphs would not have been possible without the capabilities brought to Shader Model 6 by adopting an LLVM-based IR and compiler. If you want to understand more about interchange formats please read through to the Appendix.

As we look to the future, maintaining a proprietary IR format (even one based on an open-source project) is counter to our commitments to open technologies, so Shader Model 7.0 will adopt SPIR-V as its interchange format. Over the next few years, we will be working to define a SPIR-V environment for Direct3D, and a set of SPIR-V extensions to support all of Direct3D’s current and future shader programming features through SPIR-V. This will allow developers to take better advantage of existing tools and unify the ecosystem around investing in one IR.

In addition to providing a compiler for HLSL to Direct3D’s SPIR-V, we will also be building and providing translation tools to translate SPIR-V to DXIL and DXIL to SPIR-V. Those tools will allow and driver developers to gradually transition and gracefully adapt tooling and drivers.

Workflows for developers building Direct3D applications with the AgilitySDK will remain largely unchanged. We do expect some changes for developers who maintain tooling that manipulates or edits compiled shaders, however we believe that the robust tooling available for working with SPIR-V binaries will provide benefits outweighing the cost of transition.

SPIR-V’s core design enables extensibility, which will enable more rapid innovation of GPU API features. Using a common format for representing compiled shaders will enable faster adoption of features across multiple APIs. We feel this is a huge step forward for enabling developer productivity across the industry.

This transition will take several years, and we hope that by being open with our plans early we can enable developers and partners to plan appropriately with as much notice as possible.

Unlocking Innovation in Direct3D​

Our plans for Shader Model 7 represent the beginning of a new chapter of innovation for Direct3D. By aligning with open standards and embracing the best open-source technologies we will accelerate development of new features and enable rapidly surfacing cutting-edge hardware capabilities.

Utilizing an industry standard interchange format will allow Microsoft and hardware vendors to focus their engineering efforts on differentiating features that will power the next generation of applications instead of duplicating common functionality.

With these upcoming changes and our continued investment in Direct3D, the future of DirectX has never been brighter.

Appendix: A Brief History of GPU Interchange Formats​

Unlike CPUs, GPUs have not adopted common long-lived architectures. That means that, while the CPU code for an application compiled once 10+ years ago may run on a brand new device, the GPU code would not have the same portability if it were compiled to the GPU’s native Instruction Set Architecture (ISA).

To solve this problem, GPU programming models often defer generating native ISA to runtime when the GPU driver can optimize for the GPU’s specific hardware capabilities. Graphics programming APIs support either shipping shader programs in source code form, or in a Virtual ISA that abstracts common hardware features at a higher level. Both forms allow the GPU driver to lower and optimize the program more efficiently, but the use of a virtual ISA reduces the time it takes the driver to generate native code. As such, virtual ISAs have become the preferred method for shipping shader programs for high-performance applications.

Direct3D has supported a virtual ISA for shader programs since shader programmability was introduced in Direct3D 8. The original virtual ISA, DirectX Bytecode (DXBC), evolved and eventually was replaced by the LLVM-based DirectX Intermediate Language (DXIL).

WhatIsIR.png

Adapted from, “Andy doesn’t know,” Michael Schur, “Parks and Recreation,” 2009-2015

LLVM’s Intermediate Representation (IR) brought some major advantages to GPU programmability. LLVM’s IR can be treated as a virtual ISA, but it is inherently a Static Single-Assignment (SSA) IR. Most well-known and widely used optimizing compilers use SSA IRs because they provide significant advantages due to a simplified program representation that makes it easier to write optimizing transformations.

Using an SSA IR as the interchange format for GPU programs simplified the transformation from the interchange representation to the GPU driver compiler’s internal representation required for optimizing and lowering to the native ISA.

LLVM has a long history of being used as a GPU interchange format. The original Standard Portable Intermediate Representation (SPIR) was LLVM 3.2’s IR serialized to LLVM’s bitcode format.

LLVM’s bitcode format had some significant drawbacks. Notably it is not version stable. New versions of LLVM support a lossy upgrading of older LLVM IR modules, but new LLVM cannot write IR modules that can be read by older versions of LLVM. Additionally, LLVM bitcode is a bit-packed file format which has two big drawbacks (1) it compresses poorly, and (2) it is hard to read or write from tools that aren’t LLVM.

To solve these problems The Khronos Group developed SPIR-V as a successor to SPIR. SPIR-V is ideologically aligned with LLVM’s IR, but it supports a stable and simple binary serialization. This makes SPIR-V easy to read and write by simpler tools than LLVM IR. SPIR-V is the interchange format used for a wide array of GPU programming technologies developed by the Khronos Group including Vulkan, OpenCL, and SYCL.


 Source:

 
Microsoft only adopts open specifications for file formats, once they see that the tide is turning from programmers with hacking sensibilities who create alternatives.

  • Sun Microsystems employing a hacker who created a software to open proprietary .doc .xls .ppt files, to help create Sun StarOffice and Sun OpenOffice, which later became LibreOffice, which forced Microsoft's hand to make the OOXML more open and machine readable as an XML file with a .zip structure rather than binary when opened in Notepad.
  • Visual Studio having a free version once people made a free open source alternative as an IDE called SharpDevelop
  • .NET 5 Core being open source, which is a subset of .NET 5, once Mono created an open source implementation of the .NET standard.
  • Outlook Express and Windows Live Mail supporting exporting emails as a PDF, once it became clear that their XPS standard (that was first bundled in Office 2007) failed to gain market share or third party support.
  • Google funding VP8 and VP9 video codecs after buying ON2 Technologies, which with Youtube being a Top 10 website according to the gone Alexa.com, it led QuickTime, Windows Media Video and RealVideo to disappear. That and Apple using HLS for streaming which is Apple's technology, compared to MPEG-DASH which is supported by Android and Windows Phone but is banned on the iPhone (along with Flash and Flash Video).
However when it comes to the open source plaza (well I wouldn't say marketplace), the only reason why they brought Github after shutting down Codeplex, is that they realised they could datamine Github to train their AI for OpenAI and Github Copilot.

Swiftly moving on, with all the talk of "smart pipe" and "dumb pipe", "ecosystem" and "walled garden", Microsoft definitely had a Damascus Moment regretting shutting down Windows Phone, as despite the 30 million programs on softpedia compared to the 2 million apps on the Apple App Store, Microsoft eventually realised that the majority of people could replace their windows laptop with an iPad without loss or compromise. Well most people aren't hardcore gamers, creative professionals or compiling code.

The same again with shutting down Visual FoxPro because it was a one-off payment compared to Visual Studio Membership and the Developer Program having an annual subscription. However with zero-code and low-code solutions like Sktch and Retool, they started to regret it and now there's Office 365 App Builder, ahem, Microsoft 365 App Builder that exists within the web browser.

That reminds me of how Kodak invented digital cameras 30 years before everyone else but refused to release it, surpressing the technology, as they felt it would cannibalise their highly profitable analogue film capsule sales for their analogue cameras. Remember going to the pharmacist or photography store to get your film developed? I went to Boots, not Walgreens! Once other companies started inventing it, the consumer division of Kodak went bankrupt so now they only have the Hollywood film and manufacturing side be profitable. That's the same reason why Apple shut down Lala after buying it and why Skype sucks after Microsoft brought it, as Skype is free whereas Microsoft Teams costs money so the new skype removed most of the features that the old skype had and they removed the P2P peer-to-peer features so gamers abandoned it (for Discord or back to Ventrilio or Teamspeak) and they also throttled the latency and audiovisual quality of the voice and video calls and the framerate and audio bitrate.

PS. There was a time where you had to PAY Adobe then Microsoft money for the ability to convert a .doc or .docx file to PDF (which caused a hilarious lawsuit of Adobe suing Microsoft when Microsoft made it free when Adobe made PDF an open standard).
 
Last edited:

My Computer

System One

  • OS
    Windows 11 22H2
    Computer type
    Laptop
    Manufacturer/Model
    Acer Aspire 315-56
    CPU
    Intel i5 10th generation Ice Lake
    Memory
    8GB
    Graphics Card(s)
    Intel Intregated Graphics
    Sound Card
    Realtek and Intel Audio
    Monitor(s) Displays
    Built-in
    Screen Resolution
    15.6"
    Hard Drives
    2TB Hard Disk Drive (HDD)
    Keyboard
    Built-in
    Mouse
    Built-in
    Browser
    Microsoft Edge
    Antivirus
    Comodo Internet Security

Latest Support Threads

Back
Top Bottom