mirror of
https://github.com/tangerineturtle1/NX2navi.git
synced 2026-11-19 21:39:58 -04:00
Add frame generation through AMD's FSR SDK 2.4 as a setting to try with FSR 4, and never generate a frame without the HUD-less picture.
runtime/vk_fg4.cpp makes the frame generation swapchain and context with the libraries FSR 4 comes with (amd_fidelityfx_loader_vk.dll and amd_fidelityfx_framegeneration_vk.dll beside the executable). vk_fg.cpp takes that path only with fsr4_fg = 1 while FSR 4 is the upscaler; the default stays the FSR 3.1 library. The loader picks the version for the card: the machine-learned FSR Frame Generation 4 on Radeon RX 9000 cards with Windows 11, which is untested, and 3.1.6 elsewhere. On an RX 7900 XT (driver 26.10.1) it lists frame generation 3.1.6 and the swapchains 4.0.0, which the driver brings and the loader chooses, and 3.1.7. The swapchain in place is wanted only while its library is the one to use, so a change of the setting or of the upscaler, or a failure of this path, takes it down as switching frame generation off does and the next present makes it with the other library. The preparation gives this library the camera's position and axes, which FSR Frame Generation 4 requires, and a scene scale of one metre a unit: with the 0.01 the FSR 3.1 path uses, version 3.1.6 drew grey translucent shapes into the sky of its frames while the camera turned (160 captures of the screen during a camera sweep; clean with 1). Both paths now generate a frame only when the picture without the HUD is there for it: generated from the presented picture alone, the HUD would be warped with the scene behind it. In four configurations (21:9 with either library, a 16:9 picture in a 21:9 window, a 1080 picture without HDR) every generated frame had it, and the log counts the frames without. On screen, of the 6,404 pixels of the HUD's item button that stayed fixed through a camera sweep with the FSR 3.1 library, 6,162 stayed fixed with this one. Standing in Hyrule Field at 3440x1440 with FSR 4 Quality the game draws 43.0 frames a second with this path and 42.2 with the FSR 3.1 library, each shown twice over. One run changed the present mode, HDR, fullscreen, frame generation, FSR 4, this setting and the upscaler in turn: 216 screenshots without a bad frame, and no failure. The SDK's frame generation headers join runtime/third_party/ffx_sdk, unmodified. tools/make_kit.py and tools/make_launcher.py take the third library from the --ffx4 folder when it is there, and tools/make_game.py copies it beside the game. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
This commit is contained in:
150
runtime/third_party/ffx_sdk/framegeneration/include/vk/ffx_api_framegeneration_vk.h
vendored
Normal file
150
runtime/third_party/ffx_sdk/framegeneration/include/vk/ffx_api_framegeneration_vk.h
vendored
Normal file
@@ -0,0 +1,150 @@
|
||||
// This file is part of the FidelityFX SDK.
|
||||
//
|
||||
// Copyright (C) 2026 Advanced Micro Devices, Inc.
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files(the "Software"), to deal
|
||||
// in the Software without restriction, including without limitation the rights
|
||||
// to use, copy, modify, merge, publish, distribute, sublicense, and /or sell
|
||||
// copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions :
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in
|
||||
// all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
// THE SOFTWARE.
|
||||
|
||||
#pragma once
|
||||
#include "../../../api/include/vk/ffx_api_vk.h"
|
||||
|
||||
#define FFX_FRAMEGENERATION_SWAPCHAIN_VK_VERSION_MAJOR 4
|
||||
#define FFX_FRAMEGENERATION_SWAPCHAIN_VK_VERSION_MINOR 0
|
||||
#define FFX_FRAMEGENERATION_SWAPCHAIN_VK_VERSION_PATCH 0
|
||||
|
||||
#define FFX_FRAMEGENERATION_SWAPCHAIN_VK_MAKE_VERSION(major, minor, patch) (((major) << 22) | ((minor) << 12) | (patch))
|
||||
#define FFX_FRAMEGENERATION_SWAPCHAIN_VK_VERSION FFX_FRAMEGENERATION_SWAPCHAIN_VK_MAKE_VERSION(FFX_FRAMEGENERATION_SWAPCHAIN_VK_VERSION_MAJOR, FFX_FRAMEGENERATION_SWAPCHAIN_VK_VERSION_MINOR, FFX_FRAMEGENERATION_SWAPCHAIN_VK_VERSION_PATCH)
|
||||
|
||||
#define FFX_API_CREATE_CONTEXT_DESC_TYPE_FGSWAPCHAIN_VK FFX_API_MAKE_EFFECT_SUB_ID(FFX_API_EFFECT_ID_FRAMEGENERATIONSWAPCHAIN_VK, 0x01)
|
||||
struct ffxCreateContextDescFrameGenerationSwapChainVK
|
||||
{
|
||||
ffxCreateContextDescHeader header;
|
||||
VkPhysicalDevice physicalDevice; ///< the physicak device used by the program.
|
||||
VkDevice device; ///< the logical device used by the program.
|
||||
VkSwapchainKHR* swapchain; ///< the current swapchain to be replaced. Will be destroyed when the context is created. This can be VK_NULL_HANDLE. Will contain the new swapchain on return.
|
||||
VkAllocationCallbacks* allocator; ///< optional allocation callbacks.
|
||||
VkSwapchainCreateInfoKHR createInfo; ///< the description of the desired swapchain. If its VkSwapchainCreateInfoKHR::oldSwapchain field isn't VK_NULL_HANDLE, it should be the same as the ffxCreateContextDescFrameGenerationSwapChainVK::swapchain field above.
|
||||
VkQueueInfoFFXAPI gameQueue; ///< the main graphics queue, where Present is called.
|
||||
VkQueueInfoFFXAPI asyncComputeQueue; ///< A queue with Compute capability.
|
||||
VkQueueInfoFFXAPI presentQueue; ///< A queue with Transfer and Present capabilities.
|
||||
VkQueueInfoFFXAPI imageAcquireQueue; ///< A queue with no capability required.
|
||||
};
|
||||
|
||||
#define FFX_API_CONFIGURE_DESC_TYPE_FGSWAPCHAIN_REGISTERUIRESOURCE_VK FFX_API_MAKE_EFFECT_SUB_ID(FFX_API_EFFECT_ID_FRAMEGENERATIONSWAPCHAIN_VK, 0x02)
|
||||
struct ffxConfigureDescFrameGenerationSwapChainRegisterUiResourceVK
|
||||
{
|
||||
ffxConfigureDescHeader header;
|
||||
struct FfxApiResource uiResource; ///< Resource containing user interface for composition. May be empty.
|
||||
uint32_t flags; ///< Zero or combination of values from FfxApiUiCompositionFlags.
|
||||
};
|
||||
|
||||
#define FFX_API_QUERY_DESC_TYPE_FGSWAPCHAIN_INTERPOLATIONCOMMANDLIST_VK FFX_API_MAKE_EFFECT_SUB_ID(FFX_API_EFFECT_ID_FRAMEGENERATIONSWAPCHAIN_VK, 0x03)
|
||||
struct ffxQueryDescFrameGenerationSwapChainInterpolationCommandListVK
|
||||
{
|
||||
ffxQueryDescHeader header;
|
||||
void** pOutCommandList; ///< Output command nuffer (VkCommandBuffer) to be used for frame generation dispatch.
|
||||
};
|
||||
|
||||
#define FFX_API_QUERY_DESC_TYPE_FGSWAPCHAIN_INTERPOLATIONTEXTURE_VK FFX_API_MAKE_EFFECT_SUB_ID(FFX_API_EFFECT_ID_FRAMEGENERATIONSWAPCHAIN_VK, 0x04)
|
||||
struct ffxQueryDescFrameGenerationSwapChainInterpolationTextureVK
|
||||
{
|
||||
ffxQueryDescHeader header;
|
||||
struct FfxApiResource* pOutTexture; ///< Output resource in which the frame interpolation result should be placed.
|
||||
};
|
||||
|
||||
#define FFX_API_DISPATCH_DESC_TYPE_FGSWAPCHAIN_WAIT_FOR_PRESENTS_VK FFX_API_MAKE_EFFECT_SUB_ID(FFX_API_EFFECT_ID_FRAMEGENERATIONSWAPCHAIN_VK, 0x07)
|
||||
struct ffxDispatchDescFrameGenerationSwapChainWaitForPresentsVK
|
||||
{
|
||||
ffxDispatchDescHeader header;
|
||||
};
|
||||
|
||||
#define FFX_API_CONFIGURE_DESC_TYPE_FRAMEGENERATIONSWAPCHAIN_KEYVALUE_VK FFX_API_MAKE_EFFECT_SUB_ID(FFX_API_EFFECT_ID_FRAMEGENERATIONSWAPCHAIN_VK, 0x08)
|
||||
struct ffxConfigureDescFrameGenerationSwapChainKeyValueVK
|
||||
{
|
||||
ffxConfigureDescHeader header;
|
||||
uint64_t key; ///< Configuration key, member of the FfxApiConfigureFrameGenerationSwapChainKeyVK enumeration.
|
||||
uint64_t u64; ///< Integer value or enum value to set.
|
||||
void* ptr; ///< Pointer to set or pointer to value to set.
|
||||
};
|
||||
|
||||
//enum value matches enum FfxFrameInterpolationSwapchainConfigureKey
|
||||
enum FfxApiConfigureFrameGenerationSwapChainKeyVK
|
||||
{
|
||||
FFX_API_CONFIGURE_FG_SWAPCHAIN_KEY_WAITCALLBACK = 0, ///< Sets FfxWaitCallbackFunc
|
||||
FFX_API_CONFIGURE_FG_SWAPCHAIN_KEY_FRAMEPACINGTUNING = 2, ///< Sets FfxApiSwapchainFramePacingTuning casted from ptr
|
||||
};
|
||||
|
||||
#define FFX_API_QUERY_DESC_TYPE_FRAMEGENERATIONSWAPCHAIN_GPU_MEMORY_USAGE_VK FFX_API_MAKE_EFFECT_SUB_ID(FFX_API_EFFECT_ID_FRAMEGENERATIONSWAPCHAIN_VK, 0x09)
|
||||
struct ffxQueryFrameGenerationSwapChainGetGPUMemoryUsageVK
|
||||
{
|
||||
ffxQueryDescHeader header;
|
||||
struct FfxApiEffectMemoryUsage* gpuMemoryUsageFrameGenerationSwapchain; ///< Output pointer. Requires an existing swapchain context.
|
||||
};
|
||||
|
||||
/// Pre-context GPU memory estimate for a Vulkan frame-generation swapchain.
|
||||
/// Does not require an ffxContext. Pass the device and the swapchain configuration the application intends to create.
|
||||
#define FFX_API_QUERY_DESC_TYPE_FRAMEGENERATIONSWAPCHAIN_GPU_MEMORY_USAGE_VK_V2 FFX_API_MAKE_EFFECT_SUB_ID(FFX_API_EFFECT_ID_FRAMEGENERATIONSWAPCHAIN_VK, 0x0b)
|
||||
struct ffxQueryFrameGenerationSwapChainGetGPUMemoryUsageVKV2
|
||||
{
|
||||
ffxQueryDescHeader header; ///< Description header for the pre-context GPU memory query.
|
||||
VkDevice device; ///< Logical device used to size images. Required.
|
||||
VkPhysicalDevice physicalDevice; ///< Physical device that owns the logical device. Required. Used to select an external provider.
|
||||
struct FfxApiDimensions2D displaySize; ///< Resolution of rendered and generated frames. Required.
|
||||
uint32_t backBufferFormat; ///< Backbuffer format. One of the values from FfxApiSurfaceFormat. Required.
|
||||
uint32_t backBufferCount; ///< Number of application backbuffers, from 1 through 6. Required.
|
||||
struct FfxApiDimensions2D uiResourceSize; ///< UI resource resolution. Required when flags requests internal UI double buffering, otherwise ignored.
|
||||
uint32_t uiResourceFormat; ///< UI resource format. One of the values from FfxApiSurfaceFormat. Required when flags requests internal UI double buffering.
|
||||
uint32_t flags; ///< UI composition flags. Zero or a combination of values from FfxApiUiCompositionFlags.
|
||||
uint32_t composeOnGameQueue; ///< Nonzero when UI composition runs on the game queue. Adds the composition output image.
|
||||
uint32_t reserved; ///< Must be zero.
|
||||
struct FfxApiEffectMemoryUsage* gpuMemoryUsageFrameGenerationSwapchain; ///< Output. totalUsageInBytes is the sum of the swapchain images. aliasableUsageInBytes is zero because those images stay live together.
|
||||
};
|
||||
|
||||
/// Function to get the number of presents. This is useful when using frame interpolation
|
||||
typedef uint64_t(*PFN_getLastPresentCountFFXAPI)(VkSwapchainKHR);
|
||||
|
||||
/// FFX API specific functions to create and destroy a swapchain
|
||||
typedef VkResult(*PFN_vkCreateSwapchainFFXAPI)(VkDevice device, const VkSwapchainCreateInfoKHR* pCreateInfo, const VkAllocationCallbacks* pAllocator, VkSwapchainKHR* pSwapchain, void* pContext);
|
||||
typedef void(*PFN_vkDestroySwapchainFFXAPI)(VkDevice device, VkSwapchainKHR swapchain, const VkAllocationCallbacks* pAllocator, void* pContext);
|
||||
|
||||
#define FFX_API_QUERY_DESC_TYPE_FGSWAPCHAIN_FUNCTIONS_VK FFX_API_MAKE_EFFECT_SUB_ID(FFX_API_EFFECT_ID_FRAMEGENERATIONSWAPCHAIN_VK, 0x05)
|
||||
struct ffxQueryDescSwapchainReplacementFunctionsVK
|
||||
{
|
||||
ffxQueryDescHeader header;
|
||||
PFN_vkCreateSwapchainFFXAPI pOutCreateSwapchainFFXAPI; ///< Replacement of vkCreateSwapchainKHR. Recreates the swapchain in place (for example on resize or vsync toggle); pContext and the returned handle are the existing frame generation swapchain.
|
||||
PFN_vkDestroySwapchainFFXAPI pOutDestroySwapchainFFXAPI; ///< Replacement of vkDestroySwapchainKHR. Must be called after the swapchain context is destroyed; pContext is the frame generation swapchain. The handle is invalid afterwards.
|
||||
PFN_vkGetSwapchainImagesKHR pOutGetSwapchainImagesKHR; ///< Replacement of vkGetSwapchainImagesKHR.
|
||||
PFN_vkAcquireNextImageKHR pOutAcquireNextImageKHR; ///< Replacement of vkAcquireNextImageKHR.
|
||||
PFN_vkQueuePresentKHR pOutQueuePresentKHR; ///< Replacement of vkQueuePresentKHR.
|
||||
PFN_vkSetHdrMetadataEXT pOutSetHdrMetadataEXT; ///< Replacement of vkSetHdrMetadataEXT.
|
||||
PFN_getLastPresentCountFFXAPI pOutGetLastPresentCountFFXAPI; ///< Additional function to get the number of times present has been called since the swapchain creation.
|
||||
};
|
||||
|
||||
#define FFX_API_CREATE_CONTEXT_DESC_TYPE_FGSWAPCHAIN_MODE_VK FFX_API_MAKE_EFFECT_SUB_ID(FFX_API_EFFECT_ID_FRAMEGENERATIONSWAPCHAIN_VK, 0x10)
|
||||
struct ffxCreateContextDescFrameGenerationSwapChainModeVK
|
||||
{
|
||||
ffxCreateContextDescHeader header;
|
||||
bool composeOnPresentQueue; ///< flags indicating that composition will happen on the present queue
|
||||
};
|
||||
|
||||
#define FFX_API_CREATE_CONTEXT_DESC_TYPE_FRAMEGENERATIONSWAPCHAIN_VERSION_VK FFX_API_MAKE_EFFECT_SUB_ID(FFX_API_EFFECT_ID_FRAMEGENERATIONSWAPCHAIN_VK, 0x0a)
|
||||
struct ffxCreateContextDescFrameGenerationSwapChainVersionVK
|
||||
{
|
||||
ffxCreateContextDescHeader header; ///< Description header for frame generation swapchain version context creation.
|
||||
uint32_t version; ///< The API version the application was built against. This must be set to FFX_FRAMEGENERATION_SWAPCHAIN_VK_VERSION.
|
||||
};
|
||||
Reference in New Issue
Block a user