Add wrapper capability query and runtime capability gating

This commit is contained in:
Kelsi 2026-03-09 02:19:11 -07:00
parent 45c2ed7a64
commit 40289c5f8e
3 changed files with 44 additions and 2 deletions

View file

@ -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,

View file

@ -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_cast<decltype(fns_->wrapperGetAbiVersion)>(resolveSym("wowee_fsr3_wrapper_get_abi_version"));
fns_->wrapperGetName = reinterpret_cast<decltype(fns_->wrapperGetName)>(resolveSym("wowee_fsr3_wrapper_get_name"));
fns_->wrapperGetBackend = reinterpret_cast<decltype(fns_->wrapperGetBackend)>(resolveSym("wowee_fsr3_wrapper_get_backend"));
fns_->wrapperGetCapabilities = reinterpret_cast<decltype(fns_->wrapperGetCapabilities)>(resolveSym("wowee_fsr3_wrapper_get_capabilities"));
fns_->wrapperInitialize = reinterpret_cast<decltype(fns_->wrapperInitialize)>(resolveSym("wowee_fsr3_wrapper_initialize"));
fns_->wrapperDispatchUpscale = reinterpret_cast<decltype(fns_->wrapperDispatchUpscale)>(resolveSym("wowee_fsr3_wrapper_dispatch_upscale"));
fns_->wrapperDispatchFramegen = reinterpret_cast<decltype(fns_->wrapperDispatchFramegen)>(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<unsigned int>(wrapperCaps));
}
}
return true;

View file

@ -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<WrapperContext*>(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,