Page 1 of 1

Broken geometry on macOS Intel

PostPosted: Sat Jun 15, 2019 9:00 am
by _mental_
I encountered a very specific hardware/driver issue, and I unable to fix it.

In very specific map spots with complex geometry, sector's floor and/or ceiling is rendered incorrectly.
The bug is limited to Intel Iris Pro integrated GPU and macOS. NVIDIA GPU in the same Mac isn't affected.


Somehow, it's tightly coupled with sky rendering. When sky is visible, everything is correct.
Both screenshots were taken in the same map spot with slightly different angle.


It's this map from Vinesauce Doom Mapping Contest II: Hellectric Boogaloo.
Code: Select allExpand view
-iwad doom2 -file +map map01 +warp 540 920 -nomonsters +noclip +god

With gl_no_skyclear CVAR set, broken geometry persists regardless of sky portal in view.
Curiously enough, Metal GPU capture in Xcode shows recorded frame without an issue.

At the moment, I have no idea what else I can check. Any advice will greatly appreciated.

Re: Broken geometry on macOS Intel

PostPosted: Sat Jun 15, 2019 11:29 am
by dpJudas
I'm not really sure what could be causing this. It renders the entire scene in one render pass where it switches between pipeline objects (unless flushed, but then its starts a new immediately after). Inside a single subpass (which we only have one) the render order is guaranteed without a need for the application to set up any barriers.

My best bet would be an uninitialized variable, or a state variable that doesn't get reset properly. But which one? It looks like on the first screenshot that some vertex gets the wrong position as the textures don't match. It doesn't look completely corrupted though as the texture change makes it seem like a different valid vertex got used instead. Which primitive draw type does the ceiling use?

Re: Broken geometry on macOS Intel

PostPosted: Sat Jun 15, 2019 11:38 am
by dpJudas
If the draw type for the ceiling is DT_TriangleFan there's also the possibility that this line doesn't get executed. It could perhaps leave it in a situation where the drawIndexed call isn't using DT_Triangles as expected. It might be worth extending it with a mPipelineKey.DrawType != DT_Triangles check, just in case that's the reason.

Re: Broken geometry on macOS Intel

PostPosted: Sun Jun 16, 2019 4:23 am
by _mental_
That broken ceiling is rendered via triangle list. Also, floor of the same sector uses triangles too, but it's rendered properly.

At first, I suspected a bug in MoltenVK or in specific render state we have for it.
Although, it's not the case as everything is rendered correctly on the same Mac using NVIDIA GPU.
Validation layers are silent regardless of active graphics hardware.

Re: Broken geometry on macOS Intel

PostPosted: Sun Jul 28, 2019 8:29 am
by _mental_
I tested with Vulkan Portability Implementation instead of MoltenVK, and the bug still persist.
The issue isn't caused by particular Vulkan implementation but most likely by Intel Metal driver.

Curiously enough, I found a workaround by occasional. Addition of the following code after this line fixes broken geometry.
Code: Select allExpand view
GetRenderState()->Draw(DT_TriangleStrip, 0, 0, false);

Calling VkRenderState::Apply() without "drawing" zero primitives didn't do the trick. Honestly, I have no idea what's going on here.

Re: Broken geometry on macOS Intel

PostPosted: Sun Jul 28, 2019 10:47 am
by dpJudas
My best theory right now is unfortunately still that VkRenderStateMolten::Draw might be messing up some state. It doesn't really match well with the evidence you've presented so far though. Only other theory I got is driver error, but that doesn't help us much. :(

Re: Broken geometry on macOS Intel

PostPosted: Sun Jul 28, 2019 11:15 am
by _mental_
Overridden Draw() in VkRenderStateMolten doesn’t explain why it works correctly with NVIDIA GPU.
Actually, I can play with this function, I’m not sure what should be changed here exactly.