Bug 107276 - radv: OpBitfieldUExtract returns incorrect result when count is zero
Summary: radv: OpBitfieldUExtract returns incorrect result when count is zero
Status: RESOLVED FIXED
Alias: None
Product: Mesa
Classification: Unclassified
Component: Drivers/Vulkan/radeon (show other bugs)
Version: git
Hardware: Other All
: medium normal
Assignee: mesa-dev
QA Contact: mesa-dev
URL:
Whiteboard:
Keywords:
: 107156 (view as bug list)
Depends on:
Blocks:
 
Reported: 2018-07-18 13:30 UTC by Philip Rebohle
Modified: 2018-07-23 08:57 UTC (History)
2 users (show)

See Also:
i915 platform:
i915 features:


Attachments
One of the affected shaders (GLSL version) (16.75 KB, text/plain)
2018-07-18 13:30 UTC, Philip Rebohle
Details
Workaround that fixes the rendering issue (1009 bytes, patch)
2018-07-18 13:31 UTC, Philip Rebohle
Details | Splinter Review
Final image (correct) (4.69 MB, image/png)
2018-07-18 13:32 UTC, Philip Rebohle
Details
Final image (broken) (3.41 MB, image/png)
2018-07-18 13:32 UTC, Philip Rebohle
Details
Demo app that does not trigger the problem (3.67 KB, application/x-bzip)
2018-07-18 13:35 UTC, Philip Rebohle
Details

Description Philip Rebohle 2018-07-18 13:30:47 UTC
Created attachment 140691 [details]
One of the affected shaders (GLSL version)

Hello,

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:
https://github.com/doitsujin/dxvk/issues/497

Here's a renderdoc capture (recorded on Polaris) showing the issue:
https://mega.nz/#!8W5nDTxT!P7PI4BZ_gpmZDIoh1Iziq0PHpLp448hiUqJN9iEhukg

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.

Regards,
- Philip
Comment 1 Philip Rebohle 2018-07-18 13:31:17 UTC
Created attachment 140692 [details] [review]
Workaround that fixes the rendering issue
Comment 2 Philip Rebohle 2018-07-18 13:32:01 UTC
Created attachment 140693 [details]
Final image (correct)
Comment 3 Philip Rebohle 2018-07-18 13:32:20 UTC
Created attachment 140694 [details]
Final image (broken)
Comment 4 Philip Rebohle 2018-07-18 13:35:23 UTC
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.
Comment 6 Gregor Münch 2018-07-23 08:57:41 UTC
*** Bug 107156 has been marked as a duplicate of this bug. ***


Use of freedesktop.org services, including Bugzilla, is subject to our Code of Conduct. How we collect and use information is described in our Privacy Policy.