dxvk icon indicating copy to clipboard operation
dxvk copied to clipboard

[d3d11][regresion] Genshin Impact broken lightning with defrag

Open isbugged opened this issue 1 year ago • 23 comments

With current master dxvk lightning breaks in certain spaces, specially indoors defrag

Disabling defrag with DXVK_CONFIG="dxvk.enableMemoryDefrag = false" fixes it nodefrag

Software information

Genshin Impact 5.1 Max quality settings

System information

  • GPU: Intel Arc A770
  • Driver: Mesa 24.3 git - Linux 6.11.5
  • Wine version: 9.20-staging-tkg
  • DXVK version: 2.4.1-341-g640379e5

isbugged avatar Oct 24 '24 11:10 isbugged

Is there a way to actually like debug this? I can't really go off a screenshot.

doitsujin avatar Oct 24 '24 11:10 doitsujin

Try to make a apitrace of a affected area https://github.com/doitsujin/dxvk/wiki/Using-Apitrace

Blisto91 avatar Oct 24 '24 11:10 Blisto91

Gonna need detailed instructions on how to reproduce this in game. Been running around in some early areas including some buildings in the first city and it looks fine with defrag on and off, but please keep in mind that I don't really play this game, I don't have access to everything.

doitsujin avatar Oct 24 '24 14:10 doitsujin

Reproducing this seems inconsistent, the moment i restart the game to do the trace it solves itself. I managed to make apitrace work with the game, if i find a consistent trigger i'll upload a trace

isbugged avatar Oct 24 '24 14:10 isbugged

This is why I'm trying to reproduce this locally, I can play around with the code to make defrag more aggressive but for that I need to know an area where the problem reproduces somewhat consistently. So far I haven't been able to find one.

doitsujin avatar Oct 24 '24 14:10 doitsujin

Here's a branch which essentially moves everything around all the time, should trigger the problem more reliably: https://github.com/doitsujin/dxvk/tree/frog

Still looks fine here though.

doitsujin avatar Oct 24 '24 14:10 doitsujin

Got a trace with the frog branch, i had to run around to trigger it, it happens in the last seconds of the trace when i enter the tabern.

https://share.mailbox.org/ajax/share/058a246a007fa64b51ac93807fa64f8eb4af6c9b7c206432/1/8/MzQ/MzQvMg

That place should be accesible from the start of the game, but i only managed to trigger it after jumping around, reproducing this will require some teleport points unlocked probably.

isbugged avatar Oct 24 '24 16:10 isbugged

Does this look correct? I tried this a whole bunch now but just can't seem to get it to break with either the trace or in game itslef. I did some teleporting around in the starting area as you described. Bildschirmfoto-703

doitsujin avatar Oct 24 '24 17:10 doitsujin

That seems right, when it triggers it looks like the first screenshot, with no lightning anywhere in the scene. It took me a lot of restarts to make it happen, i dont think its very easy to trigger. Maybe the defrag rework has nothing to do with it and its a coincidence that it triggered just now. Ill keep testing with master or that image invalidation branch for some days and report back.

isbugged avatar Oct 24 '24 17:10 isbugged

I've tested this weekend a fair bit with master and I couldn't reproduce it, the frog branch seemed more consistent. I've rebased it locally to get the latest changes and retested, it triggered instantly.

The game seems to have 2 lightning systems, the main time of day sun/moon cycle and static lightning for cities/indoors/caves that can change at 06:00 or 18:00 ingame, in most scenes its only on at night. When the bug triggers it only affects the static lightning, but it can trigger in different ways: weirdcircles2 For reference this are the graphics options i had at the time: options The circles correspond more or less to the light sources/probes for global illumination. I tested changing the option in that state and it turned all the lightning off: globalilluminationoff And turning off volumetric fog for some reason made this: wtf2 This where the only options that seemed to have an effect.

Once the lightning is turned off changing options it doesnt trigger it back on anywhere without restarting. Teleporting, waiting for ingame time change of lightning trigger, logout and login again doesnt matter.

I also had this happen in another run trying to trace it: trace2

I tried to reproduce it replaying the traces, but i only managed to trigger it once compared to the game, and not the same effect (also apitrace breaks if i pass the loop option, which makes it difficult to stress test). The best way to trigger it seems to be entering and exiting the tavern (I used the entrance on the top floor) and changing global illumination options after some time.

isbugged avatar Oct 28 '24 10:10 isbugged

Do you know if ANV exposes a transfer queue on your GPU? This should be apparent from the DXVK logs.

I still haven't managed to reproduce this at all and I'm starting to suspect driver memes.

doitsujin avatar Oct 28 '24 13:10 doitsujin

I've attached the logs plus vulkaninfo output, but the relevant parts seems this:

info:  Queue families:
info:    Graphics : 0
info:    Transfer : 0
info:    Sparse   : 0
VkQueueFamilyProperties:
========================
	queueProperties[0]:
	-------------------
		minImageTransferGranularity = (1,1,1)
		queueCount                  = 1
		queueFlags                  = QUEUE_GRAPHICS_BIT | QUEUE_COMPUTE_BIT | QUEUE_TRANSFER_BIT | QUEUE_SPARSE_BINDING_BIT
		timestampValidBits          = 64
		present support             = true
		VkQueueFamilyGlobalPriorityPropertiesKHR:
		-----------------------------------------
			priorityCount  = 4
			priorities: count = 4
				QUEUE_GLOBAL_PRIORITY_LOW_KHR
				QUEUE_GLOBAL_PRIORITY_MEDIUM_KHR
				QUEUE_GLOBAL_PRIORITY_HIGH_KHR
				QUEUE_GLOBAL_PRIORITY_REALTIME_KHR

There is an option (ANV_QUEUE_OVERRIDE) to force queue support in the driver but enabling anything outside default settings breaks everything (more so since they enabled sparse binding).

GenshinImpact_d3d11.log GenshinImpact_dxgi.log vulkaninfo.txt

isbugged avatar Oct 28 '24 15:10 isbugged

That's a firm no and rules out one of the theories I had.

That said, I have another suspicion. The game copies an R32G32B32A32_UINT image to a BC6H_UFLOAT one, which is legal in both D3D11 and Vulkan, however there is an edge case that is fun for the whole family, specifically copying one RGBA32 texel to a 1x1 or 2x2 mip of the destination image. If ANV fails there, we'll read stale data and artifacts like the ones in your last couple of screenshots happen.

I updated the frog branch with some code that replaces those image->image copies with an image->buffer->image round-trip, would appreciate if you could test with that.

doitsujin avatar Oct 28 '24 18:10 doitsujin

I'm afraid it still triggers intelworkaround1 intelworkaround2 intelworkaround3

I've also done a quick test with mesa stable as of current Arch Linux packages: intelworkaroundstable1 intelworkaroundstable2

Same steps of triggering, disabling global illumination and volumetric fog.

Now if this is clearly a bug in ANV ill report it and see where it goes. Its hard to trigger it on master with the current defrag code, only this stress test branch triggers it consistently, so being more cautious with ANV reports might be enough for the moment until it gets looked at.

isbugged avatar Oct 28 '24 19:10 isbugged

Yeah I'm pretty much out of ideas then. I don't have solid proof for this being an ANV bug either, but so far no one seems to have been able to reproduce this on all sorts of other hardware (and drivers; I've thrown AMDVLK at it for good measure and even that works just fine here).

doitsujin avatar Oct 28 '24 19:10 doitsujin

@isbugged Could you per chance try to make a ANV mesa issue about this? Would be great to get some driver dev input on the issue if it reproduces only on Intel.

Edit: nevermind i see you already did https://gitlab.freedesktop.org/mesa/mesa/-/issues/12084

Blisto91 avatar Nov 05 '24 16:11 Blisto91

@isbugged Do you know if this is still an issue with the latest drivers?

Blisto91 avatar May 16 '25 10:05 Blisto91

It still happens on the original frog branch with my A770

A770 on Mesa 25.1 with frog branch:

Image

A770 on Mesa main as of yesterday or so:

Image

I made a quick rebase of that branch onto master and the results are slightly different (although I dont know if its still valid, git rebase didn't generate any conflicts and the memory HUD had the same behavior of moving things around constantly). I couldn't manage to break the lightning in the same than before by changing locations, but i managed to reproduce the colored sparkles by using character abilities constantly (notice that while the DXVK version is still 2.4.1 it has all the commits up to 5e59382d542e3d545140976049fdd62076ed3fb5)

Image

I have a B580 now and it doesnt happen there on any build, but there is a caveat. The game has some kind of white/blacklist to enable some graphic features like global illumination or the "dynamic resolution characters" option. On the my A770 the options appear but on the B580 by default they dont. If I spoof the card to show as the A770 with DXVK_CONFIG='dxgi.customVendorId=8086;dxgi.customDeviceId=56a0;dxgi.customDeviceDesc="Intel(R) Arc(tm) A770 Graphics (DG2)"' then they show up. I had to use all the options for it to appear, dxgi.hideIntelGpu=true or changing only the device name or the pci id didnt work. I also tested changing the description for the same name of the Windows drivers for the B580 (Intel(R) Arc(tm) B580 Graphics) and it also didn't work. For the test I also added dxvk.enableMemoryDefrag=true and checked on the logs that its detected without errors.

All this test were done by disabling the kernel driver of the other unused card to simulate having only one and connecting the monitor to the tested card. My experience of DRI_PRIME setups between cards using i915 and xe kernel is that they dont work very well and I dont have a need for them.

isbugged avatar May 16 '25 17:05 isbugged

Thank you very much for the retest and very nicely found in regards to the B580. I have one myself and wasn't able to reproduce the issue, but didn't know about the blacklist.

Blisto91 avatar May 16 '25 18:05 Blisto91

Got a trace with the frog branch, i had to run around to trigger it, it happens in the last seconds of the trace when i enter the tabern.

https://share.mailbox.org/ajax/share/058a246a007fa64b51ac93807fa64f8eb4af6c9b7c206432/1/8/MzQ/MzQvMg

That place should be accesible from the start of the game, but i only managed to trigger it after jumping around, reproducing this will require some teleport points unlocked probably.

Would you be able to reshare the trace? This link doesn't work anymore.

djdeath avatar Jun 04 '25 14:06 djdeath

I've tried for a little while now to reproduce on my B580 with the spoof provided, but have still been unable to

Blisto91 avatar Jun 14 '25 19:06 Blisto91

Got a trace with the frog branch, i had to run around to trigger it, it happens in the last seconds of the trace when i enter the tabern. https://share.mailbox.org/ajax/share/058a246a007fa64b51ac93807fa64f8eb4af6c9b7c206432/1/8/MzQ/MzQvMg That place should be accesible from the start of the game, but i only managed to trigger it after jumping around, reproducing this will require some teleport points unlocked probably.

Would you be able to reshare the trace? This link doesn't work anymore.

Sorry for the lateness, the new link is https://share.mailbox.org/ajax/share/00541f910129b14d0c4f2c3129b1485f8d872ab55aa09ebe/1/8/MzQ/MzQvMg

I've tried for a little while now to reproduce on my B580 with the spoof provided, but have still been unable to

Also sorry for this, maybe i didn't explain myself very well. With the B580 I never managed to reproduce any of the effects of the bug even with the spoof, but to make the global illumination option that triggers the bug in the A770 appear and test in equal conditions the spoof might be needed if the GPU is in that blacklist.

If more testing is needed feel free to ping me.

isbugged avatar Jun 14 '25 21:06 isbugged

Thanks, downloaded

djdeath avatar Jun 14 '25 22:06 djdeath

I also cannot reproduce with the B580 spoofed as an A770. I'm using DXVK 2.7.

anh0516 avatar Jul 07 '25 13:07 anh0516