Kelsidavis-WoWee/include/rendering/amd_fsr3_runtime.hpp
Kelsi bae32c1823 Add FSR3 Generic API path and harden runtime diagnostics
- AmdFsr3Runtime now probes both the legacy ffxFsr3* API and the newer
  generic ffxCreateContext/ffxDispatch API; selects whichever the loaded
  runtime library exports (GenericApi takes priority fallback)
- Generic API path implements full upscale + frame-generation context
  creation, configure, dispatch, and destroy lifecycle
- dlopen error captured and surfaced in lastError_ on Linux so runtime
  initialization failures are actionable
- FSR3 runtime init failure log now includes path kind, error string,
  and loaded library path for easier debugging
- tools/generate_ffx_sdk_vk_permutations.sh added: auto-bootstraps
  missing VK permutation headers; DXC auto-downloaded on Linux/Windows
  MSYS2; macOS reads from PATH (CI installs via brew dxc)
- CMakeLists: add upscalers/include to probe include dirs, invoke
  permutation script before SDK build, scope FFX pragma/ODR warning
  suppressions to affected TUs, add runtime-copy dependency on wowee
- UI labels updated from "FSR2" → "FSR3" in settings, tuning panel,
  performance HUD, and combo boxes
- CI macOS job now installs dxc via Homebrew for permutation codegen
2026-03-09 12:51:59 -07:00

94 lines
2.8 KiB
C++

#pragma once
#include <cstdint>
#include <string>
#include <vulkan/vulkan.h>
namespace wowee::rendering {
struct AmdFsr3RuntimeInitDesc {
VkPhysicalDevice physicalDevice = VK_NULL_HANDLE;
VkDevice device = VK_NULL_HANDLE;
PFN_vkGetDeviceProcAddr getDeviceProcAddr = nullptr;
uint32_t maxRenderWidth = 0;
uint32_t maxRenderHeight = 0;
uint32_t displayWidth = 0;
uint32_t displayHeight = 0;
VkFormat colorFormat = VK_FORMAT_UNDEFINED;
bool hdrInput = false;
bool depthInverted = false;
bool enableFrameGeneration = false;
};
struct AmdFsr3RuntimeDispatchDesc {
VkCommandBuffer commandBuffer = VK_NULL_HANDLE;
VkImage colorImage = VK_NULL_HANDLE;
VkImage depthImage = VK_NULL_HANDLE;
VkImage motionVectorImage = VK_NULL_HANDLE;
VkImage outputImage = VK_NULL_HANDLE;
VkImage frameGenOutputImage = VK_NULL_HANDLE;
uint32_t renderWidth = 0;
uint32_t renderHeight = 0;
uint32_t outputWidth = 0;
uint32_t outputHeight = 0;
VkFormat colorFormat = VK_FORMAT_UNDEFINED;
VkFormat depthFormat = VK_FORMAT_UNDEFINED;
VkFormat motionVectorFormat = VK_FORMAT_R16G16_SFLOAT;
VkFormat outputFormat = VK_FORMAT_UNDEFINED;
float jitterX = 0.0f;
float jitterY = 0.0f;
float motionScaleX = 1.0f;
float motionScaleY = 1.0f;
float frameTimeDeltaMs = 16.67f;
float cameraNear = 0.1f;
float cameraFar = 1000.0f;
float cameraFovYRadians = 1.0f;
bool reset = false;
};
class AmdFsr3Runtime {
public:
enum class LoadPathKind {
None,
Official
};
AmdFsr3Runtime();
~AmdFsr3Runtime();
bool initialize(const AmdFsr3RuntimeInitDesc& desc);
bool dispatchUpscale(const AmdFsr3RuntimeDispatchDesc& desc);
bool dispatchFrameGeneration(const AmdFsr3RuntimeDispatchDesc& desc);
void shutdown();
bool isReady() const { return ready_; }
bool isFrameGenerationReady() const { return frameGenerationReady_; }
const std::string& loadedLibraryPath() const { return loadedLibraryPath_; }
LoadPathKind loadPathKind() const { return loadPathKind_; }
const std::string& lastError() const { return lastError_; }
private:
enum class ApiMode {
LegacyFsr3,
GenericApi
};
void* libHandle_ = nullptr;
std::string loadedLibraryPath_;
void* scratchBuffer_ = nullptr;
size_t scratchBufferSize_ = 0;
bool ready_ = false;
bool frameGenerationReady_ = false;
LoadPathKind loadPathKind_ = LoadPathKind::None;
std::string lastError_;
struct RuntimeFns;
RuntimeFns* fns_ = nullptr;
void* contextStorage_ = nullptr;
ApiMode apiMode_ = ApiMode::LegacyFsr3;
void* genericUpscaleContext_ = nullptr;
void* genericFramegenContext_ = nullptr;
uint64_t genericFrameId_ = 1;
};
} // namespace wowee::rendering