New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Bisected] Color corruption on intel graphics #356
Comments
Noticed this after upgrading to 3.10.3 on Arch Linux. Goes away after downgrading to 3.9.5. |
Great. Never noticed this before but with this I'll try to bisect it. |
Ok I managed to bisect it. Here is the log.
And the first bad commit:
|
Once we fix validation stuff and add acquire barrier itd make sense to open an issue on Mesa if it isnt fixed. |
Might worth a try with mesa-git package to see if it's fixed upstream. |
Tested now, same result with mesa-git (version 22.0.0_devel.149533.24fef8f33da.d41d8cd98f00b204e9800998ecf8427e-1). |
This should be reported to mesa, as far as I know we do everything correctly now. All the validation errors have been fixed. |
Not sure how helpful this might be, but I've been experimenting/hacking a few changes to try to get it visually working on my setup. There are two scenarios that I have tested, both involving changes in the
struct {
uint32_t DRMFormat;
VkFormat vkFormat;
VkFormat vkFormatSrgb;
bool bHasAlpha;
} s_DRMVKFormatTable[] = {
- { DRM_FORMAT_ARGB8888, VK_FORMAT_B8G8R8A8_UNORM, VK_FORMAT_B8G8R8A8_SRGB, true },
- { DRM_FORMAT_XRGB8888, VK_FORMAT_B8G8R8A8_UNORM, VK_FORMAT_B8G8R8A8_SRGB, false },
+ { DRM_FORMAT_ARGB8888, VK_FORMAT_B8G8R8A8_SRGB, VK_FORMAT_B8G8R8A8_SRGB, true },
+ { DRM_FORMAT_XRGB8888, VK_FORMAT_B8G8R8A8_SRGB, VK_FORMAT_B8G8R8A8_SRGB, false },
{ DRM_FORMAT_NV12, VK_FORMAT_G8_B8R8_2PLANE_420_UNORM, VK_FORMAT_G8_B8R8_2PLANE_420_UNORM, false },
{ DRM_FORMAT_INVALID, VK_FORMAT_UNDEFINED, VK_FORMAT_UNDEFINED, false },
}; This makes gamescope run with correct colors, however enabling FSR results in black screen.
struct {
uint32_t DRMFormat;
VkFormat vkFormat;
VkFormat vkFormatSrgb;
bool bHasAlpha;
} s_DRMVKFormatTable[] = {
- { DRM_FORMAT_ARGB8888, VK_FORMAT_B8G8R8A8_UNORM, VK_FORMAT_B8G8R8A8_SRGB, true },
- { DRM_FORMAT_XRGB8888, VK_FORMAT_B8G8R8A8_UNORM, VK_FORMAT_B8G8R8A8_SRGB, false },
+ { DRM_FORMAT_ARGB8888, VK_FORMAT_B8G8R8A8_UNORM, VK_FORMAT_B8G8R8A8_UNORM, true },
+ { DRM_FORMAT_XRGB8888, VK_FORMAT_B8G8R8A8_UNORM, VK_FORMAT_B8G8R8A8_UNORM, false },
{ DRM_FORMAT_NV12, VK_FORMAT_G8_B8R8_2PLANE_420_UNORM, VK_FORMAT_G8_B8R8_2PLANE_420_UNORM, false },
{ DRM_FORMAT_INVALID, VK_FORMAT_UNDEFINED, VK_FORMAT_UNDEFINED, false },
}; This makes gamescope run in incorrect washed-out colors (obviously due to color conversion), however when using FSR all colors return into their properness.
I'm not experienced at all in these regions and I found these changes purely by trial and error, so I am unsure of any possible side-effects nor the full purpose of such changes, however I hope it will help narrow the issue down somewhat. |
I can confirm I'm having near identical same issues on an 7700HQ under intel UHD 630 Created an issue here, but realising this is actually the same as this thread |
@vignedev All of that indicates that it's a driver issue, so something that should be reported to mesa. |
@DadSchoorse Would this really be a mesa issue if the game runs without gamescope on mesa? |
@patrickaldis There's always the possibility that there's some subtle bug in our code, but given that gamescope works fine on radv I think it's an anv problem. The hacks by @vignedev show that there's is some issue with mutable images + dmabufs and with the import barriers. The game doesn't matter. |
As an anecdotal evidence, I've tested this on several different Intel CPUs with integrated graphics. Only one of them (UHD 630) has this visual artifact (but works fine without Gamescope). Everything else works fine with or without Gamescope. @Samsagax Which Intel CPU/iGPU have you tested on? |
I'd like to add my two cents in, and say that these problems occur on most games I've tried, but there are at least a few games where Gamescope is mostly working fine with Intel UHD graphics. I'm running it on a Celeron N4120 with UHD 600 graphics. I've tested out Portal and Lara Croft: Temple of Osiris and both these games are playable with Gamescope, at least in all the sections with real-time 3D graphics. Portal is very playable, only seeing image artifacts in the Valve splash screen and the death sequences. Temple of Osiris starts with a setup window where artifacts show up, but once you get past that window it all looks fine. |
I have an i5 6200U cpu, the iGPU is a 520 (SKL GT2). |
For what is worth, seems to be a problem with the vulkan bit of the intel driver for those iGPUs. Games that use OpenGL will not have this issue. Does anyone have an account on the mesa gitlab instance to report this? I think we colected valuable information and should be able to report it to be fixed easily.
You would need to use git tags for this. Use the gamescope-git package as a reference. |
I can reproduce this issue on my Kaby Lake UHD 620 using Mesa 21.3.5. However, on gamescope master and latest Mesa main it's working fine. |
@Oschowa You're right! With |
Yes, it seems like latest Mesa only fixes it for vulkan apps running in gamescope, anything using OpenGL is still broken. I opened a Mesa issue about this here https://gitlab.freedesktop.org/mesa/mesa/-/issues/6029 |
I can confirm I also encounter this issue running Minecraft Java Edition or glxgears on my Intel HD Graphics 500 iGPU. |
I also have this problem on Intel UHD 600 (Gemini Lake) |
@Samsagax Nope. Even installed the Zen Kernel. The only major difference with your config seems to be the GPU.
|
|
Thanks, I don't have access to an Icelake machine, but I'll try to see with a colleague. Though for me the tip of tree of gamescope is just crashing for a completely different reason : #1188 |
Let me know if I can help you in any way. |
The problem still occurs if I try to use any --filter besides linear or start it with vkBasalt enabled. Currently on:
Problem also happens to Mesa stable releases. |
I'm still blocked by #1188 to investigate this. |
My guess for the ICL failure is that gamescope is performing excessive layout transitions from UNDEFINED: gamescope/src/rendervulkan.cpp Line 1711 in d7aace1
gamescope/src/rendervulkan.cpp Line 1644 in d7aace1
|
Hmm makes sense. The problem is that there is also this VU that forces the import operation to use UNDEFINED :
The spec also kind of contradicts itself by saying using the undefined layout might loose the data :
We might have to ignore the undefined layout in case of external queue transitions... |
Apps should be able to account for these rules by doing any import operations before rendering, no? If the driver ignores the layout, apps depending on this behavior could get GPU hangs. The reason I think excessive layout transitions is the issue is because gamescope seems to consider the dmabuf as not imported every time it's read from (follow the call stack from the second referenced line of code). That causes it to do a layout transition from UNDEFINED more than necessary. Assuming an app didn't perform import operations before rendering, I would expect a single import and layout transition from UNDEFINED to cause a single frame of corruption. |
We've had this discussion a bunch before. FWIR, when transitioning from a foreign queue, drivers must ignore the srcLayout. |
Someone had commented on the mesa issue thread a year ago about this: Where they basically confirmed what you just said |
@djdeath @nchery-intel @mrozigor I don't really expect this to actually fix the issue, but I guess it's worth a shot? |
I've rebuild gamescope with those changes but still doesn't work correctly. |
Thanks, I asked on the Khronos gitlab and got forwarded to the discussion from a while ago : https://gitlab.khronos.org/vulkan/vulkan/-/issues/2692 So it looks like we need to start handling the case where oldLayout = UNDEFINED in Anv. We should probably limit that to images with modifiers having compression though, because we can have separated compression not living in the shared buffer and that one would still need to be put back to UNDEFINED. |
Yes, it helped! I've tried mesa-24.0.5 first, but with no change. Then after applying above patch gamescope works properly. Thanks! |
So I've been discussing this more in particular here : https://gitlab.khronos.org/vulkan/vulkan/-/issues/3846 And to me it looks like gamescope should try to avoid using the I'm not sure how images are allocated & bound, but if an image is received from the application (glxgears), it should already be in Another alternative would be for us to implement |
Interesting
From what I can tell, it seems like Vuk has pretty good support for both renderpass stuff and compute work, and it doesn't force you to only present via graphics pipeline, because you can do an
|
UPDATE |
In my opinion this has nothing to do with semaphores. |
A change that would make sense to me would be :
But I'm not really sure this is correct. For Icelake it will depend on whether the image has storage usage. |
Is it well defined by the spec that imported images will be in the |
Nope. It depends on the application you interact with I suppose.
|
ok, so uh, let’s say for example:
Honestly even for this specific situation, I’m not quite sure, but would imagine it would be in For other situations, I think when gamescope WSI is not being used, gamescope might either use xwayland, or (especially w/ the new wayland backend for gamescope) use some wayland stuff for grabbing frames |
You might be able to add a layout value to communicate between the app and gamescope in that case. And you could use whatever layout you think is best. Just don't use |
No. Undefined is fine as the src layout is ignored for foreign import. If you wanted an undefined transition, you would just not do a queue transition. |
Can you point to the spec bit that says this? |
I'm not against amending the spec, but afaict, this "ignore undefined layout when doing queue transitions" is not specified anywhere. |
There was some discussion here https://gitlab.khronos.org/vulkan/vulkan/-/issues/3195 I agree it is underspecified but there is really no other option than ignoring oldLayout? Otherwise the entire ext is totally unusable. This is what RADV and NV prop do and what Gamescope + other users would expect as its the only way to use the ext. If you wanted an undefined transition, you wouldn't need or do a queue ownership transfer. |
The VK_IMAGE_LAYOUT_UNDEFINED layout means that the data hold by the texture can be discarded, and we don't want to discard it. Because the Vulkan spec is unclear (see [1] for a discussion), err on the side of caution and use VK_IMAGE_LAYOUT_GENERAL. Fixes import failures with WebKit. [1] ValveSoftware/gamescope#356
This can apparently cause the driver to discard the dmabuf contents on some systems. For more discussion, see the following gamescope thread: ValveSoftware/gamescope#356
Being using gamescope on my AMD machine for a while without issues. When trying out on my laptop Nvidia won't let me use it because of #151 but I managed to start gamescope on the intel GPU (iGPU) and then start games from it using the Nvidia GPU (dGPU) by setting some env variables (pretty cool, huh?).
Here is the issue: I started steam client within gamescope on my intel card by forcing
VK_ICD_FILENAMES
variable like soThe client launches fine but then the colors are corrupted:
But I managed to start a native game (selected Factorio, then Start) and then it all works inside the game (Launched with
__NV_PRIME*
variables for it to use the dGPU):Also when the game is launching the window flickers back and forth with the corrupted colors client and the correct colored game. After the game is started, it all "just works".
The text was updated successfully, but these errors were encountered: