Created attachment 140691 [details]
One of the affected shaders (GLSL version)
when building Mesa with LLVM 7.0-svn, OpBitfieldUExtract sometimes returns the original source operand instead of zero when the bit count is zero. With LLVM 6.0.1, it works as expected.
This causes the following bug in DXVK:
Here's a renderdoc capture (recorded on Polaris) showing the issue:
The attached shader is a GLSL version of the vertex shader used in the bookmarked draw call. I added some comments around like 220 for observed vs. expected behaviour of the shader code.
I tried to reproduce the problem outside of DXVK, but had no luck so far: A small demo app testing the GLSL bitfieldExtract function in a compute shader always returns the correct values.
Handling the count = 0 case explicitly in the NIR->LLVM translation fixes the issue in Far Cry 5.
Created attachment 140692 [details] [review]
Workaround that fixes the rendering issue
Created attachment 140693 [details]
Final image (correct)
Created attachment 140694 [details]
Final image (broken)
Created attachment 140695 [details]
Demo app that does not trigger the problem
I used this small sample app in an attempt to reproduce the problem, but for me it always returns 0 for the count=0 case for some reason.
Please note that the queue family and memory type indices are hardcoded.
Should be fixed with
*** Bug 107156 has been marked as a duplicate of this bug. ***