mirror of
https://github.com/tangerineturtle1/NX2navi.git
synced 2026-11-19 12:59:58 -04:00
Add AMD FSR 3.1 frame generation: a generated frame between every two the game draws.
With Frame generation set to AMD FSR 3.1 (after a restart), AMD's frame generation swapchain takes the place of the present path's own: the device creates two more graphics queues for its presents and image acquires, the present path acquires, gets images and presents through its replacement functions, and every frame configures generation and records its preparation from the depth and camera motion vectors the DLSS or FSR 3.1 upscaling pass made (one of them must be on). Generation pauses while the menu is open. On an RTX 5090 at a 60 fps game, about one frame was generated for every frame drawn in play. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -10,6 +10,9 @@
|
||||
#include "vk.h"
|
||||
#include "platform/platform.h"
|
||||
#include "vk_dlaa.h"
|
||||
#include "vk_fg.h"
|
||||
|
||||
static uint32_t g_gfx_queues = 1; // queues the graphics family offers (pick_device)
|
||||
|
||||
static VkCtx g_vk;
|
||||
static int g_ready;
|
||||
@@ -184,6 +187,7 @@ static int pick_device(void) {
|
||||
VkQueueFamilyProperties *qp = calloc(nq ? nq : 1, sizeof *qp);
|
||||
vkGetPhysicalDeviceQueueFamilyProperties(g_vk.phys, &nq, qp);
|
||||
g_vk.gfx_family = find_gfx_family(g_vk.phys, qp, nq);
|
||||
g_gfx_queues = qp[g_vk.gfx_family].queueCount;
|
||||
g_vk.xfer_family = g_vk.gfx_family;
|
||||
for (uint32_t i = 0; i < nq; i++) // a family that does transfer only (async DMA engine)
|
||||
if ((qp[i].queueFlags & VK_QUEUE_TRANSFER_BIT) && !(qp[i].queueFlags & (VK_QUEUE_GRAPHICS_BIT | VK_QUEUE_COMPUTE_BIT))) {
|
||||
@@ -340,14 +344,16 @@ static int create_device(void) {
|
||||
has_fbl && c->fbl.attachmentFeedbackLoopLayout, has_lr && c->lr.dynamicRenderingLocalRead);
|
||||
}
|
||||
|
||||
float prio = 1.0f;
|
||||
// Frame generation (vk_fg.cpp) presents on a second queue of the graphics family and acquires on a third
|
||||
static const float prio[3] = {1.0f, 1.0f, 1.0f};
|
||||
uint32_t nq_gfx = vk_fg_queue_count() < g_gfx_queues ? vk_fg_queue_count() : g_gfx_queues;
|
||||
VkDeviceQueueCreateInfo qi[2] = {
|
||||
{.sType = VK_STRUCTURE_TYPE_DEVICE_QUEUE_CREATE_INFO, .queueFamilyIndex = g_vk.gfx_family, .queueCount = 1,
|
||||
.pQueuePriorities = &prio}};
|
||||
{.sType = VK_STRUCTURE_TYPE_DEVICE_QUEUE_CREATE_INFO, .queueFamilyIndex = g_vk.gfx_family, .queueCount = nq_gfx,
|
||||
.pQueuePriorities = prio}};
|
||||
uint32_t nqi = 1;
|
||||
if (g_vk.xfer_family != g_vk.gfx_family) {
|
||||
qi[1] = (VkDeviceQueueCreateInfo){.sType = VK_STRUCTURE_TYPE_DEVICE_QUEUE_CREATE_INFO,
|
||||
.queueFamilyIndex = g_vk.xfer_family, .queueCount = 1, .pQueuePriorities = &prio};
|
||||
.queueFamilyIndex = g_vk.xfer_family, .queueCount = 1, .pQueuePriorities = prio};
|
||||
nqi = 2;
|
||||
}
|
||||
VkDeviceCreateInfo di = {.sType = VK_STRUCTURE_TYPE_DEVICE_CREATE_INFO, .pNext = &c->f2, .queueCreateInfoCount = nqi,
|
||||
@@ -356,6 +362,12 @@ static int create_device(void) {
|
||||
free(c);
|
||||
if (r != VK_SUCCESS) { rt_log("vk: vkCreateDevice failed (%d)", (int)r); return 0; }
|
||||
vkGetDeviceQueue(g_vk.device, g_vk.gfx_family, 0, &g_vk.gfx_queue);
|
||||
if (nq_gfx >= 2) {
|
||||
VkQueue present, acquire;
|
||||
vkGetDeviceQueue(g_vk.device, g_vk.gfx_family, 1, &present);
|
||||
vkGetDeviceQueue(g_vk.device, g_vk.gfx_family, nq_gfx - 1, &acquire);
|
||||
vk_fg_queues(present, acquire);
|
||||
}
|
||||
if (g_vk.xfer_family != g_vk.gfx_family) vkGetDeviceQueue(g_vk.device, g_vk.xfer_family, 0, &g_vk.xfer_queue);
|
||||
else { g_vk.xfer_queue = g_vk.gfx_queue; g_vk.xfer_shared = 1; }
|
||||
|
||||
|
||||
Reference in New Issue
Block a user