Skip to content
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

Don't use explicit sync fences if we can tear #8645

Closed
wants to merge 1 commit into from

Conversation

ferrreo
Copy link
Contributor

@ferrreo ferrreo commented Dec 4, 2024

Describe your PR, what does it fix/add?

Fixes #8482

This fixes the issue where with explicit sync on no tearing is possible even when the requirements for it are fully met.

This is similar to how KWIN handles it.

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

I am not 100% sure this is ultimately the correct fix but it retains fences and allows tearing to happen when requested. It also seems to be what other compositors are doing too.

Also been running this patch on my distro with a good number of users with no issues reported for around 3 weeks.

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

Yea do it.

This fixes the issue where with explicit sync on no tearing is possible even when the requirements for it are fully met.

This is similar to how KWIN handles it.
Copy link
Member

@vaxerski vaxerski left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can I get a ref on kwin for this one?

@@ -1531,7 +1531,7 @@ bool CHyprRenderer::commitPendingAndDoExplicitSync(PHLMONITOR pMonitor) {
if (inFD >= 0)
pMonitor->output->state->setExplicitInFence(inFD);
auto explicitOptions = getExplicitSyncSettings();
if (explicitOptions.explicitEnabled && explicitOptions.explicitKMSEnabled)
if (explicitOptions.explicitEnabled && explicitOptions.explicitKMSEnabled && !pMonitor->tearingState.canTear)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this should be activelyTearing not canTear.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tried that first and it didn't work

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

canTear is definitely wrong, but I don't thing we even use the out fence, can we drop it?

@vaxerski
Copy link
Member

vaxerski commented Dec 4, 2024

generally yes this looks correct apart from the mistaken variable. Out fence doesn't matter while tearing, though we still have to give back feedback. Considering it's working I assume it's done somewhere else and works.

@vaxerski
Copy link
Member

vaxerski commented Dec 4, 2024

yeah looks like it. we release when backend releases regardless

@ferrreo
Copy link
Contributor Author

ferrreo commented Dec 4, 2024

@vaxerski
Copy link
Member

vaxerski commented Dec 4, 2024

  1. that's IN_FENCE? And you are disabling OUT_FENCE?
  2. my comment still stands

@UjinT34
Copy link
Contributor

UjinT34 commented Dec 4, 2024

What does explicitOutFence really fences and when we should wait for it?

This Sync File contains the CRTC fence that will be signaled when all framebuffers present on the Atomic Commit * request for that given CRTC are scanned out on the screen.

https://drmdb.emersion.fr/properties/3435973836/OUT_FENCE_PTR

Seems reasonable not to use it with tearing.

kwin doesn't use OUT_FENCE_PTR at all and disables IN_FENCE_FD to avoid some bugs.

@vaxerski
Copy link
Member

vaxerski commented Dec 5, 2024

we could disable IN_FENCE, but I don't think that's a good idea: explicit sync + scanout without IN_FENCE will mess up.

@UjinT34
Copy link
Contributor

UjinT34 commented Dec 5, 2024

Is it possible to get DS with tearing?

if (*PDIRECTSCANOUT && !shouldTear) {

@vaxerski
Copy link
Member

vaxerski commented Dec 5, 2024

hm, in our code, maybe not, but ideally yea it should be perfectly possible

@vaxerski
Copy link
Member

vaxerski commented Dec 5, 2024

patch.txt
can't we just do this? (patch for main). This just drops out fd, I don't think we actually use it at all.

@ferrreo
Copy link
Contributor Author

ferrreo commented Dec 5, 2024

Doesn't that patch undo 967fe76?

@vaxerski
Copy link
Member

vaxerski commented Dec 5, 2024

yes. @UjinT34 what was the point? I'm running the patch and it seems fine. IDK about nvidia.

@vaxerski
Copy link
Member

vaxerski commented Dec 5, 2024

the cursor does look choppy when tearing, but oh well.

@UjinT34
Copy link
Contributor

UjinT34 commented Dec 5, 2024

With explicit sync enabled HL expects to receive the fence from AQ and complains
Aquamarine did not return an explicit out fence

I don't know how this fence should be used. Looks like it should be waited either before committing the next frame or before reusing the current framebuffer. Waiting for it immediately after the commit feels too early. Not using it at all is probably the same as waiting for it before reusing the fb because it is very unlikely to block at that point. Maybe there is no point in this fence with double buffering.

@vaxerski
Copy link
Member

vaxerski commented Dec 5, 2024

yeah I don't think there is.

@vaxerski
Copy link
Member

vaxerski commented Dec 5, 2024

We can go with my patch, do you want me to commit it to main or will you apply it here and we roll with this MR?

@ferrreo
Copy link
Contributor Author

ferrreo commented Dec 5, 2024

We can go with my patch, do you want me to commit it to main or will you apply it here and we roll with this MR?

I think Just stick yer patch in main and I'll close this

@ferrreo ferrreo closed this Dec 5, 2024
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.

Fullscreen apps cap to refresh rate when tearing is enabled
3 participants