https://bugs.winehq.org/show_bug.cgi?id=54736
Bug ID: 54736 Summary: MojoShader HLSL requires ternary operators Product: vkd3d Version: 1.7 Hardware: x86-64 OS: Linux Status: UNCONFIRMED Severity: normal Priority: P2 Component: hlsl Assignee: wine-bugs@winehq.org Reporter: flibitijibibo@gmail.com Distribution: ---
A quick note before the report: Many thanks to the vkd3d team for their work on the HLSL compiler, we have been using it as our Linux-native HLSL compiler for FNA and as of 1.7 we have commercial games running with it! The FNA community is very grateful for this work.
In testing games against the latest compiler, we found that one notable hlsl_fixme was ternary operators:
https://gitlab.winehq.org/wine/vkd3d/-/blob/57d92a15cf93d9448f2deb91a8614f9c...
MojoShader, our method for converting D3D9-era DXBC to other shader formats, uses ternaries in a number of ways:
- cnd/cmp operations - rsq/rcp operations (have to handle the division-by-zero case) - Translating SV_IsFrontFace to an equivalent VFACE value
This can be tested with the Linux-native version of Terraria on Steam, using the following process:
1. Download Terraria from the Steam client 2. Download https://fna.flibitijibibo.com/archive/fnalibs.tar.bz2, copy lib64/libFNA3D.so.0 into Terraria's lib64 folder 3. Copy the following libraries into Terraria's lib64 folder: - libdxvk_d3d11.so - libdxvk_dxgi.so - libvkd3d.so.1 - libvkd3d-shader.so.1 - libvkd3d-utils.so.1
As of writing, DXVK currently requires the latest development builds:
https://github.com/doitsujin/dxvk/actions/workflows/artifacts.yml?query=bran...
3. Run Terraria with /gldevice:D3D11 as a launch argument
With the vanilla binaries, you should be able to see the title screen and main menu! However, the in-game screen will be mostly black, since compiling the shaders with ternaries will fail. (Setting a breakpoint on hlsl_fixme is the easiest way to catch the issue.)
When we intentionally break MojoShader to avoid ternaries, the game appears to be okay, ignoring the whole "shader output is obviously incorrect" part:
https://twitter.com/flibitijibibo/status/1640136828433883139