mirror of
https://github.com/valentderah/totk-pc-recomp.git
synced 2026-11-24 21:55:57 +00:00
FidelityFX SDK 1.1.4 frame interpolation and optical flow built into totk.exe behind frame_gen, contexts created and destroyed only, no frame-path change
The SDK subset, its compat header and the SPIR-V shader header come from Savage Wind (MIT); tools/ffx_shaders.py regenerates the header with glslangValidator, build_game.py compiles the SDK sources with ffx_compat.h force-included, and runtime/vk_fg.cpp makes the backend, optical flow and frame interpolation contexts after the device exists when frame_gen = 1 (default 0, read at start). Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Co-Authored-By: Revivedx <82332536+Revivedx@users.noreply.github.com>
This commit is contained in:
1 parent
25a53e5ef2
commit
4e48669c86
114 files changed
+46877
-6
No files matched your search
@@ -0,0 +1,46 @@
|
||||
// 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>
|
||||
#include <FidelityFX/host/ffx_interface.h>
|
||||
|
||||
#if defined(__cplusplus)
|
||||
extern "C" {
|
||||
#endif // #if defined(__cplusplus)
|
||||
|
||||
struct FfxShaderBlob;
|
||||
|
||||
// Get a shader blob for the specified effect, pass, and permutation index.
|
||||
FfxErrorCode ffxGetPermutationBlobByIndex(FfxEffect effectId,
|
||||
FfxPass passId,
|
||||
FfxBindStage bindStage,
|
||||
uint32_t permutationOptions,
|
||||
FfxShaderBlob* outBlob);
|
||||
|
||||
// Check is Wave64 is requested on this permutation
|
||||
FfxErrorCode ffxIsWave64(FfxEffect effectId, uint32_t permutationOptions, bool& isWave64);
|
||||
|
||||
#if defined(__cplusplus)
|
||||
}
|
||||
#endif // #if defined(__cplusplus)
|
||||
File diff suppressed because it is too large.
Load diff
+75
@@ -0,0 +1,75 @@
|
||||
// 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.
|
||||
|
||||
#version 450
|
||||
|
||||
#extension GL_GOOGLE_include_directive : require
|
||||
#extension GL_EXT_samplerless_texture_functions : require
|
||||
|
||||
#define FFX_FRAMEINTERPOLATION_BIND_SRV_GAME_MOTION_VECTOR_FIELD_X 0
|
||||
#define FFX_FRAMEINTERPOLATION_BIND_SRV_GAME_MOTION_VECTOR_FIELD_Y 1
|
||||
|
||||
#define FFX_FRAMEINTERPOLATION_BIND_UAV_COUNTERS 2
|
||||
#define FFX_FRAMEINTERPOLATION_BIND_UAV_INPAINTING_PYRAMID_MIPMAP_0 3
|
||||
#define FFX_FRAMEINTERPOLATION_BIND_UAV_INPAINTING_PYRAMID_MIPMAP_1 4
|
||||
#define FFX_FRAMEINTERPOLATION_BIND_UAV_INPAINTING_PYRAMID_MIPMAP_2 5
|
||||
#define FFX_FRAMEINTERPOLATION_BIND_UAV_INPAINTING_PYRAMID_MIPMAP_3 6
|
||||
#define FFX_FRAMEINTERPOLATION_BIND_UAV_INPAINTING_PYRAMID_MIPMAP_4 7
|
||||
#define FFX_FRAMEINTERPOLATION_BIND_UAV_INPAINTING_PYRAMID_MIPMAP_5 8
|
||||
#define FFX_FRAMEINTERPOLATION_BIND_UAV_INPAINTING_PYRAMID_MIPMAP_6 9
|
||||
#define FFX_FRAMEINTERPOLATION_BIND_UAV_INPAINTING_PYRAMID_MIPMAP_7 10
|
||||
#define FFX_FRAMEINTERPOLATION_BIND_UAV_INPAINTING_PYRAMID_MIPMAP_8 11
|
||||
#define FFX_FRAMEINTERPOLATION_BIND_UAV_INPAINTING_PYRAMID_MIPMAP_9 12
|
||||
#define FFX_FRAMEINTERPOLATION_BIND_UAV_INPAINTING_PYRAMID_MIPMAP_10 13
|
||||
#define FFX_FRAMEINTERPOLATION_BIND_UAV_INPAINTING_PYRAMID_MIPMAP_11 14
|
||||
#define FFX_FRAMEINTERPOLATION_BIND_UAV_INPAINTING_PYRAMID_MIPMAP_12 15
|
||||
|
||||
#define FFX_FRAMEINTERPOLATION_BIND_CB_FRAMEINTERPOLATION 16
|
||||
#define FFX_FRAMEINTERPOLATION_BIND_CB_INPAINTING_PYRAMID 17
|
||||
|
||||
#ifdef FFX_HALF
|
||||
#undef FFX_HALF
|
||||
#define FFX_HALF 0
|
||||
#endif
|
||||
|
||||
#include "frameinterpolation/ffx_frameinterpolation_callbacks_glsl.h"
|
||||
#include "frameinterpolation/ffx_frameinterpolation_common.h"
|
||||
#include "frameinterpolation/ffx_frameinterpolation_compute_game_vector_field_inpainting_pyramid.h"
|
||||
|
||||
#ifndef FFX_FRAMEINTERPOLATION_THREAD_GROUP_WIDTH
|
||||
#define FFX_FRAMEINTERPOLATION_THREAD_GROUP_WIDTH 256
|
||||
#endif // #ifndef FFX_FRAMEINTERPOLATION_THREAD_GROUP_WIDTH
|
||||
#ifndef FFX_FRAMEINTERPOLATION_THREAD_GROUP_HEIGHT
|
||||
#define FFX_FRAMEINTERPOLATION_THREAD_GROUP_HEIGHT 1
|
||||
#endif // #ifndef FFX_FRAMEINTERPOLATION_THREAD_GROUP_HEIGHT
|
||||
#ifndef FFX_FRAMEINTERPOLATION_THREAD_GROUP_DEPTH
|
||||
#define FFX_FRAMEINTERPOLATION_THREAD_GROUP_DEPTH 1
|
||||
#endif // #ifndef FFX_FRAMEINTERPOLATION_THREAD_GROUP_DEPTH
|
||||
#ifndef FFX_FRAMEINTERPOLATION_NUM_THREADS
|
||||
#define FFX_FRAMEINTERPOLATION_NUM_THREADS layout (local_size_x = FFX_FRAMEINTERPOLATION_THREAD_GROUP_WIDTH, local_size_y = FFX_FRAMEINTERPOLATION_THREAD_GROUP_HEIGHT, local_size_z = FFX_FRAMEINTERPOLATION_THREAD_GROUP_DEPTH) in;
|
||||
#endif // #ifndef FFX_FRAMEINTERPOLATION_NUM_THREADS
|
||||
|
||||
FFX_FRAMEINTERPOLATION_NUM_THREADS
|
||||
void main()
|
||||
{
|
||||
computeFrameinterpolationGameVectorFieldInpaintingPyramid(FfxInt32x3(gl_WorkGroupID), FfxInt32(gl_LocalInvocationIndex));
|
||||
}
|
||||
+74
@@ -0,0 +1,74 @@
|
||||
// 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.
|
||||
|
||||
#version 450
|
||||
|
||||
#extension GL_GOOGLE_include_directive : require
|
||||
#extension GL_EXT_samplerless_texture_functions : require
|
||||
|
||||
#define FFX_FRAMEINTERPOLATION_BIND_SRV_OUTPUT 0
|
||||
|
||||
#define FFX_FRAMEINTERPOLATION_BIND_UAV_COUNTERS 1
|
||||
#define FFX_FRAMEINTERPOLATION_BIND_UAV_INPAINTING_PYRAMID_MIPMAP_0 2
|
||||
#define FFX_FRAMEINTERPOLATION_BIND_UAV_INPAINTING_PYRAMID_MIPMAP_1 3
|
||||
#define FFX_FRAMEINTERPOLATION_BIND_UAV_INPAINTING_PYRAMID_MIPMAP_2 4
|
||||
#define FFX_FRAMEINTERPOLATION_BIND_UAV_INPAINTING_PYRAMID_MIPMAP_3 5
|
||||
#define FFX_FRAMEINTERPOLATION_BIND_UAV_INPAINTING_PYRAMID_MIPMAP_4 6
|
||||
#define FFX_FRAMEINTERPOLATION_BIND_UAV_INPAINTING_PYRAMID_MIPMAP_5 7
|
||||
#define FFX_FRAMEINTERPOLATION_BIND_UAV_INPAINTING_PYRAMID_MIPMAP_6 8
|
||||
#define FFX_FRAMEINTERPOLATION_BIND_UAV_INPAINTING_PYRAMID_MIPMAP_7 9
|
||||
#define FFX_FRAMEINTERPOLATION_BIND_UAV_INPAINTING_PYRAMID_MIPMAP_8 10
|
||||
#define FFX_FRAMEINTERPOLATION_BIND_UAV_INPAINTING_PYRAMID_MIPMAP_9 11
|
||||
#define FFX_FRAMEINTERPOLATION_BIND_UAV_INPAINTING_PYRAMID_MIPMAP_10 12
|
||||
#define FFX_FRAMEINTERPOLATION_BIND_UAV_INPAINTING_PYRAMID_MIPMAP_11 13
|
||||
#define FFX_FRAMEINTERPOLATION_BIND_UAV_INPAINTING_PYRAMID_MIPMAP_12 14
|
||||
|
||||
#define FFX_FRAMEINTERPOLATION_BIND_CB_FRAMEINTERPOLATION 15
|
||||
#define FFX_FRAMEINTERPOLATION_BIND_CB_INPAINTING_PYRAMID 16
|
||||
|
||||
#ifdef FFX_HALF
|
||||
#undef FFX_HALF
|
||||
#define FFX_HALF 0
|
||||
#endif
|
||||
|
||||
#include "frameinterpolation/ffx_frameinterpolation_callbacks_glsl.h"
|
||||
#include "frameinterpolation/ffx_frameinterpolation_common.h"
|
||||
#include "frameinterpolation/ffx_frameinterpolation_compute_inpainting_pyramid.h"
|
||||
|
||||
#ifndef FFX_FRAMEINTERPOLATION_THREAD_GROUP_WIDTH
|
||||
#define FFX_FRAMEINTERPOLATION_THREAD_GROUP_WIDTH 256
|
||||
#endif // #ifndef FFX_FRAMEINTERPOLATION_THREAD_GROUP_WIDTH
|
||||
#ifndef FFX_FRAMEINTERPOLATION_THREAD_GROUP_HEIGHT
|
||||
#define FFX_FRAMEINTERPOLATION_THREAD_GROUP_HEIGHT 1
|
||||
#endif // #ifndef FFX_FRAMEINTERPOLATION_THREAD_GROUP_HEIGHT
|
||||
#ifndef FFX_FRAMEINTERPOLATION_THREAD_GROUP_DEPTH
|
||||
#define FFX_FRAMEINTERPOLATION_THREAD_GROUP_DEPTH 1
|
||||
#endif // #ifndef FFX_FRAMEINTERPOLATION_THREAD_GROUP_DEPTH
|
||||
#ifndef FFX_FRAMEINTERPOLATION_NUM_THREADS
|
||||
#define FFX_FRAMEINTERPOLATION_NUM_THREADS layout (local_size_x = FFX_FRAMEINTERPOLATION_THREAD_GROUP_WIDTH, local_size_y = FFX_FRAMEINTERPOLATION_THREAD_GROUP_HEIGHT, local_size_z = FFX_FRAMEINTERPOLATION_THREAD_GROUP_DEPTH) in;
|
||||
#endif // #ifndef FFX_FRAMEINTERPOLATION_NUM_THREADS
|
||||
|
||||
FFX_FRAMEINTERPOLATION_NUM_THREADS
|
||||
void main()
|
||||
{
|
||||
computeFrameinterpolationInpaintingPyramid(FfxInt32x3(gl_WorkGroupID), FfxInt32(gl_LocalInvocationIndex));
|
||||
}
|
||||
+65
@@ -0,0 +1,65 @@
|
||||
// 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.
|
||||
|
||||
#version 450
|
||||
|
||||
#extension GL_GOOGLE_include_directive : require
|
||||
#extension GL_EXT_samplerless_texture_functions : require
|
||||
// Needed for rw_output declaration
|
||||
#extension GL_EXT_shader_image_load_formatted : require
|
||||
|
||||
#define FFX_FRAMEINTERPOLATION_BIND_SRV_GAME_MOTION_VECTOR_FIELD_X 0
|
||||
#define FFX_FRAMEINTERPOLATION_BIND_SRV_GAME_MOTION_VECTOR_FIELD_Y 1
|
||||
#define FFX_FRAMEINTERPOLATION_BIND_SRV_OPTICAL_FLOW_MOTION_VECTOR_FIELD_X 2
|
||||
#define FFX_FRAMEINTERPOLATION_BIND_SRV_OPTICAL_FLOW_MOTION_VECTOR_FIELD_Y 3
|
||||
#define FFX_FRAMEINTERPOLATION_BIND_SRV_DISOCCLUSION_MASK 4
|
||||
#define FFX_FRAMEINTERPOLATION_BIND_SRV_PRESENT_BACKBUFFER 5
|
||||
#define FFX_FRAMEINTERPOLATION_BIND_SRV_INPAINTING_PYRAMID 6
|
||||
#define FFX_FRAMEINTERPOLATION_BIND_SRV_CURRENT_INTERPOLATION_SOURCE 7
|
||||
#define FFX_FRAMEINTERPOLATION_BIND_SRV_DISTORTION_FIELD 8
|
||||
|
||||
#define FFX_FRAMEINTERPOLATION_BIND_UAV_OUTPUT 9
|
||||
|
||||
#define FFX_FRAMEINTERPOLATION_BIND_CB_FRAMEINTERPOLATION 10
|
||||
|
||||
#include "frameinterpolation/ffx_frameinterpolation_callbacks_glsl.h"
|
||||
#include "frameinterpolation/ffx_frameinterpolation_common.h"
|
||||
#include "frameinterpolation/ffx_frameinterpolation_debug_view.h"
|
||||
|
||||
#ifndef FFX_FRAMEINTERPOLATION_THREAD_GROUP_WIDTH
|
||||
#define FFX_FRAMEINTERPOLATION_THREAD_GROUP_WIDTH 8
|
||||
#endif // #ifndef FFX_FRAMEINTERPOLATION_THREAD_GROUP_WIDTH
|
||||
#ifndef FFX_FRAMEINTERPOLATION_THREAD_GROUP_HEIGHT
|
||||
#define FFX_FRAMEINTERPOLATION_THREAD_GROUP_HEIGHT 8
|
||||
#endif // #ifndef FFX_FRAMEINTERPOLATION_THREAD_GROUP_HEIGHT
|
||||
#ifndef FFX_FRAMEINTERPOLATION_THREAD_GROUP_DEPTH
|
||||
#define FFX_FRAMEINTERPOLATION_THREAD_GROUP_DEPTH 1
|
||||
#endif // #ifndef FFX_FRAMEINTERPOLATION_THREAD_GROUP_DEPTH
|
||||
#ifndef FFX_FRAMEINTERPOLATION_NUM_THREADS
|
||||
#define FFX_FRAMEINTERPOLATION_NUM_THREADS layout (local_size_x = FFX_FRAMEINTERPOLATION_THREAD_GROUP_WIDTH, local_size_y = FFX_FRAMEINTERPOLATION_THREAD_GROUP_HEIGHT, local_size_z = FFX_FRAMEINTERPOLATION_THREAD_GROUP_DEPTH) in;
|
||||
#endif // #ifndef FFX_FRAMEINTERPOLATION_NUM_THREADS
|
||||
|
||||
FFX_FRAMEINTERPOLATION_NUM_THREADS
|
||||
void main()
|
||||
{
|
||||
computeDebugView(FfxInt32x2(gl_GlobalInvocationID.xy));
|
||||
}
|
||||
+61
@@ -0,0 +1,61 @@
|
||||
// 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.
|
||||
|
||||
#version 450
|
||||
|
||||
#extension GL_GOOGLE_include_directive : require
|
||||
#extension GL_EXT_samplerless_texture_functions : require
|
||||
|
||||
#define FFX_FRAMEINTERPOLATION_BIND_SRV_GAME_MOTION_VECTOR_FIELD_X 0
|
||||
#define FFX_FRAMEINTERPOLATION_BIND_SRV_GAME_MOTION_VECTOR_FIELD_Y 1
|
||||
#define FFX_FRAMEINTERPOLATION_BIND_SRV_RECONSTRUCTED_DEPTH_PREVIOUS_FRAME 2
|
||||
#define FFX_FRAMEINTERPOLATION_BIND_SRV_DILATED_DEPTH 3
|
||||
#define FFX_FRAMEINTERPOLATION_BIND_SRV_RECONSTRUCTED_DEPTH_INTERPOLATED_FRAME 4
|
||||
#define FFX_FRAMEINTERPOLATION_BIND_SRV_INPAINTING_PYRAMID 5
|
||||
#define FFX_FRAMEINTERPOLATION_BIND_SRV_DISTORTION_FIELD 6
|
||||
|
||||
#define FFX_FRAMEINTERPOLATION_BIND_UAV_DISOCCLUSION_MASK 7
|
||||
|
||||
#define FFX_FRAMEINTERPOLATION_BIND_CB_FRAMEINTERPOLATION 8
|
||||
|
||||
#include "frameinterpolation/ffx_frameinterpolation_callbacks_glsl.h"
|
||||
#include "frameinterpolation/ffx_frameinterpolation_common.h"
|
||||
#include "frameinterpolation/ffx_frameinterpolation_disocclusion_mask.h"
|
||||
|
||||
#ifndef FFX_FRAMEINTERPOLATION_THREAD_GROUP_WIDTH
|
||||
#define FFX_FRAMEINTERPOLATION_THREAD_GROUP_WIDTH 8
|
||||
#endif // #ifndef FFX_FRAMEINTERPOLATION_THREAD_GROUP_WIDTH
|
||||
#ifndef FFX_FRAMEINTERPOLATION_THREAD_GROUP_HEIGHT
|
||||
#define FFX_FRAMEINTERPOLATION_THREAD_GROUP_HEIGHT 8
|
||||
#endif // #ifndef FFX_FRAMEINTERPOLATION_THREAD_GROUP_HEIGHT
|
||||
#ifndef FFX_FRAMEINTERPOLATION_THREAD_GROUP_DEPTH
|
||||
#define FFX_FRAMEINTERPOLATION_THREAD_GROUP_DEPTH 1
|
||||
#endif // #ifndef FFX_FRAMEINTERPOLATION_THREAD_GROUP_DEPTH
|
||||
#ifndef FFX_FRAMEINTERPOLATION_NUM_THREADS
|
||||
#define FFX_FRAMEINTERPOLATION_NUM_THREADS layout (local_size_x = FFX_FRAMEINTERPOLATION_THREAD_GROUP_WIDTH, local_size_y = FFX_FRAMEINTERPOLATION_THREAD_GROUP_HEIGHT, local_size_z = FFX_FRAMEINTERPOLATION_THREAD_GROUP_DEPTH) in;
|
||||
#endif // #ifndef FFX_FRAMEINTERPOLATION_NUM_THREADS
|
||||
|
||||
FFX_FRAMEINTERPOLATION_NUM_THREADS
|
||||
void main()
|
||||
{
|
||||
computeDisocclusionMask(FfxInt32x2(gl_GlobalInvocationID.xy));
|
||||
}
|
||||
+60
@@ -0,0 +1,60 @@
|
||||
// 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.
|
||||
|
||||
#version 450
|
||||
|
||||
#extension GL_GOOGLE_include_directive : require
|
||||
#extension GL_EXT_samplerless_texture_functions : require
|
||||
|
||||
#define FFX_FRAMEINTERPOLATION_BIND_SRV_DILATED_MOTION_VECTORS 0
|
||||
#define FFX_FRAMEINTERPOLATION_BIND_SRV_DILATED_DEPTH 1
|
||||
#define FFX_FRAMEINTERPOLATION_BIND_SRV_PREVIOUS_INTERPOLATION_SOURCE 2
|
||||
#define FFX_FRAMEINTERPOLATION_BIND_SRV_CURRENT_INTERPOLATION_SOURCE 3
|
||||
#define FFX_FRAMEINTERPOLATION_BIND_SRV_DISTORTION_FIELD 4
|
||||
|
||||
#define FFX_FRAMEINTERPOLATION_BIND_UAV_GAME_MOTION_VECTOR_FIELD_X 5
|
||||
#define FFX_FRAMEINTERPOLATION_BIND_UAV_GAME_MOTION_VECTOR_FIELD_Y 6
|
||||
|
||||
#define FFX_FRAMEINTERPOLATION_BIND_CB_FRAMEINTERPOLATION 7
|
||||
|
||||
#include "frameinterpolation/ffx_frameinterpolation_callbacks_glsl.h"
|
||||
#include "frameinterpolation/ffx_frameinterpolation_common.h"
|
||||
#include "frameinterpolation/ffx_frameinterpolation_game_motion_vector_field.h"
|
||||
|
||||
#ifndef FFX_FRAMEINTERPOLATION_THREAD_GROUP_WIDTH
|
||||
#define FFX_FRAMEINTERPOLATION_THREAD_GROUP_WIDTH 8
|
||||
#endif // #ifndef FFX_FRAMEINTERPOLATION_THREAD_GROUP_WIDTH
|
||||
#ifndef FFX_FRAMEINTERPOLATION_THREAD_GROUP_HEIGHT
|
||||
#define FFX_FRAMEINTERPOLATION_THREAD_GROUP_HEIGHT 8
|
||||
#endif // #ifndef FFX_FRAMEINTERPOLATION_THREAD_GROUP_HEIGHT
|
||||
#ifndef FFX_FRAMEINTERPOLATION_THREAD_GROUP_DEPTH
|
||||
#define FFX_FRAMEINTERPOLATION_THREAD_GROUP_DEPTH 1
|
||||
#endif // #ifndef FFX_FRAMEINTERPOLATION_THREAD_GROUP_DEPTH
|
||||
#ifndef FFX_FRAMEINTERPOLATION_NUM_THREADS
|
||||
#define FFX_FRAMEINTERPOLATION_NUM_THREADS layout (local_size_x = FFX_FRAMEINTERPOLATION_THREAD_GROUP_WIDTH, local_size_y = FFX_FRAMEINTERPOLATION_THREAD_GROUP_HEIGHT, local_size_z = FFX_FRAMEINTERPOLATION_THREAD_GROUP_DEPTH) in;
|
||||
#endif // #ifndef FFX_FRAMEINTERPOLATION_NUM_THREADS
|
||||
|
||||
FFX_FRAMEINTERPOLATION_NUM_THREADS
|
||||
void main()
|
||||
{
|
||||
computeGameFieldMvs(FfxInt32x2(gl_GlobalInvocationID.xy));
|
||||
}
|
||||
+60
@@ -0,0 +1,60 @@
|
||||
// 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.
|
||||
|
||||
#version 450
|
||||
|
||||
#extension GL_GOOGLE_include_directive : require
|
||||
#extension GL_EXT_samplerless_texture_functions : require
|
||||
// Needed for rw_output declaration
|
||||
#extension GL_EXT_shader_image_load_formatted : require
|
||||
|
||||
#define FFX_FRAMEINTERPOLATION_BIND_SRV_OPTICAL_FLOW_SCENE_CHANGE_DETECTION 0
|
||||
#define FFX_FRAMEINTERPOLATION_BIND_SRV_INPAINTING_PYRAMID 1
|
||||
#define FFX_FRAMEINTERPOLATION_BIND_SRV_PRESENT_BACKBUFFER 2
|
||||
#define FFX_FRAMEINTERPOLATION_BIND_SRV_CURRENT_INTERPOLATION_SOURCE 3
|
||||
|
||||
#define FFX_FRAMEINTERPOLATION_BIND_UAV_OUTPUT 7
|
||||
|
||||
#define FFX_FRAMEINTERPOLATION_BIND_CB_FRAMEINTERPOLATION 8
|
||||
|
||||
#include "frameinterpolation/ffx_frameinterpolation_callbacks_glsl.h"
|
||||
#include "frameinterpolation/ffx_frameinterpolation_common.h"
|
||||
#include "frameinterpolation/ffx_frameinterpolation_inpainting.h"
|
||||
|
||||
#ifndef FFX_FRAMEINTERPOLATION_THREAD_GROUP_WIDTH
|
||||
#define FFX_FRAMEINTERPOLATION_THREAD_GROUP_WIDTH 8
|
||||
#endif // #ifndef FFX_FRAMEINTERPOLATION_THREAD_GROUP_WIDTH
|
||||
#ifndef FFX_FRAMEINTERPOLATION_THREAD_GROUP_HEIGHT
|
||||
#define FFX_FRAMEINTERPOLATION_THREAD_GROUP_HEIGHT 8
|
||||
#endif // #ifndef FFX_FRAMEINTERPOLATION_THREAD_GROUP_HEIGHT
|
||||
#ifndef FFX_FRAMEINTERPOLATION_THREAD_GROUP_DEPTH
|
||||
#define FFX_FRAMEINTERPOLATION_THREAD_GROUP_DEPTH 1
|
||||
#endif // #ifndef FFX_FRAMEINTERPOLATION_THREAD_GROUP_DEPTH
|
||||
#ifndef FFX_FRAMEINTERPOLATION_NUM_THREADS
|
||||
#define FFX_FRAMEINTERPOLATION_NUM_THREADS layout (local_size_x = FFX_FRAMEINTERPOLATION_THREAD_GROUP_WIDTH, local_size_y = FFX_FRAMEINTERPOLATION_THREAD_GROUP_HEIGHT, local_size_z = FFX_FRAMEINTERPOLATION_THREAD_GROUP_DEPTH) in;
|
||||
#endif // #ifndef FFX_FRAMEINTERPOLATION_NUM_THREADS
|
||||
|
||||
FFX_FRAMEINTERPOLATION_NUM_THREADS
|
||||
void main()
|
||||
{
|
||||
computeInpainting(FfxInt32x2(gl_GlobalInvocationID.xy));
|
||||
}
|
||||
+60
@@ -0,0 +1,60 @@
|
||||
// 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.
|
||||
|
||||
#version 450
|
||||
|
||||
#extension GL_GOOGLE_include_directive : require
|
||||
#extension GL_EXT_samplerless_texture_functions : require
|
||||
|
||||
#define FFX_FRAMEINTERPOLATION_BIND_SRV_OPTICAL_FLOW 0
|
||||
#define FFX_FRAMEINTERPOLATION_BIND_SRV_OPTICAL_FLOW_CONFIDENCE 1
|
||||
#define FFX_FRAMEINTERPOLATION_BIND_SRV_DILATED_DEPTH 2
|
||||
#define FFX_FRAMEINTERPOLATION_BIND_SRV_PREVIOUS_INTERPOLATION_SOURCE 3
|
||||
#define FFX_FRAMEINTERPOLATION_BIND_SRV_CURRENT_INTERPOLATION_SOURCE 4
|
||||
|
||||
#define FFX_FRAMEINTERPOLATION_BIND_UAV_OPTICAL_FLOW_MOTION_VECTOR_FIELD_X 6
|
||||
#define FFX_FRAMEINTERPOLATION_BIND_UAV_OPTICAL_FLOW_MOTION_VECTOR_FIELD_Y 7
|
||||
|
||||
#define FFX_FRAMEINTERPOLATION_BIND_CB_FRAMEINTERPOLATION 8
|
||||
|
||||
#include "frameinterpolation/ffx_frameinterpolation_callbacks_glsl.h"
|
||||
#include "frameinterpolation/ffx_frameinterpolation_common.h"
|
||||
#include "frameinterpolation/ffx_frameinterpolation_optical_flow_vector_field.h"
|
||||
|
||||
#ifndef FFX_FRAMEINTERPOLATION_THREAD_GROUP_WIDTH
|
||||
#define FFX_FRAMEINTERPOLATION_THREAD_GROUP_WIDTH 8
|
||||
#endif // #ifndef FFX_FRAMEINTERPOLATION_THREAD_GROUP_WIDTH
|
||||
#ifndef FFX_FRAMEINTERPOLATION_THREAD_GROUP_HEIGHT
|
||||
#define FFX_FRAMEINTERPOLATION_THREAD_GROUP_HEIGHT 8
|
||||
#endif // #ifndef FFX_FRAMEINTERPOLATION_THREAD_GROUP_HEIGHT
|
||||
#ifndef FFX_FRAMEINTERPOLATION_THREAD_GROUP_DEPTH
|
||||
#define FFX_FRAMEINTERPOLATION_THREAD_GROUP_DEPTH 1
|
||||
#endif // #ifndef FFX_FRAMEINTERPOLATION_THREAD_GROUP_DEPTH
|
||||
#ifndef FFX_FRAMEINTERPOLATION_NUM_THREADS
|
||||
#define FFX_FRAMEINTERPOLATION_NUM_THREADS layout (local_size_x = FFX_FRAMEINTERPOLATION_THREAD_GROUP_WIDTH, local_size_y = FFX_FRAMEINTERPOLATION_THREAD_GROUP_HEIGHT, local_size_z = FFX_FRAMEINTERPOLATION_THREAD_GROUP_DEPTH) in;
|
||||
#endif // #ifndef FFX_FRAMEINTERPOLATION_NUM_THREADS
|
||||
|
||||
FFX_FRAMEINTERPOLATION_NUM_THREADS
|
||||
void main()
|
||||
{
|
||||
computeOpticalFlowVectorField(FfxInt32x2(gl_GlobalInvocationID.xy));
|
||||
}
|
||||
+65
@@ -0,0 +1,65 @@
|
||||
// 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.
|
||||
|
||||
#version 450
|
||||
|
||||
#extension GL_GOOGLE_include_directive : require
|
||||
#extension GL_EXT_samplerless_texture_functions : require
|
||||
// Needed for rw_output declaration
|
||||
#extension GL_EXT_shader_image_load_formatted : require
|
||||
|
||||
#define FFX_FRAMEINTERPOLATION_BIND_SRV_GAME_MOTION_VECTOR_FIELD_X 0
|
||||
#define FFX_FRAMEINTERPOLATION_BIND_SRV_GAME_MOTION_VECTOR_FIELD_Y 1
|
||||
#define FFX_FRAMEINTERPOLATION_BIND_SRV_OPTICAL_FLOW_MOTION_VECTOR_FIELD_X 2
|
||||
#define FFX_FRAMEINTERPOLATION_BIND_SRV_OPTICAL_FLOW_MOTION_VECTOR_FIELD_Y 3
|
||||
#define FFX_FRAMEINTERPOLATION_BIND_SRV_PREVIOUS_INTERPOLATION_SOURCE 4
|
||||
#define FFX_FRAMEINTERPOLATION_BIND_SRV_CURRENT_INTERPOLATION_SOURCE 5
|
||||
#define FFX_FRAMEINTERPOLATION_BIND_SRV_DISOCCLUSION_MASK 6
|
||||
#define FFX_FRAMEINTERPOLATION_BIND_SRV_INPAINTING_PYRAMID 7
|
||||
#define FFX_FRAMEINTERPOLATION_BIND_SRV_COUNTERS 8
|
||||
|
||||
#define FFX_FRAMEINTERPOLATION_BIND_UAV_OUTPUT 9
|
||||
|
||||
#define FFX_FRAMEINTERPOLATION_BIND_CB_FRAMEINTERPOLATION 10
|
||||
|
||||
#include "frameinterpolation/ffx_frameinterpolation_callbacks_glsl.h"
|
||||
#include "frameinterpolation/ffx_frameinterpolation_common.h"
|
||||
#include "frameinterpolation/ffx_frameinterpolation.h"
|
||||
|
||||
#ifndef FFX_FRAMEINTERPOLATION_THREAD_GROUP_WIDTH
|
||||
#define FFX_FRAMEINTERPOLATION_THREAD_GROUP_WIDTH 8
|
||||
#endif // #ifndef FFX_FRAMEINTERPOLATION_THREAD_GROUP_WIDTH
|
||||
#ifndef FFX_FRAMEINTERPOLATION_THREAD_GROUP_HEIGHT
|
||||
#define FFX_FRAMEINTERPOLATION_THREAD_GROUP_HEIGHT 8
|
||||
#endif // #ifndef FFX_FRAMEINTERPOLATION_THREAD_GROUP_HEIGHT
|
||||
#ifndef FFX_FRAMEINTERPOLATION_THREAD_GROUP_DEPTH
|
||||
#define FFX_FRAMEINTERPOLATION_THREAD_GROUP_DEPTH 1
|
||||
#endif // #ifndef FFX_FRAMEINTERPOLATION_THREAD_GROUP_DEPTH
|
||||
#ifndef FFX_FRAMEINTERPOLATION_NUM_THREADS
|
||||
#define FFX_FRAMEINTERPOLATION_NUM_THREADS layout (local_size_x = FFX_FRAMEINTERPOLATION_THREAD_GROUP_WIDTH, local_size_y = FFX_FRAMEINTERPOLATION_THREAD_GROUP_HEIGHT, local_size_z = FFX_FRAMEINTERPOLATION_THREAD_GROUP_DEPTH) in;
|
||||
#endif // #ifndef FFX_FRAMEINTERPOLATION_NUM_THREADS
|
||||
|
||||
FFX_FRAMEINTERPOLATION_NUM_THREADS
|
||||
void main()
|
||||
{
|
||||
computeFrameinterpolation(ivec2(gl_GlobalInvocationID.xy));
|
||||
}
|
||||
+58
@@ -0,0 +1,58 @@
|
||||
// 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.
|
||||
|
||||
#version 450
|
||||
|
||||
#extension GL_GOOGLE_include_directive : require
|
||||
#extension GL_EXT_samplerless_texture_functions : require
|
||||
|
||||
#define FFX_FRAMEINTERPOLATION_BIND_SRV_INPUT_MOTION_VECTORS 0
|
||||
#define FFX_FRAMEINTERPOLATION_BIND_SRV_INPUT_DEPTH 1
|
||||
|
||||
#define FFX_FRAMEINTERPOLATION_BIND_UAV_RECONSTRUCTED_DEPTH_PREVIOUS_FRAME 2
|
||||
#define FFX_FRAMEINTERPOLATION_BIND_UAV_DILATED_MOTION_VECTORS 3
|
||||
#define FFX_FRAMEINTERPOLATION_BIND_UAV_DILATED_DEPTH 4
|
||||
|
||||
#define FFX_FRAMEINTERPOLATION_BIND_CB_FRAMEINTERPOLATION 5
|
||||
|
||||
#include "frameinterpolation/ffx_frameinterpolation_callbacks_glsl.h"
|
||||
#include "frameinterpolation/ffx_frameinterpolation_common.h"
|
||||
#include "frameinterpolation/ffx_frameinterpolation_reconstruct_dilated_velocity_and_previous_depth.h"
|
||||
|
||||
#ifndef FFX_FRAMEINTERPOLATION_THREAD_GROUP_WIDTH
|
||||
#define FFX_FRAMEINTERPOLATION_THREAD_GROUP_WIDTH 8
|
||||
#endif // #ifndef FFX_FSR3UPSCALER_THREAD_GROUP_WIDTH
|
||||
#ifndef FFX_FRAMEINTERPOLATION_THREAD_GROUP_HEIGHT
|
||||
#define FFX_FRAMEINTERPOLATION_THREAD_GROUP_HEIGHT 8
|
||||
#endif // #ifndef FFX_FSR3UPSCALER_THREAD_GROUP_HEIGHT
|
||||
#ifndef FFX_FRAMEINTERPOLATION_THREAD_GROUP_DEPTH
|
||||
#define FFX_FRAMEINTERPOLATION_THREAD_GROUP_DEPTH 1
|
||||
#endif // #ifndef FFX_FSR3UPSCALER_THREAD_GROUP_DEPTH
|
||||
#ifndef FFX_FRAMEINTERPOLATION_NUM_THREADS
|
||||
#define FFX_FRAMEINTERPOLATION_NUM_THREADS layout (local_size_x = FFX_FRAMEINTERPOLATION_THREAD_GROUP_WIDTH, local_size_y = FFX_FRAMEINTERPOLATION_THREAD_GROUP_HEIGHT, local_size_z = FFX_FRAMEINTERPOLATION_THREAD_GROUP_DEPTH) in;
|
||||
#endif // #ifndef FFX_FSR3UPSCALER_NUM_THREADS
|
||||
|
||||
FFX_FRAMEINTERPOLATION_NUM_THREADS
|
||||
void main()
|
||||
{
|
||||
ReconstructAndDilate(FfxInt32x2(gl_GlobalInvocationID.xy));
|
||||
}
|
||||
+58
@@ -0,0 +1,58 @@
|
||||
// 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.
|
||||
|
||||
#version 450
|
||||
|
||||
#extension GL_GOOGLE_include_directive : require
|
||||
#extension GL_EXT_samplerless_texture_functions : require
|
||||
|
||||
#define FFX_FRAMEINTERPOLATION_BIND_SRV_DILATED_MOTION_VECTORS 0
|
||||
#define FFX_FRAMEINTERPOLATION_BIND_SRV_DILATED_DEPTH 1
|
||||
#define FFX_FRAMEINTERPOLATION_BIND_SRV_CURRENT_INTERPOLATION_SOURCE 2
|
||||
#define FFX_FRAMEINTERPOLATION_BIND_SRV_DISTORTION_FIELD 3
|
||||
|
||||
#define FFX_FRAMEINTERPOLATION_BIND_UAV_RECONSTRUCTED_DEPTH_INTERPOLATED_FRAME 4
|
||||
|
||||
#define FFX_FRAMEINTERPOLATION_BIND_CB_FRAMEINTERPOLATION 5
|
||||
|
||||
#include "frameinterpolation/ffx_frameinterpolation_callbacks_glsl.h"
|
||||
#include "frameinterpolation/ffx_frameinterpolation_common.h"
|
||||
#include "frameinterpolation/ffx_frameinterpolation_reconstruct_previous_depth.h"
|
||||
|
||||
#ifndef FFX_FRAMEINTERPOLATION_THREAD_GROUP_WIDTH
|
||||
#define FFX_FRAMEINTERPOLATION_THREAD_GROUP_WIDTH 8
|
||||
#endif // #ifndef FFX_FRAMEINTERPOLATION_THREAD_GROUP_WIDTH
|
||||
#ifndef FFX_FRAMEINTERPOLATION_THREAD_GROUP_HEIGHT
|
||||
#define FFX_FRAMEINTERPOLATION_THREAD_GROUP_HEIGHT 8
|
||||
#endif // #ifndef FFX_FRAMEINTERPOLATION_THREAD_GROUP_HEIGHT
|
||||
#ifndef FFX_FRAMEINTERPOLATION_THREAD_GROUP_DEPTH
|
||||
#define FFX_FRAMEINTERPOLATION_THREAD_GROUP_DEPTH 1
|
||||
#endif // #ifndef FFX_FRAMEINTERPOLATION_THREAD_GROUP_DEPTH
|
||||
#ifndef FFX_FRAMEINTERPOLATION_NUM_THREADS
|
||||
#define FFX_FRAMEINTERPOLATION_NUM_THREADS layout (local_size_x = FFX_FRAMEINTERPOLATION_THREAD_GROUP_WIDTH, local_size_y = FFX_FRAMEINTERPOLATION_THREAD_GROUP_HEIGHT, local_size_z = FFX_FRAMEINTERPOLATION_THREAD_GROUP_DEPTH) in;
|
||||
#endif // #ifndef FFX_FRAMEINTERPOLATION_NUM_THREADS
|
||||
|
||||
FFX_FRAMEINTERPOLATION_NUM_THREADS
|
||||
void main()
|
||||
{
|
||||
reconstructPreviousDepth(FfxInt32x2(gl_GlobalInvocationID.xy));
|
||||
}
|
||||
+60
@@ -0,0 +1,60 @@
|
||||
// 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.
|
||||
|
||||
#version 450
|
||||
|
||||
#extension GL_GOOGLE_include_directive : require
|
||||
#extension GL_EXT_samplerless_texture_functions : require
|
||||
|
||||
#define FFX_FRAMEINTERPOLATION_BIND_SRV_OPTICAL_FLOW_SCENE_CHANGE_DETECTION 0
|
||||
|
||||
#define FFX_FRAMEINTERPOLATION_BIND_UAV_GAME_MOTION_VECTOR_FIELD_X 1
|
||||
#define FFX_FRAMEINTERPOLATION_BIND_UAV_GAME_MOTION_VECTOR_FIELD_Y 2
|
||||
#define FFX_FRAMEINTERPOLATION_BIND_UAV_OPTICAL_FLOW_MOTION_VECTOR_FIELD_X 3
|
||||
#define FFX_FRAMEINTERPOLATION_BIND_UAV_OPTICAL_FLOW_MOTION_VECTOR_FIELD_Y 4
|
||||
#define FFX_FRAMEINTERPOLATION_BIND_UAV_DISOCCLUSION_MASK 5
|
||||
#define FFX_FRAMEINTERPOLATION_BIND_UAV_COUNTERS 6
|
||||
|
||||
#define FFX_FRAMEINTERPOLATION_BIND_CB_FRAMEINTERPOLATION 7
|
||||
|
||||
#include "frameinterpolation/ffx_frameinterpolation_callbacks_glsl.h"
|
||||
#include "frameinterpolation/ffx_frameinterpolation_common.h"
|
||||
#include "frameinterpolation/ffx_frameinterpolation_setup.h"
|
||||
|
||||
#ifndef FFX_FRAMEINTERPOLATION_THREAD_GROUP_WIDTH
|
||||
#define FFX_FRAMEINTERPOLATION_THREAD_GROUP_WIDTH 8
|
||||
#endif // #ifndef FFX_FRAMEINTERPOLATION_THREAD_GROUP_WIDTH
|
||||
#ifndef FFX_FRAMEINTERPOLATION_THREAD_GROUP_HEIGHT
|
||||
#define FFX_FRAMEINTERPOLATION_THREAD_GROUP_HEIGHT 8
|
||||
#endif // #ifndef FFX_FRAMEINTERPOLATION_THREAD_GROUP_HEIGHT
|
||||
#ifndef FFX_FRAMEINTERPOLATION_THREAD_GROUP_DEPTH
|
||||
#define FFX_FRAMEINTERPOLATION_THREAD_GROUP_DEPTH 1
|
||||
#endif // #ifndef FFX_FRAMEINTERPOLATION_THREAD_GROUP_DEPTH
|
||||
#ifndef FFX_FRAMEINTERPOLATION_NUM_THREADS
|
||||
#define FFX_FRAMEINTERPOLATION_NUM_THREADS layout (local_size_x = FFX_FRAMEINTERPOLATION_THREAD_GROUP_WIDTH, local_size_y = FFX_FRAMEINTERPOLATION_THREAD_GROUP_HEIGHT, local_size_z = FFX_FRAMEINTERPOLATION_THREAD_GROUP_DEPTH) in;
|
||||
#endif // #ifndef FFX_FRAMEINTERPOLATION_NUM_THREADS
|
||||
|
||||
FFX_FRAMEINTERPOLATION_NUM_THREADS
|
||||
void main()
|
||||
{
|
||||
setupFrameinterpolationResources(FfxInt32x2(gl_GlobalInvocationID.xy));
|
||||
}
|
||||
+60
@@ -0,0 +1,60 @@
|
||||
// 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.
|
||||
|
||||
#version 450
|
||||
|
||||
#extension GL_GOOGLE_include_directive : require
|
||||
#extension GL_EXT_samplerless_texture_functions : require
|
||||
|
||||
#define FFX_OPTICALFLOW_BIND_UAV_OPTICAL_FLOW_INPUT 0
|
||||
#define FFX_OPTICALFLOW_BIND_UAV_OPTICAL_FLOW_INPUT_LEVEL_1 1
|
||||
#define FFX_OPTICALFLOW_BIND_UAV_OPTICAL_FLOW_INPUT_LEVEL_2 2
|
||||
#define FFX_OPTICALFLOW_BIND_UAV_OPTICAL_FLOW_INPUT_LEVEL_3 3
|
||||
#define FFX_OPTICALFLOW_BIND_UAV_OPTICAL_FLOW_INPUT_LEVEL_4 4
|
||||
#define FFX_OPTICALFLOW_BIND_UAV_OPTICAL_FLOW_INPUT_LEVEL_5 5
|
||||
#define FFX_OPTICALFLOW_BIND_UAV_OPTICAL_FLOW_INPUT_LEVEL_6 6
|
||||
|
||||
#define FFX_OPTICALFLOW_BIND_CB_COMMON 7
|
||||
#define FFX_OPTICALFLOW_BIND_CB_SPD 8
|
||||
|
||||
#include "opticalflow/ffx_opticalflow_callbacks_glsl.h"
|
||||
#include "opticalflow/ffx_opticalflow_common.h"
|
||||
#include "opticalflow/ffx_opticalflow_compute_luminance_pyramid.h"
|
||||
|
||||
#ifndef FFX_OPTICALFLOW_THREAD_GROUP_WIDTH
|
||||
#define FFX_OPTICALFLOW_THREAD_GROUP_WIDTH 256
|
||||
#endif // #ifndef FFX_OPTICALFLOW_THREAD_GROUP_WIDTH
|
||||
#ifndef FFX_OPTICALFLOW_THREAD_GROUP_HEIGHT
|
||||
#define FFX_OPTICALFLOW_THREAD_GROUP_HEIGHT 1
|
||||
#endif // #ifndef FFX_OPTICALFLOW_THREAD_GROUP_HEIGHT
|
||||
#ifndef FFX_OPTICALFLOW_THREAD_GROUP_DEPTH
|
||||
#define FFX_OPTICALFLOW_THREAD_GROUP_DEPTH 1
|
||||
#endif // #ifndef FFX_OPTICALFLOW_THREAD_GROUP_DEPTH
|
||||
#ifndef FFX_OPTICALFLOW_NUM_THREADS
|
||||
#define FFX_OPTICALFLOW_NUM_THREADS layout (local_size_x = FFX_OPTICALFLOW_THREAD_GROUP_WIDTH, local_size_y = FFX_OPTICALFLOW_THREAD_GROUP_HEIGHT, local_size_z = FFX_OPTICALFLOW_THREAD_GROUP_DEPTH) in;
|
||||
#endif // #ifndef FFX_OPTICALFLOW_NUM_THREADS
|
||||
|
||||
FFX_OPTICALFLOW_NUM_THREADS
|
||||
void main()
|
||||
{
|
||||
ComputeOpticalFlowInputPyramid(FfxInt32x2(gl_WorkGroupID.xy), FfxInt32(gl_LocalInvocationIndex));
|
||||
}
|
||||
+66
@@ -0,0 +1,66 @@
|
||||
// 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.
|
||||
|
||||
#version 450
|
||||
|
||||
#extension GL_GOOGLE_include_directive : require
|
||||
#extension GL_EXT_samplerless_texture_functions : require
|
||||
|
||||
#define FFX_WAVE 1
|
||||
#extension GL_KHR_shader_subgroup_basic : require
|
||||
|
||||
#define FFX_OPTICALFLOW_BIND_SRV_OPTICAL_FLOW_INPUT 0
|
||||
#define FFX_OPTICALFLOW_BIND_SRV_OPTICAL_FLOW_PREVIOUS_INPUT 1
|
||||
|
||||
#define FFX_OPTICALFLOW_BIND_UAV_OPTICAL_FLOW 2
|
||||
#define FFX_OPTICALFLOW_BIND_UAV_OPTICAL_FLOW_SCD_OUTPUT 3
|
||||
|
||||
#define FFX_OPTICALFLOW_BIND_CB_COMMON 4
|
||||
|
||||
|
||||
#include "opticalflow/ffx_opticalflow_callbacks_glsl.h"
|
||||
#include "opticalflow/ffx_opticalflow_common.h"
|
||||
|
||||
#ifndef FFX_OPTICALFLOW_BLOCK_SIZE
|
||||
#define FFX_OPTICALFLOW_BLOCK_SIZE 8
|
||||
#endif // #ifndef FFX_OPTICALFLOW_BLOCK_SIZE
|
||||
#ifndef FFX_OPTICALFLOW_THREAD_GROUP_WIDTH
|
||||
#define FFX_OPTICALFLOW_THREAD_GROUP_WIDTH 64
|
||||
#endif // #ifndef FFX_OPTICALFLOW_THREAD_GROUP_WIDTH
|
||||
#ifndef FFX_OPTICALFLOW_THREAD_GROUP_HEIGHT
|
||||
#define FFX_OPTICALFLOW_THREAD_GROUP_HEIGHT 1
|
||||
#endif // #ifndef FFX_OPTICALFLOW_THREAD_GROUP_HEIGHT
|
||||
#ifndef FFX_OPTICALFLOW_THREAD_GROUP_DEPTH
|
||||
#define FFX_OPTICALFLOW_THREAD_GROUP_DEPTH 1
|
||||
#endif // #ifndef FFX_OPTICALFLOW_THREAD_GROUP_DEPTH
|
||||
|
||||
#include "opticalflow/ffx_opticalflow_compute_optical_flow_v5.h"
|
||||
|
||||
#ifndef FFX_OPTICALFLOW_NUM_THREADS
|
||||
#define FFX_OPTICALFLOW_NUM_THREADS layout (local_size_x = FFX_OPTICALFLOW_THREAD_GROUP_WIDTH, local_size_y = FFX_OPTICALFLOW_THREAD_GROUP_HEIGHT, local_size_z = FFX_OPTICALFLOW_THREAD_GROUP_DEPTH) in;
|
||||
#endif // #ifndef FFX_OPTICALFLOW_NUM_THREADS
|
||||
|
||||
FFX_OPTICALFLOW_NUM_THREADS
|
||||
void main()
|
||||
{
|
||||
ComputeOpticalFlowAdvanced(FfxInt32x2(gl_GlobalInvocationID.xy), FfxInt32x2(gl_LocalInvocationID.xy), FfxInt32x2(gl_WorkGroupID.xy), FfxInt32(gl_LocalInvocationIndex));
|
||||
}
|
||||
+57
@@ -0,0 +1,57 @@
|
||||
// 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.
|
||||
|
||||
#version 450
|
||||
|
||||
#extension GL_GOOGLE_include_directive : require
|
||||
#extension GL_EXT_samplerless_texture_functions : require
|
||||
|
||||
#define FFX_OPTICALFLOW_BIND_UAV_OPTICAL_FLOW_SCD_HISTOGRAM 0
|
||||
#define FFX_OPTICALFLOW_BIND_UAV_OPTICAL_FLOW_SCD_PREVIOUS_HISTOGRAM 1
|
||||
#define FFX_OPTICALFLOW_BIND_UAV_OPTICAL_FLOW_SCD_TEMP 2
|
||||
#define FFX_OPTICALFLOW_BIND_UAV_OPTICAL_FLOW_SCD_OUTPUT 3
|
||||
|
||||
#define FFX_OPTICALFLOW_BIND_CB_COMMON 4
|
||||
|
||||
#include "opticalflow/ffx_opticalflow_callbacks_glsl.h"
|
||||
#include "opticalflow/ffx_opticalflow_common.h"
|
||||
#include "opticalflow/ffx_opticalflow_compute_scd_divergence.h"
|
||||
|
||||
#ifndef FFX_OPTICALFLOW_THREAD_GROUP_WIDTH
|
||||
#define FFX_OPTICALFLOW_THREAD_GROUP_WIDTH 256
|
||||
#endif // #ifndef FFX_OPTICALFLOW_THREAD_GROUP_WIDTH
|
||||
#ifndef FFX_OPTICALFLOW_THREAD_GROUP_HEIGHT
|
||||
#define FFX_OPTICALFLOW_THREAD_GROUP_HEIGHT 1
|
||||
#endif // #ifndef FFX_OPTICALFLOW_THREAD_GROUP_HEIGHT
|
||||
#ifndef FFX_OPTICALFLOW_THREAD_GROUP_DEPTH
|
||||
#define FFX_OPTICALFLOW_THREAD_GROUP_DEPTH 1
|
||||
#endif // #ifndef FFX_OPTICALFLOW_THREAD_GROUP_DEPTH
|
||||
#ifndef FFX_OPTICALFLOW_NUM_THREADS
|
||||
#define FFX_OPTICALFLOW_NUM_THREADS layout (local_size_x = FFX_OPTICALFLOW_THREAD_GROUP_WIDTH, local_size_y = FFX_OPTICALFLOW_THREAD_GROUP_HEIGHT, local_size_z = FFX_OPTICALFLOW_THREAD_GROUP_DEPTH) in;
|
||||
#endif // #ifndef FFX_OPTICALFLOW_NUM_THREADS
|
||||
|
||||
FFX_OPTICALFLOW_NUM_THREADS
|
||||
void main()
|
||||
{
|
||||
FfxInt32x2 iGroupSize = FfxInt32x2(FFX_OPTICALFLOW_THREAD_GROUP_WIDTH, FFX_OPTICALFLOW_THREAD_GROUP_HEIGHT);
|
||||
ComputeSCDHistogramsDivergence(FfxInt32x3(gl_GlobalInvocationID.xyz), FfxInt32x2(gl_LocalInvocationID.xy), FfxInt32(gl_LocalInvocationIndex), FfxInt32x2(gl_WorkGroupID.xy), iGroupSize);
|
||||
}
|
||||
+57
@@ -0,0 +1,57 @@
|
||||
// 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.
|
||||
|
||||
#version 450
|
||||
|
||||
#extension GL_GOOGLE_include_directive : require
|
||||
#extension GL_EXT_samplerless_texture_functions : require
|
||||
|
||||
#define FFX_OPTICALFLOW_BIND_SRV_OPTICAL_FLOW_PREVIOUS 0
|
||||
|
||||
#define FFX_OPTICALFLOW_BIND_UAV_OPTICAL_FLOW 1
|
||||
|
||||
#define FFX_OPTICALFLOW_BIND_CB_COMMON 2
|
||||
|
||||
#include "opticalflow/ffx_opticalflow_callbacks_glsl.h"
|
||||
#include "opticalflow/ffx_opticalflow_common.h"
|
||||
|
||||
#ifndef FFX_OPTICALFLOW_THREAD_GROUP_WIDTH
|
||||
#define FFX_OPTICALFLOW_THREAD_GROUP_WIDTH 16
|
||||
#endif // #ifndef FFX_OPTICALFLOW_THREAD_GROUP_WIDTH
|
||||
#ifndef FFX_OPTICALFLOW_THREAD_GROUP_HEIGHT
|
||||
#define FFX_OPTICALFLOW_THREAD_GROUP_HEIGHT 4
|
||||
#endif // #ifndef FFX_OPTICALFLOW_THREAD_GROUP_HEIGHT
|
||||
#ifndef FFX_OPTICALFLOW_THREAD_GROUP_DEPTH
|
||||
#define FFX_OPTICALFLOW_THREAD_GROUP_DEPTH 1
|
||||
#endif // #ifndef FFX_OPTICALFLOW_THREAD_GROUP_DEPTH
|
||||
|
||||
#include "opticalflow/ffx_opticalflow_filter_optical_flow_v5.h"
|
||||
|
||||
#ifndef FFX_OPTICALFLOW_NUM_THREADS
|
||||
#define FFX_OPTICALFLOW_NUM_THREADS layout (local_size_x = FFX_OPTICALFLOW_THREAD_GROUP_WIDTH, local_size_y = FFX_OPTICALFLOW_THREAD_GROUP_HEIGHT, local_size_z = FFX_OPTICALFLOW_THREAD_GROUP_DEPTH) in;
|
||||
#endif // #ifndef FFX_OPTICALFLOW_NUM_THREADS
|
||||
|
||||
FFX_OPTICALFLOW_NUM_THREADS
|
||||
void main()
|
||||
{
|
||||
FilterOpticalFlow(FfxInt32x2(gl_GlobalInvocationID.xy), FfxInt32x2(gl_LocalInvocationID.xy), FfxInt32x2(gl_WorkGroupID.xy), FfxInt32(gl_LocalInvocationIndex));
|
||||
}
|
||||
+55
@@ -0,0 +1,55 @@
|
||||
// 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.
|
||||
|
||||
#version 450
|
||||
|
||||
#extension GL_GOOGLE_include_directive : require
|
||||
#extension GL_EXT_samplerless_texture_functions : require
|
||||
|
||||
#define FFX_OPTICALFLOW_BIND_SRV_OPTICAL_FLOW_INPUT 0
|
||||
#define FFX_OPTICALFLOW_BIND_UAV_OPTICAL_FLOW_SCD_HISTOGRAM 1
|
||||
|
||||
#define FFX_OPTICALFLOW_BIND_CB_COMMON 2
|
||||
|
||||
#include "opticalflow/ffx_opticalflow_callbacks_glsl.h"
|
||||
#include "opticalflow/ffx_opticalflow_common.h"
|
||||
#include "opticalflow/ffx_opticalflow_generate_scd_histogram.h"
|
||||
|
||||
#ifndef FFX_OPTICALFLOW_THREAD_GROUP_WIDTH
|
||||
#define FFX_OPTICALFLOW_THREAD_GROUP_WIDTH 32
|
||||
#endif // #ifndef FFX_OPTICALFLOW_THREAD_GROUP_WIDTH
|
||||
#ifndef FFX_OPTICALFLOW_THREAD_GROUP_HEIGHT
|
||||
#define FFX_OPTICALFLOW_THREAD_GROUP_HEIGHT 8
|
||||
#endif // #ifndef FFX_OPTICALFLOW_THREAD_GROUP_HEIGHT
|
||||
#ifndef FFX_OPTICALFLOW_THREAD_GROUP_DEPTH
|
||||
#define FFX_OPTICALFLOW_THREAD_GROUP_DEPTH 1
|
||||
#endif // #ifndef FFX_OPTICALFLOW_THREAD_GROUP_DEPTH
|
||||
#ifndef FFX_OPTICALFLOW_NUM_THREADS
|
||||
#define FFX_OPTICALFLOW_NUM_THREADS layout (local_size_x = FFX_OPTICALFLOW_THREAD_GROUP_WIDTH, local_size_y = FFX_OPTICALFLOW_THREAD_GROUP_HEIGHT, local_size_z = FFX_OPTICALFLOW_THREAD_GROUP_DEPTH) in;
|
||||
#endif // #ifndef FFX_OPTICALFLOW_NUM_THREADS
|
||||
|
||||
FFX_OPTICALFLOW_NUM_THREADS
|
||||
void main()
|
||||
{
|
||||
FfxInt32x2 iGroupSize = FfxInt32x2(FFX_OPTICALFLOW_THREAD_GROUP_WIDTH, FFX_OPTICALFLOW_THREAD_GROUP_HEIGHT);
|
||||
GenerateSceneChangeDetectionHistogram(FfxInt32x3(gl_GlobalInvocationID.xyz), FfxInt32x2(gl_LocalInvocationID.xy), FfxInt32(gl_LocalInvocationIndex), FfxInt32x2(gl_WorkGroupID.xy), iGroupSize);
|
||||
}
|
||||
+55
@@ -0,0 +1,55 @@
|
||||
// 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.
|
||||
|
||||
#version 450
|
||||
|
||||
#extension GL_GOOGLE_include_directive : require
|
||||
#extension GL_EXT_samplerless_texture_functions : require
|
||||
|
||||
#define FFX_OPTICALFLOW_BIND_SRV_INPUT_COLOR 0
|
||||
#define FFX_OPTICALFLOW_BIND_UAV_OPTICAL_FLOW_INPUT 1
|
||||
|
||||
#define FFX_OPTICALFLOW_BIND_CB_COMMON 2
|
||||
|
||||
#include "opticalflow/ffx_opticalflow_callbacks_glsl.h"
|
||||
#include "opticalflow/ffx_opticalflow_common.h"
|
||||
|
||||
#ifndef FFX_OPTICALFLOW_THREAD_GROUP_WIDTH
|
||||
#define FFX_OPTICALFLOW_THREAD_GROUP_WIDTH 16
|
||||
#endif // #ifndef FFX_OPTICALFLOW_THREAD_GROUP_WIDTH
|
||||
#ifndef FFX_OPTICALFLOW_THREAD_GROUP_HEIGHT
|
||||
#define FFX_OPTICALFLOW_THREAD_GROUP_HEIGHT 16
|
||||
#endif // #ifndef FFX_OPTICALFLOW_THREAD_GROUP_HEIGHT
|
||||
#ifndef FFX_OPTICALFLOW_THREAD_GROUP_DEPTH
|
||||
#define FFX_OPTICALFLOW_THREAD_GROUP_DEPTH 1
|
||||
#endif // #ifndef FFX_OPTICALFLOW_THREAD_GROUP_DEPTH
|
||||
#ifndef FFX_OPTICALFLOW_NUM_THREADS
|
||||
#define FFX_OPTICALFLOW_NUM_THREADS layout (local_size_x = FFX_OPTICALFLOW_THREAD_GROUP_WIDTH, local_size_y = FFX_OPTICALFLOW_THREAD_GROUP_HEIGHT, local_size_z = FFX_OPTICALFLOW_THREAD_GROUP_DEPTH) in;
|
||||
#endif // #ifndef FFX_OPTICALFLOW_NUM_THREADS
|
||||
|
||||
#include "opticalflow/ffx_opticalflow_prepare_luma.h"
|
||||
|
||||
FFX_OPTICALFLOW_NUM_THREADS
|
||||
void main()
|
||||
{
|
||||
PrepareLuma(FfxInt32x2(gl_GlobalInvocationID.xy), FfxInt32(gl_LocalInvocationIndex));
|
||||
}
|
||||
+66
@@ -0,0 +1,66 @@
|
||||
// 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.
|
||||
|
||||
#version 450
|
||||
|
||||
#extension GL_GOOGLE_include_directive : require
|
||||
#extension GL_EXT_samplerless_texture_functions : require
|
||||
|
||||
#define FFX_OPTICALFLOW_BIND_SRV_OPTICAL_FLOW_INPUT 0
|
||||
#define FFX_OPTICALFLOW_BIND_SRV_OPTICAL_FLOW_PREVIOUS_INPUT 1
|
||||
#define FFX_OPTICALFLOW_BIND_SRV_OPTICAL_FLOW 2
|
||||
|
||||
#define FFX_OPTICALFLOW_BIND_UAV_OPTICAL_FLOW_NEXT_LEVEL 3
|
||||
#define FFX_OPTICALFLOW_BIND_UAV_OPTICAL_FLOW_SCD_OUTPUT 4
|
||||
|
||||
#define FFX_OPTICALFLOW_BIND_CB_COMMON 5
|
||||
|
||||
#include "opticalflow/ffx_opticalflow_callbacks_glsl.h"
|
||||
#include "opticalflow/ffx_opticalflow_common.h"
|
||||
|
||||
#ifndef FFX_OPTICALFLOW_BLOCK_SIZE
|
||||
#define FFX_OPTICALFLOW_BLOCK_SIZE 8
|
||||
#endif // #ifndef FFX_OPTICALFLOW_BLOCK_SIZE
|
||||
|
||||
#ifndef FFX_OPTICALFLOW_THREAD_GROUP_WIDTH
|
||||
#define FFX_OPTICALFLOW_THREAD_GROUP_WIDTH 4
|
||||
#endif // #ifndef FFX_OPTICALFLOW_THREAD_GROUP_WIDTH
|
||||
|
||||
#ifndef FFX_OPTICALFLOW_THREAD_GROUP_HEIGHT
|
||||
#define FFX_OPTICALFLOW_THREAD_GROUP_HEIGHT 4
|
||||
#endif // #ifndef FFX_OPTICALFLOW_THREAD_GROUP_HEIGHT
|
||||
|
||||
#ifndef FFX_OPTICALFLOW_THREAD_GROUP_DEPTH
|
||||
#define FFX_OPTICALFLOW_THREAD_GROUP_DEPTH 4
|
||||
#endif // #ifndef FFX_OPTICALFLOW_THREAD_GROUP_DEPTH
|
||||
|
||||
#include "opticalflow/ffx_opticalflow_scale_optical_flow_advanced_v5.h"
|
||||
|
||||
#ifndef FFX_OPTICALFLOW_NUM_THREADS
|
||||
#define FFX_OPTICALFLOW_NUM_THREADS layout (local_size_x = FFX_OPTICALFLOW_THREAD_GROUP_WIDTH, local_size_y = FFX_OPTICALFLOW_THREAD_GROUP_HEIGHT, local_size_z = FFX_OPTICALFLOW_THREAD_GROUP_DEPTH) in;
|
||||
#endif // #ifndef FFX_OPTICALFLOW_NUM_THREADS
|
||||
|
||||
FFX_OPTICALFLOW_NUM_THREADS
|
||||
void main()
|
||||
{
|
||||
ScaleOpticalFlowAdvanced(FfxInt32x3(gl_GlobalInvocationID.xyz), FfxInt32x3(gl_LocalInvocationID.xyz));
|
||||
}
|
||||
Vendored
+1265
File diff suppressed because it is too large.
Load diff
+147
@@ -0,0 +1,147 @@
|
||||
// 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 <FidelityFX/gpu/frameinterpolation/ffx_frameinterpolation_resources.h>
|
||||
|
||||
/// An enumeration of all the permutations that can be passed to the FSR3 algorithm.
|
||||
///
|
||||
/// FSR3 features are organized through a set of pre-defined compile
|
||||
/// permutation options that need to be specified. Which shader blob
|
||||
/// is returned for pipeline creation will be determined by what combination
|
||||
/// of shader permutations are enabled.
|
||||
///
|
||||
/// @ingroup FRAMEINTERPOLATION
|
||||
typedef enum FrameInterpolationShaderPermutationOptions
|
||||
{
|
||||
FRAMEINTERPOLATION_SHADER_PERMUTATION_LOW_RES_MOTION_VECTORS = (1 << 0),
|
||||
FRAMEINTERPOLATION_SHADER_PERMUTATION_JITTER_MOTION_VECTORS = (1 << 1),
|
||||
FRAMEINTERPOLATION_SHADER_PERMUTATION_DEPTH_INVERTED = (1 << 2), ///< Indicates input resources were generated with inverted depth
|
||||
FRAMEINTERPOLATION_SHADER_PERMUTATION_FORCE_WAVE64 = (1 << 3), ///< doesn't map to a define, selects different table
|
||||
FRAMEINTERPOLATION_SHADER_PERMUTATION_ALLOW_FP16 = (1 << 4), ///< Enables fast math computations where possible
|
||||
} FrameInterpolationShaderPermutationOptions;
|
||||
|
||||
typedef struct FrameInterpolationConstants
|
||||
{
|
||||
int32_t renderSize[2];
|
||||
int32_t displaySize[2];
|
||||
|
||||
float displaySizeRcp[2];
|
||||
float cameraNear;
|
||||
float cameraFar;
|
||||
|
||||
int32_t upscalerTargetSize[2]; // how is that different from display size?
|
||||
int Mode;
|
||||
int Reset;
|
||||
|
||||
float deviceToViewDepth[4];
|
||||
|
||||
float deltaTime;
|
||||
int HUDLessAttachedFactor;
|
||||
int32_t distortionFieldSize[2];
|
||||
|
||||
float opticalFlowScale[2];
|
||||
int32_t opticalFlowBlockSize;
|
||||
uint32_t dispatchFlags;
|
||||
|
||||
int32_t maxRenderSize[2];
|
||||
int opticalFlowHalfResMode;
|
||||
int numInstances;
|
||||
|
||||
int32_t interpolationRectBase[2];
|
||||
int32_t interpolationRectSize[2];
|
||||
|
||||
float debugBarColor[3];
|
||||
uint32_t backBufferTransferFunction;
|
||||
|
||||
float minMaxLuminance[2];
|
||||
float fTanHalfFOV;
|
||||
float _pad1;
|
||||
|
||||
float jitter[2];
|
||||
float motionVectorScale[2];
|
||||
} FrameInterpolationConstants;
|
||||
|
||||
typedef struct InpaintingPyramidConstants {
|
||||
|
||||
uint32_t mips;
|
||||
uint32_t numworkGroups;
|
||||
uint32_t workGroupOffset[2];
|
||||
} InpaintingPyramidConstants;
|
||||
|
||||
struct FfxDeviceCapabilities;
|
||||
struct FfxPipelineState;
|
||||
struct FfxResource;
|
||||
|
||||
typedef struct FfxFrameInterpolationRenderDescription
|
||||
{
|
||||
FfxDimensions2D renderSize;
|
||||
FfxDimensions2D upscaleSize;
|
||||
|
||||
float cameraNear;
|
||||
float cameraFar;
|
||||
float cameraFovAngleVertical;
|
||||
float viewSpaceToMetersFactor;
|
||||
|
||||
FfxFloatCoords2D motionVectorScale; ///< The scale factor to apply to motion vectors.
|
||||
} FfxFrameInterpolationRenderDescription;
|
||||
|
||||
// FfxFsr3Context_Private
|
||||
// The private implementation of the FSR3 context.
|
||||
typedef struct FfxFrameInterpolationContext_Private {
|
||||
|
||||
FfxFrameInterpolationContextDescription contextDescription;
|
||||
FfxUInt32 effectContextId;
|
||||
FfxFrameInterpolationRenderDescription renderDescription;
|
||||
FrameInterpolationConstants constants;
|
||||
InpaintingPyramidConstants inpaintingPyramidContants;
|
||||
FfxDevice device;
|
||||
FfxDeviceCapabilities deviceCapabilities;
|
||||
|
||||
// FrameInterpolation Pipelines
|
||||
FfxPipelineState pipelineFiReconstructAndDilate;
|
||||
FfxPipelineState pipelineFiSetup;
|
||||
FfxPipelineState pipelineFiReconstructPreviousDepth;
|
||||
FfxPipelineState pipelineFiGameMotionVectorField;
|
||||
FfxPipelineState pipelineFiOpticalFlowVectorField;
|
||||
FfxPipelineState pipelineFiDisocclusionMask;
|
||||
FfxPipelineState pipelineFiScfi;
|
||||
FfxPipelineState pipelineInpaintingPyramid;
|
||||
FfxPipelineState pipelineInpainting;
|
||||
FfxPipelineState pipelineGameVectorFieldInpaintingPyramid;
|
||||
FfxPipelineState pipelineDebugView;
|
||||
|
||||
FfxConstantBuffer constantBuffers[FFX_FRAMEINTERPOLATION_CONSTANTBUFFER_COUNT];
|
||||
|
||||
// 2 arrays of resources, as e.g. FFX_FSR3_RESOURCE_IDENTIFIER_LOCK_STATUS will use different resources when bound as SRV vs when bound as UAV
|
||||
FfxResourceInternal srvResources[FFX_FRAMEINTERPOLATION_RESOURCE_IDENTIFIER_COUNT];
|
||||
FfxResourceInternal uavResources[FFX_FRAMEINTERPOLATION_RESOURCE_IDENTIFIER_COUNT];
|
||||
|
||||
bool firstExecution;
|
||||
bool refreshPipelineStates;
|
||||
|
||||
bool asyncSupported;
|
||||
uint64_t previousFrameID;
|
||||
uint64_t dispatchCount;
|
||||
|
||||
} FfxFrameInterpolationContext_Private;
|
||||
+987
@@ -0,0 +1,987 @@
|
||||
// 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.
|
||||
|
||||
#include <algorithm> // for max used inside SPD CPU code.
|
||||
#include <cmath> // for fabs, abs, sinf, sqrt, etc.
|
||||
#include <string> // for memset
|
||||
#include <cfloat> // for FLT_EPSILON
|
||||
#include "FidelityFX/host/ffx_opticalflow.h"
|
||||
|
||||
#ifdef __clang__
|
||||
#pragma clang diagnostic ignored "-Wunused-function"
|
||||
#pragma clang diagnostic ignored "-Wsign-compare"
|
||||
#endif
|
||||
|
||||
#define FFX_CPU
|
||||
#include <FidelityFX/gpu/ffx_core.h>
|
||||
#include <FidelityFX/gpu/spd/ffx_spd.h>
|
||||
#include <FidelityFX/gpu/opticalflow/ffx_opticalflow_callbacks_hlsl.h>
|
||||
#include <ffx_object_management.h>
|
||||
|
||||
#define FFX_OPTICALFLOW_MAX_QUEUED_FRAMES 16
|
||||
|
||||
#include "ffx_opticalflow_private.h"
|
||||
|
||||
typedef struct Binding
|
||||
{
|
||||
uint32_t index;
|
||||
wchar_t name[64];
|
||||
}Binding;
|
||||
|
||||
static const Binding srvBindingNames[] =
|
||||
{
|
||||
{FFX_OF_BINDING_IDENTIFIER_INPUT_COLOR, L"r_input_color"},
|
||||
{FFX_OF_BINDING_IDENTIFIER_OPTICAL_FLOW_INPUT, L"r_optical_flow_input"},
|
||||
{FFX_OF_BINDING_IDENTIFIER_OPTICAL_FLOW_PREVIOUS_INPUT, L"r_optical_flow_previous_input"},
|
||||
{FFX_OF_BINDING_IDENTIFIER_OPTICAL_FLOW, L"r_optical_flow"},
|
||||
{FFX_OF_BINDING_IDENTIFIER_OPTICAL_FLOW_PREVIOUS, L"r_optical_flow_previous"},
|
||||
};
|
||||
|
||||
static const Binding uavBindingNames[] =
|
||||
{
|
||||
{FFX_OF_BINDING_IDENTIFIER_OPTICAL_FLOW_INPUT, L"rw_optical_flow_input"},
|
||||
{FFX_OF_BINDING_IDENTIFIER_OPTICAL_FLOW_INPUT_LEVEL_1, L"rw_optical_flow_input_level_1"},
|
||||
{FFX_OF_BINDING_IDENTIFIER_OPTICAL_FLOW_INPUT_LEVEL_2, L"rw_optical_flow_input_level_2"},
|
||||
{FFX_OF_BINDING_IDENTIFIER_OPTICAL_FLOW_INPUT_LEVEL_3, L"rw_optical_flow_input_level_3"},
|
||||
{FFX_OF_BINDING_IDENTIFIER_OPTICAL_FLOW_INPUT_LEVEL_4, L"rw_optical_flow_input_level_4"},
|
||||
{FFX_OF_BINDING_IDENTIFIER_OPTICAL_FLOW_INPUT_LEVEL_5, L"rw_optical_flow_input_level_5"},
|
||||
{FFX_OF_BINDING_IDENTIFIER_OPTICAL_FLOW_INPUT_LEVEL_6, L"rw_optical_flow_input_level_6"},
|
||||
{FFX_OF_BINDING_IDENTIFIER_OPTICAL_FLOW, L"rw_optical_flow"},
|
||||
{FFX_OF_BINDING_IDENTIFIER_OPTICAL_FLOW_NEXT_LEVEL, L"rw_optical_flow_next_level"},
|
||||
{FFX_OF_BINDING_IDENTIFIER_OPTICAL_FLOW_SCD_HISTOGRAM, L"rw_optical_flow_scd_histogram"}, // scene change detection histogram
|
||||
{FFX_OF_BINDING_IDENTIFIER_OPTICAL_FLOW_SCD_PREVIOUS_HISTOGRAM, L"rw_optical_flow_scd_previous_histogram"},
|
||||
{FFX_OF_BINDING_IDENTIFIER_OPTICAL_FLOW_SCD_TEMP, L"rw_optical_flow_scd_temp"},
|
||||
{FFX_OF_BINDING_IDENTIFIER_OPTICAL_FLOW_SCD_OUTPUT, L"rw_optical_flow_scd_output"},
|
||||
};
|
||||
|
||||
static const Binding cbBindingNames[] =
|
||||
{
|
||||
{FFX_OPTICALFLOW_CONSTANTBUFFER_IDENTIFIER, L"cbOF"},
|
||||
{FFX_OPTICALFLOW_CONSTANTBUFFER_IDENTIFIER_SPD, L"cbOF_SPD"}
|
||||
};
|
||||
|
||||
// Broad structure of the root signature.
|
||||
typedef enum OpticalFlowRootSignatureLayout {
|
||||
|
||||
OPTICALFLOW_ROOT_SIGNATURE_LAYOUT_UAVS,
|
||||
OPTICALFLOW_ROOT_SIGNATURE_LAYOUT_SRVS,
|
||||
OPTICALFLOW_ROOT_SIGNATURE_LAYOUT_CONSTANTS,
|
||||
OPTICALFLOW_ROOT_SIGNATURE_LAYOUT_CONSTANTS_REGISTER_1,
|
||||
OPTICALFLOW_ROOT_SIGNATURE_LAYOUT_PARAMETER_COUNT
|
||||
} OpticalFlowRootSignatureLayout;
|
||||
|
||||
typedef struct OpticalFlowSpdConstants
|
||||
{
|
||||
uint32_t mips;
|
||||
uint32_t numworkGroups;
|
||||
uint32_t workGroupOffset[2];
|
||||
|
||||
uint32_t numworkGroupsOpticalFlowInputPyramid;
|
||||
uint32_t pad0_;
|
||||
uint32_t pad1_;
|
||||
uint32_t pad2_;
|
||||
|
||||
} OpticalFlowSpdConstants;
|
||||
|
||||
static FfxErrorCode patchResourceBindings(FfxPipelineState* inoutPipeline)
|
||||
{
|
||||
for (uint32_t srvIndex = 0; srvIndex < inoutPipeline->srvTextureCount; ++srvIndex)
|
||||
{
|
||||
int32_t mapIndex = 0;
|
||||
for (mapIndex = 0; mapIndex < _countof(srvBindingNames); ++mapIndex)
|
||||
{
|
||||
if (0 == wcscmp(srvBindingNames[mapIndex].name, inoutPipeline->srvTextureBindings[srvIndex].name))
|
||||
break;
|
||||
}
|
||||
FFX_ASSERT(mapIndex < _countof(srvBindingNames));
|
||||
if (mapIndex == _countof(srvBindingNames))
|
||||
return FFX_ERROR_INVALID_ARGUMENT;
|
||||
|
||||
inoutPipeline->srvTextureBindings[srvIndex].resourceIdentifier = srvBindingNames[mapIndex].index;
|
||||
}
|
||||
|
||||
for (uint32_t uavIndex = 0; uavIndex < inoutPipeline->uavTextureCount; ++uavIndex)
|
||||
{
|
||||
int32_t mapIndex = 0;
|
||||
for (mapIndex = 0; mapIndex < _countof(uavBindingNames); ++mapIndex)
|
||||
{
|
||||
if (0 == wcscmp(uavBindingNames[mapIndex].name, inoutPipeline->uavTextureBindings[uavIndex].name))
|
||||
break;
|
||||
}
|
||||
FFX_ASSERT(mapIndex < _countof(uavBindingNames));
|
||||
if (mapIndex == _countof(uavBindingNames))
|
||||
return FFX_ERROR_INVALID_ARGUMENT;
|
||||
|
||||
inoutPipeline->uavTextureBindings[uavIndex].resourceIdentifier = uavBindingNames[mapIndex].index;
|
||||
}
|
||||
|
||||
for (uint32_t cbIndex = 0; cbIndex < inoutPipeline->constCount; ++cbIndex)
|
||||
{
|
||||
int32_t mapIndex = 0;
|
||||
for (mapIndex = 0; mapIndex < _countof(cbBindingNames); ++mapIndex)
|
||||
{
|
||||
if (0 == wcscmp(cbBindingNames[mapIndex].name, inoutPipeline->constantBufferBindings[cbIndex].name))
|
||||
break;
|
||||
}
|
||||
FFX_ASSERT(mapIndex < _countof(cbBindingNames));
|
||||
if (mapIndex == _countof(cbBindingNames))
|
||||
return FFX_ERROR_INVALID_ARGUMENT;
|
||||
|
||||
inoutPipeline->constantBufferBindings[cbIndex].resourceIdentifier = cbBindingNames[mapIndex].index;
|
||||
}
|
||||
|
||||
return FFX_OK;
|
||||
}
|
||||
|
||||
static uint32_t getPipelinePermutationFlags(uint32_t, FfxPass, bool fp16, bool force64, bool)
|
||||
{
|
||||
uint32_t flags = 0;
|
||||
flags |= (force64) ? OPTICALFLOW_SHADER_PERMUTATION_FORCE_WAVE64 : 0;
|
||||
flags |= (fp16) ? OPTICALFLOW_SHADER_PERMUTATION_ALLOW_FP16 : 0;
|
||||
return flags;
|
||||
}
|
||||
|
||||
static FfxErrorCode createPipelineStates(FfxOpticalflowContext_Private* context)
|
||||
{
|
||||
FFX_ASSERT(context);
|
||||
|
||||
constexpr size_t samplerCount = 2;
|
||||
FfxSamplerDescription samplerDescs[samplerCount] = {
|
||||
{FFX_FILTER_TYPE_MINMAGMIP_POINT, FFX_ADDRESS_MODE_CLAMP, FFX_ADDRESS_MODE_CLAMP, FFX_ADDRESS_MODE_CLAMP, FFX_BIND_COMPUTE_SHADER_STAGE},
|
||||
{FFX_FILTER_TYPE_MINMAGMIP_LINEAR, FFX_ADDRESS_MODE_CLAMP, FFX_ADDRESS_MODE_CLAMP, FFX_ADDRESS_MODE_CLAMP, FFX_BIND_COMPUTE_SHADER_STAGE} };
|
||||
|
||||
const size_t rootConstantCount = 2;
|
||||
FfxRootConstantDescription rootConstantDescs[2] = { {sizeof(OpticalflowConstants) / sizeof(uint32_t), FFX_BIND_COMPUTE_SHADER_STAGE},
|
||||
{sizeof(OpticalFlowSpdConstants) / sizeof(uint32_t), FFX_BIND_COMPUTE_SHADER_STAGE} };
|
||||
FfxPipelineDescription pipelineDescription = {};
|
||||
pipelineDescription.stage = FFX_BIND_COMPUTE_SHADER_STAGE;
|
||||
pipelineDescription.contextFlags = context->contextDescription.flags;
|
||||
pipelineDescription.samplerCount = samplerCount;
|
||||
pipelineDescription.samplers = samplerDescs;
|
||||
pipelineDescription.rootConstantBufferCount = rootConstantCount;
|
||||
pipelineDescription.rootConstants = rootConstantDescs;
|
||||
|
||||
FfxDeviceCapabilities capabilities;
|
||||
context->contextDescription.backendInterface.fpGetDeviceCapabilities(&context->contextDescription.backendInterface, &capabilities);
|
||||
|
||||
bool haveShaderModel66 = capabilities.maximumSupportedShaderModel >= FFX_SHADER_MODEL_6_6;
|
||||
bool supportedFP16 = capabilities.fp16Supported;
|
||||
bool canForceWave64 = false;
|
||||
bool useLut = false;
|
||||
|
||||
const uint32_t waveLaneCountMin = capabilities.waveLaneCountMin;
|
||||
const uint32_t waveLaneCountMax = capabilities.waveLaneCountMax;
|
||||
if (waveLaneCountMin == 32 && waveLaneCountMax == 64)
|
||||
{
|
||||
useLut = true;
|
||||
canForceWave64 = haveShaderModel66;
|
||||
}
|
||||
else
|
||||
canForceWave64 = false;
|
||||
|
||||
uint32_t contextFlags = context->contextDescription.flags;
|
||||
|
||||
auto CreateComputePipeline = [&](FfxPass pass, const wchar_t* name, FfxPipelineState* pipeline) -> FfxErrorCode {
|
||||
ffxSafeReleasePipeline(&context->contextDescription.backendInterface, pipeline, context->effectContextId);
|
||||
wcscpy_s(pipelineDescription.name, name);
|
||||
FFX_VALIDATE(context->contextDescription.backendInterface.fpCreatePipeline(
|
||||
&context->contextDescription.backendInterface,
|
||||
FFX_EFFECT_OPTICALFLOW,
|
||||
pass,
|
||||
getPipelinePermutationFlags(contextFlags, pass, supportedFP16, canForceWave64, useLut),
|
||||
&pipelineDescription,
|
||||
context->effectContextId,
|
||||
pipeline));
|
||||
|
||||
patchResourceBindings(pipeline);
|
||||
return FFX_OK;
|
||||
};
|
||||
|
||||
CreateComputePipeline(FFX_OPTICALFLOW_PASS_GENERATE_OPTICAL_FLOW_INPUT_PYRAMID, L"Opticalflow_InputPyramid", & context->pipelineGenerateOpticalFlowInputPyramid);
|
||||
pipelineDescription.rootConstantBufferCount = 1;
|
||||
CreateComputePipeline(FFX_OPTICALFLOW_PASS_PREPARE_LUMA, L"Opticalflow_Luma", &context->pipelinePrepareLuma);
|
||||
CreateComputePipeline(FFX_OPTICALFLOW_PASS_GENERATE_SCD_HISTOGRAM, L"Opticalflow_SCD_Histogram", &context->pipelineGenerateSCDHistogram);
|
||||
CreateComputePipeline(FFX_OPTICALFLOW_PASS_COMPUTE_SCD_DIVERGENCE, L"Opticalflow_SCD_Divergence", &context->pipelineComputeSCDDivergence);
|
||||
CreateComputePipeline(FFX_OPTICALFLOW_PASS_COMPUTE_OPTICAL_FLOW_ADVANCED_V5, L"Opticalflow_Search", &context->pipelineComputeOpticalFlowAdvancedV5);
|
||||
CreateComputePipeline(FFX_OPTICALFLOW_PASS_FILTER_OPTICAL_FLOW_V5, L"Opticalflow_Filter", &context->pipelineFilterOpticalFlowV5);
|
||||
CreateComputePipeline(FFX_OPTICALFLOW_PASS_SCALE_OPTICAL_FLOW_ADVANCED_V5, L"Opticalflow_Upscale", &context->pipelineScaleOpticalFlowAdvancedV5);
|
||||
|
||||
return FFX_OK;
|
||||
}
|
||||
|
||||
constexpr uint32_t OpticalFlowMaxPyramidLevels = 7;
|
||||
constexpr uint32_t HistogramBins = 256;
|
||||
constexpr uint32_t HistogramsPerDim = 3;
|
||||
constexpr uint32_t HistogramShifts = 3;
|
||||
|
||||
static FfxDimensions2D GetOpticalFlowTextureSize(const FfxDimensions2D& displaySize, const uint32_t opticalFlowBlockSize)
|
||||
{
|
||||
uint32_t width = (displaySize.width + opticalFlowBlockSize - 1) / opticalFlowBlockSize;
|
||||
uint32_t height = (displaySize.height + opticalFlowBlockSize - 1) / opticalFlowBlockSize;
|
||||
return { width, height };
|
||||
}
|
||||
|
||||
static FfxDimensions2D GetOpticalFlowHistogramSize(int level)
|
||||
{
|
||||
const uint32_t searchRadius = 8;
|
||||
uint32_t maxVelocity = searchRadius * (1 << (OpticalFlowMaxPyramidLevels - 1 - level));
|
||||
uint32_t binsPerDimension = 2 * maxVelocity + 1;
|
||||
return { binsPerDimension, binsPerDimension };
|
||||
}
|
||||
|
||||
static FfxDimensions2D GetGlobalMotionSearchDispatchSize(int level)
|
||||
{
|
||||
const uint32_t threadGroupSizeX = 16;
|
||||
const uint32_t threadGroupSizeY = 16;
|
||||
const FfxDimensions2D opticalFlowHistogramSize = GetOpticalFlowHistogramSize(level);
|
||||
const uint32_t additionalElementsDueToShiftsX = opticalFlowHistogramSize.width / threadGroupSizeX;
|
||||
const uint32_t additionalElementsDueToShiftsY = opticalFlowHistogramSize.height / threadGroupSizeY;
|
||||
const uint32_t dispatchX = (opticalFlowHistogramSize.width + additionalElementsDueToShiftsX + threadGroupSizeX - 1) / threadGroupSizeX;
|
||||
const uint32_t dispatchY = (opticalFlowHistogramSize.height + additionalElementsDueToShiftsY + threadGroupSizeY - 1) / threadGroupSizeY;
|
||||
return { dispatchX, dispatchY };
|
||||
}
|
||||
|
||||
static uint32_t GetSCDHistogramTextureWidth()
|
||||
{
|
||||
return HistogramBins * (HistogramsPerDim * HistogramsPerDim);
|
||||
}
|
||||
|
||||
static FfxErrorCode opticalflowCreate(FfxOpticalflowContext_Private* context, const FfxOpticalflowContextDescription* contextDescription)
|
||||
{
|
||||
FFX_ASSERT(context);
|
||||
FFX_ASSERT(contextDescription);
|
||||
FfxErrorCode errorCode = FFX_OK;
|
||||
|
||||
memset(context, 0, sizeof(FfxOpticalflowContext_Private));
|
||||
context->device = contextDescription->backendInterface.device;
|
||||
|
||||
memcpy(&context->contextDescription, contextDescription, sizeof(FfxOpticalflowContextDescription));
|
||||
|
||||
// Check version info - make sure we are linked with the right backend version
|
||||
FfxVersionNumber version = context->contextDescription.backendInterface.fpGetSDKVersion(&context->contextDescription.backendInterface);
|
||||
FFX_RETURN_ON_ERROR(version == FFX_SDK_MAKE_VERSION(1, 1, 4), FFX_ERROR_INVALID_VERSION);
|
||||
|
||||
errorCode = context->contextDescription.backendInterface.fpCreateBackendContext(&context->contextDescription.backendInterface, FFX_EFFECT_OPTICALFLOW, nullptr, &context->effectContextId);
|
||||
FFX_RETURN_ON_ERROR(errorCode == FFX_OK, errorCode);
|
||||
|
||||
errorCode = context->contextDescription.backendInterface.fpGetDeviceCapabilities(&context->contextDescription.backendInterface, &context->deviceCapabilities);
|
||||
FFX_RETURN_ON_ERROR(errorCode == FFX_OK, errorCode);
|
||||
|
||||
context->firstExecution = true;
|
||||
context->resourceFrameIndex = 0;
|
||||
|
||||
context->constants.inputLumaResolution[0] = context->contextDescription.resolution.width;
|
||||
context->constants.inputLumaResolution[1] = context->contextDescription.resolution.height;
|
||||
|
||||
FfxDimensions2D opticalFlowInputTextureSize = context->contextDescription.resolution;
|
||||
|
||||
const FfxResourceType texture1dResourceType = (context->contextDescription.flags & FFX_OPTICALFLOW_ENABLE_TEXTURE1D_USAGE) ? FFX_RESOURCE_TYPE_TEXTURE1D : FFX_RESOURCE_TYPE_TEXTURE2D;
|
||||
|
||||
uint32_t minBlockSize = 8;
|
||||
const FfxDimensions2D opticalFlowTextureSize = GetOpticalFlowTextureSize(contextDescription->resolution, minBlockSize);
|
||||
|
||||
const FfxDimensions2D opticalFlowLevel1TextureSize = { FFX_ALIGN_UP(opticalFlowTextureSize.width, 2) / 2, FFX_ALIGN_UP(opticalFlowTextureSize.height, 2) / 2 };
|
||||
const FfxDimensions2D opticalFlowLevel2TextureSize = { FFX_ALIGN_UP(opticalFlowLevel1TextureSize.width, 2) / 2, FFX_ALIGN_UP(opticalFlowLevel1TextureSize.height, 2) / 2 };
|
||||
const FfxDimensions2D opticalFlowLevel3TextureSize = { FFX_ALIGN_UP(opticalFlowLevel2TextureSize.width, 2) / 2, FFX_ALIGN_UP(opticalFlowLevel2TextureSize.height, 2) / 2 };
|
||||
const FfxDimensions2D opticalFlowLevel4TextureSize = { FFX_ALIGN_UP(opticalFlowLevel3TextureSize.width, 2) / 2, FFX_ALIGN_UP(opticalFlowLevel3TextureSize.height, 2) / 2 };
|
||||
const FfxDimensions2D opticalFlowLevel5TextureSize = { FFX_ALIGN_UP(opticalFlowLevel4TextureSize.width, 2) / 2, FFX_ALIGN_UP(opticalFlowLevel4TextureSize.height, 2) / 2 };
|
||||
const FfxDimensions2D opticalFlowLevel6TextureSize = { FFX_ALIGN_UP(opticalFlowLevel5TextureSize.width, 2) / 2, FFX_ALIGN_UP(opticalFlowLevel5TextureSize.height, 2) / 2 };
|
||||
const FfxDimensions2D opticalFlowLevel7TextureSize = { FFX_ALIGN_UP(opticalFlowLevel6TextureSize.width, 2) / 2, FFX_ALIGN_UP(opticalFlowLevel6TextureSize.height, 2) / 2 };
|
||||
|
||||
const FfxDimensions2D opticalFlowHistogramTextureSize = GetOpticalFlowHistogramSize(0);
|
||||
|
||||
const FfxDimensions2D globalMotionSearchMaxDispatchSize = GetGlobalMotionSearchDispatchSize(0);
|
||||
const uint32_t globalMotionSearchTextureWidth = 4 + (globalMotionSearchMaxDispatchSize.width * globalMotionSearchMaxDispatchSize.height);
|
||||
|
||||
const FfxInternalResourceDescription internalSurfaceDesc[] = {
|
||||
{ FFX_OF_RESOURCE_IDENTIFIER_OPTICAL_FLOW_INPUT_1, L"OPTICALFLOW_OpticalFlowInput1", FFX_RESOURCE_TYPE_TEXTURE2D, FFX_RESOURCE_USAGE_UAV,
|
||||
FFX_SURFACE_FORMAT_R8_UINT, opticalFlowInputTextureSize.width, opticalFlowInputTextureSize.height, 1, FFX_RESOURCE_FLAGS_NONE, {FFX_RESOURCE_INIT_DATA_TYPE_UNINITIALIZED} },
|
||||
|
||||
{ FFX_OF_RESOURCE_IDENTIFIER_OPTICAL_FLOW_INPUT_1_LEVEL_1, L"OPTICALFLOW_OpticalFlowInput1Level1", FFX_RESOURCE_TYPE_TEXTURE2D, FFX_RESOURCE_USAGE_UAV,
|
||||
FFX_SURFACE_FORMAT_R8_UINT, opticalFlowInputTextureSize.width >> 1, opticalFlowInputTextureSize.height >> 1, 1, FFX_RESOURCE_FLAGS_NONE, {FFX_RESOURCE_INIT_DATA_TYPE_UNINITIALIZED} },
|
||||
|
||||
{ FFX_OF_RESOURCE_IDENTIFIER_OPTICAL_FLOW_INPUT_1_LEVEL_2, L"OPTICALFLOW_OpticalFlowInput1Level2", FFX_RESOURCE_TYPE_TEXTURE2D, FFX_RESOURCE_USAGE_UAV,
|
||||
FFX_SURFACE_FORMAT_R8_UINT, opticalFlowInputTextureSize.width >> 2, opticalFlowInputTextureSize.height >> 2, 1, FFX_RESOURCE_FLAGS_NONE, {FFX_RESOURCE_INIT_DATA_TYPE_UNINITIALIZED} },
|
||||
|
||||
{ FFX_OF_RESOURCE_IDENTIFIER_OPTICAL_FLOW_INPUT_1_LEVEL_3, L"OPTICALFLOW_OpticalFlowInput1Level3", FFX_RESOURCE_TYPE_TEXTURE2D, FFX_RESOURCE_USAGE_UAV,
|
||||
FFX_SURFACE_FORMAT_R8_UINT, opticalFlowInputTextureSize.width >> 3, opticalFlowInputTextureSize.height >> 3, 1, FFX_RESOURCE_FLAGS_NONE, {FFX_RESOURCE_INIT_DATA_TYPE_UNINITIALIZED} },
|
||||
|
||||
{ FFX_OF_RESOURCE_IDENTIFIER_OPTICAL_FLOW_INPUT_1_LEVEL_4, L"OPTICALFLOW_OpticalFlowInput1Level4", FFX_RESOURCE_TYPE_TEXTURE2D, FFX_RESOURCE_USAGE_UAV,
|
||||
FFX_SURFACE_FORMAT_R8_UINT, opticalFlowInputTextureSize.width >> 4, opticalFlowInputTextureSize.height >> 4, 1, FFX_RESOURCE_FLAGS_NONE, {FFX_RESOURCE_INIT_DATA_TYPE_UNINITIALIZED} },
|
||||
|
||||
{ FFX_OF_RESOURCE_IDENTIFIER_OPTICAL_FLOW_INPUT_1_LEVEL_5, L"OPTICALFLOW_OpticalFlowInput1Level5", FFX_RESOURCE_TYPE_TEXTURE2D, FFX_RESOURCE_USAGE_UAV,
|
||||
FFX_SURFACE_FORMAT_R8_UINT, opticalFlowInputTextureSize.width >> 5, opticalFlowInputTextureSize.height >> 5, 1, FFX_RESOURCE_FLAGS_NONE, {FFX_RESOURCE_INIT_DATA_TYPE_UNINITIALIZED} },
|
||||
|
||||
{ FFX_OF_RESOURCE_IDENTIFIER_OPTICAL_FLOW_INPUT_1_LEVEL_6, L"OPTICALFLOW_OpticalFlowInput1Level6", FFX_RESOURCE_TYPE_TEXTURE2D, FFX_RESOURCE_USAGE_UAV,
|
||||
FFX_SURFACE_FORMAT_R8_UINT, opticalFlowInputTextureSize.width >> 6, opticalFlowInputTextureSize.height >> 6, 1, FFX_RESOURCE_FLAGS_NONE, {FFX_RESOURCE_INIT_DATA_TYPE_UNINITIALIZED} },
|
||||
|
||||
{ FFX_OF_RESOURCE_IDENTIFIER_OPTICAL_FLOW_INPUT_2, L"OPTICALFLOW_OpticalFlowInput2", FFX_RESOURCE_TYPE_TEXTURE2D, FFX_RESOURCE_USAGE_UAV,
|
||||
FFX_SURFACE_FORMAT_R8_UINT, opticalFlowInputTextureSize.width, opticalFlowInputTextureSize.height, 1, FFX_RESOURCE_FLAGS_NONE, {FFX_RESOURCE_INIT_DATA_TYPE_UNINITIALIZED} },
|
||||
|
||||
{ FFX_OF_RESOURCE_IDENTIFIER_OPTICAL_FLOW_INPUT_2_LEVEL_1, L"OPTICALFLOW_OpticalFlowInput2Level1", FFX_RESOURCE_TYPE_TEXTURE2D, FFX_RESOURCE_USAGE_UAV,
|
||||
FFX_SURFACE_FORMAT_R8_UINT, opticalFlowInputTextureSize.width >> 1, opticalFlowInputTextureSize.height >> 1, 1, FFX_RESOURCE_FLAGS_NONE, {FFX_RESOURCE_INIT_DATA_TYPE_UNINITIALIZED} },
|
||||
|
||||
{ FFX_OF_RESOURCE_IDENTIFIER_OPTICAL_FLOW_INPUT_2_LEVEL_2, L"OPTICALFLOW_OpticalFlowInput2Level2", FFX_RESOURCE_TYPE_TEXTURE2D, FFX_RESOURCE_USAGE_UAV,
|
||||
FFX_SURFACE_FORMAT_R8_UINT, opticalFlowInputTextureSize.width >> 2, opticalFlowInputTextureSize.height >> 2, 1, FFX_RESOURCE_FLAGS_NONE, {FFX_RESOURCE_INIT_DATA_TYPE_UNINITIALIZED} },
|
||||
|
||||
{ FFX_OF_RESOURCE_IDENTIFIER_OPTICAL_FLOW_INPUT_2_LEVEL_3, L"OPTICALFLOW_OpticalFlowInput2Level3", FFX_RESOURCE_TYPE_TEXTURE2D, FFX_RESOURCE_USAGE_UAV,
|
||||
FFX_SURFACE_FORMAT_R8_UINT, opticalFlowInputTextureSize.width >> 3, opticalFlowInputTextureSize.height >> 3, 1, FFX_RESOURCE_FLAGS_NONE, {FFX_RESOURCE_INIT_DATA_TYPE_UNINITIALIZED} },
|
||||
|
||||
{ FFX_OF_RESOURCE_IDENTIFIER_OPTICAL_FLOW_INPUT_2_LEVEL_4, L"OPTICALFLOW_OpticalFlowInput2Level4", FFX_RESOURCE_TYPE_TEXTURE2D, FFX_RESOURCE_USAGE_UAV,
|
||||
FFX_SURFACE_FORMAT_R8_UINT, opticalFlowInputTextureSize.width >> 4, opticalFlowInputTextureSize.height >> 4, 1, FFX_RESOURCE_FLAGS_NONE, {FFX_RESOURCE_INIT_DATA_TYPE_UNINITIALIZED} },
|
||||
|
||||
{ FFX_OF_RESOURCE_IDENTIFIER_OPTICAL_FLOW_INPUT_2_LEVEL_5, L"OPTICALFLOW_OpticalFlowInput2Level5", FFX_RESOURCE_TYPE_TEXTURE2D, FFX_RESOURCE_USAGE_UAV,
|
||||
FFX_SURFACE_FORMAT_R8_UINT, opticalFlowInputTextureSize.width >> 5, opticalFlowInputTextureSize.height >> 5, 1, FFX_RESOURCE_FLAGS_NONE, {FFX_RESOURCE_INIT_DATA_TYPE_UNINITIALIZED} },
|
||||
|
||||
{ FFX_OF_RESOURCE_IDENTIFIER_OPTICAL_FLOW_INPUT_2_LEVEL_6, L"OPTICALFLOW_OpticalFlowInput2Level6", FFX_RESOURCE_TYPE_TEXTURE2D, FFX_RESOURCE_USAGE_UAV,
|
||||
FFX_SURFACE_FORMAT_R8_UINT, opticalFlowInputTextureSize.width >> 6, opticalFlowInputTextureSize.height >> 6, 1, FFX_RESOURCE_FLAGS_NONE, {FFX_RESOURCE_INIT_DATA_TYPE_UNINITIALIZED} },
|
||||
|
||||
{ FFX_OF_RESOURCE_IDENTIFIER_OPTICAL_FLOW_1, L"OPTICALFLOW_OpticalFlow1", FFX_RESOURCE_TYPE_TEXTURE2D, FFX_RESOURCE_USAGE_UAV,
|
||||
FFX_SURFACE_FORMAT_R16G16_SINT, opticalFlowTextureSize.width, opticalFlowTextureSize.height, 1, FFX_RESOURCE_FLAGS_NONE, {FFX_RESOURCE_INIT_DATA_TYPE_UNINITIALIZED} },
|
||||
|
||||
{ FFX_OF_RESOURCE_IDENTIFIER_OPTICAL_FLOW_1_LEVEL_1, L"OPTICALFLOW_OpticalFlow1Level1", FFX_RESOURCE_TYPE_TEXTURE2D, FFX_RESOURCE_USAGE_UAV,
|
||||
FFX_SURFACE_FORMAT_R16G16_SINT, opticalFlowLevel1TextureSize.width, opticalFlowLevel1TextureSize.height, 1, FFX_RESOURCE_FLAGS_NONE, {FFX_RESOURCE_INIT_DATA_TYPE_UNINITIALIZED} },
|
||||
|
||||
{ FFX_OF_RESOURCE_IDENTIFIER_OPTICAL_FLOW_1_LEVEL_2, L"OPTICALFLOW_OpticalFlow1Level2", FFX_RESOURCE_TYPE_TEXTURE2D, FFX_RESOURCE_USAGE_UAV,
|
||||
FFX_SURFACE_FORMAT_R16G16_SINT, opticalFlowLevel2TextureSize.width, opticalFlowLevel2TextureSize.height, 1, FFX_RESOURCE_FLAGS_NONE, {FFX_RESOURCE_INIT_DATA_TYPE_UNINITIALIZED} },
|
||||
|
||||
{ FFX_OF_RESOURCE_IDENTIFIER_OPTICAL_FLOW_1_LEVEL_3, L"OPTICALFLOW_OpticalFlow1Level3", FFX_RESOURCE_TYPE_TEXTURE2D, FFX_RESOURCE_USAGE_UAV,
|
||||
FFX_SURFACE_FORMAT_R16G16_SINT, opticalFlowLevel3TextureSize.width, opticalFlowLevel3TextureSize.height, 1, FFX_RESOURCE_FLAGS_NONE, {FFX_RESOURCE_INIT_DATA_TYPE_UNINITIALIZED} },
|
||||
|
||||
{ FFX_OF_RESOURCE_IDENTIFIER_OPTICAL_FLOW_1_LEVEL_4, L"OPTICALFLOW_OpticalFlow1Level4", FFX_RESOURCE_TYPE_TEXTURE2D, FFX_RESOURCE_USAGE_UAV,
|
||||
FFX_SURFACE_FORMAT_R16G16_SINT, opticalFlowLevel4TextureSize.width, opticalFlowLevel4TextureSize.height, 1, FFX_RESOURCE_FLAGS_NONE, {FFX_RESOURCE_INIT_DATA_TYPE_UNINITIALIZED} },
|
||||
|
||||
{ FFX_OF_RESOURCE_IDENTIFIER_OPTICAL_FLOW_1_LEVEL_5, L"OPTICALFLOW_OpticalFlow1Level5", FFX_RESOURCE_TYPE_TEXTURE2D, FFX_RESOURCE_USAGE_UAV,
|
||||
FFX_SURFACE_FORMAT_R16G16_SINT, opticalFlowLevel5TextureSize.width, opticalFlowLevel5TextureSize.height, 1, FFX_RESOURCE_FLAGS_NONE, {FFX_RESOURCE_INIT_DATA_TYPE_UNINITIALIZED} },
|
||||
|
||||
{ FFX_OF_RESOURCE_IDENTIFIER_OPTICAL_FLOW_1_LEVEL_6, L"OPTICALFLOW_OpticalFlow1Level6", FFX_RESOURCE_TYPE_TEXTURE2D, FFX_RESOURCE_USAGE_UAV,
|
||||
FFX_SURFACE_FORMAT_R16G16_SINT, opticalFlowLevel6TextureSize.width, opticalFlowLevel6TextureSize.height, 1, FFX_RESOURCE_FLAGS_NONE, {FFX_RESOURCE_INIT_DATA_TYPE_UNINITIALIZED} },
|
||||
|
||||
{ FFX_OF_RESOURCE_IDENTIFIER_OPTICAL_FLOW_2, L"OPTICALFLOW_OpticalFlow2", FFX_RESOURCE_TYPE_TEXTURE2D, FFX_RESOURCE_USAGE_UAV,
|
||||
FFX_SURFACE_FORMAT_R16G16_SINT, opticalFlowTextureSize.width, opticalFlowTextureSize.height, 1, FFX_RESOURCE_FLAGS_NONE, {FFX_RESOURCE_INIT_DATA_TYPE_UNINITIALIZED} },
|
||||
|
||||
{ FFX_OF_RESOURCE_IDENTIFIER_OPTICAL_FLOW_2_LEVEL_1, L"OPTICALFLOW_OpticalFlow2Level1", FFX_RESOURCE_TYPE_TEXTURE2D, FFX_RESOURCE_USAGE_UAV,
|
||||
FFX_SURFACE_FORMAT_R16G16_SINT, opticalFlowLevel1TextureSize.width, opticalFlowLevel1TextureSize.height, 1, FFX_RESOURCE_FLAGS_NONE, {FFX_RESOURCE_INIT_DATA_TYPE_UNINITIALIZED} },
|
||||
|
||||
{ FFX_OF_RESOURCE_IDENTIFIER_OPTICAL_FLOW_2_LEVEL_2, L"OPTICALFLOW_OpticalFlow2Level2", FFX_RESOURCE_TYPE_TEXTURE2D, FFX_RESOURCE_USAGE_UAV,
|
||||
FFX_SURFACE_FORMAT_R16G16_SINT, opticalFlowLevel2TextureSize.width, opticalFlowLevel2TextureSize.height, 1, FFX_RESOURCE_FLAGS_NONE, {FFX_RESOURCE_INIT_DATA_TYPE_UNINITIALIZED} },
|
||||
|
||||
{ FFX_OF_RESOURCE_IDENTIFIER_OPTICAL_FLOW_2_LEVEL_3, L"OPTICALFLOW_OpticalFlow2Level3", FFX_RESOURCE_TYPE_TEXTURE2D, FFX_RESOURCE_USAGE_UAV,
|
||||
FFX_SURFACE_FORMAT_R16G16_SINT, opticalFlowLevel3TextureSize.width, opticalFlowLevel3TextureSize.height, 1, FFX_RESOURCE_FLAGS_NONE, {FFX_RESOURCE_INIT_DATA_TYPE_UNINITIALIZED} },
|
||||
|
||||
{ FFX_OF_RESOURCE_IDENTIFIER_OPTICAL_FLOW_2_LEVEL_4, L"OPTICALFLOW_OpticalFlow2Level4", FFX_RESOURCE_TYPE_TEXTURE2D, FFX_RESOURCE_USAGE_UAV,
|
||||
FFX_SURFACE_FORMAT_R16G16_SINT, opticalFlowLevel4TextureSize.width, opticalFlowLevel4TextureSize.height, 1, FFX_RESOURCE_FLAGS_NONE, {FFX_RESOURCE_INIT_DATA_TYPE_UNINITIALIZED} },
|
||||
|
||||
{ FFX_OF_RESOURCE_IDENTIFIER_OPTICAL_FLOW_2_LEVEL_5, L"OPTICALFLOW_OpticalFlow2Level5", FFX_RESOURCE_TYPE_TEXTURE2D, FFX_RESOURCE_USAGE_UAV,
|
||||
FFX_SURFACE_FORMAT_R16G16_SINT, opticalFlowLevel5TextureSize.width, opticalFlowLevel5TextureSize.height, 1, FFX_RESOURCE_FLAGS_NONE, {FFX_RESOURCE_INIT_DATA_TYPE_UNINITIALIZED} },
|
||||
|
||||
{ FFX_OF_RESOURCE_IDENTIFIER_OPTICAL_FLOW_2_LEVEL_6, L"OPTICALFLOW_OpticalFlow2Level6", FFX_RESOURCE_TYPE_TEXTURE2D, FFX_RESOURCE_USAGE_UAV,
|
||||
FFX_SURFACE_FORMAT_R16G16_SINT, opticalFlowLevel6TextureSize.width, opticalFlowLevel6TextureSize.height, 1, FFX_RESOURCE_FLAGS_NONE, {FFX_RESOURCE_INIT_DATA_TYPE_UNINITIALIZED} },
|
||||
|
||||
{ FFX_OF_RESOURCE_IDENTIFIER_OPTICAL_FLOW_SCD_HISTOGRAM, L"OPTICALFLOW_OpticalFlowSCDHistogram", FFX_RESOURCE_TYPE_TEXTURE2D, FFX_RESOURCE_USAGE_UAV,
|
||||
FFX_SURFACE_FORMAT_R32_UINT, GetSCDHistogramTextureWidth(), 1, 1, FFX_RESOURCE_FLAGS_NONE, {FFX_RESOURCE_INIT_DATA_TYPE_UNINITIALIZED} },
|
||||
|
||||
{ FFX_OF_RESOURCE_IDENTIFIER_OPTICAL_FLOW_SCD_PREVIOUS_HISTOGRAM, L"OPTICALFLOW_OpticalFlowSCDPreviousHistogram", FFX_RESOURCE_TYPE_TEXTURE2D, FFX_RESOURCE_USAGE_UAV,
|
||||
FFX_SURFACE_FORMAT_R32_FLOAT, GetSCDHistogramTextureWidth(), 1, 1, FFX_RESOURCE_FLAGS_NONE, {FFX_RESOURCE_INIT_DATA_TYPE_UNINITIALIZED} },
|
||||
|
||||
{ FFX_OF_RESOURCE_IDENTIFIER_OPTICAL_FLOW_SCD_TEMP, L"OPTICALFLOW_OpticalFlowSCDTemp", FFX_RESOURCE_TYPE_TEXTURE2D, FFX_RESOURCE_USAGE_UAV,
|
||||
FFX_SURFACE_FORMAT_R32_UINT, 3, 1, 1, FFX_RESOURCE_FLAGS_NONE, {FFX_RESOURCE_INIT_DATA_TYPE_UNINITIALIZED} },
|
||||
};
|
||||
|
||||
memset(context->resources, 0, sizeof(context->resources));
|
||||
|
||||
for (int32_t currentSurfaceIndex = 0; currentSurfaceIndex < FFX_ARRAY_ELEMENTS(internalSurfaceDesc); ++currentSurfaceIndex) {
|
||||
|
||||
const FfxInternalResourceDescription* currentSurfaceDescription = &internalSurfaceDesc[currentSurfaceIndex];
|
||||
const FfxResourceType resourceType = currentSurfaceDescription->height > 1 ? FFX_RESOURCE_TYPE_TEXTURE2D : texture1dResourceType;
|
||||
const FfxResourceDescription resourceDescription = {
|
||||
resourceType, currentSurfaceDescription->format,
|
||||
currentSurfaceDescription->width, currentSurfaceDescription->height, 1,
|
||||
currentSurfaceDescription->mipCount, FFX_RESOURCE_FLAGS_NONE, currentSurfaceDescription->usage };
|
||||
const FfxResourceStates initialState = FFX_RESOURCE_STATE_UNORDERED_ACCESS;
|
||||
const FfxCreateResourceDescription createResourceDescription = {
|
||||
FFX_HEAP_TYPE_DEFAULT, resourceDescription, initialState, currentSurfaceDescription->name, currentSurfaceDescription->id, currentSurfaceDescription->initData };
|
||||
|
||||
FFX_VALIDATE(context->contextDescription.backendInterface.fpCreateResource(
|
||||
&context->contextDescription.backendInterface,
|
||||
&createResourceDescription,
|
||||
context->effectContextId,
|
||||
&context->resources[currentSurfaceDescription->id]));
|
||||
}
|
||||
|
||||
memset(context->srvBindings, 0, sizeof(context->srvBindings));
|
||||
memset(context->uavBindings, 0, sizeof(context->uavBindings));
|
||||
|
||||
{
|
||||
context->refreshPipelineStates = false;
|
||||
errorCode = createPipelineStates(context);
|
||||
FFX_RETURN_ON_ERROR(errorCode == FFX_OK, errorCode);
|
||||
}
|
||||
|
||||
return FFX_OK;
|
||||
}
|
||||
|
||||
static FfxErrorCode opticalflowRelease(FfxOpticalflowContext_Private* context)
|
||||
{
|
||||
FFX_ASSERT(context);
|
||||
|
||||
ffxSafeReleasePipeline(&context->contextDescription.backendInterface, &context->pipelinePrepareLuma, context->effectContextId);
|
||||
ffxSafeReleasePipeline(&context->contextDescription.backendInterface, &context->pipelineGenerateOpticalFlowInputPyramid, context->effectContextId);
|
||||
ffxSafeReleasePipeline(&context->contextDescription.backendInterface, &context->pipelineGenerateSCDHistogram, context->effectContextId);
|
||||
ffxSafeReleasePipeline(&context->contextDescription.backendInterface, &context->pipelineComputeSCDDivergence, context->effectContextId);
|
||||
ffxSafeReleasePipeline(&context->contextDescription.backendInterface, &context->pipelineComputeOpticalFlowAdvancedV5, context->effectContextId);
|
||||
ffxSafeReleasePipeline(&context->contextDescription.backendInterface, &context->pipelineFilterOpticalFlowV5, context->effectContextId);
|
||||
ffxSafeReleasePipeline(&context->contextDescription.backendInterface, &context->pipelineScaleOpticalFlowAdvancedV5, context->effectContextId);
|
||||
|
||||
for (int32_t currentResourceIndex = 0; currentResourceIndex < FFX_OF_RESOURCE_IDENTIFIER_COUNT; ++currentResourceIndex) {
|
||||
|
||||
ffxSafeReleaseResource(&context->contextDescription.backendInterface, context->resources[currentResourceIndex], context->effectContextId);
|
||||
}
|
||||
|
||||
context->contextDescription.backendInterface.fpDestroyBackendContext(&context->contextDescription.backendInterface, context->effectContextId);
|
||||
|
||||
return FFX_OK;
|
||||
}
|
||||
|
||||
static void scheduleDispatch(FfxOpticalflowContext_Private* context, const FfxPipelineState* pipeline, const wchar_t* pipelineName, uint32_t dispatchX, uint32_t dispatchY, uint32_t dispatchZ = 1)
|
||||
{
|
||||
FfxComputeJobDescription jobDescriptor = {};
|
||||
|
||||
for (uint32_t currentShaderResourceViewIndex = 0; currentShaderResourceViewIndex < pipeline->srvTextureCount; ++currentShaderResourceViewIndex) {
|
||||
|
||||
const uint32_t bindingIdentifier = pipeline->srvTextureBindings[currentShaderResourceViewIndex].resourceIdentifier;
|
||||
const FfxResourceInternal currentResource = context->srvBindings[bindingIdentifier];
|
||||
jobDescriptor.srvTextures[currentShaderResourceViewIndex].resource = currentResource;
|
||||
#ifdef FFX_DEBUG
|
||||
wcscpy_s(jobDescriptor.srvTextures[currentShaderResourceViewIndex].name, pipeline->srvTextureBindings[currentShaderResourceViewIndex].name);
|
||||
#endif
|
||||
|
||||
FFX_ASSERT(bindingIdentifier != FFX_OF_BINDING_IDENTIFIER_NULL);
|
||||
FFX_ASSERT(bindingIdentifier < FFX_OF_BINDING_IDENTIFIER_COUNT);
|
||||
}
|
||||
|
||||
for (uint32_t currentUnorderedAccessViewIndex = 0; currentUnorderedAccessViewIndex < pipeline->uavTextureCount; ++currentUnorderedAccessViewIndex) {
|
||||
|
||||
const uint32_t bindingIdentifier = pipeline->uavTextureBindings[currentUnorderedAccessViewIndex].resourceIdentifier;
|
||||
const FfxResourceInternal currentResource = context->uavBindings[bindingIdentifier];
|
||||
jobDescriptor.uavTextures[currentUnorderedAccessViewIndex].resource = currentResource;
|
||||
jobDescriptor.uavTextures[currentUnorderedAccessViewIndex].mip = 0;
|
||||
#ifdef FFX_DEBUG
|
||||
wcscpy_s(jobDescriptor.uavTextures[currentUnorderedAccessViewIndex].name, pipeline->uavTextureBindings[currentUnorderedAccessViewIndex].name);
|
||||
#endif
|
||||
|
||||
FFX_ASSERT(bindingIdentifier != FFX_OF_BINDING_IDENTIFIER_NULL);
|
||||
FFX_ASSERT(bindingIdentifier < FFX_OF_BINDING_IDENTIFIER_COUNT);
|
||||
}
|
||||
|
||||
jobDescriptor.dimensions[0] = dispatchX;
|
||||
jobDescriptor.dimensions[1] = dispatchY;
|
||||
jobDescriptor.dimensions[2] = dispatchZ;
|
||||
jobDescriptor.pipeline = *pipeline;
|
||||
|
||||
for (uint32_t currentRootConstantIndex = 0; currentRootConstantIndex < pipeline->constCount; ++currentRootConstantIndex) {
|
||||
#ifdef FFX_DEBUG
|
||||
wcscpy_s(jobDescriptor.cbNames[currentRootConstantIndex], pipeline->constantBufferBindings[currentRootConstantIndex].name);
|
||||
#endif
|
||||
jobDescriptor.cbs[currentRootConstantIndex] = context->constantBuffers[pipeline->constantBufferBindings[currentRootConstantIndex].resourceIdentifier];
|
||||
}
|
||||
|
||||
FfxGpuJobDescription dispatchJob = { FFX_GPU_JOB_COMPUTE };
|
||||
wcscpy_s(dispatchJob.jobLabel, pipelineName);
|
||||
dispatchJob.computeJobDescriptor = jobDescriptor;
|
||||
|
||||
context->contextDescription.backendInterface.fpScheduleGpuJob(&context->contextDescription.backendInterface, &dispatchJob);
|
||||
}
|
||||
|
||||
static FfxErrorCode dispatch(FfxOpticalflowContext_Private* context, const FfxOpticalflowDispatchDescription* params)
|
||||
{
|
||||
context->contextDescription.backendInterface.fpRegisterResource(
|
||||
&context->contextDescription.backendInterface,
|
||||
¶ms->opticalFlowVector,
|
||||
context->effectContextId,
|
||||
&context->uavBindings[FFX_OF_BINDING_IDENTIFIER_SHARED_OPTICAL_FLOW_VECTOR]);
|
||||
context->contextDescription.backendInterface.fpRegisterResource(
|
||||
&context->contextDescription.backendInterface,
|
||||
¶ms->opticalFlowSCD,
|
||||
context->effectContextId,
|
||||
&context->uavBindings[FFX_OF_BINDING_IDENTIFIER_SHARED_OPTICAL_FLOW_SCD_OUTPUT]);
|
||||
|
||||
context->contextDescription.backendInterface.fpRegisterResource(
|
||||
&context->contextDescription.backendInterface,
|
||||
¶ms->color,
|
||||
context->effectContextId,
|
||||
&context->srvBindings[FFX_OF_BINDING_IDENTIFIER_INPUT_COLOR]);
|
||||
|
||||
FfxCommandList commandList = params->commandList;
|
||||
int advancedAlgorithmIterations = 7;
|
||||
uint32_t opticalFlowBlockSize = 8;
|
||||
|
||||
if (context->refreshPipelineStates) {
|
||||
|
||||
context->refreshPipelineStates = false;
|
||||
|
||||
const FfxErrorCode errorCode = createPipelineStates(context);
|
||||
FFX_RETURN_ON_ERROR(errorCode == FFX_OK, errorCode);
|
||||
}
|
||||
|
||||
const FfxResourceDescription resourceDescInputColor = context->contextDescription.backendInterface.fpGetResourceDescription(
|
||||
&context->contextDescription.backendInterface,
|
||||
context->srvBindings[FFX_OF_BINDING_IDENTIFIER_INPUT_COLOR]);
|
||||
FFX_ASSERT(resourceDescInputColor.type == FFX_RESOURCE_TYPE_TEXTURE2D);
|
||||
|
||||
context->constants.backbufferTransferFunction = params->backbufferTransferFunction;
|
||||
context->constants.minMaxLuminance[0] = params->minMaxLuminance.x;
|
||||
context->constants.minMaxLuminance[1] = params->minMaxLuminance.y;
|
||||
|
||||
const bool resetAccumulation = params->reset || context->firstExecution;
|
||||
context->firstExecution = false;
|
||||
|
||||
if (resetAccumulation) {
|
||||
context->constants.frameIndex = 0;
|
||||
}
|
||||
else {
|
||||
context->constants.frameIndex++;
|
||||
}
|
||||
|
||||
if (resetAccumulation)
|
||||
{
|
||||
const float clearValuesToZeroFloat[]{ 0.f, 0.f, 0.f, 0.f };
|
||||
FfxGpuJobDescription clearJob = { FFX_GPU_JOB_CLEAR_FLOAT };
|
||||
memcpy(clearJob.clearJobDescriptor.color, clearValuesToZeroFloat, 4 * sizeof(float));
|
||||
|
||||
wcscpy_s(clearJob.jobLabel, L"Clear Optical Flow SCD Temp");
|
||||
clearJob.clearJobDescriptor.target = context->resources[FFX_OF_RESOURCE_IDENTIFIER_OPTICAL_FLOW_SCD_TEMP];
|
||||
context->contextDescription.backendInterface.fpScheduleGpuJob(&context->contextDescription.backendInterface, &clearJob);
|
||||
clearJob.clearJobDescriptor.target = context->uavBindings[FFX_OF_BINDING_IDENTIFIER_SHARED_OPTICAL_FLOW_SCD_OUTPUT];
|
||||
context->contextDescription.backendInterface.fpScheduleGpuJob(&context->contextDescription.backendInterface, &clearJob);
|
||||
wcscpy_s(clearJob.jobLabel, L"Clear Optical Flow SCD Histogram");
|
||||
clearJob.clearJobDescriptor.target = context->resources[FFX_OF_RESOURCE_IDENTIFIER_OPTICAL_FLOW_SCD_HISTOGRAM];
|
||||
context->contextDescription.backendInterface.fpScheduleGpuJob(&context->contextDescription.backendInterface, &clearJob);
|
||||
wcscpy_s(clearJob.jobLabel, L"Clear Optical Flow SCD Previous histogram");
|
||||
clearJob.clearJobDescriptor.target = context->resources[FFX_OF_RESOURCE_IDENTIFIER_OPTICAL_FLOW_SCD_PREVIOUS_HISTOGRAM];
|
||||
context->contextDescription.backendInterface.fpScheduleGpuJob(&context->contextDescription.backendInterface, &clearJob);
|
||||
wcscpy_s(clearJob.jobLabel, L"Clear Optical Flow Input 1");
|
||||
clearJob.clearJobDescriptor.target = context->resources[FFX_OF_RESOURCE_IDENTIFIER_OPTICAL_FLOW_INPUT_1];
|
||||
context->contextDescription.backendInterface.fpScheduleGpuJob(&context->contextDescription.backendInterface, &clearJob);
|
||||
wcscpy_s(clearJob.jobLabel, L"Clear Optical Flow Input 1 Level 1");
|
||||
clearJob.clearJobDescriptor.target = context->resources[FFX_OF_RESOURCE_IDENTIFIER_OPTICAL_FLOW_INPUT_1_LEVEL_1];
|
||||
context->contextDescription.backendInterface.fpScheduleGpuJob(&context->contextDescription.backendInterface, &clearJob);
|
||||
wcscpy_s(clearJob.jobLabel, L"Clear Optical Flow Input 1 Level 2");
|
||||
clearJob.clearJobDescriptor.target = context->resources[FFX_OF_RESOURCE_IDENTIFIER_OPTICAL_FLOW_INPUT_1_LEVEL_2];
|
||||
context->contextDescription.backendInterface.fpScheduleGpuJob(&context->contextDescription.backendInterface, &clearJob);
|
||||
wcscpy_s(clearJob.jobLabel, L"Clear Optical Flow Input 1 Level 3");
|
||||
clearJob.clearJobDescriptor.target = context->resources[FFX_OF_RESOURCE_IDENTIFIER_OPTICAL_FLOW_INPUT_1_LEVEL_3];
|
||||
context->contextDescription.backendInterface.fpScheduleGpuJob(&context->contextDescription.backendInterface, &clearJob);
|
||||
wcscpy_s(clearJob.jobLabel, L"Clear Optical Flow Input 1 Level 4");
|
||||
clearJob.clearJobDescriptor.target = context->resources[FFX_OF_RESOURCE_IDENTIFIER_OPTICAL_FLOW_INPUT_1_LEVEL_4];
|
||||
context->contextDescription.backendInterface.fpScheduleGpuJob(&context->contextDescription.backendInterface, &clearJob);
|
||||
wcscpy_s(clearJob.jobLabel, L"Clear Optical Flow Input 1 Level 5");
|
||||
clearJob.clearJobDescriptor.target = context->resources[FFX_OF_RESOURCE_IDENTIFIER_OPTICAL_FLOW_INPUT_1_LEVEL_5];
|
||||
context->contextDescription.backendInterface.fpScheduleGpuJob(&context->contextDescription.backendInterface, &clearJob);
|
||||
wcscpy_s(clearJob.jobLabel, L"Clear Optical Flow Input 1 Level 6");
|
||||
clearJob.clearJobDescriptor.target = context->resources[FFX_OF_RESOURCE_IDENTIFIER_OPTICAL_FLOW_INPUT_1_LEVEL_6];
|
||||
context->contextDescription.backendInterface.fpScheduleGpuJob(&context->contextDescription.backendInterface, &clearJob);
|
||||
wcscpy_s(clearJob.jobLabel, L"Clear Optical Flow Input 2");
|
||||
clearJob.clearJobDescriptor.target = context->resources[FFX_OF_RESOURCE_IDENTIFIER_OPTICAL_FLOW_INPUT_2];
|
||||
context->contextDescription.backendInterface.fpScheduleGpuJob(&context->contextDescription.backendInterface, &clearJob);
|
||||
wcscpy_s(clearJob.jobLabel, L"Clear Optical Flow Input 2 Level 1");
|
||||
clearJob.clearJobDescriptor.target = context->resources[FFX_OF_RESOURCE_IDENTIFIER_OPTICAL_FLOW_INPUT_2_LEVEL_1];
|
||||
context->contextDescription.backendInterface.fpScheduleGpuJob(&context->contextDescription.backendInterface, &clearJob);
|
||||
wcscpy_s(clearJob.jobLabel, L"Clear Optical Flow Input 2 Level 2");
|
||||
clearJob.clearJobDescriptor.target = context->resources[FFX_OF_RESOURCE_IDENTIFIER_OPTICAL_FLOW_INPUT_2_LEVEL_2];
|
||||
context->contextDescription.backendInterface.fpScheduleGpuJob(&context->contextDescription.backendInterface, &clearJob);
|
||||
wcscpy_s(clearJob.jobLabel, L"Clear Optical Flow Input 2 Level 3");
|
||||
clearJob.clearJobDescriptor.target = context->resources[FFX_OF_RESOURCE_IDENTIFIER_OPTICAL_FLOW_INPUT_2_LEVEL_3];
|
||||
context->contextDescription.backendInterface.fpScheduleGpuJob(&context->contextDescription.backendInterface, &clearJob);
|
||||
wcscpy_s(clearJob.jobLabel, L"Clear Optical Flow Input 2 Level 4");
|
||||
clearJob.clearJobDescriptor.target = context->resources[FFX_OF_RESOURCE_IDENTIFIER_OPTICAL_FLOW_INPUT_2_LEVEL_4];
|
||||
context->contextDescription.backendInterface.fpScheduleGpuJob(&context->contextDescription.backendInterface, &clearJob);
|
||||
wcscpy_s(clearJob.jobLabel, L"Clear Optical Flow Input 2 Level 5");
|
||||
clearJob.clearJobDescriptor.target = context->resources[FFX_OF_RESOURCE_IDENTIFIER_OPTICAL_FLOW_INPUT_2_LEVEL_5];
|
||||
context->contextDescription.backendInterface.fpScheduleGpuJob(&context->contextDescription.backendInterface, &clearJob);
|
||||
wcscpy_s(clearJob.jobLabel, L"Clear Optical Flow Input 2 Level 6");
|
||||
clearJob.clearJobDescriptor.target = context->resources[FFX_OF_RESOURCE_IDENTIFIER_OPTICAL_FLOW_INPUT_2_LEVEL_6];
|
||||
context->contextDescription.backendInterface.fpScheduleGpuJob(&context->contextDescription.backendInterface, &clearJob);
|
||||
}
|
||||
|
||||
uint32_t resolutionMultiplier = 1;
|
||||
|
||||
FfxUInt32x2 threadGroupSizeOpticalFlowInputPyramid;
|
||||
FfxUInt32x2 workGroupOffset;
|
||||
FfxUInt32x2 numWorkGroupsAndMips;
|
||||
FfxUInt32x4 rectInfo = { 0, 0,
|
||||
context->contextDescription.resolution.width * resolutionMultiplier,
|
||||
context->contextDescription.resolution.height * resolutionMultiplier };
|
||||
ffxSpdSetup(threadGroupSizeOpticalFlowInputPyramid, workGroupOffset, numWorkGroupsAndMips, rectInfo, 4);
|
||||
|
||||
OpticalFlowSpdConstants luminancePyramidConstants;
|
||||
luminancePyramidConstants.numworkGroups = numWorkGroupsAndMips[0];
|
||||
luminancePyramidConstants.mips = numWorkGroupsAndMips[1];
|
||||
luminancePyramidConstants.workGroupOffset[0] = workGroupOffset[0];
|
||||
luminancePyramidConstants.workGroupOffset[1] = workGroupOffset[1];
|
||||
luminancePyramidConstants.numworkGroupsOpticalFlowInputPyramid = numWorkGroupsAndMips[0];
|
||||
|
||||
context->contextDescription.backendInterface.fpStageConstantBufferDataFunc(&context->contextDescription.backendInterface, &context->constants, sizeof(context->constants), &context->constantBuffers[FFX_OPTICALFLOW_CONSTANTBUFFER_IDENTIFIER]);
|
||||
context->contextDescription.backendInterface.fpStageConstantBufferDataFunc(&context->contextDescription.backendInterface, &luminancePyramidConstants, sizeof(luminancePyramidConstants), &context->constantBuffers[FFX_OPTICALFLOW_CONSTANTBUFFER_IDENTIFIER_SPD]);
|
||||
|
||||
{
|
||||
context->uavBindings[FFX_OF_BINDING_IDENTIFIER_OPTICAL_FLOW_SCD_HISTOGRAM] = context->resources[FFX_OF_RESOURCE_IDENTIFIER_OPTICAL_FLOW_SCD_HISTOGRAM];
|
||||
context->uavBindings[FFX_OF_BINDING_IDENTIFIER_OPTICAL_FLOW_SCD_PREVIOUS_HISTOGRAM] = context->resources[FFX_OF_RESOURCE_IDENTIFIER_OPTICAL_FLOW_SCD_PREVIOUS_HISTOGRAM];
|
||||
context->uavBindings[FFX_OF_BINDING_IDENTIFIER_OPTICAL_FLOW_SCD_TEMP] = context->resources[FFX_OF_RESOURCE_IDENTIFIER_OPTICAL_FLOW_SCD_TEMP];
|
||||
context->uavBindings[FFX_OF_BINDING_IDENTIFIER_OPTICAL_FLOW_SCD_OUTPUT] = context->uavBindings[FFX_OF_BINDING_IDENTIFIER_SHARED_OPTICAL_FLOW_SCD_OUTPUT];
|
||||
|
||||
const bool isOddFrame = !!(context->resourceFrameIndex & 1);
|
||||
|
||||
uint32_t opticalFlowInputResourceIndex = isOddFrame ? FFX_OF_RESOURCE_IDENTIFIER_OPTICAL_FLOW_INPUT_2 : FFX_OF_RESOURCE_IDENTIFIER_OPTICAL_FLOW_INPUT_1;
|
||||
uint32_t opticalFlowPreviousInputResourceIndex = isOddFrame ? FFX_OF_RESOURCE_IDENTIFIER_OPTICAL_FLOW_INPUT_1 : FFX_OF_RESOURCE_IDENTIFIER_OPTICAL_FLOW_INPUT_2;
|
||||
|
||||
uint32_t opticalFlowResourceIndex = isOddFrame ? FFX_OF_RESOURCE_IDENTIFIER_OPTICAL_FLOW_2 : FFX_OF_RESOURCE_IDENTIFIER_OPTICAL_FLOW_1;
|
||||
uint32_t opticalFlowPreviousResourceIndex = isOddFrame ? FFX_OF_RESOURCE_IDENTIFIER_OPTICAL_FLOW_1 : FFX_OF_RESOURCE_IDENTIFIER_OPTICAL_FLOW_2;
|
||||
|
||||
context->uavBindings[FFX_OF_BINDING_IDENTIFIER_OPTICAL_FLOW_INPUT] = context->resources[opticalFlowInputResourceIndex];
|
||||
context->uavBindings[FFX_OF_BINDING_IDENTIFIER_OPTICAL_FLOW_INPUT_LEVEL_1] = context->resources[opticalFlowInputResourceIndex + 1];
|
||||
context->uavBindings[FFX_OF_BINDING_IDENTIFIER_OPTICAL_FLOW_INPUT_LEVEL_2] = context->resources[opticalFlowInputResourceIndex + 2];
|
||||
context->uavBindings[FFX_OF_BINDING_IDENTIFIER_OPTICAL_FLOW_INPUT_LEVEL_3] = context->resources[opticalFlowInputResourceIndex + 3];
|
||||
context->uavBindings[FFX_OF_BINDING_IDENTIFIER_OPTICAL_FLOW_INPUT_LEVEL_4] = context->resources[opticalFlowInputResourceIndex + 4];
|
||||
context->uavBindings[FFX_OF_BINDING_IDENTIFIER_OPTICAL_FLOW_INPUT_LEVEL_5] = context->resources[opticalFlowInputResourceIndex + 5];
|
||||
context->uavBindings[FFX_OF_BINDING_IDENTIFIER_OPTICAL_FLOW_INPUT_LEVEL_6] = context->resources[opticalFlowInputResourceIndex + 6];
|
||||
|
||||
context->srvBindings[FFX_OF_BINDING_IDENTIFIER_OPTICAL_FLOW_INPUT] = context->resources[opticalFlowInputResourceIndex];
|
||||
context->srvBindings[FFX_OF_BINDING_IDENTIFIER_OPTICAL_FLOW_PREVIOUS_INPUT] = context->resources[opticalFlowPreviousInputResourceIndex];
|
||||
|
||||
context->srvBindings[FFX_OF_BINDING_IDENTIFIER_OPTICAL_FLOW] = context->resources[opticalFlowResourceIndex];
|
||||
context->uavBindings[FFX_OF_BINDING_IDENTIFIER_OPTICAL_FLOW] = context->resources[opticalFlowResourceIndex];
|
||||
context->srvBindings[FFX_OF_BINDING_IDENTIFIER_OPTICAL_FLOW_PREVIOUS] = context->resources[opticalFlowPreviousResourceIndex];
|
||||
|
||||
{
|
||||
int32_t threadGroupSizeX = 16;
|
||||
int32_t threadGroupSizeY = 16;
|
||||
uint32_t threadPixelsX = 2;
|
||||
uint32_t threadPixelsY = 2;
|
||||
int32_t dispatchX = ((context->contextDescription.resolution.width + (threadPixelsX - 1)) / threadPixelsX + (threadGroupSizeX - 1)) / threadGroupSizeX;
|
||||
int32_t dispatchY = ((context->contextDescription.resolution.height + (threadPixelsY - 1)) / threadPixelsY + (threadGroupSizeY - 1)) / threadGroupSizeY;
|
||||
scheduleDispatch(context, &context->pipelinePrepareLuma, L"OF PrepareLuma", dispatchX, dispatchY);
|
||||
}
|
||||
|
||||
{
|
||||
{
|
||||
scheduleDispatch(context,
|
||||
&context->pipelineGenerateOpticalFlowInputPyramid,
|
||||
L"OF GenerateOpticalFlowInputPyramid",
|
||||
threadGroupSizeOpticalFlowInputPyramid[0],
|
||||
threadGroupSizeOpticalFlowInputPyramid[1]
|
||||
);
|
||||
}
|
||||
|
||||
{
|
||||
{
|
||||
const uint32_t threadGroupSizeX = 32;
|
||||
const uint32_t threadGroupSizeY = 8;
|
||||
const uint32_t strataWidth = (context->contextDescription.resolution.width / 4) / HistogramsPerDim;
|
||||
const uint32_t strataHeight = context->contextDescription.resolution.height / HistogramsPerDim;
|
||||
const uint32_t dispatchX = (strataWidth + threadGroupSizeX - 1) / threadGroupSizeX;
|
||||
const uint32_t dispatchY = 16;
|
||||
const uint32_t dispatchZ = HistogramsPerDim * HistogramsPerDim;
|
||||
scheduleDispatch(context, &context->pipelineGenerateSCDHistogram, L"OF GenerateSCDHistogram", dispatchX, dispatchY, dispatchZ);
|
||||
}
|
||||
{
|
||||
const uint32_t dispatchX = HistogramsPerDim * HistogramsPerDim;
|
||||
const uint32_t dispatchY = HistogramShifts;
|
||||
scheduleDispatch(context, &context->pipelineComputeSCDDivergence, L"OF ComputeSCDDivergence", dispatchX, dispatchY);
|
||||
}
|
||||
}
|
||||
|
||||
FfxDimensions2D opticalFlowTextureSizes[OpticalFlowMaxPyramidLevels];
|
||||
const int pyramidMaxIterations = advancedAlgorithmIterations;
|
||||
FFX_ASSERT(pyramidMaxIterations <= OpticalFlowMaxPyramidLevels);
|
||||
|
||||
opticalFlowTextureSizes[0] = GetOpticalFlowTextureSize(context->contextDescription.resolution, opticalFlowBlockSize);
|
||||
for (int i = 1; i < pyramidMaxIterations; i++)
|
||||
{
|
||||
opticalFlowTextureSizes[i] = {
|
||||
(opticalFlowTextureSizes[i - 1].width + 1) / 2,
|
||||
(opticalFlowTextureSizes[i - 1].height + 1) / 2
|
||||
};
|
||||
}
|
||||
|
||||
for (int level = pyramidMaxIterations - 1; level >= 0; level--)
|
||||
{
|
||||
bool isOddLevel = !!(level & 1);
|
||||
|
||||
uint32_t opticalFlowInputResourceIndexA = isOddFrame ? FFX_OF_RESOURCE_IDENTIFIER_OPTICAL_FLOW_INPUT_2 : FFX_OF_RESOURCE_IDENTIFIER_OPTICAL_FLOW_INPUT_1;
|
||||
uint32_t opticalFlowInputResourceIndexB = isOddFrame ? FFX_OF_RESOURCE_IDENTIFIER_OPTICAL_FLOW_INPUT_1 : FFX_OF_RESOURCE_IDENTIFIER_OPTICAL_FLOW_INPUT_2;
|
||||
uint32_t opticalFlowResourceIndexA = (isOddFrame != isOddLevel) ? FFX_OF_RESOURCE_IDENTIFIER_OPTICAL_FLOW_2 : FFX_OF_RESOURCE_IDENTIFIER_OPTICAL_FLOW_1;
|
||||
uint32_t opticalFlowResourceIndexB = (isOddFrame != isOddLevel) ? FFX_OF_RESOURCE_IDENTIFIER_OPTICAL_FLOW_1 : FFX_OF_RESOURCE_IDENTIFIER_OPTICAL_FLOW_2;
|
||||
context->constants.opticalFlowPyramidLevel = level;
|
||||
context->constants.opticalFlowPyramidLevelCount = pyramidMaxIterations;
|
||||
|
||||
context->contextDescription.backendInterface.fpStageConstantBufferDataFunc(&context->contextDescription.backendInterface, &context->constants, sizeof(context->constants), &context->constantBuffers[FFX_OPTICALFLOW_CONSTANTBUFFER_IDENTIFIER]);
|
||||
|
||||
context->srvBindings[FFX_OF_BINDING_IDENTIFIER_OPTICAL_FLOW_INPUT] = context->resources[opticalFlowInputResourceIndexA + level];
|
||||
context->srvBindings[FFX_OF_BINDING_IDENTIFIER_OPTICAL_FLOW_PREVIOUS_INPUT] = context->resources[opticalFlowInputResourceIndexB + level];
|
||||
context->uavBindings[FFX_OF_BINDING_IDENTIFIER_OPTICAL_FLOW] = context->resources[opticalFlowResourceIndexA + level];
|
||||
|
||||
context->srvBindings[FFX_OF_BINDING_IDENTIFIER_OPTICAL_FLOW_PREVIOUS] = context->resources[opticalFlowResourceIndexB + level];
|
||||
|
||||
{
|
||||
const FfxUInt32 inputLumaWidth = ffxMax(context->contextDescription.resolution.width >> level, 1);
|
||||
const FfxUInt32 inputLumaHeight = ffxMax(context->contextDescription.resolution.height >> level, 1);
|
||||
std::wstring pipelineName = L"OF " + std::to_wstring(level) + L" Search";
|
||||
|
||||
{
|
||||
uint32_t threadPixels = 4;
|
||||
FFX_ASSERT(opticalFlowBlockSize >= threadPixels);
|
||||
uint32_t threadGroupSizeY = 16;
|
||||
uint32_t threadGroupSize = 64;
|
||||
uint32_t dispatchX = ((inputLumaWidth + threadPixels - 1) / threadPixels * threadGroupSizeY + (threadGroupSize - 1)) / threadGroupSize;
|
||||
uint32_t dispatchY = (inputLumaHeight + (threadGroupSizeY - 1)) / threadGroupSizeY;
|
||||
scheduleDispatch(context, &context->pipelineComputeOpticalFlowAdvancedV5, pipelineName.c_str(), dispatchX, dispatchY);
|
||||
}
|
||||
}
|
||||
|
||||
{
|
||||
context->srvBindings[FFX_OF_BINDING_IDENTIFIER_OPTICAL_FLOW_PREVIOUS] = context->resources[opticalFlowResourceIndexA + level];
|
||||
context->uavBindings[FFX_OF_BINDING_IDENTIFIER_OPTICAL_FLOW] = context->resources[opticalFlowResourceIndexB + level];
|
||||
}
|
||||
|
||||
{
|
||||
if (level == 0)
|
||||
{
|
||||
context->uavBindings[FFX_OF_BINDING_IDENTIFIER_OPTICAL_FLOW] = context->uavBindings[FFX_OF_BINDING_IDENTIFIER_SHARED_OPTICAL_FLOW_VECTOR];
|
||||
}
|
||||
|
||||
const uint32_t levelWidth = opticalFlowTextureSizes[level].width;
|
||||
const uint32_t levelHeight = opticalFlowTextureSizes[level].height;
|
||||
|
||||
const uint32_t threadGroupSizeX = 16;
|
||||
const uint32_t threadGroupSizeY = 4;
|
||||
const uint32_t dispatchX = (levelWidth + threadGroupSizeX - 1) / threadGroupSizeX;
|
||||
const uint32_t dispatchY = (levelHeight + threadGroupSizeY - 1) / threadGroupSizeY;
|
||||
std::wstring pipelineName = L"OF " + std::to_wstring(level) + L" Filter";
|
||||
|
||||
{
|
||||
scheduleDispatch(context, &context->pipelineFilterOpticalFlowV5, pipelineName.c_str(), dispatchX, dispatchY);
|
||||
}
|
||||
}
|
||||
|
||||
if (level > 0)
|
||||
{
|
||||
context->srvBindings[FFX_OF_BINDING_IDENTIFIER_OPTICAL_FLOW_ALIAS_LEVEL_1 + level - 1] = context->uavBindings[FFX_OF_BINDING_IDENTIFIER_OPTICAL_FLOW];
|
||||
}
|
||||
|
||||
if (level > 0)
|
||||
{
|
||||
{
|
||||
context->srvBindings[FFX_OF_BINDING_IDENTIFIER_OPTICAL_FLOW] = context->resources[opticalFlowResourceIndexB + level];
|
||||
context->uavBindings[FFX_OF_BINDING_IDENTIFIER_OPTICAL_FLOW_NEXT_LEVEL] = level > 0 ? context->resources[opticalFlowResourceIndexB + level - 1] : FfxResourceInternal{ FFX_OF_RESOURCE_IDENTIFIER_NULL };
|
||||
}
|
||||
|
||||
FFX_ASSERT(opticalFlowBlockSize >= 2);
|
||||
const uint32_t nextLevelWidth = opticalFlowTextureSizes[level - 1].width;
|
||||
const uint32_t nextLevelHeight = opticalFlowTextureSizes[level - 1].height;
|
||||
|
||||
const uint32_t threadGroupSizeX = opticalFlowBlockSize / 2;
|
||||
const uint32_t threadGroupSizeY = opticalFlowBlockSize / 2;
|
||||
const uint32_t threadGroupSizeZ = 4;
|
||||
const uint32_t dispatchX = (nextLevelWidth + threadGroupSizeX - 1) / threadGroupSizeX;
|
||||
const uint32_t dispatchY = (nextLevelHeight + threadGroupSizeY - 1) / threadGroupSizeY;
|
||||
const uint32_t dispatchZ = 1;
|
||||
std::wstring pipelineName = L"OF " + std::to_wstring(level) + L" Scale";
|
||||
|
||||
{
|
||||
const uint32_t dispatchX = (nextLevelWidth + 3) / 4;
|
||||
const uint32_t dispatchY = (nextLevelHeight + 3) / 4;
|
||||
scheduleDispatch(context, &context->pipelineScaleOpticalFlowAdvancedV5, pipelineName.c_str(), dispatchX, dispatchY, dispatchZ);
|
||||
}
|
||||
|
||||
{
|
||||
FfxGpuJobDescription barrierJob = {FFX_GPU_JOB_BARRIER};
|
||||
barrierJob.barrierDescriptor = { context->srvBindings[FFX_OF_BINDING_IDENTIFIER_OPTICAL_FLOW], FFX_BARRIER_TYPE_TRANSITION, FFX_RESOURCE_STATE_COMPUTE_READ, FFX_RESOURCE_STATE_UNORDERED_ACCESS, 0};
|
||||
context->contextDescription.backendInterface.fpScheduleGpuJob(&context->contextDescription.backendInterface, &barrierJob);
|
||||
}
|
||||
}
|
||||
|
||||
{
|
||||
FfxGpuJobDescription barrierJob = {FFX_GPU_JOB_BARRIER};
|
||||
barrierJob.barrierDescriptor = { context->srvBindings[FFX_OF_BINDING_IDENTIFIER_OPTICAL_FLOW_PREVIOUS], FFX_BARRIER_TYPE_TRANSITION, FFX_RESOURCE_STATE_COMPUTE_READ, FFX_RESOURCE_STATE_UNORDERED_ACCESS, 0};
|
||||
context->contextDescription.backendInterface.fpScheduleGpuJob(&context->contextDescription.backendInterface, &barrierJob);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
{
|
||||
FfxGpuJobDescription barrierJob = {FFX_GPU_JOB_BARRIER};
|
||||
|
||||
wcscpy_s(barrierJob.jobLabel, L"Transition Optical Flow Input 1");
|
||||
barrierJob.barrierDescriptor = { context->resources[FFX_OF_RESOURCE_IDENTIFIER_OPTICAL_FLOW_INPUT_1], FFX_BARRIER_TYPE_TRANSITION, FFX_RESOURCE_STATE_COMPUTE_READ, FFX_RESOURCE_STATE_UNORDERED_ACCESS, 0};
|
||||
context->contextDescription.backendInterface.fpScheduleGpuJob(&context->contextDescription.backendInterface, &barrierJob);
|
||||
wcscpy_s(barrierJob.jobLabel, L"Transition Optical Flow Input 1 Level 1");
|
||||
barrierJob.barrierDescriptor = { context->resources[FFX_OF_RESOURCE_IDENTIFIER_OPTICAL_FLOW_INPUT_1_LEVEL_1], FFX_BARRIER_TYPE_TRANSITION, FFX_RESOURCE_STATE_COMPUTE_READ, FFX_RESOURCE_STATE_UNORDERED_ACCESS, 0};
|
||||
context->contextDescription.backendInterface.fpScheduleGpuJob(&context->contextDescription.backendInterface, &barrierJob);
|
||||
wcscpy_s(barrierJob.jobLabel, L"Transition Optical Flow Input 1 Level 2");
|
||||
barrierJob.barrierDescriptor = { context->resources[FFX_OF_RESOURCE_IDENTIFIER_OPTICAL_FLOW_INPUT_1_LEVEL_2], FFX_BARRIER_TYPE_TRANSITION, FFX_RESOURCE_STATE_COMPUTE_READ, FFX_RESOURCE_STATE_UNORDERED_ACCESS, 0};
|
||||
context->contextDescription.backendInterface.fpScheduleGpuJob(&context->contextDescription.backendInterface, &barrierJob);
|
||||
wcscpy_s(barrierJob.jobLabel, L"Transition Optical Flow Input 1 Level 3");
|
||||
barrierJob.barrierDescriptor = { context->resources[FFX_OF_RESOURCE_IDENTIFIER_OPTICAL_FLOW_INPUT_1_LEVEL_3], FFX_BARRIER_TYPE_TRANSITION, FFX_RESOURCE_STATE_COMPUTE_READ, FFX_RESOURCE_STATE_UNORDERED_ACCESS, 0};
|
||||
context->contextDescription.backendInterface.fpScheduleGpuJob(&context->contextDescription.backendInterface, &barrierJob);
|
||||
wcscpy_s(barrierJob.jobLabel, L"Transition Optical Flow Input 1 Level 4");
|
||||
barrierJob.barrierDescriptor = { context->resources[FFX_OF_RESOURCE_IDENTIFIER_OPTICAL_FLOW_INPUT_1_LEVEL_4], FFX_BARRIER_TYPE_TRANSITION, FFX_RESOURCE_STATE_COMPUTE_READ, FFX_RESOURCE_STATE_UNORDERED_ACCESS, 0};
|
||||
context->contextDescription.backendInterface.fpScheduleGpuJob(&context->contextDescription.backendInterface, &barrierJob);
|
||||
wcscpy_s(barrierJob.jobLabel, L"Transition Optical Flow Input 1 Level 5");
|
||||
barrierJob.barrierDescriptor = { context->resources[FFX_OF_RESOURCE_IDENTIFIER_OPTICAL_FLOW_INPUT_1_LEVEL_5], FFX_BARRIER_TYPE_TRANSITION, FFX_RESOURCE_STATE_COMPUTE_READ, FFX_RESOURCE_STATE_UNORDERED_ACCESS, 0};
|
||||
context->contextDescription.backendInterface.fpScheduleGpuJob(&context->contextDescription.backendInterface, &barrierJob);
|
||||
wcscpy_s(barrierJob.jobLabel, L"Transition Optical Flow Input 1 Level 6");
|
||||
barrierJob.barrierDescriptor = { context->resources[FFX_OF_RESOURCE_IDENTIFIER_OPTICAL_FLOW_INPUT_1_LEVEL_6], FFX_BARRIER_TYPE_TRANSITION, FFX_RESOURCE_STATE_COMPUTE_READ, FFX_RESOURCE_STATE_UNORDERED_ACCESS, 0};
|
||||
context->contextDescription.backendInterface.fpScheduleGpuJob(&context->contextDescription.backendInterface, &barrierJob);
|
||||
wcscpy_s(barrierJob.jobLabel, L"Transition Optical Flow Input 2");
|
||||
barrierJob.barrierDescriptor = { context->resources[FFX_OF_RESOURCE_IDENTIFIER_OPTICAL_FLOW_INPUT_2], FFX_BARRIER_TYPE_TRANSITION, FFX_RESOURCE_STATE_COMPUTE_READ, FFX_RESOURCE_STATE_UNORDERED_ACCESS, 0};
|
||||
context->contextDescription.backendInterface.fpScheduleGpuJob(&context->contextDescription.backendInterface, &barrierJob);
|
||||
wcscpy_s(barrierJob.jobLabel, L"Transition Optical Flow Input 2 Level 1");
|
||||
barrierJob.barrierDescriptor = { context->resources[FFX_OF_RESOURCE_IDENTIFIER_OPTICAL_FLOW_INPUT_2_LEVEL_1], FFX_BARRIER_TYPE_TRANSITION, FFX_RESOURCE_STATE_COMPUTE_READ, FFX_RESOURCE_STATE_UNORDERED_ACCESS, 0};
|
||||
context->contextDescription.backendInterface.fpScheduleGpuJob(&context->contextDescription.backendInterface, &barrierJob);
|
||||
wcscpy_s(barrierJob.jobLabel, L"Transition Optical Flow Input 2 Level 2");
|
||||
barrierJob.barrierDescriptor = { context->resources[FFX_OF_RESOURCE_IDENTIFIER_OPTICAL_FLOW_INPUT_2_LEVEL_2], FFX_BARRIER_TYPE_TRANSITION, FFX_RESOURCE_STATE_COMPUTE_READ, FFX_RESOURCE_STATE_UNORDERED_ACCESS, 0};
|
||||
context->contextDescription.backendInterface.fpScheduleGpuJob(&context->contextDescription.backendInterface, &barrierJob);
|
||||
wcscpy_s(barrierJob.jobLabel, L"Transition Optical Flow Input 2 Level 3");
|
||||
barrierJob.barrierDescriptor = { context->resources[FFX_OF_RESOURCE_IDENTIFIER_OPTICAL_FLOW_INPUT_2_LEVEL_3], FFX_BARRIER_TYPE_TRANSITION, FFX_RESOURCE_STATE_COMPUTE_READ, FFX_RESOURCE_STATE_UNORDERED_ACCESS, 0};
|
||||
context->contextDescription.backendInterface.fpScheduleGpuJob(&context->contextDescription.backendInterface, &barrierJob);
|
||||
wcscpy_s(barrierJob.jobLabel, L"Transition Optical Flow Input 2 Level 4");
|
||||
barrierJob.barrierDescriptor = { context->resources[FFX_OF_RESOURCE_IDENTIFIER_OPTICAL_FLOW_INPUT_2_LEVEL_4], FFX_BARRIER_TYPE_TRANSITION, FFX_RESOURCE_STATE_COMPUTE_READ, FFX_RESOURCE_STATE_UNORDERED_ACCESS, 0};
|
||||
context->contextDescription.backendInterface.fpScheduleGpuJob(&context->contextDescription.backendInterface, &barrierJob);
|
||||
wcscpy_s(barrierJob.jobLabel, L"Transition Optical Flow Input 2 Level 5");
|
||||
barrierJob.barrierDescriptor = { context->resources[FFX_OF_RESOURCE_IDENTIFIER_OPTICAL_FLOW_INPUT_2_LEVEL_5], FFX_BARRIER_TYPE_TRANSITION, FFX_RESOURCE_STATE_COMPUTE_READ, FFX_RESOURCE_STATE_UNORDERED_ACCESS, 0};
|
||||
context->contextDescription.backendInterface.fpScheduleGpuJob(&context->contextDescription.backendInterface, &barrierJob);
|
||||
wcscpy_s(barrierJob.jobLabel, L"Transition Optical Flow Input 2 Level 6");
|
||||
barrierJob.barrierDescriptor = { context->resources[FFX_OF_RESOURCE_IDENTIFIER_OPTICAL_FLOW_INPUT_2_LEVEL_6], FFX_BARRIER_TYPE_TRANSITION, FFX_RESOURCE_STATE_COMPUTE_READ, FFX_RESOURCE_STATE_UNORDERED_ACCESS, 0};
|
||||
context->contextDescription.backendInterface.fpScheduleGpuJob(&context->contextDescription.backendInterface, &barrierJob);
|
||||
}
|
||||
|
||||
context->resourceFrameIndex = (context->resourceFrameIndex + 1) % FFX_OPTICALFLOW_MAX_QUEUED_FRAMES;
|
||||
|
||||
FFX_VALIDATE(context->contextDescription.backendInterface.fpExecuteGpuJobs(&context->contextDescription.backendInterface, commandList, context->effectContextId));
|
||||
|
||||
context->contextDescription.backendInterface.fpUnregisterResources(&context->contextDescription.backendInterface, commandList, context->effectContextId);
|
||||
|
||||
return FFX_OK;
|
||||
}
|
||||
|
||||
FfxErrorCode ffxOpticalflowContextCreate(FfxOpticalflowContext* context, FfxOpticalflowContextDescription* contextDescription)
|
||||
{
|
||||
FFX_RETURN_ON_ERROR(context, FFX_ERROR_INVALID_POINTER);
|
||||
FFX_RETURN_ON_ERROR(contextDescription, FFX_ERROR_INVALID_POINTER);
|
||||
|
||||
FFX_RETURN_ON_ERROR(contextDescription->backendInterface.fpGetSDKVersion, FFX_ERROR_INCOMPLETE_INTERFACE);
|
||||
FFX_RETURN_ON_ERROR(contextDescription->backendInterface.fpGetDeviceCapabilities, FFX_ERROR_INCOMPLETE_INTERFACE);
|
||||
FFX_RETURN_ON_ERROR(contextDescription->backendInterface.fpCreateBackendContext, FFX_ERROR_INCOMPLETE_INTERFACE);
|
||||
FFX_RETURN_ON_ERROR(contextDescription->backendInterface.fpDestroyBackendContext, FFX_ERROR_INCOMPLETE_INTERFACE);
|
||||
|
||||
if (contextDescription->backendInterface.scratchBuffer) {
|
||||
|
||||
FFX_RETURN_ON_ERROR(contextDescription->backendInterface.scratchBufferSize, FFX_ERROR_INCOMPLETE_INTERFACE);
|
||||
}
|
||||
|
||||
FFX_STATIC_ASSERT(sizeof(FfxOpticalflowContext) >= sizeof(FfxOpticalflowContext_Private));
|
||||
|
||||
FfxOpticalflowContext_Private* contextPrivate = (FfxOpticalflowContext_Private*)(context);
|
||||
FfxErrorCode errorCode = opticalflowCreate(contextPrivate, contextDescription);
|
||||
|
||||
return errorCode;
|
||||
}
|
||||
|
||||
FFX_API FfxErrorCode ffxOpticalflowContextGetGpuMemoryUsage(FfxOpticalflowContext* context, FfxEffectMemoryUsage* vramUsage)
|
||||
{
|
||||
FFX_RETURN_ON_ERROR(context, FFX_ERROR_INVALID_POINTER);
|
||||
FFX_RETURN_ON_ERROR(vramUsage, FFX_ERROR_INVALID_POINTER);
|
||||
FfxOpticalflowContext_Private* contextPrivate = (FfxOpticalflowContext_Private*)(context);
|
||||
|
||||
FFX_RETURN_ON_ERROR(contextPrivate->device, FFX_ERROR_NULL_DEVICE);
|
||||
|
||||
FfxErrorCode errorCode = contextPrivate->contextDescription.backendInterface.fpGetEffectGpuMemoryUsage(
|
||||
&contextPrivate->contextDescription.backendInterface, contextPrivate->effectContextId, vramUsage);
|
||||
FFX_RETURN_ON_ERROR(errorCode == FFX_OK, errorCode);
|
||||
|
||||
return FFX_OK;
|
||||
}
|
||||
|
||||
FfxErrorCode ffxOpticalflowContextDestroy(FfxOpticalflowContext* context)
|
||||
{
|
||||
FFX_RETURN_ON_ERROR(context, FFX_ERROR_INVALID_POINTER);
|
||||
|
||||
FfxOpticalflowContext_Private* contextPrivate = (FfxOpticalflowContext_Private*)(context);
|
||||
const FfxErrorCode errorCode = opticalflowRelease(contextPrivate);
|
||||
|
||||
return errorCode;
|
||||
}
|
||||
|
||||
FFX_API bool ffxOpticalflowResourceIsNull(FfxResource resource)
|
||||
{
|
||||
return resource.resource == NULL;
|
||||
}
|
||||
|
||||
FFX_API FfxErrorCode ffxOpticalflowGetSharedResourceDescriptions(FfxOpticalflowContext* context, FfxOpticalflowSharedResourceDescriptions* SharedResources)
|
||||
{
|
||||
FFX_RETURN_ON_ERROR(context, FFX_ERROR_INVALID_POINTER);
|
||||
FFX_RETURN_ON_ERROR(SharedResources, FFX_ERROR_INVALID_POINTER);
|
||||
|
||||
FfxOpticalflowContext_Private* contextPrivate = (FfxOpticalflowContext_Private*)(context);
|
||||
const FfxDimensions2D opticalFlowTextureSize = GetOpticalFlowTextureSize(contextPrivate->contextDescription.resolution, 8);
|
||||
const FfxDimensions2D globalMotionSearchMaxDispatchSize = GetGlobalMotionSearchDispatchSize(0);
|
||||
const uint32_t globalMotionSearchTextureWidth = 4 /* predefined slots */ + (globalMotionSearchMaxDispatchSize.width * globalMotionSearchMaxDispatchSize.height);
|
||||
|
||||
SharedResources->opticalFlowVector = {
|
||||
FFX_HEAP_TYPE_DEFAULT,
|
||||
{ FFX_RESOURCE_TYPE_TEXTURE2D, FFX_SURFACE_FORMAT_R16G16_SINT, opticalFlowTextureSize.width, opticalFlowTextureSize.height, 1, 1, FFX_RESOURCE_FLAGS_NONE, FFX_RESOURCE_USAGE_UAV },
|
||||
FFX_RESOURCE_STATE_UNORDERED_ACCESS, L"OPTICALFLOW_Result", 0, {FFX_RESOURCE_INIT_DATA_TYPE_UNINITIALIZED} };
|
||||
|
||||
SharedResources->opticalFlowSCD = {
|
||||
FFX_HEAP_TYPE_DEFAULT,
|
||||
{ FFX_RESOURCE_TYPE_TEXTURE2D, FFX_SURFACE_FORMAT_R32_UINT, 3, 1, 1, 1, FFX_RESOURCE_FLAGS_NONE, FFX_RESOURCE_USAGE_UAV },
|
||||
FFX_RESOURCE_STATE_UNORDERED_ACCESS, L"OPTICALFLOW_SCDOutput", 0, {FFX_RESOURCE_INIT_DATA_TYPE_UNINITIALIZED} };
|
||||
|
||||
return FFX_OK;
|
||||
}
|
||||
|
||||
FfxErrorCode ffxOpticalflowContextDispatch(FfxOpticalflowContext* context, const FfxOpticalflowDispatchDescription* dispatchParams)
|
||||
{
|
||||
FFX_RETURN_ON_ERROR(context, FFX_ERROR_INVALID_POINTER);
|
||||
FFX_RETURN_ON_ERROR(dispatchParams, FFX_ERROR_INVALID_POINTER);
|
||||
FFX_RETURN_ON_ERROR(dispatchParams->commandList, FFX_ERROR_INVALID_POINTER);
|
||||
FFX_RETURN_ON_ERROR(!ffxOpticalflowResourceIsNull(dispatchParams->color), FFX_ERROR_INVALID_POINTER);
|
||||
FFX_RETURN_ON_ERROR(dispatchParams->color.description.type == FFX_RESOURCE_TYPE_TEXTURE2D, FFX_ERROR_INVALID_ARGUMENT);
|
||||
FFX_RETURN_ON_ERROR(!ffxOpticalflowResourceIsNull(dispatchParams->opticalFlowVector), FFX_ERROR_INVALID_POINTER);
|
||||
FFX_RETURN_ON_ERROR(!ffxOpticalflowResourceIsNull(dispatchParams->opticalFlowSCD), FFX_ERROR_INVALID_POINTER);
|
||||
|
||||
FfxOpticalflowContext_Private* contextPrivate = (FfxOpticalflowContext_Private*)(context);
|
||||
|
||||
FFX_RETURN_ON_ERROR(contextPrivate->device, FFX_ERROR_NULL_DEVICE);
|
||||
FFX_RETURN_ON_ERROR(dispatchParams->color.description.width <= contextPrivate->contextDescription.resolution.width, FFX_ERROR_INVALID_ARGUMENT);
|
||||
FFX_RETURN_ON_ERROR(dispatchParams->color.description.height <= contextPrivate->contextDescription.resolution.height, FFX_ERROR_INVALID_ARGUMENT);
|
||||
|
||||
const FfxErrorCode errorCode = dispatch(contextPrivate, dispatchParams);
|
||||
return errorCode;
|
||||
}
|
||||
|
||||
FFX_API FfxVersionNumber ffxOpticalflowGetEffectVersion()
|
||||
{
|
||||
return FFX_SDK_MAKE_VERSION(FFX_OPTICALFLOW_VERSION_MAJOR, FFX_OPTICALFLOW_VERSION_MINOR, FFX_OPTICALFLOW_VERSION_PATCH);
|
||||
}
|
||||
+108
@@ -0,0 +1,108 @@
|
||||
// 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
|
||||
|
||||
#define FFX_CPU
|
||||
#include <FidelityFX/gpu/opticalflow/ffx_opticalflow_resources.h>
|
||||
|
||||
typedef enum OpticalFlowBindingIdentifiers
|
||||
{
|
||||
FFX_OF_BINDING_IDENTIFIER_NULL = 0,
|
||||
FFX_OF_BINDING_IDENTIFIER_INPUT_COLOR,
|
||||
|
||||
FFX_OF_BINDING_IDENTIFIER_OPTICAL_FLOW_INPUT,
|
||||
FFX_OF_BINDING_IDENTIFIER_OPTICAL_FLOW_INPUT_LEVEL_1,
|
||||
FFX_OF_BINDING_IDENTIFIER_OPTICAL_FLOW_INPUT_LEVEL_2,
|
||||
FFX_OF_BINDING_IDENTIFIER_OPTICAL_FLOW_INPUT_LEVEL_3,
|
||||
FFX_OF_BINDING_IDENTIFIER_OPTICAL_FLOW_INPUT_LEVEL_4,
|
||||
FFX_OF_BINDING_IDENTIFIER_OPTICAL_FLOW_INPUT_LEVEL_5,
|
||||
FFX_OF_BINDING_IDENTIFIER_OPTICAL_FLOW_INPUT_LEVEL_6,
|
||||
|
||||
FFX_OF_BINDING_IDENTIFIER_OPTICAL_FLOW_PREVIOUS_INPUT,
|
||||
|
||||
FFX_OF_BINDING_IDENTIFIER_OPTICAL_FLOW_SCD_HISTOGRAM,
|
||||
FFX_OF_BINDING_IDENTIFIER_OPTICAL_FLOW_SCD_PREVIOUS_HISTOGRAM,
|
||||
FFX_OF_BINDING_IDENTIFIER_OPTICAL_FLOW_SCD_TEMP,
|
||||
FFX_OF_BINDING_IDENTIFIER_OPTICAL_FLOW_SCD_OUTPUT,
|
||||
|
||||
FFX_OF_BINDING_IDENTIFIER_OPTICAL_FLOW,
|
||||
FFX_OF_BINDING_IDENTIFIER_OPTICAL_FLOW_NEXT_LEVEL,
|
||||
FFX_OF_BINDING_IDENTIFIER_OPTICAL_FLOW_PREVIOUS,
|
||||
|
||||
FFX_OF_BINDING_IDENTIFIER_OPTICAL_FLOW_ALIAS_LEVEL_1,
|
||||
FFX_OF_BINDING_IDENTIFIER_OPTICAL_FLOW_ALIAS_LEVEL_2,
|
||||
FFX_OF_BINDING_IDENTIFIER_OPTICAL_FLOW_ALIAS_LEVEL_3,
|
||||
FFX_OF_BINDING_IDENTIFIER_OPTICAL_FLOW_ALIAS_LEVEL_4,
|
||||
FFX_OF_BINDING_IDENTIFIER_OPTICAL_FLOW_ALIAS_LEVEL_5,
|
||||
FFX_OF_BINDING_IDENTIFIER_OPTICAL_FLOW_ALIAS_LEVEL_6,
|
||||
|
||||
FFX_OF_BINDING_IDENTIFIER_SHARED_OPTICAL_FLOW_VECTOR,
|
||||
FFX_OF_BINDING_IDENTIFIER_SHARED_OPTICAL_FLOW_SCD_OUTPUT,
|
||||
|
||||
FFX_OF_BINDING_IDENTIFIER_COUNT
|
||||
} OpticalFlowBindingIdentifiers;
|
||||
|
||||
typedef enum OpticalflowShaderPermutationOptions
|
||||
{
|
||||
OPTICALFLOW_SHADER_PERMUTATION_FORCE_WAVE64 = (1 << 0), ///< doesn't map to a define, selects different table
|
||||
OPTICALFLOW_SHADER_PERMUTATION_ALLOW_FP16 = (1 << 1), ///< Enables fast math computations where possible
|
||||
OPTICALFLOW_HDR_COLOR_INPUT = (1 << 2),
|
||||
} OpticalflowShaderPermutationOptions;
|
||||
|
||||
typedef struct OpticalflowConstants
|
||||
{
|
||||
int32_t inputLumaResolution[2];
|
||||
uint32_t opticalFlowPyramidLevel;
|
||||
uint32_t opticalFlowPyramidLevelCount;
|
||||
|
||||
int32_t frameIndex;
|
||||
uint32_t backbufferTransferFunction;
|
||||
float minMaxLuminance[2];
|
||||
} OpticalflowConstants;
|
||||
|
||||
typedef struct FfxOpticalflowContext_Private
|
||||
{
|
||||
FfxOpticalflowContextDescription contextDescription;
|
||||
FfxUInt32 effectContextId;
|
||||
OpticalflowConstants constants;
|
||||
FfxDevice device;
|
||||
FfxDeviceCapabilities deviceCapabilities;
|
||||
|
||||
FfxPipelineState pipelinePrepareLuma;
|
||||
FfxPipelineState pipelineGenerateOpticalFlowInputPyramid;
|
||||
FfxPipelineState pipelineGenerateSCDHistogram;
|
||||
FfxPipelineState pipelineComputeSCDDivergence;
|
||||
FfxPipelineState pipelineComputeOpticalFlowAdvancedV5;
|
||||
FfxPipelineState pipelineFilterOpticalFlowV5;
|
||||
FfxPipelineState pipelineScaleOpticalFlowAdvancedV5;
|
||||
|
||||
FfxResourceInternal resources[FFX_OF_RESOURCE_IDENTIFIER_COUNT];
|
||||
FfxResourceInternal srvBindings[FFX_OF_BINDING_IDENTIFIER_COUNT];
|
||||
FfxResourceInternal uavBindings[FFX_OF_BINDING_IDENTIFIER_COUNT];
|
||||
|
||||
FfxConstantBuffer constantBuffers[FFX_OPTICALFLOW_CONSTANTBUFFER_COUNT];
|
||||
|
||||
bool firstExecution;
|
||||
bool refreshPipelineStates;
|
||||
uint32_t resourceFrameIndex;
|
||||
} FfxOpticalflowContext_Private;
|
||||
@@ -0,0 +1,82 @@
|
||||
// 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.
|
||||
|
||||
#include <FidelityFX/host/ffx_assert.h>
|
||||
#include <stdlib.h> // for malloc()
|
||||
|
||||
#ifdef _WIN32
|
||||
#ifndef WIN32_LEAN_AND_MEAN
|
||||
#define WIN32_LEAN_AND_MEAN
|
||||
#endif
|
||||
#include <windows.h> // required for OutputDebugString()
|
||||
#include <stdio.h> // required for sprintf_s
|
||||
#endif // #ifndef _WIN32
|
||||
|
||||
static FfxAssertCallback s_assertCallback;
|
||||
|
||||
// set the printing callback function
|
||||
void ffxAssertSetPrintingCallback(FfxAssertCallback callback)
|
||||
{
|
||||
s_assertCallback = callback;
|
||||
return;
|
||||
}
|
||||
|
||||
// implementation of assert reporting
|
||||
bool ffxAssertReport(const char* file, int32_t line, const char* condition, const char* message)
|
||||
{
|
||||
if (!file) {
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
#ifdef _WIN32
|
||||
// form the final assertion string and output to the TTY.
|
||||
const size_t bufferSize = snprintf(NULL, 0, "%s(%d): ASSERTION FAILED. %s\n", file, line, message ? message : condition) + 1;
|
||||
char* tempBuf = (char*)malloc(bufferSize);
|
||||
if (!tempBuf) {
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!message) {
|
||||
sprintf_s(tempBuf, bufferSize, "%s(%d): ASSERTION FAILED. %s\n", file, line, condition);
|
||||
} else {
|
||||
sprintf_s(tempBuf, bufferSize, "%s(%d): ASSERTION FAILED. %s\n", file, line, message);
|
||||
}
|
||||
|
||||
if (!s_assertCallback) {
|
||||
OutputDebugStringA(tempBuf);
|
||||
} else {
|
||||
s_assertCallback(tempBuf);
|
||||
}
|
||||
|
||||
// free the buffer.
|
||||
free(tempBuf);
|
||||
|
||||
#else
|
||||
FFX_UNUSED(line);
|
||||
FFX_UNUSED(condition);
|
||||
FFX_UNUSED(message);
|
||||
#endif
|
||||
|
||||
return true;
|
||||
}
|
||||
@@ -0,0 +1,49 @@
|
||||
// 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.
|
||||
|
||||
#include "ffx_breadcrumbs_list.h"
|
||||
|
||||
void* ffxBreadcrumbsAppendList(void* src, size_t currentCount, size_t elementSize, size_t appendCount, FfxAllocationCallbacks* callbacks)
|
||||
{
|
||||
FFX_ASSERT(src ? currentCount > 0 : currentCount == 0);
|
||||
|
||||
void* dst = callbacks->fpRealloc(src, elementSize * (currentCount + appendCount));
|
||||
FFX_ASSERT(dst);
|
||||
|
||||
return dst;
|
||||
}
|
||||
|
||||
void* ffxBreadcrumbsPopList(void* src, size_t newCount, size_t elementSize, FfxAllocationCallbacks* callbacks)
|
||||
{
|
||||
FFX_ASSERT(src);
|
||||
|
||||
void* dst = nullptr;
|
||||
if (newCount > 0)
|
||||
{
|
||||
dst = callbacks->fpRealloc(src, elementSize * newCount);
|
||||
FFX_ASSERT(dst);
|
||||
}
|
||||
else
|
||||
callbacks->fpFree(src);
|
||||
|
||||
return dst;
|
||||
}
|
||||
@@ -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
|
||||
|
||||
#include <cstdint>
|
||||
#include <cstdio> // sprintf_s
|
||||
#include <FidelityFX/host/ffx_assert.h>
|
||||
|
||||
#define FFX_BREADCRUMBS_APPEND_STRING(buff, count, str) \
|
||||
do \
|
||||
{ \
|
||||
buff = (char*)ffxBreadcrumbsAppendList(buff, count, 1, sizeof(str) - 1, allocs); \
|
||||
memcpy(buff + count, str, sizeof(str) - 1); \
|
||||
count += sizeof(str) - 1; \
|
||||
} while (false)
|
||||
|
||||
#define FFX_BREADCRUMBS_APPEND_STRING_DYNAMIC(buff, count, src) \
|
||||
do \
|
||||
{ \
|
||||
const char* _str = src; \
|
||||
const size_t _length = strlen(_str); \
|
||||
buff = (char*)ffxBreadcrumbsAppendList(buff, count, 1, _length, allocs); \
|
||||
memcpy(buff + count, _str, _length); \
|
||||
count += _length; \
|
||||
} while (false)
|
||||
|
||||
#define FFX_BREADCRUMBS_APPEND_NUMBER(buff, count, number, maxLength, format) \
|
||||
do \
|
||||
{ \
|
||||
char _numberStr[maxLength]; \
|
||||
const size_t _length = sprintf_s(_numberStr, maxLength, format, number); \
|
||||
buff = (char*)ffxBreadcrumbsAppendList(buff, count, 1, _length, allocs); \
|
||||
memcpy(buff + count, _numberStr, _length); \
|
||||
count += _length; \
|
||||
} while (false)
|
||||
|
||||
#define FFX_BREADCRUMBS_APPEND_UINT(buff, count, number) \
|
||||
FFX_BREADCRUMBS_APPEND_NUMBER(buff, count, number, 11, "%u")
|
||||
|
||||
#define FFX_BREADCRUMBS_APPEND_UINT64(buff, count, number) \
|
||||
FFX_BREADCRUMBS_APPEND_NUMBER(buff, count, number, 21, "%zu")
|
||||
|
||||
#define FFX_BREADCRUMBS_APPEND_FLOAT(buff, count, number) \
|
||||
FFX_BREADCRUMBS_APPEND_NUMBER(buff, count, number, 18, "%.3f")
|
||||
|
||||
#define FFX_BREADCRUMBS_PRINTING_INDENT " "
|
||||
|
||||
#define FFX_BREADCRUMBS_PRINT_STRING(buff, count, baseStruct, member) \
|
||||
do \
|
||||
{ \
|
||||
FFX_BREADCRUMBS_APPEND_STRING(buff, count, FFX_BREADCRUMBS_PRINTING_INDENT #member ": "); \
|
||||
FFX_BREADCRUMBS_APPEND_STRING_DYNAMIC(buff, count, baseStruct.member); \
|
||||
FFX_BREADCRUMBS_APPEND_STRING(buff, count, "\n"); \
|
||||
} while (false)
|
||||
|
||||
#define FFX_BREADCRUMBS_PRINT_UINT(buff, count, baseStruct, member) \
|
||||
do \
|
||||
{ \
|
||||
FFX_BREADCRUMBS_APPEND_STRING(buff, count, FFX_BREADCRUMBS_PRINTING_INDENT #member ": "); \
|
||||
FFX_BREADCRUMBS_APPEND_UINT(buff, count, baseStruct.member); \
|
||||
FFX_BREADCRUMBS_APPEND_STRING(buff, count, "\n"); \
|
||||
} while (false)
|
||||
|
||||
#define FFX_BREADCRUMBS_PRINT_UINT64(buff, count, baseStruct, member) \
|
||||
do \
|
||||
{ \
|
||||
FFX_BREADCRUMBS_APPEND_STRING(buff, count, FFX_BREADCRUMBS_PRINTING_INDENT #member ": "); \
|
||||
FFX_BREADCRUMBS_APPEND_UINT64(buff, count, baseStruct.member); \
|
||||
FFX_BREADCRUMBS_APPEND_STRING(buff, count, "\n"); \
|
||||
} while (false)
|
||||
|
||||
#define FFX_BREADCRUMBS_PRINT_FLOAT(buff, count, baseStruct, member) \
|
||||
do \
|
||||
{ \
|
||||
FFX_BREADCRUMBS_APPEND_STRING(buff, count, FFX_BREADCRUMBS_PRINTING_INDENT #member ": "); \
|
||||
FFX_BREADCRUMBS_APPEND_FLOAT(buff, count, baseStruct.member); \
|
||||
FFX_BREADCRUMBS_APPEND_STRING(buff, count, "\n"); \
|
||||
} while (false)
|
||||
|
||||
#define FFX_BREADCRUMBS_PRINT_BOOL(buff, count, baseStruct, member) \
|
||||
do \
|
||||
{ \
|
||||
FFX_BREADCRUMBS_APPEND_STRING(buff, count, FFX_BREADCRUMBS_PRINTING_INDENT #member ": "); \
|
||||
if (baseStruct.member) \
|
||||
{ \
|
||||
FFX_BREADCRUMBS_APPEND_STRING(buff, count, "True\n"); \
|
||||
} \
|
||||
else \
|
||||
{ \
|
||||
FFX_BREADCRUMBS_APPEND_STRING(buff, count, "False\n"); \
|
||||
} \
|
||||
} while (false)
|
||||
|
||||
#define FFX_BREADCRUMBS_PRINT_HEX_NUMBER(buff, count, baseStruct, member, maxLength, format) \
|
||||
do \
|
||||
{ \
|
||||
FFX_BREADCRUMBS_APPEND_STRING(buff, count, FFX_BREADCRUMBS_PRINTING_INDENT #member ": 0x"); \
|
||||
char _hexStr[maxLength]; \
|
||||
const size_t _length = sprintf_s(_hexStr, maxLength, format, baseStruct.member); \
|
||||
buff = (char*)ffxBreadcrumbsAppendList(buff, count, 1, _length + 1, allocs); \
|
||||
memcpy(buff + count, _hexStr, _length); \
|
||||
count += _length; \
|
||||
buff[count++] = '\n'; \
|
||||
} while (false)
|
||||
|
||||
#define FFX_BREADCRUMBS_PRINT_HEX32(buff, count, baseStruct, member) \
|
||||
FFX_BREADCRUMBS_PRINT_HEX_NUMBER(buff, count, baseStruct, member, 9, "%X")
|
||||
|
||||
#define FFX_BREADCRUMBS_PRINT_HEX64(buff, count, baseStruct, member) \
|
||||
FFX_BREADCRUMBS_PRINT_HEX_NUMBER(buff, count, baseStruct, member, 17, "%zX")
|
||||
|
||||
#define FFX_BREADCRUMBS_PRINT_HEX_BYTE(buff, count, val) \
|
||||
do \
|
||||
{ \
|
||||
buff = (char*)ffxBreadcrumbsAppendList(buff, count, 1, 2, allocs); \
|
||||
buff[count++] = (char)((val >> 4) + ((val >> 4) >= 10 ? '7' : '0')); \
|
||||
buff[count++] = (char)((val & 0x0F) + ((val & 0x0F) >= 10 ? '7' : '0')); \
|
||||
} while (false)
|
||||
|
||||
#if defined(__cplusplus)
|
||||
extern "C" {
|
||||
#endif // #if defined(__cplusplus)
|
||||
|
||||
FFX_API void* ffxBreadcrumbsAppendList(void* src, size_t currentCount, size_t elementSize, size_t appendCount, FfxAllocationCallbacks* callbacks);
|
||||
|
||||
FFX_API void* ffxBreadcrumbsPopList(void* src, size_t newCount, size_t elementSize, FfxAllocationCallbacks* callbacks);
|
||||
|
||||
#if defined(__cplusplus)
|
||||
}
|
||||
#endif // #if defined(__cplusplus)
|
||||
@@ -0,0 +1,64 @@
|
||||
// This file is part of the FidelityFX SDK.
|
||||
//
|
||||
// Copyright (C) 2025 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.
|
||||
|
||||
#include <FidelityFX/host/ffx_message.h>
|
||||
|
||||
#ifdef _WIN32
|
||||
#ifndef WIN32_LEAN_AND_MEAN
|
||||
#define WIN32_LEAN_AND_MEAN
|
||||
#endif
|
||||
#include <windows.h> // required for OutputDebugString()
|
||||
#endif // #ifdef _WIN32
|
||||
|
||||
static ffxMessageCallback s_messageCallback;
|
||||
static uint32_t s_debugLevel;
|
||||
|
||||
// set the printing callback function
|
||||
void ffxSetPrintMessageCallback(ffxMessageCallback callback, uint32_t debugLevel)
|
||||
{
|
||||
s_messageCallback = callback;
|
||||
s_debugLevel = debugLevel;
|
||||
return;
|
||||
}
|
||||
|
||||
void ffxPrintMessage(uint32_t type, const wchar_t* message)
|
||||
{
|
||||
#ifdef _WIN32
|
||||
if (!s_messageCallback) {
|
||||
// Format the message string
|
||||
wchar_t buffer[512];
|
||||
if (type == FFX_MESSAGE_TYPE_ERROR) {
|
||||
swprintf_s(buffer, 512, L"FSR_API_DEBUG_ERROR: %ls\n", message);
|
||||
}
|
||||
else if (type == FFX_MESSAGE_TYPE_WARNING) {
|
||||
swprintf_s(buffer, 512, L"FSR_API_DEBUG_WARNING: %ls\n", message);
|
||||
}
|
||||
OutputDebugStringW(buffer);
|
||||
} else {
|
||||
s_messageCallback(type, message);
|
||||
}
|
||||
#else
|
||||
FFX_UNUSED(type);
|
||||
FFX_UNUSED(message);
|
||||
#endif
|
||||
return;
|
||||
}
|
||||
@@ -0,0 +1,48 @@
|
||||
// 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.
|
||||
|
||||
#include <FidelityFX/host/ffx_interface.h>
|
||||
#include "ffx_object_management.h"
|
||||
|
||||
void ffxSafeReleasePipeline(FfxInterface* backendInterface, FfxPipelineState* pipeline, FfxUInt32 effectContextId)
|
||||
{
|
||||
FFX_ASSERT(pipeline);
|
||||
FFX_ASSERT(backendInterface->fpDestroyPipeline);
|
||||
|
||||
backendInterface->fpDestroyPipeline(backendInterface, pipeline, effectContextId);
|
||||
}
|
||||
|
||||
void ffxSafeReleaseCopyResource(FfxInterface* backendInterface, FfxResourceInternal resource, FfxUInt32 effectContextId)
|
||||
{
|
||||
FFX_ASSERT(backendInterface->fpDestroyResource);
|
||||
|
||||
FfxResourceInternal copyResource;
|
||||
copyResource.internalIndex = resource.internalIndex + 1;
|
||||
backendInterface->fpDestroyResource(backendInterface, copyResource, effectContextId);
|
||||
}
|
||||
|
||||
void ffxSafeReleaseResource(FfxInterface* backendInterface, FfxResourceInternal resource, FfxUInt32 effectContextId)
|
||||
{
|
||||
FFX_ASSERT(backendInterface->fpDestroyResource);
|
||||
|
||||
backendInterface->fpDestroyResource(backendInterface, resource, effectContextId);
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
// 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 <FidelityFX/host/ffx_types.h>
|
||||
#include <FidelityFX/host/ffx_interface.h>
|
||||
|
||||
#if defined(__cplusplus)
|
||||
extern "C" {
|
||||
#endif // #if defined(__cplusplus)
|
||||
|
||||
FFX_API void ffxSafeReleasePipeline(FfxInterface* backendInterface, FfxPipelineState* pipeline, FfxUInt32 effectContextId);
|
||||
FFX_API void ffxSafeReleaseCopyResource(FfxInterface* backendInterface, FfxResourceInternal resource, FfxUInt32 effectContextId);
|
||||
FFX_API void ffxSafeReleaseResource(FfxInterface* backendInterface, FfxResourceInternal resource, FfxUInt32 effectContextId);
|
||||
|
||||
#if defined(__cplusplus)
|
||||
}
|
||||
#endif // #if defined(__cplusplus)
|
||||
Reference in new issue
Block a user