Skip to content
0.2.0-dev Download ZIP
91 lines ·4.0 KB Raw
1// This file is part of the FidelityFX SDK.
2//
3// Copyright (c) 2022-2023 Advanced Micro Devices, Inc. All rights reserved.
4//
5// Permission is hereby granted, free of charge, to any person obtaining a copy
6// of this software and associated documentation files (the "Software"), to deal
7// in the Software without restriction, including without limitation the rights
8// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9// copies of the Software, and to permit persons to whom the Software is
10// furnished to do so, subject to the following conditions:
11// The above copyright notice and this permission notice shall be included in
12// all copies or substantial portions of the Software.
13//
14// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
20// THE SOFTWARE.
21
22//#version 450
23
24#extension GL_GOOGLE_include_directive : require
25#extension GL_EXT_samplerless_texture_functions : require
26// Needed for rw_upscaled_output declaration
27#extension GL_EXT_shader_image_load_formatted : require
28
29#define FSR2_BIND_SRV_INPUT_EXPOSURE 0
30#define FSR2_BIND_SRV_DILATED_REACTIVE_MASKS 1
31#if FFX_FSR2_OPTION_LOW_RESOLUTION_MOTION_VECTORS
32#define FSR2_BIND_SRV_DILATED_MOTION_VECTORS 2
33#else
34#define FSR2_BIND_SRV_INPUT_MOTION_VECTORS 2
35#endif
36#define FSR2_BIND_SRV_INTERNAL_UPSCALED 3
37#define FSR2_BIND_SRV_LOCK_STATUS 4
38//#define FSR2_BIND_SRV_INPUT_DEPTH_CLIP 5
39#define FSR2_BIND_SRV_PREPARED_INPUT_COLOR 6
40#define FSR2_BIND_SRV_LUMA_INSTABILITY 7
41#define FSR2_BIND_SRV_LANCZOS_LUT 8
42#define FSR2_BIND_SRV_UPSCALE_MAXIMUM_BIAS_LUT 9
43#define FSR2_BIND_SRV_SCENE_LUMINANCE_MIPS 10
44#define FSR2_BIND_SRV_AUTO_EXPOSURE 11
45#define FSR2_BIND_SRV_LUMA_HISTORY 12
46
47#define FSR2_BIND_UAV_INTERNAL_UPSCALED 13
48#define FSR2_BIND_UAV_LOCK_STATUS 14
49#define FSR2_BIND_UAV_UPSCALED_OUTPUT 15
50#define FSR2_BIND_UAV_NEW_LOCKS 16
51#define FSR2_BIND_UAV_LUMA_HISTORY 17
52
53#define FSR2_BIND_CB_FSR2 18
54
55#if FFX_FSR2_OPTION_GODOT_DERIVE_INVALID_MOTION_VECTORS
56#define FSR2_BIND_SRV_INPUT_DEPTH 5
57#endif
58
59#include "ffx_fsr2_callbacks_glsl.h"
60#include "ffx_fsr2_common.h"
61#include "ffx_fsr2_sample.h"
62#include "ffx_fsr2_upsample.h"
63#include "ffx_fsr2_postprocess_lock_status.h"
64#include "ffx_fsr2_reproject.h"
65#include "ffx_fsr2_accumulate.h"
66
67#ifndef FFX_FSR2_THREAD_GROUP_WIDTH
68#define FFX_FSR2_THREAD_GROUP_WIDTH 8
69#endif // #ifndef FFX_FSR2_THREAD_GROUP_WIDTH
70#ifndef FFX_FSR2_THREAD_GROUP_HEIGHT
71#define FFX_FSR2_THREAD_GROUP_HEIGHT 8
72#endif // FFX_FSR2_THREAD_GROUP_HEIGHT
73#ifndef FFX_FSR2_THREAD_GROUP_DEPTH
74#define FFX_FSR2_THREAD_GROUP_DEPTH 1
75#endif // #ifndef FFX_FSR2_THREAD_GROUP_DEPTH
76#ifndef FFX_FSR2_NUM_THREADS
77#define FFX_FSR2_NUM_THREADS layout (local_size_x = FFX_FSR2_THREAD_GROUP_WIDTH, local_size_y = FFX_FSR2_THREAD_GROUP_HEIGHT, local_size_z = FFX_FSR2_THREAD_GROUP_DEPTH) in;
78
79#endif // #ifndef FFX_FSR2_NUM_THREADS
80
81FFX_FSR2_NUM_THREADS
82void main()
83{
84 uvec2 uGroupId = gl_WorkGroupID.xy;
85 const uint GroupRows = (uint(DisplaySize().y) + FFX_FSR2_THREAD_GROUP_HEIGHT - 1) / FFX_FSR2_THREAD_GROUP_HEIGHT;
86 uGroupId.y = GroupRows - uGroupId.y - 1;
87
88 uvec2 uDispatchThreadId = uGroupId * uvec2(FFX_FSR2_THREAD_GROUP_WIDTH, FFX_FSR2_THREAD_GROUP_HEIGHT) + gl_LocalInvocationID.xy;
89
90 Accumulate(ivec2(uDispatchThreadId));
91}