4 Commits

  1. 2
      .gitignore
  2. 6
      include/UnityPluginAPI/IUnityGraphics.h
  3. 84
      include/UnityPluginAPI/IUnityGraphicsD3D12.h
  4. 49
      include/UnityPluginAPI/IUnityGraphicsVulkan.h
  5. 4
      include/UnityPluginAPI/IUnityLog.h
  6. 11
      include/UnityPluginAPI/IUnityRenderingExtensions.h
  7. 8
      include/ffx_api/ffx_api.h
  8. 3
      include/ffx_api/ffx_api.hpp
  9. 3
      include/ffx_api/ffx_api_types.h
  10. 25
      include/ffx_api/ffx_framegeneration.h
  11. 14
      include/ffx_api/ffx_framegeneration.hpp
  12. 6
      include/ffx_api/ffx_upscale.h
  13. BIN
      lib/amd_fidelityfx_dx12.dll
  14. BIN
      lib/amd_fidelityfx_dx12.lib
  15. BIN
      lib/amd_fidelityfx_vk.dll
  16. BIN
      lib/amd_fidelityfx_vk.lib
  17. 5
      src/FSR3UnityPlugin.cpp
  18. 6
      src/FSR3Upscaler_DX12.h

2
.gitignore

@ -2,3 +2,5 @@
.vs/
FSR3UnityPlugin/x64/
x64/
FSR3UnityPlugin/Debug/
FSR3UnityPlugin/Release/

6
include/UnityPluginAPI/IUnityGraphics.h

@ -14,7 +14,7 @@ typedef enum UnityGfxRenderer
//kUnityGfxRendererD3D9 = 1, // Direct3D 9, removed
kUnityGfxRendererD3D11 = 2, // Direct3D 11
kUnityGfxRendererNull = 4, // "null" device (used in batch mode)
kUnityGfxRendererOpenGLES20 = 8, // OpenGL ES 2.0
//kUnityGfxRendererOpenGLES20 = 8, // OpenGL ES 2.0, removed
kUnityGfxRendererOpenGLES30 = 11, // OpenGL ES 3.0
//kUnityGfxRendererGXM = 12, // PlayStation Vita, removed
kUnityGfxRendererPS4 = 13, // PlayStation 4
@ -28,7 +28,9 @@ typedef enum UnityGfxRenderer
kUnityGfxRendererGameCoreXboxOne = 24, // GameCore Xbox One
kUnityGfxRendererGameCoreXboxSeries = 25, // GameCore XboxSeries
kUnityGfxRendererPS5 = 26, // PS5
kUnityGfxRendererPS5NGGC = 27 // PS5 NGGC
kUnityGfxRendererPS5NGGC = 27, // PS5 NGGC
kUnityGfxRendererReservedCFE = 29
} UnityGfxRenderer;
typedef enum UnityGfxDeviceEventType

84
include/UnityPluginAPI/IUnityGraphicsD3D12.h

@ -13,59 +13,111 @@
struct RenderSurfaceBase;
typedef struct RenderSurfaceBase* UnityRenderBuffer;
typedef struct UnityGraphicsD3D12ResourceState UnityGraphicsD3D12ResourceState;
struct UnityGraphicsD3D12ResourceState
typedef struct UnityGraphicsD3D12ResourceState
{
ID3D12Resource* resource; // Resource to barrier.
D3D12_RESOURCE_STATES expected; // Expected resource state before this command list is executed.
D3D12_RESOURCE_STATES current; // State this resource will be in after this command list is executed.
};
}UnityGraphicsD3D12ResourceState;
struct UnityGraphicsD3D12RecordingState
typedef struct UnityGraphicsD3D12RecordingState
{
ID3D12GraphicsCommandList* commandList; // D3D12 command list that is currently recorded by Unity
};
}UnityGraphicsD3D12RecordingState;
enum UnityD3D12GraphicsQueueAccess
typedef enum UnityD3D12GraphicsQueueAccess
{
// No queue acccess, no work must be submitted to UnityD3D12Instance::graphicsQueue from the plugin event callback
// Enables access to CommandRecordingState and disables access to GetCommandQueue. When using this plugin callbacks
// will be called from the render thread. When accessing the command queue from GetCommandQueue it is hihgly likely
// that submission thread will be using at the same time and it will cause issues.
kUnityD3D12GraphicsQueueAccess_DontCare,
// Make sure that Unity worker threads don't access the D3D12 graphics queue
// This disables access to the current Unity command buffer
// Enables access to GetCommandQueue and disables access to CommandRecordingState. When using this plugin callbacks
// will be called from the submission thread. When accessing the commmand list from CommandRecordingState it is highly
// likely that the render thread will be accessing it at the same time and it will cause issues.
kUnityD3D12GraphicsQueueAccess_Allow,
};
}UnityD3D12GraphicsQueueAccess;
enum UnityD3D12EventConfigFlagBits
typedef enum UnityD3D12EventConfigFlagBits
{
kUnityD3D12EventConfigFlag_EnsurePreviousFrameSubmission = (1 << 0), // default: (NOT SUPPORTED)
kUnityD3D12EventConfigFlag_FlushCommandBuffers = (1 << 1), // submit existing command buffers, default: not set
kUnityD3D12EventConfigFlag_SyncWorkerThreads = (1 << 2), // wait for worker threads to finish, default: not set
kUnityD3D12EventConfigFlag_ModifiesCommandBuffersState = (1 << 3), // should be set when descriptor set bindings, vertex buffer bindings, etc are changed (default: set)
};
}UnityD3D12EventConfigFlagBits;
struct UnityD3D12PluginEventConfig
typedef struct UnityD3D12PluginEventConfig
{
UnityD3D12GraphicsQueueAccess graphicsQueueAccess;
UINT32 flags; // UnityD3D12EventConfigFlagBits to be used when invoking a native plugin
bool ensureActiveRenderTextureIsBound; // If true, the actively bound render texture will be bound prior the execution of the native plugin method.
};
}UnityD3D12PluginEventConfig;
typedef struct UnityGraphicsD3D12PhysicalVideoMemoryControlValues UnityGraphicsD3D12PhysicalVideoMemoryControlValues;
struct UnityGraphicsD3D12PhysicalVideoMemoryControlValues // all absolute values in bytes
typedef struct UnityGraphicsD3D12PhysicalVideoMemoryControlValues // all absolute values in bytes
{
UINT64 reservation; // Minimum required physical memory for an application [default = 64MB].
UINT64 systemMemoryThreshold; // If free physical video memory drops below this threshold, resources will be allocated in system memory. [default = 64MB]
UINT64 residencyHysteresisThreshold; // Minimum free physical video memory needed to start bringing evicted resources back after shrunken video memory budget expands again. [default = 128MB]
float nonEvictableRelativeThreshold; // The relative proportion of the video memory budget that must be kept available for non-evictable resources. [default = 0.25]
}UnityGraphicsD3D12PhysicalVideoMemoryControlValues;
// Should only be used on the rendering/submission thread.
UNITY_DECLARE_INTERFACE(IUnityGraphicsD3D12v8)
{
ID3D12Device* (UNITY_INTERFACE_API * GetDevice)();
// Swap chain is only accessible when using the unity player.
// When using the editor GetSwapChain will return nullptr.
IDXGISwapChain* (UNITY_INTERFACE_API * GetSwapChain)();
// These are also only accessible when using the player,
// both of these return 0 when editor is used.
UINT32(UNITY_INTERFACE_API * GetSyncInterval)();
UINT(UNITY_INTERFACE_API * GetPresentFlags)();
ID3D12Fence* (UNITY_INTERFACE_API * GetFrameFence)();
// Returns the value set on the frame fence once the current frame completes or the GPU is flushed
UINT64(UNITY_INTERFACE_API * GetNextFrameFenceValue)();
// Executes a given command list on a worker thread. The command list type must be D3D12_COMMAND_LIST_TYPE_DIRECT.
// [Optional] Declares expected and post-execution resource states.
// Returns the fence value. The value will be set once the current frame completes or the GPU is flushed.
UINT64(UNITY_INTERFACE_API * ExecuteCommandList)(ID3D12GraphicsCommandList * commandList, int stateCount, UnityGraphicsD3D12ResourceState * states);
void(UNITY_INTERFACE_API * SetPhysicalVideoMemoryControlValues)(const UnityGraphicsD3D12PhysicalVideoMemoryControlValues * memInfo);
ID3D12CommandQueue* (UNITY_INTERFACE_API * GetCommandQueue)();
ID3D12Resource* (UNITY_INTERFACE_API * TextureFromRenderBuffer)(UnityRenderBuffer rb);
ID3D12Resource* (UNITY_INTERFACE_API * TextureFromNativeTexture)(UnityTextureID texture);
// Change the precondition for a specific user-defined event
// Should be called during initialization
void(UNITY_INTERFACE_API * ConfigureEvent)(int eventID, const UnityD3D12PluginEventConfig * pluginEventConfig);
bool(UNITY_INTERFACE_API * CommandRecordingState)(UnityGraphicsD3D12RecordingState * outCommandRecordingState);
// Ask the state of a resource to be the requested state in the active command list. Adds barriers if needed.
void(UNITY_INTERFACE_API * RequestResourceState)(ID3D12Resource * resource, D3D12_RESOURCE_STATES state);
// Notify Unity about the state of a resource in the active command list.
// Needs to be called after adding commands to command recording state if they change the state of any resource,
// so that the graphics backend can add necessary barriers for any further commands.
void(UNITY_INTERFACE_API * NotifyResourceState)(ID3D12Resource * resource, D3D12_RESOURCE_STATES state, bool UAVAccess);
};
UNITY_REGISTER_INTERFACE_GUID(0x9d303045d00d4cfdULL, 0x8febb42968b423b6ULL, IUnityGraphicsD3D12v8) // TODO: Get proper values
// Should only be used on the rendering/submission thread.
UNITY_DECLARE_INTERFACE(IUnityGraphicsD3D12v7)
{
ID3D12Device* (UNITY_INTERFACE_API * GetDevice)();
// Swap chain is only accessible when using the unity player.
// When using the editor GetSwapChain will return nullptr.
IDXGISwapChain* (UNITY_INTERFACE_API * GetSwapChain)();
// These are also only accessible when using the player,
// both of these return 0 when editor is used.
UINT32(UNITY_INTERFACE_API * GetSyncInterval)();
UINT(UNITY_INTERFACE_API * GetPresentFlags)();

49
include/UnityPluginAPI/IUnityGraphicsVulkan.h

@ -6,6 +6,7 @@
#pragma once
#include "IUnityInterface.h"
#include <stdbool.h>
#ifndef UNITY_VULKAN_HEADER
#define UNITY_VULKAN_HEADER <vulkan/vulkan.h>
@ -13,7 +14,7 @@
#include UNITY_VULKAN_HEADER
struct UnityVulkanInstance
typedef struct UnityVulkanInstance
{
VkPipelineCache pipelineCache; // Unity's pipeline cache is serialized to disk
VkInstance instance;
@ -24,9 +25,9 @@ struct UnityVulkanInstance
unsigned int queueFamilyIndex;
void* reserved[8];
};
}UnityVulkanInstance;
struct UnityVulkanMemory
typedef struct UnityVulkanMemory
{
VkDeviceMemory memory; // Vulkan memory handle
VkDeviceSize offset; // offset within memory
@ -36,9 +37,9 @@ struct UnityVulkanMemory
unsigned int memoryTypeIndex; // index into VkPhysicalDeviceMemoryProperties::memoryTypes
void* reserved[4];
};
}UnityVulkanMemory;
enum UnityVulkanResourceAccessMode
typedef enum UnityVulkanResourceAccessMode
{
// Does not imply any pipeline barriers, should only be used to query resource attributes
kUnityVulkanResourceAccess_ObserveOnly,
@ -48,9 +49,9 @@ enum UnityVulkanResourceAccessMode
// Recreates the backing resource (VkBuffer/VkImage) but keeps the previous one alive if it's in use
kUnityVulkanResourceAccess_Recreate,
};
}UnityVulkanResourceAccessMode;
struct UnityVulkanImage
typedef struct UnityVulkanImage
{
UnityVulkanMemory memory; // memory that backs the image
VkImage image; // Vulkan image handle
@ -66,9 +67,9 @@ struct UnityVulkanImage
int mipCount;
void* reserved[4];
};
}UnityVulkanImage;
struct UnityVulkanBuffer
typedef struct UnityVulkanBuffer
{
UnityVulkanMemory memory; // memory that backs the buffer
VkBuffer buffer; // Vulkan buffer handle
@ -76,9 +77,9 @@ struct UnityVulkanBuffer
VkBufferUsageFlags usage;
void* reserved[4];
};
}UnityVulkanBuffer;
struct UnityVulkanRecordingState
typedef struct UnityVulkanRecordingState
{
VkCommandBuffer commandBuffer; // Vulkan command buffer that is currently recorded by Unity
VkCommandBufferLevel commandBufferLevel;
@ -91,9 +92,9 @@ struct UnityVulkanRecordingState
unsigned long long safeFrameNumber; // all resources that were used in this frame (or before) are safe to be released
void* reserved[4];
};
}UnityVulkanRecordingState;
enum UnityVulkanEventRenderPassPreCondition
typedef enum UnityVulkanEventRenderPassPreCondition
{
// Don't care about the state on Unity's current command buffer
// This is the default precondition
@ -110,9 +111,9 @@ enum UnityVulkanEventRenderPassPreCondition
// Ends the current render pass (and resumes it afterwards if needed)
// If used in combination with the SRP RenderPass API the resuls is undefined.
kUnityVulkanRenderPass_EnsureOutside
};
}UnityVulkanEventRenderPassPreCondition;
enum UnityVulkanGraphicsQueueAccess
typedef enum UnityVulkanGraphicsQueueAccess
{
// No queue acccess, no work must be submitted to UnityVulkanInstance::graphicsQueue from the plugin event callback
kUnityVulkanGraphicsQueueAccess_DontCare,
@ -120,22 +121,22 @@ enum UnityVulkanGraphicsQueueAccess
// Make sure that Unity worker threads don't access the Vulkan graphics queue
// This disables access to the current Unity command buffer
kUnityVulkanGraphicsQueueAccess_Allow,
};
}UnityVulkanGraphicsQueueAccess;
enum UnityVulkanEventConfigFlagBits
typedef enum UnityVulkanEventConfigFlagBits
{
kUnityVulkanEventConfigFlag_EnsurePreviousFrameSubmission = (1 << 0), // default: set
kUnityVulkanEventConfigFlag_FlushCommandBuffers = (1 << 1), // submit existing command buffers, default: not set
kUnityVulkanEventConfigFlag_SyncWorkerThreads = (1 << 2), // wait for worker threads to finish, default: not set
kUnityVulkanEventConfigFlag_ModifiesCommandBuffersState = (1 << 3), // should be set when descriptor set bindings, vertex buffer bindings, etc are changed (default: set)
};
}UnityVulkanEventConfigFlagBits;
struct UnityVulkanPluginEventConfig
typedef struct UnityVulkanPluginEventConfig
{
UnityVulkanEventRenderPassPreCondition renderPassPrecondition;
UnityVulkanGraphicsQueueAccess graphicsQueueAccess;
uint32_t flags;
};
}UnityVulkanPluginEventConfig;
// Constant that can be used to reference the whole image
const VkImageSubresource* const UnityVulkanWholeImage = NULL;
@ -143,16 +144,16 @@ const VkImageSubresource* const UnityVulkanWholeImage = NULL;
// callback function, see InterceptInitialization
typedef PFN_vkGetInstanceProcAddr(UNITY_INTERFACE_API * UnityVulkanInitCallback)(PFN_vkGetInstanceProcAddr getInstanceProcAddr, void* userdata);
enum UnityVulkanSwapchainMode
typedef enum UnityVulkanSwapchainMode
{
kUnityVulkanSwapchainMode_Default,
kUnityVulkanSwapchainMode_Offscreen
};
}UnityVulkanSwapchainMode;
struct UnityVulkanSwapchainConfiguration
typedef struct UnityVulkanSwapchainConfiguration
{
UnityVulkanSwapchainMode mode;
};
}UnityVulkanSwapchainConfiguration;
enum
{

4
include/UnityPluginAPI/IUnityLog.h

@ -8,7 +8,7 @@
#include "IUnityInterface.h"
/// The type of the log message
enum UnityLogType
typedef enum UnityLogType
{
/// UnityLogType used for Errors.
kUnityLogTypeError = 0,
@ -18,7 +18,7 @@ enum UnityLogType
kUnityLogTypeLog = 3,
/// UnityLogType used for Exceptions.
kUnityLogTypeException = 4,
};
}UnityLogType;
#define UNITY_WRAP_CODE(CODE_) do { CODE_; } while (0)
#define UNITY_LOG(PTR_, MSG_) UNITY_WRAP_CODE((PTR_)->Log(kUnityLogTypeLog, MSG_, __FILE__, __LINE__))

11
include/UnityPluginAPI/IUnityRenderingExtensions.h

@ -8,6 +8,7 @@
#include "IUnityGraphics.h"
#include <stdbool.h>
/*
Low-level Native Plugin Rendering Extensions
@ -290,13 +291,13 @@ typedef enum UnityRenderingExtTextureFormat
// Video formats
kUnityRenderingExtFormatYUV2,
// Automatic formats, back-end decides
kUnityRenderingExtFormatDepthAuto_removed_donotuse,
kUnityRenderingExtFormatShadowAuto_removed_donotuse,
kUnityRenderingExtFormatVideoAuto_removed_donotuse,
// Obsoleted
//kUnityRenderingExtFormatDepthAuto_removed_donotuse = 142,
//kUnityRenderingExtFormatShadowAuto_removed_donotuse = 143,
//kUnityRenderingExtFormatVideoAuto_removed_donotuse = 144,
// ASTC hdr profile
kUnityRenderingExtFormatRGBA_ASTC4X4_UFloat,
kUnityRenderingExtFormatRGBA_ASTC4X4_UFloat = 145,
kUnityRenderingExtFormatRGBA_ASTC5X5_UFloat,
kUnityRenderingExtFormatRGBA_ASTC6X6_UFloat,
kUnityRenderingExtFormatRGBA_ASTC8X8_UFloat,

8
include/ffx_api/ffx_api.h

@ -100,6 +100,14 @@ struct ffxOverrideVersion
uint64_t versionId; ///< Id of version to use. Must be a value returned from a query in ffxQueryDescGetVersions.versionIds array.
};
#define FFX_API_QUERY_DESC_TYPE_GET_PROVIDER_VERSION 6u
struct ffxQueryGetProviderVersion
{
ffxQueryDescHeader header;
uint64_t versionId; ///< Id of provider being used for queried context. 0 if invalid.
const char* versionName; ///< Version name for display. If nullptr, the query was invalid.
};
// Memory allocation function. Must return a valid pointer to at least size bytes of memory aligned to hold any type.
// May return null to indicate failure. Standard library malloc fulfills this requirement.
typedef void* (*ffxAlloc)(void* pUserData, uint64_t size);

3
include/ffx_api/ffx_api.hpp

@ -138,6 +138,9 @@ struct struct_type<ffxOverrideVersion> : std::integral_constant<uint64_t, FFX_AP
template<>
struct struct_type<ffxQueryDescGetVersions> : std::integral_constant<uint64_t, FFX_API_QUERY_DESC_TYPE_GET_VERSIONS> {};
template <>
struct struct_type<ffxQueryGetProviderVersion> : std::integral_constant<uint64_t, FFX_API_QUERY_DESC_TYPE_GET_PROVIDER_VERSION> {};
template <class Inner, uint64_t type = struct_type<Inner>::value>
struct InitHelper : public Inner
{

3
include/ffx_api/ffx_api_types.h

@ -23,6 +23,7 @@
#pragma once
#include <stdint.h>
#include <stdbool.h>
/// An enumeration of surface formats. Needs to match enum FfxSurfaceFormat
enum FfxApiSurfaceFormat
@ -79,7 +80,7 @@ enum FfxApiResourceUsage
FFX_API_RESOURCE_USAGE_ARRAYVIEW = (1<<4), ///< Indicates a resource that will generate array views. Works on 2D and cubemap textures
FFX_API_RESOURCE_USAGE_STENCILTARGET = (1<<5), ///< Indicates a resource will be used as stencil target.
};
typedef FfxApiResourceUsage FfxApiResorceUsage; // Corrects a typo that shipped with original API
/// An enumeration of resource states.
enum FfxApiResourceState

25
include/ffx_api/ffx_framegeneration.h

@ -30,7 +30,6 @@
#if defined(__cplusplus)
extern "C" {
#endif
enum FfxApiCreateContextFramegenerationFlags
{
FFX_FRAMEGENERATION_ENABLE_ASYNC_WORKLOAD_SUPPORT = (1<<0),
@ -39,6 +38,7 @@ enum FfxApiCreateContextFramegenerationFlags
FFX_FRAMEGENERATION_ENABLE_DEPTH_INVERTED = (1<<3), ///< A bit indicating that the input depth buffer data provided is inverted [1..0].
FFX_FRAMEGENERATION_ENABLE_DEPTH_INFINITE = (1<<4), ///< A bit indicating that the input depth buffer data provided is using an infinite far plane.
FFX_FRAMEGENERATION_ENABLE_HIGH_DYNAMIC_RANGE = (1<<5), ///< A bit indicating if the input color data provided to all inputs is using a high-dynamic range.
FFX_FRAMEGENERATION_ENABLE_DEBUG_CHECKING = (1<<6), ///< A bit indicating that the runtime should check some API values and report issues.
};
enum FfxApiDispatchFramegenerationFlags
@ -48,7 +48,8 @@ enum FfxApiDispatchFramegenerationFlags
FFX_FRAMEGENERATION_FLAG_DRAW_DEBUG_VIEW = (1 << 2), ///< A bit indicating that the generated output resource will contain debug views with relevant information.
FFX_FRAMEGENERATION_FLAG_NO_SWAPCHAIN_CONTEXT_NOTIFY = (1 << 3), ///< A bit indicating that the context should only run frame interpolation and not modify the swapchain.
FFX_FRAMEGENERATION_FLAG_DRAW_DEBUG_PACING_LINES = (1 << 4), ///< A bit indicating that the debug pacing lines will be drawn to the generated output.
FFX_FRAMEGENERATION_FLAG_RESERVED_1 = (1 << 5),
FFX_FRAMEGENERATION_FLAG_RESERVED_2 = (1 << 6),
};
enum FfxApiUiCompositionFlags
@ -68,7 +69,7 @@ struct ffxCreateContextDescFrameGeneration
};
#define FFX_API_CALLBACK_DESC_TYPE_FRAMEGENERATION_PRESENT 0x00020005u
struct ffxCallbackDescFrameGenerationPresent
typedef struct ffxCallbackDescFrameGenerationPresent
{
ffxDispatchDescHeader header;
void* device; ///< The device passed in (from a backend description) during context creation.
@ -78,10 +79,10 @@ struct ffxCallbackDescFrameGenerationPresent
struct FfxApiResource outputSwapChainBuffer; ///< Output image that will be presented.
bool isGeneratedFrame; ///< true if this frame is generated, false if rendered.
uint64_t frameID; ///< Identifier used to select internal resources when async support is enabled. Must increment by exactly one (1) for each frame. Any non-exactly-one difference will reset the frame generation logic.
};
} ffxCallbackDescFrameGenerationPresent;
#define FFX_API_DISPATCH_DESC_TYPE_FRAMEGENERATION 0x00020003u
struct ffxDispatchDescFrameGeneration
typedef struct ffxDispatchDescFrameGeneration
{
ffxDispatchDescHeader header;
void* commandList; ///< The command list on which to register render commands.
@ -93,7 +94,7 @@ struct ffxDispatchDescFrameGeneration
float minMaxLuminance[2]; ///< Min and max luminance values, used when converting HDR colors to linear RGB.
struct FfxApiRect2D generationRect; ///< The area of the backbuffer that should be used for generation in case only a part of the screen is used e.g. due to movie bars.
uint64_t frameID; ///< Identifier used to select internal resources when async support is enabled. Must increment by exactly one (1) for each frame. Any non-exactly-one difference will reset the frame generation logic.
};
} ffxDispatchDescFrameGeneration;
typedef ffxReturnCode_t(*FfxApiPresentCallbackFunc)(ffxCallbackDescFrameGenerationPresent* params, void* pUserCtx);
typedef ffxReturnCode_t(*FfxApiFrameGenerationDispatchFunc)(ffxDispatchDescFrameGeneration* params, void* pUserCtx);
@ -166,12 +167,24 @@ struct ffxConfigureDescFrameGenerationRegisterDistortionFieldResource
};
#define FFX_API_CREATE_CONTEXT_DESC_TYPE_FRAMEGENERATION_HUDLESS 0x00020009u
//Pass this optional linked struct at FG context creation to enable app to use different hudlessBackBufferformat (IE.RGBA8_UNORM) from backBufferFormat (IE. BGRA8_UNORM)
struct ffxCreateContextDescFrameGenerationHudless
{
ffxCreateContextDescHeader header;
uint32_t hudlessBackBufferFormat; ///< The surface format for the hudless back buffer. One of the values from FfxApiSurfaceFormat.
};
#define FFX_API_DISPATCH_DESC_TYPE_FRAMEGENERATION_PREPARE_CAMERAINFO 0x0002000au
//Link this struct after ffxDispatchDescFrameGenerationPrepare. This is a required input to FSR3.1.4 and onwards for best quality.
struct ffxDispatchDescFrameGenerationPrepareCameraInfo
{
ffxConfigureDescHeader header;
float cameraPosition[3]; ///< The camera position in world space
float cameraUp[3]; ///< The camera up normalized vector in world space.
float cameraRight[3]; ///< The camera right normalized vector in world space.
float cameraForward[3]; ///< The camera forward normalized vector in world space.
};
#if defined(__cplusplus)
} // extern "C"
#endif

14
include/ffx_api/ffx_framegeneration.hpp

@ -35,11 +35,6 @@ struct struct_type<ffxCreateContextDescFrameGeneration> : std::integral_constant
struct CreateContextDescFrameGeneration : public InitHelper<ffxCreateContextDescFrameGeneration> {};
template<>
struct struct_type<ffxCreateContextDescFrameGenerationHudless> : std::integral_constant<uint64_t, FFX_API_CREATE_CONTEXT_DESC_TYPE_FRAMEGENERATION_HUDLESS> {};
struct CreateContextDescFrameGenerationHudless : public InitHelper<ffxCreateContextDescFrameGenerationHudless> {};
template<>
struct struct_type<ffxConfigureDescFrameGeneration> : std::integral_constant<uint64_t, FFX_API_CONFIGURE_DESC_TYPE_FRAMEGENERATION> {};
@ -70,4 +65,13 @@ struct struct_type<ffxConfigureDescFrameGenerationRegisterDistortionFieldResourc
struct ConfigureDescFrameGenerationRegisterDistortionFieldResource : public InitHelper<ffxConfigureDescFrameGenerationRegisterDistortionFieldResource> {};
template<>
struct struct_type<ffxCreateContextDescFrameGenerationHudless> : std::integral_constant<uint64_t, FFX_API_CREATE_CONTEXT_DESC_TYPE_FRAMEGENERATION_HUDLESS> {};
struct CreateContextDescFrameGenerationHudless : public InitHelper<ffxCreateContextDescFrameGenerationHudless> {};
template<>
struct struct_type<ffxDispatchDescFrameGenerationPrepareCameraInfo> : std::integral_constant<uint64_t, FFX_API_DISPATCH_DESC_TYPE_FRAMEGENERATION_PREPARE_CAMERAINFO> {};
struct DispatchDescFrameGenerationPrepareCameraInfo : public InitHelper<ffxDispatchDescFrameGenerationPrepareCameraInfo> {};
}

6
include/ffx_api/ffx_upscale.h

@ -169,7 +169,11 @@ struct ffxConfigureDescUpscaleKeyValue
enum FfxApiConfigureUpscaleKey
{
FFX_API_CONFIGURE_UPSCALE_KEY_FVELOCITYFACTOR = 0 //Override constant buffer fVelocityFactor (from 1.0f at context creation) to floating point value casted from void * ptr. Value of 0.0f can improve temporal stability of bright pixels. Value is clamped to [0.0f, 1.0f].
FFX_API_CONFIGURE_UPSCALE_KEY_FVELOCITYFACTOR = 0, //Override constant buffer fVelocityFactor. The float value is casted from void * ptr. Value of 0.0f can improve temporal stability of bright pixels. Default value is 1.0f. Value is clamped to [0.0f, 1.0f].
FFX_API_CONFIGURE_UPSCALE_KEY_FREACTIVENESSSCALE = 1, //Override constant buffer fReactivenessScale. The float value is casted from void * ptr. Meant for development purpose to test if writing a larger value to reactive mask, reduces ghosting. Default value is 1.0f. Value is clamped to [0.0f, +infinity].
FFX_API_CONFIGURE_UPSCALE_KEY_FSHADINGCHANGESCALE = 2, //Override fShadingChangeScale. Increasing this scales fsr3.1 computed shading change value at read to have higher reactiveness. Default value is 1.0f. Value is clamped to [0.0f, +infinity].
FFX_API_CONFIGURE_UPSCALE_KEY_FACCUMULATIONADDEDPERFRAME = 3, // Override constant buffer fAccumulationAddedPerFrame. Corresponds to amount of accumulation added per frame at pixel coordinate where disocclusion occured or when reactive mask value is > 0.0f. Decreasing this and drawing the ghosting object (IE no mv) to reactive mask with value close to 1.0f can decrease temporal ghosting. Decreasing this value could result in more thin feature pixels flickering. Default value is 0.333. Value is clamped to [0.0f, 1.0f].
FFX_API_CONFIGURE_UPSCALE_KEY_FMINDISOCCLUSIONACCUMULATION = 4, //Override constant buffer fMinDisocclusionAccumulation. Increasing this value may reduce white pixel temporal flickering around swaying thin objects that are disoccluding one another often. Too high value may increase ghosting. A sufficiently negative value means for pixel coordinate at frame N that is disoccluded, add fAccumulationAddedPerFrame starting at frame N+2. Default value is -0.333. Value is clamped to [-1.0f, 1.0f].
};
#define FFX_API_QUERY_DESC_TYPE_UPSCALE_GPU_MEMORY_USAGE 0x00010008u

BIN
lib/amd_fidelityfx_dx12.dll

BIN
lib/amd_fidelityfx_dx12.lib

BIN
lib/amd_fidelityfx_vk.dll

BIN
lib/amd_fidelityfx_vk.lib

5
src/FSR3UnityPlugin.cpp

@ -85,7 +85,10 @@ static void UNITY_INTERFACE_API OnGraphicsDeviceEvent(UnityGfxDeviceEventType ev
s_GraphicsD3D12 = graphicsD3D12;
s_Upscaler = new FSR3Upscaler_DX12(s_Log, graphicsD3D12);
// Older Unity versions won't have this interface yet, so its presence is optional
auto* graphicsD3D12v8 = s_UnityInterfaces->Get<IUnityGraphicsD3D12v8>();
s_Upscaler = new FSR3Upscaler_DX12(s_Log, graphicsD3D12, graphicsD3D12v8);
UnityD3D12PluginEventConfig eventConfig{};
eventConfig.graphicsQueueAccess = kUnityD3D12GraphicsQueueAccess_DontCare;

6
src/FSR3Upscaler_DX12.h

@ -10,9 +10,10 @@
class FSR3Upscaler_DX12 : public FSR3Upscaler_FFXBase
{
public:
FSR3Upscaler_DX12(IUnityLog* log, IUnityGraphicsD3D12v7* graphicsDevice):
FSR3Upscaler_DX12(IUnityLog* log, IUnityGraphicsD3D12v7* graphicsDevice, IUnityGraphicsD3D12v8* graphicsDeviceV8):
FSR3Upscaler_FFXBase(log),
m_GraphicsDevice(graphicsDevice), m_DX12BackendDesc(), m_FrameFenceEventHandle(nullptr)
m_GraphicsDevice(graphicsDevice), m_GraphicsDeviceV8(graphicsDeviceV8),
m_DX12BackendDesc(), m_FrameFenceEventHandle(nullptr)
{
}
@ -28,6 +29,7 @@ protected:
private:
IUnityGraphicsD3D12v7* m_GraphicsDevice;
IUnityGraphicsD3D12v8* m_GraphicsDeviceV8;
ffx::CreateBackendDX12Desc m_DX12BackendDesc;
HANDLE m_FrameFenceEventHandle;
};
Loading…
Cancel
Save