Skip to content

render: properly release rendered buffers #9807

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

Draft
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

ikalco
Copy link
Contributor

@ikalco ikalco commented Mar 30, 2025

Describe your PR, what does it fix/add?

as title says, this pr intends to properly do buffer release when rendering by

  • ensuring we keep all surface buffers used in rendering referenced, including non-drmsyncobj buffers since wl_events.release still applies for them
  • ensuring we only release buffers when rendering is done, so either on EGLSync signal or after a glFinish
  • as a bonus we can also make a renderingDoneCallback, which can be useful for some purposes like screencopy

Is there anything you want to mention? (unchecked code, possible bugs, found problems, breaking compatibility, etc.)

Is it ready for merging, or does it need work?

after #9806

@ikalco ikalco mentioned this pull request Apr 4, 2025
6 tasks
@ikalco ikalco force-pushed the properly_release_rendered_buffers branch 2 times, most recently from b63c4cc to 57d9342 Compare April 6, 2025 02:06
@ikalco ikalco force-pushed the properly_release_rendered_buffers branch 3 times, most recently from 9e327ef to d7f7552 Compare April 8, 2025 21:05
@ikalco ikalco marked this pull request as ready for review April 10, 2025 19:28
@ikalco
Copy link
Contributor Author

ikalco commented Apr 10, 2025

merge after #9806 (i"ll rebase this to main then)
also some final testing from me and @gulafaran

@gulafaran
Copy link
Contributor

merge after #9806 (i"ll rebase this to main then) also some testing from me and @gulafaran

As long as this pr moves from syncrelease/fd signaling to wayland eventloop/waiter releasing its going to get a no from me, as mentioned earlier it means moving from as early as possible at as correct time release possible to cpu based wait in the crowded wayland eventloop which makes it always out of time. and since this isnt per se fixing anything im not settling for a potential slower approach.

@ikalco
Copy link
Contributor Author

ikalco commented Apr 10, 2025

merge after #9806 (i"ll rebase this to main then) also some testing from me and @gulafaran

As long as this pr moves from syncrelease/fd signaling to wayland eventloop/waiter releasing its going to get a no from me, as mentioned earlier it means moving from as early as possible at as correct time release possible to cpu based wait in the crowded wayland eventloop which makes it always out of time. and since this isnt per se fixing anything im not settling for a potential slower approach.

we're still using fd signaling, just not syncrelease

if (eglSync.isValid()) {
if (getExplicitSyncSettings(PMONITOR->output).explicitKMSEnabled) {
// let kernel signal release points rather than slow wayland event loop
for (const auto& buf : usedAsyncBuffers) {
for (auto& point : buf->releasePoints) {
point.importSyncFD(eglSync.fd());
}
}
}

also previously we didn't release non-drmsynobj dmabuf buffers when rendering finished,
now we do through an eventfd in wayland loop
but if there's a drmsyncobj point, we signal based on EGLSync, like before, not through wayland loop

@gulafaran
Copy link
Contributor

merge after #9806 (i"ll rebase this to main then) also some testing from me and @gulafaran

As long as this pr moves from syncrelease/fd signaling to wayland eventloop/waiter releasing its going to get a no from me, as mentioned earlier it means moving from as early as possible at as correct time release possible to cpu based wait in the crowded wayland eventloop which makes it always out of time. and since this isnt per se fixing anything im not settling for a potential slower approach.

we're still using fd signaling, just not syncrelease

if (eglSync.isValid()) {
if (getExplicitSyncSettings(PMONITOR->output).explicitKMSEnabled) {
// let kernel signal release points rather than slow wayland event loop
for (const auto& buf : usedAsyncBuffers) {
for (auto& point : buf->releasePoints) {
point.importSyncFD(eglSync.fd());
}
}
}

also previously we didn't release non-drmsynobj dmabuf buffers when rendering finished, now we do through an eventfd in wayland loop but if there's a drmsyncobj point, we signal based on EGLSync, like before, not through wayland loop

well previously it accounted for both the release point fd and eglsync fd, it merged those and imported it. now it only accounts for the eglsync fd and ignores if the releasepoint fd is signaled, it was also previously signaling on destruction if the buffer wasnt rendered.

@gulafaran
Copy link
Contributor

merge after #9806 (i"ll rebase this to main then) also some testing from me and @gulafaran

As long as this pr moves from syncrelease/fd signaling to wayland eventloop/waiter releasing its going to get a no from me, as mentioned earlier it means moving from as early as possible at as correct time release possible to cpu based wait in the crowded wayland eventloop which makes it always out of time. and since this isnt per se fixing anything im not settling for a potential slower approach.

we're still using fd signaling, just not syncrelease

if (eglSync.isValid()) {
if (getExplicitSyncSettings(PMONITOR->output).explicitKMSEnabled) {
// let kernel signal release points rather than slow wayland event loop
for (const auto& buf : usedAsyncBuffers) {
for (auto& point : buf->releasePoints) {
point.importSyncFD(eglSync.fd());
}
}
}

also previously we didn't release non-drmsynobj dmabuf buffers when rendering finished, now we do through an eventfd in wayland loop but if there's a drmsyncobj point, we signal based on EGLSync, like before, not through wayland loop

well previously it accounted for both the release point fd and eglsync fd, it merged those and imported it. now it only accounts for the eglsync fd and ignores if the releasepoint fd is signaled, it was also previously signaling on destruction if the buffer wasnt rendered.

hm let me rethink that, it seems we were merely merging the eglsync fd if a new appeared before it was released. can we render the same buffer multiple times before its actually dropped? what happends if the client is at 30fps on a 60hz monitor. is the same buffer supposed to be rendered multiple times and the eglsync just merged until finally dropped?

@ikalco ikalco marked this pull request as draft April 11, 2025 23:35
@ikalco ikalco force-pushed the properly_release_rendered_buffers branch from d7f7552 to a31912a Compare April 12, 2025 00:05
@ikalco ikalco force-pushed the properly_release_rendered_buffers branch from a31912a to 6b1f947 Compare April 16, 2025 21:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants