What is DirectX11/12 and how does it work?
DirectX is a graphics abstraction layer between a piece of software, typically a video game, and the hardware that helps simplify the code necessary to draw something to the screen.
There are several layers of abstraction. At the top you’ve got the program (game) and it’s making calls to DirectX, DirectX is working with the Operating System to make calls to the Graphics Driver (software that is specific to a certain piece of installed hardware), the Graphics Driver is then doing what it needs to execute the requested commands on the hardware.
Different parts of a computer need to have a standardized way of talking to each other in order to control for the fact that there are thousands of configurations of computers and what exact constellation of components from various manufacturers they have.
Directx is Microsoft’s brand of graphics API for the Windows operating system (if you’ve heard of Vulkan, that’s an open source alternative that’s picking up steam) and the communication goes a little something like this:
Your game is a program running in a little box set up by your operating system, your operating system has given it some access to resources inside of its box in the form of that API. Now, with that API the game can issue commands to your graphics card about rendering models, textures and shades to make the actual pictures on your screen.
As to the difference between the versions, that’s gets into the wonkiness that is PC compatibility. You see, whenever AMD, Intel, or Nvidia come out with a graphics processor (integrated or discrete) that processor and its drivers (API but for the operating system to talk to the silicone) that chip will only be able able to do what was built into it (see ray tracing functionality) which means that when new versions of Directx are released that have new commands in them old silicone won’t know what to do with those commands. You can put old hardware together, but it has limits as to what it will be capable of.
On the other end, if you take an old game it can get a kinda funny. Say you booted up the original Half Life on a modern PC, which was around the time of DirectX 6, it will run just fine despite the 6 versions of difference. Now, your initial guess might be that 12 contains all of 6, but that’s not true. What is true is that 12 contains formulas for how to condense multiple instructions from older versions into shorter, faster instructions to run on modern hardware.
Is 12 better? Kind of? It’s hard to say at this point. If you look at early Xbox 360 games and later ones you can see a marked increase in graphical quality on the same hardware because devs got better at using the console and understood it better. So as it stands right now, 11 is trid and true, but 12 will overtake it in the not to distant future. Just like it took a bit for studios to get good at implementing Ray tracing in games to make it both look nice and run well.
TL;DR DirectX is an API, and APIs are dictionaries for computers or parts of a computer to talk to each other.
DirectX is an ***API,*** or application programming interface.
It’s essentially a set of tools that helps your graphics hardware communicate with your operating system. It essentially “tells” your GPU how to draw the graphics.