Project

General

Profile

Actions

Emulator Issues #10552

closed

Vulkan presentation modes issue

Added by markk about 7 years ago. Updated about 7 years ago.

Status:
Invalid
Priority:
Normal
Assignee:
-
% Done:

0%

Operating system:
N/A
Issue type:
Bug
Milestone:
Regression:
No
Relates to usability:
No
Relates to performance:
No
Easy:
No
Relates to maintainability:
No
Regression start:
Fixed in:

Description

In Source/Core/VideoBackends/Vulkan/SwapChain.cpp (as of Dolphin-5551), the SwapChain::SelectPresentMode() function is used to select the Vulkan presentation mode. (See below.)

If vsync is enabled, VK_PRESENT_MODE_FIFO_KHR will always be used, since that must be supported by the driver. But the "Use optimized-vsync above vsync" comment suggests that VK_PRESENT_MODE_MAILBOX_KHR should be used in preference to VK_PRESENT_MODE_FIFO_KHR. Currently VK_PRESENT_MODE_MAILBOX_KHR will only be used when the vsync option is not enabled, and the driver doesn't support VK_PRESENT_MODE_IMMEDIATE_KHR.

Also, in the non-vsync case, should you try for VK_PRESENT_MODE_FIFO_RELAXED_KHR if VK_PRESENT_MODE_IMMEDIATE_KHR is not available?

bool SwapChain::SelectPresentMode()
{
  ... stuff deleted ...
  // If vsync is enabled, use VK_PRESENT_MODE_FIFO_KHR.
  // This check should not fail with conforming drivers, as the FIFO present mode is mandated by
  // the specification (VK_KHR_swapchain). In case it isn't though, fall through to any other mode.
  if (m_vsync_enabled && CheckForMode(VK_PRESENT_MODE_FIFO_KHR))
  {
    m_present_mode = VK_PRESENT_MODE_FIFO_KHR;
    return true;
  }

  // Prefer screen-tearing, if possible, for lowest latency.
  if (CheckForMode(VK_PRESENT_MODE_IMMEDIATE_KHR))
  {
    m_present_mode = VK_PRESENT_MODE_IMMEDIATE_KHR;
    return true;
  }

  // Use optimized-vsync above vsync.
  if (CheckForMode(VK_PRESENT_MODE_MAILBOX_KHR))
  {
    m_present_mode = VK_PRESENT_MODE_MAILBOX_KHR;
    return true;
  }

  // Fall back to whatever is available.
  m_present_mode = present_modes[0];
  return true;
}
Actions #1

Updated by Stenzek about 7 years ago

  • Status changed from New to Invalid

Looks like an error in the comment. Mailbox is basically "scan out the last queued image, and replace any previously queued images if we render more than one before the next scanout time". Feel free to submit a PR to correct it ;)

It's been a while since I wrote that code, but I'm guessing it was a leftover from when I was using FIFO_RELAXED_KHR, which is "tear if vsync is missed". I ended up dropping it because there were quite a few complaints about tearing when vsync was enabled, presumably because Dolphin's frame timing wasn't aligning with the graphics driver. I suppose we could add a second vsync mode to the graphics options, since we can do this in OpenGL as well, SwapInterval(-1) if I recall correctly.

BTW, IRC is probably a better avenue for this sort of question than the bug tracker, most of us idle there, so even if you don't get a response immediately, usually we will see it eventually. :)

Actions #2

Updated by markk about 7 years ago

Stenzek wrote:

Looks like an error in the comment. Mailbox is basically "scan out the last queued image, and replace any previously queued images if we render more than one before the next scanout time". Feel free to submit a PR to correct it ;)

Wouldn't mailbox generally be preferable to FIFO due to lower latency? The issue being, you never use it when vsync is enabled.

It's been a while since I wrote that code, but I'm guessing it was a leftover from when I was using FIFO_RELAXED_KHR, which is "tear if vsync is missed". I ended up dropping it because there were quite a few complaints about tearing when vsync was enabled, presumably because Dolphin's frame timing wasn't aligning with the graphics driver. I suppose we could add a second vsync mode to the graphics options, since we can do this in OpenGL as well, SwapInterval(-1) if I recall correctly.

Some way to manually set the mode in the GUI would be great. For example some people might prefer FIFO_RELAXED which should give lower latency at the expense of tearing, in situations where their computer can't render a particular frame in < 1/60 sec.

In the absence of being able to manually specify, should the default be something like:

if vsync: [assume the user wants to never see tearing]
VK_PRESENT_MODE_MAILBOX_KHR if supported, [lower latency than VK_PRESENT_MODE_FIFO_KHR?]
else VK_PRESENT_MODE_FIFO_KHR if supported,
else default

if not vsync:
VK_PRESENT_MODE_IMMEDIATE_KHR if supported,
else VK_PRESENT_FIFO_RELAXED_KHR if supported, [not sure about relative order of this & mailbox]
else VK_PRESENT_MODE_MAILBOX_KHR if supported,
else default

Actions #3

Updated by Stenzek about 7 years ago

Using mailbox, at least on NV drivers, causes tearing in fullscreen mode ("exclusive fullscreen"). So we can't use that for vsync-on. I'm not sure if mailbox_relaxed would also behave this way, but exclusive fullscreen is desired by many users for the lowest latency possible.

IMO the best way to go would be to replace vsync with a drop-down box with three modes, "VSync off", "VSync on", "VSync where possible", corresponding to mailbox, fifo, and fifo_relaxed.

Actions #4

Updated by Helios about 7 years ago

Considering that we've already marked this as invalid, please move further discussion to IRC @ #dolphin-dev on freenode or the forums. Thanks.

Actions

Also available in: Atom PDF