Sorry if this is a stupid question. What would it take to get DirectX on Linux?

Started by
24 comments, last by MJP 11 years, 5 months ago
Again sorry if this question is inane.

But I'm a gamer, the only reason I run Windows is because I have to to play Games on it.
If I could run windows games directly on a Linux OS, id go Ubuntu in a heartbeat.

The reason is ofc resources, Ive got a kickass computer, but I also play top of the line games at maximum settings, Id love to not have to run the massive Windows OS as well as the game I'm playing.

Which is why Wine, or any other form of box simulation makes no sense, I certainly don't want to run a Linux Os, an OS emulator, and a massive Windows OS under the game I'm playing.

So whats the deal? Why cant DirectX be made for Linux? I get that its illegal, but when has that stopped the open source community?

I take the Question to this forum to ask the experts, is there a technical reason why DirectX can NEVER be applied to another OS?
Is it simple impossible?

-Exo
Advertisement
Wine is not an emulator.
That is, it doesn't emulate the bare hardware (the "box"), instead it reimplements the required windows libraries. So, in principle, it can be as fast as native Windows.. I don't know if DX in particular has been reimplemented or if the windows version is used on top of a more low-level interface.


I get that its illegal, but when has that stopped the open source community?


[citation needed] on that being illegal. IANAL, but I wouldn't see why. Also, most of the OSS community, and in particular the free software movement, base all their claims (think open licenses) on legal bases, so I think you have the wrong impression of them.

EDIT: I realized I wasn't being very helful above. If I were you I would try wine. Or the commercialy supported version of it, "CrossOver".
Why cant DirectX be made for Linux?
That's because of Microsoft. Anyways, there are so many games out there that are still written in OpenGL. Even the final version of Steam will soon head to Linux :)
Wine being as fast as Windows, would still mean id have to run windows, as well as running Ubuntu AND my game.
So while playing that is still one OS too many.

Everyone thought OpenGL would crush DirectX due to its open source nature, but ppl fail to realize the importance of the gaming community as a way to maintain OS monopoly, Microsoft didnt. Consider Games for Windows, this was way before Microsoft made any game, it was merely a marketing incentive for developers to keep making Windows games.

So am I to understand that the reason here is the legality, its proprietary software, Microsoft will sue, therefore its not done?
Is that It?
Or is there a more technical reason why its has not even been attempted since Windows 95?

-Exo
OpenGL isn't open source - an OpenGL implementation can be quite as proprietary as D3D (vendor specific extensions can make it even more so).

All that DirectX is is an interface between your program and the graphics hardware. That means it needs at least two components - the DirectX runtime that provides the common interface, and a hardware-specific driver that understands the interface and understands how to control the hardware with it (simplified explanation). Some parts of it are Windows-specific, such as the ties to the windowing system when creating a D3D device, but assuming that they can be sensibly emulated (e.g. by stuffing a pointer to the appropriate struct into a HWND) there is no good purely technical reason why it couldn't be implemented on any OS. However doing so wouldn't just require someone to implement the runtime; it would also require contributions from the hardware vendors to provide a driver.

It goes like this (again, simplified):
- Program makes a D3D call.
- Runtime takes that call and converts it to a lower-level representation.
- Vendor-specific driver takes that lower-level representation and passes it on to the hardware.
- Hardware actually does the drawing.

Where things break down is in transition from the second to third step, and in the third step itself. That's where it gets into vendor-specific stuff, and that's where the open source community on it's own can do nothing.

Right now the WINE approach of implementing it on top of OpenGL seems a more sensible route, at least one that's more likely to actually produce a result, as it sidesteps the need for vendors to provide a driver (there already is one - the OpenGL driver).

Direct3D has need of instancing, but we do not. We have plenty of glVertexAttrib calls.

There was an attempt two years ago with Gallium "Direct3D 10/11 Is Now Natively Implemented On Linux!", but not sure they have been working on it since then...

it would also require contributions from the hardware vendors to provide a driver.


Couldn't it instead point to an OpenGL driver... no wait I see the issue with that...

Ok thanks a lot mr. mhagain, and the rest of u for not laughing in my face but providing me with an honest straight forward answer to this.
smile.png

-Exo
The stuff that goes on between a D3D11 app and the GPU is actually pretty complicated. There's the D3D runtime provided by Microsoft, the user-mode and kernel-mode components of the driver, and a complex display driver model that forms the backbone of DXGI and D3D11. You'd have to somehow replace all of that if you wanted a D3D11 app to run on Linux, which is a monumental task if you're not doing it with the help of the hardware vendors. Intercepting D3D calls and translating them into OpenGL is a lot easier, but less efficient. But even then it's not always a simple mapping between the two API's.
Even if you got DirectX to run on Linux, that is hardly enough to run the game(s).
Games on Windows take input via a window’s message pump typically, which you would also have to emulate.
Which means you also have to emulate Windows’ windowing system itself and the message queue etc.

You would have to emulate WinSocks for any network games.

The executable itself won’t run natively on Linux. You would have to manually unpack (execute) it and somehow get its threads to start running.
Every API function they use from the Windows SDK would have to be replaced/emulated.


Basically you wouldn’t have a choice but to use a Windows emulator or something like Wine, at which point you are still running the Windows operating system and won’t see any improvement in performance.


L. Spiro

I restore Nintendo 64 video-game OST’s into HD! https://www.youtube.com/channel/UCCtX_wedtZ5BoyQBXEhnVZw/playlists?view=1&sort=lad&flow=grid


Again sorry if this question is inane.

But I'm a gamer, the only reason I run Windows is because I have to to play Games on it.
If I could run windows games directly on a Linux OS, id go Ubuntu in a heartbeat.

The reason is ofc resources, Ive got a kickass computer, but I also play top of the line games at maximum settings, Id love to not have to run the massive Windows OS as well as the game I'm playing.

Which is why Wine, or any other form of box simulation makes no sense, I certainly don't want to run a Linux Os, an OS emulator, and a massive Windows OS under the game I'm playing.

So whats the deal? Why cant DirectX be made for Linux? I get that its illegal, but when has that stopped the open source community?

I take the Question to this forum to ask the experts, is there a technical reason why DirectX can NEVER be applied to another OS?
Is it simple impossible?

-Exo


1) Wine is able to outperform Windows in many cases(Allthough it also falls very short from time to time), its not an emulator, its a re-implementation of the Windows APIs and effectivly tries to do the same job as the DX and Win32 APIs do on Windows, for Windows compatibility it really is the best solution(since there are tons of Windows system libraries that has to be re-implemented for full compatibility and Windows is a moving target). The alternative would be to go down the path of ReactOS and also re-implement the kernel interfaces in order to run Windows drivers but then it wouldn't be Linux anymore.

2) OpenGL provides the same features and equivalent performance as D3D or in the case of D3D9, better performance(or lower batch overhead really), D3D is not necessary in order to make games for any platform. (OpenGL only really fell out of favor because the ARB were so darn inefficient that it took years for key features to become standardized effectivly forcing developers who wanted to use OpenGL in AAA games to write separate codepaths for each hardware vendor) (This situation has improved greatly in recent years).

3) If you want performance in Linux you shouldn't use Ubuntu, it is reasonably bloated and its binaries are not optimized for modern CPUs (Windows also suffers from this problem), You should build from source with a new gcc version and -march=native (This will make your binaries unusable on older CPUs but allows them to take advantage of all the new instructions your CPU offers), or atleast use a distribution with a lightweight desktop enviroment.

From a legal point of view there is nothing preventing a DirectX version for Linux, APIs are not covered by copyright (atleast not according to the Oracle vs Google case), from a practical point of view it just isn't worth it, hardware vendors have nothing to gain by writing D3D drivers for Linux, the opensource drivers are so far behind performancewise that you'd get far better performance by using Wine with the proprietary drivers than you would with opensource D3D drivers (unless the opensource D3D drivers for some magical reason became much better than the opensource OpenGL drivers)
[size="1"]I don't suffer from insanity, I'm enjoying every minute of it.
The voices in my head may not be real, but they have some good ideas!

This topic is closed to new replies.

Advertisement