protonscr

How can I make sure VK_PRESENT_MODE_IMMEDIATE_KHR is used?

vkd3dclosed
HansKristian-Work/vkd3d-proton#2273 · opened 2025-01-07 by dougg0k · updated 2025-01-13 · 9 comments · github
Ddougg0k 2025-01-07 github

Hi,

How can I enable VK_PRESENT_MODE_IMMEDIATE_KHR (aka, tearing enabled) and make sure it's being used?

https://registry.khronos.org/vulkan/specs/latest/man/html/VkPresentModeKHR.html

With Nvidia.

Is it related to VKD3D_SWAPCHAIN_LATENCY_FRAMES set to 1?


With 2 frame latency where CPU and GPU are decently subscribed, the present wait event will come in with VBlank-alignment
Does this mean if I set to 1, there would be no vblank? If I understood incorrectly, what would?

It seem to make sense, as it is following similarly to gpu drivers, where priority are not input latency.

 /* 3 frames is the default in the API, so that's what we should report to application if asks. */
        chain->frame_latency = DEFAULT_FRAME_LATENCY;

Nvm, I think I found it.

present_mode = chain->request.swap_interval > 0 ? VK_PRESENT_MODE_FIFO_KHR : VK_PRESENT_MODE_IMMEDIATE_KHR;

So, 0 would be the one to be immediate. As long as 0 does not go back to default 3, like in does in gpu driver setting.

Unless the request->swap_interval = SyncInterval; has nothing to do with VKD3D_SWAPCHAIN_LATENCY_FRAMES.

If not, what does?


I wonder if VKD3D_SWAPCHAIN_IMAGES has anything related to low latency? Maybe it should be tested with 0 or 1.

Maybe it's similar to backbuffer from dxvk https://github.com/doitsujin/dxvk/issues/1636#issuecomment-632595403

Is it?

HHansKristian-Work maintainer 2025-01-08 github

What is the goal here? You want to force a game that is using vsync to not be vsynced?

Ddougg0k 2025-01-08 github

Lower latency, and sure, that also.

Most of the time, they have the option to disable vsync. But this is the idea of possibly making sure that the sync layer is always in the immediate. And if can reduce even further by other changes, that also.

HHansKristian-Work maintainer 2025-01-08 github

I'd expect the dxvk option to force period to 0. Maybe that's not hooked up for the interop DXGI swapchain. Maybe a question for @doitsujin.

Ddougg0k 2025-01-08 github

But isnt vkd3d for dx12, while dxvk for dx11? I want to know for dx12.

Does dxvk still has an effect on dx12?

HHansKristian-Work maintainer 2025-01-08 github

Yes. DXVK's DXGI implementation is used for D3D12 too. It forwards calls to vkd3d-proton.

Ddougg0k 2025-01-08 github

I see.

But can you tell what VKD3D_SWAPCHAIN_LATENCY_FRAMES and VKD3D_SWAPCHAIN_IMAGES have in relation to latency in all this?

HHansKristian-Work maintainer 2025-01-08 github

VKD3D_SWAPCHAIN_LATENCY_FRAMES is used for latency limiting on Present. It's mostly relevant for FIFO modes, but I suppose it can be useful for IMMEDIATE too, but it would make sure that CPU cannot run too far ahead of GPU. It's basically a DIY NV Reflex in that case.

Ddougg0k 2025-01-13 github

@HansKristian-Work What would be the ideal value for lowest latency with VKD3D_SWAPCHAIN_LATENCY_FRAMES in immediate?

Also, what is VKD3D_SWAPCHAIN_IMAGES and is it related to back buffers? If not, what is it's relation to latency?

HHansKristian-Work maintainer 2025-01-13 github

What would be the ideal value for lowest latency with VKD3D_SWAPCHAIN_LATENCY_FRAMES in immediate?

1, but FPS might drop due to missing CPU/GPU overlap. 2 should be ideal.

Also, what is VKD3D_SWAPCHAIN_IMAGES and is it related to back buffers? If not, what is it's relation to latency?

It is, but with present wait, number of swapchain images does not matter for latency.

Launch options

Upstream links