0.2.0-dev Download ZIP
67 lines ·2.3 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 | #define GROUP_SIZE 8 |
| 23 | |
| 24 | #define FSR_RCAS_DENOISE 1 |
| 25 | |
| 26 | void WriteUpscaledOutput(FFX_MIN16_U2 iPxHrPos, FfxFloat32x3 fUpscaledColor) |
| 27 | { |
| 28 | StoreUpscaledOutput(FFX_MIN16_I2(iPxHrPos), fUpscaledColor); |
| 29 | } |
| 30 | |
| 31 | #define FSR_RCAS_F |
| 32 | FfxFloat32x4 FsrRcasLoadF(FfxInt32x2 p) |
| 33 | { |
| 34 | FfxFloat32x4 fColor = LoadRCAS_Input(p); |
| 35 | |
| 36 | fColor.rgb = PrepareRgb(fColor.rgb, Exposure(), PreExposure()); |
| 37 | |
| 38 | return fColor; |
| 39 | } |
| 40 | |
| 41 | void FsrRcasInputF(inout FfxFloat32 r, inout FfxFloat32 g, inout FfxFloat32 b) {} |
| 42 | |
| 43 | #include "ffx_fsr1.h" |
| 44 | |
| 45 | |
| 46 | void CurrFilter(FFX_MIN16_U2 pos) |
| 47 | { |
| 48 | FfxFloat32x3 c; |
| 49 | FsrRcasF(c.r, c.g, c.b, pos, RCASConfig()); |
| 50 | |
| 51 | c = UnprepareRgb(c, Exposure()); |
| 52 | |
| 53 | WriteUpscaledOutput(pos, c); |
| 54 | } |
| 55 | |
| 56 | void RCAS(FfxUInt32x3 LocalThreadId, FfxUInt32x3 WorkGroupId, FfxUInt32x3 Dtid) |
| 57 | { |
| 58 | // Do remapping of local xy in workgroup for a more PS-like swizzle pattern. |
| 59 | FfxUInt32x2 gxy = ffxRemapForQuad(LocalThreadId.x) + FfxUInt32x2(WorkGroupId.x << 4u, WorkGroupId.y << 4u); |
| 60 | CurrFilter(FFX_MIN16_U2(gxy)); |
| 61 | gxy.x += 8u; |
| 62 | CurrFilter(FFX_MIN16_U2(gxy)); |
| 63 | gxy.y += 8u; |
| 64 | CurrFilter(FFX_MIN16_U2(gxy)); |
| 65 | gxy.x -= 8u; |
| 66 | CurrFilter(FFX_MIN16_U2(gxy)); |
| 67 | } |