Daemon icon indicating copy to clipboard operation
Daemon copied to clipboard

Broken rendering on disc surface with Clang 14 and later with `-march=native`

Open illwieckz opened this issue 1 year ago • 17 comments

See that vega place in viewpos 486 -57 96 147 24, the wrong black triangles on the disc surface on the right:

Image

The bug disappears with r_deluxeMapping 0:

Image

I'm reproducing it with current master but I was already noticing the problems on commit 9352952a9a04a298c64b7f2360f92e3d5cf3169d. I don't know when the bug was introduced, but the Unvanquished 0.55.2 release build doesn't reproduce the bug.

illwieckz avatar Feb 06 '25 16:02 illwieckz

With what other settings? I can't reproduce this so far.

VReaperV avatar Feb 06 '25 22:02 VReaperV

I use the ultra preset. I'm running it on an AMD Radeon W7600 PRO on Mesa radeonsi 24.2.8 (LLVM 19.1.1).

illwieckz avatar Feb 06 '25 22:02 illwieckz

Still can't reproduce. Maybe a driver bug?

VReaperV avatar Feb 06 '25 22:02 VReaperV

Also, it may be some other setting really, since disabling deluxe mapping disables a bunch of other features too.

VReaperV avatar Feb 06 '25 22:02 VReaperV

@illwieckz Can you try on OGLP? Also, try with r_showDeluxeMaps 1, r_showNormalMaps 1, and r_showMaterialMaps 1 (separately) to see if any of those appear broken.

VReaperV avatar Feb 06 '25 23:02 VReaperV

Maybe a driver bug?

Maybe, but the release build isn't affected. I may do a bisect at some point.

illwieckz avatar Feb 06 '25 23:02 illwieckz

I don't think anything really changed there except making texture matrices 3x2.

VReaperV avatar Feb 07 '25 00:02 VReaperV

r_depthShaders 0 is a good thing to try with these bugs

slipher avatar Feb 07 '25 01:02 slipher

The texture matrix there is just an identity matrix, so it shouldn't be that. These triangles are also all part of the same surface. I wonder if this some different build of the map? Otherwise this bug would probably show up on other maps as well.

VReaperV avatar Feb 07 '25 01:02 VReaperV

I first seen that on a custom built map with custom engine branch, but then I reverted to stock released map and master engine branch to reproduce the bug before reporting it.

illwieckz avatar Feb 07 '25 01:02 illwieckz

I first noticed it on some Xonotic maps with similar geometry, Vega is just the first Unvanquished stock map I reproduced with, there is no reason other Unvanquished maps featuring the same kind of geometry would not be buggy as well.

illwieckz avatar Feb 07 '25 01:02 illwieckz

I reproduce it with Clang 20 and -march=native on a Zen 2 CPU, the bug is still there with fast math disabled.

Since the release wasn't built that way, that may not be a regression.

A release-like build with Clang 20 (not using -march=native) is not affected.

illwieckz avatar Feb 07 '25 02:02 illwieckz

Oh. Maybe it's some SIMD code breaking for triangle processing when loading the BSP, like the R_TBNtoQtangents()? Or a Clang bug.

VReaperV avatar Feb 07 '25 02:02 VReaperV

I starts breaking with Clang 14:

compiler status
Clang 20 ❌️
Clang 19 ❌️
Clang 18 ❌️
Clang 17 ❌️
Clang 16 ❌️
Clang 15 ❌️
Clang 14 ❌️
Clang 13 ✅️
Clang 12 ✅️
Clang 11 ✅️
Clang 10 ✅️

illwieckz avatar Feb 07 '25 02:02 illwieckz

https://github.com/DaemonEngine/Daemon/pull/1451#discussion_r1950673023 seems to suggest that R_TBNtoQtangents() may, indeed, be the issue here.

VReaperV avatar Feb 12 '25 08:02 VReaperV

This area of the floor is acted upon by patch stitching. Does the bug go away with r_stitchCurves 0? If so, it is probably caused by a use-after-free in patch stitching fixed in #1639.

slipher avatar Apr 05 '25 06:04 slipher

Hmm nope. I can reproduce with Linux + Clang 14 + disabling CPU_GENERIC_ARCHITECTURE + -march=native. Setting r_stitchCurves 0 reduces the number of big gaps from 4 to 2, but otherwise the bug looks the same. Fixing the memory bug doesn't do anything.

slipher avatar Apr 05 '25 06:04 slipher