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

Allow disabling waiting for latency waitable object #7400

Open
wants to merge 9 commits into
base: trunk
Choose a base branch
from

Conversation

marcpabst
Copy link
Contributor

@marcpabst marcpabst commented Mar 23, 2025

This PR allows you to skip the frame latency waitable mechanism used for the DX12 backend by adding a new option to Dx12BackendOptions. The options now also carry over to the DX12 Surface, and a waitable object is only obtained when use_latency_waitable_object == true. The swap chain still gets created with the DXGI_SWAP_CHAIN_FLAG_FRAME_LATENCY_WAITABLE_OBJECT flag, because I don't think there are any downsides and it lets users still obtain a waitable object themselves.

Not sure if this is the best way to do this or the right place for this setting, so let me know what you think. Happy to also change the docs.

@marcpabst marcpabst requested review from crowlKats and a team as code owners March 23, 2025 14:59
@cwfitzgerald cwfitzgerald self-assigned this Mar 23, 2025
Copy link
Member

@cwfitzgerald cwfitzgerald left a comment

Choose a reason for hiding this comment

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

Unless I missed something, seems to be missing the part where None doesn't make a swapchain with waitable object support.

Code looks pretty darn good otherwise :)

Comment on lines +555 to +558
pub unsafe fn wait_for_frame_latency_object(
&self,
timeout: Option<std::time::Duration>,
) -> Result<bool, crate::SurfaceError> {
Copy link
Member

Choose a reason for hiding this comment

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

This feels weird being pub

Copy link
Contributor Author

@marcpabst marcpabst Apr 1, 2025

Choose a reason for hiding this comment

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

My idea was that you don't need to expose the actual waitable handle this way. So wgpu can still handle the configuration of the swap chain and creation of the waitable object but we can abstract away the actual unsafe syscalls.

@marcpabst
Copy link
Contributor Author

Unless I missed something, seems to be missing the part where None doesn't make a swapchain with waitable object support.

Code looks pretty darn good otherwise :)

Yes, I thought that's the best way to deal with this. There's no documented downside to setting this flag, but with my (very limited) DX12 experience, that's not to say there are no side effects at all. So it might be better to at least give users an option to disable it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants