Fix FG disable state reset and FSR3 context compatibility for SDK variants

This commit is contained in:
Kelsi 2026-03-08 23:32:02 -07:00
parent aa43aa6fc8
commit e600f003ca
2 changed files with 34 additions and 3 deletions

View file

@ -3,6 +3,8 @@
#include <algorithm>
#include <cstdlib>
#include <cstring>
#include <type_traits>
#include <utility>
#include <vector>
#include "core/logger.hpp"
@ -48,6 +50,24 @@ FfxErrorCode vkSwapchainConfigureNoop(const FfxFrameGenerationConfig*) {
return FFX_OK;
}
template <typename T, typename = void>
struct HasUpscaleOutputSize : std::false_type {};
template <typename T>
struct HasUpscaleOutputSize<T, std::void_t<decltype(std::declval<T&>().upscaleOutputSize)>> : std::true_type {};
template <typename T>
inline void setUpscaleOutputSizeIfPresent(T& ctxDesc, uint32_t width, uint32_t height) {
if constexpr (HasUpscaleOutputSize<T>::value) {
ctxDesc.upscaleOutputSize.width = width;
ctxDesc.upscaleOutputSize.height = height;
} else {
(void)ctxDesc;
(void)width;
(void)height;
}
}
FfxSurfaceFormat mapVkFormatToFfxSurfaceFormat(VkFormat format, bool isDepth) {
if (isDepth) {
switch (format) {
@ -233,8 +253,7 @@ bool AmdFsr3Runtime::initialize(const AmdFsr3RuntimeInitDesc& desc) {
if (desc.depthInverted) ctxDesc.flags |= FFX_FSR3_ENABLE_DEPTH_INVERTED;
ctxDesc.maxRenderSize.width = desc.maxRenderWidth;
ctxDesc.maxRenderSize.height = desc.maxRenderHeight;
ctxDesc.upscaleOutputSize.width = desc.displayWidth;
ctxDesc.upscaleOutputSize.height = desc.displayHeight;
setUpscaleOutputSizeIfPresent(ctxDesc, desc.displayWidth, desc.displayHeight);
ctxDesc.displaySize.width = desc.displayWidth;
ctxDesc.displaySize.height = desc.displayHeight;
if (!backendShared.fpSwapChainConfigureFrameGeneration) {

View file

@ -4413,6 +4413,10 @@ void Renderer::dispatchAmdFsr2() {
void Renderer::dispatchAmdFsr3Framegen() {
#if WOWEE_HAS_AMD_FSR3_FRAMEGEN
if (!fsr2_.amdFsr3FramegenEnabled) {
fsr2_.amdFsr3FramegenRuntimeActive = false;
return;
}
if (!fsr2_.amdFsr3Runtime || !fsr2_.amdFsr3FramegenRuntimeReady) {
fsr2_.amdFsr3FramegenRuntimeActive = false;
return;
@ -4517,7 +4521,7 @@ void Renderer::renderFSR2Sharpen() {
VkDescriptorImageInfo imgInfo{};
imgInfo.sampler = fsr2_.linearSampler;
if (fsr2_.useAmdBackend) {
imgInfo.imageView = (fsr2_.amdFsr3FramegenRuntimeActive && fsr2_.framegenOutput.imageView)
imgInfo.imageView = (fsr2_.amdFsr3FramegenEnabled && fsr2_.amdFsr3FramegenRuntimeActive && fsr2_.framegenOutput.imageView)
? fsr2_.framegenOutput.imageView
: fsr2_.history[outputIdx].imageView;
} else {
@ -4583,24 +4587,32 @@ void Renderer::setFSR2DebugTuning(float jitterSign, float motionVecScaleX, float
}
void Renderer::setAmdFsr3FramegenEnabled(bool enabled) {
if (fsr2_.amdFsr3FramegenEnabled == enabled) return;
fsr2_.amdFsr3FramegenEnabled = enabled;
#if WOWEE_HAS_AMD_FSR3_FRAMEGEN
if (enabled) {
fsr2_.amdFsr3FramegenRuntimeActive = false;
fsr2_.framegenOutputValid = false;
fsr2_.needsRecreate = true;
fsr2_.needsHistoryReset = true;
fsr2_.amdFsr3FramegenRuntimeReady = false;
LOG_INFO("FSR3 framegen requested; runtime will initialize on next FSR2 resource creation.");
} else {
fsr2_.amdFsr3FramegenRuntimeActive = false;
fsr2_.amdFsr3FramegenRuntimeReady = false;
fsr2_.framegenOutputValid = false;
fsr2_.needsHistoryReset = true;
fsr2_.needsRecreate = true;
if (fsr2_.amdFsr3Runtime) {
fsr2_.amdFsr3Runtime->shutdown();
fsr2_.amdFsr3Runtime.reset();
}
LOG_INFO("FSR3 framegen disabled; forcing FSR2-only path rebuild.");
}
#else
fsr2_.amdFsr3FramegenRuntimeActive = false;
fsr2_.amdFsr3FramegenRuntimeReady = false;
fsr2_.framegenOutputValid = false;
if (enabled) {
LOG_WARNING("FSR3 framegen requested, but AMD FSR3 framegen SDK headers are unavailable in this build.");
}