Why is there no DirectX API for Linux?
Asked Answered
R

7

24

Upon considering the driver side implementation for DirectX API on windows systems for modern video cards I was wondering why this implementation is not available on non-windows system, most notably linux.

Since there is an obvious absence of this functionality I can only assume there is a good reason which I am blind to, but in my primitive understanding I simply see the DirectX calls as no more than function entry points on the hardware device. And for the record I am not referring to a compatibility layer (most notably WINE, a project I am amazed by every single day) but a library making direct hardware calls.

Is it possible to create an open source version of directx? Would it be possible but obscenely difficult?

Ritornello answered 20/6, 2012 at 13:57 Comment(6)
There is no "absence of this functionality". Linux provides other, non-Microsoft non-proprietary graphics APIs.Impoverished
@BenVoigt You've entirely missed the point of the question. He's not asking about accelerated 3D graphics rendering functionality, which Linux does have, but about DirectX functionality, which it doesn't.Domesday
DirectX is ProPrIeTarY™.Hullo
Because DirectX is proprietary software licensed by Microsoft. Why would Microsoft make this available on a non Windows operating system and in the process give reasons to potential customers to not use their os? There could be reasons like that in the future, but I sincerely doubt it.Cravens
devblogs.microsoft.com/directx/directx-heart-linux may be it is changingRealistic
world-today-news.com/…Realistic
A
20

AFAIK, the DirectX contains 3 parts

  • Vendor driver (provide low level API defined by DX)
  • DirectX library (use low level API defined by DX to access hardware, provide DirectX API)
  • Software (use DirectX API, ex. game)

There are no driver providing the low level API defined by DX on linux, so even it is possible to provide the DirectX library, but it won't work without proper vendor driver, and I can't see if there is any vendor is going to create one for their hardware platform.

Aurelioaurelius answered 20/6, 2012 at 14:14 Comment(0)
S
8

Why not just use OpenGL? It supports all the functionality that DirectX does. Do you have a specific reason to use DirectX? As for a reason, Microsoft made DirectX and I guess they didn't see any need to allow it to run on Linux.

You can run DirectX games in Linux using Wine. You can program XNA on Linux using MonoGame. But all of these use OpenGL to provide hardware-accelerated rendering. AFAIK, OpenGL has been (and probably will be) the only option on Linux for the foreseeable future.

Is it possible to write your own DirectX implementation? Sure - but it involves writing drivers, proprietary knowledge and probably too much cost for anyone to REALLY benefit from it.

EDIT: These days, DXVK is a very real and performant way to run DirectX applications on Linux.

Severity answered 20/6, 2012 at 14:10 Comment(1)
The question comes from a usability standpoint, not so much a development one. If the gaming industry is using DirectX, then I would like to know what impediments there are for the gaming industry to port existing games to linux. Using the exact same hardware, I can run a game natively in one OS, but not the other, so in my naivete I would like to imagine it's as simple as writing the API layer and then passing everything off to the drivers. Obviously this does not exist so my understanding is wrong, I just want some clarification.Ritornello
G
3

DirectX is a suit of API's:

  • Direct3D (drawing 3D graphics)
  • DirectX Graphics Infrastructure (enumerating adapters and monitors and managing swap chains)
  • Direct2D (drawing 2D graphics)
  • DirectWrite (fonts)
  • DirectCompute (GPU Computing)
  • DirectSound3D (playback of 3D sounds)
  • DirectX Media (DirectAnimation for 2D/3D web animation, DirectShow for multimedia playback and streaming media, DirectX Transform for web interactivity, and Direct3D Retained Mode for higher level 3D graphics)
  • DirectX Diagnostics (tool for diagnosing and generating reports on components related to DirectX, such as audio, video, and input drivers)
  • DirectX Media Objects (support for streaming objects such as encoders, decoders, and effects)
  • DirectSetup (installation of DirectX components, and the detection of the current DirectX version)

DirectX components deprecated, but still supported

  • DirectDraw
  • DirectInput
  • DirectPlay
  • DirectSound
  • DirectMusic

As you can see many parts of the DirectX suit of API's would need to be rewritten with functionality for Drivers written for Linux. Also some parts of the DirectX suit are likely going to make calls to the Windows OS and that code would have to rewritten for a Linux machine without infringement of the copy-written parts of either DirectX or the Windows OS.

Yes you could write a open source API suit which does the same kind of thing as DirectX for Linux, however without a great knowledge of sound and graphic drivers/support by their manufactures for Linux, it would be a very hard task to do.

However if you question was more of a "Can I get/write something to be able to run games and programs made with DirectX to run on Linux?" in it's meaning, in short no due to more likely copyright infringement.

Gourmand answered 29/12, 2014 at 9:2 Comment(0)
S
3

Your question is wrong in 2019. DXVK is an implementation of D3D11 and D3D10 implementation for Linux using Vulkan and Wine

Also mesa has native Direct3D 9 implementation but in my knowledge, no one uses it except wine

Scoundrelly answered 28/1, 2019 at 13:30 Comment(2)
There has also, for a long time, been an implementation of DirectX in WINE on top of OpenGL.Crosspollinate
dxvk is now also an implementation of d3d9Pummel
A
2

The work to create a port for DirectX would create the same problems as you encounter in WINE. It will never be the same as on Windows. Derived from that principle you would have to look into OpenGL and related multi-platform libraries.

At this very moment WINE would be your closest medium if you want to accomplish something with DirectX code you already have. Then again, I'm not sure in what manner Visual Studio or plain typing would get you closer yo a fluent environment. The WINE libraries aren't that far from native, but there always exists emulation, what is acceptable to a certain point in my honest opinion.

If I look at how superbly Final Fantasy XIV ran on full settings on my iMac (2011) I think it's not that bad to rely on WINE's implementation. The game exactly rendered as on Bootcamp (Windows) on my iMac.

If you really want to make work on this front you could try to ask WINE Devs at their forums or mailing lists how you could maybe use the implementation of their DirectX compatibility only and use that in your project. Where you maybe can call libraries instead of requesting DirectX through Windows-emulated system calls.

Edit: I fully agree with user956030's answer too.

Acetyl answered 20/6, 2012 at 15:20 Comment(0)
P
0

DirectX is a propriety products designed for Microsoft targets, so for this to happen would be very unusual

There are two other pieces of software that come to mind, SDL and OpenGL

OpenGL provides the hardware alternative to DirectX, and SDL works with OpenGL to provide the software support you would expect from DirectX

Patinated answered 23/4, 2017 at 17:23 Comment(0)
S
0

Since 2020, Microsoft has been working to port DirectX 12 to WSL2, which is being done in this repository. In a mailist, Steve Pronovost commented that they might work to port this driver to Linux to have it running natively.

However, in order to do this, they would need to implement the driver on top of the kernel's DRM stack, which itself needs to be modified if they want to keep the driver similar to the Windows one and have related APIs.

There is some effort being done in the Mesa library as well, to support D3D12 within itself, the main purpose being to optimize server-sided GPU calculations that are heavily used in machine learning algorithms.

Even though this is great, it's unlikely that we will ever see any advantage running Windows games on Linux with that driver. The open source community would only have the upper ground if more games start supporting Vulkan, which is faster and better than DirectX, there had been experiments where using DXVK on Windows would be faster than DirectX 9 or even 11, such as the one mentioned here, but DXVK tends to be less reliable and more prone to errors and crashes.

Stephie answered 12/5, 2022 at 1:52 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.