Commit 260d6f0e authored by Bas Nieuwenhuizen's avatar Bas Nieuwenhuizen
Browse files

HACK: vulkan/wsi: enable freesync.

parent 58376c6b
......@@ -1297,6 +1297,31 @@ x11_swapchain_destroy(struct wsi_swapchain *anv_chain,
return VK_SUCCESS;
static void
x11_set_adaptive_sync_property(xcb_connection_t *conn, xcb_drawable_t drawable,
uint32_t state)
static char const name[] = "_VARIABLE_REFRESH";
xcb_intern_atom_cookie_t cookie;
xcb_intern_atom_reply_t* reply;
xcb_void_cookie_t check;
cookie = xcb_intern_atom(conn, 0, sizeof(name), name);
Please register or sign in to reply
reply = xcb_intern_atom_reply(conn, cookie, NULL);
if (reply == NULL)
if (state)
check = xcb_change_property_checked(conn, XCB_PROP_MODE_REPLACE,
drawable, reply->atom,
XCB_ATOM_CARDINAL, 32, 1, &state);
check = xcb_delete_property_checked(conn, drawable, reply->atom);
xcb_discard_reply(conn, check.sequence);
static VkResult
x11_surface_create_swapchain(VkIcdSurfaceBase *icd_surface,
VkDevice device,
......@@ -1447,6 +1472,8 @@ x11_surface_create_swapchain(VkIcdSurfaceBase *icd_surface,
x11_set_adaptive_sync_property(conn, window, true);
for (int i = 0; i < ARRAY_SIZE(modifiers); i++)
vk_free(pAllocator, modifiers[i]);
*swapchain_out = &chain->base;
  • FWIW, no FreeSync capable monitor is needed for testing this patch. All that's needed is verifying that starting an app hits amdgpu_vrr_property_update with the variable_refresh parameter set to TRUE in Xorg. In that case, VRR can be enabled while the app's window uses page flipping.

  • Could you please elaborate how it would be indicated when amdgpu_vrr_property_update is hit? I'm with Linux 5.0 DC, xf86-video-amdgpu-git, and, according to xorg log, VRR is properly configured. But I can't see any hint in the terminal or xorg log if a fullscreen application hits that property, be it radeonsi or radv (display not capable of VRR).

  • @aufkrawall you need to either attach gdb to Xorg and set a breakpoint (don't try this from within the Xorg session :), or add debugging output to amdgpu_vrr_property_update.

  • Thank you. That's unfortunately a bit beyond my reach, but I probably can test it with a VRR display at the end of the week if there aren't many reports.

  • Hi, I've spent a couple of hours experimenting with your branch. I have a VRR display and have Freesync working on OpenGL. My monitor has an FPS counter that shows what refresh rate it's running at.

    What I've found is, Freesync with Vulkan works, but it's a bit brittle. If I ran a Vulkan program and alt-tabbed away and back, I'd often be locked at 60Hz until I quit the Vulkan program and ran it again. Sometimes I could get Freesync back by closing the terminal program I'd alt-tabbed out to. For a while I thought Freesync wasn't working at all because I had alt-tabbed to check log files and bugged it.

    If I just run a program and it doesn't lose focus, Freesync works. I had success with Refresh2025 in Vulkan mode and with World of Warcraft + DXVK.

    I spent five minutes just wandering around in World of Warcraft with all the detail settings maxed out, getting between 40 and 60 FPS. No tearing or stutter, the monitor's FPS counter matched the in-game FPS number.

    Edited by zurohki
  • Are you absolutely sure that the compositor successfully unredirected (turned off) after Alt + Tabbing again into the game? Could you test a Plasma session with deactivated compositor?

  • @zurohki the Alt-Tab issue doesn't happen with OpenGL apps?

  • This patch works fine and I hope it will be merged asap to the mainline Mesa. I tested with 2 Linux games and 2 windows games that works with freesync. Video:

    The Shadow of the Tomb Raider Benchmark has a fps meter and it proves that RADV freesync works fine.

    You can live without alt tabbing from games.

  • I've spent some more time with the patch now.

    If I alt-tab away from World of Warcraft and back, I'll usually have lost Freesync. But if I alt-tab away from the game again, maximise all other programs over top of WoW then minimise them all, when World of Warcraft is the only thing left it will have Freesync again.

    I have the same issue with Bioshock Infinite, which is a native OpenGL game, except that the magic dance described above doesn't work. I need to actually quit the game and run it again to get Freesync back.

    I tried both games with compositing turned off on KDE 5.

    Only guessing, but it seems like maybe there's an issue detecting which window has focus? So it doesn't notice the game is back?

  • @zurohki sounds like some kind of bug in the xf86-video-amdgpu code keeping track of which window is flipping / whether VRR should be enabled for it. Please file a bug report:

  • mentioned in merge request mesa/mesa!672 (merged)

    Toggle commit list
  • mentioned in issue xorg/driver/xf86-video-amdgpu#3

    Toggle commit list
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment