327 points · by emidoots · 2y ago · 108 comments
If the Mach team can pull off this whole "Zig as a cross-3D-API shader compiler" and make it work as smoothly as "Zig as a cross-compilation toolchain", then this would be pretty much the biggest thing in computer graphics since 1995 or so :)
And a major boost for Zig -- both as a language and a toolchain.
Why not? Doesn't that just mean that nobody has implemented it yet?
There are "source code" files in zip and tar.gz
Aren't those source code for those dlls?
Yes. Yes I want my GPU, wifi and bluetooth to work. Get over yourselves and leave that checkbox checked by default.
I have no clue why they did this. I work for MS and I'm as annoyed about it as anyone.
Edit: apparently dxil.dll is not part of DXC (the classic move to make "open source" software dependent on external proprietary garbage, apparently.) But I'd still doubt it's a managed DLL.
Many video games already do this with all the proprietary middleware they use (Bink, SpeedTree, PhysX, etc). Most launchers (Steam, GOG, Epic, etc) also require their respective .DLLs. Many games also use D3D11On12. Many shipping games in my list have dxil.dll amongst their installed files.
Therefore, an honest question: what's the problem with shipping an additional DLL? The work done here to reverse-engineer and re-implement the code-signing is fantastic—especially the fact that it is bitwise equal to dxil.dll's output. But I am ridiculously lazy and prefer to take the easier way out, and would've just shipped the DLL.
In addition, even for AAA games (but also for other games and software, this adds extra dependencies that may be broken outside your control. At a company i worked several years ago, we spent more effort upgrading Visual Studio because for some middle we only had DLLs (and their libraries) to link against and had to obtain new versions (part of the effort was that the company that wrote said middleware hadn't upgraded their own so we also became QA for their compatibility with the newer VS, though i don't remember if there were any issues in practice).
Of course having the code doesn't mean updates will be frictionless, but there will certainly be way less friction and you wont need to wait for someone else.
(btw i think Visual Studio has tried to be backwards compatible in recent versions with binary C++ libraries, but i don't think this is something you can rely on in the long term)
Also all that are with the assumption that the requirement is that your code remain on the same platform and targets. But at some point you may want to work with another platform (be it as host or target) and not having source code can make that from incredibly difficult to impossible. This may not seem much of an issue for something as platform-specific as DXIL - but actually notice the article mentioning that the binary blobbiness of DXIL made it impossible to precompile shaders on platforms outside specific Windows and Linux architectures for which the DLL was provided by Microsoft.
1: https://github.com/hexops/DirectXShaderCompiler/blob/4190bb0...
Anyone paying attention in the article to that point knew it had to be some basic hash or similar, where even in your worst case someone has to reverse engineer some assembly.
After all that effort, just out Microsoft, particularly when we're talking about opensource code that anyone that cares to can just dig through and find (thanks for that, msk!).
I think it's for plausible deniability in case M$ ever comes after them for RE reasons. They probably want to be able to say that they didn't use the proprietary blob in order to implement their own code signing.
"dxil.dll is closed-source, so we cannot simply patch it in the same way. To fix this, we outright disable runtime loading of dxil.dll and silence warnings related to it not being present / the final binary not being code signed. Instead, once the compiler would emit a compiled shader blob, we perform our own code signing algorithm (Mach Siegbert Vogt DXCSA) which results in a bitwise identical compiled shader, and thus dxil.dll is no longer needed to perform code signing of shaders."
[1] https://github.com/hexops/DirectXShaderCompiler/commit/7a013...
https://github.com/baldurk/renderdoc/blob/4a620bb5a16b4de4e2...
It sort of works if your signing tool is part of a private console SDK, but the DirectX SDK was always freely available.
I appreciate this quote[0] from the microsoft camp. Setting clear expectations that something will not be done is a nice bit of fresh air.
[0] https://github.com/microsoft/DirectXShaderCompiler/issues/57...
From my experience, it's been disappointing. Big, complex to setup, not convinced about many tradeoffs.
In vkd3d (from wine), I think you have a DXIL->SPIR-V translater (much more robust than any high level shading language converter since it is a much more simple intermediate language).
That said, apart from this abomination of llvm, is there a HLSL->DXIL compiler written in plain and simple C99 (namely which require NOT gcc or clang to compile)?
That said, vkd3d(wine) is plain and simple C, and I suspect that mesa tool to be part of microsoft "push" in mesa, dirtying it with c++.
Also to answer your question, no. The hlsl to dxil translation is basically owned by microsoft. There's been little effort to move away from that
I am perfectly aware this will require a bit more upfront work to write shaders, but due to their life cycle, it should be benign and we should get all the benefits (not even mentioning to free the SDK dependency from a massive and complex high level shading language compiler).
I am going to give it a try. I need first a SPIR-V assembler, the one from the khronos spriv tools and the one from llvm are c++ diarrhea then a definitive nono, have to write my own. Let's think long run here: we don't have a _REAL_ standard very high level language yet (python? lua? javascript? perl5? ruby? so_many_others?), I'll go rv64 assembly then (I'll write a mini rv64 interpreter for x86_64).
That above is the real magic. Since he won't comment on the how, I guess he took a swing at poping the hood underneath, and did exactly what Wine developers did 2 decades ago. Any old timers here remembering that scandal? Smart kid to not comment on the how, this way Microsoft won't have any legal leg and since times have changed with all that "Microsoft loves Linux" shit they yell at all corners (not that I believe that for a single second), then it will be swept all under the rug and FOSS wins. For now.
The way signing is done is already public knowledge that can be found using google as other open source projects have implemented it.
[1] https://github.com/hexops/DirectXShaderCompiler/blob/4190bb0...
This one hits the nail on the head, and the reason why not just Microsoft, but a lot of large software players are not incentivized to create better software.
At the end of the day, people like power, to make money, and the people at Microsoft are no exception. And businesses are businesses, enterprises to make money, not altruistic benefactors of humanity, or optimizers of a specific domain, like software. So what business will do are their original thing AND business tactics, and the larger the business, the more tactics they have to employ, otherwise they won't be as large, or even simply won't be, at all. So, on the top, it's all ruthless business tactics. As Microsoft is a large player for a long time, they have quite the rep sheet[0], but they are not unique in doing this. It's the name of the game.
[1] Case in point: glibc's compatibility guarantees are weaker than what you get on Windows. (For instance, your system's glibc cannot be older than what a game is built against, which may present problems for devs using Fedora/Arch and players on Debian/LTS Ubuntu, something I've experienced first-hand for my apps.) The X11 to Wayland migration is also still underway. (Though things are getting better, the attitudes of some Wayland maintainers are a bit concerning: "I don't [care] what you think is normal behavior for games. You get certain guarantees with wayland. Deal with it. If clients decide to do exactly what they do on windows or X11 they won't work correctly." [3] I'm not sure game developers would enjoy such reception.)
[2] https://store.steampowered.com/hwsurvey
[3] https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/18...
Imagine games that dynamically link some library (or glibc). They wouldn’t run on other Linux distributions with mismatching dependencies (or a different libc).
Sure, 100% statically linked binaries might work. But wine also runs on non-Linux.
Windows is a sufficiently homogeneous target, and wine works well enough. Heck, some games run better in Linux+Wine than they do in windows.
'Most' just want their browser to behave like always anyway.
Microsoft uses this software to make their own video games. They have a very vested interest in making any software they use better.
And then the same can be said about a lot of Microsoft products. DirectX is no different; it's the canonical Microsoft piece of shit, and that goes all the way back to the OpenGL days [1].
[1] https://www.gamedeveloper.com/programming/why-you-should-use...
Are you saying this as a qualitative statement, or as an emotional and irrational outpouring of hate?
By qualitative, I mean things like performance, compatibility, UI/UX, programmability, software design, etc.
Somehow I doubt it's the former...
Are you responding to the wrong comment?
To bring you back into the fold, we are discussing how Microsoft writes video games and therefor has a very vested interest in making their shader compiler as good as possible because their games use it.
At no point were we discussing dual booting to another OS. I have to be honest, I have no idea how you got to there from a shader compiler discussion :)