diff --git a/include/rendering/amd_fsr3_wrapper_abi.h b/include/rendering/amd_fsr3_wrapper_abi.h index a13783be..7cf94201 100644 --- a/include/rendering/amd_fsr3_wrapper_abi.h +++ b/include/rendering/amd_fsr3_wrapper_abi.h @@ -78,9 +78,16 @@ enum { WOWEE_FSR3_WRAPPER_EXTERNAL_RELEASE_SEMAPHORE = 1u << 6 }; +enum { + WOWEE_FSR3_WRAPPER_CAP_UPSCALE = 1u << 0, + WOWEE_FSR3_WRAPPER_CAP_FRAME_GENERATION = 1u << 1, + WOWEE_FSR3_WRAPPER_CAP_EXTERNAL_INTEROP = 1u << 2 +}; + uint32_t wowee_fsr3_wrapper_get_abi_version(void); const char* wowee_fsr3_wrapper_get_name(void); const char* wowee_fsr3_wrapper_get_backend(WoweeFsr3WrapperContext context); +uint32_t wowee_fsr3_wrapper_get_capabilities(WoweeFsr3WrapperContext context); int32_t wowee_fsr3_wrapper_initialize(const WoweeFsr3WrapperInitDesc* initDesc, WoweeFsr3WrapperContext* outContext, char* outErrorText, diff --git a/src/rendering/amd_fsr3_runtime.cpp b/src/rendering/amd_fsr3_runtime.cpp index f32e0538..f0b14b14 100644 --- a/src/rendering/amd_fsr3_runtime.cpp +++ b/src/rendering/amd_fsr3_runtime.cpp @@ -29,6 +29,7 @@ struct AmdFsr3Runtime::RuntimeFns { uint32_t (*wrapperGetAbiVersion)() = nullptr; const char* (*wrapperGetName)() = nullptr; const char* (*wrapperGetBackend)(WoweeFsr3WrapperContext) = nullptr; + uint32_t (*wrapperGetCapabilities)(WoweeFsr3WrapperContext) = nullptr; int32_t (*wrapperInitialize)(const WoweeFsr3WrapperInitDesc*, WoweeFsr3WrapperContext*, char*, uint32_t) = nullptr; int32_t (*wrapperDispatchUpscale)(WoweeFsr3WrapperContext, const WoweeFsr3WrapperDispatchDesc*) = nullptr; int32_t (*wrapperDispatchFramegen)(WoweeFsr3WrapperContext, const WoweeFsr3WrapperDispatchDesc*) = nullptr; @@ -238,6 +239,7 @@ bool AmdFsr3Runtime::initialize(const AmdFsr3RuntimeInitDesc& desc) { fns_->wrapperGetAbiVersion = reinterpret_castwrapperGetAbiVersion)>(resolveSym("wowee_fsr3_wrapper_get_abi_version")); fns_->wrapperGetName = reinterpret_castwrapperGetName)>(resolveSym("wowee_fsr3_wrapper_get_name")); fns_->wrapperGetBackend = reinterpret_castwrapperGetBackend)>(resolveSym("wowee_fsr3_wrapper_get_backend")); + fns_->wrapperGetCapabilities = reinterpret_castwrapperGetCapabilities)>(resolveSym("wowee_fsr3_wrapper_get_capabilities")); fns_->wrapperInitialize = reinterpret_castwrapperInitialize)>(resolveSym("wowee_fsr3_wrapper_initialize")); fns_->wrapperDispatchUpscale = reinterpret_castwrapperDispatchUpscale)>(resolveSym("wowee_fsr3_wrapper_dispatch_upscale")); fns_->wrapperDispatchFramegen = reinterpret_castwrapperDispatchFramegen)>(resolveSym("wowee_fsr3_wrapper_dispatch_framegen")); @@ -293,9 +295,20 @@ bool AmdFsr3Runtime::initialize(const AmdFsr3RuntimeInitDesc& desc) { } wrapperContext_ = wrapperCtx; - frameGenerationReady_ = desc.enableFrameGeneration; + frameGenerationReady_ = false; ready_ = true; backend_ = RuntimeBackend::Wrapper; + uint32_t wrapperCaps = 0; + if (fns_->wrapperGetCapabilities) { + wrapperCaps = fns_->wrapperGetCapabilities(wrapperCtx); + } else { + wrapperCaps = WOWEE_FSR3_WRAPPER_CAP_UPSCALE; + if (fns_->wrapperDispatchFramegen) { + wrapperCaps |= WOWEE_FSR3_WRAPPER_CAP_FRAME_GENERATION; + } + } + frameGenerationReady_ = desc.enableFrameGeneration && + ((wrapperCaps & WOWEE_FSR3_WRAPPER_CAP_FRAME_GENERATION) != 0u); if (fns_->wrapperGetBackend) { const char* backendName = fns_->wrapperGetBackend(wrapperCtx); if (backendName && *backendName) wrapperBackendName_ = backendName; @@ -303,7 +316,9 @@ bool AmdFsr3Runtime::initialize(const AmdFsr3RuntimeInitDesc& desc) { if (fns_->wrapperGetName) { const char* wrapperName = fns_->wrapperGetName(); if (wrapperName && *wrapperName) { - LOG_INFO("FSR3 runtime: wrapper active: ", wrapperName); + LOG_INFO("FSR3 runtime: wrapper active: ", wrapperName, + " backend=", wrapperBackendName_.empty() ? "unknown" : wrapperBackendName_, + " caps=0x", static_cast(wrapperCaps)); } } return true; diff --git a/src/rendering/amd_fsr3_wrapper_impl.cpp b/src/rendering/amd_fsr3_wrapper_impl.cpp index f77102c3..5af7e817 100644 --- a/src/rendering/amd_fsr3_wrapper_impl.cpp +++ b/src/rendering/amd_fsr3_wrapper_impl.cpp @@ -596,6 +596,26 @@ WOWEE_FSR3_WRAPPER_EXPORT const char* wowee_fsr3_wrapper_get_backend(WoweeFsr3Wr #endif } +WOWEE_FSR3_WRAPPER_EXPORT uint32_t wowee_fsr3_wrapper_get_capabilities(WoweeFsr3WrapperContext context) { +#if WOWEE_HAS_AMD_FSR3_FRAMEGEN + WrapperContext* ctx = reinterpret_cast(context); + if (!ctx) return 0; + uint32_t caps = WOWEE_FSR3_WRAPPER_CAP_UPSCALE; + if (ctx->frameGenerationReady && ctx->fns.fsr3DispatchFrameGeneration) { + caps |= WOWEE_FSR3_WRAPPER_CAP_FRAME_GENERATION; + } +#if defined(_WIN32) + if (ctx->backend == WrapperBackend::Dx12Bridge) { + caps |= WOWEE_FSR3_WRAPPER_CAP_EXTERNAL_INTEROP; + } +#endif + return caps; +#else + (void)context; + return 0; +#endif +} + WOWEE_FSR3_WRAPPER_EXPORT int32_t wowee_fsr3_wrapper_initialize(const WoweeFsr3WrapperInitDesc* initDesc, WoweeFsr3WrapperContext* outContext, char* outErrorText,