ඩිරෙක්ට් එක්ස්

**Microsoft DirectX** is a collection of application programming interfaces (APIs) for handling tasks related to multimedia, especially game programming and video, on Microsoft platforms. Originally, the names of these APIs all began with "Direct", such as Direct3D, DirectDraw, DirectMusic, DirectPlay, DirectSound, and so forth. The name *DirectX* was coined as a shorthand term for all of these APIs (the *X* standing in for the particular API names) and soon became the name of the collection. When Microsoft later set out to develop a gaming console, the *X* was used as the basis of the name Xbox to indicate that the console was based on DirectX technology. The *X* initial has been carried forward in the naming of APIs designed for the Xbox such as XInput and the Cross-platform Audio Creation Tool (XACT), while the DirectX pattern has been continued for Windows APIs such as Direct2D and DirectWrite.

Direct3D (the 3D graphics API within DirectX) is widely used in the development of video games for Microsoft Windows and the Xbox line of consoles. Direct3D is also used by other software applications for visualization and graphics tasks such as CAD/CAM engineering. As Direct3D is the most widely publicized component of DirectX, it is common to see the names "DirectX" and "Direct3D" used interchangeably.

The DirectX software development kit (SDK) consists of runtime libraries in redistributable binary form, along with accompanying documentation and headers for use in coding. Originally, the runtimes were only installed by games or explicitly by the user. Windows 95 did not launch with DirectX, but DirectX was included with Windows 95 OEM Service Release 2. Windows 98 and Windows NT 4.0 both shipped with DirectX, as has every version of Windows released since. The SDK is available as a free download. While the runtimes are proprietary, closed-source software, source code is provided for most of the SDK samples. Starting with the release of Windows 8 Developer Preview, DirectX SDK has been integrated into Windows SDK.

## Development history
In late 1994, Microsoft was ready to release Windows 95, its next operating system. An important factor in its value to consumers was the programs that would be able to run on it. Microsoft employee Alex St. John had been in discussions with various game developers asking how likely they would be to bring their MS-DOS games to Windows 95, and found the responses mostly negative, since programmers had found that the Windows environment did not provide the necessary features which were available under MS-DOS using BIOS routines or direct hardware access. There were also strong fears of compatibility; a notable case of this was from ''Disney's Animated Storybook: The Lion King'' which was based on the WinG programming interface. Due to numerous incompatible graphics drivers from new Compaq computers that were not tested with the WinG interface which came bundled with the game, it crashed so frequently on many desktop systems that parents had flooded Disney's call-in help lines.

Another Microsoft employee, Craig Eisler, had joined the Windows 95 multimedia team to work on game technology. Hearing from St. John that the technology Microsoft had was not resonating with developers, Eisler set out to build a new set of APIs and a driver model that would allow developers to access the native capabilities of graphics hardware, and gave graphics hardware companies the ability to innovate in ways that developers could use. Needing program management support, Eisler recruited Eric Engstrom, and together they were granted 11 patents for their DirectX work. The project was codenamed the Manhattan Project, like the World War II project of the same name, and the idea was to displace the Japanese-developed video game consoles with personal computers running Microsoft's operating system.

Most of the work by the three was done among other assigned projects starting near the end of 1994. DirectSound for audio, and DirectPlay for communication between players over a network. Furthermore, an extended joystick API already present in Windows 95 was documented for the first time as DirectInput, while a description of how to implement the immediate start of the installation procedure of a software title after inserting its CD-ROM, a feature called AutoPlay, was also part of the SDK. The "Direct" part of the library was so named as these routines bypassed existing core Windows&nbsp;95 routines and accessed the computer hardware only via a hardware abstraction layer (HAL). Though the team had named it the "Game SDK" (software development kit), the name "DirectX" came from one journalist that had mocked the naming scheme of the various libraries. The team opted to continue to use that naming scheme and call the project DirectX. and WinG APIs for Windows 3.1. DirectX allowed all versions of Microsoft Windows, starting with Windows 95, to incorporate high-performance multimedia. Eisler wrote about the frenzy to build DirectX 1 through 5 in his blog.

To get more developers on board DirectX, Microsoft approached id Software's John Carmack and offered to port *Doom* and *Doom 2* from MS-DOS to DirectX, free of charge, with id retaining all publishing rights to the game. Carmack agreed, and Microsoft's Gabe Newell led the porting project. The first game was released as *Doom 95* in August 1996, the first published DirectX game. Microsoft promoted the game heavily with Bill Gates appearing in ads for the title. It was at this event that Microsoft first introduced Direct3D, and demonstrated multiplayer *MechWarrior&nbsp;2* being played over the Internet.

The DirectX team faced the challenging task of testing each DirectX release against an array of computer hardware and software. A variety of different graphics cards, audio cards, motherboards, CPUs, input devices, games, and other multimedia applications were tested with each beta and final release. The DirectX team also built and distributed tests that allowed the hardware industry to confirm that new hardware designs and driver releases would be compatible with DirectX.

Prior to DirectX Microsoft had added OpenGL to its Windows&nbsp;NT platform. OpenGL had been designed as a cross-platform, window system independent software interface to graphics hardware by Silicon Graphics, Inc. to bring 3D graphics programming into the mainstream of application programming.  It could also be used for 2D graphics and imaging, and was controlled by the Architectural Review Board (ARB), which included Microsoft. Direct3D was intended to be a Microsoft controlled alternative to OpenGL, focused initially on game use. As 3D gaming grew,  game developers discovered that OpenGL could also be used effectively for game development. At that point, a "battle" began between supporters of the cross-platform OpenGL and the Windows-only Direct3D. Incidentally, OpenGL was supported at Microsoft by the DirectX team. If a developer chose to use the OpenGL 3D graphics API in computer games, the other APIs of DirectX besides Direct3D were often combined with OpenGL, since OpenGL does not include all of DirectX's functionality, such as sound or joystick support.

In a console-specific version, DirectX was used as a basis for Microsoft's Xbox, Xbox 360 and Xbox One console API. The API was developed jointly between Microsoft and Nvidia, which developed the custom graphics hardware used by the original Xbox. The Xbox API was similar to DirectX version 8.1, but is non-updateable like other console technologies. The Xbox was code named DirectXbox, but this was shortened to Xbox for its commercial name.

In 2002, Microsoft released DirectX 9 with support for the use of much longer shader programs than before with pixel and vertex shader version 2.0. Microsoft has continued to update the DirectX suite since then, introducing Shader Model 3.0 in DirectX 9.0c, released in August 2004.

As of April 2005, DirectShow was removed from DirectX and moved to the Microsoft Platform SDK instead.

DirectX has been confirmed to be present in Microsoft's Windows Phone 8.

Real-time raytracing was announced as DXR in 2018. Support for compiling HLSL to SPIR-V was also added in the DirectX Shader Compiler the same year.

## Components
DirectX is composed of multiple APIs:

* Direct3D (D3D): Real-time 3D rendering API
* DXGI: Enumerates adapters and monitors and manages swap chains for Direct3D 10 and later.
* Direct2D: 2D graphics API
* DirectWrite: Text rendering API
* DirectCompute: API for general-purpose computing on graphics processing units
* DirectX Diagnostics (DxDiag): A tool for diagnosing and generating reports on components related to DirectX, such as audio, video, and input drivers
* XACT3: High-level audio API
* XAudio2: Low-level audio API
* DirectX Raytracing (DXR): Real-time raytracing API
* DirectStorage: GPU-oriented file I/O API
* DirectML: GPU-accelerated machine learning and artificial intelligence API
* DirectSR: GPU-accelerated resolution upscaling API
* Media Foundation
** DirectX Video Acceleration for accelerated video playback

Microsoft has deprecated the following components:
* DirectX Media: Consists of:
** DirectAnimation for 2D/3D web animation, DirectShow for multimedia playback and streaming media
** DirectX Media Objects: Support for streaming objects such as encoders, decoders, and effects (Deprecated in favor of Media Foundation Transforms; MFTs)
** DirectX Transform for web interactivity, and Direct3D Retained Mode for higher level 3D graphics
** DirectX plugins for audio signal processing
* DirectDraw: 2D graphics API (Deprecated in favor of Direct2D)
* DirectInput: Input API for interfacing with keyboards, mice, joysticks, and game controllers (Deprecated after version 8 in favor of XInput for Xbox 360 controllers or standard WM_INPUT window message processing for keyboard and mouse input)
* DirectPlay: Network API for communication over a local-area or wide-area network (Deprecated after version 8 in favor of Games for Windows Live and Xbox Live)
* DirectSound: Audio API (Deprecated since DirectX 8 in favor of XAudio2 and XACT3)
* DirectSound3D (DS3D): 3D sounds API
* DirectMusic: Components for playing soundtracks authored in DirectMusic Producer

DirectX functionality is provided in the form of COM-style objects and interfaces. Additionally, while not DirectX components themselves, managed objects have been built on top of some parts of DirectX, such as Managed Direct3D and the XNA graphics library on top of Direct3D 9.

Microsoft distributes the debugging tool for DirectX called "PIX".

## Versions
### DirectX 9
Introduced by Microsoft in 2002, DirectX 9 was a significant release in the DirectX family. It brought many important features and enhancements to the graphics capabilities of Windows. At the time of its release, it supported Windows 98, Windows Me, Windows 2000, and Windows XP. As of August 2024 it remains supported by all subsequent versions of Windows for backward compatibility.

One of the key features introduced in DirectX 9 was Shader Model 2.0, which included Pixel Shader 2.0 and Vertex Shader 2.0. These allowed for more complex and realistic graphics rendering. It also brought much needed performance improvements through better hardware acceleration capabilities, and better utilization of GPU resources. It also introduced HLSL, which provided a more accessible way for developers to produce shaders.

DirectX 9.0c was an update to the original, and has been continuously changed over the years affecting its compatibility with older operating systems. As of January 2007, Windows 2000 and Windows XP became the minimum required operating systems. This means support was officially dropped for Windows 98 and Windows Me. As of August 2024, DirectX 9.0c is still regularly updated.

Windows XP SP2 and newer include DirectX 9.0c, but may require a newer DirectX runtime redistributable installation for DirectX 9.0c applications compiled with the February 2005 DirectX 9.0 SDK or newer.

DirectX 9 had a significant impact on game development. Many games from the mid-2000s to early 2010s were developed using DirectX 9 and it became a standard target for developers. Even today, some games still use DirectX 9 as an option for older or less powerful hardware.

### DirectX 10
A major update to the DirectX API, DirectX 10 shipped with and was only available with Windows Vista (launched in late 2006) and later. Previous versions of Windows such as Windows XP are not able to run DirectX 10-exclusive applications. Instead, programs running on a Windows XP system with DirectX 10 hardware would simply use the DirectX 9.0c code path, which was the latest version available for Windows XP
.

Changes for DirectX 10 were extensive. Many former parts of DirectX API were deprecated in the latest DirectX SDK and are preserved for compatibility only: DirectInput was deprecated in favor of XInput, DirectSound was deprecated in favor of the Cross-platform Audio Creation Tool system (XACT) and additionally lost support for hardware accelerated audio, since the Vista audio stack renders sound in software on the CPU. The DirectPlay DPLAY.DLL was also removed and was replaced with dplayx.dll; games that rely on this DLL must duplicate it and rename it to dplay.dll.

In order to achieve backwards compatibility, DirectX in Windows Vista contains several versions of Direct3D:
* **Direct3D 9**: emulates Direct3D 9 behavior as it was on Windows XP. Details and advantages of Vista's Windows Display Driver Model are hidden from the application if WDDM drivers are installed. This is the only API available if there are only XP graphic drivers (XDDM) installed, after an upgrade to Vista for example.
* **Direct3D 9Ex** (known internally during Windows Vista development as 9.0L or 9.L): allows full access to the new capabilities of WDDM (if WDDM drivers are installed) while maintaining compatibility for existing Direct3D applications. The Windows Aero user interface relies on D3D 9Ex.
* **Direct3D 10**: Designed around the new driver model in Windows Vista and featuring a number of improvements to rendering capabilities and flexibility, including Shader Model 4.
Direct3D 10.1 is an incremental update of Direct3D 10.0 which shipped with, and required, Windows Vista Service Pack 1, which was released in February 2008. This release mainly sets a few more image quality standards for graphics vendors, while giving developers more control over image quality. It also adds support for cube map arrays, separate blend modes per-MRT, coverage mask export from a pixel shader, ability to run pixel shader per sample, access to multi-sampled depth buffers and requires that the video card supports Shader Model 4.1 or higher and 32-bit floating-point operations. Direct3D 10.1 still fully supports Direct3D 10 hardware, but in order to utilize all of the new features, updated hardware is required.

### DirectX 11
Microsoft unveiled DirectX 11 at the Gamefest 08 event in Seattle. The Final Platform Update launched for Windows Vista on October 27, 2009, which was a week after the initial release of Windows 7, which launched with Direct3D 11 as a base standard.

Major scheduled features including GPGPU software support (DirectCompute), and Direct3D 11 with tessellation support and improved multi-threading support to assist video game developers in developing games that better utilize multi-core processors. Parts of the new API such as multi-threaded resource handling can be supported on Direct3D 9/10/10.1-class hardware. Hardware tessellation and Shader Model 5.0 require Direct3D 11 supporting hardware. Direct3D 11 is a strict superset of Direct3D 10.1 — all hardware and API features of version 10.1 are retained, and new features are added only when necessary for exposing new functionality. This helps to keep backwards compatibility with previous versions of DirectX.

Four updates for DirectX 11 were released:
* DirectX 11.1 is included in Windows 8. It supports WDDM 1.2 for increased performance, features improved integration of Direct2D (now at version 1.1), Direct3D, and DirectCompute, and includes DirectXMath, XAudio2, and XInput libraries from the XNA framework. It also features stereoscopic 3D support for gaming and video. DirectX 11.1 was also partially backported to Windows 7, via the Windows 7 platform update.
* DirectX 11.2 is included in Windows 8.1 (including the RT version) and Windows Server 2012 R2. It added some new features to Direct2D like geometry realizations. It also added swap chain composition, which allows some elements of the scene to be rendered at lower resolutions and then composited via hardware overlay with other parts rendered at higher resolution.
* DirectX 11.X is a superset of DirectX 11.2 running on the Xbox One. It actually includes some features, such as draw bundles, that were later announced as part of DirectX 12.
* DirectX 11.3 was announced along with DirectX 12 at GDC and released in 2015. It is meant to complement DirectX 12 as a higher-level alternative. It is included with Windows 10. The release of Direct3D 12 comes alongside other initiatives for low-overhead graphics APIs including AMD's Mantle for AMD graphics cards, Apple's Metal for iOS and macOS and Khronos Group's cross-platform Vulkan.

Multiadapter support will feature in DirectX 12 allowing developers to utilize multiple GPUs on a system simultaneously; multi-GPU (mGPU) support was previously dependent on vendor implementations such as AMD CrossFireX or NVIDIA SLI.
**Implicit Multiadapter* support will work in a similar manner to previous versions of DirectX where frames are rendered alternately across linked GPUs of similar compute-power.
**Explicit Multiadapter* will provide two distinct API patterns to developers. *Linked GPUs* will allow DirectX to view graphics cards in SLI or CrossFireX as a single GPU and use the combined resources; whereas *Unlinked GPUs* will allow GPUs from different vendors to be utilized by DirectX, such as supplementing the dedicated GPU with the integrated GPU on the CPU, or combining AMD and NVIDIA cards. However, elaborate mixed multi-GPU setups requires significantly more attentive developer support.

DirectX 12 is supported on all Fermi and later Nvidia GPUs, on AMD's GCN-based chips and on Intel's Haswell and later processors' graphics units.

At SIGGRAPH 2014, Intel released a demo showing a computer generated asteroid field, in which DirectX 12 was claimed to be 50–70% more efficient than DirectX 11 in rendering speed and CPU power consumption.

*Ashes of the Singularity* was the first publicly available game to utilize DirectX 12. Testing by *Ars Technica* in August 2015 revealed slight performance regressions in DirectX 12 over DirectX 11 mode for the Nvidia GeForce 980 Ti, whereas the AMD Radeon R9 290x achieved consistent performance improvements of up to 70% under DirectX 12, and in some scenarios the AMD outperformed the more powerful Nvidia under DirectX 12. The performance discrepancies may be due to poor Nvidia driver optimizations for DirectX 12, or even hardware limitations of the card which was optimized for DirectX 11 serial execution; however, the exact cause remains unclear.

The performance improvements of DirectX 12 on the Xbox are not as substantial as on the PC.

In March 2018, DirectX Raytracing (DXR) was announced, capable of real-time ray-tracing on supported hardware, and the DXR API was added in the Windows 10 October 2018 update.

In 2019 Microsoft announced the arrival of DirectX 12 to Windows 7 but only as a plug-in for certain game titles.

### DirectX 12 Ultimate
Microsoft revealed DirectX 12 Ultimate in March 2020. DirectX 12 Ultimate will unify to a common library on both Windows 10 computers and the Xbox Series X and other ninth-generation Xbox consoles. Among the new features in Ultimate includes DirectX Raytracing 1.1, Variable Rate Shading, which gives programmers control over the level of detail of shading depending on design choices, Mesh Shaders, and Sampler Feedback.

### Version history 
The version number as reported by Microsoft's DxDiag tool (version 4.09.0000.0900 and higher) use the x.xx.xxxx.xxxx format for version numbers. However, the DirectX and Windows XP MSDN page claims that the registry always has been in the x.xx.xx.xxxx format. Therefore, when the above table lists a version as '4.09.00.0904' Microsoft's DxDiag tool may have it as '4.09.0000.0904'.

## Compatibility
Various releases of Windows have included and supported various versions of DirectX, allowing newer versions of the operating system to continue running applications designed for earlier versions of DirectX until those versions can be gradually phased out in favor of newer APIs, drivers, and hardware.

APIs such as Direct3D and DirectSound need to interact with hardware, and they do this through a device driver. Hardware manufacturers have to write these drivers for a particular DirectX version's device driver interface (or DDI), and test each individual piece of hardware to make them DirectX compatible. Some hardware devices have only DirectX compatible drivers (in other words, one must install DirectX in order to use that hardware). Early versions of DirectX included an up-to-date library of all of the DirectX compatible drivers currently available. This practice was stopped however, in favor of the web-based Windows Update driver-update system, which allowed users to download only the drivers relevant to their hardware, rather than the entire library.

Prior to DirectX 10, DirectX runtime was designed to be *backward compatible* with older drivers, meaning that newer versions of the APIs were designed to interoperate with older drivers written against a previous version's DDI. The application programmer had to query the available hardware capabilities using a complex system of "cap bits" each tied to a particular hardware feature. Direct3D 7 and earlier would work on any version of the DDI, Direct3D 8 requires a minimum DDI level of 6 and Direct3D 9 requires a minimum DDI level of 7.
However, the Direct3D 10 runtime in Windows Vista cannot run on older hardware drivers due to the significantly updated DDI, which requires a unified feature set and abandons the use of "cap bits".

Direct3D 10.1 introduces "feature levels" 10_0 and 10_1, which allow use of only the hardware features defined in the specified version of Direct3D API. Direct3D 11 adds level 11_0 and "10 Level 9" - a subset of the Direct3D 10 API designed to run on Direct3D 9 hardware, which has three feature levels (9_1, 9_2 and 9_3) grouped by common capabilities of "low", "med" and "high-end" video cards; the runtime directly uses Direct3D 9 DDI provided in all WDDM drivers. Feature level 11_1 has been introduced with Direct3D 11.1.

### .NET Framework
In 2002, Microsoft released a version of DirectX compatible with the Microsoft .NET Framework, thus allowing programmers to take advantage of DirectX functionality from within .NET applications using compatible languages such as managed C++ or the use of the C# programming language. This API was known as "Managed DirectX" (or MDX for short), and claimed to operate at 98% of performance of the underlying native DirectX APIs. In December 2005, February 2006, April 2006, and August 2006, Microsoft released successive updates to this library, culminating in a beta version called Managed DirectX 2.0. While Managed DirectX 2.0 consolidated functionality that had previously been scattered over multiple assemblies into a single assembly, thus simplifying dependencies on it for software developers, development on this version has subsequently been discontinued, and it is no longer supported. The Managed DirectX 2.0 library expired on October 5, 2006.

During the GDC 2006, Microsoft presented the XNA Framework, a new managed version of DirectX (similar but not identical to Managed DirectX) that is intended to assist development of games by making it easier to integrate DirectX, HLSL and other tools in one package. It also supports the execution of managed code on the Xbox 360. The XNA Game Studio Express RTM was made available on December 11, 2006, as a free download for Windows XP. Unlike the DirectX runtime, Managed DirectX, XNA Framework or the Xbox 360 APIs (XInput, XACT etc.) have not shipped as part of Windows. Developers are expected to redistribute the runtime components along with their games or applications.

No Microsoft product including the latest XNA releases provides DirectX 10 support for the .NET Framework.

The other approach for DirectX in managed languages is to use third-party libraries like:

* SlimDX, an open source library for DirectX programming on the .NET Framework
* SharpDX, which is an open source project delivering the full DirectX API for .NET on all Windows platforms, allowing the development of high performance game, 2D and 3D graphics rendering as well as real-time sound applications
* DirectShow.NET for the DirectShow subset
* Windows API CodePack for .NET Framework , which is an open source library from Microsoft.

## Alternatives
There are alternatives to the DirectX family of APIs, with OpenGL, its successor Vulkan, Metal and Mantle having the most features comparable to Direct3D. Examples of other APIs include SDL, Allegro, OpenMAX, OpenML, OpenAL, OpenCL, FMOD, SFML etc. Many of these libraries are cross-platform or have open codebases. There are also alternative implementations that aim to provide the same API, such as the one in Wine. Furthermore, the developers of ReactOS are trying to reimplement DirectX under the name "ReactX".

## See also
* Direct3D
* DxDiag
* Graphics Device Interface (GDI)
* Graphics pipeline
* Vulkan

## References
## External links
* Microsoft's DirectX developer site
* The State of DirectX 10 - Image Quality & Performance