Browse Source
Added FSR3 optical flow and frame interpolation shaders and headers, directly from the FidelityFX SDK.
fsr3framegen
Added FSR3 optical flow and frame interpolation shaders and headers, directly from the FidelityFX SDK.
fsr3framegen
93 changed files with 7283 additions and 0 deletions
-
71Shaders/shaders/ffx_frameinterpolation_compute_game_vector_field_inpainting_pyramid_pass.hlsl
-
7Shaders/shaders/ffx_frameinterpolation_compute_game_vector_field_inpainting_pyramid_pass.hlsl.meta
-
70Shaders/shaders/ffx_frameinterpolation_compute_inpainting_pyramid_pass.hlsl
-
7Shaders/shaders/ffx_frameinterpolation_compute_inpainting_pyramid_pass.hlsl.meta
-
57Shaders/shaders/ffx_frameinterpolation_debug_view_pass.hlsl
-
7Shaders/shaders/ffx_frameinterpolation_debug_view_pass.hlsl.meta
-
55Shaders/shaders/ffx_frameinterpolation_disocclusion_mask_pass.hlsl
-
7Shaders/shaders/ffx_frameinterpolation_disocclusion_mask_pass.hlsl.meta
-
54Shaders/shaders/ffx_frameinterpolation_game_motion_vector_field_pass.hlsl
-
7Shaders/shaders/ffx_frameinterpolation_game_motion_vector_field_pass.hlsl.meta
-
53Shaders/shaders/ffx_frameinterpolation_inpainting_pass.hlsl
-
7Shaders/shaders/ffx_frameinterpolation_inpainting_pass.hlsl.meta
-
55Shaders/shaders/ffx_frameinterpolation_optical_flow_vector_field_pass.hlsl
-
7Shaders/shaders/ffx_frameinterpolation_optical_flow_vector_field_pass.hlsl.meta
-
58Shaders/shaders/ffx_frameinterpolation_pass.hlsl
-
7Shaders/shaders/ffx_frameinterpolation_pass.hlsl.meta
-
58Shaders/shaders/ffx_frameinterpolation_reconstruct_and_dilate_pass.hlsl
-
7Shaders/shaders/ffx_frameinterpolation_reconstruct_and_dilate_pass.hlsl.meta
-
52Shaders/shaders/ffx_frameinterpolation_reconstruct_previous_depth_pass.hlsl
-
7Shaders/shaders/ffx_frameinterpolation_reconstruct_previous_depth_pass.hlsl.meta
-
55Shaders/shaders/ffx_frameinterpolation_setup_pass.hlsl
-
7Shaders/shaders/ffx_frameinterpolation_setup_pass.hlsl.meta
-
57Shaders/shaders/ffx_opticalflow_compute_luminance_pyramid_pass.hlsl
-
7Shaders/shaders/ffx_opticalflow_compute_luminance_pyramid_pass.hlsl.meta
-
63Shaders/shaders/ffx_opticalflow_compute_optical_flow_advanced_pass_v5.hlsl
-
7Shaders/shaders/ffx_opticalflow_compute_optical_flow_advanced_pass_v5.hlsl.meta
-
56Shaders/shaders/ffx_opticalflow_compute_scd_divergence_pass.hlsl
-
7Shaders/shaders/ffx_opticalflow_compute_scd_divergence_pass.hlsl.meta
-
56Shaders/shaders/ffx_opticalflow_filter_optical_flow_pass_v5.hlsl
-
7Shaders/shaders/ffx_opticalflow_filter_optical_flow_pass_v5.hlsl.meta
-
54Shaders/shaders/ffx_opticalflow_generate_scd_histogram_pass.hlsl
-
7Shaders/shaders/ffx_opticalflow_generate_scd_histogram_pass.hlsl.meta
-
50Shaders/shaders/ffx_opticalflow_prepare_luma_pass.hlsl
-
7Shaders/shaders/ffx_opticalflow_prepare_luma_pass.hlsl.meta
-
62Shaders/shaders/ffx_opticalflow_scale_optical_flow_advanced_pass_v5.hlsl
-
7Shaders/shaders/ffx_opticalflow_scale_optical_flow_advanced_pass_v5.hlsl.meta
-
8Shaders/shaders/frameinterpolation.meta
-
192Shaders/shaders/frameinterpolation/ffx_frameinterpolation.h
-
60Shaders/shaders/frameinterpolation/ffx_frameinterpolation.h.meta
-
778Shaders/shaders/frameinterpolation/ffx_frameinterpolation_callbacks_hlsl.h
-
60Shaders/shaders/frameinterpolation/ffx_frameinterpolation_callbacks_hlsl.h.meta
-
445Shaders/shaders/frameinterpolation/ffx_frameinterpolation_common.h
-
60Shaders/shaders/frameinterpolation/ffx_frameinterpolation_common.h.meta
-
121Shaders/shaders/frameinterpolation/ffx_frameinterpolation_compute_game_vector_field_inpainting_pyramid.h
-
60Shaders/shaders/frameinterpolation/ffx_frameinterpolation_compute_game_vector_field_inpainting_pyramid.h.meta
-
120Shaders/shaders/frameinterpolation/ffx_frameinterpolation_compute_inpainting_pyramid.h
-
60Shaders/shaders/frameinterpolation/ffx_frameinterpolation_compute_inpainting_pyramid.h.meta
-
163Shaders/shaders/frameinterpolation/ffx_frameinterpolation_debug_view.h
-
60Shaders/shaders/frameinterpolation/ffx_frameinterpolation_debug_view.h.meta
-
142Shaders/shaders/frameinterpolation/ffx_frameinterpolation_disocclusion_mask.h
-
60Shaders/shaders/frameinterpolation/ffx_frameinterpolation_disocclusion_mask.h.meta
-
118Shaders/shaders/frameinterpolation/ffx_frameinterpolation_game_motion_vector_field.h
-
60Shaders/shaders/frameinterpolation/ffx_frameinterpolation_game_motion_vector_field.h.meta
-
150Shaders/shaders/frameinterpolation/ffx_frameinterpolation_inpainting.h
-
60Shaders/shaders/frameinterpolation/ffx_frameinterpolation_inpainting.h.meta
-
124Shaders/shaders/frameinterpolation/ffx_frameinterpolation_optical_flow_vector_field.h
-
60Shaders/shaders/frameinterpolation/ffx_frameinterpolation_optical_flow_vector_field.h.meta
-
123Shaders/shaders/frameinterpolation/ffx_frameinterpolation_reconstruct_dilated_velocity_and_previous_depth.h
-
60Shaders/shaders/frameinterpolation/ffx_frameinterpolation_reconstruct_dilated_velocity_and_previous_depth.h.meta
-
59Shaders/shaders/frameinterpolation/ffx_frameinterpolation_reconstruct_previous_depth.h
-
60Shaders/shaders/frameinterpolation/ffx_frameinterpolation_reconstruct_previous_depth.h.meta
-
99Shaders/shaders/frameinterpolation/ffx_frameinterpolation_resources.h
-
60Shaders/shaders/frameinterpolation/ffx_frameinterpolation_resources.h.meta
-
50Shaders/shaders/frameinterpolation/ffx_frameinterpolation_setup.h
-
60Shaders/shaders/frameinterpolation/ffx_frameinterpolation_setup.h.meta
-
8Shaders/shaders/fsr3.meta
-
24Shaders/shaders/fsr3/ffx_fsr3_callbacks_hlsl.h
-
60Shaders/shaders/fsr3/ffx_fsr3_callbacks_hlsl.h.meta
-
25Shaders/shaders/fsr3/ffx_fsr3_common.h
-
60Shaders/shaders/fsr3/ffx_fsr3_common.h.meta
-
37Shaders/shaders/fsr3/ffx_fsr3_resources.h
-
60Shaders/shaders/fsr3/ffx_fsr3_resources.h.meta
-
8Shaders/shaders/opticalflow.meta
-
634Shaders/shaders/opticalflow/ffx_opticalflow_callbacks_hlsl.h
-
60Shaders/shaders/opticalflow/ffx_opticalflow_callbacks_hlsl.h.meta
-
99Shaders/shaders/opticalflow/ffx_opticalflow_common.h
-
60Shaders/shaders/opticalflow/ffx_opticalflow_common.h.meta
-
107Shaders/shaders/opticalflow/ffx_opticalflow_compute_luminance_pyramid.h
-
60Shaders/shaders/opticalflow/ffx_opticalflow_compute_luminance_pyramid.h.meta
-
279Shaders/shaders/opticalflow/ffx_opticalflow_compute_optical_flow_v5.h
-
60Shaders/shaders/opticalflow/ffx_opticalflow_compute_optical_flow_v5.h.meta
-
159Shaders/shaders/opticalflow/ffx_opticalflow_compute_scd_divergence.h
-
60Shaders/shaders/opticalflow/ffx_opticalflow_compute_scd_divergence.h.meta
-
58Shaders/shaders/opticalflow/ffx_opticalflow_filter_optical_flow_v5.h
-
60Shaders/shaders/opticalflow/ffx_opticalflow_filter_optical_flow_v5.h.meta
-
92Shaders/shaders/opticalflow/ffx_opticalflow_generate_scd_histogram.h
-
60Shaders/shaders/opticalflow/ffx_opticalflow_generate_scd_histogram.h.meta
-
106Shaders/shaders/opticalflow/ffx_opticalflow_prepare_luma.h
-
60Shaders/shaders/opticalflow/ffx_opticalflow_prepare_luma.h.meta
-
74Shaders/shaders/opticalflow/ffx_opticalflow_resources.h
-
60Shaders/shaders/opticalflow/ffx_opticalflow_resources.h.meta
-
99Shaders/shaders/opticalflow/ffx_opticalflow_scale_optical_flow_advanced_v5.h
-
60Shaders/shaders/opticalflow/ffx_opticalflow_scale_optical_flow_advanced_v5.h.meta
@ -0,0 +1,71 @@ |
|||
// 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. |
|||
|
|||
#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 0 |
|||
#define FFX_FRAMEINTERPOLATION_BIND_UAV_INPAINTING_PYRAMID_MIPMAP_0 1 |
|||
#define FFX_FRAMEINTERPOLATION_BIND_UAV_INPAINTING_PYRAMID_MIPMAP_1 2 |
|||
#define FFX_FRAMEINTERPOLATION_BIND_UAV_INPAINTING_PYRAMID_MIPMAP_2 3 |
|||
#define FFX_FRAMEINTERPOLATION_BIND_UAV_INPAINTING_PYRAMID_MIPMAP_3 4 |
|||
#define FFX_FRAMEINTERPOLATION_BIND_UAV_INPAINTING_PYRAMID_MIPMAP_4 5 |
|||
#define FFX_FRAMEINTERPOLATION_BIND_UAV_INPAINTING_PYRAMID_MIPMAP_5 6 |
|||
#define FFX_FRAMEINTERPOLATION_BIND_UAV_INPAINTING_PYRAMID_MIPMAP_6 7 |
|||
#define FFX_FRAMEINTERPOLATION_BIND_UAV_INPAINTING_PYRAMID_MIPMAP_7 8 |
|||
#define FFX_FRAMEINTERPOLATION_BIND_UAV_INPAINTING_PYRAMID_MIPMAP_8 9 |
|||
#define FFX_FRAMEINTERPOLATION_BIND_UAV_INPAINTING_PYRAMID_MIPMAP_9 10 |
|||
#define FFX_FRAMEINTERPOLATION_BIND_UAV_INPAINTING_PYRAMID_MIPMAP_10 11 |
|||
#define FFX_FRAMEINTERPOLATION_BIND_UAV_INPAINTING_PYRAMID_MIPMAP_11 12 |
|||
#define FFX_FRAMEINTERPOLATION_BIND_UAV_INPAINTING_PYRAMID_MIPMAP_12 13 |
|||
|
|||
#define FFX_FRAMEINTERPOLATION_BIND_CB_FRAMEINTERPOLATION 0 |
|||
|
|||
#ifdef FFX_HALF |
|||
#undef FFX_HALF |
|||
#define FFX_HALF 0 |
|||
#endif |
|||
|
|||
#define FFX_FRAMEINTERPOLATION_BIND_CB_INPAINTING_PYRAMID 1 |
|||
|
|||
#include "frameinterpolation/ffx_frameinterpolation_callbacks_hlsl.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 [numthreads(FFX_FRAMEINTERPOLATION_THREAD_GROUP_WIDTH, FFX_FRAMEINTERPOLATION_THREAD_GROUP_HEIGHT, FFX_FRAMEINTERPOLATION_THREAD_GROUP_DEPTH)] |
|||
#endif // #ifndef FFX_FRAMEINTERPOLATION_NUM_THREADS |
|||
|
|||
FFX_FRAMEINTERPOLATION_NUM_THREADS |
|||
void CS(FfxUInt32x3 WorkGroupId : SV_GroupID, FfxUInt32 LocalThreadIndex : SV_GroupIndex) |
|||
{ |
|||
computeFrameinterpolationGameVectorFieldInpaintingPyramid(WorkGroupId, LocalThreadIndex); |
|||
} |
|||
@ -0,0 +1,7 @@ |
|||
fileFormatVersion: 2 |
|||
guid: 3cd4562d24383ce4fa00eadf5d122cd9 |
|||
ShaderIncludeImporter: |
|||
externalObjects: {} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|||
@ -0,0 +1,70 @@ |
|||
// 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. |
|||
|
|||
#define FFX_FRAMEINTERPOLATION_BIND_SRV_OUTPUT 0 |
|||
|
|||
#define FFX_FRAMEINTERPOLATION_BIND_UAV_COUNTERS 0 |
|||
#define FFX_FRAMEINTERPOLATION_BIND_UAV_INPAINTING_PYRAMID_MIPMAP_0 1 |
|||
#define FFX_FRAMEINTERPOLATION_BIND_UAV_INPAINTING_PYRAMID_MIPMAP_1 2 |
|||
#define FFX_FRAMEINTERPOLATION_BIND_UAV_INPAINTING_PYRAMID_MIPMAP_2 3 |
|||
#define FFX_FRAMEINTERPOLATION_BIND_UAV_INPAINTING_PYRAMID_MIPMAP_3 4 |
|||
#define FFX_FRAMEINTERPOLATION_BIND_UAV_INPAINTING_PYRAMID_MIPMAP_4 5 |
|||
#define FFX_FRAMEINTERPOLATION_BIND_UAV_INPAINTING_PYRAMID_MIPMAP_5 6 |
|||
#define FFX_FRAMEINTERPOLATION_BIND_UAV_INPAINTING_PYRAMID_MIPMAP_6 7 |
|||
#define FFX_FRAMEINTERPOLATION_BIND_UAV_INPAINTING_PYRAMID_MIPMAP_7 8 |
|||
#define FFX_FRAMEINTERPOLATION_BIND_UAV_INPAINTING_PYRAMID_MIPMAP_8 9 |
|||
#define FFX_FRAMEINTERPOLATION_BIND_UAV_INPAINTING_PYRAMID_MIPMAP_9 10 |
|||
#define FFX_FRAMEINTERPOLATION_BIND_UAV_INPAINTING_PYRAMID_MIPMAP_10 11 |
|||
#define FFX_FRAMEINTERPOLATION_BIND_UAV_INPAINTING_PYRAMID_MIPMAP_11 12 |
|||
#define FFX_FRAMEINTERPOLATION_BIND_UAV_INPAINTING_PYRAMID_MIPMAP_12 13 |
|||
|
|||
#define FFX_FRAMEINTERPOLATION_BIND_CB_FRAMEINTERPOLATION 0 |
|||
|
|||
#ifdef FFX_HALF |
|||
#undef FFX_HALF |
|||
#define FFX_HALF 0 |
|||
#endif |
|||
|
|||
#define FFX_FRAMEINTERPOLATION_BIND_CB_INPAINTING_PYRAMID 1 |
|||
|
|||
#include "frameinterpolation/ffx_frameinterpolation_callbacks_hlsl.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 [numthreads(FFX_FRAMEINTERPOLATION_THREAD_GROUP_WIDTH, FFX_FRAMEINTERPOLATION_THREAD_GROUP_HEIGHT, FFX_FRAMEINTERPOLATION_THREAD_GROUP_DEPTH)] |
|||
#endif // #ifndef FFX_FRAMEINTERPOLATION_NUM_THREADS |
|||
|
|||
FFX_FRAMEINTERPOLATION_NUM_THREADS |
|||
void CS(FfxUInt32x3 WorkGroupId : SV_GroupID, FfxUInt32 LocalThreadIndex : SV_GroupIndex) |
|||
{ |
|||
computeFrameinterpolationInpaintingPyramid(WorkGroupId, LocalThreadIndex); |
|||
} |
|||
@ -0,0 +1,7 @@ |
|||
fileFormatVersion: 2 |
|||
guid: 37d572f0b28b6f645a923b6590f12efb |
|||
ShaderIncludeImporter: |
|||
externalObjects: {} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|||
@ -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. |
|||
|
|||
#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_UAV_OUTPUT 0 |
|||
|
|||
#define FFX_FRAMEINTERPOLATION_BIND_CB_FRAMEINTERPOLATION 0 |
|||
|
|||
#include "frameinterpolation/ffx_frameinterpolation_callbacks_hlsl.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 [numthreads(FFX_FRAMEINTERPOLATION_THREAD_GROUP_WIDTH, FFX_FRAMEINTERPOLATION_THREAD_GROUP_HEIGHT, FFX_FRAMEINTERPOLATION_THREAD_GROUP_DEPTH)] |
|||
#endif // #ifndef FFX_FRAMEINTERPOLATION_NUM_THREADS |
|||
|
|||
FFX_FRAMEINTERPOLATION_NUM_THREADS |
|||
void CS(FfxInt32x2 iPxPos : SV_DispatchThreadID) |
|||
{ |
|||
computeDebugView(iPxPos); |
|||
} |
|||
@ -0,0 +1,7 @@ |
|||
fileFormatVersion: 2 |
|||
guid: 354e05e22a936934089e2c7bfb157e9e |
|||
ShaderIncludeImporter: |
|||
externalObjects: {} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|||
@ -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. |
|||
|
|||
#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_UAV_DISOCCLUSION_MASK 0 |
|||
|
|||
#define FFX_FRAMEINTERPOLATION_BIND_CB_FRAMEINTERPOLATION 0 |
|||
|
|||
#include "frameinterpolation/ffx_frameinterpolation_callbacks_hlsl.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 [numthreads(FFX_FRAMEINTERPOLATION_THREAD_GROUP_WIDTH, FFX_FRAMEINTERPOLATION_THREAD_GROUP_HEIGHT, FFX_FRAMEINTERPOLATION_THREAD_GROUP_DEPTH)] |
|||
#endif // #ifndef FFX_FRAMEINTERPOLATION_NUM_THREADS |
|||
|
|||
FFX_FRAMEINTERPOLATION_NUM_THREADS |
|||
void CS(FfxInt32x2 iPxPos : SV_DispatchThreadID) |
|||
{ |
|||
computeDisocclusionMask(iPxPos); |
|||
} |
|||
@ -0,0 +1,7 @@ |
|||
fileFormatVersion: 2 |
|||
guid: f8740ba66c4b7624ea1abc8b3e6c35b1 |
|||
ShaderIncludeImporter: |
|||
externalObjects: {} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|||
@ -0,0 +1,54 @@ |
|||
// 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. |
|||
|
|||
#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_UAV_GAME_MOTION_VECTOR_FIELD_X 0 |
|||
#define FFX_FRAMEINTERPOLATION_BIND_UAV_GAME_MOTION_VECTOR_FIELD_Y 1 |
|||
|
|||
#define FFX_FRAMEINTERPOLATION_BIND_CB_FRAMEINTERPOLATION 0 |
|||
|
|||
#include "frameinterpolation/ffx_frameinterpolation_callbacks_hlsl.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 [numthreads(FFX_FRAMEINTERPOLATION_THREAD_GROUP_WIDTH, FFX_FRAMEINTERPOLATION_THREAD_GROUP_HEIGHT, FFX_FRAMEINTERPOLATION_THREAD_GROUP_DEPTH)] |
|||
#endif // #ifndef FFX_FRAMEINTERPOLATION_NUM_THREADS |
|||
|
|||
FFX_FRAMEINTERPOLATION_NUM_THREADS |
|||
void CS(FfxInt32x2 iPxPos : SV_DispatchThreadID) |
|||
{ |
|||
computeGameFieldMvs(iPxPos); |
|||
} |
|||
@ -0,0 +1,7 @@ |
|||
fileFormatVersion: 2 |
|||
guid: 60cde4822dd54e6499101ea385167618 |
|||
ShaderIncludeImporter: |
|||
externalObjects: {} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|||
@ -0,0 +1,53 @@ |
|||
// 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. |
|||
|
|||
#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 0 |
|||
|
|||
#define FFX_FRAMEINTERPOLATION_BIND_CB_FRAMEINTERPOLATION 0 |
|||
|
|||
#include "frameinterpolation/ffx_frameinterpolation_callbacks_hlsl.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 [numthreads(FFX_FRAMEINTERPOLATION_THREAD_GROUP_WIDTH, FFX_FRAMEINTERPOLATION_THREAD_GROUP_HEIGHT, FFX_FRAMEINTERPOLATION_THREAD_GROUP_DEPTH)] |
|||
#endif // #ifndef FFX_FRAMEINTERPOLATION_NUM_THREADS |
|||
|
|||
FFX_FRAMEINTERPOLATION_NUM_THREADS |
|||
void CS(FfxInt32x2 iPxPos : SV_DispatchThreadID) |
|||
{ |
|||
computeInpainting(iPxPos); |
|||
} |
|||
@ -0,0 +1,7 @@ |
|||
fileFormatVersion: 2 |
|||
guid: 1296628e84d82b442955b313b553aa73 |
|||
ShaderIncludeImporter: |
|||
externalObjects: {} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|||
@ -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. |
|||
|
|||
#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 0 |
|||
#define FFX_FRAMEINTERPOLATION_BIND_UAV_OPTICAL_FLOW_MOTION_VECTOR_FIELD_Y 1 |
|||
|
|||
#define FFX_FRAMEINTERPOLATION_BIND_CB_FRAMEINTERPOLATION 0 |
|||
|
|||
#include "frameinterpolation/ffx_frameinterpolation_callbacks_hlsl.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 [numthreads(FFX_FRAMEINTERPOLATION_THREAD_GROUP_WIDTH, FFX_FRAMEINTERPOLATION_THREAD_GROUP_HEIGHT, FFX_FRAMEINTERPOLATION_THREAD_GROUP_DEPTH)] |
|||
#endif // #ifndef FFX_FRAMEINTERPOLATION_NUM_THREADS |
|||
|
|||
FFX_FRAMEINTERPOLATION_NUM_THREADS |
|||
void CS(FfxInt32x2 iPxPos : SV_DispatchThreadID) |
|||
{ |
|||
computeOpticalFlowVectorField(iPxPos); |
|||
} |
|||
@ -0,0 +1,7 @@ |
|||
fileFormatVersion: 2 |
|||
guid: 274f931fd4682ac46995bfd8d55957d9 |
|||
ShaderIncludeImporter: |
|||
externalObjects: {} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|||
@ -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. |
|||
|
|||
#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 0 |
|||
|
|||
#define FFX_FRAMEINTERPOLATION_BIND_CB_FRAMEINTERPOLATION 0 |
|||
|
|||
#include "frameinterpolation/ffx_frameinterpolation_callbacks_hlsl.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 [numthreads(FFX_FRAMEINTERPOLATION_THREAD_GROUP_WIDTH, FFX_FRAMEINTERPOLATION_THREAD_GROUP_HEIGHT, FFX_FRAMEINTERPOLATION_THREAD_GROUP_DEPTH)] |
|||
#endif // #ifndef FFX_FRAMEINTERPOLATION_NUM_THREADS |
|||
|
|||
FFX_FRAMEINTERPOLATION_NUM_THREADS |
|||
void CS(FfxInt32x2 iPxPos : SV_DispatchThreadID) |
|||
{ |
|||
computeFrameinterpolation(iPxPos); |
|||
} |
|||
@ -0,0 +1,7 @@ |
|||
fileFormatVersion: 2 |
|||
guid: f5a24abc414175245b30414b90c737f7 |
|||
ShaderIncludeImporter: |
|||
externalObjects: {} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|||
@ -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. |
|||
|
|||
#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 0 |
|||
#define FFX_FRAMEINTERPOLATION_BIND_UAV_DILATED_MOTION_VECTORS 1 |
|||
#define FFX_FRAMEINTERPOLATION_BIND_UAV_DILATED_DEPTH 2 |
|||
|
|||
#define FFX_FRAMEINTERPOLATION_BIND_CB_FRAMEINTERPOLATION 0 |
|||
|
|||
#include "frameinterpolation/ffx_frameinterpolation_callbacks_hlsl.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 [numthreads(FFX_FRAMEINTERPOLATION_THREAD_GROUP_WIDTH, FFX_FRAMEINTERPOLATION_THREAD_GROUP_HEIGHT, FFX_FRAMEINTERPOLATION_THREAD_GROUP_DEPTH)] |
|||
#endif // #ifndef FFX_FSR3UPSCALER_NUM_THREADS |
|||
|
|||
FFX_FRAMEINTERPOLATION_NUM_THREADS |
|||
void CS( |
|||
int2 iGroupId : SV_GroupID, |
|||
int2 iDispatchThreadId : SV_DispatchThreadID, |
|||
int2 iGroupThreadId : SV_GroupThreadID, |
|||
int iGroupIndex : SV_GroupIndex |
|||
) |
|||
{ |
|||
ReconstructAndDilate(iDispatchThreadId); |
|||
} |
|||
@ -0,0 +1,7 @@ |
|||
fileFormatVersion: 2 |
|||
guid: 9ab74cb734203714c82850108dd09b66 |
|||
ShaderIncludeImporter: |
|||
externalObjects: {} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|||
@ -0,0 +1,52 @@ |
|||
// 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. |
|||
|
|||
#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_UAV_RECONSTRUCTED_DEPTH_INTERPOLATED_FRAME 0 |
|||
|
|||
#define FFX_FRAMEINTERPOLATION_BIND_CB_FRAMEINTERPOLATION 0 |
|||
|
|||
#include "frameinterpolation/ffx_frameinterpolation_callbacks_hlsl.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 [numthreads(FFX_FRAMEINTERPOLATION_THREAD_GROUP_WIDTH, FFX_FRAMEINTERPOLATION_THREAD_GROUP_HEIGHT, FFX_FRAMEINTERPOLATION_THREAD_GROUP_DEPTH)] |
|||
#endif // #ifndef FFX_FRAMEINTERPOLATION_NUM_THREADS |
|||
|
|||
FFX_FRAMEINTERPOLATION_NUM_THREADS |
|||
void CS(FfxInt32x2 iPxPos : SV_DispatchThreadID) |
|||
{ |
|||
reconstructPreviousDepth(iPxPos); |
|||
} |
|||
@ -0,0 +1,7 @@ |
|||
fileFormatVersion: 2 |
|||
guid: c18054d765fcf0f4499305fa7accdf27 |
|||
ShaderIncludeImporter: |
|||
externalObjects: {} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|||
@ -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. |
|||
|
|||
#define FFX_FRAMEINTERPOLATION_BIND_SRV_OPTICAL_FLOW_SCENE_CHANGE_DETECTION 0 |
|||
|
|||
#define FFX_FRAMEINTERPOLATION_BIND_UAV_GAME_MOTION_VECTOR_FIELD_X 0 |
|||
#define FFX_FRAMEINTERPOLATION_BIND_UAV_GAME_MOTION_VECTOR_FIELD_Y 1 |
|||
#define FFX_FRAMEINTERPOLATION_BIND_UAV_OPTICAL_FLOW_MOTION_VECTOR_FIELD_X 2 |
|||
#define FFX_FRAMEINTERPOLATION_BIND_UAV_OPTICAL_FLOW_MOTION_VECTOR_FIELD_Y 3 |
|||
#define FFX_FRAMEINTERPOLATION_BIND_UAV_DISOCCLUSION_MASK 4 |
|||
#define FFX_FRAMEINTERPOLATION_BIND_UAV_COUNTERS 5 |
|||
|
|||
#define FFX_FRAMEINTERPOLATION_BIND_CB_FRAMEINTERPOLATION 0 |
|||
|
|||
#include "frameinterpolation/ffx_frameinterpolation_callbacks_hlsl.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 [numthreads(FFX_FRAMEINTERPOLATION_THREAD_GROUP_WIDTH, FFX_FRAMEINTERPOLATION_THREAD_GROUP_HEIGHT, FFX_FRAMEINTERPOLATION_THREAD_GROUP_DEPTH)] |
|||
#endif // #ifndef FFX_FRAMEINTERPOLATION_NUM_THREADS |
|||
|
|||
FFX_FRAMEINTERPOLATION_NUM_THREADS |
|||
void CS(FfxInt32x2 iPxPos : SV_DispatchThreadID) |
|||
{ |
|||
setupFrameinterpolationResources(iPxPos); |
|||
} |
|||
@ -0,0 +1,7 @@ |
|||
fileFormatVersion: 2 |
|||
guid: 12f0653f1cdae7f4ca75c41024576f2f |
|||
ShaderIncludeImporter: |
|||
externalObjects: {} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|||
@ -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. |
|||
|
|||
#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 0 |
|||
#define FFX_OPTICALFLOW_BIND_CB_SPD 1 |
|||
|
|||
#include "opticalflow/ffx_opticalflow_callbacks_hlsl.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 [numthreads(FFX_OPTICALFLOW_THREAD_GROUP_WIDTH, FFX_OPTICALFLOW_THREAD_GROUP_HEIGHT, FFX_OPTICALFLOW_THREAD_GROUP_DEPTH)] |
|||
#endif // #ifndef FFX_OPTICALFLOW_NUM_THREADS |
|||
|
|||
FFX_OPTICALFLOW_NUM_THREADS |
|||
FFX_OPTICALFLOW_EMBED_CB2_ROOTSIG_CONTENT |
|||
void CS(int2 iGlobalId : SV_DispatchThreadID, |
|||
int2 iGroupId : SV_GroupID, |
|||
int iLocalIndex : SV_GroupIndex) |
|||
{ |
|||
ComputeOpticalFlowInputPyramid(iGroupId, iLocalIndex); |
|||
} |
|||
@ -0,0 +1,7 @@ |
|||
fileFormatVersion: 2 |
|||
guid: 7752434668a56bb4a9a44893de0e30c0 |
|||
ShaderIncludeImporter: |
|||
externalObjects: {} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|||
@ -0,0 +1,63 @@ |
|||
// 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. |
|||
|
|||
#define FFX_WAVE 1 |
|||
|
|||
#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 0 |
|||
#define FFX_OPTICALFLOW_BIND_UAV_OPTICAL_FLOW_SCD_OUTPUT 1 |
|||
|
|||
#define FFX_OPTICALFLOW_BIND_CB_COMMON 0 |
|||
|
|||
#include "opticalflow/ffx_opticalflow_callbacks_hlsl.h" |
|||
|
|||
#ifndef FFX_OPTICALFLOW_BLOCK_SIZE |
|||
#define FFX_OPTICALFLOW_BLOCK_SIZE 8 |
|||
#endif |
|||
#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 [numthreads(FFX_OPTICALFLOW_THREAD_GROUP_WIDTH, FFX_OPTICALFLOW_THREAD_GROUP_HEIGHT, FFX_OPTICALFLOW_THREAD_GROUP_DEPTH)] |
|||
#endif // #ifndef FFX_OPTICALFLOW_NUM_THREADS |
|||
|
|||
FFX_OPTICALFLOW_NUM_THREADS |
|||
FFX_OPTICALFLOW_EMBED_ROOTSIG_CONTENT |
|||
FFX_PREFER_WAVE64 |
|||
void CS(int2 iGlobalId : SV_DispatchThreadID, |
|||
int2 iLocalId : SV_GroupThreadID, |
|||
int2 iGroupId : SV_GroupID, |
|||
int iLocalIndex : SV_GroupIndex) |
|||
{ |
|||
ComputeOpticalFlowAdvanced(iGlobalId, iLocalId, iGroupId, iLocalIndex); |
|||
} |
|||
@ -0,0 +1,7 @@ |
|||
fileFormatVersion: 2 |
|||
guid: 147318f7f0a12f34ea3afcb41cfcdb9b |
|||
ShaderIncludeImporter: |
|||
externalObjects: {} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|||
@ -0,0 +1,56 @@ |
|||
// 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. |
|||
|
|||
#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 0 |
|||
|
|||
#include "opticalflow/ffx_opticalflow_callbacks_hlsl.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 [numthreads(FFX_OPTICALFLOW_THREAD_GROUP_WIDTH, FFX_OPTICALFLOW_THREAD_GROUP_HEIGHT, FFX_OPTICALFLOW_THREAD_GROUP_DEPTH)] |
|||
#endif // #ifndef FFX_OPTICALFLOW_NUM_THREADS |
|||
|
|||
FFX_OPTICALFLOW_NUM_THREADS |
|||
FFX_OPTICALFLOW_EMBED_ROOTSIG_CONTENT |
|||
FFX_PREFER_WAVE64 |
|||
void CS(int3 iGlobalId : SV_DispatchThreadID, |
|||
int2 iLocalId : SV_GroupThreadID, |
|||
int2 iGroupId : SV_GroupID, |
|||
int iLocalIndex : SV_GroupIndex) |
|||
{ |
|||
int2 iGroupSize = int2(FFX_OPTICALFLOW_THREAD_GROUP_WIDTH, FFX_OPTICALFLOW_THREAD_GROUP_HEIGHT); |
|||
ComputeSCDHistogramsDivergence(iGlobalId, iLocalId, iLocalIndex, iGroupId, iGroupSize); |
|||
} |
|||
@ -0,0 +1,7 @@ |
|||
fileFormatVersion: 2 |
|||
guid: 5ca6afef1cf3c134498a709d2a6d4d54 |
|||
ShaderIncludeImporter: |
|||
externalObjects: {} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|||
@ -0,0 +1,56 @@ |
|||
// 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. |
|||
|
|||
#define FFX_OPTICALFLOW_BIND_SRV_OPTICAL_FLOW_PREVIOUS 0 |
|||
|
|||
#define FFX_OPTICALFLOW_BIND_UAV_OPTICAL_FLOW 0 |
|||
|
|||
#define FFX_OPTICALFLOW_BIND_CB_COMMON 0 |
|||
|
|||
#include "opticalflow/ffx_opticalflow_callbacks_hlsl.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 [numthreads(FFX_OPTICALFLOW_THREAD_GROUP_WIDTH, FFX_OPTICALFLOW_THREAD_GROUP_HEIGHT, FFX_OPTICALFLOW_THREAD_GROUP_DEPTH)] |
|||
#endif // #ifndef FFX_OPTICALFLOW_NUM_THREADS |
|||
|
|||
FFX_OPTICALFLOW_NUM_THREADS |
|||
FFX_OPTICALFLOW_EMBED_ROOTSIG_CONTENT |
|||
FFX_PREFER_WAVE64 |
|||
void CS(int2 iGlobalId : SV_DispatchThreadID, |
|||
int2 iLocalId : SV_GroupThreadID, |
|||
int2 iGroupId : SV_GroupID, |
|||
int iLocalIndex : SV_GroupIndex) |
|||
{ |
|||
FilterOpticalFlow(iGlobalId, iLocalId, iGroupId, iLocalIndex); |
|||
} |
|||
@ -0,0 +1,7 @@ |
|||
fileFormatVersion: 2 |
|||
guid: 59903e151d8d6594d97a989a7dd21df1 |
|||
ShaderIncludeImporter: |
|||
externalObjects: {} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|||
@ -0,0 +1,54 @@ |
|||
// 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. |
|||
|
|||
#define FFX_OPTICALFLOW_BIND_SRV_OPTICAL_FLOW_INPUT 0 |
|||
#define FFX_OPTICALFLOW_BIND_UAV_OPTICAL_FLOW_SCD_HISTOGRAM 0 |
|||
|
|||
#define FFX_OPTICALFLOW_BIND_CB_COMMON 0 |
|||
|
|||
#include "opticalflow/ffx_opticalflow_callbacks_hlsl.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_HEIGHT |
|||
#define FFX_OPTICALFLOW_THREAD_GROUP_HEIGHT 8 |
|||
#endif |
|||
#ifndef FFX_OPTICALFLOW_THREAD_GROUP_DEPTH |
|||
#define FFX_OPTICALFLOW_THREAD_GROUP_DEPTH 1 |
|||
#endif |
|||
#ifndef FFX_OPTICALFLOW_NUM_THREADS |
|||
#define FFX_OPTICALFLOW_NUM_THREADS [numthreads(FFX_OPTICALFLOW_THREAD_GROUP_WIDTH, FFX_OPTICALFLOW_THREAD_GROUP_HEIGHT, FFX_OPTICALFLOW_THREAD_GROUP_DEPTH)] |
|||
#endif |
|||
|
|||
FFX_OPTICALFLOW_NUM_THREADS |
|||
FFX_OPTICALFLOW_EMBED_ROOTSIG_CONTENT |
|||
FFX_PREFER_WAVE64 |
|||
void CS(int3 iGlobalId : SV_DispatchThreadID, |
|||
int2 iLocalId : SV_GroupThreadID, |
|||
int2 iGroupId : SV_GroupID, |
|||
int iLocalIndex : SV_GroupIndex) |
|||
{ |
|||
int2 iGroupSize = int2(FFX_OPTICALFLOW_THREAD_GROUP_WIDTH, FFX_OPTICALFLOW_THREAD_GROUP_HEIGHT); |
|||
GenerateSceneChangeDetectionHistogram(iGlobalId, iLocalId, iLocalIndex, iGroupId, iGroupSize); |
|||
} |
|||
@ -0,0 +1,7 @@ |
|||
fileFormatVersion: 2 |
|||
guid: 9f4290c7d6c15f641a115e39b7ec5342 |
|||
ShaderIncludeImporter: |
|||
externalObjects: {} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|||
@ -0,0 +1,50 @@ |
|||
// 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. |
|||
|
|||
#define FFX_OPTICALFLOW_BIND_SRV_INPUT_COLOR 0 |
|||
#define FFX_OPTICALFLOW_BIND_UAV_OPTICAL_FLOW_INPUT 0 |
|||
|
|||
#define FFX_OPTICALFLOW_BIND_CB_COMMON 0 |
|||
|
|||
#include "opticalflow/ffx_opticalflow_callbacks_hlsl.h" |
|||
|
|||
#ifndef FFX_OPTICALFLOW_THREAD_GROUP_WIDTH |
|||
#define FFX_OPTICALFLOW_THREAD_GROUP_WIDTH 16 |
|||
#endif |
|||
#ifndef FFX_OPTICALFLOW_THREAD_GROUP_HEIGHT |
|||
#define FFX_OPTICALFLOW_THREAD_GROUP_HEIGHT 16 |
|||
#endif |
|||
#ifndef FFX_OPTICALFLOW_THREAD_GROUP_DEPTH |
|||
#define FFX_OPTICALFLOW_THREAD_GROUP_DEPTH 1 |
|||
#endif |
|||
#ifndef FFX_OPTICALFLOW_NUM_THREADS |
|||
#define FFX_OPTICALFLOW_NUM_THREADS [numthreads(FFX_OPTICALFLOW_THREAD_GROUP_WIDTH, FFX_OPTICALFLOW_THREAD_GROUP_HEIGHT, FFX_OPTICALFLOW_THREAD_GROUP_DEPTH)] |
|||
#endif |
|||
|
|||
#include "opticalflow/ffx_opticalflow_prepare_luma.h" |
|||
|
|||
FFX_OPTICALFLOW_NUM_THREADS |
|||
FFX_OPTICALFLOW_EMBED_ROOTSIG_CONTENT |
|||
void CS(int2 iGlobalId : SV_DispatchThreadID, int iLocalIndex : SV_GroupIndex) |
|||
{ |
|||
PrepareLuma(iGlobalId, iLocalIndex); |
|||
} |
|||
@ -0,0 +1,7 @@ |
|||
fileFormatVersion: 2 |
|||
guid: 455ee99394fc6a04e94c113d68e72241 |
|||
ShaderIncludeImporter: |
|||
externalObjects: {} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|||
@ -0,0 +1,62 @@ |
|||
// 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. |
|||
|
|||
#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 0 |
|||
#define FFX_OPTICALFLOW_BIND_UAV_OPTICAL_FLOW_SCD_OUTPUT 1 |
|||
|
|||
#define FFX_OPTICALFLOW_BIND_CB_COMMON 0 |
|||
|
|||
#include "opticalflow/ffx_opticalflow_callbacks_hlsl.h" |
|||
|
|||
#ifndef FFX_OPTICALFLOW_BLOCK_SIZE |
|||
#define FFX_OPTICALFLOW_BLOCK_SIZE 8 |
|||
#endif |
|||
|
|||
#ifndef FFX_OPTICALFLOW_THREAD_GROUP_WIDTH |
|||
#define FFX_OPTICALFLOW_THREAD_GROUP_WIDTH 4 |
|||
#endif |
|||
|
|||
#ifndef FFX_OPTICALFLOW_THREAD_GROUP_HEIGHT |
|||
#define FFX_OPTICALFLOW_THREAD_GROUP_HEIGHT 4 |
|||
#endif |
|||
|
|||
#ifndef FFX_OPTICALFLOW_THREAD_GROUP_DEPTH |
|||
#define FFX_OPTICALFLOW_THREAD_GROUP_DEPTH 4 |
|||
#endif |
|||
|
|||
#include "opticalflow/ffx_opticalflow_scale_optical_flow_advanced_v5.h" |
|||
|
|||
#ifndef FFX_OPTICALFLOW_NUM_THREADS |
|||
#define FFX_OPTICALFLOW_NUM_THREADS [numthreads(FFX_OPTICALFLOW_THREAD_GROUP_WIDTH, FFX_OPTICALFLOW_THREAD_GROUP_HEIGHT, FFX_OPTICALFLOW_THREAD_GROUP_DEPTH)] |
|||
#endif |
|||
|
|||
FFX_OPTICALFLOW_NUM_THREADS |
|||
FFX_OPTICALFLOW_EMBED_ROOTSIG_CONTENT |
|||
FFX_PREFER_WAVE64 |
|||
void CS(int3 iGlobalId : SV_DispatchThreadID, int3 iLocalId : SV_GroupThreadID) |
|||
{ |
|||
ScaleOpticalFlowAdvanced(iGlobalId, iLocalId); |
|||
} |
|||
@ -0,0 +1,7 @@ |
|||
fileFormatVersion: 2 |
|||
guid: c1132c214a4b8244280127c25ba743b0 |
|||
ShaderIncludeImporter: |
|||
externalObjects: {} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|||
@ -0,0 +1,8 @@ |
|||
fileFormatVersion: 2 |
|||
guid: b8f9d950634cf174fa36dc607959997a |
|||
folderAsset: yes |
|||
DefaultImporter: |
|||
externalObjects: {} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|||
@ -0,0 +1,192 @@ |
|||
// 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. |
|||
|
|||
#ifndef FFX_FRAMEINTERPOLATION_H |
|||
#define FFX_FRAMEINTERPOLATION_H |
|||
|
|||
struct InterpolationSourceColor |
|||
{ |
|||
FfxFloat32x3 fRaw; |
|||
FfxFloat32x3 fLinear; |
|||
FfxFloat32 fBilinearWeightSum; |
|||
}; |
|||
|
|||
InterpolationSourceColor NewInterpolationSourceColor() |
|||
{ |
|||
InterpolationSourceColor c; |
|||
c.fRaw = FfxFloat32x3(0.0, 0.0, 0.0); |
|||
c.fLinear = FfxFloat32x3(0.0, 0.0, 0.0); |
|||
c.fBilinearWeightSum = 0.0; |
|||
return c; |
|||
} |
|||
|
|||
InterpolationSourceColor SampleTextureBilinear(FfxBoolean isCurrent, FfxFloat32x2 fUv, FfxFloat32x2 fMotionVector, FfxInt32x2 texSize) |
|||
{ |
|||
InterpolationSourceColor result = NewInterpolationSourceColor(); |
|||
|
|||
FfxFloat32x2 fReprojectedUv = fUv + fMotionVector; |
|||
BilinearSamplingData bilinearInfo = GetBilinearSamplingData(fReprojectedUv, texSize); |
|||
|
|||
FfxFloat32x3 fColor = FfxFloat32x3(0.0, 0.0, 0.0); |
|||
FfxFloat32 fWeightSum = 0.0f; |
|||
for (FfxInt32 iSampleIndex = 0; iSampleIndex < 4; iSampleIndex++) { |
|||
|
|||
const FfxInt32x2 iOffset = bilinearInfo.iOffsets[iSampleIndex]; |
|||
const FfxInt32x2 iSamplePos = bilinearInfo.iBasePos + iOffset; |
|||
|
|||
if (IsInRect(iSamplePos, InterpolationRectBase(), InterpolationRectSize())) |
|||
{ |
|||
FfxFloat32 fWeight = bilinearInfo.fWeights[iSampleIndex]; |
|||
|
|||
if (isCurrent) |
|||
fColor += LoadCurrentBackbuffer(iSamplePos).rgb * fWeight; |
|||
else |
|||
fColor += LoadPreviousBackbuffer(iSamplePos).rgb * fWeight; |
|||
fWeightSum += fWeight; |
|||
} |
|||
} |
|||
|
|||
//normalize colors |
|||
fColor = (fWeightSum != 0.0f) ? fColor / fWeightSum : FfxFloat32x3(0.0f, 0.0f, 0.0f); |
|||
|
|||
result.fRaw = fColor; |
|||
result.fLinear = RawRGBToLinear(fColor); |
|||
result.fBilinearWeightSum = fWeightSum; |
|||
|
|||
return result; |
|||
} |
|||
|
|||
void updateInPaintingWeight(inout FfxFloat32 fInPaintingWeight, FfxFloat32 fFactor) |
|||
{ |
|||
fInPaintingWeight = ffxSaturate(ffxMax(fInPaintingWeight, fFactor)); |
|||
} |
|||
|
|||
void computeInterpolatedColor(FfxUInt32x2 iPxPos, out FfxFloat32x3 fInterpolatedColor, inout FfxFloat32 fInPaintingWeight) |
|||
{ |
|||
const FfxFloat32x2 fUvInInterpolationRect = (FfxFloat32x2(iPxPos - InterpolationRectBase()) + 0.5f) / InterpolationRectSize(); |
|||
const FfxFloat32x2 fUvInScreenSpace = (FfxFloat32x2(iPxPos) + 0.5f) / DisplaySize(); |
|||
const FfxFloat32x2 fLrUvInInterpolationRect = fUvInInterpolationRect * (FfxFloat32x2(RenderSize()) / GetMaxRenderSize()); |
|||
|
|||
const FfxFloat32x2 fUvLetterBoxScale = FfxFloat32x2(InterpolationRectSize()) / DisplaySize(); |
|||
|
|||
// game MV are top left aligned, the function scales them to render res UV |
|||
VectorFieldEntry gameMv; |
|||
LoadInpaintedGameFieldMv(fUvInInterpolationRect, gameMv); |
|||
|
|||
// OF is done on the back buffers which already have black bars |
|||
VectorFieldEntry ofMv; |
|||
SampleOpticalFlowMotionVectorField(fUvInScreenSpace, ofMv); |
|||
|
|||
// Binarize disucclusion factor |
|||
FfxFloat32x2 fDisocclusionFactor = FfxFloat32x2(FFX_EQUAL(ffxSaturate(SampleDisocclusionMask(fLrUvInInterpolationRect).xy), FfxFloat32x2(1.0, 1.0))); |
|||
|
|||
InterpolationSourceColor fPrevColorGame = SampleTextureBilinear(false, fUvInScreenSpace, +gameMv.fMotionVector * fUvLetterBoxScale, DisplaySize()); |
|||
InterpolationSourceColor fCurrColorGame = SampleTextureBilinear(true, fUvInScreenSpace, -gameMv.fMotionVector * fUvLetterBoxScale, DisplaySize()); |
|||
|
|||
InterpolationSourceColor fPrevColorOF = SampleTextureBilinear(false, fUvInScreenSpace, +ofMv.fMotionVector * fUvLetterBoxScale, DisplaySize()); |
|||
InterpolationSourceColor fCurrColorOF = SampleTextureBilinear(true, fUvInScreenSpace, -ofMv.fMotionVector * fUvLetterBoxScale, DisplaySize()); |
|||
|
|||
FfxFloat32 fBilinearWeightSum = 0.0f; |
|||
FfxFloat32 fDisoccludedFactor = 0.0f; |
|||
|
|||
// Disocclusion logic |
|||
{ |
|||
fDisocclusionFactor.x *= FfxFloat32(!gameMv.bNegOutside); |
|||
fDisocclusionFactor.y *= FfxFloat32(!gameMv.bPosOutside); |
|||
|
|||
// Inpaint in bi-directional disocclusion areas |
|||
updateInPaintingWeight(fInPaintingWeight, FfxFloat32(length(fDisocclusionFactor) <= FFX_FRAMEINTERPOLATION_EPSILON)); |
|||
|
|||
FfxFloat32 t = 0.5f; |
|||
t += 0.5f * (1 - (fDisocclusionFactor.x)); |
|||
t -= 0.5f * (1 - (fDisocclusionFactor.y)); |
|||
|
|||
fInterpolatedColor = ffxLerp(fPrevColorGame.fRaw, fCurrColorGame.fRaw, ffxSaturate(t)); |
|||
fBilinearWeightSum = ffxLerp(fPrevColorGame.fBilinearWeightSum, fCurrColorGame.fBilinearWeightSum, ffxSaturate(t)); |
|||
|
|||
fDisoccludedFactor = ffxSaturate(1 - ffxMin(fDisocclusionFactor.x, fDisocclusionFactor.y)); |
|||
|
|||
if (fPrevColorGame.fBilinearWeightSum == 0.0f) |
|||
{ |
|||
fInterpolatedColor = fCurrColorGame.fRaw; |
|||
fBilinearWeightSum = fCurrColorGame.fBilinearWeightSum; |
|||
} |
|||
else if (fCurrColorGame.fBilinearWeightSum == 0.0f) |
|||
{ |
|||
fInterpolatedColor = fPrevColorGame.fRaw; |
|||
fBilinearWeightSum = fPrevColorGame.fBilinearWeightSum; |
|||
} |
|||
if (fPrevColorGame.fBilinearWeightSum == 0 && fCurrColorGame.fBilinearWeightSum == 0) |
|||
{ |
|||
fInPaintingWeight = 1.0f; |
|||
} |
|||
} |
|||
|
|||
{ |
|||
|
|||
FfxFloat32 ofT = 0.5f; |
|||
|
|||
if (fPrevColorOF.fBilinearWeightSum > 0 && fCurrColorOF.fBilinearWeightSum > 0) |
|||
{ |
|||
ofT = 0.5f; |
|||
} |
|||
else if (fPrevColorOF.fBilinearWeightSum > 0) |
|||
{ |
|||
ofT = 0; |
|||
} else { |
|||
ofT = 1; |
|||
} |
|||
|
|||
const FfxFloat32x3 ofColor = ffxLerp(fPrevColorOF.fRaw, fCurrColorOF.fRaw, ofT); |
|||
|
|||
FfxFloat32 fOF_Sim = NormalizedDot3(fPrevColorOF.fRaw, fCurrColorOF.fRaw); |
|||
FfxFloat32 fGame_Sim = NormalizedDot3(fPrevColorGame.fRaw, fCurrColorGame.fRaw); |
|||
|
|||
fGame_Sim = ffxLerp(ffxMax(FFX_FRAMEINTERPOLATION_EPSILON, fGame_Sim), 1.0f, ffxSaturate(fDisoccludedFactor)); |
|||
FfxFloat32 fGameMvBias = ffxPow(ffxSaturate(fGame_Sim / ffxMax(FFX_FRAMEINTERPOLATION_EPSILON, fOF_Sim)), 1.0f); |
|||
|
|||
const FfxFloat32 fFrameIndexFactor = FfxFloat32(FrameIndexSinceLastReset() < 10); |
|||
fGameMvBias = ffxLerp(fGameMvBias, 1.0f, fFrameIndexFactor); |
|||
|
|||
fInterpolatedColor = ffxLerp(ofColor, fInterpolatedColor, ffxSaturate(fGameMvBias)); |
|||
} |
|||
} |
|||
|
|||
void computeFrameinterpolation(FfxInt32x2 iPxPos) |
|||
{ |
|||
FfxFloat32x3 fColor = FfxFloat32x3(0, 0, 0); |
|||
FfxFloat32 fInPaintingWeight = 0.0f; |
|||
|
|||
if (IsInRect(iPxPos, InterpolationRectBase(), InterpolationRectSize()) == false || FrameIndexSinceLastReset() == 0) |
|||
{ |
|||
// if we just reset or we are out of the interpolation rect, copy the current back buffer and don't interpolate |
|||
fColor = LoadCurrentBackbuffer(iPxPos); |
|||
} |
|||
else |
|||
{ |
|||
computeInterpolatedColor(iPxPos, fColor, fInPaintingWeight); |
|||
} |
|||
|
|||
StoreFrameinterpolationOutput(FfxInt32x2(iPxPos), FfxFloat32x4(fColor, fInPaintingWeight)); |
|||
} |
|||
|
|||
#endif // FFX_FRAMEINTERPOLATION_H |
|||
@ -0,0 +1,60 @@ |
|||
fileFormatVersion: 2 |
|||
guid: df35e42a01c1c3b4dbfd823e9aec076c |
|||
PluginImporter: |
|||
externalObjects: {} |
|||
serializedVersion: 2 |
|||
iconMap: {} |
|||
executionOrder: {} |
|||
defineConstraints: [] |
|||
isPreloaded: 0 |
|||
isOverridable: 1 |
|||
isExplicitlyReferenced: 0 |
|||
validateReferences: 1 |
|||
platformData: |
|||
- first: |
|||
: Any |
|||
second: |
|||
enabled: 0 |
|||
settings: |
|||
Exclude Editor: 1 |
|||
Exclude GameCoreScarlett: 1 |
|||
Exclude GameCoreXboxOne: 1 |
|||
Exclude Linux64: 1 |
|||
Exclude OSXUniversal: 1 |
|||
Exclude PS4: 1 |
|||
Exclude PS5: 1 |
|||
Exclude WebGL: 1 |
|||
Exclude Win: 1 |
|||
Exclude Win64: 1 |
|||
- first: |
|||
Any: |
|||
second: |
|||
enabled: 0 |
|||
settings: {} |
|||
- first: |
|||
Editor: Editor |
|||
second: |
|||
enabled: 0 |
|||
settings: |
|||
DefaultValueInitialized: true |
|||
- first: |
|||
Standalone: Linux64 |
|||
second: |
|||
enabled: 0 |
|||
settings: |
|||
CPU: None |
|||
- first: |
|||
Standalone: Win |
|||
second: |
|||
enabled: 0 |
|||
settings: |
|||
CPU: None |
|||
- first: |
|||
Standalone: Win64 |
|||
second: |
|||
enabled: 0 |
|||
settings: |
|||
CPU: None |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|||
@ -0,0 +1,778 @@ |
|||
// 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_frameinterpolation_resources.h" |
|||
|
|||
#if defined(FFX_GPU) |
|||
#ifdef __hlsl_dx_compiler |
|||
#pragma dxc diagnostic push |
|||
#pragma dxc diagnostic ignored "-Wambig-lit-shift" |
|||
#endif //__hlsl_dx_compiler |
|||
#include "ffx_core.h" |
|||
#ifdef __hlsl_dx_compiler |
|||
#pragma dxc diagnostic pop |
|||
#endif //__hlsl_dx_compiler |
|||
#endif // #if defined(FFX_GPU) |
|||
|
|||
#if defined(FFX_GPU) |
|||
|
|||
#define COUNTER_SPD 0 |
|||
#define COUNTER_FRAME_INDEX_SINCE_LAST_RESET 1 |
|||
|
|||
/////////////////////////////////////////////// |
|||
// declare CBs and CB accessors |
|||
/////////////////////////////////////////////// |
|||
#if defined(FFX_FRAMEINTERPOLATION_BIND_CB_FRAMEINTERPOLATION) |
|||
cbuffer cbFI : FFX_DECLARE_CB(FFX_FRAMEINTERPOLATION_BIND_CB_FRAMEINTERPOLATION) |
|||
{ |
|||
FfxInt32x2 renderSize; |
|||
FfxInt32x2 displaySize; |
|||
|
|||
FfxFloat32x2 displaySizeRcp; |
|||
FfxFloat32 cameraNear; |
|||
FfxFloat32 cameraFar; |
|||
|
|||
FfxInt32x2 upscalerTargetSize; |
|||
FfxInt32 Mode; |
|||
FfxInt32 reset; |
|||
|
|||
FfxFloat32x4 fDeviceToViewDepth; |
|||
|
|||
FfxFloat32 deltaTime; |
|||
FfxInt32 HUDLessAttachedFactor; |
|||
FfxFloat32x2 UNUSED; |
|||
|
|||
FfxFloat32x2 opticalFlowScale; |
|||
FfxInt32 opticalFlowBlockSize; |
|||
FfxUInt32 dispatchFlags; |
|||
|
|||
FfxInt32x2 maxRenderSize; |
|||
FfxInt32 opticalFlowHalfResMode; |
|||
FfxInt32 NumInstances; |
|||
|
|||
FfxInt32x2 interpolationRectBase; |
|||
FfxInt32x2 interpolationRectSize; |
|||
|
|||
FfxFloat32x3 debugBarColor; |
|||
FfxUInt32 backBufferTransferFunction; |
|||
|
|||
FfxFloat32x2 minMaxLuminance; |
|||
FfxFloat32 fTanHalfFOV; |
|||
FfxInt32 _pad1; |
|||
|
|||
FfxFloat32x2 fJitter; |
|||
FfxFloat32x2 fMotionVectorScale; |
|||
} |
|||
|
|||
const FfxFloat32x2 Jitter() |
|||
{ |
|||
return fJitter; |
|||
} |
|||
|
|||
const FfxFloat32x2 MotionVectorScale() |
|||
{ |
|||
return fMotionVectorScale; |
|||
} |
|||
|
|||
const FfxInt32x2 InterpolationRectBase() |
|||
{ |
|||
return interpolationRectBase; |
|||
} |
|||
|
|||
const FfxInt32x2 InterpolationRectSize() |
|||
{ |
|||
return interpolationRectSize; |
|||
} |
|||
|
|||
const FfxInt32x2 RenderSize() |
|||
{ |
|||
return renderSize; |
|||
} |
|||
|
|||
const FfxInt32x2 DisplaySize() |
|||
{ |
|||
return displaySize; |
|||
} |
|||
|
|||
const FfxBoolean Reset() |
|||
{ |
|||
return reset == 1; |
|||
} |
|||
|
|||
FfxFloat32x4 DeviceToViewSpaceTransformFactors() |
|||
{ |
|||
return fDeviceToViewDepth; |
|||
} |
|||
|
|||
FfxInt32x2 GetOpticalFlowSize() |
|||
{ |
|||
FfxInt32x2 iOpticalFlowSize = (1.0f / opticalFlowScale) / FfxFloat32x2(opticalFlowBlockSize.xx); |
|||
|
|||
return iOpticalFlowSize; |
|||
} |
|||
|
|||
FfxInt32x2 GetOpticalFlowSize2() |
|||
{ |
|||
return GetOpticalFlowSize() * 1; |
|||
} |
|||
|
|||
FfxFloat32x2 GetOpticalFlowScale() |
|||
{ |
|||
return opticalFlowScale; |
|||
} |
|||
|
|||
FfxInt32 GetOpticalFlowBlockSize() |
|||
{ |
|||
return opticalFlowBlockSize; |
|||
} |
|||
|
|||
FfxInt32 GetHUDLessAttachedFactor() |
|||
{ |
|||
return HUDLessAttachedFactor; |
|||
} |
|||
|
|||
FfxUInt32 GetDispatchFlags() |
|||
{ |
|||
return dispatchFlags; |
|||
} |
|||
|
|||
FfxInt32x2 GetMaxRenderSize() |
|||
{ |
|||
return maxRenderSize; |
|||
} |
|||
|
|||
FfxInt32 GetOpticalFlowHalfResMode() |
|||
{ |
|||
return opticalFlowHalfResMode; |
|||
} |
|||
|
|||
FfxFloat32x3 GetDebugBarColor() |
|||
{ |
|||
return debugBarColor; |
|||
} |
|||
|
|||
FfxFloat32 TanHalfFoV() |
|||
{ |
|||
return fTanHalfFOV; |
|||
} |
|||
|
|||
FfxUInt32 BackBufferTransferFunction() |
|||
{ |
|||
return backBufferTransferFunction; |
|||
} |
|||
|
|||
FfxFloat32 MinLuminance() |
|||
{ |
|||
return minMaxLuminance[0]; |
|||
} |
|||
|
|||
FfxFloat32 MaxLuminance() |
|||
{ |
|||
return minMaxLuminance[1]; |
|||
} |
|||
|
|||
#endif // #if defined(FFX_FRAMEINTERPOLATION_BIND_CB_FRAMEINTERPOLATION) |
|||
|
|||
#if defined(FFX_FRAMEINTERPOLATION_BIND_CB_INPAINTING_PYRAMID) |
|||
cbuffer cbInpaintingPyramid : FFX_DECLARE_CB(FFX_FRAMEINTERPOLATION_BIND_CB_INPAINTING_PYRAMID) |
|||
{ |
|||
FfxUInt32 mips; |
|||
FfxUInt32 numWorkGroups; |
|||
FfxUInt32x2 workGroupOffset; |
|||
} |
|||
|
|||
FfxUInt32 NumMips() |
|||
{ |
|||
return mips; |
|||
} |
|||
FfxUInt32 NumWorkGroups() |
|||
{ |
|||
return numWorkGroups; |
|||
} |
|||
FfxUInt32x2 WorkGroupOffset() |
|||
{ |
|||
return workGroupOffset; |
|||
} |
|||
#endif // #if defined(FFX_FRAMEINTERPOLATION_BIND_CB_INPAINTING_PYRAMID) |
|||
|
|||
#define FFX_FRAMEINTERPOLATION_ROOTSIG_STRINGIFY(p) FFX_FRAMEINTERPOLATION_ROOTSIG_STR(p) |
|||
#define FFX_FRAMEINTERPOLATION_ROOTSIG_STR(p) #p |
|||
#define FFX_FRAMEINTERPOLATION_ROOTSIG [RootSignature( "DescriptorTable(UAV(u0, numDescriptors = " FFX_FRAMEINTERPOLATION_ROOTSIG_STRINGIFY(FFX_FRAMEINTERPOLATION_RESOURCE_IDENTIFIER_COUNT) ")), " \ |
|||
"DescriptorTable(SRV(t0, numDescriptors = " FFX_FRAMEINTERPOLATION_ROOTSIG_STRINGIFY(FFX_FRAMEINTERPOLATION_RESOURCE_IDENTIFIER_COUNT) ")), " \ |
|||
"CBV(b0), " \ |
|||
"StaticSampler(s0, filter = FILTER_MIN_MAG_MIP_LINEAR, " \ |
|||
"addressU = TEXTURE_ADDRESS_CLAMP, " \ |
|||
"addressV = TEXTURE_ADDRESS_CLAMP, " \ |
|||
"addressW = TEXTURE_ADDRESS_CLAMP, " \ |
|||
"comparisonFunc = COMPARISON_NEVER, " \ |
|||
"borderColor = STATIC_BORDER_COLOR_TRANSPARENT_BLACK)" )] |
|||
|
|||
#define FFX_FRAMEINTERPOLATION_INPAINTING_ROOTSIG [RootSignature( "DescriptorTable(UAV(u0, numDescriptors = " FFX_FRAMEINTERPOLATION_ROOTSIG_STRINGIFY(FFX_FRAMEINTERPOLATION_RESOURCE_IDENTIFIER_COUNT) ")), " \ |
|||
"DescriptorTable(SRV(t0, numDescriptors = " FFX_FRAMEINTERPOLATION_ROOTSIG_STRINGIFY(FFX_FRAMEINTERPOLATION_RESOURCE_IDENTIFIER_COUNT) ")), " \ |
|||
"CBV(b0), " \ |
|||
"CBV(b1), " \ |
|||
"StaticSampler(s0, filter = FILTER_MIN_MAG_MIP_LINEAR, " \ |
|||
"addressU = TEXTURE_ADDRESS_CLAMP, " \ |
|||
"addressV = TEXTURE_ADDRESS_CLAMP, " \ |
|||
"addressW = TEXTURE_ADDRESS_CLAMP, " \ |
|||
"comparisonFunc = COMPARISON_NEVER, " \ |
|||
"borderColor = STATIC_BORDER_COLOR_TRANSPARENT_BLACK)" )] |
|||
|
|||
#if defined(FFX_FRAMEINTERPOLATION_EMBED_ROOTSIG) |
|||
#define FFX_FRAMEINTERPOLATION_EMBED_ROOTSIG_CONTENT FFX_FRAMEINTERPOLATION_ROOTSIG |
|||
#define FFX_FRAMEINTERPOLATION_EMBED_INPAINTING_ROOTSIG_CONTENT FFX_FRAMEINTERPOLATION_INPAINTING_ROOTSIG |
|||
#else |
|||
#define FFX_FRAMEINTERPOLATION_EMBED_ROOTSIG_CONTENT |
|||
#define FFX_FRAMEINTERPOLATION_EMBED_INPAINTING_ROOTSIG_CONTENT |
|||
#endif // #if FFX_FRAMEINTERPOLATION_EMBED_ROOTSIG |
|||
|
|||
/////////////////////////////////////////////// |
|||
// declare samplers |
|||
/////////////////////////////////////////////// |
|||
|
|||
SamplerState s_LinearClamp : register(s0); |
|||
|
|||
/////////////////////////////////////////////// |
|||
// declare SRVs and SRV accessors |
|||
/////////////////////////////////////////////// |
|||
|
|||
#ifdef FFX_FRAMEINTERPOLATION_BIND_SRV_PREVIOUS_INTERPOLATION_SOURCE |
|||
Texture2D<FfxFloat32x4> r_previous_interpolation_source : FFX_DECLARE_SRV(FFX_FRAMEINTERPOLATION_BIND_SRV_PREVIOUS_INTERPOLATION_SOURCE); |
|||
|
|||
FfxFloat32x3 LoadPreviousBackbuffer(FFX_PARAMETER_IN FfxInt32x2 iPxPos) |
|||
{ |
|||
return r_previous_interpolation_source[iPxPos].rgb; |
|||
} |
|||
FfxFloat32x3 SamplePreviousBackbuffer(FFX_PARAMETER_IN FfxFloat32x2 fUv) |
|||
{ |
|||
return r_previous_interpolation_source.SampleLevel(s_LinearClamp, fUv, 0).xyz; |
|||
} |
|||
#endif |
|||
|
|||
#ifdef FFX_FRAMEINTERPOLATION_BIND_SRV_CURRENT_INTERPOLATION_SOURCE |
|||
Texture2D<FfxFloat32x4> r_current_interpolation_source : FFX_DECLARE_SRV(FFX_FRAMEINTERPOLATION_BIND_SRV_CURRENT_INTERPOLATION_SOURCE); |
|||
|
|||
FfxFloat32x3 LoadCurrentBackbuffer(FFX_PARAMETER_IN FfxInt32x2 iPxPos) |
|||
{ |
|||
return r_current_interpolation_source[iPxPos].rgb; |
|||
} |
|||
FfxFloat32x3 SampleCurrentBackbuffer(FFX_PARAMETER_IN FfxFloat32x2 fUv) |
|||
{ |
|||
return r_current_interpolation_source.SampleLevel(s_LinearClamp, fUv, 0).xyz; |
|||
} |
|||
#endif |
|||
|
|||
#ifdef FFX_FRAMEINTERPOLATION_BIND_SRV_DILATED_MOTION_VECTORS |
|||
Texture2D<FfxFloat32x2> r_dilated_motion_vectors : FFX_DECLARE_SRV(FFX_FRAMEINTERPOLATION_BIND_SRV_DILATED_MOTION_VECTORS); |
|||
|
|||
FfxFloat32x2 LoadDilatedMotionVector(FFX_PARAMETER_IN FfxInt32x2 iPxPos) |
|||
{ |
|||
return r_dilated_motion_vectors[iPxPos].xy; |
|||
} |
|||
#endif |
|||
|
|||
#ifdef FFX_FRAMEINTERPOLATION_BIND_SRV_DILATED_DEPTH |
|||
Texture2D<FfxFloat32> r_dilated_depth : FFX_DECLARE_SRV(FFX_FRAMEINTERPOLATION_BIND_SRV_DILATED_DEPTH); |
|||
|
|||
FfxFloat32 LoadDilatedDepth(FFX_PARAMETER_IN FfxInt32x2 iPxPos) |
|||
{ |
|||
return r_dilated_depth[iPxPos].x; |
|||
} |
|||
#endif |
|||
|
|||
#ifdef FFX_FRAMEINTERPOLATION_BIND_SRV_RECONSTRUCTED_DEPTH_PREVIOUS_FRAME |
|||
Texture2D<FfxUInt32> r_reconstructed_depth_previous_frame : FFX_DECLARE_SRV(FFX_FRAMEINTERPOLATION_BIND_SRV_RECONSTRUCTED_DEPTH_PREVIOUS_FRAME); |
|||
|
|||
FfxFloat32 LoadReconstructedDepthPreviousFrame(FFX_PARAMETER_IN FfxInt32x2 iPxInput) |
|||
{ |
|||
return asfloat(r_reconstructed_depth_previous_frame[iPxInput]); |
|||
} |
|||
#endif |
|||
|
|||
#ifdef FFX_FRAMEINTERPOLATION_BIND_SRV_RECONSTRUCTED_DEPTH_INTERPOLATED_FRAME |
|||
Texture2D<FfxUInt32> r_reconstructed_depth_interpolated_frame : FFX_DECLARE_SRV(FFX_FRAMEINTERPOLATION_BIND_SRV_RECONSTRUCTED_DEPTH_INTERPOLATED_FRAME); |
|||
|
|||
FfxFloat32 LoadEstimatedInterpolationFrameDepth(FFX_PARAMETER_IN FfxInt32x2 iPxInput) |
|||
{ |
|||
return asfloat(r_reconstructed_depth_interpolated_frame[iPxInput]); |
|||
} |
|||
#endif |
|||
|
|||
#ifdef FFX_FRAMEINTERPOLATION_BIND_SRV_DISOCCLUSION_MASK |
|||
Texture2D<FfxFloat32x4> r_disocclusion_mask : FFX_DECLARE_SRV(FFX_FRAMEINTERPOLATION_BIND_SRV_DISOCCLUSION_MASK); |
|||
|
|||
FfxFloat32x4 LoadDisocclusionMask(FFX_PARAMETER_IN FfxInt32x2 iPxPos) |
|||
{ |
|||
return r_disocclusion_mask[iPxPos]; |
|||
} |
|||
FfxFloat32x4 SampleDisocclusionMask(FFX_PARAMETER_IN FfxFloat32x2 fUv) |
|||
{ |
|||
return r_disocclusion_mask.SampleLevel(s_LinearClamp, fUv, 0); |
|||
} |
|||
#endif |
|||
|
|||
#if defined(FFX_FRAMEINTERPOLATION_BIND_SRV_GAME_MOTION_VECTOR_FIELD_X) && \ |
|||
defined(FFX_FRAMEINTERPOLATION_BIND_SRV_GAME_MOTION_VECTOR_FIELD_Y) |
|||
Texture2D<FfxUInt32> r_game_motion_vector_field_x : FFX_DECLARE_SRV(FFX_FRAMEINTERPOLATION_BIND_SRV_GAME_MOTION_VECTOR_FIELD_X); |
|||
Texture2D<FfxUInt32> r_game_motion_vector_field_y : FFX_DECLARE_SRV(FFX_FRAMEINTERPOLATION_BIND_SRV_GAME_MOTION_VECTOR_FIELD_Y); |
|||
|
|||
FfxUInt32x2 LoadGameFieldMv(FFX_PARAMETER_IN FfxInt32x2 iPxSample) |
|||
{ |
|||
FfxUInt32 packedX = r_game_motion_vector_field_x[iPxSample]; |
|||
FfxUInt32 packedY = r_game_motion_vector_field_y[iPxSample]; |
|||
|
|||
return FfxUInt32x2(packedX, packedY); |
|||
} |
|||
#endif |
|||
|
|||
#if defined(FFX_FRAMEINTERPOLATION_BIND_SRV_OPTICAL_FLOW_MOTION_VECTOR_FIELD_X) && \ |
|||
defined(FFX_FRAMEINTERPOLATION_BIND_SRV_OPTICAL_FLOW_MOTION_VECTOR_FIELD_Y) |
|||
Texture2D<FfxUInt32> r_optical_flow_motion_vector_field_x : FFX_DECLARE_SRV(FFX_FRAMEINTERPOLATION_BIND_SRV_OPTICAL_FLOW_MOTION_VECTOR_FIELD_X); |
|||
Texture2D<FfxUInt32> r_optical_flow_motion_vector_field_y : FFX_DECLARE_SRV(FFX_FRAMEINTERPOLATION_BIND_SRV_OPTICAL_FLOW_MOTION_VECTOR_FIELD_Y); |
|||
|
|||
FfxUInt32x2 LoadOpticalFlowFieldMv(FFX_PARAMETER_IN FfxInt32x2 iPxSample) |
|||
{ |
|||
FfxUInt32 packedX = r_optical_flow_motion_vector_field_x[iPxSample]; |
|||
FfxUInt32 packedY = r_optical_flow_motion_vector_field_y[iPxSample]; |
|||
|
|||
return FfxUInt32x2(packedX, packedY); |
|||
} |
|||
#endif |
|||
|
|||
#ifdef FFX_FRAMEINTERPOLATION_BIND_SRV_OPTICAL_FLOW |
|||
Texture2D<FfxInt32x2> r_optical_flow : FFX_DECLARE_SRV(FFX_FRAMEINTERPOLATION_BIND_SRV_OPTICAL_FLOW); |
|||
|
|||
#if defined(FFX_FRAMEINTERPOLATION_BIND_CB_FRAMEINTERPOLATION) |
|||
FfxFloat32x2 LoadOpticalFlow(FFX_PARAMETER_IN FfxInt32x2 iPxPos) |
|||
{ |
|||
return r_optical_flow[iPxPos] * GetOpticalFlowScale(); |
|||
} |
|||
#endif |
|||
#endif |
|||
|
|||
#ifdef FFX_FRAMEINTERPOLATION_BIND_SRV_OPTICAL_FLOW_UPSAMPLED |
|||
Texture2D<FfxFloat32x2> r_optical_flow_upsampled : FFX_DECLARE_SRV(FFX_FRAMEINTERPOLATION_BIND_SRV_OPTICAL_FLOW_UPSAMPLED); |
|||
|
|||
FfxFloat32x2 LoadOpticalFlowUpsampled(FFX_PARAMETER_IN FfxInt32x2 iPxPos) |
|||
{ |
|||
return r_optical_flow_upsampled[iPxPos]; |
|||
} |
|||
#endif |
|||
|
|||
#ifdef FFX_FRAMEINTERPOLATION_BIND_SRV_OPTICAL_FLOW_CONFIDENCE |
|||
Texture2D<FfxUInt32x2> r_optical_flow_confidence : FFX_DECLARE_SRV(FFX_FRAMEINTERPOLATION_BIND_SRV_OPTICAL_FLOW_CONFIDENCE); |
|||
|
|||
FfxFloat32 LoadOpticalFlowConfidence(FFX_PARAMETER_IN FfxInt32x2 iPxPos) |
|||
{ |
|||
return r_optical_flow_confidence[iPxPos].y; |
|||
} |
|||
#endif |
|||
|
|||
#ifdef FFX_FRAMEINTERPOLATION_BIND_SRV_OPTICAL_FLOW_GLOBAL_MOTION |
|||
Texture2D<FfxUInt32> r_optical_flow_global_motion : FFX_DECLARE_SRV(FFX_FRAMEINTERPOLATION_BIND_SRV_OPTICAL_FLOW_GLOBAL_MOTION); |
|||
|
|||
FfxUInt32 LoadOpticalFlowGlobalMotion(FFX_PARAMETER_IN FfxInt32x2 iPxPos) |
|||
{ |
|||
return r_optical_flow_global_motion[iPxPos]; |
|||
} |
|||
#endif |
|||
|
|||
#ifdef FFX_FRAMEINTERPOLATION_BIND_SRV_OPTICAL_FLOW_SCENE_CHANGE_DETECTION |
|||
Texture2D<FfxUInt32> r_optical_flow_scd : FFX_DECLARE_SRV(FFX_FRAMEINTERPOLATION_BIND_SRV_OPTICAL_FLOW_SCENE_CHANGE_DETECTION); |
|||
|
|||
FfxUInt32 LoadOpticalFlowSceneChangeDetection(FFX_PARAMETER_IN FfxInt32x2 iPxPos) |
|||
{ |
|||
return r_optical_flow_scd[iPxPos]; |
|||
} |
|||
|
|||
FfxBoolean HasSceneChanged() |
|||
{ |
|||
#define SCD_OUTPUT_HISTORY_BITS_SLOT 1 |
|||
//if (FrameIndex() <= 5) // threshold according to original OpenCL code |
|||
//{ |
|||
// return 1.0; |
|||
//} |
|||
//else |
|||
{ |
|||
// Report that the scene is changed if the change was detected in any of the |
|||
// 4 previous frames (0xfu - covers 4 history bits). |
|||
return (r_optical_flow_scd[FfxInt32x2(SCD_OUTPUT_HISTORY_BITS_SLOT, 0)] & 0xfu) != 0; |
|||
} |
|||
} |
|||
#endif |
|||
|
|||
#ifdef FFX_FRAMEINTERPOLATION_BIND_SRV_OPTICAL_FLOW_DEBUG |
|||
Texture2D<FfxFloat32x4> r_optical_flow_debug : FFX_DECLARE_SRV(FFX_FRAMEINTERPOLATION_BIND_SRV_OPTICAL_FLOW_DEBUG); |
|||
|
|||
FfxFloat32x4 LoadOpticalFlowDebug(FFX_PARAMETER_IN FfxInt32x2 iPxPos) |
|||
{ |
|||
return r_optical_flow_debug[iPxPos]; |
|||
} |
|||
#endif |
|||
|
|||
#ifdef FFX_FRAMEINTERPOLATION_BIND_SRV_OUTPUT |
|||
Texture2D<FfxFloat32x4> r_output : FFX_DECLARE_SRV(FFX_FRAMEINTERPOLATION_BIND_SRV_OUTPUT); |
|||
|
|||
FfxFloat32x4 LoadFrameInterpolationOutput(FFX_PARAMETER_IN FfxInt32x2 iPxInput) |
|||
{ |
|||
return r_output[iPxInput]; |
|||
} |
|||
#endif |
|||
|
|||
#ifdef FFX_FRAMEINTERPOLATION_BIND_SRV_INPAINTING_PYRAMID |
|||
Texture2D<FfxFloat32x4> r_inpainting_pyramid : FFX_DECLARE_SRV(FFX_FRAMEINTERPOLATION_BIND_SRV_INPAINTING_PYRAMID); |
|||
|
|||
FfxFloat32x4 LoadInpaintingPyramid(FFX_PARAMETER_IN FfxInt32 mipLevel, FFX_PARAMETER_IN FfxUInt32x2 iPxInput) |
|||
{ |
|||
return r_inpainting_pyramid.mips[mipLevel][iPxInput]; |
|||
} |
|||
#endif |
|||
|
|||
#ifdef FFX_FRAMEINTERPOLATION_BIND_SRV_PRESENT_BACKBUFFER |
|||
Texture2D<FfxFloat32x4> r_present_backbuffer : FFX_DECLARE_SRV(FFX_FRAMEINTERPOLATION_BIND_SRV_PRESENT_BACKBUFFER); |
|||
|
|||
FfxFloat32x4 LoadPresentBackbuffer(FFX_PARAMETER_IN FfxInt32x2 iPxInput) |
|||
{ |
|||
return r_present_backbuffer[iPxInput]; |
|||
} |
|||
FfxFloat32x4 SamplePresentBackbuffer(FFX_PARAMETER_IN FfxFloat32x2 fUv) |
|||
{ |
|||
return r_present_backbuffer.SampleLevel(s_LinearClamp, fUv, 0); |
|||
} |
|||
#endif |
|||
|
|||
#ifdef FFX_FRAMEINTERPOLATION_BIND_SRV_COUNTERS |
|||
StructuredBuffer<FfxUInt32> r_counters : FFX_DECLARE_SRV(FFX_FRAMEINTERPOLATION_BIND_SRV_COUNTERS); |
|||
|
|||
FfxUInt32 LoadCounter(FFX_PARAMETER_IN FfxInt32 iPxPos) |
|||
{ |
|||
return r_counters[iPxPos]; |
|||
} |
|||
|
|||
const FfxUInt32 FrameIndexSinceLastReset() |
|||
{ |
|||
return LoadCounter(COUNTER_FRAME_INDEX_SINCE_LAST_RESET); |
|||
} |
|||
#endif |
|||
|
|||
#if defined(FFX_FRAMEINTERPOLATION_BIND_SRV_INPUT_DEPTH) |
|||
Texture2D<FfxFloat32> r_input_depth : FFX_DECLARE_SRV(FFX_FRAMEINTERPOLATION_BIND_SRV_INPUT_DEPTH); |
|||
FfxFloat32 LoadInputDepth(FfxInt32x2 iPxPos) |
|||
{ |
|||
return r_input_depth[iPxPos]; |
|||
} |
|||
#endif |
|||
|
|||
#if defined(FFX_FRAMEINTERPOLATION_BIND_SRV_INPUT_MOTION_VECTORS) |
|||
Texture2D<FfxFloat32x4> r_input_motion_vectors : FFX_DECLARE_SRV(FFX_FRAMEINTERPOLATION_BIND_SRV_INPUT_MOTION_VECTORS); |
|||
FfxFloat32x2 LoadInputMotionVector(FfxInt32x2 iPxDilatedMotionVectorPos) |
|||
{ |
|||
FfxFloat32x2 fSrcMotionVector = r_input_motion_vectors[iPxDilatedMotionVectorPos].xy; |
|||
|
|||
FfxFloat32x2 fUvMotionVector = fSrcMotionVector * MotionVectorScale(); |
|||
|
|||
#if FFX_FRAMEINTERPOLATION_OPTION_JITTERED_MOTION_VECTORS |
|||
fUvMotionVector -= MotionVectorJitterCancellation(); |
|||
#endif |
|||
|
|||
return fUvMotionVector; |
|||
} |
|||
#endif |
|||
/////////////////////////////////////////////// |
|||
// declare UAVs and UAV accessors |
|||
/////////////////////////////////////////////// |
|||
#ifdef FFX_FRAMEINTERPOLATION_BIND_UAV_OUTPUT |
|||
RWTexture2D<FfxFloat32x4> rw_output : FFX_DECLARE_UAV(FFX_FRAMEINTERPOLATION_BIND_UAV_OUTPUT); |
|||
|
|||
FfxFloat32x4 RWLoadFrameinterpolationOutput(FFX_PARAMETER_IN FfxInt32x2 iPxPos) |
|||
{ |
|||
return rw_output[iPxPos]; |
|||
} |
|||
|
|||
void StoreFrameinterpolationOutput(FFX_PARAMETER_IN FfxInt32x2 iPxPos, FFX_PARAMETER_IN FfxFloat32x4 val) |
|||
{ |
|||
rw_output[iPxPos] = val; |
|||
} |
|||
#endif |
|||
|
|||
#ifdef FFX_FRAMEINTERPOLATION_BIND_UAV_DILATED_MOTION_VECTORS |
|||
RWTexture2D<FfxFloat32x2> rw_dilated_motion_vectors : FFX_DECLARE_UAV(FFX_FRAMEINTERPOLATION_BIND_UAV_DILATED_MOTION_VECTORS); |
|||
|
|||
FfxFloat32x2 RWLoadDilatedMotionVectors(FFX_PARAMETER_IN FfxInt32x2 iPxPos) |
|||
{ |
|||
return rw_dilated_motion_vectors[iPxPos]; |
|||
} |
|||
|
|||
void StoreDilatedMotionVectors(FFX_PARAMETER_IN FfxInt32x2 iPxPos, FFX_PARAMETER_IN FfxFloat32x2 val) |
|||
{ |
|||
rw_dilated_motion_vectors[iPxPos] = val; |
|||
} |
|||
#endif |
|||
|
|||
#ifdef FFX_FRAMEINTERPOLATION_BIND_UAV_DILATED_DEPTH |
|||
RWTexture2D<FfxFloat32> rw_dilated_depth : FFX_DECLARE_UAV(FFX_FRAMEINTERPOLATION_BIND_UAV_DILATED_DEPTH); |
|||
|
|||
FfxFloat32 RWLoadDilatedDepth(FFX_PARAMETER_IN FfxInt32x2 iPxPos) |
|||
{ |
|||
return rw_dilated_depth[iPxPos]; |
|||
} |
|||
|
|||
void StoreDilatedDepth(FFX_PARAMETER_IN FfxInt32x2 iPxPos, FFX_PARAMETER_IN FfxFloat32 val) |
|||
{ |
|||
rw_dilated_depth[iPxPos] = val; |
|||
} |
|||
#endif |
|||
|
|||
#ifdef FFX_FRAMEINTERPOLATION_BIND_UAV_RECONSTRUCTED_DEPTH_PREVIOUS_FRAME |
|||
RWTexture2D<FfxUInt32> rw_reconstructed_depth_previous_frame : FFX_DECLARE_UAV(FFX_FRAMEINTERPOLATION_BIND_UAV_RECONSTRUCTED_DEPTH_PREVIOUS_FRAME); |
|||
|
|||
FfxFloat32 RWLoadReconstructedDepthPreviousFrame(FFX_PARAMETER_IN FfxInt32x2 iPxPos) |
|||
{ |
|||
return ffxAsFloat(rw_reconstructed_depth_previous_frame[iPxPos]); |
|||
} |
|||
|
|||
void UpdateReconstructedDepthPreviousFrame(FfxInt32x2 iPxSample, FfxFloat32 fDepth) |
|||
{ |
|||
FfxUInt32 uDepth = ffxAsUInt32(fDepth); |
|||
|
|||
#if FFX_FRAMEINTERPOLATION_OPTION_INVERTED_DEPTH |
|||
InterlockedMax(rw_reconstructed_depth_previous_frame[iPxSample], uDepth); |
|||
#else |
|||
InterlockedMin(rw_reconstructed_depth_previous_frame[iPxSample], uDepth); // min for standard, max for inverted depth |
|||
#endif |
|||
} |
|||
#endif |
|||
|
|||
#ifdef FFX_FRAMEINTERPOLATION_BIND_UAV_RECONSTRUCTED_DEPTH_INTERPOLATED_FRAME |
|||
RWTexture2D<FfxUInt32> rw_reconstructed_depth_interpolated_frame : FFX_DECLARE_UAV(FFX_FRAMEINTERPOLATION_BIND_UAV_RECONSTRUCTED_DEPTH_INTERPOLATED_FRAME); |
|||
|
|||
FfxFloat32 RWLoadReconstructedDepthInterpolatedFrame(FFX_PARAMETER_IN FfxInt32x2 iPxPos) |
|||
{ |
|||
return ffxAsFloat(rw_reconstructed_depth_interpolated_frame[iPxPos]); |
|||
} |
|||
|
|||
void StoreReconstructedDepthInterpolatedFrame(FFX_PARAMETER_IN FfxInt32x2 iPxPos, FFX_PARAMETER_IN FfxFloat32 value) |
|||
{ |
|||
FfxUInt32 uDepth = ffxAsUInt32(value); |
|||
rw_reconstructed_depth_interpolated_frame[iPxPos] = uDepth; |
|||
} |
|||
|
|||
void UpdateReconstructedDepthInterpolatedFrame(FfxInt32x2 iPxSample, FfxFloat32 fDepth) |
|||
{ |
|||
FfxUInt32 uDepth = ffxAsUInt32(fDepth); |
|||
|
|||
#if FFX_FRAMEINTERPOLATION_OPTION_INVERTED_DEPTH |
|||
InterlockedMax(rw_reconstructed_depth_interpolated_frame[iPxSample], uDepth); |
|||
#else |
|||
InterlockedMin(rw_reconstructed_depth_interpolated_frame[iPxSample], uDepth); // min for standard, max for inverted depth |
|||
#endif |
|||
} |
|||
#endif |
|||
|
|||
#ifdef FFX_FRAMEINTERPOLATION_BIND_UAV_DISOCCLUSION_MASK |
|||
RWTexture2D<FfxFloat32x2> rw_disocclusion_mask : FFX_DECLARE_UAV(FFX_FRAMEINTERPOLATION_BIND_UAV_DISOCCLUSION_MASK); |
|||
|
|||
FfxFloat32x2 RWLoadDisocclusionMask(FFX_PARAMETER_IN FfxInt32x2 iPxPos) |
|||
{ |
|||
return rw_disocclusion_mask[iPxPos]; |
|||
} |
|||
|
|||
void StoreDisocclusionMask(FFX_PARAMETER_IN FfxInt32x2 iPxPos, FFX_PARAMETER_IN FfxFloat32x2 val) |
|||
{ |
|||
rw_disocclusion_mask[iPxPos] = val; |
|||
} |
|||
#endif |
|||
|
|||
#if defined(FFX_FRAMEINTERPOLATION_BIND_UAV_GAME_MOTION_VECTOR_FIELD_X) && \ |
|||
defined(FFX_FRAMEINTERPOLATION_BIND_UAV_GAME_MOTION_VECTOR_FIELD_Y) |
|||
|
|||
RWTexture2D<FfxUInt32> rw_game_motion_vector_field_x : FFX_DECLARE_UAV(FFX_FRAMEINTERPOLATION_BIND_UAV_GAME_MOTION_VECTOR_FIELD_X); |
|||
RWTexture2D<FfxUInt32> rw_game_motion_vector_field_y : FFX_DECLARE_UAV(FFX_FRAMEINTERPOLATION_BIND_UAV_GAME_MOTION_VECTOR_FIELD_Y); |
|||
|
|||
FfxUInt32 RWLoadGameMotionVectorFieldX(FFX_PARAMETER_IN FfxInt32x2 iPxPos) |
|||
{ |
|||
return rw_game_motion_vector_field_x[iPxPos]; |
|||
} |
|||
|
|||
void StoreGameMotionVectorFieldX(FFX_PARAMETER_IN FfxInt32x2 iPxPos, FFX_PARAMETER_IN FfxUInt32 val) |
|||
{ |
|||
rw_game_motion_vector_field_x[iPxPos] = val; |
|||
} |
|||
|
|||
FfxUInt32 RWLoadGameMotionVectorFieldY(FFX_PARAMETER_IN FfxInt32x2 iPxPos) |
|||
{ |
|||
return rw_game_motion_vector_field_y[iPxPos]; |
|||
} |
|||
|
|||
void StoreGameMotionVectorFieldY(FFX_PARAMETER_IN FfxInt32x2 iPxPos, FFX_PARAMETER_IN FfxUInt32 val) |
|||
{ |
|||
rw_game_motion_vector_field_y[iPxPos] = val; |
|||
} |
|||
|
|||
void UpdateGameMotionVectorField(FFX_PARAMETER_IN FfxInt32x2 iPxPos, FFX_PARAMETER_IN FfxUInt32x2 packedVector) |
|||
{ |
|||
InterlockedMax(rw_game_motion_vector_field_x[iPxPos], packedVector.x); |
|||
InterlockedMax(rw_game_motion_vector_field_y[iPxPos], packedVector.y); |
|||
} |
|||
|
|||
FfxUInt32 UpdateGameMotionVectorFieldEx(FFX_PARAMETER_IN FfxInt32x2 iPxPos, FFX_PARAMETER_IN FfxUInt32x2 packedVector) |
|||
{ |
|||
FfxUInt32 uPreviousValueX = 0; |
|||
FfxUInt32 uPreviousValueY = 0; |
|||
InterlockedMax(rw_game_motion_vector_field_x[iPxPos], packedVector.x, uPreviousValueX); |
|||
InterlockedMax(rw_game_motion_vector_field_y[iPxPos], packedVector.y, uPreviousValueY); |
|||
|
|||
const FfxUInt32 uExistingVectorFieldEntry = ffxMax(uPreviousValueX, uPreviousValueY); |
|||
|
|||
return uExistingVectorFieldEntry; |
|||
} |
|||
#endif |
|||
|
|||
#if defined(FFX_FRAMEINTERPOLATION_BIND_UAV_OPTICAL_FLOW_MOTION_VECTOR_FIELD_X) && \ |
|||
defined(FFX_FRAMEINTERPOLATION_BIND_UAV_OPTICAL_FLOW_MOTION_VECTOR_FIELD_Y) |
|||
|
|||
RWTexture2D<FfxUInt32> rw_optical_flow_motion_vector_field_x : FFX_DECLARE_UAV(FFX_FRAMEINTERPOLATION_BIND_UAV_OPTICAL_FLOW_MOTION_VECTOR_FIELD_X); |
|||
RWTexture2D<FfxUInt32> rw_optical_flow_motion_vector_field_y : FFX_DECLARE_UAV(FFX_FRAMEINTERPOLATION_BIND_UAV_OPTICAL_FLOW_MOTION_VECTOR_FIELD_Y); |
|||
|
|||
FfxUInt32 RWLoadOpticalflowMotionVectorFieldX(FFX_PARAMETER_IN FfxInt32x2 iPxPos) |
|||
{ |
|||
return rw_optical_flow_motion_vector_field_x[iPxPos]; |
|||
} |
|||
void StoreOpticalflowMotionVectorFieldX(FFX_PARAMETER_IN FfxInt32x2 iPxPos, FFX_PARAMETER_IN FfxUInt32 val) |
|||
{ |
|||
rw_optical_flow_motion_vector_field_x[iPxPos] = val; |
|||
} |
|||
FfxUInt32 RWLoadOpticalflowMotionVectorFieldY(FFX_PARAMETER_IN FfxInt32x2 iPxPos) |
|||
{ |
|||
return rw_optical_flow_motion_vector_field_y[iPxPos]; |
|||
} |
|||
void StoreOpticalflowMotionVectorFieldY(FFX_PARAMETER_IN FfxInt32x2 iPxPos, FFX_PARAMETER_IN FfxUInt32 val) |
|||
{ |
|||
rw_optical_flow_motion_vector_field_y[iPxPos] = val; |
|||
} |
|||
void UpdateOpticalflowMotionVectorField(FFX_PARAMETER_IN FfxInt32x2 iPxPos, FFX_PARAMETER_IN FfxUInt32x2 packedVector) |
|||
{ |
|||
InterlockedMax(rw_optical_flow_motion_vector_field_x[iPxPos], packedVector.x); |
|||
InterlockedMax(rw_optical_flow_motion_vector_field_y[iPxPos], packedVector.y); |
|||
} |
|||
#endif |
|||
|
|||
#ifdef FFX_FRAMEINTERPOLATION_BIND_UAV_COUNTERS |
|||
globallycoherent RWStructuredBuffer<FfxUInt32> rw_counters : FFX_DECLARE_UAV(FFX_FRAMEINTERPOLATION_BIND_UAV_COUNTERS); |
|||
|
|||
FfxUInt32 RWLoadCounter(FFX_PARAMETER_IN FfxInt32 iPxPos) |
|||
{ |
|||
return rw_counters[iPxPos]; |
|||
} |
|||
|
|||
void StoreCounter(FFX_PARAMETER_IN FfxInt32 iPxPos, FFX_PARAMETER_IN FfxUInt32 counter) |
|||
{ |
|||
rw_counters[iPxPos] = counter; |
|||
} |
|||
void AtomicIncreaseCounter(FFX_PARAMETER_IN FfxInt32 iPxPos, FFX_PARAMETER_OUT FfxUInt32 oldVal) |
|||
{ |
|||
InterlockedAdd(rw_counters[iPxPos], 1, oldVal); |
|||
} |
|||
#endif |
|||
|
|||
|
|||
#if defined(FFX_FRAMEINTERPOLATION_BIND_UAV_INPAINTING_PYRAMID_MIPMAP_0) && \ |
|||
defined(FFX_FRAMEINTERPOLATION_BIND_UAV_INPAINTING_PYRAMID_MIPMAP_1) && \ |
|||
defined(FFX_FRAMEINTERPOLATION_BIND_UAV_INPAINTING_PYRAMID_MIPMAP_2) && \ |
|||
defined(FFX_FRAMEINTERPOLATION_BIND_UAV_INPAINTING_PYRAMID_MIPMAP_3) && \ |
|||
defined(FFX_FRAMEINTERPOLATION_BIND_UAV_INPAINTING_PYRAMID_MIPMAP_4) && \ |
|||
defined(FFX_FRAMEINTERPOLATION_BIND_UAV_INPAINTING_PYRAMID_MIPMAP_5) && \ |
|||
defined(FFX_FRAMEINTERPOLATION_BIND_UAV_INPAINTING_PYRAMID_MIPMAP_6) && \ |
|||
defined(FFX_FRAMEINTERPOLATION_BIND_UAV_INPAINTING_PYRAMID_MIPMAP_7) && \ |
|||
defined(FFX_FRAMEINTERPOLATION_BIND_UAV_INPAINTING_PYRAMID_MIPMAP_8) && \ |
|||
defined(FFX_FRAMEINTERPOLATION_BIND_UAV_INPAINTING_PYRAMID_MIPMAP_9) && \ |
|||
defined(FFX_FRAMEINTERPOLATION_BIND_UAV_INPAINTING_PYRAMID_MIPMAP_10) && \ |
|||
defined(FFX_FRAMEINTERPOLATION_BIND_UAV_INPAINTING_PYRAMID_MIPMAP_11) && \ |
|||
defined(FFX_FRAMEINTERPOLATION_BIND_UAV_INPAINTING_PYRAMID_MIPMAP_12) |
|||
|
|||
RWTexture2D<FfxFloat32x4> rw_inpainting_pyramid0 : FFX_DECLARE_UAV(FFX_FRAMEINTERPOLATION_BIND_UAV_INPAINTING_PYRAMID_MIPMAP_0); |
|||
RWTexture2D<FfxFloat32x4> rw_inpainting_pyramid1 : FFX_DECLARE_UAV(FFX_FRAMEINTERPOLATION_BIND_UAV_INPAINTING_PYRAMID_MIPMAP_1); |
|||
RWTexture2D<FfxFloat32x4> rw_inpainting_pyramid2 : FFX_DECLARE_UAV(FFX_FRAMEINTERPOLATION_BIND_UAV_INPAINTING_PYRAMID_MIPMAP_2); |
|||
RWTexture2D<FfxFloat32x4> rw_inpainting_pyramid3 : FFX_DECLARE_UAV(FFX_FRAMEINTERPOLATION_BIND_UAV_INPAINTING_PYRAMID_MIPMAP_3); |
|||
RWTexture2D<FfxFloat32x4> rw_inpainting_pyramid4 : FFX_DECLARE_UAV(FFX_FRAMEINTERPOLATION_BIND_UAV_INPAINTING_PYRAMID_MIPMAP_4); |
|||
globallycoherent RWTexture2D<FfxFloat32x4> rw_inpainting_pyramid5 : FFX_DECLARE_UAV(FFX_FRAMEINTERPOLATION_BIND_UAV_INPAINTING_PYRAMID_MIPMAP_5); |
|||
RWTexture2D<FfxFloat32x4> rw_inpainting_pyramid6 : FFX_DECLARE_UAV(FFX_FRAMEINTERPOLATION_BIND_UAV_INPAINTING_PYRAMID_MIPMAP_6); |
|||
RWTexture2D<FfxFloat32x4> rw_inpainting_pyramid7 : FFX_DECLARE_UAV(FFX_FRAMEINTERPOLATION_BIND_UAV_INPAINTING_PYRAMID_MIPMAP_7); |
|||
RWTexture2D<FfxFloat32x4> rw_inpainting_pyramid8 : FFX_DECLARE_UAV(FFX_FRAMEINTERPOLATION_BIND_UAV_INPAINTING_PYRAMID_MIPMAP_8); |
|||
RWTexture2D<FfxFloat32x4> rw_inpainting_pyramid9 : FFX_DECLARE_UAV(FFX_FRAMEINTERPOLATION_BIND_UAV_INPAINTING_PYRAMID_MIPMAP_9); |
|||
RWTexture2D<FfxFloat32x4> rw_inpainting_pyramid10 : FFX_DECLARE_UAV(FFX_FRAMEINTERPOLATION_BIND_UAV_INPAINTING_PYRAMID_MIPMAP_10); |
|||
RWTexture2D<FfxFloat32x4> rw_inpainting_pyramid11 : FFX_DECLARE_UAV(FFX_FRAMEINTERPOLATION_BIND_UAV_INPAINTING_PYRAMID_MIPMAP_11); |
|||
RWTexture2D<FfxFloat32x4> rw_inpainting_pyramid12 : FFX_DECLARE_UAV(FFX_FRAMEINTERPOLATION_BIND_UAV_INPAINTING_PYRAMID_MIPMAP_12); |
|||
|
|||
|
|||
FfxFloat32x4 RWLoadInpaintingPyramid(FFX_PARAMETER_IN FfxInt32x2 iPxPos, FFX_PARAMETER_IN FfxUInt32 index) |
|||
{ |
|||
#define LOAD(idx) \ |
|||
if (index == idx) \ |
|||
{ \ |
|||
return rw_inpainting_pyramid##idx[iPxPos]; \ |
|||
} |
|||
LOAD(0); |
|||
LOAD(1); |
|||
LOAD(2); |
|||
LOAD(3); |
|||
LOAD(4); |
|||
LOAD(5); |
|||
LOAD(6); |
|||
LOAD(7); |
|||
LOAD(8); |
|||
LOAD(9); |
|||
LOAD(10); |
|||
LOAD(11); |
|||
LOAD(12); |
|||
return 0; |
|||
|
|||
#undef LOAD |
|||
} |
|||
|
|||
void StoreInpaintingPyramid(FFX_PARAMETER_IN FfxInt32x2 iPxPos, FFX_PARAMETER_IN FfxFloat32x4 outValue, FFX_PARAMETER_IN FfxUInt32 index) |
|||
{ |
|||
#define STORE(idx) \ |
|||
if (index == idx) \ |
|||
{ \ |
|||
rw_inpainting_pyramid##idx[iPxPos] = outValue; \ |
|||
} |
|||
|
|||
STORE(0); |
|||
STORE(1); |
|||
STORE(2); |
|||
STORE(3); |
|||
STORE(4); |
|||
STORE(5); |
|||
STORE(6); |
|||
STORE(7); |
|||
STORE(8); |
|||
STORE(9); |
|||
STORE(10); |
|||
STORE(11); |
|||
STORE(12); |
|||
|
|||
#undef STORE |
|||
} |
|||
#endif |
|||
|
|||
#endif // #if defined(FFX_GPU) |
|||
@ -0,0 +1,60 @@ |
|||
fileFormatVersion: 2 |
|||
guid: 8aa4708e4b50cd149a4df075f45b2ac7 |
|||
PluginImporter: |
|||
externalObjects: {} |
|||
serializedVersion: 2 |
|||
iconMap: {} |
|||
executionOrder: {} |
|||
defineConstraints: [] |
|||
isPreloaded: 0 |
|||
isOverridable: 1 |
|||
isExplicitlyReferenced: 0 |
|||
validateReferences: 1 |
|||
platformData: |
|||
- first: |
|||
: Any |
|||
second: |
|||
enabled: 0 |
|||
settings: |
|||
Exclude Editor: 1 |
|||
Exclude GameCoreScarlett: 1 |
|||
Exclude GameCoreXboxOne: 1 |
|||
Exclude Linux64: 1 |
|||
Exclude OSXUniversal: 1 |
|||
Exclude PS4: 1 |
|||
Exclude PS5: 1 |
|||
Exclude WebGL: 1 |
|||
Exclude Win: 1 |
|||
Exclude Win64: 1 |
|||
- first: |
|||
Any: |
|||
second: |
|||
enabled: 0 |
|||
settings: {} |
|||
- first: |
|||
Editor: Editor |
|||
second: |
|||
enabled: 0 |
|||
settings: |
|||
DefaultValueInitialized: true |
|||
- first: |
|||
Standalone: Linux64 |
|||
second: |
|||
enabled: 0 |
|||
settings: |
|||
CPU: None |
|||
- first: |
|||
Standalone: Win |
|||
second: |
|||
enabled: 0 |
|||
settings: |
|||
CPU: None |
|||
- first: |
|||
Standalone: Win64 |
|||
second: |
|||
enabled: 0 |
|||
settings: |
|||
CPU: None |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|||
@ -0,0 +1,445 @@ |
|||
// 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. |
|||
|
|||
#if !defined(FFX_FRAMEINTERPOLATION_COMMON_H) |
|||
#define FFX_FRAMEINTERPOLATION_COMMON_H |
|||
|
|||
#define FFX_FRAMEINTERPOLATION_DISPATCH_DRAW_DEBUG_TEAR_LINES (1 << 0) |
|||
#define FFX_FRAMEINTERPOLATION_DISPATCH_DRAW_DEBUG_RESET_INDICATORS (1 << 1) |
|||
#define FFX_FRAMEINTERPOLATION_DISPATCH_DRAW_DEBUG_VIEW (1 << 2) |
|||
|
|||
FFX_STATIC const FfxFloat32 FFX_FRAMEINTERPOLATION_EPSILON = 1e-03f; |
|||
FFX_STATIC const FfxFloat32 FFX_FRAMEINTERPOLATION_FLT_MAX = 3.402823466e+38f; |
|||
FFX_STATIC const FfxFloat32 FFX_FRAMEINTERPOLATION_FLT_MIN = 1.175494351e-38f; |
|||
|
|||
FFX_STATIC const FfxFloat32 fReconstructedDepthBilinearWeightThreshold = FFX_FRAMEINTERPOLATION_EPSILON; |
|||
|
|||
FfxFloat32 RGBToLuma(FfxFloat32x3 fLinearRgb) |
|||
{ |
|||
return dot(fLinearRgb, FfxFloat32x3(0.2126f, 0.7152f, 0.0722f)); |
|||
} |
|||
|
|||
FfxFloat32 LinearRec2020ToLuminance(FfxFloat32x3 linearRec2020RGB) |
|||
{ |
|||
FfxFloat32 fY = 0.2627 * linearRec2020RGB.x + 0.678 * linearRec2020RGB.y + 0.0593 * linearRec2020RGB.z; |
|||
return fY; |
|||
} |
|||
|
|||
FfxFloat32x3 ffxscRGBToLinear(FfxFloat32x3 value, FfxFloat32 minLuminance, FfxFloat32 maxLuminance) |
|||
{ |
|||
FfxFloat32x3 p = value - ffxBroadcast3(minLuminance / 80.0f); |
|||
return p / ffxBroadcast3((maxLuminance - minLuminance) / 80.0f); |
|||
} |
|||
|
|||
FfxFloat32x3 RawRGBToLinear(FfxFloat32x3 fRawRgb) |
|||
{ |
|||
FfxFloat32x3 fLinearRgb; |
|||
|
|||
switch (BackBufferTransferFunction()) |
|||
{ |
|||
case 0: |
|||
fLinearRgb = ffxLinearFromSrgb(fRawRgb); |
|||
break; |
|||
case 1: |
|||
fLinearRgb = ffxLinearFromPQ(fRawRgb) * (10000.0f / MaxLuminance()); |
|||
break; |
|||
case 2: |
|||
fLinearRgb = ffxscRGBToLinear(fRawRgb, MinLuminance(), MaxLuminance()); |
|||
break; |
|||
} |
|||
|
|||
return fLinearRgb; |
|||
} |
|||
|
|||
FfxFloat32 RawRGBToLuminance(FfxFloat32x3 fRawRgb) |
|||
{ |
|||
FfxFloat32 fLuminance = 0.0f; |
|||
|
|||
switch (BackBufferTransferFunction()) |
|||
{ |
|||
case 0: |
|||
fLuminance = RGBToLuma(RawRGBToLinear(fRawRgb)); |
|||
break; |
|||
case 1: |
|||
fLuminance = LinearRec2020ToLuminance(RawRGBToLinear(fRawRgb)); |
|||
break; |
|||
case 2: |
|||
fLuminance = RGBToLuma(RawRGBToLinear(fRawRgb)); |
|||
break; |
|||
} |
|||
|
|||
return fLuminance; |
|||
} |
|||
|
|||
FfxFloat32 RawRGBToPerceivedLuma(FfxFloat32x3 fRawRgb) |
|||
{ |
|||
FfxFloat32 fLuminance = RawRGBToLuminance(fRawRgb); |
|||
|
|||
FfxFloat32 fPercievedLuminance = 0; |
|||
if (fLuminance <= 216.0f / 24389.0f) |
|||
{ |
|||
fPercievedLuminance = fLuminance * (24389.0f / 27.0f); |
|||
} |
|||
else |
|||
{ |
|||
fPercievedLuminance = ffxPow(fLuminance, 1.0f / 3.0f) * 116.0f - 16.0f; |
|||
} |
|||
|
|||
return fPercievedLuminance * 0.01f; |
|||
} |
|||
|
|||
struct BilinearSamplingData |
|||
{ |
|||
FfxInt32x2 iOffsets[4]; |
|||
FfxFloat32 fWeights[4]; |
|||
FfxInt32x2 iBasePos; |
|||
}; |
|||
|
|||
BilinearSamplingData GetBilinearSamplingData(FfxFloat32x2 fUv, FfxInt32x2 iSize) |
|||
{ |
|||
BilinearSamplingData data; |
|||
|
|||
FfxFloat32x2 fPxSample = (fUv * iSize) - FfxFloat32x2(0.5f, 0.5f); |
|||
data.iBasePos = FfxInt32x2(floor(fPxSample)); |
|||
FfxFloat32x2 fPxFrac = ffxFract(fPxSample); |
|||
|
|||
data.iOffsets[0] = FfxInt32x2(0, 0); |
|||
data.iOffsets[1] = FfxInt32x2(1, 0); |
|||
data.iOffsets[2] = FfxInt32x2(0, 1); |
|||
data.iOffsets[3] = FfxInt32x2(1, 1); |
|||
|
|||
data.fWeights[0] = (1 - fPxFrac.x) * (1 - fPxFrac.y); |
|||
data.fWeights[1] = (fPxFrac.x) * (1 - fPxFrac.y); |
|||
data.fWeights[2] = (1 - fPxFrac.x) * (fPxFrac.y); |
|||
data.fWeights[3] = (fPxFrac.x) * (fPxFrac.y); |
|||
|
|||
return data; |
|||
} |
|||
|
|||
#if defined(FFX_FRAMEINTERPOLATION_BIND_CB_FRAMEINTERPOLATION) |
|||
FfxFloat32 ConvertFromDeviceDepthToViewSpace(FfxFloat32 fDeviceDepth) |
|||
{ |
|||
const FfxFloat32x4 deviceToViewDepth = DeviceToViewSpaceTransformFactors(); |
|||
return deviceToViewDepth[1] / (fDeviceDepth - deviceToViewDepth[0]); |
|||
} |
|||
|
|||
FfxFloat32x2 ComputeNdc(FfxFloat32x2 fPxPos, FfxInt32x2 iSize) |
|||
{ |
|||
return fPxPos / FfxFloat32x2(iSize) * FfxFloat32x2(2.0f, -2.0f) + FfxFloat32x2(-1.0f, 1.0f); |
|||
} |
|||
|
|||
FfxFloat32x3 GetViewSpacePosition(FfxInt32x2 iViewportPos, FfxInt32x2 iViewportSize, FfxFloat32 fDeviceDepth) |
|||
{ |
|||
const FfxFloat32x4 fDeviceToViewDepth = DeviceToViewSpaceTransformFactors(); |
|||
|
|||
const FfxFloat32 Z = ConvertFromDeviceDepthToViewSpace(fDeviceDepth); |
|||
|
|||
const FfxFloat32x2 fNdcPos = ComputeNdc(iViewportPos, iViewportSize); |
|||
const FfxFloat32 X = fDeviceToViewDepth[2] * fNdcPos.x * Z; |
|||
const FfxFloat32 Y = fDeviceToViewDepth[3] * fNdcPos.y * Z; |
|||
|
|||
return FfxFloat32x3(X, Y, Z); |
|||
} |
|||
#endif |
|||
|
|||
FfxBoolean IsOnScreen(FfxInt32x2 pos, FfxInt32x2 size) |
|||
{ |
|||
return all(FFX_LESS_THAN(FfxUInt32x2(pos), FfxUInt32x2(size))); |
|||
} |
|||
|
|||
FfxBoolean IsUvInside(FfxFloat32x2 fUv) |
|||
{ |
|||
return (fUv.x > 0.0f && fUv.x < 1.0f) && (fUv.y > 0.0f && fUv.y < 1.0f); |
|||
} |
|||
|
|||
FfxBoolean IsInRect(FfxInt32x2 pos, FfxInt32x2 iRectCorner, FfxInt32x2 iRectSize) |
|||
{ |
|||
return (pos.x >= iRectCorner.x && pos.x < (iRectSize.x + iRectCorner.x) && pos.y >= iRectCorner.y && pos.y < (iRectSize.y + iRectCorner.y)); |
|||
} |
|||
|
|||
FfxFloat32 MinDividedByMax(const FfxFloat32 v0, const FfxFloat32 v1) |
|||
{ |
|||
const FfxFloat32 m = ffxMax(v0, v1); |
|||
return m != 0 ? ffxMin(v0, v1) / m : 0; |
|||
} |
|||
|
|||
FfxFloat32 NormalizedDot3(const FfxFloat32x3 v0, const FfxFloat32x3 v1) |
|||
{ |
|||
FfxFloat32 fMaxLength = ffxMax(length(v0), length(v1)); |
|||
|
|||
return fMaxLength > 0.0f ? dot(v0 / fMaxLength, v1 / fMaxLength) : 1.0f; |
|||
} |
|||
|
|||
FfxFloat32 NormalizedDot2(const FfxFloat32x2 v0, const FfxFloat32x2 v1) |
|||
{ |
|||
FfxFloat32 fMaxLength = ffxMax(length(v0), length(v1)); |
|||
|
|||
return fMaxLength > 0.0f ? dot(v0 / fMaxLength, v1 / fMaxLength) : 1.0f; |
|||
} |
|||
|
|||
FfxFloat32 CalculateStaticContentFactor(FfxFloat32x3 fCurrentInterpolationSource, FfxFloat32x3 fPresentColor) |
|||
{ |
|||
const FfxFloat32x3 fFactor = ffxSaturate(FfxFloat32x3( |
|||
ffxSaturate((1.0f - MinDividedByMax(fCurrentInterpolationSource.r, fPresentColor.r)) / 0.1f), |
|||
ffxSaturate((1.0f - MinDividedByMax(fCurrentInterpolationSource.g, fPresentColor.g)) / 0.1f), |
|||
ffxSaturate((1.0f - MinDividedByMax(fCurrentInterpolationSource.b, fPresentColor.b)) / 0.1f) |
|||
)); |
|||
|
|||
return max(fFactor.x, max(fFactor.y, fFactor.z)); |
|||
} |
|||
|
|||
// |
|||
// MOTION VECTOR FIELD |
|||
// |
|||
|
|||
FFX_STATIC const FfxUInt32 MOTION_VECTOR_FIELD_ENTRY_BIT_COUNT = 32; |
|||
|
|||
// Make sure all bit counts add up to MOTION_VECTOR_FIELD_ENTRY_BIT_COUNT |
|||
FFX_STATIC const FfxUInt32 MOTION_VECTOR_FIELD_VECTOR_COEFFICIENT_BIT_COUNT = 16; |
|||
FFX_STATIC const FfxUInt32 MOTION_VECTOR_FIELD_PRIORITY_LOW_BIT_COUNT = 5; |
|||
FFX_STATIC const FfxUInt32 MOTION_VECTOR_FIELD_PRIORITY_HIGH_BIT_COUNT = 10; |
|||
FFX_STATIC const FfxUInt32 MOTION_VECTOR_PRIMARY_VECTOR_INDICATION_BIT_COUNT = 1; |
|||
|
|||
FFX_STATIC const FfxUInt32 MOTION_VECTOR_FIELD_PRIMARY_VECTOR_INDICATION_BIT = (1U << (MOTION_VECTOR_FIELD_ENTRY_BIT_COUNT - 1)); |
|||
|
|||
FFX_STATIC const FfxUInt32 PRIORITY_LOW_MAX = (1U << MOTION_VECTOR_FIELD_PRIORITY_LOW_BIT_COUNT) - 1; |
|||
FFX_STATIC const FfxUInt32 PRIORITY_HIGH_MAX = (1U << MOTION_VECTOR_FIELD_PRIORITY_HIGH_BIT_COUNT) - 1; |
|||
|
|||
FFX_STATIC const FfxUInt32 PRIORITY_LOW_OFFSET = MOTION_VECTOR_FIELD_VECTOR_COEFFICIENT_BIT_COUNT; |
|||
FFX_STATIC const FfxUInt32 PRIORITY_HIGH_OFFSET = PRIORITY_LOW_OFFSET + MOTION_VECTOR_FIELD_PRIORITY_LOW_BIT_COUNT; |
|||
FFX_STATIC const FfxUInt32 PRIMARY_VECTOR_INDICATION_OFFSET = PRIORITY_HIGH_OFFSET + MOTION_VECTOR_FIELD_PRIORITY_HIGH_BIT_COUNT; |
|||
|
|||
struct VectorFieldEntry |
|||
{ |
|||
FfxFloat32x2 fMotionVector; |
|||
FfxFloat32 uHighPriorityFactor; |
|||
FfxFloat32 uLowPriorityFactor; |
|||
FfxBoolean bValid; |
|||
FfxBoolean bPrimary; |
|||
FfxBoolean bSecondary; |
|||
FfxBoolean bInPainted; |
|||
FfxFloat32 fVelocity; |
|||
FfxBoolean bNegOutside; |
|||
FfxBoolean bPosOutside; |
|||
}; |
|||
|
|||
VectorFieldEntry NewVectorFieldEntry() |
|||
{ |
|||
VectorFieldEntry vfe; |
|||
vfe.fMotionVector = FfxFloat32x2(0.0, 0.0); |
|||
vfe.uHighPriorityFactor = 0.0; |
|||
vfe.uLowPriorityFactor = 0.0; |
|||
vfe.bValid = false; |
|||
vfe.bPrimary = false; |
|||
vfe.bSecondary = false; |
|||
vfe.bInPainted = false; |
|||
vfe.fVelocity = 0.0; |
|||
vfe.bNegOutside = false; |
|||
vfe.bPosOutside = false; |
|||
return vfe; |
|||
} |
|||
|
|||
FfxBoolean PackedVectorFieldEntryIsPrimary(FfxUInt32 packedEntry) |
|||
{ |
|||
return ((packedEntry & MOTION_VECTOR_FIELD_PRIMARY_VECTOR_INDICATION_BIT) != 0); |
|||
} |
|||
|
|||
FfxUInt32x2 PackVectorFieldEntries(FfxBoolean bIsPrimary, FfxUInt32 uHighPriorityFactor, FfxUInt32 uLowPriorityFactor, FfxFloat32x2 fMotionVector) |
|||
{ |
|||
const FfxUInt32 uPriority = |
|||
(FfxUInt32(bIsPrimary) * MOTION_VECTOR_FIELD_PRIMARY_VECTOR_INDICATION_BIT) |
|||
| ((uHighPriorityFactor & PRIORITY_HIGH_MAX) << PRIORITY_HIGH_OFFSET) |
|||
| ((uLowPriorityFactor & PRIORITY_LOW_MAX) << PRIORITY_LOW_OFFSET); |
|||
|
|||
FfxUInt32 packedX = uPriority | ffxF32ToF16(fMotionVector.x); |
|||
FfxUInt32 packedY = uPriority | ffxF32ToF16(fMotionVector.y); |
|||
|
|||
return FfxUInt32x2(packedX, packedY); |
|||
} |
|||
|
|||
void UnpackVectorFieldEntries(FfxUInt32x2 packed, out VectorFieldEntry vfElement) |
|||
{ |
|||
vfElement.uHighPriorityFactor = FfxFloat32((packed.x >> PRIORITY_HIGH_OFFSET) & PRIORITY_HIGH_MAX) / PRIORITY_HIGH_MAX; |
|||
vfElement.uLowPriorityFactor = FfxFloat32((packed.x >> PRIORITY_LOW_OFFSET) & PRIORITY_LOW_MAX) / PRIORITY_LOW_MAX; |
|||
|
|||
vfElement.bPrimary = PackedVectorFieldEntryIsPrimary(packed.x); |
|||
vfElement.bValid = (vfElement.uHighPriorityFactor > 0.0f); |
|||
vfElement.bSecondary = vfElement.bValid && !vfElement.bPrimary; |
|||
|
|||
// Reverse priority factor for secondary vectors |
|||
if (vfElement.bSecondary) |
|||
{ |
|||
vfElement.uHighPriorityFactor = 1.0f - vfElement.uHighPriorityFactor; |
|||
} |
|||
|
|||
vfElement.fMotionVector.x = ffxUnpackF32(packed.x).x; |
|||
vfElement.fMotionVector.y = ffxUnpackF32(packed.y).x; |
|||
vfElement.bInPainted = false; |
|||
} |
|||
|
|||
// |
|||
// MOTION VECTOR FIELD |
|||
// |
|||
|
|||
#if defined(FFX_FRAMEINTERPOLATION_BIND_SRV_INPAINTING_PYRAMID) |
|||
FfxFloat32x4 ComputeMvInpaintingLevel(FfxFloat32x2 fUv, const FfxInt32 iMipLevel, const FfxInt32x2 iTexSize) |
|||
{ |
|||
BilinearSamplingData bilinearInfo = GetBilinearSamplingData(fUv, iTexSize); |
|||
|
|||
FfxFloat32 fSum = 0.0f; |
|||
FfxFloat32x4 fColor = FfxFloat32x4(0.0, 0.0, 0.0, 0.0); |
|||
fColor.z = 0; |
|||
|
|||
const FfxFloat32 fMaxPriorityFactor = 1.0f; |
|||
|
|||
for (FfxInt32 iSampleIndex = 0; iSampleIndex < 4; iSampleIndex++) |
|||
{ |
|||
const FfxInt32x2 iOffset = bilinearInfo.iOffsets[iSampleIndex]; |
|||
const FfxInt32x2 iSamplePos = bilinearInfo.iBasePos + iOffset; |
|||
|
|||
if (IsOnScreen(iSamplePos, iTexSize)) |
|||
{ |
|||
FfxFloat32x4 fSample = LoadInpaintingPyramid(iMipLevel, iSamplePos); |
|||
|
|||
const FfxFloat32 fPriorityFactor = fSample.z; |
|||
const FfxFloat32 fValidMvFactor = FfxFloat32(fSample.z > 0); |
|||
const FfxFloat32 fSampleWeight = bilinearInfo.fWeights[iSampleIndex] * fValidMvFactor * fPriorityFactor; |
|||
|
|||
fSum += fSampleWeight; |
|||
fColor += fSample * fSampleWeight; |
|||
} |
|||
} |
|||
|
|||
fColor /= (fSum > 0.0f) ? fSum : 1.0f; |
|||
|
|||
return fColor; |
|||
} |
|||
#if defined(FFX_FRAMEINTERPOLATION_BIND_CB_FRAMEINTERPOLATION) && \ |
|||
defined(FFX_FRAMEINTERPOLATION_BIND_SRV_GAME_MOTION_VECTOR_FIELD_X) && \ |
|||
defined(FFX_FRAMEINTERPOLATION_BIND_SRV_GAME_MOTION_VECTOR_FIELD_Y) |
|||
|
|||
void LoadInpaintedGameFieldMv(FfxFloat32x2 fUv, out VectorFieldEntry vfElement) |
|||
{ |
|||
FfxInt32x2 iPxSample = FfxInt32x2(fUv * RenderSize()); |
|||
FfxUInt32x2 packedGameFieldMv = LoadGameFieldMv(iPxSample); |
|||
UnpackVectorFieldEntries(packedGameFieldMv, vfElement); |
|||
|
|||
if (!vfElement.bValid) |
|||
{ |
|||
//FfxFloat32x2 fUv = (FfxFloat32x2(iPxSample) + 0.5f) / RenderSize(); |
|||
FfxInt32x2 iTexSize = RenderSize(); |
|||
|
|||
FfxFloat32x4 fInPaintedVector = FfxFloat32x4(0.0, 0.0, 0.0, 0.0); |
|||
for (FfxInt32 iMipLevel = 0; iMipLevel < 11 && (fInPaintedVector.w == 0.0f); iMipLevel++) |
|||
{ |
|||
iTexSize /= 2; |
|||
|
|||
fInPaintedVector = ComputeMvInpaintingLevel(fUv, iMipLevel, iTexSize); |
|||
} |
|||
|
|||
vfElement.fMotionVector = fInPaintedVector.xy; |
|||
vfElement.uHighPriorityFactor = fInPaintedVector.z; |
|||
vfElement.uLowPriorityFactor = fInPaintedVector.w; |
|||
vfElement.bInPainted = true; |
|||
} |
|||
|
|||
vfElement.bNegOutside = !IsUvInside(fUv - vfElement.fMotionVector); |
|||
vfElement.bPosOutside = !IsUvInside(fUv + vfElement.fMotionVector); |
|||
vfElement.fVelocity = length(vfElement.fMotionVector); |
|||
} |
|||
#endif |
|||
#endif |
|||
|
|||
#if defined(FFX_FRAMEINTERPOLATION_BIND_SRV_OPTICAL_FLOW_MOTION_VECTOR_FIELD_X) && \ |
|||
defined(FFX_FRAMEINTERPOLATION_BIND_SRV_OPTICAL_FLOW_MOTION_VECTOR_FIELD_Y) && \ |
|||
defined(FFX_FRAMEINTERPOLATION_BIND_CB_FRAMEINTERPOLATION) |
|||
void SampleOpticalFlowMotionVectorField(FfxFloat32x2 fUv, out VectorFieldEntry vfElement) |
|||
{ |
|||
const FfxFloat32 scaleFactor = 1.0f; |
|||
|
|||
BilinearSamplingData bilinearInfo = GetBilinearSamplingData(fUv, FfxInt32x2(GetOpticalFlowSize2() * scaleFactor)); |
|||
|
|||
vfElement = NewVectorFieldEntry(); |
|||
|
|||
FfxFloat32 fWeightSum = 0.0f; |
|||
for (FfxInt32 iSampleIndex = 0; iSampleIndex < 4; iSampleIndex++) |
|||
{ |
|||
const FfxInt32x2 iOffset = bilinearInfo.iOffsets[iSampleIndex]; |
|||
const FfxInt32x2 iSamplePos = bilinearInfo.iBasePos + iOffset; |
|||
|
|||
if (IsOnScreen(iSamplePos, FfxInt32x2(GetOpticalFlowSize2() * scaleFactor))) |
|||
{ |
|||
const FfxFloat32 fWeight = bilinearInfo.fWeights[iSampleIndex]; |
|||
|
|||
VectorFieldEntry fOfVectorSample = NewVectorFieldEntry(); |
|||
FfxInt32x2 packedOpticalFlowMv = FfxInt32x2(LoadOpticalFlowFieldMv(iSamplePos)); |
|||
UnpackVectorFieldEntries(packedOpticalFlowMv, fOfVectorSample); |
|||
|
|||
vfElement.fMotionVector += fOfVectorSample.fMotionVector * fWeight; |
|||
vfElement.uHighPriorityFactor += fOfVectorSample.uHighPriorityFactor * fWeight; |
|||
vfElement.uLowPriorityFactor += fOfVectorSample.uLowPriorityFactor * fWeight; |
|||
|
|||
fWeightSum += fWeight; |
|||
} |
|||
} |
|||
|
|||
if (fWeightSum > 0.0f) |
|||
{ |
|||
vfElement.fMotionVector /= fWeightSum; |
|||
vfElement.uHighPriorityFactor /= fWeightSum; |
|||
vfElement.uLowPriorityFactor /= fWeightSum; |
|||
} |
|||
|
|||
vfElement.bNegOutside = !IsUvInside(fUv - vfElement.fMotionVector); |
|||
vfElement.bPosOutside = !IsUvInside(fUv + vfElement.fMotionVector); |
|||
vfElement.fVelocity = length(vfElement.fMotionVector); |
|||
} |
|||
#endif |
|||
|
|||
FfxFloat32x3 Tonemap(FfxFloat32x3 fRgb) |
|||
{ |
|||
return fRgb / (ffxMax(ffxMax(0.f, fRgb.r), ffxMax(fRgb.g, fRgb.b)) + 1.f).xxx; |
|||
} |
|||
|
|||
FfxFloat32x3 InverseTonemap(FfxFloat32x3 fRgb) |
|||
{ |
|||
return fRgb / ffxMax(FFX_TONEMAP_EPSILON, 1.f - ffxMax(fRgb.r, ffxMax(fRgb.g, fRgb.b))).xxx; |
|||
} |
|||
|
|||
FfxInt32x2 ComputeHrPosFromLrPos(FfxInt32x2 iPxLrPos) |
|||
{ |
|||
FfxFloat32x2 fSrcJitteredPos = FfxFloat32x2(iPxLrPos) + 0.5f - Jitter(); |
|||
FfxFloat32x2 fLrPosInHr = (fSrcJitteredPos / RenderSize()) * DisplaySize(); |
|||
FfxInt32x2 iPxHrPos = FfxInt32x2(floor(fLrPosInHr)); |
|||
return iPxHrPos; |
|||
} |
|||
#if FFX_HALF |
|||
FFX_MIN16_I2 ComputeHrPosFromLrPos(FFX_MIN16_I2 iPxLrPos) |
|||
{ |
|||
FFX_MIN16_F2 fSrcJitteredPos = FFX_MIN16_F2(iPxLrPos) + FFX_MIN16_F(0.5f) - FFX_MIN16_F2(Jitter()); |
|||
FFX_MIN16_F2 fLrPosInHr = (fSrcJitteredPos / FFX_MIN16_F2(RenderSize())) * FFX_MIN16_F2(DisplaySize()); |
|||
FFX_MIN16_I2 iPxHrPos = FFX_MIN16_I2(floor(fLrPosInHr)); |
|||
return iPxHrPos; |
|||
} |
|||
#endif |
|||
|
|||
#endif //!defined(FFX_FRAMEINTERPOLATION_COMMON_H) |
|||
@ -0,0 +1,60 @@ |
|||
fileFormatVersion: 2 |
|||
guid: 35acb60e8d4c40a458862ab63bd9e45c |
|||
PluginImporter: |
|||
externalObjects: {} |
|||
serializedVersion: 2 |
|||
iconMap: {} |
|||
executionOrder: {} |
|||
defineConstraints: [] |
|||
isPreloaded: 0 |
|||
isOverridable: 1 |
|||
isExplicitlyReferenced: 0 |
|||
validateReferences: 1 |
|||
platformData: |
|||
- first: |
|||
: Any |
|||
second: |
|||
enabled: 0 |
|||
settings: |
|||
Exclude Editor: 1 |
|||
Exclude GameCoreScarlett: 1 |
|||
Exclude GameCoreXboxOne: 1 |
|||
Exclude Linux64: 1 |
|||
Exclude OSXUniversal: 1 |
|||
Exclude PS4: 1 |
|||
Exclude PS5: 1 |
|||
Exclude WebGL: 1 |
|||
Exclude Win: 1 |
|||
Exclude Win64: 1 |
|||
- first: |
|||
Any: |
|||
second: |
|||
enabled: 0 |
|||
settings: {} |
|||
- first: |
|||
Editor: Editor |
|||
second: |
|||
enabled: 0 |
|||
settings: |
|||
DefaultValueInitialized: true |
|||
- first: |
|||
Standalone: Linux64 |
|||
second: |
|||
enabled: 0 |
|||
settings: |
|||
CPU: None |
|||
- first: |
|||
Standalone: Win |
|||
second: |
|||
enabled: 0 |
|||
settings: |
|||
CPU: None |
|||
- first: |
|||
Standalone: Win64 |
|||
second: |
|||
enabled: 0 |
|||
settings: |
|||
CPU: None |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|||
@ -0,0 +1,121 @@ |
|||
// 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. |
|||
|
|||
#ifndef FFX_FRAMEINTERPOLATION_COMPUTE_GAME_VECTOR_FIELD_INPAINTING_PYRAMID_H |
|||
#define FFX_FRAMEINTERPOLATION_COMPUTE_GAME_VECTOR_FIELD_INPAINTING_PYRAMID_H |
|||
|
|||
#include "ffx_frameinterpolation_common.h" |
|||
//-------------------------------------------------------------------------------------- |
|||
// Buffer definitions - global atomic counter |
|||
//-------------------------------------------------------------------------------------- |
|||
|
|||
FFX_GROUPSHARED FfxUInt32 spdCounter; |
|||
FFX_GROUPSHARED FfxFloat32 spdIntermediateR[16][16]; |
|||
FFX_GROUPSHARED FfxFloat32 spdIntermediateG[16][16]; |
|||
FFX_GROUPSHARED FfxFloat32 spdIntermediateB[16][16]; |
|||
FFX_GROUPSHARED FfxFloat32 spdIntermediateA[16][16]; |
|||
|
|||
FfxFloat32x4 SpdLoadSourceImage(FfxInt32x2 tex, FfxUInt32 slice) |
|||
{ |
|||
VectorFieldEntry gameMv; |
|||
FfxUInt32x2 packedGameFieldMv = LoadGameFieldMv(tex); |
|||
UnpackVectorFieldEntries(packedGameFieldMv, gameMv); |
|||
|
|||
return FfxFloat32x4(gameMv.fMotionVector, gameMv.uHighPriorityFactor, gameMv.uLowPriorityFactor) * FfxFloat32(DisplaySize().x > 0); |
|||
} |
|||
|
|||
FfxFloat32x4 SpdLoad(FfxInt32x2 tex, FfxUInt32 slice) |
|||
{ |
|||
return RWLoadInpaintingPyramid(tex, 5); |
|||
} |
|||
|
|||
void SpdStore(FfxInt32x2 pix, FfxFloat32x4 outValue, FfxUInt32 index, FfxUInt32 slice) |
|||
{ |
|||
StoreInpaintingPyramid(pix, outValue, index); |
|||
} |
|||
|
|||
void SpdIncreaseAtomicCounter(FfxUInt32 slice) |
|||
{ |
|||
AtomicIncreaseCounter(COUNTER_SPD, spdCounter); |
|||
} |
|||
|
|||
FfxUInt32 SpdGetAtomicCounter() |
|||
{ |
|||
return spdCounter; |
|||
} |
|||
void SpdResetAtomicCounter(FfxUInt32 slice) |
|||
{ |
|||
StoreCounter(COUNTER_SPD, 0); |
|||
} |
|||
|
|||
FfxFloat32x4 SpdLoadIntermediate(FfxUInt32 x, FfxUInt32 y) |
|||
{ |
|||
return FfxFloat32x4( |
|||
spdIntermediateR[x][y], |
|||
spdIntermediateG[x][y], |
|||
spdIntermediateB[x][y], |
|||
spdIntermediateA[x][y]); |
|||
} |
|||
|
|||
void SpdStoreIntermediate(FfxUInt32 x, FfxUInt32 y, FfxFloat32x4 value) |
|||
{ |
|||
spdIntermediateR[x][y] = value.x; |
|||
spdIntermediateG[x][y] = value.y; |
|||
spdIntermediateB[x][y] = value.z; |
|||
spdIntermediateA[x][y] = value.w; |
|||
} |
|||
|
|||
FfxFloat32x4 SpdReduce4(FfxFloat32x4 v0, FfxFloat32x4 v1, FfxFloat32x4 v2, FfxFloat32x4 v3) |
|||
{ |
|||
FfxFloat32x4 vec = FfxFloat32x4(0,0,0,0); |
|||
|
|||
FfxFloat32 fWeightSum = 0.0f; |
|||
#define ADD(SAMPLE) { \ |
|||
FfxFloat32 fWeight = FfxFloat32(SAMPLE.z > 0.0f); \ |
|||
vec += SAMPLE * fWeight; \ |
|||
fWeightSum += fWeight; \ |
|||
} |
|||
|
|||
ADD(v0); |
|||
ADD(v1); |
|||
ADD(v2); |
|||
ADD(v3); |
|||
|
|||
vec /= (fWeightSum > FFX_FRAMEINTERPOLATION_EPSILON) ? fWeightSum : 1.0f; |
|||
|
|||
return vec; |
|||
} |
|||
|
|||
#include "spd/ffx_spd.h" |
|||
|
|||
void computeFrameinterpolationGameVectorFieldInpaintingPyramid(FfxInt32x3 iGroupId, FfxInt32 iLocalIndex) |
|||
{ |
|||
SpdDownsample( |
|||
FfxUInt32x2(iGroupId.xy), |
|||
FfxUInt32(iLocalIndex), |
|||
FfxUInt32(NumMips()), |
|||
FfxUInt32(NumWorkGroups()), |
|||
FfxUInt32(iGroupId.z), |
|||
FfxUInt32x2(WorkGroupOffset())); |
|||
} |
|||
|
|||
#endif // FFX_FRAMEINTERPOLATION_COMPUTE_GAME_VECTOR_FIELD_INPAINTING_PYRAMID_H |
|||
@ -0,0 +1,60 @@ |
|||
fileFormatVersion: 2 |
|||
guid: 283ecd643b314d348886d886b8c7b6fa |
|||
PluginImporter: |
|||
externalObjects: {} |
|||
serializedVersion: 2 |
|||
iconMap: {} |
|||
executionOrder: {} |
|||
defineConstraints: [] |
|||
isPreloaded: 0 |
|||
isOverridable: 1 |
|||
isExplicitlyReferenced: 0 |
|||
validateReferences: 1 |
|||
platformData: |
|||
- first: |
|||
: Any |
|||
second: |
|||
enabled: 0 |
|||
settings: |
|||
Exclude Editor: 1 |
|||
Exclude GameCoreScarlett: 1 |
|||
Exclude GameCoreXboxOne: 1 |
|||
Exclude Linux64: 1 |
|||
Exclude OSXUniversal: 1 |
|||
Exclude PS4: 1 |
|||
Exclude PS5: 1 |
|||
Exclude WebGL: 1 |
|||
Exclude Win: 1 |
|||
Exclude Win64: 1 |
|||
- first: |
|||
Any: |
|||
second: |
|||
enabled: 0 |
|||
settings: {} |
|||
- first: |
|||
Editor: Editor |
|||
second: |
|||
enabled: 0 |
|||
settings: |
|||
DefaultValueInitialized: true |
|||
- first: |
|||
Standalone: Linux64 |
|||
second: |
|||
enabled: 0 |
|||
settings: |
|||
CPU: None |
|||
- first: |
|||
Standalone: Win |
|||
second: |
|||
enabled: 0 |
|||
settings: |
|||
CPU: None |
|||
- first: |
|||
Standalone: Win64 |
|||
second: |
|||
enabled: 0 |
|||
settings: |
|||
CPU: None |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|||
@ -0,0 +1,120 @@ |
|||
// 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. |
|||
|
|||
#ifndef FFX_FRAMEINTERPOLATION_COMPUTE_INPAINTING_PYRAMID_H |
|||
#define FFX_FRAMEINTERPOLATION_COMPUTE_INPAINTING_PYRAMID_H |
|||
|
|||
//-------------------------------------------------------------------------------------- |
|||
// Buffer definitions - global atomic counter |
|||
//-------------------------------------------------------------------------------------- |
|||
|
|||
FFX_GROUPSHARED FfxUInt32 spdCounter; |
|||
FFX_GROUPSHARED FfxFloat32 spdIntermediateR[16][16]; |
|||
FFX_GROUPSHARED FfxFloat32 spdIntermediateG[16][16]; |
|||
FFX_GROUPSHARED FfxFloat32 spdIntermediateB[16][16]; |
|||
FFX_GROUPSHARED FfxFloat32 spdIntermediateA[16][16]; |
|||
|
|||
FfxFloat32x4 SpdLoadSourceImage(FfxInt32x2 tex, FfxUInt32 slice) |
|||
{ |
|||
FfxFloat32x4 fColor = LoadFrameInterpolationOutput(tex) * FfxFloat32(DisplaySize().x > 0); |
|||
|
|||
// reverse sample weights |
|||
fColor.w = ffxSaturate(1.0f - fColor.w); |
|||
|
|||
|
|||
if (tex.x < InterpolationRectBase().x || tex.x >= (InterpolationRectSize().x + InterpolationRectBase().x) || tex.y < InterpolationRectBase().y || |
|||
tex.y >= (InterpolationRectSize().y + InterpolationRectBase().y)) |
|||
{ |
|||
fColor.w = 0.0f; // don't take contributions from outside of the interpolation rect |
|||
} |
|||
|
|||
return fColor; |
|||
} |
|||
|
|||
FfxFloat32x4 SpdLoad(FfxInt32x2 tex, FfxUInt32 slice) |
|||
{ |
|||
return RWLoadInpaintingPyramid(tex, 5); |
|||
} |
|||
|
|||
void SpdStore(FfxInt32x2 pix, FfxFloat32x4 outValue, FfxUInt32 index, FfxUInt32 slice) |
|||
{ |
|||
StoreInpaintingPyramid(pix, outValue, index); |
|||
} |
|||
|
|||
void SpdIncreaseAtomicCounter(FfxUInt32 slice) |
|||
{ |
|||
AtomicIncreaseCounter(COUNTER_SPD, spdCounter); |
|||
} |
|||
|
|||
FfxUInt32 SpdGetAtomicCounter() |
|||
{ |
|||
return spdCounter; |
|||
} |
|||
void SpdResetAtomicCounter(FfxUInt32 slice) |
|||
{ |
|||
StoreCounter(COUNTER_SPD, 0); |
|||
} |
|||
|
|||
FfxFloat32x4 SpdLoadIntermediate(FfxUInt32 x, FfxUInt32 y) |
|||
{ |
|||
return FfxFloat32x4( |
|||
spdIntermediateR[x][y], |
|||
spdIntermediateG[x][y], |
|||
spdIntermediateB[x][y], |
|||
spdIntermediateA[x][y]); |
|||
} |
|||
|
|||
void SpdStoreIntermediate(FfxUInt32 x, FfxUInt32 y, FfxFloat32x4 value) |
|||
{ |
|||
spdIntermediateR[x][y] = value.x; |
|||
spdIntermediateG[x][y] = value.y; |
|||
spdIntermediateB[x][y] = value.z; |
|||
spdIntermediateA[x][y] = value.w; |
|||
} |
|||
|
|||
FfxFloat32x4 SpdReduce4(FfxFloat32x4 v0, FfxFloat32x4 v1, FfxFloat32x4 v2, FfxFloat32x4 v3) |
|||
{ |
|||
FfxFloat32x4 w = FfxFloat32x4(v0.w, v1.w, v2.w, v3.w); |
|||
|
|||
FfxFloat32 sum = (w[0] + w[1] + w[2] + w[3]); |
|||
|
|||
if (sum == 0.0f) { |
|||
return FfxFloat32x4(0.0, 0.0, 0.0, 0.0); |
|||
} |
|||
|
|||
return (v0 * w[0] + v1 * w[1] + v2 * w[2] + v3 * w[3]) / sum; |
|||
} |
|||
|
|||
#include "spd/ffx_spd.h" |
|||
|
|||
void computeFrameinterpolationInpaintingPyramid(FfxInt32x3 iGroupId, FfxInt32 iLocalIndex) |
|||
{ |
|||
SpdDownsample( |
|||
FfxUInt32x2(iGroupId.xy), |
|||
FfxUInt32(iLocalIndex), |
|||
FfxUInt32(NumMips()), |
|||
FfxUInt32(NumWorkGroups()), |
|||
FfxUInt32(iGroupId.z), |
|||
FfxUInt32x2(WorkGroupOffset())); |
|||
} |
|||
|
|||
#endif // FFX_FRAMEINTERPOLATION_COMPUTE_INPAINTING_PYRAMID_H |
|||
@ -0,0 +1,60 @@ |
|||
fileFormatVersion: 2 |
|||
guid: 1044379078f56104f8a6b0a227287666 |
|||
PluginImporter: |
|||
externalObjects: {} |
|||
serializedVersion: 2 |
|||
iconMap: {} |
|||
executionOrder: {} |
|||
defineConstraints: [] |
|||
isPreloaded: 0 |
|||
isOverridable: 1 |
|||
isExplicitlyReferenced: 0 |
|||
validateReferences: 1 |
|||
platformData: |
|||
- first: |
|||
: Any |
|||
second: |
|||
enabled: 0 |
|||
settings: |
|||
Exclude Editor: 1 |
|||
Exclude GameCoreScarlett: 1 |
|||
Exclude GameCoreXboxOne: 1 |
|||
Exclude Linux64: 1 |
|||
Exclude OSXUniversal: 1 |
|||
Exclude PS4: 1 |
|||
Exclude PS5: 1 |
|||
Exclude WebGL: 1 |
|||
Exclude Win: 1 |
|||
Exclude Win64: 1 |
|||
- first: |
|||
Any: |
|||
second: |
|||
enabled: 0 |
|||
settings: {} |
|||
- first: |
|||
Editor: Editor |
|||
second: |
|||
enabled: 0 |
|||
settings: |
|||
DefaultValueInitialized: true |
|||
- first: |
|||
Standalone: Linux64 |
|||
second: |
|||
enabled: 0 |
|||
settings: |
|||
CPU: None |
|||
- first: |
|||
Standalone: Win |
|||
second: |
|||
enabled: 0 |
|||
settings: |
|||
CPU: None |
|||
- first: |
|||
Standalone: Win64 |
|||
second: |
|||
enabled: 0 |
|||
settings: |
|||
CPU: None |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|||
@ -0,0 +1,163 @@ |
|||
// 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. |
|||
|
|||
#ifndef FFX_FRAMEINTERPOLATION_DEBUG_VIEW_H |
|||
#define FFX_FRAMEINTERPOLATION_DEBUG_VIEW_H |
|||
|
|||
struct FfxFrameInterpolationDebugViewport |
|||
{ |
|||
FfxInt32x2 offset; |
|||
FfxInt32x2 size; |
|||
}; |
|||
|
|||
// Macro to cull and draw debug viewport |
|||
#define DRAW_VIEWPORT(function, pos, vp) \ |
|||
{ \ |
|||
if (pointIsInsideViewport(pos, vp)) \ |
|||
{ \ |
|||
function(pos, vp); \ |
|||
} \ |
|||
} |
|||
|
|||
FfxFloat32x2 getTransformedUv(FfxInt32x2 iPxPos, FfxFrameInterpolationDebugViewport vp) |
|||
{ |
|||
FfxFloat32x2 fUv = (FfxFloat32x2(iPxPos - vp.offset) + 0.5f) / vp.size; |
|||
|
|||
return fUv; |
|||
} |
|||
|
|||
FfxFloat32x4 getMotionVectorColor(FfxFloat32x2 fMotionVector) |
|||
{ |
|||
return FfxFloat32x4(0.5f + fMotionVector * DisplaySize() * 0.1f, 0.5f, 1.0f); |
|||
} |
|||
|
|||
FfxFloat32x4 getUnusedIndicationColor(FfxInt32x2 iPxPos, FfxFrameInterpolationDebugViewport vp) |
|||
{ |
|||
FfxInt32x2 basePos = iPxPos - vp.offset; |
|||
|
|||
FfxFloat32 ar = FfxFloat32(vp.size.x) / FfxFloat32(vp.size.y); |
|||
|
|||
return FfxFloat32x4(basePos.x == FfxInt32(basePos.y * ar), 0, 0, 1); |
|||
} |
|||
|
|||
void drawGameMotionVectorFieldVectors(FfxInt32x2 iPxPos, FfxFrameInterpolationDebugViewport vp) |
|||
{ |
|||
FfxFloat32x2 fUv = getTransformedUv(iPxPos, vp); |
|||
|
|||
VectorFieldEntry gameMv; |
|||
LoadInpaintedGameFieldMv(fUv, gameMv); |
|||
|
|||
StoreFrameinterpolationOutput(iPxPos, getMotionVectorColor(gameMv.fMotionVector)); |
|||
} |
|||
|
|||
void drawGameMotionVectorFieldDepthPriority(FfxInt32x2 iPxPos, FfxFrameInterpolationDebugViewport vp) |
|||
{ |
|||
FfxFloat32x2 fUv = getTransformedUv(iPxPos, vp); |
|||
|
|||
VectorFieldEntry gameMv; |
|||
LoadInpaintedGameFieldMv(fUv, gameMv); |
|||
|
|||
StoreFrameinterpolationOutput(iPxPos, FfxFloat32x4(0, gameMv.uHighPriorityFactor, 0, 1)); |
|||
} |
|||
|
|||
void drawOpticalFlowMotionVectorField(FfxInt32x2 iPxPos, FfxFrameInterpolationDebugViewport vp) |
|||
{ |
|||
FfxFloat32x2 fUv = getTransformedUv(iPxPos, vp); |
|||
|
|||
VectorFieldEntry ofMv; |
|||
SampleOpticalFlowMotionVectorField(fUv, ofMv); |
|||
|
|||
StoreFrameinterpolationOutput(iPxPos, getMotionVectorColor(ofMv.fMotionVector)); |
|||
} |
|||
|
|||
void drawDisocclusionMask(FfxInt32x2 iPxPos, FfxFrameInterpolationDebugViewport vp) |
|||
{ |
|||
FfxFloat32x2 fUv = getTransformedUv(iPxPos, vp); |
|||
|
|||
FfxFloat32x2 fLrUv = fUv * (FfxFloat32x2(RenderSize()) / GetMaxRenderSize()); |
|||
|
|||
FfxFloat32x2 fDisocclusionFactor = ffxSaturate(SampleDisocclusionMask(fLrUv).xy); |
|||
|
|||
StoreFrameinterpolationOutput(iPxPos, FfxFloat32x4(fDisocclusionFactor, 0, 1)); |
|||
} |
|||
|
|||
void drawPresentBackbuffer(FfxInt32x2 iPxPos, FfxFrameInterpolationDebugViewport vp) |
|||
{ |
|||
FfxFloat32x2 fUv = getTransformedUv(iPxPos, vp); |
|||
|
|||
FfxFloat32x4 fPresentColor = getUnusedIndicationColor(iPxPos, vp); |
|||
|
|||
if (GetHUDLessAttachedFactor() == 1) |
|||
{ |
|||
fPresentColor = SamplePresentBackbuffer(fUv); |
|||
} |
|||
|
|||
StoreFrameinterpolationOutput(iPxPos, fPresentColor); |
|||
} |
|||
|
|||
void drawCurrentInterpolationSource(FfxInt32x2 iPxPos, FfxFrameInterpolationDebugViewport vp) |
|||
{ |
|||
FfxFloat32x2 fUv = getTransformedUv(iPxPos, vp); |
|||
|
|||
FfxFloat32x4 fCurrentBackBuffer = FfxFloat32x4(SampleCurrentBackbuffer(fUv), 1.0f); |
|||
|
|||
StoreFrameinterpolationOutput(iPxPos, fCurrentBackBuffer); |
|||
} |
|||
|
|||
FfxBoolean pointIsInsideViewport(FfxInt32x2 iPxPos, FfxFrameInterpolationDebugViewport vp) |
|||
{ |
|||
FfxInt32x2 extent = vp.offset + vp.size; |
|||
|
|||
return (iPxPos.x >= vp.offset.x && iPxPos.x < extent.x) && (iPxPos.y >= vp.offset.y && iPxPos.y < extent.y); |
|||
} |
|||
|
|||
void computeDebugView(FfxInt32x2 iPxPos) |
|||
{ |
|||
#define VIEWPORT_GRID_SIZE_X 3 |
|||
#define VIEWPORT_GRID_SIZE_Y 3 |
|||
|
|||
FfxFloat32x2 fViewportScale = FfxFloat32x2(1.0f / VIEWPORT_GRID_SIZE_X, 1.0f / VIEWPORT_GRID_SIZE_Y); |
|||
FfxInt32x2 iViewportSize = FfxInt32x2(DisplaySize() * fViewportScale); |
|||
|
|||
// compute grid [y][x] for easier placement of viewports |
|||
FfxFrameInterpolationDebugViewport vp[VIEWPORT_GRID_SIZE_Y][VIEWPORT_GRID_SIZE_X]; |
|||
for (FfxInt32 y = 0; y < VIEWPORT_GRID_SIZE_Y; y++) |
|||
{ |
|||
for (FfxInt32 x = 0; x < VIEWPORT_GRID_SIZE_X; x++) |
|||
{ |
|||
vp[y][x].offset = iViewportSize * FfxInt32x2(x, y); |
|||
vp[y][x].size = iViewportSize; |
|||
} |
|||
} |
|||
|
|||
// top row |
|||
DRAW_VIEWPORT(drawGameMotionVectorFieldVectors, iPxPos, vp[0][0]); |
|||
DRAW_VIEWPORT(drawGameMotionVectorFieldDepthPriority, iPxPos, vp[0][1]); |
|||
DRAW_VIEWPORT(drawOpticalFlowMotionVectorField, iPxPos, vp[0][2]); |
|||
|
|||
// bottom row |
|||
DRAW_VIEWPORT(drawDisocclusionMask, iPxPos, vp[2][0]); |
|||
DRAW_VIEWPORT(drawCurrentInterpolationSource, iPxPos, vp[2][1]); |
|||
DRAW_VIEWPORT(drawPresentBackbuffer, iPxPos, vp[2][2]); |
|||
} |
|||
|
|||
#endif // FFX_FRAMEINTERPOLATION_DEBUG_VIEW_H |
|||
@ -0,0 +1,60 @@ |
|||
fileFormatVersion: 2 |
|||
guid: b57f077e3c35e814fb8ad642a8f61ddd |
|||
PluginImporter: |
|||
externalObjects: {} |
|||
serializedVersion: 2 |
|||
iconMap: {} |
|||
executionOrder: {} |
|||
defineConstraints: [] |
|||
isPreloaded: 0 |
|||
isOverridable: 1 |
|||
isExplicitlyReferenced: 0 |
|||
validateReferences: 1 |
|||
platformData: |
|||
- first: |
|||
: Any |
|||
second: |
|||
enabled: 0 |
|||
settings: |
|||
Exclude Editor: 1 |
|||
Exclude GameCoreScarlett: 1 |
|||
Exclude GameCoreXboxOne: 1 |
|||
Exclude Linux64: 1 |
|||
Exclude OSXUniversal: 1 |
|||
Exclude PS4: 1 |
|||
Exclude PS5: 1 |
|||
Exclude WebGL: 1 |
|||
Exclude Win: 1 |
|||
Exclude Win64: 1 |
|||
- first: |
|||
Any: |
|||
second: |
|||
enabled: 0 |
|||
settings: {} |
|||
- first: |
|||
Editor: Editor |
|||
second: |
|||
enabled: 0 |
|||
settings: |
|||
DefaultValueInitialized: true |
|||
- first: |
|||
Standalone: Linux64 |
|||
second: |
|||
enabled: 0 |
|||
settings: |
|||
CPU: None |
|||
- first: |
|||
Standalone: Win |
|||
second: |
|||
enabled: 0 |
|||
settings: |
|||
CPU: None |
|||
- first: |
|||
Standalone: Win64 |
|||
second: |
|||
enabled: 0 |
|||
settings: |
|||
CPU: None |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|||
@ -0,0 +1,142 @@ |
|||
// 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. |
|||
|
|||
#ifndef FFX_FRAMEINTERPOLATION_DISOCCLUSION_MASK_H |
|||
#define FFX_FRAMEINTERPOLATION_DISOCCLUSION_MASK_H |
|||
|
|||
FFX_STATIC const FfxFloat32 DepthClipBaseScale = 1.0f; |
|||
|
|||
FfxFloat32 ComputeSampleDepthClip(FfxInt32x2 iPxSamplePos, FfxFloat32 fPreviousDepth, FfxFloat32 fPreviousDepthBilinearWeight, FfxFloat32 fCurrentDepthViewSpace) |
|||
{ |
|||
FfxFloat32 fPrevNearestDepthViewSpace = ConvertFromDeviceDepthToViewSpace(fPreviousDepth); |
|||
|
|||
// Depth separation logic ref: See "Minimum Triangle Separation for Correct Z-Buffer Occlusion" |
|||
// Intention: worst case of formula in Figure4 combined with Ksep factor in Section 4 |
|||
const FfxFloat32 fHalfViewportWidth = RenderSize().x * 0.5f; |
|||
FfxFloat32 fDepthThreshold = ffxMax(fCurrentDepthViewSpace, fPrevNearestDepthViewSpace); |
|||
|
|||
// WARNING: Ksep only works with reversed-z with infinite projection. |
|||
const FfxFloat32 Ksep = 1.37e-05f; |
|||
FfxFloat32 fRequiredDepthSeparation = Ksep * fDepthThreshold * TanHalfFoV() * fHalfViewportWidth; |
|||
FfxFloat32 fDepthDiff = fCurrentDepthViewSpace - fPrevNearestDepthViewSpace; |
|||
|
|||
FfxFloat32 fDepthClipFactor = (fDepthDiff > 0) ? ffxSaturate(fRequiredDepthSeparation / fDepthDiff) : 1.0f; |
|||
|
|||
return fPreviousDepthBilinearWeight * fDepthClipFactor * ffxLerp(1.0f, DepthClipBaseScale, ffxSaturate(fDepthDiff * fDepthDiff)); |
|||
} |
|||
|
|||
FfxFloat32 LoadEstimatedDepth(FfxUInt32 estimatedIndex, FfxInt32x2 iSamplePos) |
|||
{ |
|||
if (estimatedIndex == 0) |
|||
{ |
|||
return LoadReconstructedDepthPreviousFrame(iSamplePos); |
|||
} |
|||
else if (estimatedIndex == 1) |
|||
{ |
|||
return LoadDilatedDepth(iSamplePos); |
|||
} |
|||
|
|||
return 0; |
|||
} |
|||
|
|||
FfxFloat32 ComputeDepthClip(FfxUInt32 estimatedIndex, FfxFloat32x2 fUvSample, FfxFloat32 fCurrentDepthSample) |
|||
{ |
|||
FfxFloat32 fCurrentDepthViewSpace = ConvertFromDeviceDepthToViewSpace(fCurrentDepthSample); |
|||
BilinearSamplingData bilinearInfo = GetBilinearSamplingData(fUvSample, RenderSize()); |
|||
|
|||
FfxFloat32 fDilatedSum = 0.0f; |
|||
FfxFloat32 fDepth = 0.0f; |
|||
FfxFloat32 fWeightSum = 0.0f; |
|||
for (FfxInt32 iSampleIndex = 0; iSampleIndex < 4; iSampleIndex++) { |
|||
|
|||
const FfxInt32x2 iOffset = bilinearInfo.iOffsets[iSampleIndex]; |
|||
const FfxInt32x2 iSamplePos = bilinearInfo.iBasePos + iOffset; |
|||
|
|||
if (IsOnScreen(iSamplePos, RenderSize())) { |
|||
const FfxFloat32 fWeight = bilinearInfo.fWeights[iSampleIndex]; |
|||
if (fWeight > fReconstructedDepthBilinearWeightThreshold) { |
|||
|
|||
const FfxFloat32 fPrevDepthSample = LoadEstimatedDepth(estimatedIndex, iSamplePos); |
|||
const FfxFloat32 fPrevNearestDepthViewSpace = ConvertFromDeviceDepthToViewSpace(fPrevDepthSample); |
|||
|
|||
const FfxFloat32 fDepthDiff = fCurrentDepthViewSpace - fPrevNearestDepthViewSpace; |
|||
|
|||
if (fDepthDiff > 0.0f) { |
|||
|
|||
#if FFX_FRAMEINTERPOLATION_OPTION_INVERTED_DEPTH |
|||
const FfxFloat32 fPlaneDepth = ffxMin(fPrevDepthSample, fCurrentDepthSample); |
|||
#else |
|||
const FfxFloat32 fPlaneDepth = ffxMax(fPrevDepthSample, fCurrentDepthSample); |
|||
#endif |
|||
|
|||
const FfxFloat32x3 fCenter = GetViewSpacePosition(FfxInt32x2(RenderSize() * 0.5f), RenderSize(), fPlaneDepth); |
|||
const FfxFloat32x3 fCorner = GetViewSpacePosition(FfxInt32x2(0, 0), RenderSize(), fPlaneDepth); |
|||
|
|||
const FfxFloat32 fHalfViewportWidth = length(FfxFloat32x2(RenderSize())); |
|||
const FfxFloat32 fDepthThreshold = ffxMin(fCurrentDepthViewSpace, fPrevNearestDepthViewSpace); |
|||
|
|||
const FfxFloat32 Ksep = 1.37e-05f; |
|||
const FfxFloat32 Kfov = length(fCorner) / length(fCenter); |
|||
const FfxFloat32 fRequiredDepthSeparation = Ksep * Kfov * fHalfViewportWidth * fDepthThreshold; |
|||
|
|||
const FfxFloat32 fResolutionFactor = ffxSaturate(length(FfxFloat32x2(RenderSize())) / length(FfxFloat32x2(1920.0f, 1080.0f))); |
|||
const FfxFloat32 fPower = ffxLerp(1.0f, 3.0f, fResolutionFactor); |
|||
|
|||
fDepth += FfxFloat32((fRequiredDepthSeparation / fDepthDiff) >= 1.0f) * fWeight; |
|||
fWeightSum += fWeight; |
|||
} |
|||
} |
|||
} |
|||
} |
|||
|
|||
return (fWeightSum > 0.0f) ? ffxSaturate(1.0f - fDepth / fWeightSum) : 0.0f; |
|||
} |
|||
|
|||
void computeDisocclusionMask(FfxInt32x2 iPxPos) |
|||
{ |
|||
FfxFloat32 fDilatedDepth = LoadEstimatedInterpolationFrameDepth(iPxPos); |
|||
|
|||
FfxFloat32x2 fDepthUv = (iPxPos + 0.5f) / RenderSize(); |
|||
FfxFloat32 fCurrentDepthViewSpace = ConvertFromDeviceDepthToViewSpace(fDilatedDepth); |
|||
|
|||
VectorFieldEntry gameMv; |
|||
LoadInpaintedGameFieldMv(fDepthUv, gameMv); |
|||
|
|||
const FfxFloat32 fDepthClipInterpolatedToPrevious = 1.0f - ComputeDepthClip(0, fDepthUv + gameMv.fMotionVector, fDilatedDepth); |
|||
const FfxFloat32 fDepthClipInterpolatedToCurrent = 1.0f - ComputeDepthClip(1, fDepthUv - gameMv.fMotionVector, fDilatedDepth); |
|||
FfxFloat32x2 fDisocclusionMask = FfxFloat32x2(fDepthClipInterpolatedToPrevious, fDepthClipInterpolatedToCurrent); |
|||
|
|||
fDisocclusionMask = FfxFloat32x2(FFX_GREATER_THAN_EQUAL(fDisocclusionMask, ffxBroadcast2(FFX_FRAMEINTERPOLATION_EPSILON))); |
|||
|
|||
// Avoid false disocclusion if primary game vector pointer outside screen area |
|||
const FfxFloat32x2 fSrcMotionVector = gameMv.fMotionVector * 2.0f; |
|||
const FfxInt32x2 iSamplePosPrevious = FfxInt32x2((fDepthUv + fSrcMotionVector) * RenderSize()); |
|||
fDisocclusionMask.x = ffxSaturate(fDisocclusionMask.x + FfxFloat32(!IsOnScreen(iSamplePosPrevious, RenderSize()))); |
|||
|
|||
const FfxInt32x2 iSamplePosCurrent = FfxInt32x2((fDepthUv - fSrcMotionVector) * RenderSize()); |
|||
fDisocclusionMask.y = ffxSaturate(fDisocclusionMask.y + FfxFloat32(!IsOnScreen(iSamplePosCurrent, RenderSize()))); |
|||
|
|||
StoreDisocclusionMask(iPxPos, fDisocclusionMask); |
|||
|
|||
} |
|||
|
|||
#endif // FFX_FRAMEINTERPOLATION_DISOCCLUSION_MASK_H |
|||
@ -0,0 +1,60 @@ |
|||
fileFormatVersion: 2 |
|||
guid: dfee50799482d8d409645894f08f1a7e |
|||
PluginImporter: |
|||
externalObjects: {} |
|||
serializedVersion: 2 |
|||
iconMap: {} |
|||
executionOrder: {} |
|||
defineConstraints: [] |
|||
isPreloaded: 0 |
|||
isOverridable: 1 |
|||
isExplicitlyReferenced: 0 |
|||
validateReferences: 1 |
|||
platformData: |
|||
- first: |
|||
: Any |
|||
second: |
|||
enabled: 0 |
|||
settings: |
|||
Exclude Editor: 1 |
|||
Exclude GameCoreScarlett: 1 |
|||
Exclude GameCoreXboxOne: 1 |
|||
Exclude Linux64: 1 |
|||
Exclude OSXUniversal: 1 |
|||
Exclude PS4: 1 |
|||
Exclude PS5: 1 |
|||
Exclude WebGL: 1 |
|||
Exclude Win: 1 |
|||
Exclude Win64: 1 |
|||
- first: |
|||
Any: |
|||
second: |
|||
enabled: 0 |
|||
settings: {} |
|||
- first: |
|||
Editor: Editor |
|||
second: |
|||
enabled: 0 |
|||
settings: |
|||
DefaultValueInitialized: true |
|||
- first: |
|||
Standalone: Linux64 |
|||
second: |
|||
enabled: 0 |
|||
settings: |
|||
CPU: None |
|||
- first: |
|||
Standalone: Win |
|||
second: |
|||
enabled: 0 |
|||
settings: |
|||
CPU: None |
|||
- first: |
|||
Standalone: Win64 |
|||
second: |
|||
enabled: 0 |
|||
settings: |
|||
CPU: None |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|||
@ -0,0 +1,118 @@ |
|||
// 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. |
|||
|
|||
#ifndef FFX_FRAMEINTERPOLATION_GAME_MOTION_VECTOR_FIELD_H |
|||
#define FFX_FRAMEINTERPOLATION_GAME_MOTION_VECTOR_FIELD_H |
|||
|
|||
FfxUInt32 getPriorityFactorFromViewSpaceDepth(FfxFloat32 fViewSpaceDepthInMeters) |
|||
{ |
|||
fViewSpaceDepthInMeters = ffxPow(fViewSpaceDepthInMeters, 0.33f); |
|||
|
|||
FfxUInt32 uPriorityFactor = FfxUInt32(FfxFloat32(1 - (fViewSpaceDepthInMeters * (1.0f / (1.0f + fViewSpaceDepthInMeters)))) * PRIORITY_HIGH_MAX); |
|||
|
|||
return ffxMax(1, uPriorityFactor); |
|||
} |
|||
|
|||
void computeGameFieldMvs(FfxInt32x2 iPxPos) |
|||
{ |
|||
const FfxFloat32x2 fUvInScreenSpace = (FfxFloat32x2(iPxPos) + 0.5f) / RenderSize(); |
|||
const FfxFloat32x2 fUvInInterpolationRectStart = FfxFloat32x2(InterpolationRectBase()) / DisplaySize(); |
|||
const FfxFloat32x2 fUvLetterBoxScale = FfxFloat32x2(InterpolationRectSize()) / DisplaySize(); |
|||
const FfxFloat32x2 fUvInInterpolationRect = fUvInInterpolationRectStart + fUvInScreenSpace * fUvLetterBoxScale; |
|||
|
|||
const FfxFloat32 fDepthSample = LoadDilatedDepth(iPxPos); |
|||
const FfxFloat32x2 fGameMotionVector = LoadDilatedMotionVector(iPxPos); |
|||
const FfxFloat32x2 fMotionVectorHalf = fGameMotionVector * 0.5f; |
|||
const FfxFloat32x2 fInterpolatedLocationUv = fUvInScreenSpace + fMotionVectorHalf; |
|||
|
|||
const FfxFloat32 fViewSpaceDepth = ConvertFromDeviceDepthToViewSpace(fDepthSample); |
|||
const FfxUInt32 uHighPriorityFactorPrimary = getPriorityFactorFromViewSpaceDepth(fViewSpaceDepth); |
|||
|
|||
FfxFloat32x3 prevBackbufferCol = SamplePreviousBackbuffer(fUvInInterpolationRect).xyz; |
|||
FfxFloat32x3 curBackbufferCol = SamplePreviousBackbuffer(fUvInInterpolationRect + fGameMotionVector * fUvLetterBoxScale).xyz; |
|||
FfxFloat32 prevLuma = 0.001f + RawRGBToLuminance(prevBackbufferCol); |
|||
FfxFloat32 currLuma = 0.001f + RawRGBToLuminance(curBackbufferCol); |
|||
|
|||
FfxUInt32 uLowPriorityFactor = FfxUInt32(ffxRound(ffxPow(MinDividedByMax(prevLuma, currLuma), 1.0f / 1.0f) * PRIORITY_LOW_MAX)) |
|||
* FfxUInt32(IsUvInside(fUvInInterpolationRect + fGameMotionVector * fUvLetterBoxScale)); |
|||
|
|||
// Update primary motion vectors |
|||
{ |
|||
const FfxUInt32x2 packedVectorPrimary = PackVectorFieldEntries(true, uHighPriorityFactorPrimary, uLowPriorityFactor, fMotionVectorHalf); |
|||
|
|||
BilinearSamplingData bilinearInfo = GetBilinearSamplingData(fInterpolatedLocationUv, RenderSize()); |
|||
for (FfxInt32 iSampleIndex = 0; iSampleIndex < 4; iSampleIndex++) |
|||
{ |
|||
const FfxInt32x2 iOffset = bilinearInfo.iOffsets[iSampleIndex]; |
|||
const FfxInt32x2 iSamplePos = bilinearInfo.iBasePos + iOffset; |
|||
|
|||
if (IsOnScreen(iSamplePos, RenderSize())) |
|||
{ |
|||
UpdateGameMotionVectorField(iSamplePos, packedVectorPrimary); |
|||
} |
|||
} |
|||
} |
|||
|
|||
// Update secondary vectors |
|||
// Main purpose of secondary vectors is to improve quality of inpainted vectors |
|||
const FfxBoolean bWriteSecondaryVectors = length(fMotionVectorHalf * RenderSize()) > FFX_FRAMEINTERPOLATION_EPSILON; |
|||
if (bWriteSecondaryVectors) |
|||
{ |
|||
FfxBoolean bWriteSecondary = true; |
|||
FfxUInt32 uNumPrimaryHits = 0; |
|||
const FfxFloat32 fSecondaryStepScale = length(1.0f / RenderSize()); |
|||
const FfxFloat32x2 fStepMv = normalize(fGameMotionVector); |
|||
const FfxFloat32 fBreakDist = ffxMin(length(fMotionVectorHalf), length(FfxFloat32x2(0.5f, 0.5f))); |
|||
|
|||
for (FfxFloat32 fMvScale = fSecondaryStepScale; fMvScale <= fBreakDist && bWriteSecondary; fMvScale += fSecondaryStepScale) |
|||
{ |
|||
const FfxFloat32x2 fSecondaryLocationUv = fInterpolatedLocationUv - fStepMv * fMvScale; |
|||
BilinearSamplingData bilinearInfo = GetBilinearSamplingData(fSecondaryLocationUv, RenderSize()); |
|||
|
|||
// Reverse depth prio for secondary vectors |
|||
FfxUInt32 uHighPriorityFactorSecondary = ffxMax(1, PRIORITY_HIGH_MAX - uHighPriorityFactorPrimary); |
|||
|
|||
const FfxFloat32x2 fToCenter = normalize(FfxFloat32x2(0.5f, 0.5f) - fSecondaryLocationUv); |
|||
uLowPriorityFactor = FfxUInt32(ffxMax(0.0f, dot(fToCenter, fStepMv)) * PRIORITY_LOW_MAX); |
|||
const FfxUInt32x2 packedVectorSecondary = PackVectorFieldEntries(false, uHighPriorityFactorSecondary, uLowPriorityFactor, fMotionVectorHalf); |
|||
|
|||
// Only write secondary mvs to single bilinear location |
|||
for (FfxInt32 iSampleIndex = 0; iSampleIndex < 1; iSampleIndex++) |
|||
{ |
|||
const FfxInt32x2 iOffset = bilinearInfo.iOffsets[iSampleIndex]; |
|||
const FfxInt32x2 iSamplePos = bilinearInfo.iBasePos + iOffset; |
|||
|
|||
bWriteSecondary = bWriteSecondary && IsOnScreen(iSamplePos, RenderSize()); |
|||
|
|||
if (bWriteSecondary) |
|||
{ |
|||
const FfxUInt32 uExistingVectorFieldEntry = UpdateGameMotionVectorFieldEx(iSamplePos, packedVectorSecondary); |
|||
|
|||
uNumPrimaryHits += FfxUInt32(PackedVectorFieldEntryIsPrimary(uExistingVectorFieldEntry)); |
|||
bWriteSecondary = bWriteSecondary && (uNumPrimaryHits <= 3); |
|||
} |
|||
} |
|||
} |
|||
} |
|||
} |
|||
|
|||
#endif // FFX_FRAMEINTERPOLATION_GAME_MOTION_VECTOR_FIELD_H |
|||
@ -0,0 +1,60 @@ |
|||
fileFormatVersion: 2 |
|||
guid: f45abe4270f0ed646a68e0cfae830b3d |
|||
PluginImporter: |
|||
externalObjects: {} |
|||
serializedVersion: 2 |
|||
iconMap: {} |
|||
executionOrder: {} |
|||
defineConstraints: [] |
|||
isPreloaded: 0 |
|||
isOverridable: 1 |
|||
isExplicitlyReferenced: 0 |
|||
validateReferences: 1 |
|||
platformData: |
|||
- first: |
|||
: Any |
|||
second: |
|||
enabled: 0 |
|||
settings: |
|||
Exclude Editor: 1 |
|||
Exclude GameCoreScarlett: 1 |
|||
Exclude GameCoreXboxOne: 1 |
|||
Exclude Linux64: 1 |
|||
Exclude OSXUniversal: 1 |
|||
Exclude PS4: 1 |
|||
Exclude PS5: 1 |
|||
Exclude WebGL: 1 |
|||
Exclude Win: 1 |
|||
Exclude Win64: 1 |
|||
- first: |
|||
Any: |
|||
second: |
|||
enabled: 0 |
|||
settings: {} |
|||
- first: |
|||
Editor: Editor |
|||
second: |
|||
enabled: 0 |
|||
settings: |
|||
DefaultValueInitialized: true |
|||
- first: |
|||
Standalone: Linux64 |
|||
second: |
|||
enabled: 0 |
|||
settings: |
|||
CPU: None |
|||
- first: |
|||
Standalone: Win |
|||
second: |
|||
enabled: 0 |
|||
settings: |
|||
CPU: None |
|||
- first: |
|||
Standalone: Win64 |
|||
second: |
|||
enabled: 0 |
|||
settings: |
|||
CPU: None |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|||
@ -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. |
|||
|
|||
#ifndef FFX_FRAMEINTERPOLATION_INPAINTING_H |
|||
#define FFX_FRAMEINTERPOLATION_INPAINTING_H |
|||
|
|||
FfxFloat32x4 ComputeInpaintingLevel(FfxFloat32x2 fUv, const FfxInt32 iMipLevel, const FfxInt32x2 iTexSize) |
|||
{ |
|||
BilinearSamplingData bilinearInfo = GetBilinearSamplingData(fUv, iTexSize); |
|||
|
|||
FfxFloat32x4 fColor = FfxFloat32x4(0.0, 0.0, 0.0, 0.0); |
|||
|
|||
for (FfxInt32 iSampleIndex = 0; iSampleIndex < 4; iSampleIndex++) { |
|||
|
|||
const FfxInt32x2 iOffset = bilinearInfo.iOffsets[iSampleIndex]; |
|||
const FfxInt32x2 iSamplePos = bilinearInfo.iBasePos + iOffset; |
|||
|
|||
if (IsOnScreen(iSamplePos, iTexSize)) { |
|||
|
|||
FfxFloat32x4 fSample = LoadInpaintingPyramid(iMipLevel, iSamplePos); |
|||
|
|||
const FfxFloat32 fWeight = bilinearInfo.fWeights[iSampleIndex] * FfxFloat32(fSample.w > 0.0f); |
|||
|
|||
fColor += FfxFloat32x4(fSample.rgb * fWeight, fWeight); |
|||
} |
|||
} |
|||
|
|||
return fColor; |
|||
} |
|||
|
|||
FfxFloat32x3 ComputeInpainting(FfxInt32x2 iPxPos) |
|||
{ |
|||
FfxFloat32x2 fUv = (iPxPos + 0.5f) / (DisplaySize()); |
|||
|
|||
FfxFloat32x4 fColor = FfxFloat32x4(0.0, 0.0, 0.0, 0.0); |
|||
FfxFloat32 fWeightSum = 0.0f; |
|||
FfxInt32x2 iTexSize = DisplaySize(); |
|||
|
|||
for (FfxInt32 iMipLevel = 0; iMipLevel < 10; iMipLevel++) { |
|||
|
|||
iTexSize /= 2; |
|||
|
|||
FfxFloat32x4 fMipColor = ComputeInpaintingLevel(fUv, iMipLevel, iTexSize); |
|||
|
|||
if (fMipColor.w > 0.0f) { |
|||
const FfxFloat32x3 fNormalizedMipColor = fMipColor.rgb / fMipColor.w; |
|||
const FfxFloat32 fMipWeight = ffxPow(1.0f - iMipLevel / 10.0f, 3.0f) * fMipColor.w; |
|||
|
|||
fColor += FfxFloat32x4(fNormalizedMipColor, 1.0f) * fMipWeight; |
|||
} |
|||
} |
|||
|
|||
return fColor.rgb / fColor.w; |
|||
} |
|||
|
|||
void drawDebugTearLines(FfxInt32x2 iPxPos, inout FfxFloat32x3 fColor, inout FfxBoolean bWriteColor) |
|||
{ |
|||
if (iPxPos.x < 16) |
|||
{ |
|||
fColor.g = 1.f; |
|||
bWriteColor = true; |
|||
} |
|||
else if (iPxPos.x > DisplaySize().x - 16) |
|||
{ |
|||
fColor += GetDebugBarColor(); |
|||
bWriteColor = true; |
|||
} |
|||
|
|||
} |
|||
|
|||
void drawDebugResetIndicators(FfxInt32x2 iPxPos, inout FfxFloat32x3 fColor, inout FfxBoolean bWriteColor) |
|||
{ |
|||
if (iPxPos.y < 32 && Reset()) |
|||
{ |
|||
fColor.r = 1.f; |
|||
bWriteColor = true; |
|||
} |
|||
else if (iPxPos.y > 32 && iPxPos.y < 64 && HasSceneChanged()) |
|||
{ |
|||
fColor.b = 1.f; |
|||
bWriteColor = true; |
|||
} |
|||
} |
|||
|
|||
void computeInpainting(FfxInt32x2 iPxPos) |
|||
{ |
|||
FfxBoolean bWriteColor = false; |
|||
FfxFloat32x4 fInterpolatedColor = RWLoadFrameinterpolationOutput(iPxPos); |
|||
|
|||
const FfxFloat32 fInPaintingWeight = fInterpolatedColor.w; |
|||
if (fInPaintingWeight > FFX_FRAMEINTERPOLATION_EPSILON) |
|||
{ |
|||
fInterpolatedColor.rgb = ffxLerp(fInterpolatedColor.rgb, ComputeInpainting(iPxPos) * FfxFloat32(DisplaySize().x > 0), fInPaintingWeight); |
|||
bWriteColor = true; |
|||
} |
|||
|
|||
if (GetHUDLessAttachedFactor() == 1) |
|||
{ |
|||
const FfxFloat32x3 fCurrentInterpolationSource = LoadCurrentBackbuffer(iPxPos).rgb; |
|||
const FfxFloat32x3 fPresentColor = LoadPresentBackbuffer(iPxPos).rgb; |
|||
|
|||
if (any(FFX_GREATER_THAN(abs(fCurrentInterpolationSource - fPresentColor), FfxFloat32x3(0.0, 0.0, 0.0)))) |
|||
{ |
|||
const FfxFloat32 fStaticFactor = CalculateStaticContentFactor(RawRGBToLinear(fCurrentInterpolationSource), RawRGBToLinear(fPresentColor)); |
|||
|
|||
if (fStaticFactor > FFX_FRAMEINTERPOLATION_EPSILON) |
|||
{ |
|||
fInterpolatedColor.rgb = ffxLerp(fInterpolatedColor.rgb, fPresentColor, fStaticFactor); |
|||
bWriteColor = true; |
|||
} |
|||
} |
|||
} |
|||
|
|||
if ((GetDispatchFlags() & FFX_FRAMEINTERPOLATION_DISPATCH_DRAW_DEBUG_TEAR_LINES) != 0) |
|||
{ |
|||
drawDebugTearLines(iPxPos, fInterpolatedColor.rgb, bWriteColor); |
|||
} |
|||
|
|||
if ((GetDispatchFlags() & FFX_FRAMEINTERPOLATION_DISPATCH_DRAW_DEBUG_RESET_INDICATORS) != 0) |
|||
{ |
|||
drawDebugResetIndicators(iPxPos, fInterpolatedColor.rgb, bWriteColor); |
|||
} |
|||
|
|||
if (bWriteColor) |
|||
{ |
|||
StoreFrameinterpolationOutput(iPxPos, FfxFloat32x4(fInterpolatedColor.rgb, 1.0f)); |
|||
} |
|||
|
|||
} |
|||
|
|||
#endif // FFX_FRAMEINTERPOLATION_INPAINTING_H |
|||
@ -0,0 +1,60 @@ |
|||
fileFormatVersion: 2 |
|||
guid: 17b45333e20e75042b320d5631323144 |
|||
PluginImporter: |
|||
externalObjects: {} |
|||
serializedVersion: 2 |
|||
iconMap: {} |
|||
executionOrder: {} |
|||
defineConstraints: [] |
|||
isPreloaded: 0 |
|||
isOverridable: 1 |
|||
isExplicitlyReferenced: 0 |
|||
validateReferences: 1 |
|||
platformData: |
|||
- first: |
|||
: Any |
|||
second: |
|||
enabled: 0 |
|||
settings: |
|||
Exclude Editor: 1 |
|||
Exclude GameCoreScarlett: 1 |
|||
Exclude GameCoreXboxOne: 1 |
|||
Exclude Linux64: 1 |
|||
Exclude OSXUniversal: 1 |
|||
Exclude PS4: 1 |
|||
Exclude PS5: 1 |
|||
Exclude WebGL: 1 |
|||
Exclude Win: 1 |
|||
Exclude Win64: 1 |
|||
- first: |
|||
Any: |
|||
second: |
|||
enabled: 0 |
|||
settings: {} |
|||
- first: |
|||
Editor: Editor |
|||
second: |
|||
enabled: 0 |
|||
settings: |
|||
DefaultValueInitialized: true |
|||
- first: |
|||
Standalone: Linux64 |
|||
second: |
|||
enabled: 0 |
|||
settings: |
|||
CPU: None |
|||
- first: |
|||
Standalone: Win |
|||
second: |
|||
enabled: 0 |
|||
settings: |
|||
CPU: None |
|||
- first: |
|||
Standalone: Win64 |
|||
second: |
|||
enabled: 0 |
|||
settings: |
|||
CPU: None |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|||
@ -0,0 +1,124 @@ |
|||
// 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. |
|||
|
|||
#ifndef FFX_FRAMEINTERPOLATION_OPTICAL_FLOW_VECTOR_FIELD_H |
|||
#define FFX_FRAMEINTERPOLATION_OPTICAL_FLOW_VECTOR_FIELD_H |
|||
|
|||
void computeOpticalFlowFieldMvs(FfxUInt32x2 dtID, FfxFloat32x2 fOpticalFlowVector) |
|||
{ |
|||
FfxFloat32x2 fUv = FfxFloat32x2(FfxFloat32x2(dtID)+0.5f) / GetOpticalFlowSize2(); |
|||
|
|||
const FfxFloat32 scaleFactor = 1.0f; |
|||
FfxFloat32x2 fMotionVectorHalf = fOpticalFlowVector * 0.5f; |
|||
|
|||
FfxFloat32 fDilatedDepth = ConvertFromDeviceDepthToViewSpace(LoadDilatedDepth(FfxInt32x2(dtID))); |
|||
|
|||
FfxFloat32x3 prevBackbufferCol = SamplePreviousBackbuffer(fUv).xyz; |
|||
FfxFloat32x3 curBackbufferCol = SampleCurrentBackbuffer(fUv + fOpticalFlowVector).xyz; |
|||
|
|||
FfxFloat32 prevLuma = 0.001f + RawRGBToLuminance(prevBackbufferCol); |
|||
FfxFloat32 currLuma = 0.001f + RawRGBToLuminance(curBackbufferCol); |
|||
|
|||
FfxFloat32 fVelocity = length(fOpticalFlowVector * InterpolationRectSize()); |
|||
FfxUInt32 uHighPriorityFactor = FfxUInt32(fVelocity > 1.0f) * FfxUInt32(ffxSaturate(fVelocity / length(InterpolationRectSize() * 0.05f)) * PRIORITY_HIGH_MAX); |
|||
|
|||
if(uHighPriorityFactor > 0) { |
|||
FfxUInt32 uLowPriorityFactor = FfxUInt32(ffxRound(ffxPow(MinDividedByMax(prevLuma, currLuma), 1.0f / 1.0f) * PRIORITY_LOW_MAX)) |
|||
* FfxUInt32(IsUvInside(fUv + fOpticalFlowVector)); |
|||
|
|||
// Project current depth into previous frame locations. |
|||
// Push to all pixels having some contribution if reprojection is using bilinear logic. |
|||
|
|||
const FfxUInt32x2 packedVectorPrimary = PackVectorFieldEntries(true, uHighPriorityFactor, uLowPriorityFactor, fMotionVectorHalf); |
|||
|
|||
BilinearSamplingData bilinearInfo = GetBilinearSamplingData(fUv + fMotionVectorHalf, GetOpticalFlowSize2()); |
|||
for (FfxInt32 iSampleIndex = 0; iSampleIndex < 4; iSampleIndex++) |
|||
{ |
|||
const FfxInt32x2 iOffset = bilinearInfo.iOffsets[iSampleIndex]; |
|||
const FfxInt32x2 iSamplePos = bilinearInfo.iBasePos + iOffset; |
|||
|
|||
if (IsOnScreen(iSamplePos, GetOpticalFlowSize2())) |
|||
{ |
|||
UpdateOpticalflowMotionVectorField(iSamplePos, packedVectorPrimary); |
|||
} |
|||
} |
|||
} |
|||
} |
|||
|
|||
void computeOpticalFlowVectorField(FfxInt32x2 iPxPos) |
|||
{ |
|||
FfxFloat32x2 fOpticalFlowVector = FfxFloat32x2(0.0, 0.0); |
|||
FfxFloat32x2 fOpticalFlowVector3x3Avg = FfxFloat32x2(0.0, 0.0); |
|||
FfxInt32 size = 1; |
|||
FfxFloat32 sw = 0.0f; |
|||
|
|||
for(FfxInt32 y = -size; y <= size; y++) { |
|||
for(FfxInt32 x = -size; x <= size; x++) { |
|||
|
|||
FfxInt32x2 samplePos = iPxPos + FfxInt32x2(x, y); |
|||
|
|||
FfxFloat32x2 vs = LoadOpticalFlow(samplePos); |
|||
FfxFloat32 fConfidenceFactor = ffxMax(FFX_FRAMEINTERPOLATION_EPSILON, LoadOpticalFlowConfidence(samplePos)); |
|||
|
|||
|
|||
FfxFloat32 len = length(vs * InterpolationRectSize()); |
|||
FfxFloat32 len_factor = ffxMax(0.0f, 512.0f - len) * FfxFloat32(len > 1.0f); |
|||
FfxFloat32 w = len_factor; |
|||
|
|||
fOpticalFlowVector3x3Avg += vs * w; |
|||
|
|||
sw += w; |
|||
} |
|||
} |
|||
|
|||
fOpticalFlowVector3x3Avg /= sw; |
|||
|
|||
|
|||
sw = 0.0f; |
|||
for(FfxInt32 y = -size; y <= size; y++) { |
|||
for(FfxInt32 x = -size; x <= size; x++) { |
|||
|
|||
FfxInt32x2 samplePos = iPxPos + FfxInt32x2(x, y); |
|||
|
|||
FfxFloat32x2 vs = LoadOpticalFlow(samplePos); |
|||
|
|||
FfxFloat32 fConfidenceFactor = ffxMax(FFX_FRAMEINTERPOLATION_EPSILON, LoadOpticalFlowConfidence(samplePos)); |
|||
FfxFloat32 len = length(vs * InterpolationRectSize()); |
|||
FfxFloat32 len_factor = ffxMax(0.0f, 512.0f - len) * FfxFloat32(len > 1.0f); |
|||
|
|||
|
|||
FfxFloat32 w = ffxMax(0.0f, ffxPow(dot(fOpticalFlowVector3x3Avg, vs), 1.25f)) * len_factor; |
|||
|
|||
fOpticalFlowVector += vs * w; |
|||
sw += w; |
|||
} |
|||
} |
|||
|
|||
if (sw > FFX_FRAMEINTERPOLATION_EPSILON) |
|||
{ |
|||
fOpticalFlowVector /= sw; |
|||
} |
|||
|
|||
computeOpticalFlowFieldMvs(iPxPos, fOpticalFlowVector); |
|||
} |
|||
|
|||
#endif // FFX_FRAMEINTERPOLATION_OPTICAL_FLOW_VECTOR_FIELD_H |
|||
@ -0,0 +1,60 @@ |
|||
fileFormatVersion: 2 |
|||
guid: 15da5f8073799904887da30032ca05c5 |
|||
PluginImporter: |
|||
externalObjects: {} |
|||
serializedVersion: 2 |
|||
iconMap: {} |
|||
executionOrder: {} |
|||
defineConstraints: [] |
|||
isPreloaded: 0 |
|||
isOverridable: 1 |
|||
isExplicitlyReferenced: 0 |
|||
validateReferences: 1 |
|||
platformData: |
|||
- first: |
|||
: Any |
|||
second: |
|||
enabled: 0 |
|||
settings: |
|||
Exclude Editor: 1 |
|||
Exclude GameCoreScarlett: 1 |
|||
Exclude GameCoreXboxOne: 1 |
|||
Exclude Linux64: 1 |
|||
Exclude OSXUniversal: 1 |
|||
Exclude PS4: 1 |
|||
Exclude PS5: 1 |
|||
Exclude WebGL: 1 |
|||
Exclude Win: 1 |
|||
Exclude Win64: 1 |
|||
- first: |
|||
Any: |
|||
second: |
|||
enabled: 0 |
|||
settings: {} |
|||
- first: |
|||
Editor: Editor |
|||
second: |
|||
enabled: 0 |
|||
settings: |
|||
DefaultValueInitialized: true |
|||
- first: |
|||
Standalone: Linux64 |
|||
second: |
|||
enabled: 0 |
|||
settings: |
|||
CPU: None |
|||
- first: |
|||
Standalone: Win |
|||
second: |
|||
enabled: 0 |
|||
settings: |
|||
CPU: None |
|||
- first: |
|||
Standalone: Win64 |
|||
second: |
|||
enabled: 0 |
|||
settings: |
|||
CPU: None |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|||
@ -0,0 +1,123 @@ |
|||
// 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. |
|||
|
|||
#ifndef FFX_FRAMEINTERPOLATION_RECONSTRUCT_DILATED_VELOCITY_AND_PREVIOUS_DEPTH_H |
|||
#define FFX_FRAMEINTERPOLATION_RECONSTRUCT_DILATED_VELOCITY_AND_PREVIOUS_DEPTH_H |
|||
|
|||
void ReconstructPrevDepth(FfxInt32x2 iPxPos, FfxFloat32 fDepth, FfxFloat32x2 fMotionVector, FfxInt32x2 iPxDepthSize) |
|||
{ |
|||
fMotionVector *= FfxFloat32(length(fMotionVector * DisplaySize()) > 0.1f); |
|||
|
|||
FfxFloat32x2 fUv = (iPxPos + FfxFloat32(0.5)) / iPxDepthSize; |
|||
FfxFloat32x2 fReprojectedUv = fUv + fMotionVector; |
|||
|
|||
BilinearSamplingData bilinearInfo = GetBilinearSamplingData(fReprojectedUv, RenderSize()); |
|||
|
|||
// Project current depth into previous frame locations. |
|||
// Push to all pixels having some contribution if reprojection is using bilinear logic. |
|||
for (FfxInt32 iSampleIndex = 0; iSampleIndex < 4; iSampleIndex++) { |
|||
|
|||
const FfxInt32x2 iOffset = bilinearInfo.iOffsets[iSampleIndex]; |
|||
FfxFloat32 fWeight = bilinearInfo.fWeights[iSampleIndex]; |
|||
|
|||
if (fWeight > fReconstructedDepthBilinearWeightThreshold) { |
|||
|
|||
FfxInt32x2 iStorePos = bilinearInfo.iBasePos + iOffset; |
|||
if (IsOnScreen(iStorePos, iPxDepthSize)) { |
|||
UpdateReconstructedDepthPreviousFrame(iStorePos, fDepth); |
|||
} |
|||
} |
|||
} |
|||
} |
|||
|
|||
void FindNearestDepth(FFX_PARAMETER_IN FfxInt32x2 iPxPos, FFX_PARAMETER_IN FfxInt32x2 iPxSize, FFX_PARAMETER_OUT FfxFloat32 fNearestDepth, FFX_PARAMETER_OUT FfxInt32x2 fNearestDepthCoord) |
|||
{ |
|||
const FfxInt32 iSampleCount = 9; |
|||
const FfxInt32x2 iSampleOffsets[iSampleCount] = { |
|||
FfxInt32x2(+0, +0), |
|||
FfxInt32x2(+1, +0), |
|||
FfxInt32x2(+0, +1), |
|||
FfxInt32x2(+0, -1), |
|||
FfxInt32x2(-1, +0), |
|||
FfxInt32x2(-1, +1), |
|||
FfxInt32x2(+1, +1), |
|||
FfxInt32x2(-1, -1), |
|||
FfxInt32x2(+1, -1), |
|||
}; |
|||
|
|||
// pull out the depth loads to allow SC to batch them |
|||
FfxFloat32 depth[9]; |
|||
FfxInt32 iSampleIndex = 0; |
|||
FFX_UNROLL |
|||
for (iSampleIndex = 0; iSampleIndex < iSampleCount; ++iSampleIndex) { |
|||
|
|||
FfxInt32x2 iPos = iPxPos + iSampleOffsets[iSampleIndex]; |
|||
depth[iSampleIndex] = LoadInputDepth(iPos); |
|||
} |
|||
|
|||
// find closest depth |
|||
fNearestDepthCoord = iPxPos; |
|||
fNearestDepth = depth[0]; |
|||
FFX_UNROLL |
|||
for (iSampleIndex = 1; iSampleIndex < iSampleCount; ++iSampleIndex) { |
|||
|
|||
FfxInt32x2 iPos = iPxPos + iSampleOffsets[iSampleIndex]; |
|||
if (IsOnScreen(iPos, iPxSize)) { |
|||
|
|||
FfxFloat32 fNdDepth = depth[iSampleIndex]; |
|||
#if FFX_FRAMEINTERPOLATION_OPTION_INVERTED_DEPTH |
|||
if (fNdDepth > fNearestDepth) { |
|||
#else |
|||
if (fNdDepth < fNearestDepth) { |
|||
#endif |
|||
fNearestDepthCoord = iPos; |
|||
fNearestDepth = fNdDepth; |
|||
} |
|||
} |
|||
} |
|||
} |
|||
|
|||
void ReconstructAndDilate(FfxInt32x2 iPxLrPos) |
|||
{ |
|||
FfxFloat32 fDilatedDepth; |
|||
FfxInt32x2 iNearestDepthCoord; |
|||
|
|||
FindNearestDepth(iPxLrPos, RenderSize(), fDilatedDepth, iNearestDepthCoord); |
|||
|
|||
#if FFX_FRAMEINTERPOLATION_OPTION_LOW_RES_MOTION_VECTORS |
|||
FfxInt32x2 iSamplePos = iPxLrPos; |
|||
FfxInt32x2 iMotionVectorPos = iNearestDepthCoord; |
|||
#else |
|||
FfxInt32x2 iSamplePos = ComputeHrPosFromLrPos(iPxLrPos); |
|||
FfxInt32x2 iMotionVectorPos = ComputeHrPosFromLrPos(iNearestDepthCoord); |
|||
#endif |
|||
|
|||
FfxFloat32x2 fDilatedMotionVector = LoadInputMotionVector(iMotionVectorPos); |
|||
|
|||
StoreDilatedDepth(iPxLrPos, fDilatedDepth); |
|||
StoreDilatedMotionVectors(iPxLrPos, fDilatedMotionVector); |
|||
|
|||
ReconstructPrevDepth(iPxLrPos, fDilatedDepth, fDilatedMotionVector, RenderSize()); |
|||
} |
|||
|
|||
|
|||
#endif //!defined( FFX_FRAMEINTERPOLATION_RECONSTRUCT_DILATED_VELOCITY_AND_PREVIOUS_DEPTH_H ) |
|||
@ -0,0 +1,60 @@ |
|||
fileFormatVersion: 2 |
|||
guid: d1f7e253b96e263459e1fd69948501f2 |
|||
PluginImporter: |
|||
externalObjects: {} |
|||
serializedVersion: 2 |
|||
iconMap: {} |
|||
executionOrder: {} |
|||
defineConstraints: [] |
|||
isPreloaded: 0 |
|||
isOverridable: 1 |
|||
isExplicitlyReferenced: 0 |
|||
validateReferences: 1 |
|||
platformData: |
|||
- first: |
|||
: Any |
|||
second: |
|||
enabled: 0 |
|||
settings: |
|||
Exclude Editor: 1 |
|||
Exclude GameCoreScarlett: 1 |
|||
Exclude GameCoreXboxOne: 1 |
|||
Exclude Linux64: 1 |
|||
Exclude OSXUniversal: 1 |
|||
Exclude PS4: 1 |
|||
Exclude PS5: 1 |
|||
Exclude WebGL: 1 |
|||
Exclude Win: 1 |
|||
Exclude Win64: 1 |
|||
- first: |
|||
Any: |
|||
second: |
|||
enabled: 0 |
|||
settings: {} |
|||
- first: |
|||
Editor: Editor |
|||
second: |
|||
enabled: 0 |
|||
settings: |
|||
DefaultValueInitialized: true |
|||
- first: |
|||
Standalone: Linux64 |
|||
second: |
|||
enabled: 0 |
|||
settings: |
|||
CPU: None |
|||
- first: |
|||
Standalone: Win |
|||
second: |
|||
enabled: 0 |
|||
settings: |
|||
CPU: None |
|||
- first: |
|||
Standalone: Win64 |
|||
second: |
|||
enabled: 0 |
|||
settings: |
|||
CPU: None |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|||
@ -0,0 +1,59 @@ |
|||
// 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. |
|||
|
|||
#ifndef FFX_FRAMEINTERPOLATION_RECONSTRUCT_PREVIOUS_DEPTH_H |
|||
#define FFX_FRAMEINTERPOLATION_RECONSTRUCT_PREVIOUS_DEPTH_H |
|||
|
|||
void ReconstructPrevDepth(FfxInt32x2 iPxPos, FfxUInt32 depthTarget, FfxFloat32 fDepth, FfxFloat32x2 fMotionVector, FfxInt32x2 iPxDepthSize) |
|||
{ |
|||
const FfxFloat32x2 fUv = (iPxPos + FfxFloat32(0.5)) / iPxDepthSize; |
|||
|
|||
// Project current depth into previous frame locations. |
|||
// Push to all pixels having some contribution if reprojection is using bilinear logic. |
|||
BilinearSamplingData bilinearInfo = GetBilinearSamplingData(fUv + fMotionVector, RenderSize()); |
|||
for (FfxInt32 iSampleIndex = 0; iSampleIndex < 4; iSampleIndex++) |
|||
{ |
|||
const FfxInt32x2 iOffset = bilinearInfo.iOffsets[iSampleIndex]; |
|||
const FfxInt32x2 iSamplePos = bilinearInfo.iBasePos + iOffset; |
|||
const FfxFloat32 fSampleWeight = bilinearInfo.fWeights[iSampleIndex]; |
|||
|
|||
if (fSampleWeight > fReconstructedDepthBilinearWeightThreshold) |
|||
{ |
|||
if (IsOnScreen(iSamplePos, RenderSize())) |
|||
{ |
|||
if (depthTarget != 0) { |
|||
UpdateReconstructedDepthInterpolatedFrame(iSamplePos, fDepth); |
|||
} |
|||
} |
|||
} |
|||
} |
|||
} |
|||
|
|||
void reconstructPreviousDepth(FfxInt32x2 iPxPos) |
|||
{ |
|||
FfxFloat32x2 fMotionVector = LoadDilatedMotionVector(iPxPos); |
|||
FfxFloat32 fDilatedDepth = LoadDilatedDepth(iPxPos); |
|||
|
|||
ReconstructPrevDepth(iPxPos, 1, fDilatedDepth, fMotionVector * 0.5f, RenderSize()); |
|||
} |
|||
|
|||
#endif // FFX_FRAMEINTERPOLATION_RECONSTRUCT_PREVIOUS_DEPTH_H |
|||
@ -0,0 +1,60 @@ |
|||
fileFormatVersion: 2 |
|||
guid: eaacebc61381a1b4381556b2abf31aa3 |
|||
PluginImporter: |
|||
externalObjects: {} |
|||
serializedVersion: 2 |
|||
iconMap: {} |
|||
executionOrder: {} |
|||
defineConstraints: [] |
|||
isPreloaded: 0 |
|||
isOverridable: 1 |
|||
isExplicitlyReferenced: 0 |
|||
validateReferences: 1 |
|||
platformData: |
|||
- first: |
|||
: Any |
|||
second: |
|||
enabled: 0 |
|||
settings: |
|||
Exclude Editor: 1 |
|||
Exclude GameCoreScarlett: 1 |
|||
Exclude GameCoreXboxOne: 1 |
|||
Exclude Linux64: 1 |
|||
Exclude OSXUniversal: 1 |
|||
Exclude PS4: 1 |
|||
Exclude PS5: 1 |
|||
Exclude WebGL: 1 |
|||
Exclude Win: 1 |
|||
Exclude Win64: 1 |
|||
- first: |
|||
Any: |
|||
second: |
|||
enabled: 0 |
|||
settings: {} |
|||
- first: |
|||
Editor: Editor |
|||
second: |
|||
enabled: 0 |
|||
settings: |
|||
DefaultValueInitialized: true |
|||
- first: |
|||
Standalone: Linux64 |
|||
second: |
|||
enabled: 0 |
|||
settings: |
|||
CPU: None |
|||
- first: |
|||
Standalone: Win |
|||
second: |
|||
enabled: 0 |
|||
settings: |
|||
CPU: None |
|||
- first: |
|||
Standalone: Win64 |
|||
second: |
|||
enabled: 0 |
|||
settings: |
|||
CPU: None |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|||
@ -0,0 +1,99 @@ |
|||
// 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. |
|||
|
|||
#ifndef FFX_FRAMEINTERPOLATION_RESOURCES_H |
|||
#define FFX_FRAMEINTERPOLATION_RESOURCES_H |
|||
|
|||
#if defined(FFX_CPU) || defined(FFX_GPU) |
|||
#define FFX_FRAMEINTERPOLATION_RESOURCE_IDENTIFIER_NULL 0 |
|||
#define FFX_FRAMEINTERPOLATION_RESOURCE_IDENTIFIER_OUTPUT 1 |
|||
//#define FFX_FRAMEINTERPOLATION_RESOURCE_IDENTIFIER_BACKBUFFER 2 |
|||
#define FFX_FRAMEINTERPOLATION_RESOURCE_IDENTIFIER_PREVIOUS_INTERPOLATION_SOURCE 3 |
|||
#define FFX_FRAMEINTERPOLATION_RESOURCE_IDENTIFIER_CURRENT_INTERPOLATION_SOURCE 4 |
|||
|
|||
#define FFX_FRAMEINTERPOLATION_RESOURCE_IDENTIFIER_DEPTH 5 |
|||
#define FFX_FRAMEINTERPOLATION_RESOURCE_IDENTIFIER_MOTION_VECTORS 6 |
|||
|
|||
#define FFX_FRAMEINTERPOLATION_RESOURCE_IDENTIFIER_RESERVED_2 7 |
|||
#define FFX_FRAMEINTERPOLATION_RESOURCE_IDENTIFIER_RESERVED_3 8 |
|||
#define FFX_FRAMEINTERPOLATION_RESOURCE_IDENTIFIER_RESERVED_4 9 |
|||
|
|||
#define FFX_FRAMEINTERPOLATION_RESOURCE_IDENTIFIER_DILATED_DEPTH 10 |
|||
#define FFX_FRAMEINTERPOLATION_RESOURCE_IDENTIFIER_DILATED_MOTION_VECTORS 11 |
|||
#define FFX_FRAMEINTERPOLATION_RESOURCE_IDENTIFIER_RECONSTRUCTED_DEPTH_PREVIOUS_FRAME 12 |
|||
#define FFX_FRAMEINTERPOLATION_RESOURCE_IDENTIFIER_RECONSTRUCTED_DEPTH_INTERPOLATED_FRAME 13 |
|||
#define FFX_FRAMEINTERPOLATION_RESOURCE_IDENTIFIER_DISOCCLUSION_MASK 14 |
|||
|
|||
#define FFX_FRAMEINTERPOLATION_RESOURCE_IDENTIFIER_GAME_MOTION_VECTOR_FIELD_X 15 |
|||
#define FFX_FRAMEINTERPOLATION_RESOURCE_IDENTIFIER_GAME_MOTION_VECTOR_FIELD_Y 16 |
|||
|
|||
#define FFX_FRAMEINTERPOLATION_RESOURCE_IDENTIFIER_OPTICAL_FLOW_MOTION_VECTOR_FIELD_X 17 |
|||
#define FFX_FRAMEINTERPOLATION_RESOURCE_IDENTIFIER_OPTICAL_FLOW_MOTION_VECTOR_FIELD_Y 18 |
|||
|
|||
#define FFX_FRAMEINTERPOLATION_RESOURCE_IDENTIFIER_OPTICAL_FLOW_VECTOR 19 |
|||
#define FFX_FRAMEINTERPOLATION_RESOURCE_IDENTIFIER_RESERVED_5 20 |
|||
#define FFX_FRAMEINTERPOLATION_RESOURCE_IDENTIFIER_OPTICAL_FLOW_CONFIDENCE 21 |
|||
#define FFX_FRAMEINTERPOLATION_RESOURCE_IDENTIFIER_OPTICAL_FLOW_GLOBAL_MOTION 22 |
|||
#define FFX_FRAMEINTERPOLATION_RESOURCE_IDENTIFIER_OPTICAL_FLOW_SCENE_CHANGE_DETECTION 23 |
|||
|
|||
#define FFX_FRAMEINTERPOLATION_RESOURCE_IDENTIFIER_RESERVED_6 25 |
|||
#define FFX_FRAMEINTERPOLATION_RESOURCE_IDENTIFIER_RESERVED_7 26 |
|||
|
|||
#define FFX_FRAMEINTERPOLATION_RESOURCE_IDENTIFIER_DEBUG_OUTPUT_0 27 |
|||
#define FFX_FRAMEINTERPOLATION_RESOURCE_IDENTIFIER_DEBUG_OUTPUT_1 28 |
|||
#define FFX_FRAMEINTERPOLATION_RESOURCE_IDENTIFIER_DEBUG_OUTPUT 29 |
|||
|
|||
#define FFX_FRAMEINTERPOLATION_RESOURCE_IDENTIFIER_RESERVED_8 30 |
|||
#define FFX_FRAMEINTERPOLATION_RESOURCE_IDENTIFIER_PRESENT_BACKBUFFER 31 |
|||
|
|||
#define FFX_FRAMEINTERPOLATION_RESOURCE_IDENTIFIER_COUNTERS 32 |
|||
#define FFX_FRAMEINTERPOLATION_RESOURCE_IDENTIFIER_INPAINTING_PYRAMID 33 // same as FFX_FRAMEINTERPOLATION_RESOURCE_IDENTIFIER_INPAINTING_PYRAMID_MIPMAP_0 |
|||
#define FFX_FRAMEINTERPOLATION_RESOURCE_IDENTIFIER_INPAINTING_PYRAMID_MIPMAP_0 33 |
|||
#define FFX_FRAMEINTERPOLATION_RESOURCE_IDENTIFIER_INPAINTING_PYRAMID_MIPMAP_1 34 |
|||
#define FFX_FRAMEINTERPOLATION_RESOURCE_IDENTIFIER_INPAINTING_PYRAMID_MIPMAP_2 35 |
|||
#define FFX_FRAMEINTERPOLATION_RESOURCE_IDENTIFIER_INPAINTING_PYRAMID_MIPMAP_3 36 |
|||
#define FFX_FRAMEINTERPOLATION_RESOURCE_IDENTIFIER_INPAINTING_PYRAMID_MIPMAP_4 37 |
|||
#define FFX_FRAMEINTERPOLATION_RESOURCE_IDENTIFIER_INPAINTING_PYRAMID_MIPMAP_5 38 |
|||
#define FFX_FRAMEINTERPOLATION_RESOURCE_IDENTIFIER_INPAINTING_PYRAMID_MIPMAP_6 39 |
|||
#define FFX_FRAMEINTERPOLATION_RESOURCE_IDENTIFIER_INPAINTING_PYRAMID_MIPMAP_7 40 |
|||
#define FFX_FRAMEINTERPOLATION_RESOURCE_IDENTIFIER_INPAINTING_PYRAMID_MIPMAP_8 41 |
|||
#define FFX_FRAMEINTERPOLATION_RESOURCE_IDENTIFIER_INPAINTING_PYRAMID_MIPMAP_9 42 |
|||
#define FFX_FRAMEINTERPOLATION_RESOURCE_IDENTIFIER_INPAINTING_PYRAMID_MIPMAP_10 43 |
|||
#define FFX_FRAMEINTERPOLATION_RESOURCE_IDENTIFIER_INPAINTING_PYRAMID_MIPMAP_11 44 |
|||
#define FFX_FRAMEINTERPOLATION_RESOURCE_IDENTIFIER_INPAINTING_PYRAMID_MIPMAP_12 45 |
|||
|
|||
#define FFX_FRAMEINTERPOLATION_RESOURCE_IDENTIFIER_DILATED_DEPTH_0 46 // resources for ping ponging if async is enabled. |
|||
#define FFX_FRAMEINTERPOLATION_RESOURCE_IDENTIFIER_DILATED_DEPTH_1 47 // code relies on them being interleaved |
|||
#define FFX_FRAMEINTERPOLATION_RESOURCE_IDENTIFIER_DILATED_MOTION_VECTORS_0 48 |
|||
#define FFX_FRAMEINTERPOLATION_RESOURCE_IDENTIFIER_DILATED_MOTION_VECTORS_1 49 // code relies on them being interleaved |
|||
#define FFX_FRAMEINTERPOLATION_RESOURCE_IDENTIFIER_RECONSTRUCTED_DEPTH_PREVIOUS_FRAME_0 50 |
|||
#define FFX_FRAMEINTERPOLATION_RESOURCE_IDENTIFIER_RECONSTRUCTED_DEPTH_PREVIOUS_FRAME_1 51 // code relies on them being interleaved |
|||
|
|||
#define FFX_FRAMEINTERPOLATION_RESOURCE_IDENTIFIER_COUNT 52 |
|||
|
|||
#define FFX_FRAMEINTERPOLATION_CONSTANTBUFFER_IDENTIFIER 0 |
|||
#define FFX_FRAMEINTERPOLATION_INPAINTING_PYRAMID_CONSTANTBUFFER_IDENTIFIER 1 |
|||
#define FFX_FRAMEINTERPOLATION_CONSTANTBUFFER_COUNT 2 |
|||
|
|||
#endif // #if defined(FFX_CPU) || defined(FFX_GPU) |
|||
|
|||
#endif //!defined( FFX_FRAMEINTERPOLATION_RESOURCES_H ) |
|||
@ -0,0 +1,60 @@ |
|||
fileFormatVersion: 2 |
|||
guid: c372a686ee040fd4d94e4e778dcfa3f0 |
|||
PluginImporter: |
|||
externalObjects: {} |
|||
serializedVersion: 2 |
|||
iconMap: {} |
|||
executionOrder: {} |
|||
defineConstraints: [] |
|||
isPreloaded: 0 |
|||
isOverridable: 1 |
|||
isExplicitlyReferenced: 0 |
|||
validateReferences: 1 |
|||
platformData: |
|||
- first: |
|||
: Any |
|||
second: |
|||
enabled: 0 |
|||
settings: |
|||
Exclude Editor: 1 |
|||
Exclude GameCoreScarlett: 1 |
|||
Exclude GameCoreXboxOne: 1 |
|||
Exclude Linux64: 1 |
|||
Exclude OSXUniversal: 1 |
|||
Exclude PS4: 1 |
|||
Exclude PS5: 1 |
|||
Exclude WebGL: 1 |
|||
Exclude Win: 1 |
|||
Exclude Win64: 1 |
|||
- first: |
|||
Any: |
|||
second: |
|||
enabled: 0 |
|||
settings: {} |
|||
- first: |
|||
Editor: Editor |
|||
second: |
|||
enabled: 0 |
|||
settings: |
|||
DefaultValueInitialized: true |
|||
- first: |
|||
Standalone: Linux64 |
|||
second: |
|||
enabled: 0 |
|||
settings: |
|||
CPU: None |
|||
- first: |
|||
Standalone: Win |
|||
second: |
|||
enabled: 0 |
|||
settings: |
|||
CPU: None |
|||
- first: |
|||
Standalone: Win64 |
|||
second: |
|||
enabled: 0 |
|||
settings: |
|||
CPU: None |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|||
@ -0,0 +1,50 @@ |
|||
// 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. |
|||
|
|||
#ifndef FFX_FRAMEINTERPOLATION_SETUP_H |
|||
#define FFX_FRAMEINTERPOLATION_SETUP_H |
|||
|
|||
void setupFrameinterpolationResources(FfxInt32x2 iPxPos) |
|||
{ |
|||
// Update reset counters |
|||
StoreCounter(COUNTER_SPD, 0); |
|||
if (all(FFX_EQUAL(iPxPos, FfxInt32x2(0, 0)))) |
|||
{ |
|||
if(Reset() || HasSceneChanged()) { |
|||
StoreCounter(COUNTER_FRAME_INDEX_SINCE_LAST_RESET, 0); |
|||
} else { |
|||
FfxUInt32 counter = RWLoadCounter(COUNTER_FRAME_INDEX_SINCE_LAST_RESET); |
|||
StoreCounter(COUNTER_FRAME_INDEX_SINCE_LAST_RESET, counter + 1); |
|||
} |
|||
} |
|||
|
|||
// Reset resources |
|||
StoreGameMotionVectorFieldX(iPxPos, 0); |
|||
StoreGameMotionVectorFieldY(iPxPos, 0); |
|||
|
|||
StoreOpticalflowMotionVectorFieldX(iPxPos, 0); |
|||
StoreOpticalflowMotionVectorFieldY(iPxPos, 0); |
|||
|
|||
StoreDisocclusionMask(iPxPos, FfxFloat32x2(0.0, 0.0)); |
|||
} |
|||
|
|||
#endif // FFX_FRAMEINTERPOLATION_SETUP_H |
|||
@ -0,0 +1,60 @@ |
|||
fileFormatVersion: 2 |
|||
guid: b762adf78ca62cf438224ff32c1356e0 |
|||
PluginImporter: |
|||
externalObjects: {} |
|||
serializedVersion: 2 |
|||
iconMap: {} |
|||
executionOrder: {} |
|||
defineConstraints: [] |
|||
isPreloaded: 0 |
|||
isOverridable: 1 |
|||
isExplicitlyReferenced: 0 |
|||
validateReferences: 1 |
|||
platformData: |
|||
- first: |
|||
: Any |
|||
second: |
|||
enabled: 0 |
|||
settings: |
|||
Exclude Editor: 1 |
|||
Exclude GameCoreScarlett: 1 |
|||
Exclude GameCoreXboxOne: 1 |
|||
Exclude Linux64: 1 |
|||
Exclude OSXUniversal: 1 |
|||
Exclude PS4: 1 |
|||
Exclude PS5: 1 |
|||
Exclude WebGL: 1 |
|||
Exclude Win: 1 |
|||
Exclude Win64: 1 |
|||
- first: |
|||
Any: |
|||
second: |
|||
enabled: 0 |
|||
settings: {} |
|||
- first: |
|||
Editor: Editor |
|||
second: |
|||
enabled: 0 |
|||
settings: |
|||
DefaultValueInitialized: true |
|||
- first: |
|||
Standalone: Linux64 |
|||
second: |
|||
enabled: 0 |
|||
settings: |
|||
CPU: None |
|||
- first: |
|||
Standalone: Win |
|||
second: |
|||
enabled: 0 |
|||
settings: |
|||
CPU: None |
|||
- first: |
|||
Standalone: Win64 |
|||
second: |
|||
enabled: 0 |
|||
settings: |
|||
CPU: None |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|||
@ -0,0 +1,8 @@ |
|||
fileFormatVersion: 2 |
|||
guid: d97a9a04054e249448b39b8184db3e9e |
|||
folderAsset: yes |
|||
DefaultImporter: |
|||
externalObjects: {} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|||
@ -0,0 +1,24 @@ |
|||
// 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 "../fsr2/ffx_fsr2_callbacks_hlsl.h" |
|||
#include "ffx_fsr3_resources.h" |
|||
@ -0,0 +1,60 @@ |
|||
fileFormatVersion: 2 |
|||
guid: 8bfa8bccfff25794a9101dcbeebb43e2 |
|||
PluginImporter: |
|||
externalObjects: {} |
|||
serializedVersion: 2 |
|||
iconMap: {} |
|||
executionOrder: {} |
|||
defineConstraints: [] |
|||
isPreloaded: 0 |
|||
isOverridable: 1 |
|||
isExplicitlyReferenced: 0 |
|||
validateReferences: 1 |
|||
platformData: |
|||
- first: |
|||
: Any |
|||
second: |
|||
enabled: 0 |
|||
settings: |
|||
Exclude Editor: 1 |
|||
Exclude GameCoreScarlett: 1 |
|||
Exclude GameCoreXboxOne: 1 |
|||
Exclude Linux64: 1 |
|||
Exclude OSXUniversal: 1 |
|||
Exclude PS4: 1 |
|||
Exclude PS5: 1 |
|||
Exclude WebGL: 1 |
|||
Exclude Win: 1 |
|||
Exclude Win64: 1 |
|||
- first: |
|||
Any: |
|||
second: |
|||
enabled: 0 |
|||
settings: {} |
|||
- first: |
|||
Editor: Editor |
|||
second: |
|||
enabled: 0 |
|||
settings: |
|||
DefaultValueInitialized: true |
|||
- first: |
|||
Standalone: Linux64 |
|||
second: |
|||
enabled: 0 |
|||
settings: |
|||
CPU: None |
|||
- first: |
|||
Standalone: Win |
|||
second: |
|||
enabled: 0 |
|||
settings: |
|||
CPU: None |
|||
- first: |
|||
Standalone: Win64 |
|||
second: |
|||
enabled: 0 |
|||
settings: |
|||
CPU: None |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|||
@ -0,0 +1,25 @@ |
|||
// 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 "../fsr2/ffx_fsr2_common.h" |
|||
#include "../frameinterpolation/ffx_frameinterpolation_common.h" |
|||
#include "../opticalflow/ffx_opticalflow_common.h" |
|||
@ -0,0 +1,60 @@ |
|||
fileFormatVersion: 2 |
|||
guid: f2c220b7bde9eac4594a94240ba6b075 |
|||
PluginImporter: |
|||
externalObjects: {} |
|||
serializedVersion: 2 |
|||
iconMap: {} |
|||
executionOrder: {} |
|||
defineConstraints: [] |
|||
isPreloaded: 0 |
|||
isOverridable: 1 |
|||
isExplicitlyReferenced: 0 |
|||
validateReferences: 1 |
|||
platformData: |
|||
- first: |
|||
: Any |
|||
second: |
|||
enabled: 0 |
|||
settings: |
|||
Exclude Editor: 1 |
|||
Exclude GameCoreScarlett: 1 |
|||
Exclude GameCoreXboxOne: 1 |
|||
Exclude Linux64: 1 |
|||
Exclude OSXUniversal: 1 |
|||
Exclude PS4: 1 |
|||
Exclude PS5: 1 |
|||
Exclude WebGL: 1 |
|||
Exclude Win: 1 |
|||
Exclude Win64: 1 |
|||
- first: |
|||
Any: |
|||
second: |
|||
enabled: 0 |
|||
settings: {} |
|||
- first: |
|||
Editor: Editor |
|||
second: |
|||
enabled: 0 |
|||
settings: |
|||
DefaultValueInitialized: true |
|||
- first: |
|||
Standalone: Linux64 |
|||
second: |
|||
enabled: 0 |
|||
settings: |
|||
CPU: None |
|||
- first: |
|||
Standalone: Win |
|||
second: |
|||
enabled: 0 |
|||
settings: |
|||
CPU: None |
|||
- first: |
|||
Standalone: Win64 |
|||
second: |
|||
enabled: 0 |
|||
settings: |
|||
CPU: None |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|||
@ -0,0 +1,37 @@ |
|||
// 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. |
|||
|
|||
#ifndef FFX_FSR3_RESOURCES_H |
|||
#define FFX_FSR3_RESOURCES_H |
|||
|
|||
#include "../fsr2/ffx_fsr2_resources.h" |
|||
#include "../frameinterpolation/ffx_frameinterpolation_resources.h" |
|||
|
|||
#if defined(FFX_CPU) || defined(FFX_GPU) |
|||
|
|||
#define FFX_FSR3_RESOURCE_IDENTIFIER_OPTICAL_FLOW_VECTOR 0 |
|||
#define FFX_FSR3_RESOURCE_IDENTIFIER_OPTICAL_FLOW_SCD_OUTPUT 1 |
|||
|
|||
#define FFX_FSR3_RESOURCE_IDENTIFIER_COUNT 2 |
|||
#endif // #if defined(FFX_CPU) || defined(FFX_GPU) |
|||
|
|||
#endif //!defined( FFX_FSR2_RESOURCES_H ) |
|||
@ -0,0 +1,60 @@ |
|||
fileFormatVersion: 2 |
|||
guid: 58bbdf17b5a92a848a552e2be710e756 |
|||
PluginImporter: |
|||
externalObjects: {} |
|||
serializedVersion: 2 |
|||
iconMap: {} |
|||
executionOrder: {} |
|||
defineConstraints: [] |
|||
isPreloaded: 0 |
|||
isOverridable: 1 |
|||
isExplicitlyReferenced: 0 |
|||
validateReferences: 1 |
|||
platformData: |
|||
- first: |
|||
: Any |
|||
second: |
|||
enabled: 0 |
|||
settings: |
|||
Exclude Editor: 1 |
|||
Exclude GameCoreScarlett: 1 |
|||
Exclude GameCoreXboxOne: 1 |
|||
Exclude Linux64: 1 |
|||
Exclude OSXUniversal: 1 |
|||
Exclude PS4: 1 |
|||
Exclude PS5: 1 |
|||
Exclude WebGL: 1 |
|||
Exclude Win: 1 |
|||
Exclude Win64: 1 |
|||
- first: |
|||
Any: |
|||
second: |
|||
enabled: 0 |
|||
settings: {} |
|||
- first: |
|||
Editor: Editor |
|||
second: |
|||
enabled: 0 |
|||
settings: |
|||
DefaultValueInitialized: true |
|||
- first: |
|||
Standalone: Linux64 |
|||
second: |
|||
enabled: 0 |
|||
settings: |
|||
CPU: None |
|||
- first: |
|||
Standalone: Win |
|||
second: |
|||
enabled: 0 |
|||
settings: |
|||
CPU: None |
|||
- first: |
|||
Standalone: Win64 |
|||
second: |
|||
enabled: 0 |
|||
settings: |
|||
CPU: None |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|||
@ -0,0 +1,8 @@ |
|||
fileFormatVersion: 2 |
|||
guid: aaf36a03a1aeb0e41824564023b1bf38 |
|||
folderAsset: yes |
|||
DefaultImporter: |
|||
externalObjects: {} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|||
@ -0,0 +1,634 @@ |
|||
// 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. |
|||
|
|||
#ifndef FFX_OPTICALFLOW_CALLBACKS_HLSL_H |
|||
#define FFX_OPTICALFLOW_CALLBACKS_HLSL_H |
|||
|
|||
#if defined(FFX_GPU) |
|||
#ifdef __hlsl_dx_compiler |
|||
#pragma dxc diagnostic push |
|||
#pragma dxc diagnostic ignored "-Wambig-lit-shift" |
|||
#endif //__hlsl_dx_compiler |
|||
#include "ffx_core.h" |
|||
#ifdef __hlsl_dx_compiler |
|||
#pragma dxc diagnostic pop |
|||
#endif //__hlsl_dx_compiler |
|||
|
|||
#define FFX_OPTICALFLOW_USE_MSAD4_INSTRUCTION 1 |
|||
#define FFX_OPTICALFLOW_FIX_TOP_LEFT_BIAS 1 |
|||
#define FFX_OPTICALFLOW_USE_HEURISTICS 1 |
|||
#define FFX_OPTICALFLOW_BLOCK_SIZE 8 |
|||
#define FFX_LOCAL_SEARCH_FALLBACK 1 |
|||
|
|||
// perf optimization for h/w not supporting accelerated msad4() |
|||
#if !defined(FFX_PREFER_WAVE64) && defined(FFX_OPTICALFLOW_USE_MSAD4_INSTRUCTION) |
|||
#undef FFX_OPTICALFLOW_USE_MSAD4_INSTRUCTION |
|||
#endif |
|||
|
|||
#include "opticalflow/ffx_opticalflow_common.h" |
|||
|
|||
#ifndef FFX_PREFER_WAVE64 |
|||
#define FFX_PREFER_WAVE64 |
|||
#endif |
|||
|
|||
|
|||
#pragma warning(disable: 3205) // conversion from larger type to smaller |
|||
|
|||
#define DECLARE_SRV_REGISTER(regIndex) t##regIndex |
|||
#define DECLARE_UAV_REGISTER(regIndex) u##regIndex |
|||
#define DECLARE_CB_REGISTER(regIndex) b##regIndex |
|||
#define FFX_OPTICALFLOW_DECLARE_SRV(regIndex) register(DECLARE_SRV_REGISTER(regIndex)) |
|||
#define FFX_OPTICALFLOW_DECLARE_UAV(regIndex) register(DECLARE_UAV_REGISTER(regIndex)) |
|||
#define FFX_OPTICALFLOW_DECLARE_CB(regIndex) register(DECLARE_CB_REGISTER(regIndex)) |
|||
|
|||
#if defined(FFX_OPTICALFLOW_BIND_CB_COMMON) |
|||
cbuffer cbOF : FFX_OPTICALFLOW_DECLARE_CB(FFX_OPTICALFLOW_BIND_CB_COMMON) |
|||
{ |
|||
FfxInt32x2 iInputLumaResolution; |
|||
FfxUInt32 uOpticalFlowPyramidLevel; |
|||
FfxUInt32 uOpticalFlowPyramidLevelCount; |
|||
|
|||
FfxUInt32 iFrameIndex; |
|||
FfxUInt32 backbufferTransferFunction; |
|||
FfxFloat32x2 minMaxLuminance; |
|||
}; |
|||
#define FFX_OPTICALFLOW_CONSTANT_BUFFER_1_SIZE 8 |
|||
|
|||
#endif //FFX_OPTICALFLOW_BIND_CB_COMMON |
|||
|
|||
#if defined(FFX_OPTICALFLOW_BIND_CB_SPD) |
|||
cbuffer cbOF_SPD : FFX_OPTICALFLOW_DECLARE_CB(FFX_OPTICALFLOW_BIND_CB_SPD) { |
|||
|
|||
FfxUInt32 mips; |
|||
FfxUInt32 numWorkGroups; |
|||
FfxUInt32x2 workGroupOffset; |
|||
FfxUInt32 numWorkGroupOpticalFlowInputPyramid; |
|||
FfxUInt32 pad0_; |
|||
FfxUInt32 pad1_; |
|||
FfxUInt32 pad2_; |
|||
}; |
|||
|
|||
FfxUInt32 NumWorkGroups() |
|||
{ |
|||
return numWorkGroupOpticalFlowInputPyramid; |
|||
} |
|||
#endif //FFX_OPTICALFLOW_BIND_CB_SPD |
|||
|
|||
#define FFX_OPTICALFLOW_CONSTANT_BUFFER_2_SIZE 8 |
|||
|
|||
#define FFX_OPTICALFLOW_DESCRIPTOR_COUNT 32 |
|||
|
|||
#define FFX_OPTICALFLOW_ROOTSIG_STRINGIFY(p) FFX_OPTICALFLOW_ROOTSIG_STR(p) |
|||
#define FFX_OPTICALFLOW_ROOTSIG_STR(p) #p |
|||
#define FFX_OPTICALFLOW_ROOTSIG [RootSignature( "DescriptorTable(UAV(u0, numDescriptors = " FFX_OPTICALFLOW_ROOTSIG_STRINGIFY(FFX_OPTICALFLOW_DESCRIPTOR_COUNT) ")), " \ |
|||
"DescriptorTable(SRV(t0, numDescriptors = " FFX_OPTICALFLOW_ROOTSIG_STRINGIFY(FFX_OPTICALFLOW_DESCRIPTOR_COUNT) ")), " \ |
|||
"CBV(b0), " \ |
|||
"StaticSampler(s0, filter = FILTER_MIN_MAG_MIP_POINT, " \ |
|||
"addressU = TEXTURE_ADDRESS_CLAMP, " \ |
|||
"addressV = TEXTURE_ADDRESS_CLAMP, " \ |
|||
"addressW = TEXTURE_ADDRESS_CLAMP, " \ |
|||
"comparisonFunc = COMPARISON_NEVER, " \ |
|||
"borderColor = STATIC_BORDER_COLOR_TRANSPARENT_BLACK), " \ |
|||
"StaticSampler(s1, filter = FILTER_MIN_MAG_MIP_LINEAR, " \ |
|||
"addressU = TEXTURE_ADDRESS_CLAMP, " \ |
|||
"addressV = TEXTURE_ADDRESS_CLAMP, " \ |
|||
"addressW = TEXTURE_ADDRESS_CLAMP, " \ |
|||
"comparisonFunc = COMPARISON_NEVER, " \ |
|||
"borderColor = STATIC_BORDER_COLOR_TRANSPARENT_BLACK)" )] |
|||
|
|||
#define FFX_OPTICALFLOW_CB2_ROOTSIG [RootSignature( "DescriptorTable(UAV(u0, numDescriptors = " FFX_OPTICALFLOW_ROOTSIG_STRINGIFY(FFX_OPTICALFLOW_DESCRIPTOR_COUNT) ")), " \ |
|||
"DescriptorTable(SRV(t0, numDescriptors = " FFX_OPTICALFLOW_ROOTSIG_STRINGIFY(FFX_OPTICALFLOW_DESCRIPTOR_COUNT) ")), " \ |
|||
"CBV(b0), " \ |
|||
"StaticSampler(s0, filter = FILTER_MIN_MAG_MIP_POINT, " \ |
|||
"addressU = TEXTURE_ADDRESS_CLAMP, " \ |
|||
"addressV = TEXTURE_ADDRESS_CLAMP, " \ |
|||
"addressW = TEXTURE_ADDRESS_CLAMP, " \ |
|||
"comparisonFunc = COMPARISON_NEVER, " \ |
|||
"borderColor = STATIC_BORDER_COLOR_TRANSPARENT_BLACK), " \ |
|||
"StaticSampler(s1, filter = FILTER_MIN_MAG_MIP_LINEAR, " \ |
|||
"addressU = TEXTURE_ADDRESS_CLAMP, " \ |
|||
"addressV = TEXTURE_ADDRESS_CLAMP, " \ |
|||
"addressW = TEXTURE_ADDRESS_CLAMP, " \ |
|||
"comparisonFunc = COMPARISON_NEVER, " \ |
|||
"borderColor = STATIC_BORDER_COLOR_TRANSPARENT_BLACK)" )] |
|||
#if defined(FFX_OPTICALFLOW_EMBED_ROOTSIG) |
|||
#define FFX_OPTICALFLOW_EMBED_ROOTSIG_CONTENT FFX_OPTICALFLOW_ROOTSIG |
|||
#define FFX_OPTICALFLOW_EMBED_CB2_ROOTSIG_CONTENT FFX_OPTICALFLOW_CB2_ROOTSIG |
|||
#else |
|||
#define FFX_OPTICALFLOW_EMBED_ROOTSIG_CONTENT |
|||
#define FFX_OPTICALFLOW_EMBED_CB2_ROOTSIG_CONTENT |
|||
#endif // #if FFX_OPTICALFLOW_EMBED_ROOTSIG |
|||
|
|||
FfxInt32x2 DisplaySize() |
|||
{ |
|||
return iInputLumaResolution; |
|||
} |
|||
|
|||
FfxUInt32 FrameIndex() |
|||
{ |
|||
return iFrameIndex; |
|||
} |
|||
|
|||
FfxUInt32 BackbufferTransferFunction() |
|||
{ |
|||
return backbufferTransferFunction; |
|||
} |
|||
|
|||
FfxFloat32x2 MinMaxLuminance() |
|||
{ |
|||
return minMaxLuminance; |
|||
} |
|||
|
|||
FfxBoolean CrossedSceneChangeThreshold(FfxFloat32 sceneChangeValue) |
|||
{ |
|||
return sceneChangeValue > 0.45f; |
|||
} |
|||
|
|||
FfxUInt32 OpticalFlowPyramidLevel() |
|||
{ |
|||
return uOpticalFlowPyramidLevel; |
|||
} |
|||
|
|||
FfxUInt32 OpticalFlowPyramidLevelCount() |
|||
{ |
|||
return uOpticalFlowPyramidLevelCount; |
|||
} |
|||
|
|||
FfxInt32x2 OpticalFlowHistogramMaxVelocity() |
|||
{ |
|||
const FfxInt32 searchRadius = 8; |
|||
FfxInt32 scale = FfxInt32(1) << (OpticalFlowPyramidLevelCount() - 1 - OpticalFlowPyramidLevel()); |
|||
FfxInt32 maxVelocity = searchRadius * scale; |
|||
return FfxInt32x2(maxVelocity, maxVelocity); |
|||
} |
|||
|
|||
#if defined FFX_OPTICALFLOW_BIND_SRV_INPUT_COLOR |
|||
Texture2D<FfxFloat32x4> r_input_color : FFX_OPTICALFLOW_DECLARE_SRV(FFX_OPTICALFLOW_BIND_SRV_INPUT_COLOR); |
|||
#endif |
|||
#if defined FFX_OPTICALFLOW_BIND_SRV_INPUT_MOTION_VECTORS |
|||
Texture2D<FfxFloat32x2> r_input_motion_vectors : FFX_OPTICALFLOW_DECLARE_SRV(FFX_OPTICALFLOW_BIND_SRV_INPUT_MOTION_VECTORS); |
|||
#endif |
|||
#if defined FFX_OPTICALFLOW_BIND_SRV_OPTICAL_FLOW_INPUT |
|||
Texture2D<FfxUInt32> r_optical_flow_input : FFX_OPTICALFLOW_DECLARE_SRV(FFX_OPTICALFLOW_BIND_SRV_OPTICAL_FLOW_INPUT); |
|||
#endif |
|||
#if defined FFX_OPTICALFLOW_BIND_SRV_OPTICAL_FLOW_PREVIOUS_INPUT |
|||
Texture2D<FfxUInt32> r_optical_flow_previous_input : FFX_OPTICALFLOW_DECLARE_SRV(FFX_OPTICALFLOW_BIND_SRV_OPTICAL_FLOW_PREVIOUS_INPUT); |
|||
#endif |
|||
#if defined FFX_OPTICALFLOW_BIND_SRV_OPTICAL_FLOW |
|||
Texture2D<FfxInt32x2> r_optical_flow : FFX_OPTICALFLOW_DECLARE_SRV(FFX_OPTICALFLOW_BIND_SRV_OPTICAL_FLOW); |
|||
#endif |
|||
#if defined FFX_OPTICALFLOW_BIND_SRV_OPTICAL_FLOW_PREVIOUS |
|||
Texture2D<FfxInt32x2> r_optical_flow_previous : FFX_OPTICALFLOW_DECLARE_SRV(FFX_OPTICALFLOW_BIND_SRV_OPTICAL_FLOW_PREVIOUS); |
|||
#endif |
|||
#if defined FFX_OPTICALFLOW_BIND_SRV_OPTICAL_FLOW_ADDITIONAL_INFO |
|||
Texture2D<FfxUInt32x2> r_optical_flow_additional_info : FFX_OPTICALFLOW_DECLARE_SRV(FFX_OPTICALFLOW_BIND_SRV_OPTICAL_FLOW_ADDITIONAL_INFO); |
|||
#endif |
|||
#if defined FFX_OPTICALFLOW_BIND_SRV_OPTICAL_FLOW_ADDITIONAL_INFO_PREVIOUS |
|||
Texture2D<FfxUInt32x2> r_optical_flow_additional_info_previous : FFX_OPTICALFLOW_DECLARE_SRV(FFX_OPTICALFLOW_BIND_SRV_OPTICAL_FLOW_ADDITIONAL_INFO_PREVIOUS); |
|||
#endif |
|||
#if defined FFX_OPTICALFLOW_BIND_SRV_OPTICAL_FLOW_HISTOGRAM |
|||
Texture2D<FfxUInt32> r_optical_flow_histogram : FFX_OPTICALFLOW_DECLARE_SRV(FFX_OPTICALFLOW_BIND_SRV_OPTICAL_FLOW_HISTOGRAM); |
|||
#endif |
|||
#if defined FFX_OPTICALFLOW_BIND_SRV_OPTICAL_FLOW_GLOBAL_MOTION_SEARCH |
|||
Texture2D<FfxUInt32> r_optical_flow_global_motion_search : FFX_OPTICALFLOW_DECLARE_SRV(FFX_OPTICALFLOW_BIND_SRV_OPTICAL_FLOW_GLOBAL_MOTION_SEARCH); |
|||
#endif |
|||
|
|||
// UAV declarations |
|||
#if defined FFX_OPTICALFLOW_BIND_UAV_OPTICAL_FLOW_INPUT |
|||
RWTexture2D<FfxUInt32> rw_optical_flow_input : FFX_OPTICALFLOW_DECLARE_UAV(FFX_OPTICALFLOW_BIND_UAV_OPTICAL_FLOW_INPUT); |
|||
#endif |
|||
#if defined FFX_OPTICALFLOW_BIND_UAV_OPTICAL_FLOW_INPUT_LEVEL_1 |
|||
globallycoherent RWTexture2D<FfxUInt32> rw_optical_flow_input_level_1 : FFX_OPTICALFLOW_DECLARE_UAV(FFX_OPTICALFLOW_BIND_UAV_OPTICAL_FLOW_INPUT_LEVEL_1); |
|||
#endif |
|||
#if defined FFX_OPTICALFLOW_BIND_UAV_OPTICAL_FLOW_INPUT_LEVEL_2 |
|||
globallycoherent RWTexture2D<FfxUInt32> rw_optical_flow_input_level_2 : FFX_OPTICALFLOW_DECLARE_UAV(FFX_OPTICALFLOW_BIND_UAV_OPTICAL_FLOW_INPUT_LEVEL_2); |
|||
#endif |
|||
#if defined FFX_OPTICALFLOW_BIND_UAV_OPTICAL_FLOW_INPUT_LEVEL_3 |
|||
globallycoherent RWTexture2D<FfxUInt32> rw_optical_flow_input_level_3 : FFX_OPTICALFLOW_DECLARE_UAV(FFX_OPTICALFLOW_BIND_UAV_OPTICAL_FLOW_INPUT_LEVEL_3); |
|||
#endif |
|||
#if defined FFX_OPTICALFLOW_BIND_UAV_OPTICAL_FLOW_INPUT_LEVEL_4 |
|||
globallycoherent RWTexture2D<FfxUInt32> rw_optical_flow_input_level_4 : FFX_OPTICALFLOW_DECLARE_UAV(FFX_OPTICALFLOW_BIND_UAV_OPTICAL_FLOW_INPUT_LEVEL_4); |
|||
#endif |
|||
#if defined FFX_OPTICALFLOW_BIND_UAV_OPTICAL_FLOW_INPUT_LEVEL_5 |
|||
globallycoherent RWTexture2D<FfxUInt32> rw_optical_flow_input_level_5 : FFX_OPTICALFLOW_DECLARE_UAV(FFX_OPTICALFLOW_BIND_UAV_OPTICAL_FLOW_INPUT_LEVEL_5); |
|||
#endif |
|||
#if defined FFX_OPTICALFLOW_BIND_UAV_OPTICAL_FLOW_INPUT_LEVEL_6 |
|||
globallycoherent RWTexture2D<FfxUInt32> rw_optical_flow_input_level_6 : FFX_OPTICALFLOW_DECLARE_UAV(FFX_OPTICALFLOW_BIND_UAV_OPTICAL_FLOW_INPUT_LEVEL_6); |
|||
#endif |
|||
#if defined FFX_OPTICALFLOW_BIND_UAV_OPTICAL_FLOW |
|||
RWTexture2D<FfxInt32x2> rw_optical_flow : FFX_OPTICALFLOW_DECLARE_UAV(FFX_OPTICALFLOW_BIND_UAV_OPTICAL_FLOW); |
|||
#endif |
|||
#if defined FFX_OPTICALFLOW_BIND_UAV_OPTICAL_FLOW_NEXT_LEVEL |
|||
RWTexture2D<FfxInt32x2> rw_optical_flow_next_level : FFX_OPTICALFLOW_DECLARE_UAV(FFX_OPTICALFLOW_BIND_UAV_OPTICAL_FLOW_NEXT_LEVEL); |
|||
#endif |
|||
#if defined FFX_OPTICALFLOW_BIND_UAV_OPTICAL_FLOW_ADDITIONAL_INFO |
|||
RWTexture2D<FfxUInt32x2> rw_optical_flow_additional_info : FFX_OPTICALFLOW_DECLARE_UAV(FFX_OPTICALFLOW_BIND_UAV_OPTICAL_FLOW_ADDITIONAL_INFO); |
|||
#endif |
|||
#if defined FFX_OPTICALFLOW_BIND_UAV_OPTICAL_FLOW_ADDITIONAL_INFO_NEXT_LEVEL |
|||
RWTexture2D<FfxUInt32x2> rw_optical_flow_additional_info_next_level : FFX_OPTICALFLOW_DECLARE_UAV(FFX_OPTICALFLOW_BIND_UAV_OPTICAL_FLOW_ADDITIONAL_INFO_NEXT_LEVEL); |
|||
#endif |
|||
#if defined FFX_OPTICALFLOW_BIND_UAV_OPTICAL_FLOW_HISTOGRAM |
|||
RWTexture2D<FfxUInt32> rw_optical_flow_histogram : FFX_OPTICALFLOW_DECLARE_UAV(FFX_OPTICALFLOW_BIND_UAV_OPTICAL_FLOW_HISTOGRAM); |
|||
#endif |
|||
#if defined FFX_OPTICALFLOW_BIND_UAV_OPTICAL_FLOW_GLOBAL_MOTION_SEARCH |
|||
globallycoherent RWTexture2D<FfxUInt32> rw_optical_flow_global_motion_search: FFX_OPTICALFLOW_DECLARE_UAV(FFX_OPTICALFLOW_BIND_UAV_OPTICAL_FLOW_GLOBAL_MOTION_SEARCH); |
|||
#endif |
|||
#if defined FFX_OPTICALFLOW_BIND_UAV_OPTICAL_FLOW_SCD_HISTOGRAM |
|||
RWTexture2D<FfxUInt32> rw_optical_flow_scd_histogram : FFX_OPTICALFLOW_DECLARE_UAV(FFX_OPTICALFLOW_BIND_UAV_OPTICAL_FLOW_SCD_HISTOGRAM); |
|||
#endif |
|||
#if defined FFX_OPTICALFLOW_BIND_UAV_OPTICAL_FLOW_SCD_PREVIOUS_HISTOGRAM |
|||
RWTexture2D<FfxFloat32> rw_optical_flow_scd_previous_histogram : FFX_OPTICALFLOW_DECLARE_UAV(FFX_OPTICALFLOW_BIND_UAV_OPTICAL_FLOW_SCD_PREVIOUS_HISTOGRAM); |
|||
#endif |
|||
#if defined FFX_OPTICALFLOW_BIND_UAV_OPTICAL_FLOW_SCD_TEMP |
|||
RWTexture2D<FfxUInt32> rw_optical_flow_scd_temp : FFX_OPTICALFLOW_DECLARE_UAV(FFX_OPTICALFLOW_BIND_UAV_OPTICAL_FLOW_SCD_TEMP); |
|||
#endif |
|||
#if defined FFX_OPTICALFLOW_BIND_UAV_OPTICAL_FLOW_SCD_OUTPUT |
|||
RWTexture2D<FfxUInt32> rw_optical_flow_scd_output : FFX_OPTICALFLOW_DECLARE_UAV(FFX_OPTICALFLOW_BIND_UAV_OPTICAL_FLOW_SCD_OUTPUT); |
|||
#endif |
|||
|
|||
#if defined(FFX_OPTICALFLOW_BIND_SRV_INPUT_COLOR) |
|||
FfxFloat32x4 LoadInputColor(FfxUInt32x2 iPxHistory) |
|||
{ |
|||
return r_input_color[iPxHistory]; |
|||
} |
|||
#endif |
|||
|
|||
#if defined(FFX_OPTICALFLOW_BIND_SRV_INPUT_MOTION_VECTORS) |
|||
FfxFloat32x2 LoadGameMotionVector(FfxInt32x2 iPxPos) |
|||
{ |
|||
FfxFloat32x2 positionScale = FfxFloat32x2(RenderSize()) / DisplaySize(); |
|||
return r_input_motion_vectors[iPxPos * positionScale] * motionVectorScale / positionScale; |
|||
} |
|||
#endif |
|||
|
|||
#if defined(FFX_OPTICALFLOW_BIND_UAV_OPTICAL_FLOW_INPUT) |
|||
void StoreOpticalFlowInput(FfxInt32x2 iPxPos, FfxUInt32 fLuma) |
|||
{ |
|||
rw_optical_flow_input[iPxPos] = fLuma; |
|||
} |
|||
#endif |
|||
|
|||
#if defined(FFX_OPTICALFLOW_BIND_SRV_OPTICAL_FLOW_INPUT) |
|||
FfxUInt32 LoadOpticalFlowInput(FfxInt32x2 iPxPos) |
|||
{ |
|||
#if FFX_OPTICALFLOW_USE_MSAD4_INSTRUCTION == 1 |
|||
return max(1, r_optical_flow_input[iPxPos]); |
|||
#else |
|||
return r_optical_flow_input[iPxPos]; |
|||
#endif |
|||
} |
|||
#endif |
|||
|
|||
#if defined(FFX_OPTICALFLOW_BIND_UAV_OPTICAL_FLOW_INPUT) |
|||
FfxUInt32 LoadRwOpticalFlowInput(FfxInt32x2 iPxPos) |
|||
{ |
|||
return rw_optical_flow_input[iPxPos]; |
|||
} |
|||
#endif |
|||
|
|||
#if defined(FFX_OPTICALFLOW_BIND_SRV_OPTICAL_FLOW_PREVIOUS_INPUT) |
|||
FfxUInt32 LoadOpticalFlowPreviousInput(FfxInt32x2 iPxPos) |
|||
{ |
|||
#if FFX_OPTICALFLOW_USE_MSAD4_INSTRUCTION == 1 |
|||
return max(1, r_optical_flow_previous_input[iPxPos]); |
|||
#else |
|||
return r_optical_flow_previous_input[iPxPos]; |
|||
#endif |
|||
} |
|||
#endif |
|||
|
|||
#if defined(FFX_OPTICALFLOW_BIND_SRV_OPTICAL_FLOW) |
|||
FfxInt32x2 LoadOpticalFlow(FfxInt32x2 iPxPos) |
|||
{ |
|||
return r_optical_flow[iPxPos]; |
|||
} |
|||
#endif |
|||
|
|||
#if defined(FFX_OPTICALFLOW_BIND_UAV_OPTICAL_FLOW) |
|||
FfxInt32x2 LoadRwOpticalFlow(FfxInt32x2 iPxPos) |
|||
{ |
|||
return rw_optical_flow[iPxPos]; |
|||
} |
|||
#endif |
|||
|
|||
#if defined(FFX_OPTICALFLOW_BIND_SRV_OPTICAL_FLOW_PREVIOUS) |
|||
FfxInt32x2 LoadPreviousOpticalFlow(FfxInt32x2 iPxPos) |
|||
{ |
|||
return r_optical_flow_previous[iPxPos]; |
|||
} |
|||
#endif |
|||
|
|||
#if defined(FFX_OPTICALFLOW_BIND_UAV_OPTICAL_FLOW) |
|||
void StoreOpticalFlow(FfxInt32x2 iPxPos, FfxInt32x2 motionVector) |
|||
{ |
|||
rw_optical_flow[iPxPos] = motionVector; |
|||
} |
|||
#endif |
|||
|
|||
#if defined(FFX_OPTICALFLOW_BIND_UAV_OPTICAL_FLOW_NEXT_LEVEL) |
|||
void StoreOpticalFlowNextLevel(FfxInt32x2 iPxPos, FfxInt32x2 motionVector) |
|||
{ |
|||
rw_optical_flow_next_level[iPxPos] = motionVector; |
|||
} |
|||
#endif |
|||
|
|||
#if defined(FFX_OPTICALFLOW_BIND_SRV_OPTICAL_FLOW_ADDITIONAL_INFO) |
|||
FfxUInt32x2 LoadOpticalFlowAdditionalInfo(FfxInt32x2 iPxPos) |
|||
{ |
|||
return r_optical_flow_additional_info[iPxPos]; |
|||
} |
|||
#endif |
|||
|
|||
#if defined(FFX_OPTICALFLOW_BIND_UAV_OPTICAL_FLOW_ADDITIONAL_INFO) |
|||
FfxUInt32x2 LoadRwOpticalFlowAdditionalInfo(FfxInt32x2 iPxPos) |
|||
{ |
|||
return rw_optical_flow_additional_info[iPxPos]; |
|||
} |
|||
#endif |
|||
|
|||
#if defined(FFX_OPTICALFLOW_BIND_SRV_OPTICAL_FLOW_ADDITIONAL_INFO_PREVIOUS) |
|||
FfxUInt32x2 LoadPreviousOpticalFlowAdditionalInfo(FfxInt32x2 iPxPos) |
|||
{ |
|||
return r_optical_flow_additional_info_previous[iPxPos]; |
|||
} |
|||
#endif |
|||
|
|||
#if defined(FFX_OPTICALFLOW_BIND_UAV_OPTICAL_FLOW_ADDITIONAL_INFO) |
|||
void StoreOpticalFlowAdditionalInfo(FfxInt32x2 iPxPos, FfxUInt32x2 additionalInfo) |
|||
{ |
|||
rw_optical_flow_additional_info[iPxPos] = additionalInfo; |
|||
} |
|||
#endif |
|||
|
|||
#if defined(FFX_OPTICALFLOW_BIND_UAV_OPTICAL_FLOW_ADDITIONAL_INFO_NEXT_LEVEL) |
|||
void StoreOpticalFlowNextLevelAdditionalInfo(FfxInt32x2 iPxPos, FfxUInt32x2 additionalInfo) |
|||
{ |
|||
rw_optical_flow_additional_info_next_level[iPxPos] = additionalInfo; |
|||
} |
|||
#endif |
|||
|
|||
#if defined(FFX_OPTICALFLOW_BIND_SRV_OPTICAL_FLOW_HISTOGRAM) |
|||
FfxUInt32 LoadOpticalFlowHistogram(FfxInt32x2 iBucketId) |
|||
{ |
|||
return r_optical_flow_histogram[iBucketId]; |
|||
} |
|||
#endif |
|||
|
|||
#if defined(FFX_OPTICALFLOW_BIND_UAV_OPTICAL_FLOW_HISTOGRAM) |
|||
void AtomicIncrementOpticalFlowHistogram(FfxInt32x2 iBucketId) |
|||
{ |
|||
InterlockedAdd(rw_optical_flow_histogram[iBucketId], 1); |
|||
} |
|||
#endif |
|||
|
|||
#if defined(FFX_OPTICALFLOW_BIND_SRV_OPTICAL_FLOW_GLOBAL_MOTION_SEARCH) |
|||
FfxInt32x2 LoadGlobalMotionVector() |
|||
{ |
|||
FfxInt32 vx = FfxInt32(r_optical_flow_global_motion_search[FfxInt32x2(0, 0)]); |
|||
FfxInt32 vy = FfxInt32(r_optical_flow_global_motion_search[FfxInt32x2(1, 0)]); |
|||
return FfxInt32x2(vx, vy); |
|||
} |
|||
#endif |
|||
|
|||
#if defined(FFX_OPTICALFLOW_BIND_UAV_OPTICAL_FLOW_GLOBAL_MOTION_SEARCH) |
|||
FfxInt32x2 LoadRwGlobalMotionVector() |
|||
{ |
|||
FfxInt32 vx = FfxInt32(rw_optical_flow_global_motion_search[FfxInt32x2(0, 0)]); |
|||
FfxInt32 vy = FfxInt32(rw_optical_flow_global_motion_search[FfxInt32x2(1, 0)]); |
|||
return FfxInt32x2(vx, vy); |
|||
} |
|||
#endif |
|||
|
|||
#if defined(FFX_OPTICALFLOW_BIND_UAV_OPTICAL_FLOW_GLOBAL_MOTION_SEARCH) |
|||
FfxUInt32 LoadGlobalMotionValue(FfxInt32 index) |
|||
{ |
|||
return rw_optical_flow_global_motion_search[FfxInt32x2(index, 0)]; |
|||
} |
|||
#endif |
|||
|
|||
#if defined(FFX_OPTICALFLOW_BIND_UAV_OPTICAL_FLOW_GLOBAL_MOTION_SEARCH) |
|||
void StoreGlobalMotionValue(FfxInt32 index, FfxUInt32 value) |
|||
{ |
|||
rw_optical_flow_global_motion_search[FfxInt32x2(index, 0)] = value; |
|||
} |
|||
#endif |
|||
|
|||
#if defined(FFX_OPTICALFLOW_BIND_UAV_OPTICAL_FLOW_GLOBAL_MOTION_SEARCH) |
|||
FfxUInt32 AtomicIncrementGlobalMotionValue(FfxInt32 index) |
|||
{ |
|||
FfxUInt32 initialValue; |
|||
InterlockedAdd(rw_optical_flow_global_motion_search[FfxInt32x2(index, 0)], 1, initialValue); |
|||
return initialValue; |
|||
} |
|||
#endif |
|||
|
|||
#if defined(FFX_OPTICALFLOW_BIND_UAV_OPTICAL_FLOW_SCD_HISTOGRAM) |
|||
FfxUInt32 LoadRwSCDHistogram(FfxInt32 iIndex) |
|||
{ |
|||
return rw_optical_flow_scd_histogram[FfxInt32x2(iIndex, 0)]; |
|||
} |
|||
#endif |
|||
|
|||
#if defined(FFX_OPTICALFLOW_BIND_UAV_OPTICAL_FLOW_SCD_HISTOGRAM) |
|||
void StoreSCDHistogram(FfxInt32 iIndex, FfxUInt32 value) |
|||
{ |
|||
rw_optical_flow_scd_histogram[FfxInt32x2(iIndex, 0)] = value; |
|||
} |
|||
#endif |
|||
|
|||
#if defined(FFX_OPTICALFLOW_BIND_UAV_OPTICAL_FLOW_SCD_HISTOGRAM) |
|||
void AtomicIncrementSCDHistogram(FfxInt32 iIndex, FfxUInt32 valueToAdd) |
|||
{ |
|||
InterlockedAdd(rw_optical_flow_scd_histogram[FfxInt32x2(iIndex, 0)], valueToAdd); |
|||
} |
|||
#endif |
|||
|
|||
#if defined(FFX_OPTICALFLOW_BIND_UAV_OPTICAL_FLOW_SCD_PREVIOUS_HISTOGRAM) |
|||
FfxFloat32 LoadRwSCDPreviousHistogram(FfxInt32 iIndex) |
|||
{ |
|||
return rw_optical_flow_scd_previous_histogram[FfxInt32x2(iIndex, 0)]; |
|||
} |
|||
#endif |
|||
|
|||
#if defined(FFX_OPTICALFLOW_BIND_UAV_OPTICAL_FLOW_SCD_PREVIOUS_HISTOGRAM) |
|||
void StoreSCDPreviousHistogram(FfxInt32 iIndex, FfxFloat32 value) |
|||
{ |
|||
rw_optical_flow_scd_previous_histogram[FfxInt32x2(iIndex, 0)] = value; |
|||
} |
|||
#endif |
|||
|
|||
#if defined(FFX_OPTICALFLOW_BIND_UAV_OPTICAL_FLOW_SCD_TEMP) |
|||
FfxUInt32 LoadRwSCDTemp(FfxInt32 iIndex) |
|||
{ |
|||
return rw_optical_flow_scd_temp[FfxInt32x2(iIndex, 0)]; |
|||
} |
|||
#endif |
|||
|
|||
#if defined(FFX_OPTICALFLOW_BIND_UAV_OPTICAL_FLOW_SCD_TEMP) |
|||
void AtomicIncrementSCDTemp(FfxInt32 iIndex, FfxUInt32 valueToAdd) |
|||
{ |
|||
InterlockedAdd(rw_optical_flow_scd_temp[FfxInt32x2(iIndex, 0)], valueToAdd); |
|||
} |
|||
#endif |
|||
|
|||
#if defined(FFX_OPTICALFLOW_BIND_UAV_OPTICAL_FLOW_SCD_TEMP) |
|||
void ResetSCDTemp() |
|||
{ |
|||
rw_optical_flow_scd_temp[FfxInt32x2(0, 0)] = 0; |
|||
rw_optical_flow_scd_temp[FfxInt32x2(1, 0)] = 0; |
|||
rw_optical_flow_scd_temp[FfxInt32x2(2, 0)] = 0; |
|||
} |
|||
#endif |
|||
|
|||
#if defined(FFX_OPTICALFLOW_BIND_UAV_OPTICAL_FLOW_SCD_OUTPUT) |
|||
FfxUInt32 LoadRwSCDOutput(FfxInt32 iIndex) |
|||
{ |
|||
return rw_optical_flow_scd_output[FfxInt32x2(iIndex, 0)]; |
|||
} |
|||
#endif |
|||
|
|||
#if defined(FFX_OPTICALFLOW_BIND_UAV_OPTICAL_FLOW_SCD_OUTPUT) |
|||
void StoreSCDOutput(FfxInt32 iIndex, FfxUInt32 value) |
|||
{ |
|||
rw_optical_flow_scd_output[FfxInt32x2(iIndex, 0)] = value; |
|||
} |
|||
#endif |
|||
|
|||
#if defined(FFX_OPTICALFLOW_BIND_UAV_OPTICAL_FLOW_SCD_OUTPUT) |
|||
FfxUInt32 AtomicIncrementSCDOutput(FfxInt32 iIndex, FfxUInt32 valueToAdd) |
|||
{ |
|||
FfxUInt32 initialValue; |
|||
InterlockedAdd(rw_optical_flow_scd_output[FfxInt32x2(iIndex, 0)], valueToAdd, initialValue); |
|||
return initialValue; |
|||
} |
|||
#endif |
|||
|
|||
#if defined(FFX_OPTICALFLOW_BIND_UAV_DEBUG_VISUALIZATION) |
|||
void StoreDebugVisualization(FfxUInt32x2 iPxPos, FfxFloat32x3 fColor) |
|||
{ |
|||
rw_debug_visualization[iPxPos] = FfxFloat32x4(fColor, 1.f); |
|||
} |
|||
#endif |
|||
|
|||
#if defined(FFX_OPTICALFLOW_BIND_UAV_OPTICAL_FLOW_SCD_OUTPUT) |
|||
FfxFloat32 GetSceneChangeValue() |
|||
{ |
|||
if (FrameIndex() <= 5) |
|||
return 1.0; |
|||
else |
|||
return ffxAsFloat(LoadRwSCDOutput(SCD_OUTPUT_SCENE_CHANGE_SLOT)); |
|||
} |
|||
|
|||
FfxBoolean IsSceneChanged() |
|||
{ |
|||
if (FrameIndex() <= 5) |
|||
{ |
|||
return 1.0; |
|||
} |
|||
else |
|||
{ |
|||
return (LoadRwSCDOutput(SCD_OUTPUT_HISTORY_BITS_SLOT) & 0xfu) != 0; |
|||
} |
|||
} |
|||
#endif |
|||
|
|||
#if defined(FFX_OPTICALFLOW_BIND_SRV_OPTICAL_FLOW_INPUT) |
|||
FfxUInt32 LoadFirstImagePackedLuma(FfxInt32x2 iPxPos) |
|||
{ |
|||
const FfxInt32 lumaTextureWidth = DisplaySize().x >> OpticalFlowPyramidLevel(); |
|||
const FfxInt32 lumaTextureHeight = DisplaySize().y >> OpticalFlowPyramidLevel(); |
|||
|
|||
FfxInt32x2 adjustedPos = FfxInt32x2( |
|||
ffxClamp(iPxPos.x, 0, lumaTextureWidth - 4), |
|||
ffxClamp(iPxPos.y, 0, lumaTextureHeight - 1) |
|||
); |
|||
|
|||
FfxUInt32 luma0 = LoadOpticalFlowInput(adjustedPos + FfxInt32x2(0, 0)); |
|||
FfxUInt32 luma1 = LoadOpticalFlowInput(adjustedPos + FfxInt32x2(1, 0)); |
|||
FfxUInt32 luma2 = LoadOpticalFlowInput(adjustedPos + FfxInt32x2(2, 0)); |
|||
FfxUInt32 luma3 = LoadOpticalFlowInput(adjustedPos + FfxInt32x2(3, 0)); |
|||
|
|||
return GetPackedLuma(lumaTextureWidth, iPxPos.x, luma0, luma1, luma2, luma3); |
|||
} |
|||
#endif |
|||
|
|||
#if defined(FFX_OPTICALFLOW_BIND_SRV_OPTICAL_FLOW_PREVIOUS_INPUT) |
|||
FfxUInt32 LoadSecondImagePackedLuma(FfxInt32x2 iPxPos) |
|||
{ |
|||
const FfxInt32 lumaTextureWidth = DisplaySize().x >> OpticalFlowPyramidLevel(); |
|||
const FfxInt32 lumaTextureHeight = DisplaySize().y >> OpticalFlowPyramidLevel(); |
|||
|
|||
FfxInt32x2 adjustedPos = FfxInt32x2( |
|||
ffxClamp(iPxPos.x, 0, lumaTextureWidth - 4), |
|||
ffxClamp(iPxPos.y, 0, lumaTextureHeight - 1) |
|||
); |
|||
|
|||
FfxUInt32 luma0 = LoadOpticalFlowPreviousInput(adjustedPos + FfxInt32x2(0, 0)); |
|||
FfxUInt32 luma1 = LoadOpticalFlowPreviousInput(adjustedPos + FfxInt32x2(1, 0)); |
|||
FfxUInt32 luma2 = LoadOpticalFlowPreviousInput(adjustedPos + FfxInt32x2(2, 0)); |
|||
FfxUInt32 luma3 = LoadOpticalFlowPreviousInput(adjustedPos + FfxInt32x2(3, 0)); |
|||
|
|||
return GetPackedLuma(lumaTextureWidth, iPxPos.x, luma0, luma1, luma2, luma3); |
|||
} |
|||
#endif |
|||
|
|||
|
|||
void SPD_SetMipmap(int2 iPxPos, int index, float value) |
|||
{ |
|||
switch (index) |
|||
{ |
|||
case 0: |
|||
#if defined FFX_OPTICALFLOW_BIND_UAV_OPTICAL_FLOW_INPUT_LEVEL_1 |
|||
rw_optical_flow_input_level_1[iPxPos] = value; |
|||
#endif // #if defined FFX_OPTICALFLOW_BIND_UAV_OPTICAL_FLOW_INPUT_LEVEL_1 |
|||
break; |
|||
case 1: |
|||
#if defined FFX_OPTICALFLOW_BIND_UAV_OPTICAL_FLOW_INPUT_LEVEL_2 |
|||
rw_optical_flow_input_level_2[iPxPos] = value; |
|||
#endif // #if defined FFX_OPTICALFLOW_BIND_UAV_OPTICAL_FLOW_INPUT_LEVEL_2 |
|||
break; |
|||
case 2: |
|||
#if defined FFX_OPTICALFLOW_BIND_UAV_OPTICAL_FLOW_INPUT_LEVEL_3 |
|||
rw_optical_flow_input_level_3[iPxPos] = value; |
|||
#endif // #if defined FFX_OPTICALFLOW_BIND_UAV_OPTICAL_FLOW_INPUT_LEVEL_3 |
|||
break; |
|||
case 3: |
|||
#if defined FFX_OPTICALFLOW_BIND_UAV_OPTICAL_FLOW_INPUT_LEVEL_4 |
|||
rw_optical_flow_input_level_4[iPxPos] = value; |
|||
#endif // #if defined FFX_OPTICALFLOW_BIND_UAV_OPTICAL_FLOW_INPUT_LEVEL_4 |
|||
break; |
|||
case 4: |
|||
#if defined FFX_OPTICALFLOW_BIND_UAV_OPTICAL_FLOW_INPUT_LEVEL_5 |
|||
rw_optical_flow_input_level_5[iPxPos] = value; |
|||
#endif // #if defined FFX_OPTICALFLOW_BIND_UAV_OPTICAL_FLOW_INPUT_LEVEL_5 |
|||
break; |
|||
case 5: |
|||
#if defined FFX_OPTICALFLOW_BIND_UAV_OPTICAL_FLOW_INPUT_LEVEL_6 |
|||
rw_optical_flow_input_level_6[iPxPos] = value; |
|||
#endif // #if defined FFX_OPTICALFLOW_BIND_UAV_OPTICAL_FLOW_INPUT_LEVEL_6 |
|||
break; |
|||
} |
|||
} |
|||
|
|||
#endif // #if defined(FFX_GPU) |
|||
|
|||
#endif // FFX_OPTICALFLOW_CALLBACKS_HLSL_H |
|||
@ -0,0 +1,60 @@ |
|||
fileFormatVersion: 2 |
|||
guid: 0a41d30eeb0591642bf99639bfd5d9ec |
|||
PluginImporter: |
|||
externalObjects: {} |
|||
serializedVersion: 2 |
|||
iconMap: {} |
|||
executionOrder: {} |
|||
defineConstraints: [] |
|||
isPreloaded: 0 |
|||
isOverridable: 1 |
|||
isExplicitlyReferenced: 0 |
|||
validateReferences: 1 |
|||
platformData: |
|||
- first: |
|||
: Any |
|||
second: |
|||
enabled: 0 |
|||
settings: |
|||
Exclude Editor: 1 |
|||
Exclude GameCoreScarlett: 1 |
|||
Exclude GameCoreXboxOne: 1 |
|||
Exclude Linux64: 1 |
|||
Exclude OSXUniversal: 1 |
|||
Exclude PS4: 1 |
|||
Exclude PS5: 1 |
|||
Exclude WebGL: 1 |
|||
Exclude Win: 1 |
|||
Exclude Win64: 1 |
|||
- first: |
|||
Any: |
|||
second: |
|||
enabled: 0 |
|||
settings: {} |
|||
- first: |
|||
Editor: Editor |
|||
second: |
|||
enabled: 0 |
|||
settings: |
|||
DefaultValueInitialized: true |
|||
- first: |
|||
Standalone: Linux64 |
|||
second: |
|||
enabled: 0 |
|||
settings: |
|||
CPU: None |
|||
- first: |
|||
Standalone: Win |
|||
second: |
|||
enabled: 0 |
|||
settings: |
|||
CPU: None |
|||
- first: |
|||
Standalone: Win64 |
|||
second: |
|||
enabled: 0 |
|||
settings: |
|||
CPU: None |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|||
@ -0,0 +1,99 @@ |
|||
// 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. |
|||
|
|||
#if !defined(FFX_OPTICALFLOW_COMMON_H) |
|||
#define FFX_OPTICALFLOW_COMMON_H |
|||
|
|||
#if defined(FFX_GPU) |
|||
|
|||
#define SCD_OUTPUT_SCENE_CHANGE_SLOT 0 |
|||
#define SCD_OUTPUT_HISTORY_BITS_SLOT 1 |
|||
#define SCD_OUTPUT_COMPLETED_WORKGROUPS_SLOT 2 |
|||
|
|||
|
|||
#define ffxClamp(x, a, b) (ffxMax(a, ffxMin(b, x))) |
|||
|
|||
|
|||
FfxUInt32 GetPackedLuma(FfxInt32 width, FfxInt32 x, FfxUInt32 luma0, FfxUInt32 luma1, FfxUInt32 luma2, FfxUInt32 luma3) |
|||
{ |
|||
FfxUInt32 packedLuma = luma0 | (luma1 << 8) | (luma2 << 16) | (luma3 << 24); |
|||
|
|||
if (x < 0) |
|||
{ |
|||
FfxUInt32 outOfScreenFiller = packedLuma & 0xffu; |
|||
if (x <= -1) |
|||
packedLuma = (packedLuma << 8) | outOfScreenFiller; |
|||
if (x <= -2) |
|||
packedLuma = (packedLuma << 8) | outOfScreenFiller; |
|||
if (x <= -3) |
|||
packedLuma = (packedLuma << 8) | outOfScreenFiller; |
|||
} |
|||
else if (x > width - 4) |
|||
{ |
|||
FfxUInt32 outOfScreenFiller = packedLuma & 0xff000000u; |
|||
if (x >= width - 3) |
|||
packedLuma = (packedLuma >> 8) | outOfScreenFiller; |
|||
if (x >= width - 2) |
|||
packedLuma = (packedLuma >> 8) | outOfScreenFiller; |
|||
if (x >= width - 1) |
|||
packedLuma = (packedLuma >> 8) | outOfScreenFiller; |
|||
} |
|||
return packedLuma; |
|||
} |
|||
|
|||
FfxUInt32 Sad(FfxUInt32 a, FfxUInt32 b) |
|||
{ |
|||
#if FFX_OPTICALFLOW_USE_MSAD4_INSTRUCTION == 1 |
|||
return msad4(a, FfxUInt32x2(b, 0), FfxUInt32x4(0, 0, 0, 0)).x; |
|||
#else |
|||
return abs(FfxInt32((a >> 0) & 0xffu) - FfxInt32((b >> 0) & 0xffu)) + |
|||
abs(FfxInt32((a >> 8) & 0xffu) - FfxInt32((b >> 8) & 0xffu)) + |
|||
abs(FfxInt32((a >> 16) & 0xffu) - FfxInt32((b >> 16) & 0xffu)) + |
|||
abs(FfxInt32((a >> 24) & 0xffu) - FfxInt32((b >> 24) & 0xffu)); |
|||
#endif |
|||
} |
|||
|
|||
FfxUInt32x4 QSad(FfxUInt32 a0, FfxUInt32 a1, FfxUInt32 b) |
|||
{ |
|||
#if FFX_OPTICALFLOW_USE_MSAD4_INSTRUCTION == 1 |
|||
return msad4(b, FfxUInt32x2(a0, a1), FfxUInt32x4(0, 0, 0, 0)); |
|||
#else |
|||
FfxUInt32x4 sad; |
|||
sad.x = Sad(a0, b); |
|||
|
|||
a0 = (a0 >> 8) | ((a1 & 0xffu) << 24); |
|||
a1 >>= 8; |
|||
sad.y = Sad(a0, b); |
|||
|
|||
a0 = (a0 >> 8) | ((a1 & 0xffu) << 24); |
|||
a1 >>= 8; |
|||
sad.z = Sad(a0, b); |
|||
|
|||
a0 = (a0 >> 8) | ((a1 & 0xffu) << 24); |
|||
sad.w = Sad(a0, b); |
|||
return sad; |
|||
#endif |
|||
} |
|||
|
|||
#endif // #if defined(FFX_GPU) |
|||
|
|||
#endif //!defined(FFX_OPTICALFLOW_COMMON_H) |
|||
@ -0,0 +1,60 @@ |
|||
fileFormatVersion: 2 |
|||
guid: 615cf613a2a57034ba6c11f20a092fd0 |
|||
PluginImporter: |
|||
externalObjects: {} |
|||
serializedVersion: 2 |
|||
iconMap: {} |
|||
executionOrder: {} |
|||
defineConstraints: [] |
|||
isPreloaded: 0 |
|||
isOverridable: 1 |
|||
isExplicitlyReferenced: 0 |
|||
validateReferences: 1 |
|||
platformData: |
|||
- first: |
|||
: Any |
|||
second: |
|||
enabled: 0 |
|||
settings: |
|||
Exclude Editor: 1 |
|||
Exclude GameCoreScarlett: 1 |
|||
Exclude GameCoreXboxOne: 1 |
|||
Exclude Linux64: 1 |
|||
Exclude OSXUniversal: 1 |
|||
Exclude PS4: 1 |
|||
Exclude PS5: 1 |
|||
Exclude WebGL: 1 |
|||
Exclude Win: 1 |
|||
Exclude Win64: 1 |
|||
- first: |
|||
Any: |
|||
second: |
|||
enabled: 0 |
|||
settings: {} |
|||
- first: |
|||
Editor: Editor |
|||
second: |
|||
enabled: 0 |
|||
settings: |
|||
DefaultValueInitialized: true |
|||
- first: |
|||
Standalone: Linux64 |
|||
second: |
|||
enabled: 0 |
|||
settings: |
|||
CPU: None |
|||
- first: |
|||
Standalone: Win |
|||
second: |
|||
enabled: 0 |
|||
settings: |
|||
CPU: None |
|||
- first: |
|||
Standalone: Win64 |
|||
second: |
|||
enabled: 0 |
|||
settings: |
|||
CPU: None |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|||
@ -0,0 +1,107 @@ |
|||
// 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. |
|||
|
|||
#ifndef FFX_OPTICALFLOW_COMPUTE_LUMINANCE_PYRAMID_H |
|||
#define FFX_OPTICALFLOW_COMPUTE_LUMINANCE_PYRAMID_H |
|||
|
|||
FFX_GROUPSHARED FfxFloat32 spdIntermediateR[16][16]; |
|||
FFX_GROUPSHARED FfxFloat32 spdIntermediateG[16][16]; |
|||
FFX_GROUPSHARED FfxFloat32 spdIntermediateB[16][16]; |
|||
FFX_GROUPSHARED FfxFloat32 spdIntermediateA[16][16]; |
|||
|
|||
void SPD_IncreaseAtomicCounter(inout FfxUInt32 spdCounter) |
|||
{ |
|||
} |
|||
|
|||
void SPD_ResetAtomicCounter() |
|||
{ |
|||
} |
|||
|
|||
FfxFloat32x4 SpdLoadSourceImage(FfxFloat32x2 tex, FfxUInt32 slice) |
|||
{ |
|||
FfxFloat32 luma = LoadRwOpticalFlowInput(FfxInt32x2(tex)); |
|||
return FfxFloat32x4(luma, 0, 0, 0); |
|||
} |
|||
|
|||
FfxFloat32x4 SpdLoad(FfxInt32x2 tex, FfxUInt32 slice) |
|||
{ |
|||
return FfxFloat32x4(0, 0, 0, 0); |
|||
} |
|||
|
|||
void SpdStore(FfxInt32x2 pix, FfxFloat32x4 outValue, FfxUInt32 index, FfxUInt32 slice) |
|||
{ |
|||
SPD_SetMipmap(pix, index, outValue.r); |
|||
} |
|||
|
|||
void SpdIncreaseAtomicCounter(FfxUInt32 slice) |
|||
{ |
|||
} |
|||
|
|||
FfxUInt32 SpdGetAtomicCounter() |
|||
{ |
|||
return 0; |
|||
} |
|||
|
|||
void SpdResetAtomicCounter(FfxUInt32 slice) |
|||
{ |
|||
SPD_ResetAtomicCounter(); |
|||
} |
|||
|
|||
FfxFloat32x4 SpdLoadIntermediate(FfxUInt32 x, FfxUInt32 y) |
|||
{ |
|||
return FfxFloat32x4( |
|||
spdIntermediateR[x][y], |
|||
spdIntermediateG[x][y], |
|||
spdIntermediateB[x][y], |
|||
spdIntermediateA[x][y]); |
|||
} |
|||
void SpdStoreIntermediate(FfxUInt32 x, FfxUInt32 y, FfxFloat32x4 value) |
|||
{ |
|||
spdIntermediateR[x][y] = value.x; |
|||
spdIntermediateG[x][y] = value.y; |
|||
spdIntermediateB[x][y] = value.z; |
|||
spdIntermediateA[x][y] = value.w; |
|||
} |
|||
FfxFloat32x4 SpdReduce4(FfxFloat32x4 v0, FfxFloat32x4 v1, FfxFloat32x4 v2, FfxFloat32x4 v3) |
|||
{ |
|||
return (v0 + v1 + v2 + v3) * 0.25; |
|||
} |
|||
|
|||
#ifdef FFX_HALF |
|||
#undef FFX_HALF |
|||
#endif |
|||
|
|||
// https://github.com/GPUOpen-Effects/FidelityFX-SPD/blob/master/docs/FidelityFX_SPD.pdf |
|||
#include "spd/ffx_spd.h" |
|||
|
|||
void ComputeOpticalFlowInputPyramid(FfxInt32x2 iGroupId, FfxInt32 iLocalIndex) |
|||
{ |
|||
SpdDownsample( |
|||
FfxUInt32x2(iGroupId.xy), |
|||
FfxUInt32(iLocalIndex), |
|||
6, // mip levels to generate |
|||
FfxUInt32(NumWorkGroups()), |
|||
1 // single slice |
|||
); |
|||
} |
|||
|
|||
#endif // FFX_OPTICALFLOW_COMPUTE_LUMINANCE_PYRAMID_H |
|||
@ -0,0 +1,60 @@ |
|||
fileFormatVersion: 2 |
|||
guid: 432b61ec0a1a27147bd8ced835676678 |
|||
PluginImporter: |
|||
externalObjects: {} |
|||
serializedVersion: 2 |
|||
iconMap: {} |
|||
executionOrder: {} |
|||
defineConstraints: [] |
|||
isPreloaded: 0 |
|||
isOverridable: 1 |
|||
isExplicitlyReferenced: 0 |
|||
validateReferences: 1 |
|||
platformData: |
|||
- first: |
|||
: Any |
|||
second: |
|||
enabled: 0 |
|||
settings: |
|||
Exclude Editor: 1 |
|||
Exclude GameCoreScarlett: 1 |
|||
Exclude GameCoreXboxOne: 1 |
|||
Exclude Linux64: 1 |
|||
Exclude OSXUniversal: 1 |
|||
Exclude PS4: 1 |
|||
Exclude PS5: 1 |
|||
Exclude WebGL: 1 |
|||
Exclude Win: 1 |
|||
Exclude Win64: 1 |
|||
- first: |
|||
Any: |
|||
second: |
|||
enabled: 0 |
|||
settings: {} |
|||
- first: |
|||
Editor: Editor |
|||
second: |
|||
enabled: 0 |
|||
settings: |
|||
DefaultValueInitialized: true |
|||
- first: |
|||
Standalone: Linux64 |
|||
second: |
|||
enabled: 0 |
|||
settings: |
|||
CPU: None |
|||
- first: |
|||
Standalone: Win |
|||
second: |
|||
enabled: 0 |
|||
settings: |
|||
CPU: None |
|||
- first: |
|||
Standalone: Win64 |
|||
second: |
|||
enabled: 0 |
|||
settings: |
|||
CPU: None |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|||
@ -0,0 +1,279 @@ |
|||
// 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. |
|||
|
|||
#ifndef FFX_OPTICALFLOW_COMPUTE_OPTICAL_FLOW_V5_H |
|||
#define FFX_OPTICALFLOW_COMPUTE_OPTICAL_FLOW_V5_H |
|||
|
|||
#define CompareSize (4 * 2) |
|||
#define BlockSizeY 8 |
|||
#define BlockSizeX 8 |
|||
#define ThreadCount (4 * 16) |
|||
#define SearchRadiusX (8) |
|||
#define SearchRadiusY (8) |
|||
#define BlockCount 2 |
|||
|
|||
#define SearchBufferSizeX ((CompareSize + SearchRadiusX*2)/4) |
|||
#define SearchBufferSizeY (CompareSize + SearchRadiusY*2) |
|||
|
|||
FFX_GROUPSHARED FfxUInt32 pixels[CompareSize][CompareSize / 4]; |
|||
FFX_GROUPSHARED FfxUInt32 searchBuffer[1][SearchBufferSizeY * SearchBufferSizeX]; |
|||
#define bankBreaker 1 |
|||
FFX_GROUPSHARED FfxUInt32 sadMapBuffer[4][SearchRadiusY * 2][(SearchRadiusX * 2) / 4 + bankBreaker]; |
|||
|
|||
#define MaxWaves 2 |
|||
FFX_GROUPSHARED FfxUInt32 sWaveSad[MaxWaves]; |
|||
FFX_GROUPSHARED FfxUInt32 sWaveMin[MaxWaves]; |
|||
|
|||
FfxUInt32 BlockSad64(FfxUInt32 blockSadSum, FfxInt32 iLocalIndex, FfxInt32 iLaneToBlockId, FfxInt32 block) |
|||
{ |
|||
if (iLaneToBlockId != block) |
|||
{ |
|||
blockSadSum = 0u; |
|||
} |
|||
blockSadSum = ffxWaveSum(blockSadSum); |
|||
|
|||
if (ffxWaveLaneCount() == 32) |
|||
{ |
|||
FfxInt32 waveId = iLocalIndex >> 5u; |
|||
if (ffxWaveIsFirstLane()) |
|||
{ |
|||
sWaveSad[waveId] = blockSadSum; |
|||
} |
|||
FFX_GROUP_MEMORY_BARRIER; |
|||
blockSadSum += sWaveSad[waveId ^ 1]; |
|||
} |
|||
|
|||
return blockSadSum; |
|||
} |
|||
|
|||
FfxUInt32 SadMapMinReduction256(FfxInt32x2 iSearchId, FfxInt32 iLocalIndex) |
|||
{ |
|||
FfxUInt32 min01 = ffxMin(sadMapBuffer[0][iSearchId.y][iSearchId.x], sadMapBuffer[1][iSearchId.y][iSearchId.x]); |
|||
FfxUInt32 min23 = ffxMin(sadMapBuffer[2][iSearchId.y][iSearchId.x], sadMapBuffer[3][iSearchId.y][iSearchId.x]); |
|||
FfxUInt32 min0123 = ffxMin(min01, min23); |
|||
min0123 = ffxWaveMin(min0123); |
|||
|
|||
if (ffxWaveLaneCount() == 32) |
|||
{ |
|||
FfxInt32 waveId = iLocalIndex >> 5u; |
|||
|
|||
if (ffxWaveIsFirstLane()) |
|||
{ |
|||
sWaveMin[waveId] = min0123; |
|||
} |
|||
FFX_GROUP_MEMORY_BARRIER; |
|||
min0123 = ffxMin(min0123, sWaveMin[waveId ^ 1]); |
|||
} |
|||
|
|||
return min0123; |
|||
} |
|||
|
|||
void LoadSearchBuffer(FfxInt32 iLocalIndex, FfxInt32x2 iPxPosShifted) |
|||
{ |
|||
FfxInt32 baseX = (iPxPosShifted.x - SearchRadiusX); |
|||
FfxInt32 baseY = (iPxPosShifted.y - SearchRadiusY); |
|||
|
|||
for (FfxInt32 id = iLocalIndex; id < SearchBufferSizeX * SearchBufferSizeY; id += ThreadCount) |
|||
{ |
|||
FfxInt32 idx = id % SearchBufferSizeX; |
|||
FfxInt32 idy = id / SearchBufferSizeX; |
|||
FfxInt32 x = baseX + idx * 4; |
|||
FfxInt32 y = baseY + idy; |
|||
searchBuffer[0][id] = LoadSecondImagePackedLuma(FfxInt32x2(x, y)); |
|||
} |
|||
FFX_GROUP_MEMORY_BARRIER; |
|||
} |
|||
|
|||
FfxUInt32x4 CalculateQSads2(FfxInt32x2 iSearchId) |
|||
{ |
|||
FfxUInt32x4 sad = ffxBroadcast4(0u); |
|||
|
|||
#if FFX_OPTICALFLOW_USE_MSAD4_INSTRUCTION == 1 |
|||
|
|||
FfxInt32 idx = iSearchId.y * 6 + iSearchId.x; |
|||
|
|||
sad = msad4(pixels[0][0], FfxUInt32x2(searchBuffer[0][idx], searchBuffer[0][idx + 1]), sad); |
|||
sad = msad4(pixels[0][1], FfxUInt32x2(searchBuffer[0][idx + 1], searchBuffer[0][idx + 2]), sad); |
|||
idx += 6; |
|||
sad = msad4(pixels[1][0], FfxUInt32x2(searchBuffer[0][idx], searchBuffer[0][idx + 1]), sad); |
|||
sad = msad4(pixels[1][1], FfxUInt32x2(searchBuffer[0][idx + 1], searchBuffer[0][idx + 2]), sad); |
|||
idx += 6; |
|||
sad = msad4(pixels[2][0], FfxUInt32x2(searchBuffer[0][idx], searchBuffer[0][idx + 1]), sad); |
|||
sad = msad4(pixels[2][1], FfxUInt32x2(searchBuffer[0][idx + 1], searchBuffer[0][idx + 2]), sad); |
|||
idx += 6; |
|||
sad = msad4(pixels[3][0], FfxUInt32x2(searchBuffer[0][idx], searchBuffer[0][idx + 1]), sad); |
|||
sad = msad4(pixels[3][1], FfxUInt32x2(searchBuffer[0][idx + 1], searchBuffer[0][idx + 2]), sad); |
|||
idx += 6; |
|||
sad = msad4(pixels[4][0], FfxUInt32x2(searchBuffer[0][idx], searchBuffer[0][idx + 1]), sad); |
|||
sad = msad4(pixels[4][1], FfxUInt32x2(searchBuffer[0][idx + 1], searchBuffer[0][idx + 2]), sad); |
|||
idx += 6; |
|||
sad = msad4(pixels[5][0], FfxUInt32x2(searchBuffer[0][idx], searchBuffer[0][idx + 1]), sad); |
|||
sad = msad4(pixels[5][1], FfxUInt32x2(searchBuffer[0][idx + 1], searchBuffer[0][idx + 2]), sad); |
|||
idx += 6; |
|||
sad = msad4(pixels[6][0], FfxUInt32x2(searchBuffer[0][idx], searchBuffer[0][idx + 1]), sad); |
|||
sad = msad4(pixels[6][1], FfxUInt32x2(searchBuffer[0][idx + 1], searchBuffer[0][idx + 2]), sad); |
|||
idx += 6; |
|||
sad = msad4(pixels[7][0], FfxUInt32x2(searchBuffer[0][idx], searchBuffer[0][idx + 1]), sad); |
|||
sad = msad4(pixels[7][1], FfxUInt32x2(searchBuffer[0][idx + 1], searchBuffer[0][idx + 2]), sad); |
|||
|
|||
#else |
|||
for (FfxInt32 dy = 0; dy < CompareSize; dy++) |
|||
{ |
|||
FfxInt32 rowOffset = (iSearchId.y + dy) * SearchBufferSizeX; |
|||
FfxUInt32 a0 = searchBuffer[0][rowOffset + iSearchId.x]; |
|||
FfxUInt32 a1 = searchBuffer[0][rowOffset + iSearchId.x + 1]; |
|||
FfxUInt32 a2 = searchBuffer[0][rowOffset + iSearchId.x + 2]; |
|||
sad += QSad(a0, a1, pixels[dy][0]); |
|||
sad += QSad(a1, a2, pixels[dy][1]); |
|||
} |
|||
#endif |
|||
|
|||
return sad; |
|||
} |
|||
|
|||
FfxUInt32x2 abs_2(FfxInt32x2 val) |
|||
{ |
|||
FfxInt32x2 tmp = val; |
|||
FfxInt32x2 mask = tmp >> 31; |
|||
FfxUInt32x2 res = (tmp + mask) ^ mask; |
|||
return res; |
|||
} |
|||
|
|||
FfxUInt32 EncodeSearchCoord(FfxInt32x2 coord) |
|||
{ |
|||
#if FFX_OPTICALFLOW_FIX_TOP_LEFT_BIAS == 1 |
|||
FfxUInt32x2 absCoord = FfxUInt32x2(abs_2(coord - 8)); |
|||
return FfxUInt32(absCoord.y << 12) | FfxUInt32(absCoord.x << 8) | FfxUInt32(coord.y << 4) | FfxUInt32(coord.x); |
|||
#else //FFX_OPTICALFLOW_FIX_TOP_LEFT_BIAS == 1 |
|||
return FfxUInt32(coord.y << 8) | FfxUInt32(coord.x); |
|||
#endif //FFX_OPTICALFLOW_FIX_TOP_LEFT_BIAS == 1 |
|||
} |
|||
|
|||
FfxInt32x2 DecodeSearchCoord(FfxUInt32 bits) |
|||
{ |
|||
#if FFX_OPTICALFLOW_FIX_TOP_LEFT_BIAS == 1 |
|||
FfxInt32 dx = FfxInt32(bits & 0xfu) - SearchRadiusX; |
|||
FfxInt32 dy = FfxInt32((bits >> 4) & 0xfu) - SearchRadiusY; |
|||
|
|||
return FfxInt32x2(dx, dy); |
|||
#else |
|||
FfxInt32 dx = FfxInt32(bits & 0xffu) - SearchRadiusX; |
|||
FfxInt32 dy = FfxInt32((bits >> 8) & 0xffu) - SearchRadiusY; |
|||
|
|||
return FfxInt32x2(dx, dy); |
|||
#endif |
|||
} |
|||
|
|||
void PrepareSadMap(FfxInt32x2 iSearchId, FfxUInt32x4 qsad) |
|||
{ |
|||
sadMapBuffer[0][iSearchId.y][iSearchId.x] = (qsad.x << 16) | EncodeSearchCoord(FfxInt32x2(iSearchId.x * 4 + 0, iSearchId.y)); |
|||
sadMapBuffer[1][iSearchId.y][iSearchId.x] = (qsad.y << 16) | EncodeSearchCoord(FfxInt32x2(iSearchId.x * 4 + 1, iSearchId.y)); |
|||
sadMapBuffer[2][iSearchId.y][iSearchId.x] = (qsad.z << 16) | EncodeSearchCoord(FfxInt32x2(iSearchId.x * 4 + 2, iSearchId.y)); |
|||
sadMapBuffer[3][iSearchId.y][iSearchId.x] = (qsad.w << 16) | EncodeSearchCoord(FfxInt32x2(iSearchId.x * 4 + 3, iSearchId.y)); |
|||
FFX_GROUP_MEMORY_BARRIER; |
|||
} |
|||
|
|||
|
|||
uint ABfe(uint src, uint off, uint bits) { uint mask = (1u << bits) - 1u; return (src >> off) & mask; } |
|||
uint ABfi(uint src, uint ins, uint mask) { return (ins & mask) | (src & (~mask)); } |
|||
uint ABfiM(uint src, uint ins, uint bits) { uint mask = (1u << bits) - 1u; return (ins & mask) | (src & (~mask)); } |
|||
void MapThreads(in FfxInt32x2 iGroupId, in FfxInt32 iLocalIndex, |
|||
out FfxInt32x2 iSearchId, out FfxInt32x2 iPxPos, out FfxInt32 iLaneToBlockId) |
|||
{ |
|||
iSearchId = FfxInt32x2(ABfe(iLocalIndex, 0u, 2u), ABfe(iLocalIndex, 2u, 4u)); |
|||
iLaneToBlockId = FfxInt32(ABfe(iLocalIndex, 1u, 1u) | (ABfe(iLocalIndex, 5u, 1u) << 1u)); |
|||
iPxPos = (iGroupId << 4u) + iSearchId * FfxInt32x2(4, 1); |
|||
} |
|||
|
|||
void ComputeOpticalFlowAdvanced(FfxInt32x2 iGlobalId, FfxInt32x2 iLocalId, FfxInt32x2 iGroupId, FfxInt32 iLocalIndex) |
|||
{ |
|||
FfxInt32x2 iSearchId; |
|||
FfxInt32x2 iPxPos; |
|||
FfxInt32 iLaneToBlockId; |
|||
MapThreads(iGroupId, iLocalIndex, iSearchId, iPxPos, iLaneToBlockId); |
|||
|
|||
FfxInt32x2 currentOFPos = iPxPos >> 3u; |
|||
|
|||
if (IsSceneChanged()) |
|||
{ |
|||
if ((iSearchId.y & 0x7) == 0 && (iSearchId.x & 0x1) == 0) |
|||
{ |
|||
StoreOpticalFlow(currentOFPos, FfxInt32x2(0, 0)); |
|||
} |
|||
|
|||
return; |
|||
} |
|||
|
|||
const FfxBoolean bUsePredictionFromPreviousLevel = (OpticalFlowPyramidLevel() != OpticalFlowPyramidLevelCount() - 1); |
|||
|
|||
FfxUInt32 packedLuma_4blocks = LoadFirstImagePackedLuma(iPxPos); |
|||
|
|||
#if FFX_LOCAL_SEARCH_FALLBACK == 1 |
|||
FfxUInt32 prevPackedLuma_4blocks = LoadSecondImagePackedLuma(iPxPos); |
|||
FfxUInt32 sad_4blocks = Sad(packedLuma_4blocks, prevPackedLuma_4blocks); |
|||
#endif //FFX_LOCAL_SEARCH_FALLBACK |
|||
|
|||
FfxInt32x2 ofGroupOffset = iGroupId << 1u; |
|||
FfxInt32x2 pixelGroupOffset = iGroupId << 4u; |
|||
|
|||
FfxInt32x2 blockId; |
|||
for (blockId.y = 0; blockId.y < BlockCount; blockId.y++) |
|||
{ |
|||
for (blockId.x = 0; blockId.x < BlockCount; blockId.x++) |
|||
{ |
|||
FfxInt32x2 currentVector = LoadRwOpticalFlow(ofGroupOffset + blockId); |
|||
if (!bUsePredictionFromPreviousLevel) |
|||
{ |
|||
currentVector = FfxInt32x2(0, 0); |
|||
} |
|||
|
|||
if (iLaneToBlockId == blockId.y * 2 + blockId.x) |
|||
{ |
|||
pixels[iSearchId.y & 0x7][iSearchId.x & 0x1] = packedLuma_4blocks; |
|||
} |
|||
|
|||
LoadSearchBuffer(iLocalIndex, pixelGroupOffset + blockId * 8 + currentVector); |
|||
|
|||
FfxUInt32x4 qsad = CalculateQSads2(iSearchId); |
|||
|
|||
PrepareSadMap(iSearchId, qsad); |
|||
FfxUInt32 minSad = SadMapMinReduction256(iSearchId, iLocalIndex); |
|||
|
|||
FfxInt32x2 minSadCoord = DecodeSearchCoord(minSad); |
|||
FfxInt32x2 newVector = currentVector + minSadCoord; |
|||
|
|||
#if FFX_LOCAL_SEARCH_FALLBACK == 1 |
|||
FfxUInt32 blockSadSum = BlockSad64(sad_4blocks, iLocalIndex, iLaneToBlockId, blockId.x + blockId.y * 2); |
|||
if (OpticalFlowPyramidLevel() == 0 && blockSadSum <= (minSad >> 16u)) |
|||
{ |
|||
newVector = FfxInt32x2(0, 0); |
|||
} |
|||
#endif //FFX_LOCAL_SEARCH_FALLBACK |
|||
|
|||
{ |
|||
StoreOpticalFlow(ofGroupOffset + blockId, newVector); |
|||
} |
|||
} |
|||
} |
|||
} |
|||
|
|||
#endif // FFX_OPTICALFLOW_COMPUTE_OPTICAL_FLOW_V5_H |
|||
@ -0,0 +1,60 @@ |
|||
fileFormatVersion: 2 |
|||
guid: 61f6df1e3ffe27440b49b1677bb9b25c |
|||
PluginImporter: |
|||
externalObjects: {} |
|||
serializedVersion: 2 |
|||
iconMap: {} |
|||
executionOrder: {} |
|||
defineConstraints: [] |
|||
isPreloaded: 0 |
|||
isOverridable: 1 |
|||
isExplicitlyReferenced: 0 |
|||
validateReferences: 1 |
|||
platformData: |
|||
- first: |
|||
: Any |
|||
second: |
|||
enabled: 0 |
|||
settings: |
|||
Exclude Editor: 1 |
|||
Exclude GameCoreScarlett: 1 |
|||
Exclude GameCoreXboxOne: 1 |
|||
Exclude Linux64: 1 |
|||
Exclude OSXUniversal: 1 |
|||
Exclude PS4: 1 |
|||
Exclude PS5: 1 |
|||
Exclude WebGL: 1 |
|||
Exclude Win: 1 |
|||
Exclude Win64: 1 |
|||
- first: |
|||
Any: |
|||
second: |
|||
enabled: 0 |
|||
settings: {} |
|||
- first: |
|||
Editor: Editor |
|||
second: |
|||
enabled: 0 |
|||
settings: |
|||
DefaultValueInitialized: true |
|||
- first: |
|||
Standalone: Linux64 |
|||
second: |
|||
enabled: 0 |
|||
settings: |
|||
CPU: None |
|||
- first: |
|||
Standalone: Win |
|||
second: |
|||
enabled: 0 |
|||
settings: |
|||
CPU: None |
|||
- first: |
|||
Standalone: Win64 |
|||
second: |
|||
enabled: 0 |
|||
settings: |
|||
CPU: None |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|||
@ -0,0 +1,159 @@ |
|||
// 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. |
|||
|
|||
#ifndef FFX_OPTICALFLOW_COMPUTE_SCD_DIVERGENCE_H |
|||
#define FFX_OPTICALFLOW_COMPUTE_SCD_DIVERGENCE_H |
|||
|
|||
FFX_GROUPSHARED FfxFloat32 sourceHistogram[256]; |
|||
FFX_GROUPSHARED FfxFloat32 filteredHistogram[256]; |
|||
FFX_GROUPSHARED FfxFloat32 tempBuffer[256]; |
|||
FFX_GROUPSHARED FfxFloat32x2 tempBuffer2[256]; |
|||
|
|||
void ComputeSCDHistogramsDivergence(FfxInt32x3 iGlobalId, FfxInt32x2 iLocalId, FfxInt32 iLocalIndex, FfxInt32x2 iGroupId, FfxInt32x2 iGroupSize) |
|||
{ |
|||
FFX_STATIC const FfxFloat32 Factor = 1000000.0; |
|||
FFX_STATIC const FfxInt32 WhereToStop = 3*9 - 1; |
|||
FFX_STATIC const FfxInt32 HistogramCount = 3 * 3; |
|||
|
|||
FFX_STATIC const FfxFloat32 Kernel[] = { |
|||
0.0088122291, 0.027143577, 0.065114059, 0.12164907, 0.17699835, 0.20056541 |
|||
}; |
|||
|
|||
sourceHistogram[iLocalIndex] = FfxFloat32(LoadRwSCDHistogram(iGlobalId.x)); |
|||
FFX_GROUP_MEMORY_BARRIER; |
|||
|
|||
const FfxInt32 kernelShift = -5; |
|||
const FfxInt32 indexToRead = iLocalIndex + kernelShift; |
|||
|
|||
FfxFloat32 val = 0.0; |
|||
val += Kernel[0] * sourceHistogram[ffxClamp(indexToRead + 0, 0, 255)]; |
|||
val += Kernel[1] * sourceHistogram[ffxClamp(indexToRead + 1, 0, 255)]; |
|||
val += Kernel[2] * sourceHistogram[ffxClamp(indexToRead + 2, 0, 255)]; |
|||
val += Kernel[3] * sourceHistogram[ffxClamp(indexToRead + 3, 0, 255)]; |
|||
val += Kernel[4] * sourceHistogram[ffxClamp(indexToRead + 4, 0, 255)]; |
|||
val += Kernel[5] * sourceHistogram[ffxClamp(indexToRead + 5, 0, 255)]; |
|||
val += Kernel[4] * sourceHistogram[ffxClamp(indexToRead + 6, 0, 255)]; |
|||
val += Kernel[3] * sourceHistogram[ffxClamp(indexToRead + 7, 0, 255)]; |
|||
val += Kernel[2] * sourceHistogram[ffxClamp(indexToRead + 8, 0, 255)]; |
|||
val += Kernel[1] * sourceHistogram[ffxClamp(indexToRead + 9, 0, 255)]; |
|||
val += Kernel[0] * sourceHistogram[ffxClamp(indexToRead + 10, 0, 255)]; |
|||
|
|||
val += 1.0; |
|||
|
|||
if (iGlobalId.y == 0) |
|||
{ |
|||
if (iLocalIndex == 0) |
|||
filteredHistogram[255] = 1.0; |
|||
else |
|||
filteredHistogram[iLocalIndex - 1] = val; |
|||
} |
|||
else if (iGlobalId.y == 1) |
|||
{ |
|||
filteredHistogram[iLocalIndex] = val; |
|||
} |
|||
else if (iGlobalId.y == 2) |
|||
{ |
|||
if (iLocalIndex == 255) |
|||
filteredHistogram[0] = 1.0; |
|||
else |
|||
filteredHistogram[iLocalIndex + 1] = val; |
|||
} |
|||
FFX_GROUP_MEMORY_BARRIER; |
|||
|
|||
tempBuffer[iLocalIndex] = filteredHistogram[iLocalIndex]; |
|||
FFX_GROUP_MEMORY_BARRIER; |
|||
|
|||
if (iLocalIndex < 128) tempBuffer[iLocalIndex] += tempBuffer[iLocalIndex + 128]; |
|||
FFX_GROUP_MEMORY_BARRIER; |
|||
|
|||
if (iLocalIndex < 64) tempBuffer[iLocalIndex] += tempBuffer[iLocalIndex + 64]; |
|||
FFX_GROUP_MEMORY_BARRIER; |
|||
|
|||
if (iLocalIndex < 32) tempBuffer[iLocalIndex] += tempBuffer[iLocalIndex + 32]; |
|||
if (iLocalIndex < 16) tempBuffer[iLocalIndex] += tempBuffer[iLocalIndex + 16]; |
|||
if (iLocalIndex < 8 ) tempBuffer[iLocalIndex] += tempBuffer[iLocalIndex + 8]; |
|||
if (iLocalIndex < 4 ) tempBuffer[iLocalIndex] += tempBuffer[iLocalIndex + 4]; |
|||
if (iLocalIndex < 2 ) tempBuffer[iLocalIndex] += tempBuffer[iLocalIndex + 2]; |
|||
if (iLocalIndex < 1 ) tempBuffer[iLocalIndex] += tempBuffer[iLocalIndex + 1]; |
|||
FFX_GROUP_MEMORY_BARRIER; |
|||
|
|||
filteredHistogram[iLocalIndex] /= tempBuffer[0]; |
|||
|
|||
FfxFloat32 currentFilteredHistogramsValue = filteredHistogram[iLocalIndex]; |
|||
FfxFloat32 previousHistogramsValue = LoadRwSCDPreviousHistogram(iGlobalId.x); |
|||
|
|||
tempBuffer2[iLocalIndex] = FfxFloat32x2( |
|||
currentFilteredHistogramsValue * log(currentFilteredHistogramsValue / previousHistogramsValue), |
|||
previousHistogramsValue * log(previousHistogramsValue / currentFilteredHistogramsValue) |
|||
); |
|||
FFX_GROUP_MEMORY_BARRIER; |
|||
|
|||
if (iLocalIndex < 128) tempBuffer2[iLocalIndex] += tempBuffer2[iLocalIndex + 128]; |
|||
FFX_GROUP_MEMORY_BARRIER; |
|||
|
|||
if (iLocalIndex < 64) tempBuffer2[iLocalIndex] += tempBuffer2[iLocalIndex + 64]; |
|||
FFX_GROUP_MEMORY_BARRIER; |
|||
|
|||
if (iLocalIndex < 32) tempBuffer2[iLocalIndex] += tempBuffer2[iLocalIndex + 32]; |
|||
if (iLocalIndex < 16) tempBuffer2[iLocalIndex] += tempBuffer2[iLocalIndex + 16]; |
|||
if (iLocalIndex < 8 ) tempBuffer2[iLocalIndex] += tempBuffer2[iLocalIndex + 8]; |
|||
if (iLocalIndex < 4 ) tempBuffer2[iLocalIndex] += tempBuffer2[iLocalIndex + 4]; |
|||
if (iLocalIndex < 2 ) tempBuffer2[iLocalIndex] += tempBuffer2[iLocalIndex + 2]; |
|||
|
|||
if (iLocalIndex == 0) |
|||
{ |
|||
FfxFloat32x2 sum = tempBuffer2[0] + tempBuffer2[1]; |
|||
|
|||
FfxFloat32 resFloat = 1 - exp(-(abs(sum.x) + abs(sum.y))); |
|||
FfxUInt32 resUInt = FfxUInt32((resFloat / FfxFloat32(HistogramCount)) * Factor); |
|||
AtomicIncrementSCDTemp(iGlobalId.y, resUInt); |
|||
|
|||
FfxUInt32 oldFinishedGroupCount = AtomicIncrementSCDOutput(SCD_OUTPUT_COMPLETED_WORKGROUPS_SLOT, 1); |
|||
if (oldFinishedGroupCount == WhereToStop) |
|||
{ |
|||
FfxUInt32 res0 = LoadRwSCDTemp(0); |
|||
FfxUInt32 res1 = LoadRwSCDTemp(1); |
|||
FfxUInt32 res2 = LoadRwSCDTemp(2); |
|||
FfxFloat32 sceneChangeValue = ffxMin(res0, ffxMin(res1, res2)) / Factor; |
|||
|
|||
FfxUInt32 history = LoadRwSCDOutput(SCD_OUTPUT_HISTORY_BITS_SLOT) << 1; |
|||
if (CrossedSceneChangeThreshold(sceneChangeValue)) |
|||
{ |
|||
history |= 1; |
|||
} |
|||
StoreSCDOutput(SCD_OUTPUT_SCENE_CHANGE_SLOT, ffxAsUInt32(sceneChangeValue)); |
|||
StoreSCDOutput(SCD_OUTPUT_HISTORY_BITS_SLOT, history); |
|||
StoreSCDOutput(SCD_OUTPUT_COMPLETED_WORKGROUPS_SLOT, 0); |
|||
|
|||
ResetSCDTemp(); |
|||
} |
|||
} |
|||
|
|||
if (iGlobalId.y == 1) |
|||
{ |
|||
StoreSCDPreviousHistogram(iGlobalId.x, currentFilteredHistogramsValue); |
|||
|
|||
StoreSCDHistogram(iGlobalId.x, 0); |
|||
} |
|||
} |
|||
|
|||
#endif // FFX_OPTICALFLOW_COMPUTE_SCD_DIVERGENCE_H |
|||
@ -0,0 +1,60 @@ |
|||
fileFormatVersion: 2 |
|||
guid: 76bc7e89a8db43140abe32ba5d4a79fc |
|||
PluginImporter: |
|||
externalObjects: {} |
|||
serializedVersion: 2 |
|||
iconMap: {} |
|||
executionOrder: {} |
|||
defineConstraints: [] |
|||
isPreloaded: 0 |
|||
isOverridable: 1 |
|||
isExplicitlyReferenced: 0 |
|||
validateReferences: 1 |
|||
platformData: |
|||
- first: |
|||
: Any |
|||
second: |
|||
enabled: 0 |
|||
settings: |
|||
Exclude Editor: 1 |
|||
Exclude GameCoreScarlett: 1 |
|||
Exclude GameCoreXboxOne: 1 |
|||
Exclude Linux64: 1 |
|||
Exclude OSXUniversal: 1 |
|||
Exclude PS4: 1 |
|||
Exclude PS5: 1 |
|||
Exclude WebGL: 1 |
|||
Exclude Win: 1 |
|||
Exclude Win64: 1 |
|||
- first: |
|||
Any: |
|||
second: |
|||
enabled: 0 |
|||
settings: {} |
|||
- first: |
|||
Editor: Editor |
|||
second: |
|||
enabled: 0 |
|||
settings: |
|||
DefaultValueInitialized: true |
|||
- first: |
|||
Standalone: Linux64 |
|||
second: |
|||
enabled: 0 |
|||
settings: |
|||
CPU: None |
|||
- first: |
|||
Standalone: Win |
|||
second: |
|||
enabled: 0 |
|||
settings: |
|||
CPU: None |
|||
- first: |
|||
Standalone: Win64 |
|||
second: |
|||
enabled: 0 |
|||
settings: |
|||
CPU: None |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|||
@ -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. |
|||
|
|||
#ifndef FFX_OPTICALFLOW_FILTER_OPTICAL_FLOW_V5_H |
|||
#define FFX_OPTICALFLOW_FILTER_OPTICAL_FLOW_V5_H |
|||
|
|||
void FilterOpticalFlow(FfxInt32x2 iGlobalId, FfxInt32x2 iLocalId, FfxInt32x2 iGroupId, FfxInt32 iLocalIndex) |
|||
{ |
|||
FfxInt32x2 tmpMV[9]; |
|||
FfxInt32 idx = 0; |
|||
for (FfxInt32 xx = -1; xx < 2; xx++) |
|||
{ |
|||
for (FfxInt32 yy = -1; yy < 2; yy++) |
|||
{ |
|||
|
|||
tmpMV[idx] = LoadPreviousOpticalFlow(iGlobalId + FfxInt32x2(xx, yy)); |
|||
idx++; |
|||
} |
|||
} |
|||
|
|||
FfxUInt32 ret = 0xFFFFFFFF; |
|||
for (FfxInt32 i = 0; i < 9; ++i) |
|||
{ |
|||
FfxUInt32 tmp = 0; |
|||
for (FfxInt32 j = 0; j < 9; ++j) |
|||
{ |
|||
FfxInt32x2 delta = tmpMV[i] - tmpMV[j]; |
|||
tmp = delta.x * delta.x + (delta.y * delta.y + tmp); |
|||
} |
|||
|
|||
ret = min(((tmp) << 4) | i, ret); |
|||
} |
|||
|
|||
FfxUInt32 minIdx = ret & 0xF; |
|||
|
|||
StoreOpticalFlow(iGlobalId, tmpMV[minIdx]); |
|||
} |
|||
|
|||
#endif // FFX_OPTICALFLOW_FILTER_OPTICAL_FLOW_V5_H |
|||
@ -0,0 +1,60 @@ |
|||
fileFormatVersion: 2 |
|||
guid: 9a5d2cc46aec47749b1b98b58392afd4 |
|||
PluginImporter: |
|||
externalObjects: {} |
|||
serializedVersion: 2 |
|||
iconMap: {} |
|||
executionOrder: {} |
|||
defineConstraints: [] |
|||
isPreloaded: 0 |
|||
isOverridable: 1 |
|||
isExplicitlyReferenced: 0 |
|||
validateReferences: 1 |
|||
platformData: |
|||
- first: |
|||
: Any |
|||
second: |
|||
enabled: 0 |
|||
settings: |
|||
Exclude Editor: 1 |
|||
Exclude GameCoreScarlett: 1 |
|||
Exclude GameCoreXboxOne: 1 |
|||
Exclude Linux64: 1 |
|||
Exclude OSXUniversal: 1 |
|||
Exclude PS4: 1 |
|||
Exclude PS5: 1 |
|||
Exclude WebGL: 1 |
|||
Exclude Win: 1 |
|||
Exclude Win64: 1 |
|||
- first: |
|||
Any: |
|||
second: |
|||
enabled: 0 |
|||
settings: {} |
|||
- first: |
|||
Editor: Editor |
|||
second: |
|||
enabled: 0 |
|||
settings: |
|||
DefaultValueInitialized: true |
|||
- first: |
|||
Standalone: Linux64 |
|||
second: |
|||
enabled: 0 |
|||
settings: |
|||
CPU: None |
|||
- first: |
|||
Standalone: Win |
|||
second: |
|||
enabled: 0 |
|||
settings: |
|||
CPU: None |
|||
- first: |
|||
Standalone: Win64 |
|||
second: |
|||
enabled: 0 |
|||
settings: |
|||
CPU: None |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|||
@ -0,0 +1,92 @@ |
|||
// 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. |
|||
|
|||
#ifndef FFX_OPTICALFLOW_GENERATE_SCD_HISTOGRAM_H |
|||
#define FFX_OPTICALFLOW_GENERATE_SCD_HISTOGRAM_H |
|||
|
|||
#define LBASE 10 |
|||
|
|||
FFX_GROUPSHARED FfxUInt32 scdBuffer[256 * LBASE]; |
|||
|
|||
void GenerateSceneChangeDetectionHistogram(FfxInt32x3 iGlobalId, FfxInt32x2 iLocalId, FfxInt32 iLocalIndex, FfxInt32x2 iGroupId, FfxInt32x2 iGroupSize) |
|||
{ |
|||
FFX_STATIC const FfxUInt32 HistogramsPerDim = 3; |
|||
|
|||
FfxUInt32 divX = DisplaySize().x / HistogramsPerDim; |
|||
FfxUInt32 divY = DisplaySize().y / HistogramsPerDim; |
|||
|
|||
FfxUInt32 nx = iGlobalId.z % HistogramsPerDim; |
|||
FfxUInt32 ny = iGlobalId.z / HistogramsPerDim; |
|||
FfxUInt32 startX = divX * nx; |
|||
FfxUInt32 startY = divY * ny; |
|||
FfxUInt32 stopX = startX + divX; |
|||
FfxUInt32 stopY = startY + divY; |
|||
|
|||
const FfxUInt32 bufferOffset = iLocalIndex * LBASE; |
|||
|
|||
for (FfxInt32 i = 0; i < LBASE; i++) |
|||
{ |
|||
scdBuffer[bufferOffset + i] = 0; |
|||
} |
|||
FFX_GROUP_MEMORY_BARRIER; |
|||
|
|||
FfxInt32x2 coord = FfxInt32x2(startX + (4 * iGlobalId.x), startY + iGlobalId.y); |
|||
if (coord.x < stopX) |
|||
{ |
|||
for (; coord.y < stopY; coord.y += 128) |
|||
{ |
|||
FfxUInt32x4 color = FfxUInt32x4( |
|||
LoadOpticalFlowInput(coord + FfxInt32x2(0, 0)), |
|||
LoadOpticalFlowInput(coord + FfxInt32x2(1, 0)), |
|||
LoadOpticalFlowInput(coord + FfxInt32x2(2, 0)), |
|||
LoadOpticalFlowInput(coord + FfxInt32x2(3, 0)) |
|||
); |
|||
color *= LBASE; |
|||
|
|||
FfxUInt32 scramblingOffset = iLocalIndex % LBASE; |
|||
|
|||
#if defined(FFX_HLSL) |
|||
InterlockedAdd(scdBuffer[color.x + scramblingOffset], 1); |
|||
InterlockedAdd(scdBuffer[color.y + scramblingOffset], 1); |
|||
InterlockedAdd(scdBuffer[color.z + scramblingOffset], 1); |
|||
InterlockedAdd(scdBuffer[color.w + scramblingOffset], 1); |
|||
#elif defined(FFX_GLSL) |
|||
atomicAdd(scdBuffer[color.x + scramblingOffset], 1); |
|||
atomicAdd(scdBuffer[color.y + scramblingOffset], 1); |
|||
atomicAdd(scdBuffer[color.z + scramblingOffset], 1); |
|||
atomicAdd(scdBuffer[color.w + scramblingOffset], 1); |
|||
#endif |
|||
} |
|||
} |
|||
FFX_GROUP_MEMORY_BARRIER; |
|||
|
|||
FfxUInt32 value = 0; |
|||
for (FfxInt32 i = 0; i < LBASE; i++) |
|||
{ |
|||
value += scdBuffer[bufferOffset + i]; |
|||
} |
|||
|
|||
FfxUInt32 histogramStart = (iGroupSize.x * iGroupSize.y) * iGlobalId.z; |
|||
AtomicIncrementSCDHistogram(FfxInt32(histogramStart + iLocalIndex), value); |
|||
} |
|||
|
|||
#endif // FFX_OPTICALFLOW_GENERATE_SCD_HISTOGRAM_H |
|||
@ -0,0 +1,60 @@ |
|||
fileFormatVersion: 2 |
|||
guid: a9cccb4a935288247bbc3bd4eb909530 |
|||
PluginImporter: |
|||
externalObjects: {} |
|||
serializedVersion: 2 |
|||
iconMap: {} |
|||
executionOrder: {} |
|||
defineConstraints: [] |
|||
isPreloaded: 0 |
|||
isOverridable: 1 |
|||
isExplicitlyReferenced: 0 |
|||
validateReferences: 1 |
|||
platformData: |
|||
- first: |
|||
: Any |
|||
second: |
|||
enabled: 0 |
|||
settings: |
|||
Exclude Editor: 1 |
|||
Exclude GameCoreScarlett: 1 |
|||
Exclude GameCoreXboxOne: 1 |
|||
Exclude Linux64: 1 |
|||
Exclude OSXUniversal: 1 |
|||
Exclude PS4: 1 |
|||
Exclude PS5: 1 |
|||
Exclude WebGL: 1 |
|||
Exclude Win: 1 |
|||
Exclude Win64: 1 |
|||
- first: |
|||
Any: |
|||
second: |
|||
enabled: 0 |
|||
settings: {} |
|||
- first: |
|||
Editor: Editor |
|||
second: |
|||
enabled: 0 |
|||
settings: |
|||
DefaultValueInitialized: true |
|||
- first: |
|||
Standalone: Linux64 |
|||
second: |
|||
enabled: 0 |
|||
settings: |
|||
CPU: None |
|||
- first: |
|||
Standalone: Win |
|||
second: |
|||
enabled: 0 |
|||
settings: |
|||
CPU: None |
|||
- first: |
|||
Standalone: Win64 |
|||
second: |
|||
enabled: 0 |
|||
settings: |
|||
CPU: None |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|||
@ -0,0 +1,106 @@ |
|||
// 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. |
|||
|
|||
#ifndef FFX_OPTICALFLOW_PREPARE_LUMA_H |
|||
#define FFX_OPTICALFLOW_PREPARE_LUMA_H |
|||
|
|||
FfxFloat32 LuminanceToPerceivedLuminance(FfxFloat32 fLuminance) |
|||
{ |
|||
FfxFloat32 fPercievedLuminance = 0; |
|||
if (fLuminance <= 216.0f / 24389.0f) { |
|||
fPercievedLuminance = fLuminance * (24389.0f / 27.0f); |
|||
} |
|||
else { |
|||
fPercievedLuminance = ffxPow(fLuminance, 1.0f / 3.0f) * 116.0f - 16.0f; |
|||
} |
|||
|
|||
return fPercievedLuminance * 0.01f; |
|||
} |
|||
|
|||
FfxFloat32 LinearLdrToLuminance(FfxFloat32x3 linearRec709RGB) |
|||
{ |
|||
FfxFloat32 fY = 0.2126 * linearRec709RGB.x + 0.7152 * linearRec709RGB.y + 0.0722 * linearRec709RGB.z; |
|||
return fY; |
|||
} |
|||
|
|||
FfxFloat32 LinearRec2020ToLuminance(FfxFloat32x3 linearRec2020RGB) |
|||
{ |
|||
FfxFloat32 fY = 0.2627 * linearRec2020RGB.x + 0.678 * linearRec2020RGB.y + 0.0593 * linearRec2020RGB.z; |
|||
return fY; |
|||
} |
|||
|
|||
FfxFloat32 PQCorrectedHdrToLuminance(FfxFloat32x3 pq, FfxFloat32 maxLuminance) |
|||
{ |
|||
FfxFloat32 fY = LinearRec2020ToLuminance(ffxLinearFromPQ(pq) * (10000.0f / maxLuminance)); |
|||
return fY; |
|||
} |
|||
|
|||
FfxFloat32x3 ffxscRGBToLinear(FfxFloat32x3 value, FfxFloat32 minLuminance, FfxFloat32 maxLuminance) |
|||
{ |
|||
FfxFloat32x3 p = value - ffxBroadcast3(minLuminance / 80.0f); |
|||
return p / ffxBroadcast3((maxLuminance - minLuminance) / 80.0f); |
|||
} |
|||
|
|||
FfxFloat32 SCRGBCorrectedHdrToLuminance(FfxFloat32x3 scRGB, FfxFloat32 minLuminance, FfxFloat32 maxLuminance) |
|||
{ |
|||
FfxFloat32 fY = LinearLdrToLuminance(ffxscRGBToLinear(scRGB, minLuminance, maxLuminance)); |
|||
return fY; |
|||
} |
|||
|
|||
void PrepareLuma(FfxInt32x2 iGlobalId, FfxInt32 iLocalIndex) |
|||
{ |
|||
#define PixelsPerThreadX 2 |
|||
#define PixelsPerThreadY 2 |
|||
#pragma unroll |
|||
for (FfxInt32 y = 0; y < PixelsPerThreadY; y++) |
|||
{ |
|||
#pragma unroll |
|||
for (FfxInt32 x = 0; x < PixelsPerThreadX; x++) |
|||
{ |
|||
FfxInt32x2 pos = iGlobalId * FfxInt32x2(PixelsPerThreadX, PixelsPerThreadY) + FfxInt32x2(x, y); |
|||
FfxInt32x2 iPxHrPos = pos; |
|||
FfxFloat32 fY = 0.0; |
|||
|
|||
FfxFloat32x3 inputColor = LoadInputColor(iPxHrPos).rgb; |
|||
|
|||
FfxUInt32 backbufferTransferFunction = BackbufferTransferFunction(); |
|||
if (backbufferTransferFunction == 0) |
|||
{ |
|||
fY = LinearLdrToLuminance(inputColor); |
|||
} |
|||
else if (backbufferTransferFunction == 1) |
|||
{ |
|||
fY = PQCorrectedHdrToLuminance(inputColor, MinMaxLuminance()[1]); |
|||
fY = LuminanceToPerceivedLuminance(fY); |
|||
} |
|||
else if (backbufferTransferFunction == 2) |
|||
{ |
|||
fY = SCRGBCorrectedHdrToLuminance(inputColor, MinMaxLuminance()[0], MinMaxLuminance()[1]); |
|||
fY = LuminanceToPerceivedLuminance(fY); |
|||
} |
|||
|
|||
StoreOpticalFlowInput(pos, FfxUInt32(fY * 255)); |
|||
} |
|||
} |
|||
} |
|||
|
|||
#endif // FFX_OPTICALFLOW_PREPARE_LUMA_H |
|||
@ -0,0 +1,60 @@ |
|||
fileFormatVersion: 2 |
|||
guid: 33627e1139c933848b4455e66f0035cd |
|||
PluginImporter: |
|||
externalObjects: {} |
|||
serializedVersion: 2 |
|||
iconMap: {} |
|||
executionOrder: {} |
|||
defineConstraints: [] |
|||
isPreloaded: 0 |
|||
isOverridable: 1 |
|||
isExplicitlyReferenced: 0 |
|||
validateReferences: 1 |
|||
platformData: |
|||
- first: |
|||
: Any |
|||
second: |
|||
enabled: 0 |
|||
settings: |
|||
Exclude Editor: 1 |
|||
Exclude GameCoreScarlett: 1 |
|||
Exclude GameCoreXboxOne: 1 |
|||
Exclude Linux64: 1 |
|||
Exclude OSXUniversal: 1 |
|||
Exclude PS4: 1 |
|||
Exclude PS5: 1 |
|||
Exclude WebGL: 1 |
|||
Exclude Win: 1 |
|||
Exclude Win64: 1 |
|||
- first: |
|||
Any: |
|||
second: |
|||
enabled: 0 |
|||
settings: {} |
|||
- first: |
|||
Editor: Editor |
|||
second: |
|||
enabled: 0 |
|||
settings: |
|||
DefaultValueInitialized: true |
|||
- first: |
|||
Standalone: Linux64 |
|||
second: |
|||
enabled: 0 |
|||
settings: |
|||
CPU: None |
|||
- first: |
|||
Standalone: Win |
|||
second: |
|||
enabled: 0 |
|||
settings: |
|||
CPU: None |
|||
- first: |
|||
Standalone: Win64 |
|||
second: |
|||
enabled: 0 |
|||
settings: |
|||
CPU: None |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|||
@ -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. |
|||
|
|||
#ifndef FFX_OPTICALFLOW_RESOURCES_H |
|||
#define FFX_OPTICALFLOW_RESOURCES_H |
|||
|
|||
#if defined(FFX_CPU) || defined(FFX_GPU) |
|||
|
|||
#define FFX_OF_RESOURCE_IDENTIFIER_NULL 0 |
|||
|
|||
#define FFX_OF_RESOURCE_IDENTIFIER_OPTICAL_FLOW_INPUT_1 1 |
|||
#define FFX_OF_RESOURCE_IDENTIFIER_OPTICAL_FLOW_INPUT_1_LEVEL_1 2 |
|||
#define FFX_OF_RESOURCE_IDENTIFIER_OPTICAL_FLOW_INPUT_1_LEVEL_2 3 |
|||
#define FFX_OF_RESOURCE_IDENTIFIER_OPTICAL_FLOW_INPUT_1_LEVEL_3 4 |
|||
#define FFX_OF_RESOURCE_IDENTIFIER_OPTICAL_FLOW_INPUT_1_LEVEL_4 5 |
|||
#define FFX_OF_RESOURCE_IDENTIFIER_OPTICAL_FLOW_INPUT_1_LEVEL_5 6 |
|||
#define FFX_OF_RESOURCE_IDENTIFIER_OPTICAL_FLOW_INPUT_1_LEVEL_6 7 |
|||
|
|||
#define FFX_OF_RESOURCE_IDENTIFIER_OPTICAL_FLOW_INPUT_2 8 |
|||
#define FFX_OF_RESOURCE_IDENTIFIER_OPTICAL_FLOW_INPUT_2_LEVEL_1 9 |
|||
#define FFX_OF_RESOURCE_IDENTIFIER_OPTICAL_FLOW_INPUT_2_LEVEL_2 10 |
|||
#define FFX_OF_RESOURCE_IDENTIFIER_OPTICAL_FLOW_INPUT_2_LEVEL_3 11 |
|||
#define FFX_OF_RESOURCE_IDENTIFIER_OPTICAL_FLOW_INPUT_2_LEVEL_4 12 |
|||
#define FFX_OF_RESOURCE_IDENTIFIER_OPTICAL_FLOW_INPUT_2_LEVEL_5 13 |
|||
#define FFX_OF_RESOURCE_IDENTIFIER_OPTICAL_FLOW_INPUT_2_LEVEL_6 14 |
|||
|
|||
#define FFX_OF_RESOURCE_IDENTIFIER_OPTICAL_FLOW_1 15 |
|||
#define FFX_OF_RESOURCE_IDENTIFIER_OPTICAL_FLOW_1_LEVEL_1 16 |
|||
#define FFX_OF_RESOURCE_IDENTIFIER_OPTICAL_FLOW_1_LEVEL_2 17 |
|||
#define FFX_OF_RESOURCE_IDENTIFIER_OPTICAL_FLOW_1_LEVEL_3 18 |
|||
#define FFX_OF_RESOURCE_IDENTIFIER_OPTICAL_FLOW_1_LEVEL_4 19 |
|||
#define FFX_OF_RESOURCE_IDENTIFIER_OPTICAL_FLOW_1_LEVEL_5 20 |
|||
#define FFX_OF_RESOURCE_IDENTIFIER_OPTICAL_FLOW_1_LEVEL_6 21 |
|||
|
|||
#define FFX_OF_RESOURCE_IDENTIFIER_OPTICAL_FLOW_2 22 |
|||
#define FFX_OF_RESOURCE_IDENTIFIER_OPTICAL_FLOW_2_LEVEL_1 23 |
|||
#define FFX_OF_RESOURCE_IDENTIFIER_OPTICAL_FLOW_2_LEVEL_2 24 |
|||
#define FFX_OF_RESOURCE_IDENTIFIER_OPTICAL_FLOW_2_LEVEL_3 25 |
|||
#define FFX_OF_RESOURCE_IDENTIFIER_OPTICAL_FLOW_2_LEVEL_4 26 |
|||
#define FFX_OF_RESOURCE_IDENTIFIER_OPTICAL_FLOW_2_LEVEL_5 27 |
|||
#define FFX_OF_RESOURCE_IDENTIFIER_OPTICAL_FLOW_2_LEVEL_6 28 |
|||
|
|||
#define FFX_OF_RESOURCE_IDENTIFIER_OPTICAL_FLOW_SCD_HISTOGRAM 29 |
|||
#define FFX_OF_RESOURCE_IDENTIFIER_OPTICAL_FLOW_SCD_PREVIOUS_HISTOGRAM 30 |
|||
#define FFX_OF_RESOURCE_IDENTIFIER_OPTICAL_FLOW_SCD_TEMP 31 |
|||
|
|||
#define FFX_OF_RESOURCE_IDENTIFIER_COUNT 32 |
|||
|
|||
#define FFX_OPTICALFLOW_CONSTANTBUFFER_IDENTIFIER 0 |
|||
#define FFX_OPTICALFLOW_CONSTANTBUFFER_IDENTIFIER_SPD 1 |
|||
#define FFX_OPTICALFLOW_CONSTANTBUFFER_COUNT 2 |
|||
|
|||
#endif // #if defined(FFX_CPU) || defined(FFX_GPU) |
|||
|
|||
#endif //!defined( FFX_OPTICALFLOW_RESOURCES_H ) |
|||
@ -0,0 +1,60 @@ |
|||
fileFormatVersion: 2 |
|||
guid: ecffc17f9a96d7540b7723e9f5d6ccac |
|||
PluginImporter: |
|||
externalObjects: {} |
|||
serializedVersion: 2 |
|||
iconMap: {} |
|||
executionOrder: {} |
|||
defineConstraints: [] |
|||
isPreloaded: 0 |
|||
isOverridable: 1 |
|||
isExplicitlyReferenced: 0 |
|||
validateReferences: 1 |
|||
platformData: |
|||
- first: |
|||
: Any |
|||
second: |
|||
enabled: 0 |
|||
settings: |
|||
Exclude Editor: 1 |
|||
Exclude GameCoreScarlett: 1 |
|||
Exclude GameCoreXboxOne: 1 |
|||
Exclude Linux64: 1 |
|||
Exclude OSXUniversal: 1 |
|||
Exclude PS4: 1 |
|||
Exclude PS5: 1 |
|||
Exclude WebGL: 1 |
|||
Exclude Win: 1 |
|||
Exclude Win64: 1 |
|||
- first: |
|||
Any: |
|||
second: |
|||
enabled: 0 |
|||
settings: {} |
|||
- first: |
|||
Editor: Editor |
|||
second: |
|||
enabled: 0 |
|||
settings: |
|||
DefaultValueInitialized: true |
|||
- first: |
|||
Standalone: Linux64 |
|||
second: |
|||
enabled: 0 |
|||
settings: |
|||
CPU: None |
|||
- first: |
|||
Standalone: Win |
|||
second: |
|||
enabled: 0 |
|||
settings: |
|||
CPU: None |
|||
- first: |
|||
Standalone: Win64 |
|||
second: |
|||
enabled: 0 |
|||
settings: |
|||
CPU: None |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|||
@ -0,0 +1,99 @@ |
|||
// 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. |
|||
|
|||
#ifndef FFX_OPTICALFLOW_SCALE_OPTICAL_FLOW_ADVANCED_V5_H |
|||
#define FFX_OPTICALFLOW_SCALE_OPTICAL_FLOW_ADVANCED_V5_H |
|||
|
|||
#define WG_WIDTH FFX_OPTICALFLOW_THREAD_GROUP_WIDTH |
|||
#define WG_HEIGHT FFX_OPTICALFLOW_THREAD_GROUP_HEIGHT |
|||
#define WG_DEPTH FFX_OPTICALFLOW_THREAD_GROUP_DEPTH |
|||
FFX_GROUPSHARED FfxInt32x2 nearestVectors[4][WG_HEIGHT][WG_WIDTH]; |
|||
FFX_GROUPSHARED FfxUInt32 localRegion[4][WG_HEIGHT][WG_WIDTH]; |
|||
FFX_GROUPSHARED FfxUInt32 sads[4][WG_HEIGHT][WG_WIDTH]; |
|||
|
|||
void ScaleOpticalFlowAdvanced(FfxInt32x3 iGlobalId, FfxInt32x3 iLocalId) |
|||
{ |
|||
if (IsSceneChanged()) |
|||
{ |
|||
StoreOpticalFlowNextLevel(iGlobalId.xy, FfxInt32x2(0, 0)); |
|||
|
|||
return; |
|||
} |
|||
|
|||
int xOffset = (iLocalId.z % 2) - 1 + iGlobalId.x % 2; |
|||
int yOffset = (iLocalId.z / 2) - 1 + iGlobalId.y % 2; |
|||
|
|||
FfxInt32x2 srcOFPos = FfxInt32x2( |
|||
(iGlobalId.x / 2) + xOffset, |
|||
(iGlobalId.y / 2) + yOffset |
|||
); |
|||
|
|||
FfxInt32x2 nearestVector = LoadOpticalFlow(srcOFPos); |
|||
nearestVectors[iLocalId.z][iLocalId.y][iLocalId.x] = nearestVector * 2; |
|||
|
|||
int maxY = 4; |
|||
for (int n = iLocalId.z; n < maxY; n += WG_DEPTH) |
|||
{ |
|||
{ |
|||
FfxInt32x2 lumaPos = FfxInt32x2((iGlobalId.x) * 4, iGlobalId.y * maxY + n); |
|||
FfxUInt32 firstPixel = LoadFirstImagePackedLuma(lumaPos); |
|||
localRegion[n][iLocalId.y][iLocalId.x] = firstPixel; |
|||
} |
|||
} |
|||
FFX_GROUP_MEMORY_BARRIER; |
|||
|
|||
uint sad = 0; |
|||
for (int n = 0; n < maxY; n++) |
|||
{ |
|||
{ |
|||
FfxInt32x2 lumaPos = FfxInt32x2((iGlobalId.x) * 4, (iGlobalId.y * maxY + n)) + nearestVector; |
|||
FfxUInt32 secondPixel = LoadSecondImagePackedLuma(lumaPos); |
|||
sad += Sad(localRegion[n][iLocalId.y][iLocalId.x], secondPixel); |
|||
} |
|||
} |
|||
sads[iLocalId.z][iLocalId.y][iLocalId.x] = sad; |
|||
|
|||
FFX_GROUP_MEMORY_BARRIER; |
|||
|
|||
{ |
|||
if (iLocalId.z == 0) |
|||
{ |
|||
uint bestSad = 0xffffffff; |
|||
uint bestId = 0; |
|||
|
|||
for (int n = 0; n < 4; n++) |
|||
{ |
|||
if ((sads[n][iLocalId.y][iLocalId.x]) < bestSad) |
|||
{ |
|||
bestSad = sads[n][iLocalId.y][iLocalId.x]; |
|||
bestId = n; |
|||
} |
|||
} |
|||
|
|||
FfxInt32x2 outputVector = nearestVectors[bestId][iLocalId.y][iLocalId.x]; |
|||
|
|||
StoreOpticalFlowNextLevel(iGlobalId.xy, outputVector); |
|||
} |
|||
} |
|||
} |
|||
|
|||
#endif // FFX_OPTICALFLOW_SCALE_OPTICAL_FLOW_ADVANCED_V5_H |
|||
@ -0,0 +1,60 @@ |
|||
fileFormatVersion: 2 |
|||
guid: 357cee7b9e5993044ad428e29696a2a2 |
|||
PluginImporter: |
|||
externalObjects: {} |
|||
serializedVersion: 2 |
|||
iconMap: {} |
|||
executionOrder: {} |
|||
defineConstraints: [] |
|||
isPreloaded: 0 |
|||
isOverridable: 1 |
|||
isExplicitlyReferenced: 0 |
|||
validateReferences: 1 |
|||
platformData: |
|||
- first: |
|||
: Any |
|||
second: |
|||
enabled: 0 |
|||
settings: |
|||
Exclude Editor: 1 |
|||
Exclude GameCoreScarlett: 1 |
|||
Exclude GameCoreXboxOne: 1 |
|||
Exclude Linux64: 1 |
|||
Exclude OSXUniversal: 1 |
|||
Exclude PS4: 1 |
|||
Exclude PS5: 1 |
|||
Exclude WebGL: 1 |
|||
Exclude Win: 1 |
|||
Exclude Win64: 1 |
|||
- first: |
|||
Any: |
|||
second: |
|||
enabled: 0 |
|||
settings: {} |
|||
- first: |
|||
Editor: Editor |
|||
second: |
|||
enabled: 0 |
|||
settings: |
|||
DefaultValueInitialized: true |
|||
- first: |
|||
Standalone: Linux64 |
|||
second: |
|||
enabled: 0 |
|||
settings: |
|||
CPU: None |
|||
- first: |
|||
Standalone: Win |
|||
second: |
|||
enabled: 0 |
|||
settings: |
|||
CPU: None |
|||
- first: |
|||
Standalone: Win64 |
|||
second: |
|||
enabled: 0 |
|||
settings: |
|||
CPU: None |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|||
Write
Preview
Loading…
Cancel
Save
Reference in new issue