#asahi-gpu · 2023-02-15 17:20
linaThen again I stole the fence code from panfrost so who knows whether it works? ^^#asahi-gpu · 2023-02-15 17:19
linaagx_flush does do the fence right, but it also didn't work when I didn't also force a full sync so clearly something is broken...#asahi-gpu · 2023-02-15 17:18
daniels(you can replace dri2_wl_swap_buffers_with_damage with dri2_drm_swap_buffers depending on context)#asahi-gpu · 2023-02-15 17:17
danielseglSwapBuffers -> dri2_wl_swap_buffers_with_damage -> dri2_flush_drawable_for_swapbuffers -> DRI2flushExt::flush_with_flags(__DRI2_FLUSH_DRAWABLE | __DRI2_THROTTLE_SWAPBUFFER) -> dri_flush -> st_context_flush(ST_FLUSH_END_OF_FRAME) -> st_context_flush(ST_FLUSH_END_OF_FRAME) -> st_flush(PIPE_FLUSH_END_OF_FRAME) -> pipe->flush(PIPE_FLUSH_END_OF_FRAME) -> your driver#asahi-gpu · 2023-02-15 17:16
jannauXe MR: https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/20418#asahi-gpu · 2023-02-15 17:15
jannauon dcp side everything should be ok then through drm_atomic_helper_commit#asahi-gpu · 2023-02-15 17:15
alyssairis with the Xe patchset is probably going to be best but idk#asahi-gpu · 2023-02-15 17:15
alyssaHey it's all good#asahi-gpu · 2023-02-15 17:15
linaSo I just winged it myself in the end ^^;;#asahi-gpu · 2023-02-15 17:15
alyssaYeah, I'm not sure either#asahi-gpu · 2023-02-15 17:15
linaI wasn't sure of what driver to look at, couldn't find a good reference for what has proper explicit sync...#asahi-gpu · 2023-02-15 17:14
alyssaI think iris is probably the best reference here/ IDK#asahi-gpu · 2023-02-15 17:14
alyssalina: Panfrost is all implicit sync so in general assume it's all broken ;)#asahi-gpu · 2023-02-15 17:12
alyssa(I shudder in fear of the pancsf undersyncing bug reports)#asahi-gpu · 2023-02-15 17:12
alyssathen again panfrost doesn't do explicit sync yet#asahi-gpu · 2023-02-15 17:12
alyssaI don't think we implement it on Panfrost, it's only in Asahi for the macOS "just pretend we're llvmpipe" code#asahi-gpu · 2023-02-15 17:11
alyssadaniels: I was under the impression flush_frontbuffer is only used for software winsys#asahi-gpu · 2023-02-15 17:11
linaalyssa: The code is unconditional there...#asahi-gpu · 2023-02-15 17:11
linaalyssa: Yes, active used to mean both but it was more of a mess that way#asahi-gpu · 2023-02-15 17:11
danielsjannau: oh nice, looks like drm_atomic_helper_prepare_planes() even calls the default prepare_fb (i.e. wait on fences) for you, so if you're just using the stock atomic helpers then you shouldn't even need to set the prepare_fb func yourself#asahi-gpu · 2023-02-15 17:11
alyssaI think#asahi-gpu · 2023-02-15 17:11
alyssathat's only on macOS#asahi-gpu · 2023-02-15 17:11
linaI just realized we're doing a CPU copy in there right now with no sync... I clearly glossed over it way too quickly today...#asahi-gpu · 2023-02-15 17:10
alyssaoh, ok. "active" means "unsubmitted and active", "submitted" means "submitted but not yet done". got it#asahi-gpu · 2023-02-15 17:09
danielsbut yeah, flush_frontbuffer is your place to update the dma_resv for implicit sync - it's the handover from your rendering to an external user, be it GBM or a Wayland server#asahi-gpu · 2023-02-15 17:09
jannaudcp does nothing explicitly, if the helpers do it correctly it should work otherwise it's broken#asahi-gpu · 2023-02-15 17:09
alyssaisn't totally sure how the batch tracking here works yet#asahi-gpu · 2023-02-15 17:09
danielsif it uses the drm_gem_shmem (IIRC) helper, then it'll wait on all fences before continuing#asahi-gpu · 2023-02-15 17:09
danielsthe easiest way to find out is to grep it for prepare_fb#asahi-gpu · 2023-02-15 17:08
danielsheh#asahi-gpu · 2023-02-15 17:08
linaI also have no idea what DCP does ^^;;#asahi-gpu · 2023-02-15 17:08
daniels(the other method is that KWin creates an EGLSyncKHR representing everything in that ctx being completed, exports that to a dma_fence, then places that as the IN_FENCE_FD on the plane during the KMS commit, but I don't think KWin does that, i.e. you need to rely on implicit sync for inter-device completion)#asahi-gpu · 2023-02-15 17:08
linaI don't sync in flush_frontbuffer yet, I wasn't sure about that one, so maybe that's it...#asahi-gpu · 2023-02-15 17:07
danielsthat would be the place at which you need to place a dma_fence for all batch completions on the dma_resv, then make sure the DCP driver respects that fence#asahi-gpu · 2023-02-15 17:07
alyssaBoth undersyncing and oversyncing in the same driver? Wow! :-D#asahi-gpu · 2023-02-15 17:07
danielsGallium flush only requires a hardware flush indeed, but there's a separate flush_frontbuffer which is your hook for eglSwapBuffers#asahi-gpu · 2023-02-15 17:06
danielsin that case, if you're seeing horribly incomplete bits which suggest KWin's own rendering is broken (i.e. it's not due to stale client data but e.g. clients being intermingled), and you're confident that your internal batch-to-batch tracking is fine (or even oversyncing), it's probably missing synchronisation indeed#asahi-gpu · 2023-02-15 17:06
alyssa:D#asahi-gpu · 2023-02-15 17:06
danielsgood answer :)#asahi-gpu · 2023-02-15 17:05
linaWayland#asahi-gpu · 2023-02-15 17:05
danielslina: is this KWin as a Wayland compositor (backing on to GBM) or as an Xorg WM?#asahi-gpu · 2023-02-15 17:05
alyssasure, ok#asahi-gpu · 2023-02-15 17:05
linaPlus without that we leak memory#asahi-gpu · 2023-02-15 17:05
linaWe do need the sync_all in context destruction if we don't want faults on clean exits#asahi-gpu · 2023-02-15 17:04
alyssaseeing as gnome is broken with it#asahi-gpu · 2023-02-15 17:04
alyssadefinitely missing syncs somewhere else#asahi-gpu · 2023-02-15 17:04
linaWell KDE becomes a mess without it... so either kwin is broken or we're missing syncs in some other place...#asahi-gpu · 2023-02-15 17:04
alyssaprobably not even context destruction#asahi-gpu · 2023-02-15 17:04
alyssaI can't think of a case where you actually need a sync_all#asahi-gpu · 2023-02-15 17:03
alyssait's a flush_all, not a sync_all