RADV: Visual glitches in Unreal Engine 5.2.1 when using material with anisotropy and light channel 2
Description
I have recently observed that when rendering a mesh containing a material that makes use of anisotropic lighting, visual glitches can occur on other objects in the scene, such as a simple plane with default material. These glitches appear to occur when the following two things are true about any visible mesh:
- The mesh has a material using anisotropy (i.e., anisotropic lighting). For example, the carbon fiber material provided as part of Unreal's car configurator sample.
- Under advanced lighting properties, the mesh has lighting channel 2 enabled.
Changing either of these parameters causes the glitch to disappear. The glitches appear upon objects regardless of their lighting channel properties; in other words, even if the plane being affected has only lighting channel 0 enabled, it still contains glitches. The glitches differ from run to run, and cover different portions of the object, but always create a horizontal stripe pattern, and the pattern is always oriented in such a way that the camera angle doesn't matter (stripes are perfectly horizontal regardless). The glitches are visible in both standalone builds and in the editor. Screenshots have been attached.
In some instances, the glitches appear briefly and then disappear. In other cases, the glitches are persistent.
The glitches are observed only when using RADV, but are not present when using AMDVLK. Likewise, when using Unreal's Vulkan RHI under Windows, the glitches do not appear.
Screenshots/video files
Steps to reproduce
I have prepared a minimal reproduction project available here:
https://github.com/bretternst/unreal-mesa-anisotropy-glitch
Load the project using Unreal Editor 5.2.1. Depending on how you've installed the Unreal editor, you may need to change the EngineAssociation field in the .uproject file to "5.2" before opening.
If the glitches do not immediately appear in the viewport, you can try running and stopping the project repeatedly. You can click on the scene's camera and observe black horizontal lines in the camera's little picture-in-picture viewport. Repeatedly clicking on the camera and then clicking on some other object seems to be a reliable way to make the horizontal lines appear. You can also build a standalone packaged build.
System information
- OS: Arch Linux
- GPU: Advanced Micro Devices, Inc. [AMD/ATI] Navi 21 [Radeon RX 6800/6800 XT / 6900 XT] [1002:73bf] (rev c1)
- Kernel version: 6.4.3-arch1-2 (current default Arch kernel)
- Mesa version: Mesa 23.1.3
- Desktop environment: GNOME
API captures (if applicable, optional)
I've included a gfxrecon capture of a brief run of a packaged build. Unfortunately, using gfxrecon appears to change the result (the plane is usually fully black instead of grey and glitched). However, it looks like some of the glitchy stripes are still visible on the little sphere in the middle, so hopefully this will be at least somewhat helpful.
gfxrecon_capture_20230717T135758.gfxr
Edit: unfortunately, it looks like trying to replay this gfxrecon capture just results in a black window for me.
Further information (optional)
I do not have any special RADV or ACO environment variables set. The issue was observed when using RADV, but did not occur when using AMDVLK.
The issue does reproduce with RADV_DEBUG=llvm
.