Frame generation: present and acquire queues from another family where the graphics family has one queue

AMD's Windows driver gives the graphics family a single queue. vk_device.c then made no frame generation queues, and
vk_fg_create_swapchain returned without a log line: AMD FSR 3.1 frame generation set in the menu did nothing on an
RX 580. The present queue (which nothing else may submit to) and the image acquire queue now come from a family that
can present, compute families first, with their families passed to AMD's swapchain; the log names them, or says that
there are none, and the menu offers FSR 3.1 frame generation only where they exist.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Tobim6
2026-11-12 16:23:12 +01:00
parent 4027229930
commit 293731d083
5 changed files with 83 additions and 26 deletions

View File

@@ -35,6 +35,7 @@ namespace {
struct {
VkQueue present = VK_NULL_HANDLE, acquire = VK_NULL_HANDLE;
uint32_t pfam = 0, afam = 0; // their queue families
ffxContext sc = nullptr; // the swapchain context
ffxContext fg = nullptr; // the frame generation context
VkExtent2D fg_ext = {0, 0};
@@ -102,6 +103,12 @@ extern "C" int vk_fg_wanted(void) {
if (F.sc) return !F.failed && !four;
if (four) return 1;
if (F.failed) return 0;
if (!F.present) { // no queue to present on besides the game's (vk_device.c says why): the plain swapchain stays
static int told_q;
if (!__atomic_exchange_n(&told_q, 1, __ATOMIC_RELAXED))
rt_log("fg: AMD FSR 3.1 frame generation is set, but the device got no queue for its presents: off");
return 0;
}
if (vk_ffx_framegen_available()) return 1;
static int told;
if (!__atomic_exchange_n(&told, 1, __ATOMIC_RELAXED))
@@ -112,11 +119,13 @@ extern "C" int vk_fg_wanted(void) {
// Always the three queues: the setting can be switched on during a run, and idle queues cost nothing.
extern "C" uint32_t vk_fg_queue_count(void) { return 3; }
extern "C" void vk_fg_queues(VkQueue present, VkQueue acquire) {
F.present = present, F.acquire = acquire;
vk_fg4_queues(present, acquire);
extern "C" void vk_fg_queues(VkQueue present, uint32_t present_family, VkQueue acquire, uint32_t acquire_family) {
F.present = present, F.acquire = acquire, F.pfam = present_family, F.afam = acquire_family;
vk_fg4_queues(present, present_family, acquire, acquire_family);
}
extern "C" int vk_fg_has_queues(void) { return F.present != VK_NULL_HANDLE; }
// AMD's swapchain is in place: the window's swapchain handle is AMD's object, and every swapchain call has to go
// through AMD's functions. That holds after a failure too, until the present code has replaced the swapchain
// (vk_fg_wanted): the plain Vulkan calls must never get that handle.
@@ -147,8 +156,8 @@ extern "C" VkResult vk_fg_create_swapchain(const VkSwapchainCreateInfoKHR *ci, V
d.createInfo.oldSwapchain = VK_NULL_HANDLE;
d.gameQueue = {c->gfx_queue, c->gfx_family, submit_game};
d.asyncComputeQueue = {VK_NULL_HANDLE, c->gfx_family, nullptr};
d.presentQueue = {F.present, c->gfx_family, nullptr};
d.imageAcquireQueue = {F.acquire, c->gfx_family, nullptr};
d.presentQueue = {F.present, F.pfam, nullptr};
d.imageAcquireQueue = {F.acquire, F.afam, nullptr};
ffxReturnCode_t r = vk_ffx_create(&F.sc, &d.header);
if (r != FFX_API_RETURN_OK) {
F.sc = nullptr;