Bug 97338 - Black squares in the Spec Ops: The Line chapter select screen
Summary: Black squares in the Spec Ops: The Line chapter select screen
Status: RESOLVED FIXED
Alias: None
Product: Mesa
Classification: Unclassified
Component: Drivers/Gallium/radeonsi (show other bugs)
Version: git
Hardware: Other All
: medium normal
Assignee: Default DRI bug account
QA Contact: Default DRI bug account
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2016-08-14 01:09 UTC by Daniel Scharrer
Modified: 2017-03-22 21:08 UTC (History)
0 users

See Also:
i915 platform:
i915 features:


Attachments
Screenshot showing the bug (frame 89) (155.85 KB, image/jpeg)
2016-08-14 01:09 UTC, Daniel Scharrer
Details
Screenshot showing the bug (frame 91) (2.33 MB, image/jpeg)
2016-08-14 01:10 UTC, Daniel Scharrer
Details
Problematic fragment shader (5.82 KB, text/plain)
2016-09-02 12:54 UTC, Nicolai Hähnle
Details

Description Daniel Scharrer 2016-08-14 01:09:11 UTC
Created attachment 125773 [details]
Screenshot showing the bug (frame 89)

With radeonsi the chapter select screen in Spec Ops: The Line has black squares that should not be there. I have not observed this bug elsewhere in the game (but haven't played through the whole game using radeonsi).

The number of squares increases with a higher texture quality setting. The number and positions of the squares only changes when the camera moves.

The chapter select screen renders fine using the amdgpu-pro driver - tested with version 16.30.3.306809 running on the upstream amdgpu kernel module.

Apitrace:
 http://constexpr.org/tmp/SpecOps-radeonsi.trace.xz (70 MiB)

This bug seems to be caused by pixels with NaN values that make it into the framebuffer and are extended to larger squares by a later post-processing pass: After draw call 1441551, pixel (875, 573) of the COLOR0 attachment has RGB components set to NaN.

GPU: R9 380X (tonga)
Kernel: 4.7.0-gentoo
Mesa: git-561fd22
LLVM: r278309
Comment 1 Daniel Scharrer 2016-08-14 01:10:52 UTC
Created attachment 125774 [details]
Screenshot showing the bug (frame 91)

May or may not be related to bug #90481 - I haven't seen any gpu lockups or crashes in the menu.
Comment 2 Nicolai Hähnle 2016-09-02 10:21:01 UTC
Hi Daniel, thank you for the detailed report and the initial investigation! I can indeed reproduce this (including the NaN values) on Polaris.
Comment 3 Nicolai Hähnle 2016-09-02 12:54:40 UTC
Created attachment 126172 [details]
Problematic fragment shader

Okay, so here's a bit more detail of what is happening: the attached fragment shader (shader object 31) samples a 2D vector from PSampler2 (texture object 3153) and does some computations on it involving inversesqrt, under the assumption that the dot product of the vector is <= 1. This is false: looking at level 0 of texture 3153 reveals e.g. a unorm value (142, 255) at texel 155,263.

The likely cause here is that this is a port from D3D, which specifies that rsq should take the absolute value of its argument, to GLSL, which says that inversesqrt is undefined for values <= 0.
Comment 4 Nicolai Hähnle 2016-09-02 13:10:36 UTC
I've raised this issue with Virtual Programming.
Comment 5 Marek Olšák 2016-11-23 21:45:58 UTC
If it's undefined, doing abs is probably a good idea to at least reduce the number of bug reports.
Comment 6 Samuel Pitoiset 2017-01-05 16:48:16 UTC
A possible fix here: https://lists.freedesktop.org/archives/mesa-dev/2017-January/139686.html
Comment 7 Samuel Pitoiset 2017-01-10 22:36:53 UTC
People might be interested by https://github.com/virtual-programming/specops-linux/issues/20
Comment 8 Aaron Paden 2017-01-23 08:48:50 UTC
(In reply to Samuel Pitoiset from comment #6)
> A possible fix here:
> https://lists.freedesktop.org/archives/mesa-dev/2017-January/139686.html

I get a build failure after applying this patch:

si_shader_tgsi_alu.c: In function ‘emit_rsq’:
si_shader_tgsi_alu.c:759:43: error: ‘TGSI_OPCODE_ABS’ undeclared (first use in this function)
  abs = lp_build_emit_llvm_unary(bld_base, TGSI_OPCODE_ABS,
                                           ^~~~~~~~~~~~~~~
si_shader_tgsi_alu.c:759:43: note: each undeclared identifier is reported only once for each function it appears in
make[4]: *** [Makefile:701: si_shader_tgsi_alu.lo] Error 1
Comment 9 Samuel Pitoiset 2017-01-23 10:47:28 UTC
Makes sense. TGSI_OPCODE_ABS has been removed after this patch, but it fixes the issue (I tested myself). The patch is still pending for some reasons, I will let you know when something change.


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.