14 changed files with 1967 additions and 0 deletions
-
318ffx_api/dx12/ffx_api_dx12.h
-
83ffx_api/dx12/ffx_api_dx12.hpp
-
150ffx_api/ffx_api.h
-
176ffx_api/ffx_api.hpp
-
43ffx_api/ffx_api_loader.h
-
242ffx_api/ffx_api_types.h
-
177ffx_api/ffx_framegeneration.h
-
73ffx_api/ffx_framegeneration.hpp
-
184ffx_api/ffx_upscale.h
-
78ffx_api/ffx_upscale.hpp
-
360ffx_api/vk/ffx_api_vk.h
-
83ffx_api/vk/ffx_api_vk.hpp
-
BINlib/amd_fidelityfx_dx12.dll
-
BINlib/amd_fidelityfx_dx12.lib
@ -0,0 +1,318 @@ |
|||||
|
// This file is part of the FidelityFX SDK. |
||||
|
// |
||||
|
// Copyright (C) 2024 Advanced Micro Devices, Inc. |
||||
|
// |
||||
|
// Permission is hereby granted, free of charge, to any person obtaining a copy |
||||
|
// of this software and associated documentation files(the "Software"), to deal |
||||
|
// in the Software without restriction, including without limitation the rights |
||||
|
// to use, copy, modify, merge, publish, distribute, sublicense, and /or sell |
||||
|
// copies of the Software, and to permit persons to whom the Software is |
||||
|
// furnished to do so, subject to the following conditions : |
||||
|
// |
||||
|
// The above copyright notice and this permission notice shall be included in |
||||
|
// all copies or substantial portions of the Software. |
||||
|
// |
||||
|
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
||||
|
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
||||
|
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
||||
|
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
||||
|
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
||||
|
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN |
||||
|
// THE SOFTWARE. |
||||
|
|
||||
|
#pragma once |
||||
|
#include "../ffx_api.h" |
||||
|
#include "../ffx_api_types.h" |
||||
|
#include <d3d12.h> |
||||
|
#include <dxgi.h> |
||||
|
#include <dxgi1_5.h> |
||||
|
|
||||
|
#define FFX_API_CREATE_CONTEXT_DESC_TYPE_BACKEND_DX12 0x0000002u |
||||
|
struct ffxCreateBackendDX12Desc |
||||
|
{ |
||||
|
ffxCreateContextDescHeader header; |
||||
|
ID3D12Device *device; ///< Device on which the backend will run. |
||||
|
}; |
||||
|
|
||||
|
#define FFX_API_EFFECT_ID_FRAMEGENERATIONSWAPCHAIN_DX12 0x00030000u |
||||
|
|
||||
|
#define FFX_API_CREATE_CONTEXT_DESC_TYPE_FRAMEGENERATIONSWAPCHAIN_WRAP_DX12 0x30001u |
||||
|
struct ffxCreateContextDescFrameGenerationSwapChainWrapDX12 |
||||
|
{ |
||||
|
ffxCreateContextDescHeader header; |
||||
|
IDXGISwapChain4** swapchain; ///< Input swap chain to wrap, output frame interpolation swapchain. |
||||
|
ID3D12CommandQueue* gameQueue; ///< Input command queue to be used for presentation. |
||||
|
}; |
||||
|
|
||||
|
#define FFX_API_CREATE_CONTEXT_DESC_TYPE_FRAMEGENERATIONSWAPCHAIN_NEW_DX12 0x30005u |
||||
|
struct ffxCreateContextDescFrameGenerationSwapChainNewDX12 |
||||
|
{ |
||||
|
ffxCreateContextDescHeader header; |
||||
|
IDXGISwapChain4** swapchain; ///< Output frame interpolation swapchain. |
||||
|
DXGI_SWAP_CHAIN_DESC* desc; ///< Swap chain creation parameters. |
||||
|
IDXGIFactory* dxgiFactory; ///< IDXGIFactory to use for DX12 swapchain creation. |
||||
|
ID3D12CommandQueue* gameQueue; ///< Input command queue to be used for presentation. |
||||
|
}; |
||||
|
|
||||
|
#define FFX_API_CREATE_CONTEXT_DESC_TYPE_FRAMEGENERATIONSWAPCHAIN_FOR_HWND_DX12 0x30006u |
||||
|
struct ffxCreateContextDescFrameGenerationSwapChainForHwndDX12 |
||||
|
{ |
||||
|
ffxCreateContextDescHeader header; |
||||
|
IDXGISwapChain4** swapchain; ///< Output frame interpolation swapchain. |
||||
|
HWND hwnd; ///< HWND handle for the calling application; |
||||
|
DXGI_SWAP_CHAIN_DESC1* desc; ///< Swap chain creation parameters. |
||||
|
DXGI_SWAP_CHAIN_FULLSCREEN_DESC* fullscreenDesc; ///< Fullscreen swap chain creation parameters. |
||||
|
IDXGIFactory* dxgiFactory; ///< IDXGIFactory to use for DX12 swapchain creation. |
||||
|
ID3D12CommandQueue* gameQueue; ///< Input command queue to be used for presentation. |
||||
|
}; |
||||
|
|
||||
|
#define FFX_API_CONFIGURE_DESC_TYPE_FRAMEGENERATIONSWAPCHAIN_REGISTERUIRESOURCE_DX12 0x30002u |
||||
|
struct ffxConfigureDescFrameGenerationSwapChainRegisterUiResourceDX12 |
||||
|
{ |
||||
|
ffxConfigureDescHeader header; |
||||
|
struct FfxApiResource uiResource; ///< Resource containing user interface for composition. May be empty. |
||||
|
uint32_t flags; ///< Zero or combination of values from FfxApiUiCompositionFlags. |
||||
|
}; |
||||
|
|
||||
|
#define FFX_API_QUERY_DESC_TYPE_FRAMEGENERATIONSWAPCHAIN_INTERPOLATIONCOMMANDLIST_DX12 0x30003u |
||||
|
struct ffxQueryDescFrameGenerationSwapChainInterpolationCommandListDX12 |
||||
|
{ |
||||
|
ffxQueryDescHeader header; |
||||
|
void** pOutCommandList; ///< Output command list (ID3D12GraphicsCommandList) to be used for frame generation dispatch. |
||||
|
}; |
||||
|
|
||||
|
#define FFX_API_QUERY_DESC_TYPE_FRAMEGENERATIONSWAPCHAIN_INTERPOLATIONTEXTURE_DX12 0x30004u |
||||
|
struct ffxQueryDescFrameGenerationSwapChainInterpolationTextureDX12 |
||||
|
{ |
||||
|
ffxQueryDescHeader header; |
||||
|
struct FfxApiResource *pOutTexture; ///< Output resource in which the frame interpolation result should be placed. |
||||
|
}; |
||||
|
|
||||
|
#define FFX_API_DISPATCH_DESC_TYPE_FRAMEGENERATIONSWAPCHAIN_WAIT_FOR_PRESENTS_DX12 0x30007u |
||||
|
struct ffxDispatchDescFrameGenerationSwapChainWaitForPresentsDX12 |
||||
|
{ |
||||
|
ffxDispatchDescHeader header; |
||||
|
}; |
||||
|
|
||||
|
#define FFX_API_CONFIGURE_DESC_TYPE_FRAMEGENERATIONSWAPCHAIN_KEYVALUE_DX12 0x30008u |
||||
|
struct ffxConfigureDescFrameGenerationSwapChainKeyValueDX12 |
||||
|
{ |
||||
|
ffxConfigureDescHeader header; |
||||
|
uint64_t key; ///< Configuration key, member of the FfxApiConfigureFrameGenerationSwapChainKeyDX12 enumeration. |
||||
|
uint64_t u64; ///< Integer value or enum value to set. |
||||
|
void* ptr; ///< Pointer to set or pointer to value to set. |
||||
|
}; |
||||
|
|
||||
|
//enum value matches enum FfxFrameInterpolationSwapchainConfigureKey |
||||
|
enum FfxApiConfigureFrameGenerationSwapChainKeyDX12 |
||||
|
{ |
||||
|
FFX_API_CONFIGURE_FG_SWAPCHAIN_KEY_WAITCALLBACK = 0, ///< Sets FfxWaitCallbackFunc |
||||
|
FFX_API_CONFIGURE_FG_SWAPCHAIN_KEY_FRAMEPACINGTUNING = 2, ///< Sets FfxApiSwapchainFramePacingTuning |
||||
|
}; |
||||
|
|
||||
|
#define FFX_API_QUERY_DESC_TYPE_FRAMEGENERATIONSWAPCHAIN_GPU_MEMORY_USAGE_DX12 0x00030009u |
||||
|
struct ffxQueryFrameGenerationSwapChainGetGPUMemoryUsageDX12 |
||||
|
{ |
||||
|
ffxQueryDescHeader header; |
||||
|
struct FfxApiEffectMemoryUsage* gpuMemoryUsageFrameGenerationSwapchain; |
||||
|
}; |
||||
|
|
||||
|
#if defined(__cplusplus) |
||||
|
|
||||
|
static inline uint32_t ffxApiGetSurfaceFormatDX12(DXGI_FORMAT format) |
||||
|
{ |
||||
|
switch (format) |
||||
|
{ |
||||
|
case DXGI_FORMAT_R32G32B32A32_TYPELESS: |
||||
|
return FFX_API_SURFACE_FORMAT_R32G32B32A32_TYPELESS; |
||||
|
case DXGI_FORMAT_R32G32B32A32_FLOAT: |
||||
|
return FFX_API_SURFACE_FORMAT_R32G32B32A32_FLOAT; |
||||
|
case DXGI_FORMAT_R32G32B32A32_UINT: |
||||
|
return FFX_API_SURFACE_FORMAT_R32G32B32A32_UINT; |
||||
|
//case DXGI_FORMAT_R32G32B32A32_SINT: |
||||
|
//case DXGI_FORMAT_R32G32B32_TYPELESS: |
||||
|
//case DXGI_FORMAT_R32G32B32_FLOAT: |
||||
|
//case DXGI_FORMAT_R32G32B32_UINT: |
||||
|
//case DXGI_FORMAT_R32G32B32_SINT: |
||||
|
|
||||
|
case DXGI_FORMAT_R16G16B16A16_TYPELESS: |
||||
|
return FFX_API_SURFACE_FORMAT_R16G16B16A16_TYPELESS; |
||||
|
case DXGI_FORMAT_R16G16B16A16_FLOAT: |
||||
|
return FFX_API_SURFACE_FORMAT_R16G16B16A16_FLOAT; |
||||
|
//case DXGI_FORMAT_R16G16B16A16_UNORM: |
||||
|
//case DXGI_FORMAT_R16G16B16A16_UINT: |
||||
|
//case DXGI_FORMAT_R16G16B16A16_SNORM: |
||||
|
//case DXGI_FORMAT_R16G16B16A16_SINT: |
||||
|
|
||||
|
case DXGI_FORMAT_R32G32_TYPELESS: |
||||
|
return FFX_API_SURFACE_FORMAT_R32G32_TYPELESS; |
||||
|
case DXGI_FORMAT_R32G32_FLOAT: |
||||
|
return FFX_API_SURFACE_FORMAT_R32G32_FLOAT; |
||||
|
//case DXGI_FORMAT_R32G32_FLOAT: |
||||
|
//case DXGI_FORMAT_R32G32_UINT: |
||||
|
//case DXGI_FORMAT_R32G32_SINT: |
||||
|
|
||||
|
case DXGI_FORMAT_R32G8X24_TYPELESS: |
||||
|
case DXGI_FORMAT_D32_FLOAT_S8X24_UINT: |
||||
|
case DXGI_FORMAT_R32_FLOAT_X8X24_TYPELESS: |
||||
|
return FFX_API_SURFACE_FORMAT_R32_FLOAT; |
||||
|
|
||||
|
case DXGI_FORMAT_R24G8_TYPELESS: |
||||
|
case DXGI_FORMAT_D24_UNORM_S8_UINT: |
||||
|
case DXGI_FORMAT_R24_UNORM_X8_TYPELESS: |
||||
|
return FFX_API_SURFACE_FORMAT_R32_UINT; |
||||
|
|
||||
|
case DXGI_FORMAT_X32_TYPELESS_G8X24_UINT: |
||||
|
case DXGI_FORMAT_X24_TYPELESS_G8_UINT: |
||||
|
return FFX_API_SURFACE_FORMAT_R8_UINT; |
||||
|
|
||||
|
case DXGI_FORMAT_R10G10B10A2_TYPELESS: |
||||
|
return FFX_API_SURFACE_FORMAT_R10G10B10A2_TYPELESS; |
||||
|
case DXGI_FORMAT_R10G10B10A2_UNORM: |
||||
|
return FFX_API_SURFACE_FORMAT_R10G10B10A2_UNORM; |
||||
|
//case DXGI_FORMAT_R10G10B10A2_UINT: |
||||
|
|
||||
|
case DXGI_FORMAT_R11G11B10_FLOAT: |
||||
|
return FFX_API_SURFACE_FORMAT_R11G11B10_FLOAT; |
||||
|
|
||||
|
case DXGI_FORMAT_R8G8B8A8_TYPELESS: |
||||
|
return FFX_API_SURFACE_FORMAT_R8G8B8A8_TYPELESS; |
||||
|
case DXGI_FORMAT_R8G8B8A8_UNORM: |
||||
|
return FFX_API_SURFACE_FORMAT_R8G8B8A8_UNORM; |
||||
|
case DXGI_FORMAT_R8G8B8A8_UNORM_SRGB: |
||||
|
return FFX_API_SURFACE_FORMAT_R8G8B8A8_SRGB; |
||||
|
//case DXGI_FORMAT_R8G8B8A8_UINT: |
||||
|
case DXGI_FORMAT_R8G8B8A8_SNORM: |
||||
|
return FFX_API_SURFACE_FORMAT_R8G8B8A8_SNORM; |
||||
|
|
||||
|
case DXGI_FORMAT_B8G8R8A8_TYPELESS: |
||||
|
return FFX_API_SURFACE_FORMAT_B8G8R8A8_TYPELESS; |
||||
|
case DXGI_FORMAT_B8G8R8A8_UNORM: |
||||
|
return FFX_API_SURFACE_FORMAT_B8G8R8A8_UNORM; |
||||
|
case DXGI_FORMAT_B8G8R8A8_UNORM_SRGB: |
||||
|
return FFX_API_SURFACE_FORMAT_B8G8R8A8_SRGB; |
||||
|
|
||||
|
case DXGI_FORMAT_R16G16_TYPELESS: |
||||
|
return FFX_API_SURFACE_FORMAT_R16G16_TYPELESS; |
||||
|
case DXGI_FORMAT_R16G16_FLOAT: |
||||
|
return FFX_API_SURFACE_FORMAT_R16G16_FLOAT; |
||||
|
//case DXGI_FORMAT_R16G16_UNORM: |
||||
|
case DXGI_FORMAT_R16G16_UINT: |
||||
|
return FFX_API_SURFACE_FORMAT_R16G16_UINT; |
||||
|
//case DXGI_FORMAT_R16G16_SNORM |
||||
|
//case DXGI_FORMAT_R16G16_SINT |
||||
|
|
||||
|
//case DXGI_FORMAT_R32_SINT: |
||||
|
case DXGI_FORMAT_R32_UINT: |
||||
|
return FFX_API_SURFACE_FORMAT_R32_UINT; |
||||
|
case DXGI_FORMAT_R32_TYPELESS: |
||||
|
return FFX_API_SURFACE_FORMAT_R32_TYPELESS; |
||||
|
case DXGI_FORMAT_D32_FLOAT: |
||||
|
case DXGI_FORMAT_R32_FLOAT: |
||||
|
return FFX_API_SURFACE_FORMAT_R32_FLOAT; |
||||
|
|
||||
|
case DXGI_FORMAT_R8G8_UINT: |
||||
|
return FFX_API_SURFACE_FORMAT_R8G8_UINT; |
||||
|
case DXGI_FORMAT_R8G8_TYPELESS: |
||||
|
return FFX_API_SURFACE_FORMAT_R8G8_TYPELESS; |
||||
|
case DXGI_FORMAT_R8G8_UNORM: |
||||
|
return FFX_API_SURFACE_FORMAT_R8G8_UNORM; |
||||
|
//case DXGI_FORMAT_R8G8_SNORM: |
||||
|
//case DXGI_FORMAT_R8G8_SINT: |
||||
|
|
||||
|
case DXGI_FORMAT_R16_TYPELESS: |
||||
|
return FFX_API_SURFACE_FORMAT_R16_TYPELESS; |
||||
|
case DXGI_FORMAT_R16_FLOAT: |
||||
|
return FFX_API_SURFACE_FORMAT_R16_FLOAT; |
||||
|
case DXGI_FORMAT_R16_UINT: |
||||
|
return FFX_API_SURFACE_FORMAT_R16_UINT; |
||||
|
case DXGI_FORMAT_D16_UNORM: |
||||
|
case DXGI_FORMAT_R16_UNORM: |
||||
|
return FFX_API_SURFACE_FORMAT_R16_UNORM; |
||||
|
case DXGI_FORMAT_R16_SNORM: |
||||
|
return FFX_API_SURFACE_FORMAT_R16_SNORM; |
||||
|
//case DXGI_FORMAT_R16_SINT: |
||||
|
|
||||
|
case DXGI_FORMAT_R8_TYPELESS: |
||||
|
return FFX_API_SURFACE_FORMAT_R8_TYPELESS; |
||||
|
case DXGI_FORMAT_R8_UNORM: |
||||
|
case DXGI_FORMAT_A8_UNORM: |
||||
|
return FFX_API_SURFACE_FORMAT_R8_UNORM; |
||||
|
case DXGI_FORMAT_R8_UINT: |
||||
|
return FFX_API_SURFACE_FORMAT_R8_UINT; |
||||
|
//case DXGI_FORMAT_R8_SNORM: |
||||
|
//case DXGI_FORMAT_R8_SINT: |
||||
|
//case DXGI_FORMAT_R1_UNORM: |
||||
|
|
||||
|
case DXGI_FORMAT_R9G9B9E5_SHAREDEXP: |
||||
|
return FFX_API_SURFACE_FORMAT_R9G9B9E5_SHAREDEXP; |
||||
|
|
||||
|
case DXGI_FORMAT_UNKNOWN: |
||||
|
default: |
||||
|
return FFX_API_SURFACE_FORMAT_UNKNOWN; |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
static inline FfxApiResource ffxApiGetResourceDX12(ID3D12Resource* pRes, uint32_t state = FFX_API_RESOURCE_STATE_COMPUTE_READ, uint32_t additionalUsages = 0) |
||||
|
{ |
||||
|
FfxApiResource res{}; |
||||
|
res.resource = pRes; |
||||
|
res.state = state; |
||||
|
if (!pRes) return res; |
||||
|
|
||||
|
D3D12_RESOURCE_DESC desc = pRes->GetDesc(); |
||||
|
if (desc.Dimension == D3D12_RESOURCE_DIMENSION_BUFFER) |
||||
|
{ |
||||
|
res.description.flags = FFX_API_RESOURCE_FLAGS_NONE; |
||||
|
res.description.usage = FFX_API_RESOURCE_USAGE_UAV; |
||||
|
res.description.size = static_cast<uint32_t>(desc.Width); |
||||
|
res.description.stride = static_cast<uint32_t>(desc.Height); |
||||
|
res.description.type = FFX_API_RESOURCE_TYPE_BUFFER; |
||||
|
} |
||||
|
else |
||||
|
{ |
||||
|
res.description.flags = FFX_API_RESOURCE_FLAGS_NONE; |
||||
|
if (desc.Format == DXGI_FORMAT_D16_UNORM || desc.Format == DXGI_FORMAT_D32_FLOAT) |
||||
|
{ |
||||
|
res.description.usage = FFX_API_RESOURCE_USAGE_DEPTHTARGET; |
||||
|
} |
||||
|
else if (desc.Format == DXGI_FORMAT_D24_UNORM_S8_UINT || desc.Format == DXGI_FORMAT_D32_FLOAT_S8X24_UINT) |
||||
|
{ |
||||
|
res.description.usage = FFX_API_RESOURCE_USAGE_DEPTHTARGET | FFX_API_RESOURCE_USAGE_STENCILTARGET; |
||||
|
} |
||||
|
else |
||||
|
{ |
||||
|
res.description.usage = FFX_API_RESOURCE_USAGE_READ_ONLY; |
||||
|
} |
||||
|
|
||||
|
if (desc.Flags & D3D12_RESOURCE_FLAG_ALLOW_UNORDERED_ACCESS) |
||||
|
res.description.usage |= FFX_API_RESOURCE_USAGE_UAV; |
||||
|
|
||||
|
res.description.width = static_cast<uint32_t>(desc.Width); |
||||
|
res.description.height = static_cast<uint32_t>(desc.Height); |
||||
|
res.description.depth = static_cast<uint32_t>(desc.DepthOrArraySize); |
||||
|
res.description.mipCount = static_cast<uint32_t>(desc.MipLevels); |
||||
|
|
||||
|
switch (desc.Dimension) |
||||
|
{ |
||||
|
case D3D12_RESOURCE_DIMENSION_TEXTURE1D: |
||||
|
res.description.type = FFX_API_RESOURCE_TYPE_TEXTURE1D; |
||||
|
break; |
||||
|
case D3D12_RESOURCE_DIMENSION_TEXTURE2D: |
||||
|
if (desc.DepthOrArraySize == 6) |
||||
|
res.description.type = FFX_API_RESOURCE_TYPE_TEXTURE_CUBE; |
||||
|
else |
||||
|
res.description.type = FFX_API_RESOURCE_TYPE_TEXTURE2D; |
||||
|
break; |
||||
|
case D3D12_RESOURCE_DIMENSION_TEXTURE3D: |
||||
|
res.description.type = FFX_API_RESOURCE_TYPE_TEXTURE3D; |
||||
|
break; |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
res.description.format = ffxApiGetSurfaceFormatDX12(desc.Format); |
||||
|
res.description.usage |= additionalUsages; |
||||
|
return res; |
||||
|
} |
||||
|
|
||||
|
#endif |
||||
@ -0,0 +1,83 @@ |
|||||
|
// This file is part of the FidelityFX SDK.
|
||||
|
//
|
||||
|
// Copyright (C) 2024 Advanced Micro Devices, Inc.
|
||||
|
//
|
||||
|
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
|
// of this software and associated documentation files(the "Software"), to deal
|
||||
|
// in the Software without restriction, including without limitation the rights
|
||||
|
// to use, copy, modify, merge, publish, distribute, sublicense, and /or sell
|
||||
|
// copies of the Software, and to permit persons to whom the Software is
|
||||
|
// furnished to do so, subject to the following conditions :
|
||||
|
//
|
||||
|
// The above copyright notice and this permission notice shall be included in
|
||||
|
// all copies or substantial portions of the Software.
|
||||
|
//
|
||||
|
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
|
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
|
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
|
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
|
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
|
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
|
// THE SOFTWARE.
|
||||
|
|
||||
|
#pragma once
|
||||
|
|
||||
|
#include "../ffx_api.hpp"
|
||||
|
#include "ffx_api_dx12.h"
|
||||
|
|
||||
|
// Helper types for header initialization. Api definition is in .h file.
|
||||
|
|
||||
|
namespace ffx |
||||
|
{ |
||||
|
|
||||
|
template<> |
||||
|
struct struct_type<ffxCreateBackendDX12Desc> : std::integral_constant<uint64_t, FFX_API_CREATE_CONTEXT_DESC_TYPE_BACKEND_DX12> {}; |
||||
|
|
||||
|
struct CreateBackendDX12Desc : public InitHelper<ffxCreateBackendDX12Desc> {}; |
||||
|
|
||||
|
template<> |
||||
|
struct struct_type<ffxCreateContextDescFrameGenerationSwapChainWrapDX12> : std::integral_constant<uint64_t, FFX_API_CREATE_CONTEXT_DESC_TYPE_FRAMEGENERATIONSWAPCHAIN_WRAP_DX12> {}; |
||||
|
|
||||
|
struct CreateContextDescFrameGenerationSwapChainWrapDX12 : public InitHelper<ffxCreateContextDescFrameGenerationSwapChainWrapDX12> {}; |
||||
|
|
||||
|
template<> |
||||
|
struct struct_type<ffxCreateContextDescFrameGenerationSwapChainNewDX12> : std::integral_constant<uint64_t, FFX_API_CREATE_CONTEXT_DESC_TYPE_FRAMEGENERATIONSWAPCHAIN_NEW_DX12> {}; |
||||
|
|
||||
|
struct CreateContextDescFrameGenerationSwapChainNewDX12 : public InitHelper<ffxCreateContextDescFrameGenerationSwapChainNewDX12> {}; |
||||
|
|
||||
|
template<> |
||||
|
struct struct_type<ffxCreateContextDescFrameGenerationSwapChainForHwndDX12> : std::integral_constant<uint64_t, FFX_API_CREATE_CONTEXT_DESC_TYPE_FRAMEGENERATIONSWAPCHAIN_FOR_HWND_DX12> {}; |
||||
|
|
||||
|
struct CreateContextDescFrameGenerationSwapChainForHwndDX12 : public InitHelper<ffxCreateContextDescFrameGenerationSwapChainForHwndDX12> {}; |
||||
|
|
||||
|
template<> |
||||
|
struct struct_type<ffxConfigureDescFrameGenerationSwapChainRegisterUiResourceDX12> : std::integral_constant<uint64_t, FFX_API_CONFIGURE_DESC_TYPE_FRAMEGENERATIONSWAPCHAIN_REGISTERUIRESOURCE_DX12> {}; |
||||
|
|
||||
|
struct ConfigureDescFrameGenerationSwapChainRegisterUiResourceDX12 : public InitHelper<ffxConfigureDescFrameGenerationSwapChainRegisterUiResourceDX12> {}; |
||||
|
|
||||
|
template<> |
||||
|
struct struct_type<ffxQueryDescFrameGenerationSwapChainInterpolationCommandListDX12> : std::integral_constant<uint64_t, FFX_API_QUERY_DESC_TYPE_FRAMEGENERATIONSWAPCHAIN_INTERPOLATIONCOMMANDLIST_DX12> {}; |
||||
|
|
||||
|
struct QueryDescFrameGenerationSwapChainInterpolationCommandListDX12 : public InitHelper<ffxQueryDescFrameGenerationSwapChainInterpolationCommandListDX12> {}; |
||||
|
|
||||
|
template<> |
||||
|
struct struct_type<ffxQueryDescFrameGenerationSwapChainInterpolationTextureDX12> : std::integral_constant<uint64_t, FFX_API_QUERY_DESC_TYPE_FRAMEGENERATIONSWAPCHAIN_INTERPOLATIONTEXTURE_DX12> {}; |
||||
|
|
||||
|
struct QueryDescFrameGenerationSwapChainInterpolationTextureDX12 : public InitHelper<ffxQueryDescFrameGenerationSwapChainInterpolationTextureDX12> {}; |
||||
|
|
||||
|
template<> |
||||
|
struct struct_type<ffxDispatchDescFrameGenerationSwapChainWaitForPresentsDX12> : std::integral_constant<uint64_t, FFX_API_DISPATCH_DESC_TYPE_FRAMEGENERATIONSWAPCHAIN_WAIT_FOR_PRESENTS_DX12> {}; |
||||
|
|
||||
|
struct DispatchDescFrameGenerationSwapChainWaitForPresentsDX12 : public InitHelper<ffxDispatchDescFrameGenerationSwapChainWaitForPresentsDX12> {}; |
||||
|
|
||||
|
template<> |
||||
|
struct struct_type<ffxConfigureDescFrameGenerationSwapChainKeyValueDX12> : std::integral_constant<uint64_t, FFX_API_CONFIGURE_DESC_TYPE_FRAMEGENERATIONSWAPCHAIN_KEYVALUE_DX12> {}; |
||||
|
|
||||
|
struct ConfigureDescFrameGenerationSwapChainKeyValueDX12 : public InitHelper<ffxConfigureDescFrameGenerationSwapChainKeyValueDX12> {}; |
||||
|
|
||||
|
template<> |
||||
|
struct struct_type<ffxQueryFrameGenerationSwapChainGetGPUMemoryUsageDX12> : std::integral_constant<uint64_t, FFX_API_QUERY_DESC_TYPE_FRAMEGENERATIONSWAPCHAIN_GPU_MEMORY_USAGE_DX12> {}; |
||||
|
|
||||
|
struct QueryFrameGenerationSwapChainGetGPUMemoryUsageDX12 : public InitHelper<ffxQueryFrameGenerationSwapChainGetGPUMemoryUsageDX12> {}; |
||||
|
|
||||
|
} |
||||
@ -0,0 +1,150 @@ |
|||||
|
// This file is part of the FidelityFX SDK. |
||||
|
// |
||||
|
// Copyright (C) 2024 Advanced Micro Devices, Inc. |
||||
|
// |
||||
|
// Permission is hereby granted, free of charge, to any person obtaining a copy |
||||
|
// of this software and associated documentation files(the "Software"), to deal |
||||
|
// in the Software without restriction, including without limitation the rights |
||||
|
// to use, copy, modify, merge, publish, distribute, sublicense, and /or sell |
||||
|
// copies of the Software, and to permit persons to whom the Software is |
||||
|
// furnished to do so, subject to the following conditions : |
||||
|
// |
||||
|
// The above copyright notice and this permission notice shall be included in |
||||
|
// all copies or substantial portions of the Software. |
||||
|
// |
||||
|
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
||||
|
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
||||
|
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
||||
|
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
||||
|
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
||||
|
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN |
||||
|
// THE SOFTWARE. |
||||
|
|
||||
|
#pragma once |
||||
|
|
||||
|
#if defined(__cplusplus) |
||||
|
extern "C" { |
||||
|
#endif // #if defined(__cplusplus) |
||||
|
|
||||
|
#define FFX_API_ENTRY __declspec(dllexport) |
||||
|
#include <stdint.h> |
||||
|
|
||||
|
enum FfxApiReturnCodes |
||||
|
{ |
||||
|
FFX_API_RETURN_OK = 0, ///< The oparation was successful. |
||||
|
FFX_API_RETURN_ERROR = 1, ///< An error occurred that is not further specified. |
||||
|
FFX_API_RETURN_ERROR_UNKNOWN_DESCTYPE = 2, ///< The structure type given was not recognized for the function or context with which it was used. This is likely a programming error. |
||||
|
FFX_API_RETURN_ERROR_RUNTIME_ERROR = 3, ///< The underlying runtime (e.g. D3D12, Vulkan) or effect returned an error code. |
||||
|
FFX_API_RETURN_NO_PROVIDER = 4, ///< No provider was found for the given structure type. This is likely a programming error. |
||||
|
FFX_API_RETURN_ERROR_MEMORY = 5, ///< A memory allocation failed. |
||||
|
FFX_API_RETURN_ERROR_PARAMETER = 6, ///< A parameter was invalid, e.g. a null pointer, empty resource or out-of-bounds enum value. |
||||
|
}; |
||||
|
|
||||
|
typedef void* ffxContext; |
||||
|
typedef uint32_t ffxReturnCode_t; |
||||
|
|
||||
|
#define FFX_API_EFFECT_MASK 0xffff0000u |
||||
|
#define FFX_API_EFFECT_ID_GENERAL 0x00000000u |
||||
|
|
||||
|
// Base Descriptor types |
||||
|
typedef uint64_t ffxStructType_t; |
||||
|
typedef struct ffxApiHeader |
||||
|
{ |
||||
|
ffxStructType_t type; ///< The structure type. Must always be set to the corresponding value for any structure (found nearby with a similar name). |
||||
|
struct ffxApiHeader* pNext; ///< Pointer to next structure, used for optional parameters and extensions. Can be null. |
||||
|
} ffxApiHeader; |
||||
|
|
||||
|
typedef ffxApiHeader ffxCreateContextDescHeader; |
||||
|
typedef ffxApiHeader ffxConfigureDescHeader; |
||||
|
typedef ffxApiHeader ffxQueryDescHeader; |
||||
|
typedef ffxApiHeader ffxDispatchDescHeader; |
||||
|
|
||||
|
// Extensions for global debug |
||||
|
#define FFX_API_CONFIGURE_GLOBALDEBUG_LEVEL_SILENCE 0x0000000u |
||||
|
#define FFX_API_CONFIGURE_GLOBALDEBUG_LEVEL_ERRORS 0x0000001u |
||||
|
#define FFX_API_CONFIGURE_GLOBALDEBUG_LEVEL_WARNINGS 0x0000002u |
||||
|
#define FFX_API_CONFIGURE_GLOBALDEBUG_LEVEL_VERBOSE 0xfffffffu |
||||
|
|
||||
|
enum FfxApiMsgType |
||||
|
{ |
||||
|
FFX_API_MESSAGE_TYPE_ERROR = 0, |
||||
|
FFX_API_MESSAGE_TYPE_WARNING = 1, |
||||
|
FFX_API_MESSAGE_TYPE_COUNT |
||||
|
}; |
||||
|
|
||||
|
typedef void (*ffxApiMessage)(uint32_t type, const wchar_t* message); |
||||
|
|
||||
|
#define FFX_API_CONFIGURE_DESC_TYPE_GLOBALDEBUG1 0x0000001u |
||||
|
struct ffxConfigureDescGlobalDebug1 |
||||
|
{ |
||||
|
ffxConfigureDescHeader header; |
||||
|
ffxApiMessage fpMessage; |
||||
|
uint32_t debugLevel; |
||||
|
}; |
||||
|
|
||||
|
#define FFX_API_QUERY_DESC_TYPE_GET_VERSIONS 4u |
||||
|
struct ffxQueryDescGetVersions |
||||
|
{ |
||||
|
ffxQueryDescHeader header; |
||||
|
uint64_t createDescType; ///< Create description for the effect whose versions should be enumerated. |
||||
|
void* device; ///< For DX12: pointer to ID3D12Device. |
||||
|
uint64_t *outputCount; ///< Input capacity of id and name arrays. Output number of returned versions. If initially zero, output is number of available versions. |
||||
|
uint64_t *versionIds; ///< Output array of version ids to be used as version overrides. If null, only names and count are returned. |
||||
|
const char** versionNames; ///< Output array of version names for display. If null, only ids and count are returned. If both this and versionIds are null, only count is returned. |
||||
|
}; |
||||
|
|
||||
|
#define FFX_API_DESC_TYPE_OVERRIDE_VERSION 5u |
||||
|
struct ffxOverrideVersion |
||||
|
{ |
||||
|
ffxApiHeader header; |
||||
|
uint64_t versionId; ///< Id of version to use. Must be a value returned from a query in ffxQueryDescGetVersions.versionIds array. |
||||
|
}; |
||||
|
|
||||
|
// 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); |
||||
|
|
||||
|
// Memory deallocation function. May be called with null pointer as second argument. |
||||
|
typedef void (*ffxDealloc)(void* pUserData, void* pMem); |
||||
|
|
||||
|
typedef struct ffxAllocationCallbacks |
||||
|
{ |
||||
|
void* pUserData; |
||||
|
ffxAlloc alloc; |
||||
|
ffxDealloc dealloc; |
||||
|
} ffxAllocationCallbacks; |
||||
|
|
||||
|
// Creates a FFX object context. |
||||
|
// Depending on the desc structures provided to this function, the context will be created with the desired version and attributes. |
||||
|
// Non-zero return indicates error code. |
||||
|
// Pointers passed in desc must remain live until ffxDestroyContext is called on the context. |
||||
|
// MemCb may be null; the system allocator (malloc/free) will be used in this case. |
||||
|
FFX_API_ENTRY ffxReturnCode_t ffxCreateContext(ffxContext* context, ffxCreateContextDescHeader* desc, const ffxAllocationCallbacks* memCb); |
||||
|
typedef ffxReturnCode_t (*PfnFfxCreateContext)(ffxContext* context, ffxCreateContextDescHeader* desc, const ffxAllocationCallbacks* memCb); |
||||
|
|
||||
|
// Destroys an FFX object context. |
||||
|
// Non-zero return indicates error code. |
||||
|
// MemCb must be compatible with the callbacks passed into ffxCreateContext. |
||||
|
FFX_API_ENTRY ffxReturnCode_t ffxDestroyContext(ffxContext* context, const ffxAllocationCallbacks* memCb); |
||||
|
typedef ffxReturnCode_t (*PfnFfxDestroyContext)(ffxContext* context, const ffxAllocationCallbacks* memCb); |
||||
|
|
||||
|
// Configures the provided FFX object context. |
||||
|
// If context is null, configure operates on any global state. |
||||
|
// Non-zero return indicates error code. |
||||
|
FFX_API_ENTRY ffxReturnCode_t ffxConfigure(ffxContext* context, const ffxConfigureDescHeader* desc); |
||||
|
typedef ffxReturnCode_t (*PfnFfxConfigure)(ffxContext* context, const ffxConfigureDescHeader* desc); |
||||
|
|
||||
|
// Queries the provided FFX object context. |
||||
|
// If context is null, query operates on any global state. |
||||
|
// Non-zero return indicates error code. |
||||
|
FFX_API_ENTRY ffxReturnCode_t ffxQuery(ffxContext* context, ffxQueryDescHeader* desc); |
||||
|
typedef ffxReturnCode_t (*PfnFfxQuery)(ffxContext* context, ffxQueryDescHeader* desc); |
||||
|
|
||||
|
// Dispatches work on the given FFX object context defined by the dispatch descriptor. |
||||
|
// Non-zero return indicates error code. |
||||
|
FFX_API_ENTRY ffxReturnCode_t ffxDispatch(ffxContext* context, const ffxDispatchDescHeader* desc); |
||||
|
typedef ffxReturnCode_t (*PfnFfxDispatch)(ffxContext* context, const ffxDispatchDescHeader* desc); |
||||
|
|
||||
|
#if defined(__cplusplus) |
||||
|
} |
||||
|
#endif // #if defined(__cplusplus) |
||||
@ -0,0 +1,176 @@ |
|||||
|
// This file is part of the FidelityFX SDK.
|
||||
|
//
|
||||
|
// Copyright (C) 2024 Advanced Micro Devices, Inc.
|
||||
|
//
|
||||
|
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
|
// of this software and associated documentation files(the "Software"), to deal
|
||||
|
// in the Software without restriction, including without limitation the rights
|
||||
|
// to use, copy, modify, merge, publish, distribute, sublicense, and /or sell
|
||||
|
// copies of the Software, and to permit persons to whom the Software is
|
||||
|
// furnished to do so, subject to the following conditions :
|
||||
|
//
|
||||
|
// The above copyright notice and this permission notice shall be included in
|
||||
|
// all copies or substantial portions of the Software.
|
||||
|
//
|
||||
|
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
|
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
|
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
|
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
|
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
|
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
|
// THE SOFTWARE.
|
||||
|
|
||||
|
#pragma once
|
||||
|
|
||||
|
#include "ffx_api.h"
|
||||
|
|
||||
|
#include <cstdint>
|
||||
|
#include <type_traits>
|
||||
|
|
||||
|
namespace ffx |
||||
|
{ |
||||
|
|
||||
|
using Context = ffxContext; |
||||
|
|
||||
|
enum class ReturnCode : uint32_t |
||||
|
{ |
||||
|
Ok = 0, |
||||
|
Error = 1, |
||||
|
ErrorUnknownDesctype = 2, |
||||
|
ErrorRuntimeError = 3, |
||||
|
ErrorNoProvider = 4, |
||||
|
ErrorMemory = 5, |
||||
|
ErrorParameter = 6, |
||||
|
}; |
||||
|
|
||||
|
static inline constexpr bool operator!(ReturnCode rc) |
||||
|
{ |
||||
|
return rc != ReturnCode::Ok; |
||||
|
} |
||||
|
|
||||
|
namespace detail |
||||
|
{ |
||||
|
static inline ReturnCode ConvertReturnCode(ffxReturnCode_t rc) |
||||
|
{ |
||||
|
return static_cast<ReturnCode>(rc); |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
template<class First, class Second, class... Rest> |
||||
|
First* LinkHeaders(First& first, Second& second, Rest&... rest) |
||||
|
{ |
||||
|
first.pNext = &second; |
||||
|
LinkHeaders(second, rest...); |
||||
|
return &first; |
||||
|
} |
||||
|
|
||||
|
template<class First, class Second> |
||||
|
First* LinkHeaders(First& first, Second& second) |
||||
|
{ |
||||
|
first.pNext = &second; |
||||
|
second.pNext = nullptr; |
||||
|
return &first; |
||||
|
} |
||||
|
|
||||
|
template<class Header> |
||||
|
Header* LinkHeaders(Header& hdr) |
||||
|
{ |
||||
|
hdr.pNext = nullptr; |
||||
|
return &hdr; |
||||
|
} |
||||
|
|
||||
|
template<class... Desc> |
||||
|
inline ReturnCode CreateContext(Context& context, ffxAllocationCallbacks* memCb, Desc&... desc) |
||||
|
{ |
||||
|
auto header = LinkHeaders(desc.header...); |
||||
|
return detail::ConvertReturnCode(ffxCreateContext(&context, header, memCb)); |
||||
|
} |
||||
|
|
||||
|
inline ReturnCode DestroyContext(Context& context, ffxAllocationCallbacks* memCb = nullptr) |
||||
|
{ |
||||
|
return detail::ConvertReturnCode(ffxDestroyContext(&context, memCb)); |
||||
|
} |
||||
|
|
||||
|
template<class... Desc> |
||||
|
inline ReturnCode Configure(Context &context, Desc&... desc) |
||||
|
{ |
||||
|
auto header = LinkHeaders(desc.header...); |
||||
|
return detail::ConvertReturnCode(ffxConfigure(&context, header)); |
||||
|
} |
||||
|
|
||||
|
template<class... Desc> |
||||
|
inline ReturnCode Configure(Desc&... desc) |
||||
|
{ |
||||
|
auto header = LinkHeaders(desc.header...); |
||||
|
return detail::ConvertReturnCode(ffxConfigure(nullptr, header)); |
||||
|
} |
||||
|
|
||||
|
template<class... Desc> |
||||
|
inline ReturnCode Query(Context &context, Desc&... desc) |
||||
|
{ |
||||
|
auto header = LinkHeaders(desc.header...); |
||||
|
return detail::ConvertReturnCode(ffxQuery(&context, header)); |
||||
|
} |
||||
|
|
||||
|
template<class... Desc> |
||||
|
inline ReturnCode Query(Desc&... desc) |
||||
|
{ |
||||
|
auto header = LinkHeaders(desc.header...); |
||||
|
return detail::ConvertReturnCode(ffxQuery(nullptr, header)); |
||||
|
} |
||||
|
|
||||
|
template<class... Desc> |
||||
|
inline ReturnCode Dispatch(Context &context, Desc&... desc) |
||||
|
{ |
||||
|
auto header = LinkHeaders(desc.header...); |
||||
|
return detail::ConvertReturnCode(ffxDispatch(&context, header)); |
||||
|
} |
||||
|
|
||||
|
template<class T> |
||||
|
struct struct_type; |
||||
|
|
||||
|
template<> |
||||
|
struct struct_type<ffxConfigureDescGlobalDebug1> : std::integral_constant<uint64_t, FFX_API_CONFIGURE_DESC_TYPE_GLOBALDEBUG1> {}; |
||||
|
|
||||
|
template<> |
||||
|
struct struct_type<ffxOverrideVersion> : std::integral_constant<uint64_t, FFX_API_DESC_TYPE_OVERRIDE_VERSION> {}; |
||||
|
|
||||
|
template<> |
||||
|
struct struct_type<ffxQueryDescGetVersions> : std::integral_constant<uint64_t, FFX_API_QUERY_DESC_TYPE_GET_VERSIONS> {}; |
||||
|
|
||||
|
template <class Inner, uint64_t type = struct_type<Inner>::value> |
||||
|
struct InitHelper : public Inner |
||||
|
{ |
||||
|
InitHelper() : Inner() |
||||
|
{ |
||||
|
this->header.pNext = nullptr; |
||||
|
this->header.type = type; |
||||
|
} |
||||
|
}; |
||||
|
|
||||
|
struct ConfigureDescGlobalDebug1 : public InitHelper<ffxConfigureDescGlobalDebug1> |
||||
|
{}; |
||||
|
|
||||
|
struct CreateContextDescOverrideVersion : public InitHelper<ffxOverrideVersion> |
||||
|
{}; |
||||
|
|
||||
|
struct QueryDescGetVersions : public InitHelper<ffxQueryDescGetVersions> |
||||
|
{}; |
||||
|
|
||||
|
template<class T> |
||||
|
const T* DynamicCast(const ffxApiHeader *hdr) |
||||
|
{ |
||||
|
if (hdr->type == struct_type<T>::value) |
||||
|
return reinterpret_cast<const T*>(hdr); |
||||
|
return nullptr; |
||||
|
} |
||||
|
|
||||
|
template<class T> |
||||
|
T* DynamicCast(ffxApiHeader *hdr) |
||||
|
{ |
||||
|
if (hdr->type == struct_type<T>::value) |
||||
|
return reinterpret_cast<T*>(hdr); |
||||
|
return nullptr; |
||||
|
} |
||||
|
|
||||
|
} |
||||
@ -0,0 +1,43 @@ |
|||||
|
// This file is part of the FidelityFX SDK. |
||||
|
// |
||||
|
// Copyright (C) 2024 Advanced Micro Devices, Inc. |
||||
|
// |
||||
|
// Permission is hereby granted, free of charge, to any person obtaining a copy |
||||
|
// of this software and associated documentation files(the "Software"), to deal |
||||
|
// in the Software without restriction, including without limitation the rights |
||||
|
// to use, copy, modify, merge, publish, distribute, sublicense, and /or sell |
||||
|
// copies of the Software, and to permit persons to whom the Software is |
||||
|
// furnished to do so, subject to the following conditions : |
||||
|
// |
||||
|
// The above copyright notice and this permission notice shall be included in |
||||
|
// all copies or substantial portions of the Software. |
||||
|
// |
||||
|
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
||||
|
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
||||
|
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
||||
|
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
||||
|
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
||||
|
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN |
||||
|
// THE SOFTWARE. |
||||
|
|
||||
|
#pragma once |
||||
|
|
||||
|
#include "ffx_api.h" |
||||
|
#include <windows.h> |
||||
|
|
||||
|
typedef struct ffxFunctions { |
||||
|
PfnFfxCreateContext CreateContext; |
||||
|
PfnFfxDestroyContext DestroyContext; |
||||
|
PfnFfxConfigure Configure; |
||||
|
PfnFfxQuery Query; |
||||
|
PfnFfxDispatch Dispatch; |
||||
|
} ffxFunctions; |
||||
|
|
||||
|
static inline void ffxLoadFunctions(ffxFunctions* pOutFunctions, HMODULE module) |
||||
|
{ |
||||
|
pOutFunctions->CreateContext = (PfnFfxCreateContext )GetProcAddress(module, "ffxCreateContext"); |
||||
|
pOutFunctions->DestroyContext = (PfnFfxDestroyContext)GetProcAddress(module, "ffxDestroyContext"); |
||||
|
pOutFunctions->Configure = (PfnFfxConfigure )GetProcAddress(module, "ffxConfigure"); |
||||
|
pOutFunctions->Query = (PfnFfxQuery )GetProcAddress(module, "ffxQuery"); |
||||
|
pOutFunctions->Dispatch = (PfnFfxDispatch )GetProcAddress(module, "ffxDispatch"); |
||||
|
} |
||||
@ -0,0 +1,242 @@ |
|||||
|
// This file is part of the FidelityFX SDK. |
||||
|
// |
||||
|
// Copyright (C) 2024 Advanced Micro Devices, Inc. |
||||
|
// |
||||
|
// Permission is hereby granted, free of charge, to any person obtaining a copy |
||||
|
// of this software and associated documentation files(the "Software"), to deal |
||||
|
// in the Software without restriction, including without limitation the rights |
||||
|
// to use, copy, modify, merge, publish, distribute, sublicense, and /or sell |
||||
|
// copies of the Software, and to permit persons to whom the Software is |
||||
|
// furnished to do so, subject to the following conditions : |
||||
|
// |
||||
|
// The above copyright notice and this permission notice shall be included in |
||||
|
// all copies or substantial portions of the Software. |
||||
|
// |
||||
|
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
||||
|
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
||||
|
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
||||
|
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
||||
|
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
||||
|
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN |
||||
|
// THE SOFTWARE. |
||||
|
|
||||
|
#pragma once |
||||
|
|
||||
|
#include <stdint.h> |
||||
|
|
||||
|
/// An enumeration of surface formats. Needs to match enum FfxSurfaceFormat |
||||
|
enum FfxApiSurfaceFormat |
||||
|
{ |
||||
|
FFX_API_SURFACE_FORMAT_UNKNOWN, ///< Unknown format |
||||
|
FFX_API_SURFACE_FORMAT_R32G32B32A32_TYPELESS, ///< 32 bit per channel, 4 channel typeless format |
||||
|
FFX_API_SURFACE_FORMAT_R32G32B32A32_UINT, ///< 32 bit per channel, 4 channel uint format |
||||
|
FFX_API_SURFACE_FORMAT_R32G32B32A32_FLOAT, ///< 32 bit per channel, 4 channel float format |
||||
|
FFX_API_SURFACE_FORMAT_R16G16B16A16_FLOAT, ///< 16 bit per channel, 4 channel float format |
||||
|
FFX_API_SURFACE_FORMAT_R32G32B32_FLOAT, ///< 32 bit per channel, 3 channel float format |
||||
|
FFX_API_SURFACE_FORMAT_R32G32_FLOAT, ///< 32 bit per channel, 2 channel float format |
||||
|
FFX_API_SURFACE_FORMAT_R8_UINT, ///< 8 bit per channel, 1 channel float format |
||||
|
FFX_API_SURFACE_FORMAT_R32_UINT, ///< 32 bit per channel, 1 channel float format |
||||
|
FFX_API_SURFACE_FORMAT_R8G8B8A8_TYPELESS, ///< 8 bit per channel, 4 channel typeless format |
||||
|
FFX_API_SURFACE_FORMAT_R8G8B8A8_UNORM, ///< 8 bit per channel, 4 channel unsigned normalized format |
||||
|
FFX_API_SURFACE_FORMAT_R8G8B8A8_SNORM, ///< 8 bit per channel, 4 channel signed normalized format |
||||
|
FFX_API_SURFACE_FORMAT_R8G8B8A8_SRGB, ///< 8 bit per channel, 4 channel srgb normalized |
||||
|
FFX_API_SURFACE_FORMAT_B8G8R8A8_TYPELESS, ///< 8 bit per channel, 4 channel typeless format |
||||
|
FFX_API_SURFACE_FORMAT_B8G8R8A8_UNORM, ///< 8 bit per channel, 4 channel unsigned normalized format |
||||
|
FFX_API_SURFACE_FORMAT_B8G8R8A8_SRGB, ///< 8 bit per channel, 4 channel srgb normalized |
||||
|
FFX_API_SURFACE_FORMAT_R11G11B10_FLOAT, ///< 32 bit 3 channel float format |
||||
|
FFX_API_SURFACE_FORMAT_R10G10B10A2_UNORM, ///< 10 bit per 3 channel, 2 bit for 1 channel normalized format |
||||
|
FFX_API_SURFACE_FORMAT_R16G16_FLOAT, ///< 16 bit per channel, 2 channel float format |
||||
|
FFX_API_SURFACE_FORMAT_R16G16_UINT, ///< 16 bit per channel, 2 channel unsigned int format |
||||
|
FFX_API_SURFACE_FORMAT_R16G16_SINT, ///< 16 bit per channel, 2 channel signed int format |
||||
|
FFX_API_SURFACE_FORMAT_R16_FLOAT, ///< 16 bit per channel, 1 channel float format |
||||
|
FFX_API_SURFACE_FORMAT_R16_UINT, ///< 16 bit per channel, 1 channel unsigned int format |
||||
|
FFX_API_SURFACE_FORMAT_R16_UNORM, ///< 16 bit per channel, 1 channel unsigned normalized format |
||||
|
FFX_API_SURFACE_FORMAT_R16_SNORM, ///< 16 bit per channel, 1 channel signed normalized format |
||||
|
FFX_API_SURFACE_FORMAT_R8_UNORM, ///< 8 bit per channel, 1 channel unsigned normalized format |
||||
|
FFX_API_SURFACE_FORMAT_R8G8_UNORM, ///< 8 bit per channel, 2 channel unsigned normalized format |
||||
|
FFX_API_SURFACE_FORMAT_R8G8_UINT, ///< 8 bit per channel, 2 channel unsigned integer format |
||||
|
FFX_API_SURFACE_FORMAT_R32_FLOAT, ///< 32 bit per channel, 1 channel float format |
||||
|
FFX_API_SURFACE_FORMAT_R9G9B9E5_SHAREDEXP, ///< 9 bit per channel, 5 bit exponent format |
||||
|
|
||||
|
FFX_API_SURFACE_FORMAT_R16G16B16A16_TYPELESS, ///< 16 bit per channel, 4 channel typeless format |
||||
|
FFX_API_SURFACE_FORMAT_R32G32_TYPELESS, ///< 32 bit per channel, 2 channel typeless format |
||||
|
FFX_API_SURFACE_FORMAT_R10G10B10A2_TYPELESS, ///< 10 bit per 3 channel, 2 bit for 1 channel typeless format |
||||
|
FFX_API_SURFACE_FORMAT_R16G16_TYPELESS, ///< 16 bit per channel, 2 channel typless format |
||||
|
FFX_API_SURFACE_FORMAT_R16_TYPELESS, ///< 16 bit per channel, 1 channel typeless format |
||||
|
FFX_API_SURFACE_FORMAT_R8_TYPELESS, ///< 8 bit per channel, 1 channel typeless format |
||||
|
FFX_API_SURFACE_FORMAT_R8G8_TYPELESS, ///< 8 bit per channel, 2 channel typeless format |
||||
|
FFX_API_SURFACE_FORMAT_R32_TYPELESS, ///< 32 bit per channel, 1 channel typeless format |
||||
|
}; |
||||
|
|
||||
|
/// An enumeration of resource usage. |
||||
|
enum FfxApiResourceUsage |
||||
|
{ |
||||
|
FFX_API_RESOURCE_USAGE_READ_ONLY = 0, ///< No usage flags indicate a resource is read only. |
||||
|
FFX_API_RESOURCE_USAGE_RENDERTARGET = (1<<0), ///< Indicates a resource will be used as render target. |
||||
|
FFX_API_RESOURCE_USAGE_UAV = (1<<1), ///< Indicates a resource will be used as UAV. |
||||
|
FFX_API_RESOURCE_USAGE_DEPTHTARGET = (1<<2), ///< Indicates a resource will be used as depth target. |
||||
|
FFX_API_RESOURCE_USAGE_INDIRECT = (1<<3), ///< Indicates a resource will be used as indirect argument buffer |
||||
|
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 |
||||
|
{ |
||||
|
FFX_API_RESOURCE_STATE_COMMON = (1 << 0), |
||||
|
FFX_API_RESOURCE_STATE_UNORDERED_ACCESS = (1 << 1), ///< Indicates a resource is in the state to be used as UAV. |
||||
|
FFX_API_RESOURCE_STATE_COMPUTE_READ = (1 << 2), ///< Indicates a resource is in the state to be read by compute shaders. |
||||
|
FFX_API_RESOURCE_STATE_PIXEL_READ = (1 << 3), ///< Indicates a resource is in the state to be read by pixel shaders. |
||||
|
FFX_API_RESOURCE_STATE_PIXEL_COMPUTE_READ = (FFX_API_RESOURCE_STATE_PIXEL_READ | FFX_API_RESOURCE_STATE_COMPUTE_READ), ///< Indicates a resource is in the state to be read by pixel or compute shaders. |
||||
|
FFX_API_RESOURCE_STATE_COPY_SRC = (1 << 4), ///< Indicates a resource is in the state to be used as source in a copy command. |
||||
|
FFX_API_RESOURCE_STATE_COPY_DEST = (1 << 5), ///< Indicates a resource is in the state to be used as destination in a copy command. |
||||
|
FFX_API_RESOURCE_STATE_GENERIC_READ = (FFX_API_RESOURCE_STATE_COPY_SRC | FFX_API_RESOURCE_STATE_COMPUTE_READ), ///< Indicates a resource is in generic (slow) read state. |
||||
|
FFX_API_RESOURCE_STATE_INDIRECT_ARGUMENT = (1 << 6), ///< Indicates a resource is in the state to be used as an indirect command argument |
||||
|
FFX_API_RESOURCE_STATE_PRESENT = (1 << 7), ///< Indicates a resource is in the state to be used to present to the swap chain |
||||
|
FFX_API_RESOURCE_STATE_RENDER_TARGET = (1 << 8), ///< Indicates a resource is in the state to be used as render target |
||||
|
}; |
||||
|
|
||||
|
/// An enumeration of surface dimensions. |
||||
|
enum FfxApiResourceDimension |
||||
|
{ |
||||
|
FFX_API_RESOURCE_DIMENSION_TEXTURE_1D, ///< A resource with a single dimension. |
||||
|
FFX_API_RESOURCE_DIMENSION_TEXTURE_2D, ///< A resource with two dimensions. |
||||
|
}; |
||||
|
|
||||
|
/// An enumeration of resource flags. |
||||
|
enum FfxApiResourceFlags |
||||
|
{ |
||||
|
FFX_API_RESOURCE_FLAGS_NONE = 0, ///< No flags. |
||||
|
FFX_API_RESOURCE_FLAGS_ALIASABLE = (1 << 0), ///< A bit indicating a resource does not need to persist across frames. |
||||
|
FFX_API_RESOURCE_FLAGS_UNDEFINED = (1 << 1), ///< Special case flag used internally when importing resources that require additional setup |
||||
|
}; |
||||
|
|
||||
|
// An enumeration for different resource types |
||||
|
enum FfxApiResourceType |
||||
|
{ |
||||
|
FFX_API_RESOURCE_TYPE_BUFFER, ///< The resource is a buffer. |
||||
|
FFX_API_RESOURCE_TYPE_TEXTURE1D, ///< The resource is a 1-dimensional texture. |
||||
|
FFX_API_RESOURCE_TYPE_TEXTURE2D, ///< The resource is a 2-dimensional texture. |
||||
|
FFX_API_RESOURCE_TYPE_TEXTURE_CUBE, ///< The resource is a cube map. |
||||
|
FFX_API_RESOURCE_TYPE_TEXTURE3D, ///< The resource is a 3-dimensional texture. |
||||
|
}; |
||||
|
|
||||
|
enum FfxApiBackbufferTransferFunction |
||||
|
{ |
||||
|
FFX_API_BACKBUFFER_TRANSFER_FUNCTION_SRGB, |
||||
|
FFX_API_BACKBUFFER_TRANSFER_FUNCTION_PQ, |
||||
|
FFX_API_BACKBUFFER_TRANSFER_FUNCTION_SCRGB |
||||
|
}; |
||||
|
|
||||
|
/// A structure encapsulating a 2-dimensional point, using 32bit unsigned integers. |
||||
|
struct FfxApiDimensions2D |
||||
|
{ |
||||
|
uint32_t width; ///< The width of a 2-dimensional range. |
||||
|
uint32_t height; ///< The height of a 2-dimensional range. |
||||
|
}; |
||||
|
|
||||
|
/// A structure encapsulating a 2-dimensional set of floating point coordinates. |
||||
|
struct FfxApiFloatCoords2D |
||||
|
{ |
||||
|
float x; ///< The x coordinate of a 2-dimensional point. |
||||
|
float y; ///< The y coordinate of a 2-dimensional point. |
||||
|
}; |
||||
|
|
||||
|
/// A structure encapsulating a 2-dimensional rect. |
||||
|
struct FfxApiRect2D |
||||
|
{ |
||||
|
int32_t left; |
||||
|
int32_t top; |
||||
|
int32_t width; |
||||
|
int32_t height; |
||||
|
}; |
||||
|
|
||||
|
/// A structure describing a resource. |
||||
|
/// |
||||
|
/// @ingroup SDKTypes |
||||
|
struct FfxApiResourceDescription |
||||
|
{ |
||||
|
uint32_t type; ///< The type of the resource. |
||||
|
uint32_t format; ///< The surface format. |
||||
|
union { |
||||
|
uint32_t width; ///< The width of the texture resource. |
||||
|
uint32_t size; ///< The size of the buffer resource. |
||||
|
}; |
||||
|
|
||||
|
union { |
||||
|
uint32_t height; ///< The height of the texture resource. |
||||
|
uint32_t stride; ///< The stride of the buffer resource. |
||||
|
}; |
||||
|
|
||||
|
union { |
||||
|
uint32_t depth; ///< The depth of the texture resource. |
||||
|
uint32_t alignment; ///< The alignment of the buffer resource. |
||||
|
}; |
||||
|
|
||||
|
uint32_t mipCount; ///< Number of mips (or 0 for full mipchain). |
||||
|
uint32_t flags; ///< A set of resource flags. |
||||
|
uint32_t usage; ///< Resource usage flags. |
||||
|
}; |
||||
|
|
||||
|
struct FfxApiResource |
||||
|
{ |
||||
|
void* resource; |
||||
|
struct FfxApiResourceDescription description; |
||||
|
uint32_t state; |
||||
|
}; |
||||
|
|
||||
|
//struct definition matches FfxEffectMemoryUsage |
||||
|
typedef struct FfxApiEffectMemoryUsage |
||||
|
{ |
||||
|
uint64_t totalUsageInBytes; |
||||
|
uint64_t aliasableUsageInBytes; |
||||
|
} FfxApiEffectMemoryUsage; |
||||
|
|
||||
|
/* |
||||
|
Tuning varianceFactor and safetyMarginInMs Tips: |
||||
|
Calculation of frame pacing algorithm's next target timestamp: |
||||
|
target frametime delta = average Frametime - (variance * varianceFactor) - safetyMarginInMs |
||||
|
|
||||
|
Default Tuning uses safetyMarginInMs==0.1ms and varianceFactor==0.1. |
||||
|
Say Tuning set A uses safetyMarginInMs==0.75ms, and varianceFactor==0.1. |
||||
|
Say Tuning Set B uses safetyMarginInMs==0.01ms and varianceFactor==0.3. |
||||
|
|
||||
|
Example #1 - Actual Game Cutscene. Game's framerate after FG ON during camera pan from normal (19ms avg frametime) to complex (37ms avg frametime over 1 sec) and back to normal scene complexity (19ms avg frametime). |
||||
|
After the panning is done, |
||||
|
- Default Tuning now gets stuck at targeting ~33ms after panning to a complex scene. GPU utilization significantly lower in this case. |
||||
|
- Tuning Set B and Tuning Set A are able to recover close to ~19ms because of these 2 tuning result in lower "target frametime delta" than Default Tuning. |
||||
|
|
||||
|
However, larger varianceFactor or safetyMarginInMs results in higher variance. As seen in Example #2 bellow. |
||||
|
|
||||
|
Example #2 - FFX_API_FSR sample. Set app fps cap to 33.33ms. Use OCAT to capture 10s at default camera position. |
||||
|
FSR 3.1.0 FG msbetweenpresents ping-pong between 16.552 (5th-percentile) and 16.832 (95th-percentile). Variance is 0.01116. |
||||
|
Tuning set A FG msbetweenpresents ping-pong between 15.901 (5th-percentile) and 17.500 (95th-percentile). Variance is 0.057674. |
||||
|
Tuning Set B FG msbetweenpresents ping-pong between 16.589 (5th-percentile) and 16.971 (95th-percentile). Variance is 0.014452. |
||||
|
|
||||
|
| FG output Frames timestamp | n | n+1 | n+2 | n+3 | frame delta n+1 to n+2 | frame delta n+2 to n+3 | |
||||
|
| -------------------------- | - | ------ | ----- | ------ | ---------------------- | ---------------------- | |
||||
|
| App real frame presents | 0 | | 33.33 | | | | |
||||
|
| Default Tuning | 0 | 16.552 | 33.33 | 49.882 | 16.778 | 16.552 | |
||||
|
| Tuning Set A | 0 | 15.901 | 33.33 | 49.231 | 17.429 | 15.901 | |
||||
|
| Tuning Set B | 0 | 16.589 | 33.33 | 49.919 | 16.741 | 16.589 | |
||||
|
|
||||
|
Analysis of table data in words: |
||||
|
Ignoring the cost of FI, |
||||
|
"Tuning set A"'s "target frametime delta" of 15.901 results in larger frame to frame delta (or in other words larger variance) vs Default tuning. |
||||
|
"Tuning set B"'s "target frametime delta" of 16.589 results in a bit larger frame to frame delta (or in other words a bit larger variance) vs Default tuning. |
||||
|
|
||||
|
TLDR: |
||||
|
If your game when using FG, frame rate is running at unexpectly low frame rate, after gradual transition from rendering complex to easy scene complexity, you could try setting "Tuning Set B" to recover lost FPS at cost of a bit higher variance. |
||||
|
|
||||
|
*/ |
||||
|
|
||||
|
//struct definition matches FfxSwapchainFramePacingTuning |
||||
|
typedef struct FfxApiSwapchainFramePacingTuning |
||||
|
{ |
||||
|
float safetyMarginInMs; // in Millisecond. Default is 0.1ms |
||||
|
float varianceFactor; // valid range [0.0,1.0]. Default is 0.1 |
||||
|
bool allowHybridSpin; //Allows pacing spinlock to sleep. Default is false. |
||||
|
uint32_t hybridSpinTime; //How long to spin if allowHybridSpin is true. Measured in timer resolution units. Not recommended to go below 2. Will result in frequent overshoots. Default is 2. |
||||
|
bool allowWaitForSingleObjectOnFence; //Allows WaitForSingleObject instead of spinning for fence value. Default is false. |
||||
|
} FfxApiSwapchainFramePacingTuning; |
||||
@ -0,0 +1,177 @@ |
|||||
|
// This file is part of the FidelityFX SDK. |
||||
|
// |
||||
|
// Copyright (C) 2024 Advanced Micro Devices, Inc. |
||||
|
// |
||||
|
// Permission is hereby granted, free of charge, to any person obtaining a copy |
||||
|
// of this software and associated documentation files(the "Software"), to deal |
||||
|
// in the Software without restriction, including without limitation the rights |
||||
|
// to use, copy, modify, merge, publish, distribute, sublicense, and /or sell |
||||
|
// copies of the Software, and to permit persons to whom the Software is |
||||
|
// furnished to do so, subject to the following conditions : |
||||
|
// |
||||
|
// The above copyright notice and this permission notice shall be included in |
||||
|
// all copies or substantial portions of the Software. |
||||
|
// |
||||
|
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
||||
|
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
||||
|
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
||||
|
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
||||
|
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
||||
|
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN |
||||
|
// THE SOFTWARE. |
||||
|
|
||||
|
#pragma once |
||||
|
|
||||
|
#include "ffx_api.h" |
||||
|
#include "ffx_api_types.h" |
||||
|
|
||||
|
#define FFX_API_EFFECT_ID_FRAMEGENERATION 0x00020000u |
||||
|
|
||||
|
#if defined(__cplusplus) |
||||
|
extern "C" { |
||||
|
#endif |
||||
|
|
||||
|
enum FfxApiCreateContextFramegenerationFlags |
||||
|
{ |
||||
|
FFX_FRAMEGENERATION_ENABLE_ASYNC_WORKLOAD_SUPPORT = (1<<0), |
||||
|
FFX_FRAMEGENERATION_ENABLE_DISPLAY_RESOLUTION_MOTION_VECTORS = (1<<1), ///< A bit indicating if the motion vectors are rendered at display resolution. |
||||
|
FFX_FRAMEGENERATION_ENABLE_MOTION_VECTORS_JITTER_CANCELLATION = (1<<2), ///< A bit indicating that the motion vectors have the jittering pattern applied to them. |
||||
|
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. |
||||
|
}; |
||||
|
|
||||
|
enum FfxApiDispatchFramegenerationFlags |
||||
|
{ |
||||
|
FFX_FRAMEGENERATION_FLAG_DRAW_DEBUG_TEAR_LINES = (1 << 0), ///< A bit indicating that the debug tear lines will be drawn to the generated output. |
||||
|
FFX_FRAMEGENERATION_FLAG_DRAW_DEBUG_RESET_INDICATORS = (1 << 1), ///< A bit indicating that the debug reset indicators will be drawn to the generated output. |
||||
|
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. |
||||
|
|
||||
|
}; |
||||
|
|
||||
|
enum FfxApiUiCompositionFlags |
||||
|
{ |
||||
|
FFX_FRAMEGENERATION_UI_COMPOSITION_FLAG_USE_PREMUL_ALPHA = (1 << 0), ///< A bit indicating that we use premultiplied alpha for UI composition. |
||||
|
FFX_FRAMEGENERATION_UI_COMPOSITION_FLAG_ENABLE_INTERNAL_UI_DOUBLE_BUFFERING = (1 << 1), ///< A bit indicating that the swapchain should doublebuffer the UI resource. |
||||
|
}; |
||||
|
|
||||
|
#define FFX_API_CREATE_CONTEXT_DESC_TYPE_FRAMEGENERATION 0x00020001u |
||||
|
struct ffxCreateContextDescFrameGeneration |
||||
|
{ |
||||
|
ffxCreateContextDescHeader header; |
||||
|
uint32_t flags; ///< A combination of zero or more values from FfxApiCreateContextFramegenerationFlags. |
||||
|
struct FfxApiDimensions2D displaySize; ///< The resolution at which both rendered and generated frames will be displayed. |
||||
|
struct FfxApiDimensions2D maxRenderSize; ///< The maximum rendering resolution. |
||||
|
uint32_t backBufferFormat; ///< The surface format for the backbuffer. One of the values from FfxApiSurfaceFormat. |
||||
|
}; |
||||
|
|
||||
|
#define FFX_API_CALLBACK_DESC_TYPE_FRAMEGENERATION_PRESENT 0x00020005u |
||||
|
struct ffxCallbackDescFrameGenerationPresent |
||||
|
{ |
||||
|
ffxDispatchDescHeader header; |
||||
|
void* device; ///< The device passed in (from a backend description) during context creation. |
||||
|
void* commandList; ///< A command list that will be executed before presentation. |
||||
|
struct FfxApiResource currentBackBuffer; ///< Backbuffer image either rendered or generated. |
||||
|
struct FfxApiResource currentUI; ///< UI image for composition if passed. Otherwise empty. |
||||
|
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. |
||||
|
}; |
||||
|
|
||||
|
#define FFX_API_DISPATCH_DESC_TYPE_FRAMEGENERATION 0x00020003u |
||||
|
struct ffxDispatchDescFrameGeneration |
||||
|
{ |
||||
|
ffxDispatchDescHeader header; |
||||
|
void* commandList; ///< The command list on which to register render commands. |
||||
|
struct FfxApiResource presentColor; ///< The current presentation color, this will be used as source data. |
||||
|
struct FfxApiResource outputs[4]; ///< Destination targets (1 for each frame in numGeneratedFrames). |
||||
|
uint32_t numGeneratedFrames; ///< The number of frames to generate from the passed in color target. |
||||
|
bool reset; ///< A boolean value which when set to true, indicates the camera has moved discontinuously. |
||||
|
uint32_t backbufferTransferFunction; ///< The transfer function use to convert frame generation source color data to linear RGB. One of the values from FfxApiBackbufferTransferFunction. |
||||
|
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. |
||||
|
}; |
||||
|
|
||||
|
typedef ffxReturnCode_t(*FfxApiPresentCallbackFunc)(ffxCallbackDescFrameGenerationPresent* params, void* pUserCtx); |
||||
|
typedef ffxReturnCode_t(*FfxApiFrameGenerationDispatchFunc)(ffxDispatchDescFrameGeneration* params, void* pUserCtx); |
||||
|
|
||||
|
#define FFX_API_CONFIGURE_DESC_TYPE_FRAMEGENERATION 0x00020002u |
||||
|
struct ffxConfigureDescFrameGeneration |
||||
|
{ |
||||
|
ffxConfigureDescHeader header; |
||||
|
void* swapChain; ///< The swapchain to use with frame generation. |
||||
|
FfxApiPresentCallbackFunc presentCallback; ///< A UI composition callback to call when finalizing the frame image. |
||||
|
void* presentCallbackUserContext; ///< A pointer to be passed to the UI composition callback. |
||||
|
FfxApiFrameGenerationDispatchFunc frameGenerationCallback; ///< The frame generation callback to use to generate a frame. |
||||
|
void* frameGenerationCallbackUserContext; ///< A pointer to be passed to the frame generation callback. |
||||
|
bool frameGenerationEnabled; ///< Sets the state of frame generation. Set to false to disable frame generation. |
||||
|
bool allowAsyncWorkloads; ///< Sets the state of async workloads. Set to true to enable generation work on async compute. |
||||
|
struct FfxApiResource HUDLessColor; ///< The hudless back buffer image to use for UI extraction from backbuffer resource. May be empty. |
||||
|
uint32_t flags; ///< Zero or combination of flags from FfxApiDispatchFrameGenerationFlags. |
||||
|
bool onlyPresentGenerated; ///< Set to true to only present generated frames. |
||||
|
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. |
||||
|
}; |
||||
|
|
||||
|
#define FFX_API_DISPATCH_DESC_TYPE_FRAMEGENERATION_PREPARE 0x00020004u |
||||
|
struct ffxDispatchDescFrameGenerationPrepare |
||||
|
{ |
||||
|
ffxDispatchDescHeader header; |
||||
|
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. |
||||
|
uint32_t flags; ///< Zero or combination of values from FfxApiDispatchFrameGenerationFlags. |
||||
|
void* commandList; ///< A command list to record frame generation commands into. |
||||
|
struct FfxApiDimensions2D renderSize; ///< The dimensions used to render game content, dilatedDepth, dilatedMotionVectors are expected to be of ths size. |
||||
|
struct FfxApiFloatCoords2D jitterOffset; ///< The subpixel jitter offset applied to the camera. |
||||
|
struct FfxApiFloatCoords2D motionVectorScale; ///< The scale factor to apply to motion vectors. |
||||
|
|
||||
|
float frameTimeDelta; ///< Time elapsed in milliseconds since the last frame. |
||||
|
bool unused_reset; ///< A (currently unused) boolean value which when set to true, indicates FrameGeneration will be called in reset mode |
||||
|
float cameraNear; ///< The distance to the near plane of the camera. |
||||
|
float cameraFar; ///< The distance to the far plane of the camera. This is used only used in case of non infinite depth. |
||||
|
float cameraFovAngleVertical; ///< The camera angle field of view in the vertical direction (expressed in radians). |
||||
|
float viewSpaceToMetersFactor; ///< The scale factor to convert view space units to meters |
||||
|
struct FfxApiResource depth; ///< The depth buffer data |
||||
|
struct FfxApiResource motionVectors; ///< The motion vector data |
||||
|
}; |
||||
|
|
||||
|
#define FFX_API_CONFIGURE_DESC_TYPE_FRAMEGENERATION_KEYVALUE 0x00020006u |
||||
|
struct ffxConfigureDescFrameGenerationKeyValue |
||||
|
{ |
||||
|
ffxConfigureDescHeader header; |
||||
|
uint64_t key; ///< Configuration key, member of the FfxApiConfigureFrameGenerationKey enumeration. |
||||
|
uint64_t u64; ///< Integer value or enum value to set. |
||||
|
void* ptr; ///< Pointer to set or pointer to value to set. |
||||
|
}; |
||||
|
|
||||
|
enum FfxApiConfigureFrameGenerationKey |
||||
|
{ |
||||
|
// No values. |
||||
|
}; |
||||
|
|
||||
|
#define FFX_API_QUERY_DESC_TYPE_FRAMEGENERATION_GPU_MEMORY_USAGE 0x00020007u |
||||
|
struct ffxQueryDescFrameGenerationGetGPUMemoryUsage |
||||
|
{ |
||||
|
ffxQueryDescHeader header; |
||||
|
struct FfxApiEffectMemoryUsage* gpuMemoryUsageFrameGeneration; |
||||
|
}; |
||||
|
|
||||
|
#define FFX_API_CONFIGURE_DESC_TYPE_FRAMEGENERATION_REGISTERDISTORTIONRESOURCE 0x00020008u |
||||
|
struct ffxConfigureDescFrameGenerationRegisterDistortionFieldResource |
||||
|
{ |
||||
|
ffxConfigureDescHeader header; |
||||
|
struct FfxApiResource distortionField; ///< A resource containing distortion offset data. Needs to be 2-component (ie. RG). Read by FG shaders via Sample. Resource's xy components encodes [UV coordinate of pixel after lens distortion effect- UV coordinate of pixel before lens distortion]. |
||||
|
}; |
||||
|
|
||||
|
#define FFX_API_CREATE_CONTEXT_DESC_TYPE_FRAMEGENERATION_HUDLESS 0x00020009u |
||||
|
struct ffxCreateContextDescFrameGenerationHudless |
||||
|
{ |
||||
|
ffxCreateContextDescHeader header; |
||||
|
uint32_t hudlessBackBufferFormat; ///< The surface format for the hudless back buffer. One of the values from FfxApiSurfaceFormat. |
||||
|
}; |
||||
|
|
||||
|
#if defined(__cplusplus) |
||||
|
} // extern "C" |
||||
|
#endif |
||||
@ -0,0 +1,73 @@ |
|||||
|
// This file is part of the FidelityFX SDK.
|
||||
|
//
|
||||
|
// Copyright (C) 2024 Advanced Micro Devices, Inc.
|
||||
|
//
|
||||
|
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
|
// of this software and associated documentation files(the "Software"), to deal
|
||||
|
// in the Software without restriction, including without limitation the rights
|
||||
|
// to use, copy, modify, merge, publish, distribute, sublicense, and /or sell
|
||||
|
// copies of the Software, and to permit persons to whom the Software is
|
||||
|
// furnished to do so, subject to the following conditions :
|
||||
|
//
|
||||
|
// The above copyright notice and this permission notice shall be included in
|
||||
|
// all copies or substantial portions of the Software.
|
||||
|
//
|
||||
|
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
|
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
|
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
|
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
|
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
|
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
|
// THE SOFTWARE.
|
||||
|
|
||||
|
#pragma once
|
||||
|
|
||||
|
#include "ffx_api.hpp"
|
||||
|
#include "ffx_framegeneration.h"
|
||||
|
|
||||
|
// Helper types for header initialization. Api definition is in .h file.
|
||||
|
|
||||
|
namespace ffx |
||||
|
{ |
||||
|
|
||||
|
template<> |
||||
|
struct struct_type<ffxCreateContextDescFrameGeneration> : std::integral_constant<uint64_t, FFX_API_CREATE_CONTEXT_DESC_TYPE_FRAMEGENERATION> {}; |
||||
|
|
||||
|
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> {}; |
||||
|
|
||||
|
struct ConfigureDescFrameGeneration : public InitHelper<ffxConfigureDescFrameGeneration> {}; |
||||
|
|
||||
|
template<> |
||||
|
struct struct_type<ffxDispatchDescFrameGeneration> : std::integral_constant<uint64_t, FFX_API_DISPATCH_DESC_TYPE_FRAMEGENERATION> {}; |
||||
|
|
||||
|
struct DispatchDescFrameGeneration : public InitHelper<ffxDispatchDescFrameGeneration> {}; |
||||
|
|
||||
|
template<> |
||||
|
struct struct_type<ffxDispatchDescFrameGenerationPrepare> : std::integral_constant<uint64_t, FFX_API_DISPATCH_DESC_TYPE_FRAMEGENERATION_PREPARE> {}; |
||||
|
|
||||
|
struct DispatchDescFrameGenerationPrepare : public InitHelper<ffxDispatchDescFrameGenerationPrepare> {}; |
||||
|
|
||||
|
template<> |
||||
|
struct struct_type<ffxConfigureDescFrameGenerationKeyValue> : std::integral_constant<uint64_t, FFX_API_CONFIGURE_DESC_TYPE_FRAMEGENERATION_KEYVALUE> {}; |
||||
|
|
||||
|
struct ConfigureDescFrameGenerationKeyValue : public InitHelper<ffxConfigureDescFrameGenerationKeyValue> {}; |
||||
|
|
||||
|
template<> |
||||
|
struct struct_type<ffxQueryDescFrameGenerationGetGPUMemoryUsage> : std::integral_constant<uint64_t, FFX_API_QUERY_DESC_TYPE_FRAMEGENERATION_GPU_MEMORY_USAGE> {}; |
||||
|
|
||||
|
struct QueryDescFrameGenerationGetGPUMemoryUsage : public InitHelper<ffxQueryDescFrameGenerationGetGPUMemoryUsage> {}; |
||||
|
|
||||
|
template<> |
||||
|
struct struct_type<ffxConfigureDescFrameGenerationRegisterDistortionFieldResource> : std::integral_constant<uint64_t, FFX_API_CONFIGURE_DESC_TYPE_FRAMEGENERATION_REGISTERDISTORTIONRESOURCE> {}; |
||||
|
|
||||
|
struct ConfigureDescFrameGenerationRegisterDistortionFieldResource : public InitHelper<ffxConfigureDescFrameGenerationRegisterDistortionFieldResource> {}; |
||||
|
|
||||
|
} |
||||
@ -0,0 +1,184 @@ |
|||||
|
// This file is part of the FidelityFX SDK. |
||||
|
// |
||||
|
// Copyright (C) 2024 Advanced Micro Devices, Inc. |
||||
|
// |
||||
|
// Permission is hereby granted, free of charge, to any person obtaining a copy |
||||
|
// of this software and associated documentation files(the "Software"), to deal |
||||
|
// in the Software without restriction, including without limitation the rights |
||||
|
// to use, copy, modify, merge, publish, distribute, sublicense, and /or sell |
||||
|
// copies of the Software, and to permit persons to whom the Software is |
||||
|
// furnished to do so, subject to the following conditions : |
||||
|
// |
||||
|
// The above copyright notice and this permission notice shall be included in |
||||
|
// all copies or substantial portions of the Software. |
||||
|
// |
||||
|
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
||||
|
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
||||
|
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
||||
|
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
||||
|
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
||||
|
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN |
||||
|
// THE SOFTWARE. |
||||
|
|
||||
|
#pragma once |
||||
|
#include "ffx_api.h" |
||||
|
#include "ffx_api_types.h" |
||||
|
|
||||
|
#ifdef __cplusplus |
||||
|
extern "C" { |
||||
|
#endif |
||||
|
|
||||
|
enum FfxApiUpscaleQualityMode |
||||
|
{ |
||||
|
FFX_UPSCALE_QUALITY_MODE_NATIVEAA = 0, ///< Perform upscaling with a per-dimension upscaling ratio of 1.0x. |
||||
|
FFX_UPSCALE_QUALITY_MODE_QUALITY = 1, ///< Perform upscaling with a per-dimension upscaling ratio of 1.5x. |
||||
|
FFX_UPSCALE_QUALITY_MODE_BALANCED = 2, ///< Perform upscaling with a per-dimension upscaling ratio of 1.7x. |
||||
|
FFX_UPSCALE_QUALITY_MODE_PERFORMANCE = 3, ///< Perform upscaling with a per-dimension upscaling ratio of 2.0x. |
||||
|
FFX_UPSCALE_QUALITY_MODE_ULTRA_PERFORMANCE = 4 ///< Perform upscaling with a per-dimension upscaling ratio of 3.0x. |
||||
|
}; |
||||
|
|
||||
|
enum FfxApiCreateContextUpscaleFlags |
||||
|
{ |
||||
|
FFX_UPSCALE_ENABLE_HIGH_DYNAMIC_RANGE = (1<<0), ///< A bit indicating if the input color data provided is using a high-dynamic range. |
||||
|
FFX_UPSCALE_ENABLE_DISPLAY_RESOLUTION_MOTION_VECTORS = (1<<1), ///< A bit indicating if the motion vectors are rendered at display resolution. |
||||
|
FFX_UPSCALE_ENABLE_MOTION_VECTORS_JITTER_CANCELLATION = (1<<2), ///< A bit indicating that the motion vectors have the jittering pattern applied to them. |
||||
|
FFX_UPSCALE_ENABLE_DEPTH_INVERTED = (1<<3), ///< A bit indicating that the input depth buffer data provided is inverted [1..0]. |
||||
|
FFX_UPSCALE_ENABLE_DEPTH_INFINITE = (1<<4), ///< A bit indicating that the input depth buffer data provided is using an infinite far plane. |
||||
|
FFX_UPSCALE_ENABLE_AUTO_EXPOSURE = (1<<5), ///< A bit indicating if automatic exposure should be applied to input color data. |
||||
|
FFX_UPSCALE_ENABLE_DYNAMIC_RESOLUTION = (1<<6), ///< A bit indicating that the application uses dynamic resolution scaling. |
||||
|
FFX_UPSCALE_ENABLE_DEBUG_CHECKING = (1<<7), ///< A bit indicating that the runtime should check some API values and report issues. |
||||
|
FFX_UPSCALE_ENABLE_NON_LINEAR_COLORSPACE = (1<<8), ///< A bit indicating that the color resource contains perceptual (gamma corrected) colors |
||||
|
}; |
||||
|
|
||||
|
enum FfxApiDispatchFsrUpscaleFlags |
||||
|
{ |
||||
|
FFX_UPSCALE_FLAG_DRAW_DEBUG_VIEW = (1 << 0), ///< A bit indicating that the output resource will contain debug views with relevant information. |
||||
|
FFX_UPSCALE_FLAG_NON_LINEAR_COLOR_SRGB = (1 << 1), ///< A bit indicating that the input color resource contains perceptual sRGB colors |
||||
|
FFX_UPSCALE_FLAG_NON_LINEAR_COLOR_PQ = (1 << 2), ///< A bit indicating that the input color resource contains perceptual PQ colors |
||||
|
}; |
||||
|
|
||||
|
enum FfxApiDispatchUpscaleAutoreactiveFlags |
||||
|
{ |
||||
|
FFX_UPSCALE_AUTOREACTIVEFLAGS_APPLY_TONEMAP = (1<<0), |
||||
|
FFX_UPSCALE_AUTOREACTIVEFLAGS_APPLY_INVERSETONEMAP = (1<<1), |
||||
|
FFX_UPSCALE_AUTOREACTIVEFLAGS_APPLY_THRESHOLD = (1<<2), |
||||
|
FFX_UPSCALE_AUTOREACTIVEFLAGS_USE_COMPONENTS_MAX = (1<<3), |
||||
|
}; |
||||
|
|
||||
|
#define FFX_API_EFFECT_ID_UPSCALE 0x00010000u |
||||
|
|
||||
|
#define FFX_API_CREATE_CONTEXT_DESC_TYPE_UPSCALE 0x00010000u |
||||
|
struct ffxCreateContextDescUpscale |
||||
|
{ |
||||
|
ffxCreateContextDescHeader header; |
||||
|
uint32_t flags; ///< Zero or a combination of values from FfxApiCreateContextFsrFlags. |
||||
|
struct FfxApiDimensions2D maxRenderSize; ///< The maximum size that rendering will be performed at. |
||||
|
struct FfxApiDimensions2D maxUpscaleSize; ///< The size of the presentation resolution targeted by the upscaling process. |
||||
|
ffxApiMessage fpMessage; ///< A pointer to a function that can receive messages from the runtime. May be null. |
||||
|
}; |
||||
|
|
||||
|
#define FFX_API_DISPATCH_DESC_TYPE_UPSCALE 0x00010001u |
||||
|
struct ffxDispatchDescUpscale |
||||
|
{ |
||||
|
ffxDispatchDescHeader header; |
||||
|
void* commandList; ///< Command list to record upscaling rendering commands into. |
||||
|
struct FfxApiResource color; ///< Color buffer for the current frame (at render resolution). |
||||
|
struct FfxApiResource depth; ///< 32bit depth values for the current frame (at render resolution). |
||||
|
struct FfxApiResource motionVectors; ///< 2-dimensional motion vectors (at render resolution if <c><i>FFX_FSR_ENABLE_DISPLAY_RESOLUTION_MOTION_VECTORS</i></c> is not set). |
||||
|
struct FfxApiResource exposure; ///< Optional resource containing a 1x1 exposure value. |
||||
|
struct FfxApiResource reactive; ///< Optional resource containing alpha value of reactive objects in the scene. |
||||
|
struct FfxApiResource transparencyAndComposition; ///< Optional resource containing alpha value of special objects in the scene. |
||||
|
struct FfxApiResource output; ///< Output color buffer for the current frame (at presentation resolution). |
||||
|
struct FfxApiFloatCoords2D jitterOffset; ///< The subpixel jitter offset applied to the camera. |
||||
|
struct FfxApiFloatCoords2D motionVectorScale; ///< The scale factor to apply to motion vectors. |
||||
|
struct FfxApiDimensions2D renderSize; ///< The resolution that was used for rendering the input resources. |
||||
|
struct FfxApiDimensions2D upscaleSize; ///< The resolution that the upscaler will upscale to (optional, assumed maxUpscaleSize otherwise). |
||||
|
bool enableSharpening; ///< Enable an additional sharpening pass. |
||||
|
float sharpness; ///< The sharpness value between 0 and 1, where 0 is no additional sharpness and 1 is maximum additional sharpness. |
||||
|
float frameTimeDelta; ///< The time elapsed since the last frame (expressed in milliseconds). |
||||
|
float preExposure; ///< The pre exposure value (must be > 0.0f) |
||||
|
bool reset; ///< A boolean value which when set to true, indicates the camera has moved discontinuously. |
||||
|
float cameraNear; ///< The distance to the near plane of the camera. |
||||
|
float cameraFar; ///< The distance to the far plane of the camera. |
||||
|
float cameraFovAngleVertical; ///< The camera angle field of view in the vertical direction (expressed in radians). |
||||
|
float viewSpaceToMetersFactor; ///< The scale factor to convert view space units to meters |
||||
|
uint32_t flags; ///< Zero or a combination of values from FfxApiDispatchFsrUpscaleFlags. |
||||
|
}; |
||||
|
|
||||
|
#define FFX_API_QUERY_DESC_TYPE_UPSCALE_GETUPSCALERATIOFROMQUALITYMODE 0x00010002u |
||||
|
struct ffxQueryDescUpscaleGetUpscaleRatioFromQualityMode |
||||
|
{ |
||||
|
ffxQueryDescHeader header; |
||||
|
uint32_t qualityMode; ///< The desired quality mode for FSR upscaling. |
||||
|
float* pOutUpscaleRatio; ///< A pointer to a <c>float</c> which will hold the upscaling the per-dimension upscaling ratio. |
||||
|
}; |
||||
|
|
||||
|
#define FFX_API_QUERY_DESC_TYPE_UPSCALE_GETRENDERRESOLUTIONFROMQUALITYMODE 0x00010003u |
||||
|
struct ffxQueryDescUpscaleGetRenderResolutionFromQualityMode |
||||
|
{ |
||||
|
ffxQueryDescHeader header; |
||||
|
uint32_t displayWidth; ///< The target display resolution width. |
||||
|
uint32_t displayHeight; ///< The target display resolution height. |
||||
|
uint32_t qualityMode; ///< The desired quality mode for FSR upscaling. |
||||
|
uint32_t* pOutRenderWidth; ///< A pointer to a <c>uint32_t</c> which will hold the calculated render resolution width. |
||||
|
uint32_t* pOutRenderHeight; ///< A pointer to a <c>uint32_t</c> which will hold the calculated render resolution height. |
||||
|
}; |
||||
|
|
||||
|
#define FFX_API_QUERY_DESC_TYPE_UPSCALE_GETJITTERPHASECOUNT 0x00010004u |
||||
|
struct ffxQueryDescUpscaleGetJitterPhaseCount |
||||
|
{ |
||||
|
ffxQueryDescHeader header; |
||||
|
uint32_t renderWidth; ///< The render resolution width. |
||||
|
uint32_t displayWidth; ///< The output resolution width. |
||||
|
int32_t* pOutPhaseCount; ///< A pointer to a <c>int32_t</c> which will hold the jitter phase count for the scaling factor between <c><i>renderWidth</i></c> and <c><i>displayWidth</i></c>. |
||||
|
}; |
||||
|
|
||||
|
#define FFX_API_QUERY_DESC_TYPE_UPSCALE_GETJITTEROFFSET 0x00010005u |
||||
|
struct ffxQueryDescUpscaleGetJitterOffset |
||||
|
{ |
||||
|
ffxQueryDescHeader header; |
||||
|
int32_t index; ///< The index within the jitter sequence. |
||||
|
int32_t phaseCount; ///< The length of jitter phase. See <c><i>ffxQueryDescFsrGetJitterPhaseCount</i></c>. |
||||
|
float* pOutX; ///< A pointer to a <c>float</c> which will contain the subpixel jitter offset for the x dimension. |
||||
|
float* pOutY; ///< A pointer to a <c>float</c> which will contain the subpixel jitter offset for the y dimension. |
||||
|
}; |
||||
|
|
||||
|
#define FFX_API_DISPATCH_DESC_TYPE_UPSCALE_GENERATEREACTIVEMASK 0x00010006u |
||||
|
struct ffxDispatchDescUpscaleGenerateReactiveMask |
||||
|
{ |
||||
|
ffxDispatchDescHeader header; |
||||
|
void* commandList; ///< The <c><i>FfxCommandList</i></c> to record FSRUPSCALE rendering commands into. |
||||
|
struct FfxApiResource colorOpaqueOnly; ///< A <c><i>FfxResource</i></c> containing the opaque only color buffer for the current frame (at render resolution). |
||||
|
struct FfxApiResource colorPreUpscale; ///< A <c><i>FfxResource</i></c> containing the opaque+translucent color buffer for the current frame (at render resolution). |
||||
|
struct FfxApiResource outReactive; ///< A <c><i>FfxResource</i></c> containing the surface to generate the reactive mask into. |
||||
|
struct FfxApiDimensions2D renderSize; ///< The resolution that was used for rendering the input resources. |
||||
|
float scale; ///< A value to scale the output |
||||
|
float cutoffThreshold; ///< A threshold value to generate a binary reactive mask |
||||
|
float binaryValue; ///< A value to set for the binary reactive mask |
||||
|
uint32_t flags; ///< Flags to determine how to generate the reactive mask |
||||
|
}; |
||||
|
|
||||
|
#define FFX_API_CONFIGURE_DESC_TYPE_UPSCALE_KEYVALUE 0x00010007u |
||||
|
struct ffxConfigureDescUpscaleKeyValue |
||||
|
{ |
||||
|
ffxConfigureDescHeader header; |
||||
|
uint64_t key; ///< Configuration key, member of the FfxApiConfigureUpscaleKey enumeration. |
||||
|
uint64_t u64; ///< Integer value or enum value to set. |
||||
|
void* ptr; ///< Pointer to set or pointer to value to set. |
||||
|
}; |
||||
|
|
||||
|
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]. |
||||
|
}; |
||||
|
|
||||
|
#define FFX_API_QUERY_DESC_TYPE_UPSCALE_GPU_MEMORY_USAGE 0x00010008u |
||||
|
struct ffxQueryDescUpscaleGetGPUMemoryUsage |
||||
|
{ |
||||
|
ffxQueryDescHeader header; |
||||
|
struct FfxApiEffectMemoryUsage* gpuMemoryUsageUpscaler; |
||||
|
}; |
||||
|
|
||||
|
#ifdef __cplusplus |
||||
|
} |
||||
|
#endif |
||||
@ -0,0 +1,78 @@ |
|||||
|
// This file is part of the FidelityFX SDK.
|
||||
|
//
|
||||
|
// Copyright (C) 2024 Advanced Micro Devices, Inc.
|
||||
|
//
|
||||
|
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
|
// of this software and associated documentation files(the "Software"), to deal
|
||||
|
// in the Software without restriction, including without limitation the rights
|
||||
|
// to use, copy, modify, merge, publish, distribute, sublicense, and /or sell
|
||||
|
// copies of the Software, and to permit persons to whom the Software is
|
||||
|
// furnished to do so, subject to the following conditions :
|
||||
|
//
|
||||
|
// The above copyright notice and this permission notice shall be included in
|
||||
|
// all copies or substantial portions of the Software.
|
||||
|
//
|
||||
|
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
|
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
|
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
|
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
|
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
|
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
|
// THE SOFTWARE.
|
||||
|
|
||||
|
#pragma once
|
||||
|
|
||||
|
#include "ffx_api.hpp"
|
||||
|
#include "ffx_upscale.h"
|
||||
|
|
||||
|
// Helper types for header initialization. Api definition is in .h file.
|
||||
|
|
||||
|
namespace ffx |
||||
|
{ |
||||
|
|
||||
|
template<> |
||||
|
struct struct_type<ffxCreateContextDescUpscale> : std::integral_constant<uint64_t, FFX_API_CREATE_CONTEXT_DESC_TYPE_UPSCALE> {}; |
||||
|
|
||||
|
struct CreateContextDescUpscale : public InitHelper<ffxCreateContextDescUpscale> {}; |
||||
|
|
||||
|
template<> |
||||
|
struct struct_type<ffxDispatchDescUpscale> : std::integral_constant<uint64_t, FFX_API_DISPATCH_DESC_TYPE_UPSCALE> {}; |
||||
|
|
||||
|
struct DispatchDescUpscale : public InitHelper<ffxDispatchDescUpscale> {}; |
||||
|
|
||||
|
template<> |
||||
|
struct struct_type<ffxQueryDescUpscaleGetUpscaleRatioFromQualityMode> : std::integral_constant<uint64_t, FFX_API_QUERY_DESC_TYPE_UPSCALE_GETUPSCALERATIOFROMQUALITYMODE> {}; |
||||
|
|
||||
|
struct QueryDescUpscaleGetUpscaleRatioFromQualityMode : public InitHelper<ffxQueryDescUpscaleGetUpscaleRatioFromQualityMode> {}; |
||||
|
|
||||
|
template<> |
||||
|
struct struct_type<ffxQueryDescUpscaleGetRenderResolutionFromQualityMode> : std::integral_constant<uint64_t, FFX_API_QUERY_DESC_TYPE_UPSCALE_GETRENDERRESOLUTIONFROMQUALITYMODE> {}; |
||||
|
|
||||
|
struct QueryDescUpscaleGetRenderResolutionFromQualityMode : public InitHelper<ffxQueryDescUpscaleGetRenderResolutionFromQualityMode> {}; |
||||
|
|
||||
|
template<> |
||||
|
struct struct_type<ffxQueryDescUpscaleGetJitterPhaseCount> : std::integral_constant<uint64_t, FFX_API_QUERY_DESC_TYPE_UPSCALE_GETJITTERPHASECOUNT> {}; |
||||
|
|
||||
|
struct QueryDescUpscaleGetJitterPhaseCount : public InitHelper<ffxQueryDescUpscaleGetJitterPhaseCount> {}; |
||||
|
|
||||
|
template<> |
||||
|
struct struct_type<ffxQueryDescUpscaleGetJitterOffset> : std::integral_constant<uint64_t, FFX_API_QUERY_DESC_TYPE_UPSCALE_GETJITTEROFFSET> {}; |
||||
|
|
||||
|
struct QueryDescUpscaleGetJitterOffset : public InitHelper<ffxQueryDescUpscaleGetJitterOffset> {}; |
||||
|
|
||||
|
template<> |
||||
|
struct struct_type<ffxDispatchDescUpscaleGenerateReactiveMask> : std::integral_constant<uint64_t, FFX_API_DISPATCH_DESC_TYPE_UPSCALE_GENERATEREACTIVEMASK> {}; |
||||
|
|
||||
|
struct DispatchDescUpscaleGenerateReactiveMask : public InitHelper<ffxDispatchDescUpscaleGenerateReactiveMask> {}; |
||||
|
|
||||
|
template<> |
||||
|
struct struct_type<ffxConfigureDescUpscaleKeyValue> : std::integral_constant<uint64_t, FFX_API_CONFIGURE_DESC_TYPE_UPSCALE_KEYVALUE> {}; |
||||
|
|
||||
|
struct ConfigureDescUpscaleKeyValue : public InitHelper<ffxConfigureDescUpscaleKeyValue> {}; |
||||
|
|
||||
|
template<> |
||||
|
struct struct_type<ffxQueryDescUpscaleGetGPUMemoryUsage> : std::integral_constant<uint64_t, FFX_API_QUERY_DESC_TYPE_UPSCALE_GPU_MEMORY_USAGE> {}; |
||||
|
|
||||
|
struct QueryDescUpscaleGetGPUMemoryUsage : public InitHelper<ffxQueryDescUpscaleGetGPUMemoryUsage> {}; |
||||
|
|
||||
|
} |
||||
@ -0,0 +1,360 @@ |
|||||
|
// This file is part of the FidelityFX SDK. |
||||
|
// |
||||
|
// Copyright (C) 2024 Advanced Micro Devices, Inc. |
||||
|
// |
||||
|
// Permission is hereby granted, free of charge, to any person obtaining a copy |
||||
|
// of this software and associated documentation files(the "Software"), to deal |
||||
|
// in the Software without restriction, including without limitation the rights |
||||
|
// to use, copy, modify, merge, publish, distribute, sublicense, and /or sell |
||||
|
// copies of the Software, and to permit persons to whom the Software is |
||||
|
// furnished to do so, subject to the following conditions : |
||||
|
// |
||||
|
// The above copyright notice and this permission notice shall be included in |
||||
|
// all copies or substantial portions of the Software. |
||||
|
// |
||||
|
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
||||
|
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
||||
|
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
||||
|
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
||||
|
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
||||
|
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN |
||||
|
// THE SOFTWARE. |
||||
|
|
||||
|
#pragma once |
||||
|
#include "../ffx_api.h" |
||||
|
#include "../ffx_api_types.h" |
||||
|
#include <vulkan/vulkan.h> |
||||
|
|
||||
|
/// FFX specific callback type when submitting a command buffer to a queue. |
||||
|
typedef VkResult (*PFN_vkQueueSubmitFFXAPI)(uint32_t submitCount, const VkSubmitInfo* pSubmits, VkFence fence); |
||||
|
|
||||
|
/// Helper stucture |
||||
|
struct VkQueueInfoFFXAPI |
||||
|
{ |
||||
|
VkQueue queue; ///< the vulkan queue |
||||
|
uint32_t familyIndex; ///< the queue family index, that will be used to perform queue family ownership transfer |
||||
|
PFN_vkQueueSubmitFFXAPI submitFunc; ///< an optional submit function in case there might be some concurrent submissions |
||||
|
}; |
||||
|
|
||||
|
#define FFX_API_CREATE_CONTEXT_DESC_TYPE_BACKEND_VK 0x0000003u |
||||
|
struct ffxCreateBackendVKDesc |
||||
|
{ |
||||
|
ffxCreateContextDescHeader header; |
||||
|
VkDevice vkDevice; ///< the logical device used by the program. |
||||
|
VkPhysicalDevice vkPhysicalDevice; ///< the physical device used by the program. |
||||
|
PFN_vkGetDeviceProcAddr vkDeviceProcAddr; ///< function pointer to get device procedure addresses |
||||
|
}; |
||||
|
|
||||
|
#define FFX_API_EFFECT_ID_FGSC_VK 0x00040000u |
||||
|
|
||||
|
#define FFX_API_CREATE_CONTEXT_DESC_TYPE_FGSWAPCHAIN_VK 0x40001u |
||||
|
struct ffxCreateContextDescFrameGenerationSwapChainVK |
||||
|
{ |
||||
|
ffxCreateContextDescHeader header; |
||||
|
VkPhysicalDevice physicalDevice; ///< the physicak device used by the program. |
||||
|
VkDevice device; ///< the logical device used by the program. |
||||
|
VkSwapchainKHR* swapchain; ///< the current swapchain to be replaced. Will be destroyed when the context is created. This can be VK_NULL_HANDLE. Will contain the new swapchain on return. |
||||
|
VkAllocationCallbacks* allocator; ///< optional allocation callbacks. |
||||
|
VkSwapchainCreateInfoKHR createInfo; ///< the description of the desired swapchain. If its VkSwapchainCreateInfoKHR::oldSwapchain field isn't VK_NULL_HANDLE, it should be the same as the ffxCreateContextDescFrameGenerationSwapChainVK::swapchain field above. |
||||
|
VkQueueInfoFFXAPI gameQueue; ///< the main graphics queue, where Present is called. |
||||
|
VkQueueInfoFFXAPI asyncComputeQueue; ///< A queue with Compute capability. |
||||
|
VkQueueInfoFFXAPI presentQueue; ///< A queue with Transfer and Present capabilities. |
||||
|
VkQueueInfoFFXAPI imageAcquireQueue; ///< A queue with no capability required. |
||||
|
}; |
||||
|
|
||||
|
#define FFX_API_CONFIGURE_DESC_TYPE_FGSWAPCHAIN_REGISTERUIRESOURCE_VK 0x40002u |
||||
|
struct ffxConfigureDescFrameGenerationSwapChainRegisterUiResourceVK |
||||
|
{ |
||||
|
ffxConfigureDescHeader header; |
||||
|
struct FfxApiResource uiResource; ///< Resource containing user interface for composition. May be empty. |
||||
|
uint32_t flags; ///< Zero or combination of values from FfxApiUiCompositionFlags. |
||||
|
}; |
||||
|
|
||||
|
#define FFX_API_QUERY_DESC_TYPE_FGSWAPCHAIN_INTERPOLATIONCOMMANDLIST_VK 0x40003u |
||||
|
struct ffxQueryDescFrameGenerationSwapChainInterpolationCommandListVK |
||||
|
{ |
||||
|
ffxQueryDescHeader header; |
||||
|
void** pOutCommandList; ///< Output command nuffer (VkCommandBuffer) to be used for frame generation dispatch. |
||||
|
}; |
||||
|
|
||||
|
#define FFX_API_QUERY_DESC_TYPE_FGSWAPCHAIN_INTERPOLATIONTEXTURE_VK 0x40004u |
||||
|
struct ffxQueryDescFrameGenerationSwapChainInterpolationTextureVK |
||||
|
{ |
||||
|
ffxQueryDescHeader header; |
||||
|
struct FfxApiResource* pOutTexture; ///< Output resource in which the frame interpolation result should be placed. |
||||
|
}; |
||||
|
|
||||
|
#define FFX_API_DISPATCH_DESC_TYPE_FGSWAPCHAIN_WAIT_FOR_PRESENTS_VK 0x40007u |
||||
|
struct ffxDispatchDescFrameGenerationSwapChainWaitForPresentsVK |
||||
|
{ |
||||
|
ffxDispatchDescHeader header; |
||||
|
}; |
||||
|
|
||||
|
#define FFX_API_CONFIGURE_DESC_TYPE_FRAMEGENERATIONSWAPCHAIN_KEYVALUE_VK 0x40008u |
||||
|
struct ffxConfigureDescFrameGenerationSwapChainKeyValueVK |
||||
|
{ |
||||
|
ffxConfigureDescHeader header; |
||||
|
uint64_t key; ///< Configuration key, member of the FfxApiConfigureFrameGenerationSwapChainKeyVK enumeration. |
||||
|
uint64_t u64; ///< Integer value or enum value to set. |
||||
|
void* ptr; ///< Pointer to set or pointer to value to set. |
||||
|
}; |
||||
|
|
||||
|
//enum value matches enum FfxFrameInterpolationSwapchainConfigureKey |
||||
|
enum FfxApiConfigureFrameGenerationSwapChainKeyVK |
||||
|
{ |
||||
|
FFX_API_CONFIGURE_FG_SWAPCHAIN_KEY_WAITCALLBACK = 0, ///< Sets FfxWaitCallbackFunc |
||||
|
FFX_API_CONFIGURE_FG_SWAPCHAIN_KEY_FRAMEPACINGTUNING = 2, ///< Sets FfxApiSwapchainFramePacingTuning casted from ptr |
||||
|
}; |
||||
|
|
||||
|
#define FFX_API_QUERY_DESC_TYPE_FRAMEGENERATIONSWAPCHAIN_GPU_MEMORY_USAGE_VK 0x00040009u |
||||
|
struct ffxQueryFrameGenerationSwapChainGetGPUMemoryUsageVK |
||||
|
{ |
||||
|
ffxQueryDescHeader header; |
||||
|
struct FfxApiEffectMemoryUsage* gpuMemoryUsageFrameGenerationSwapchain; |
||||
|
}; |
||||
|
|
||||
|
/// Function to get the number of presents. This is useful when using frame interpolation |
||||
|
typedef uint64_t (*PFN_getLastPresentCountFFXAPI)(VkSwapchainKHR); |
||||
|
|
||||
|
/// FFX API specific functions to create and destroy a swapchain |
||||
|
typedef VkResult(*PFN_vkCreateSwapchainFFXAPI)(VkDevice device, const VkSwapchainCreateInfoKHR* pCreateInfo, const VkAllocationCallbacks* pAllocator, VkSwapchainKHR* pSwapchain, void* pContext); |
||||
|
typedef void(*PFN_vkDestroySwapchainFFXAPI)(VkDevice device, VkSwapchainKHR swapchain, const VkAllocationCallbacks* pAllocator, void* pContext); |
||||
|
|
||||
|
#define FFX_API_QUERY_DESC_TYPE_FGSWAPCHAIN_FUNCTIONS_VK 0x40005u |
||||
|
struct ffxQueryDescSwapchainReplacementFunctionsVK |
||||
|
{ |
||||
|
ffxQueryDescHeader header; |
||||
|
PFN_vkCreateSwapchainFFXAPI pOutCreateSwapchainFFXAPI; ///< Replacement of vkCreateSwapchainKHR. Can be called when swapchain is recreated but swapchain context isn't (for example when toggling vsync). |
||||
|
PFN_vkDestroySwapchainFFXAPI pOutDestroySwapchainFFXAPI; ///< Replacement of vkDestroySwapchainKHR. Can be called when swapchain is destroyed but swapchain context isn't. |
||||
|
PFN_vkGetSwapchainImagesKHR pOutGetSwapchainImagesKHR; ///< Replacement of vkGetSwapchainImagesKHR. |
||||
|
PFN_vkAcquireNextImageKHR pOutAcquireNextImageKHR; ///< Replacement of vkAcquireNextImageKHR. |
||||
|
PFN_vkQueuePresentKHR pOutQueuePresentKHR; ///< Replacement of vkQueuePresentKHR. |
||||
|
PFN_vkSetHdrMetadataEXT pOutSetHdrMetadataEXT; ///< Replacement of vkSetHdrMetadataEXT. |
||||
|
PFN_getLastPresentCountFFXAPI pOutGetLastPresentCountFFXAPI; ///< Additional function to get the number of times present has been called since the swapchain creation. |
||||
|
}; |
||||
|
|
||||
|
#define FFX_API_CREATE_CONTEXT_DESC_TYPE_FGSWAPCHAIN_MODE_VK 0x40010u |
||||
|
struct ffxCreateContextDescFrameGenerationSwapChainModeVK |
||||
|
{ |
||||
|
ffxCreateContextDescHeader header; |
||||
|
bool composeOnPresentQueue; ///< flags indicating that composition will happen on the present queue |
||||
|
}; |
||||
|
|
||||
|
static inline uint32_t ffxApiGetSurfaceFormatVK(VkFormat fmt) |
||||
|
{ |
||||
|
switch (fmt) |
||||
|
{ |
||||
|
case VK_FORMAT_R32G32B32A32_SFLOAT: |
||||
|
return FFX_API_SURFACE_FORMAT_R32G32B32A32_FLOAT; |
||||
|
case VK_FORMAT_R32G32B32_SFLOAT: |
||||
|
return FFX_API_SURFACE_FORMAT_R32G32B32_FLOAT; |
||||
|
case VK_FORMAT_R32G32B32A32_UINT: |
||||
|
return FFX_API_SURFACE_FORMAT_R32G32B32A32_UINT; |
||||
|
case VK_FORMAT_R16G16B16A16_SFLOAT: |
||||
|
return FFX_API_SURFACE_FORMAT_R16G16B16A16_FLOAT; |
||||
|
case VK_FORMAT_R32G32_SFLOAT: |
||||
|
return FFX_API_SURFACE_FORMAT_R32G32_FLOAT; |
||||
|
case VK_FORMAT_R32_UINT: |
||||
|
case VK_FORMAT_D24_UNORM_S8_UINT: |
||||
|
case VK_FORMAT_X8_D24_UNORM_PACK32: |
||||
|
return FFX_API_SURFACE_FORMAT_R32_UINT; |
||||
|
case VK_FORMAT_R8G8B8A8_UNORM: |
||||
|
return FFX_API_SURFACE_FORMAT_R8G8B8A8_UNORM; |
||||
|
case VK_FORMAT_R8G8B8A8_SNORM: |
||||
|
return FFX_API_SURFACE_FORMAT_R8G8B8A8_SNORM; |
||||
|
case VK_FORMAT_R8G8B8A8_SRGB: |
||||
|
return FFX_API_SURFACE_FORMAT_R8G8B8A8_SRGB; |
||||
|
case VK_FORMAT_B8G8R8A8_UNORM: |
||||
|
return FFX_API_SURFACE_FORMAT_B8G8R8A8_UNORM; |
||||
|
case VK_FORMAT_B8G8R8A8_SRGB: |
||||
|
return FFX_API_SURFACE_FORMAT_B8G8R8A8_SRGB; |
||||
|
case VK_FORMAT_B10G11R11_UFLOAT_PACK32: |
||||
|
return FFX_API_SURFACE_FORMAT_R11G11B10_FLOAT; |
||||
|
case VK_FORMAT_A2B10G10R10_UNORM_PACK32: |
||||
|
return FFX_API_SURFACE_FORMAT_R10G10B10A2_UNORM; |
||||
|
case VK_FORMAT_R16G16_SFLOAT: |
||||
|
return FFX_API_SURFACE_FORMAT_R16G16_FLOAT; |
||||
|
case VK_FORMAT_R16G16_UINT: |
||||
|
return FFX_API_SURFACE_FORMAT_R16G16_UINT; |
||||
|
case VK_FORMAT_R16G16_SINT: |
||||
|
return FFX_API_SURFACE_FORMAT_R16G16_SINT; |
||||
|
case VK_FORMAT_R16_SFLOAT: |
||||
|
return FFX_API_SURFACE_FORMAT_R16_FLOAT; |
||||
|
case VK_FORMAT_R16_UINT: |
||||
|
return FFX_API_SURFACE_FORMAT_R16_UINT; |
||||
|
case VK_FORMAT_R16_UNORM: |
||||
|
case VK_FORMAT_D16_UNORM: |
||||
|
case VK_FORMAT_D16_UNORM_S8_UINT: |
||||
|
return FFX_API_SURFACE_FORMAT_R16_UNORM; |
||||
|
case VK_FORMAT_R16_SNORM: |
||||
|
return FFX_API_SURFACE_FORMAT_R16_SNORM; |
||||
|
case VK_FORMAT_R8_UNORM: |
||||
|
return FFX_API_SURFACE_FORMAT_R8_UNORM; |
||||
|
case VK_FORMAT_R8_UINT: |
||||
|
case VK_FORMAT_S8_UINT: |
||||
|
return FFX_API_SURFACE_FORMAT_R8_UINT; |
||||
|
case VK_FORMAT_R8G8_UNORM: |
||||
|
return FFX_API_SURFACE_FORMAT_R8G8_UNORM; |
||||
|
case VK_FORMAT_R8G8_UINT: |
||||
|
return FFX_API_SURFACE_FORMAT_R8G8_UINT; |
||||
|
case VK_FORMAT_R32_SFLOAT: |
||||
|
case VK_FORMAT_D32_SFLOAT: |
||||
|
case VK_FORMAT_D32_SFLOAT_S8_UINT: |
||||
|
return FFX_API_SURFACE_FORMAT_R32_FLOAT; |
||||
|
case VK_FORMAT_E5B9G9R9_UFLOAT_PACK32: |
||||
|
return FFX_API_SURFACE_FORMAT_R9G9B9E5_SHAREDEXP; |
||||
|
case VK_FORMAT_UNDEFINED: |
||||
|
return FFX_API_SURFACE_FORMAT_UNKNOWN; |
||||
|
|
||||
|
default: |
||||
|
// NOTE: we do not support typeless formats here |
||||
|
//FFX_ASSERT_MESSAGE(false, "Format not yet supported"); |
||||
|
return FFX_API_SURFACE_FORMAT_UNKNOWN; |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
static inline uint32_t ffxApiGetSurfaceFormatToGamma(uint32_t fmt) |
||||
|
{ |
||||
|
switch (fmt) |
||||
|
{ |
||||
|
case (FFX_API_SURFACE_FORMAT_R8G8B8A8_UNORM): |
||||
|
return FFX_API_SURFACE_FORMAT_R8G8B8A8_SRGB; |
||||
|
case (FFX_API_SURFACE_FORMAT_B8G8R8A8_UNORM): |
||||
|
return FFX_API_SURFACE_FORMAT_B8G8R8A8_SRGB; |
||||
|
default: |
||||
|
return fmt; |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
static inline bool ffxApiIsDepthFormat(VkFormat fmt) |
||||
|
{ |
||||
|
switch (fmt) |
||||
|
{ |
||||
|
case VK_FORMAT_D16_UNORM: |
||||
|
case VK_FORMAT_X8_D24_UNORM_PACK32: |
||||
|
case VK_FORMAT_D32_SFLOAT: |
||||
|
case VK_FORMAT_D16_UNORM_S8_UINT: |
||||
|
case VK_FORMAT_D24_UNORM_S8_UINT: |
||||
|
case VK_FORMAT_D32_SFLOAT_S8_UINT: |
||||
|
return true; |
||||
|
|
||||
|
default: |
||||
|
return false; |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
static inline bool ffxApiIsStencilFormat(VkFormat fmt) |
||||
|
{ |
||||
|
switch (fmt) |
||||
|
{ |
||||
|
case VK_FORMAT_S8_UINT: |
||||
|
case VK_FORMAT_D16_UNORM_S8_UINT: |
||||
|
case VK_FORMAT_D24_UNORM_S8_UINT: |
||||
|
case VK_FORMAT_D32_SFLOAT_S8_UINT: |
||||
|
return true; |
||||
|
|
||||
|
default: |
||||
|
return false; |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
static inline FfxApiResourceDescription ffxApiGetBufferResourceDescriptionVK(const VkBuffer buffer, |
||||
|
const VkBufferCreateInfo createInfo, |
||||
|
uint32_t additionalUsages) |
||||
|
{ |
||||
|
FfxApiResourceDescription resourceDescription = {}; |
||||
|
|
||||
|
// This is valid |
||||
|
if (buffer == VK_NULL_HANDLE) |
||||
|
return resourceDescription; |
||||
|
|
||||
|
resourceDescription.flags = FFX_API_RESOURCE_FLAGS_NONE; |
||||
|
resourceDescription.usage = additionalUsages; |
||||
|
resourceDescription.size = (uint32_t)createInfo.size; |
||||
|
resourceDescription.stride = 0; |
||||
|
resourceDescription.format = FFX_API_SURFACE_FORMAT_UNKNOWN; |
||||
|
|
||||
|
if ((createInfo.usage & VK_BUFFER_USAGE_STORAGE_BUFFER_BIT) != 0) |
||||
|
resourceDescription.usage |= FFX_API_RESOURCE_USAGE_UAV; |
||||
|
if ((createInfo.usage & VK_BUFFER_USAGE_INDIRECT_BUFFER_BIT) != 0) |
||||
|
resourceDescription.usage |= FFX_API_RESOURCE_USAGE_INDIRECT; |
||||
|
|
||||
|
// What should we initialize this to?? No case for this yet |
||||
|
resourceDescription.depth = 0; |
||||
|
resourceDescription.mipCount = 0; |
||||
|
|
||||
|
// Set the type |
||||
|
resourceDescription.type = FFX_API_RESOURCE_TYPE_BUFFER; |
||||
|
|
||||
|
return resourceDescription; |
||||
|
} |
||||
|
|
||||
|
static inline FfxApiResourceDescription ffxApiGetImageResourceDescriptionVK(const VkImage image, const VkImageCreateInfo createInfo, uint32_t additionalUsages) |
||||
|
{ |
||||
|
FfxApiResourceDescription resourceDescription = {}; |
||||
|
|
||||
|
// This is valid |
||||
|
if (image == VK_NULL_HANDLE) |
||||
|
return resourceDescription; |
||||
|
|
||||
|
// Set flags properly for resource registration |
||||
|
resourceDescription.flags = FFX_API_RESOURCE_FLAGS_NONE; |
||||
|
resourceDescription.usage = FFX_API_RESOURCE_USAGE_READ_ONLY; |
||||
|
|
||||
|
// Check for depth stencil use |
||||
|
if (ffxApiIsDepthFormat(createInfo.format)) |
||||
|
resourceDescription.usage |= FFX_API_RESOURCE_USAGE_DEPTHTARGET; |
||||
|
if (ffxApiIsStencilFormat(createInfo.format)) |
||||
|
resourceDescription.usage |= FFX_API_RESOURCE_USAGE_STENCILTARGET; |
||||
|
|
||||
|
// Unordered access use |
||||
|
if ((createInfo.usage & VK_IMAGE_USAGE_STORAGE_BIT) != 0) |
||||
|
resourceDescription.usage |= FFX_API_RESOURCE_USAGE_UAV; |
||||
|
|
||||
|
// Resource-specific supplemental use flags |
||||
|
resourceDescription.usage |= additionalUsages; |
||||
|
|
||||
|
resourceDescription.width = createInfo.extent.width; |
||||
|
resourceDescription.height = createInfo.extent.height; |
||||
|
resourceDescription.mipCount = createInfo.mipLevels; |
||||
|
resourceDescription.format = ffxApiGetSurfaceFormatVK(createInfo.format); |
||||
|
|
||||
|
// if the mutable flag is present, assume that the real format is sRGB |
||||
|
if ((createInfo.flags & VK_IMAGE_CREATE_MUTABLE_FORMAT_BIT) != 0) |
||||
|
resourceDescription.format = ffxApiGetSurfaceFormatToGamma(resourceDescription.format); |
||||
|
|
||||
|
switch (createInfo.imageType) |
||||
|
{ |
||||
|
case VK_IMAGE_TYPE_1D: |
||||
|
resourceDescription.type = FFX_API_RESOURCE_TYPE_TEXTURE1D; |
||||
|
break; |
||||
|
case VK_IMAGE_TYPE_2D: |
||||
|
resourceDescription.depth = createInfo.arrayLayers; |
||||
|
if ((additionalUsages & FFX_API_RESOURCE_USAGE_ARRAYVIEW) != 0) |
||||
|
resourceDescription.type = FFX_API_RESOURCE_TYPE_TEXTURE2D; |
||||
|
else if ((createInfo.flags & VK_IMAGE_CREATE_CUBE_COMPATIBLE_BIT) != 0) |
||||
|
resourceDescription.type = FFX_API_RESOURCE_TYPE_TEXTURE_CUBE; |
||||
|
else |
||||
|
resourceDescription.type = FFX_API_RESOURCE_TYPE_TEXTURE2D; |
||||
|
break; |
||||
|
case VK_IMAGE_TYPE_3D: |
||||
|
resourceDescription.depth = createInfo.extent.depth; |
||||
|
resourceDescription.type = FFX_API_RESOURCE_TYPE_TEXTURE3D; |
||||
|
break; |
||||
|
default: |
||||
|
//FFX_ASSERT_MESSAGE(false, "FFXInterface: VK: Unsupported texture dimension requested. Please implement."); |
||||
|
break; |
||||
|
} |
||||
|
|
||||
|
return resourceDescription; |
||||
|
} |
||||
|
|
||||
|
static inline FfxApiResource ffxApiGetResourceVK(void* vkResource, FfxApiResourceDescription ffxResDescription, uint32_t state) |
||||
|
{ |
||||
|
FfxApiResource resource = {}; |
||||
|
resource.resource = vkResource; |
||||
|
resource.state = state; |
||||
|
resource.description = ffxResDescription; |
||||
|
|
||||
|
return resource; |
||||
|
} |
||||
@ -0,0 +1,83 @@ |
|||||
|
// This file is part of the FidelityFX SDK.
|
||||
|
//
|
||||
|
// Copyright (C) 2024 Advanced Micro Devices, Inc.
|
||||
|
//
|
||||
|
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
|
// of this software and associated documentation files(the "Software"), to deal
|
||||
|
// in the Software without restriction, including without limitation the rights
|
||||
|
// to use, copy, modify, merge, publish, distribute, sublicense, and /or sell
|
||||
|
// copies of the Software, and to permit persons to whom the Software is
|
||||
|
// furnished to do so, subject to the following conditions :
|
||||
|
//
|
||||
|
// The above copyright notice and this permission notice shall be included in
|
||||
|
// all copies or substantial portions of the Software.
|
||||
|
//
|
||||
|
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
|
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
|
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
|
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
|
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
|
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
|
// THE SOFTWARE.
|
||||
|
|
||||
|
#pragma once
|
||||
|
|
||||
|
#include "../ffx_api.hpp"
|
||||
|
#include "ffx_api_vk.h"
|
||||
|
|
||||
|
// Helper types for header initialization. Api definition is in .h file.
|
||||
|
|
||||
|
namespace ffx |
||||
|
{ |
||||
|
|
||||
|
template<> |
||||
|
struct struct_type<ffxCreateBackendVKDesc> : std::integral_constant<uint64_t, FFX_API_CREATE_CONTEXT_DESC_TYPE_BACKEND_VK> {}; |
||||
|
|
||||
|
struct CreateBackendVKDesc : public InitHelper<ffxCreateBackendVKDesc> {}; |
||||
|
|
||||
|
template<> |
||||
|
struct struct_type<ffxCreateContextDescFrameGenerationSwapChainVK> : std::integral_constant<uint64_t, FFX_API_CREATE_CONTEXT_DESC_TYPE_FGSWAPCHAIN_VK> {}; |
||||
|
|
||||
|
struct CreateContextDescFrameGenerationSwapChainVK : public InitHelper<ffxCreateContextDescFrameGenerationSwapChainVK> {}; |
||||
|
|
||||
|
template<> |
||||
|
struct struct_type<ffxCreateContextDescFrameGenerationSwapChainModeVK> : std::integral_constant<uint64_t, FFX_API_CREATE_CONTEXT_DESC_TYPE_FGSWAPCHAIN_MODE_VK> {}; |
||||
|
|
||||
|
struct CreateContextDescFrameGenerationSwapChainModeVK : public InitHelper<ffxCreateContextDescFrameGenerationSwapChainModeVK> {}; |
||||
|
|
||||
|
template<> |
||||
|
struct struct_type<ffxConfigureDescFrameGenerationSwapChainRegisterUiResourceVK> : std::integral_constant<uint64_t, FFX_API_CONFIGURE_DESC_TYPE_FGSWAPCHAIN_REGISTERUIRESOURCE_VK> {}; |
||||
|
|
||||
|
struct ConfigureDescFrameGenerationSwapChainRegisterUiResourceVK : public InitHelper<ffxConfigureDescFrameGenerationSwapChainRegisterUiResourceVK> {}; |
||||
|
|
||||
|
template<> |
||||
|
struct struct_type<ffxQueryDescFrameGenerationSwapChainInterpolationCommandListVK> : std::integral_constant<uint64_t, FFX_API_QUERY_DESC_TYPE_FGSWAPCHAIN_INTERPOLATIONCOMMANDLIST_VK> {}; |
||||
|
|
||||
|
struct QueryDescFrameGenerationSwapChainInterpolationCommandListVK : public InitHelper<ffxQueryDescFrameGenerationSwapChainInterpolationCommandListVK> {}; |
||||
|
|
||||
|
template<> |
||||
|
struct struct_type<ffxQueryDescFrameGenerationSwapChainInterpolationTextureVK> : std::integral_constant<uint64_t, FFX_API_QUERY_DESC_TYPE_FGSWAPCHAIN_INTERPOLATIONTEXTURE_VK> {}; |
||||
|
|
||||
|
struct QueryDescFrameGenerationSwapChainInterpolationTextureVK : public InitHelper<ffxQueryDescFrameGenerationSwapChainInterpolationTextureVK> {}; |
||||
|
|
||||
|
template<> |
||||
|
struct struct_type<ffxQueryDescSwapchainReplacementFunctionsVK> : std::integral_constant<uint64_t, FFX_API_QUERY_DESC_TYPE_FGSWAPCHAIN_FUNCTIONS_VK> {}; |
||||
|
|
||||
|
struct QueryDescSwapchainReplacementFunctionsVK : public InitHelper<ffxQueryDescSwapchainReplacementFunctionsVK> {}; |
||||
|
|
||||
|
template <> |
||||
|
struct struct_type<ffxDispatchDescFrameGenerationSwapChainWaitForPresentsVK> : std::integral_constant<uint64_t, FFX_API_DISPATCH_DESC_TYPE_FGSWAPCHAIN_WAIT_FOR_PRESENTS_VK>{}; |
||||
|
|
||||
|
struct DispatchDescFrameGenerationSwapChainWaitForPresentsVK : public InitHelper<ffxDispatchDescFrameGenerationSwapChainWaitForPresentsVK>{}; |
||||
|
|
||||
|
template<> |
||||
|
struct struct_type<ffxConfigureDescFrameGenerationSwapChainKeyValueVK> : std::integral_constant<uint64_t, FFX_API_CONFIGURE_DESC_TYPE_FRAMEGENERATIONSWAPCHAIN_KEYVALUE_VK> {}; |
||||
|
|
||||
|
struct ConfigureDescFrameGenerationSwapChainKeyValueVK : public InitHelper<ffxConfigureDescFrameGenerationSwapChainKeyValueVK> {}; |
||||
|
|
||||
|
template<> |
||||
|
struct struct_type<ffxQueryFrameGenerationSwapChainGetGPUMemoryUsageVK> : std::integral_constant<uint64_t, FFX_API_QUERY_DESC_TYPE_FRAMEGENERATIONSWAPCHAIN_GPU_MEMORY_USAGE_VK> {}; |
||||
|
|
||||
|
struct QueryFrameGenerationSwapChainGetGPUMemoryUsageVK : public InitHelper<ffxQueryFrameGenerationSwapChainGetGPUMemoryUsageVK> {}; |
||||
|
|
||||
|
} |
||||
Write
Preview
Loading…
Cancel
Save
Reference in new issue