-
Notifications
You must be signed in to change notification settings - Fork 90
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
Add linux-drm-syncobj-v1
protocol
#411
base: master
Are you sure you want to change the base?
Conversation
For that you probably have to remove the old
Yeah, I am pretty sure smithay's code isn't correct in what it does today, but given direct-scanout mostly works, that is probably using implicit-sync in the background. What needs to happen is storing the fence generated by compositing or in case of direct scanout, we need to get the
Yeah, imo this needs a compile test similar to what we do for gbm in smithay: https://github.com/Smithay/smithay/blob/master/build.rs#L99-L125 So if the local kernel/drm headers of the system support it, we enable the feature and assume the kernel does as well. I don't know how well runtime detection would work, but we have to make sure to not advertise the global, if this function isn't supported. |
This should already be doing that. If there's an acquire point, it adds a
I'm not sure if implicit sync does does something to help with releases (blocking client writes to the buffer until the display controller is done with the buffer... but yeah, it does seem to mostly work. If implicit sync isn't involved, this won't be more problematic with explicit sync and the same limitation.
It should be possible to do something with We just have to make sure to only do that once the buffer is no longer used elsewhere in the compositor. |
It definitely does, but the nvidia-driver at least isn't doing that correctly, when you send dmabufs directly to KMS without going through egl-gbm and allocating a
👍
I am pretty sure, that is what our current release logic does, with the exception of handling direct-scanout. Which would be handled by the fence anywhere in this case, so that should be correct. We just need to adjust the |
I mean if we want to have
So I'm not sure when we could actually do that? Maybe with So at least for now I think we need to stick to signaling the release point from CPU? But should still track when |
Right, so this rather needs to be a list of fences to wait for. Meaning we probably have to wait and signal ourselves instead of relying on
But merge of the state should only happen, once all blockers are resolved. And only then we release, so I believe that issue is already handled correctly. Nothing would be able to use that buffer for rendering any more at that point. But we still need to track the buffer to be able to signal later, so we might as well unify the approach and handle the
I think we can implement both fifo and commit-queue with blockers as well.
Yeah, I am coming to the same conclusion, but that isn't too bad, as that is just another fd in the loop and a very small action. |
905893f
to
8d00edc
Compare
src/backend/kms/mod.rs
Outdated
@@ -450,6 +451,9 @@ pub fn init_backend( | |||
// Create relative pointer global | |||
RelativePointerManagerState::new::<State>(&dh); | |||
|
|||
// TODO check if main device supports syncobj eventfd? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess worst case we can still fail the import_timeline
-request, right?
Is Xwayland/mesa able to handle this / fallback to implicit sync?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think there's any way to fallback once we expose the global. The protocol doesn't make import_timeline
failable, except as a protocol error.
It looks like Mutter uses drmSyncobjEventfd (drm_fd, 0, 0, -1, 0) != -1 || errno != ENOENT)
to check if the call is supported. So we probably want to do the same, and only create the global if it is supported.
Can we get this rebased on the newest master please |
182a391
to
3b5de88
Compare
Is this going to be implemented soon? |
3b5de88
to
b5b9548
Compare
I've just marked Smithay/smithay#1356 as ready for review, so hopefully if no issues come up this should be merged soon. I'm not sure if explicit sync will help with whatever issues you're seeing, but if you'd like to test this PR and report how it impacts behavior (for a certain game / graphics card / driver), that could be helpful. |
I think it will. I will report back. @ids1024 There's definitely something weird with my setup, the issue is still here, no weird tearing now, but FPS are halved if they're less than 60 (they're even more than halved).
I'm not telling anything to the game, the just uses the nvidia gpu, I do not force any GPU. Mesa is at version EDIT: for more details refer to this pop-os/cosmic-epoch#184 (comment) |
FPS being lower than expected (often around 30 on a 60 fps monitor) with vsync is something I've noticed with Intel-rendered windows on a 1650 mobile (later NVIDIA cards don't seem to have this issue). In my testing Gnome Wayland seemed similar, so I assume it's something in the driver. #211 has some previous testing I've done with that. |
In my case the inverse is true. Personally I see extreme lag, the game renders fine though because if you record a gameplay and watch it, you'll see it buttery-smooth UPDATE: Basically the chronological order is the whole thing is:
|
b5b9548
to
54fc7d5
Compare
Tried this briefly with NVIDIA 560.35.03. Other things seemed to work fine though. Using Pop!_os 22.04 with popdev:master branch. |
Can you read my comment and please tell me if you don't have the issue? |
I'm using a desktop, with my intel integrated gpu disabled in BIOS. |
Hm, are there still issues with Firefox? nvidia/egl-wayland 1.1.15 was supposed to fix some issues like that. Not sure if Firefox also needed fixes. |
Appears so. I could send the firefox crash log if you think it could help. |
So my theory could still stand: it must be a problem with hybrid setups |
Yeah, I think the issue you're seeing is related in some way to copies between GPUs. Not sure why later Nvidia cards seem to have much less trouble with that. If you start a program with an env var like If it's easy for you to test Gnome Wayland on the same setup, it would be good to know if it has similar issues. (If Gnome is doing better on any systems, we should try to figure out what they're doing differently.) |
Figures
Both commands results in the issue still existing, so far I've tried to launch games in steam with that variable. |
Oh yeah, that command won't change the behavior of XWayland clients, which would probably include most Steam games. We may need to make some changes to make sure unnecessary buffer copies are avoided for XWayland clients with multiple GPUs. It's all a bit awkward currently since there isn't a reliable way for the compositor to actually know which GPU the buffers it gets from the client are allocated on. (https://gitlab.freedesktop.org/wayland/wayland-protocols/-/merge_requests/268 aims to address that; though I guess X would also need a protocol change.) |
Wasn't this protocol required to basically fix gaming on nvidia even from hybrid setups? |
Explicit sync was required to fix nvidia mostly on desktops, not really on hybrid setups.
No, we don't need a new protocol to fix Xwayland, while the protocol @ids1024 mentioned would certainly be helpful, it doesn't in it of itself fix the core issue. The issue is, that copying from one GPU to another takes time with 1000-series cards and lower. There is nothing to fix this (apart from maybe inside the nvidia-driver, but we don't know that and it doesn't appear to be particularly badly optimized for this use case). The only thing we can fix, is rendering games/apps on the nvidia-gpu and displaying them on a display directly connected to the nvidia gpu (some of your external displays might be connected to it directly). That will require multiple Xwayland instances, but can theoretically work and is on our TODO-list. But there is nothing fixing the delay, if you want to game on e.g. your internal display, which is likely hard-wired to your integrated gpu (if you don't have a switch in your BIOS). The internal FPS will always be fine in that case, as your nvidia gpu can keep up just fine with the application, but you will likely see stutter or at least not reach those same frame counts because of the copy operation, that needs to happen to actually show it on your display. |
That explains a lot. One day something changed and this "slow" synchronization problem happened. |
54fc7d5
to
351a7f2
Compare
Hm, I can reproduce the Firefox crash with Nvidia, but it doesn't seem to be a protocol error. Edit: seems to be a segfault somewhere in |
Okay, looks like this one was my fault, not Nvidia's. Smithay/smithay#1547 appears to fix the Firefox crash. |
351a7f2
to
869ebee
Compare
I think everything should be good now. So this can be merged if no more issues are occurring. |
Ive tested this MR on my 4070 Super with 560 Drivers. I was not able to open discord, nor cosmic settings or equal. |
Hm. Hopefully the logs provide more context. |
sorry, my env has WGPU_BACKEND=vulkan, so my test should not be considered a valid reference I'm trying this. spec : gtx 1080 quick check the following apps work list: not work list: It can be started, but the menu cannot be displayed: cosmic-settings vulkan log : log maybe I also need to test latest cosmic-comp
what I can do for you cosmic-comp keep printing in journal ... cosmic-comp[1718]: [GL] Buffer detailed info: Buffer object 3 (bound to GL_VERTEX_ATTRIB_ARRAY_BUFFER_BINDING_ARB (0), usage hint is GL_STATIC_DRAW) will use VIDEO memory as the source for buffer object operations. If my gpu is not supported, please let me know |
I test this pr on my rx7900xtx driver : mesa 24.3.0_devel.194431.6f3c003433f-1 I tried to play DBD and encountered the following situation, I don't see this regression in cosmic-comp 1.0.0.alpha.2 And it only happens in full screen mode, windowed mode has no problem |
We expect COSMIC to work on any GPU supported by the current NVIDIA drivers. (Though if there's a bug in their drivers on certain cards, we may not be able to do anything about it.)
Hm, probably something involving direct scanout. We should be waiting properly for the explicit sync point before the buffer is used... |
got it :)
very much like what you surmised, this damage is not visible in the capture screenshots. |
Since the latest update, cosmic settings seems to be working on nvidia. |
Yep, Smithay/smithay#1554 should fix that issue on Nvidia, at least. Not sure about the issue on the rx7900xtx, which does look like a real synchronization issue. I assume that's using vkd3d on wine on xwayland for rendering? The only RDNA hardware I have is a Steam Deck, and I'm not seeing that issue running a couple games on it under cosmic-comp. |
yep, the game I run with dx12, and it support dx11 too. You are welcome to ping me at any time with your list of testing needs and I will be available to assist with testing after get off work today :) my work computer is equipped with gtx 1080, I will test it again when I have time |
Apparently my weird issue translates to VR too since I see "backwards" frames or something. |
I'm still having the same sync issues playing dx12 and dx11 games on the latest update on my 7900xtx, and some temporary freezes during daily use. I might have to try to collect more logs, but I'm not sure what information in the journal would be useful. |
Based on Smithay/smithay#1356.
I think the blocker logic should be correct for handling acquire points (if I properly understand the transaction system in Smithay). Though I don't see rendering issues with Mesa git when the blocker is removed... maybe it needs to be tested with something heavier than vkcube. (Or is there something still forcing implicit sync?).
The logic I added in Smithay for signaling releases may be a little less correct. Though maybe not more incorrect that how buffer releases are currently handled? (If I understand DRM correctly, with direct scanout we should make sure not to release until we've committed a new buffer and are sure the display controller won't want to read the buffer.)
We'll be able to test more when the next Nvidia driver is released. This at least gives us a way to test the explicit sync support they're adding.
Presumably we should test if
drmSyncobjEventfd
is supported... maybe just creating a syncobj and calling that to see if it works? I'm also still a little unsure how this ends up working with multiple GPUs... particularly if one is Nvidia.