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
https://bugs.winehq.org/show_bug.cgi?id=54736
--- Comment #1 from Nikolay Sivov bunglehead@gmail.com --- Hi, Ethan.
Could you attach a test shader that looks similar to what you're using for mojoshader?
https://bugs.winehq.org/show_bug.cgi?id=54736
--- Comment #2 from Ethan Lee flibitijibibo@gmail.com --- Created attachment 74244 --> https://bugs.winehq.org/attachment.cgi?id=74244 Sample HLSL
Attached is a small shader that replicates the sort of ternaries MojoShader generates. It can be tested via...
`fxc.exe /T ps_4_0 test.hlsl`
`vkd3d-compiler -p ps_4_0 test.hlsl -b dxbc-tpf -o test.dxbc`
https://bugs.winehq.org/show_bug.cgi?id=54736
Nikolay Sivov bunglehead@gmail.com changed:
What |Removed |Added ---------------------------------------------------------------------------- Ever confirmed|0 |1 Status|UNCONFIRMED |NEW
--- Comment #3 from Nikolay Sivov bunglehead@gmail.com --- Thanks, I posted two separate fixes for this:
https://gitlab.winehq.org/wine/vkd3d/-/merge_requests/139 https://gitlab.winehq.org/wine/vkd3d/-/merge_requests/140
https://bugs.winehq.org/show_bug.cgi?id=54736
--- Comment #4 from Ethan Lee flibitijibibo@gmail.com --- Tested both patches together and they appear to fix the issue, thanks! Can continue to test further revisions if needed, otherwise this can be resolved when merged.
https://bugs.winehq.org/show_bug.cgi?id=54736
--- Comment #5 from Nikolay Sivov bunglehead@gmail.com --- This one is fixed now, https://source.winehq.org/git/vkd3d.git/commit/c190c184ce88fb5f2ac5d4c289cbf.... Ideally we'll need another report for input semantic issue.
https://bugs.winehq.org/show_bug.cgi?id=54736
--- Comment #6 from Ethan Lee flibitijibibo@gmail.com --- Filed a separate report for SV_IsFrontFace:
https://bugs.winehq.org/show_bug.cgi?id=54796
https://bugs.winehq.org/show_bug.cgi?id=54736
Nikolay Sivov bunglehead@gmail.com changed:
What |Removed |Added ---------------------------------------------------------------------------- Status|NEW |RESOLVED Fixed by SHA1| |c190c184ce88fb5f2ac5d4c289c | |bf5f1799e453b Resolution|--- |FIXED
--- Comment #7 from Nikolay Sivov bunglehead@gmail.com --- Marking fixed.
https://bugs.winehq.org/show_bug.cgi?id=54736
Nikolay Sivov bunglehead@gmail.com changed:
What |Removed |Added ---------------------------------------------------------------------------- Status|RESOLVED |CLOSED
--- Comment #8 from Nikolay Sivov bunglehead@gmail.com --- Closing bugs fixed in 1.9.