add fsr3
This commit is contained in:
parent
f97cace79c
commit
ff12731442
8
Assets/AEG FSR.meta
Normal file
8
Assets/AEG FSR.meta
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 9b9cfa7bca6ef7b49aabae089d9f28f3
|
||||||
|
folderAsset: yes
|
||||||
|
DefaultImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
8
Assets/AEG FSR/Editor.meta
Normal file
8
Assets/AEG FSR/Editor.meta
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: f6231cfcf34ddbe47adc5be9ccd200cb
|
||||||
|
folderAsset: yes
|
||||||
|
DefaultImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
118
Assets/AEG FSR/Editor/FSR3_Editor.cs
Normal file
118
Assets/AEG FSR/Editor/FSR3_Editor.cs
Normal file
@ -0,0 +1,118 @@
|
|||||||
|
using UnityEngine;
|
||||||
|
using UnityEditor;
|
||||||
|
|
||||||
|
namespace AEG.FSR
|
||||||
|
{
|
||||||
|
[CustomEditor(typeof(FSR3_BASE), editorForChildClasses: true)]
|
||||||
|
public class FSR3_Editor : Editor
|
||||||
|
{
|
||||||
|
public override void OnInspectorGUI() {
|
||||||
|
FSR3_BASE fsrScript = target as FSR3_BASE;
|
||||||
|
|
||||||
|
EditorGUI.BeginChangeCheck();
|
||||||
|
|
||||||
|
EditorGUILayout.LabelField("FSR Settings", EditorStyles.boldLabel);
|
||||||
|
FSR_Quality fsrQuality = (FSR_Quality)EditorGUILayout.EnumPopup(Styles.qualityText, fsrScript.FSRQuality);
|
||||||
|
float AntiGhosting = EditorGUILayout.Slider(Styles.antiGhosting, fsrScript.antiGhosting, 0.0f, 1.0f);
|
||||||
|
|
||||||
|
bool sharpening = EditorGUILayout.Toggle(Styles.sharpeningText, fsrScript.sharpening);
|
||||||
|
float sharpness = fsrScript.sharpness;
|
||||||
|
if(fsrScript.sharpening) {
|
||||||
|
EditorGUI.indentLevel++;
|
||||||
|
sharpness = EditorGUILayout.Slider(Styles.sharpnessText, fsrScript.sharpness, 0.0f, 1.0f);
|
||||||
|
EditorGUI.indentLevel--;
|
||||||
|
}
|
||||||
|
|
||||||
|
EditorGUILayout.Space();
|
||||||
|
|
||||||
|
EditorGUILayout.LabelField("Transparency Settings", EditorStyles.boldLabel);
|
||||||
|
bool generateReactiveMask = EditorGUILayout.Toggle(Styles.reactiveMaskText, fsrScript.generateReactiveMask);
|
||||||
|
|
||||||
|
float autoReactiveScale = fsrScript.autoReactiveScale;
|
||||||
|
float autoReactiveThreshold = fsrScript.autoReactiveThreshold;
|
||||||
|
float autoReactiveBinaryValue = fsrScript.autoReactiveBinaryValue;
|
||||||
|
|
||||||
|
bool generateTCMask = false;
|
||||||
|
|
||||||
|
float autoTcThreshold = fsrScript.autoTcThreshold;
|
||||||
|
float autoTcScale = fsrScript.autoTcScale;
|
||||||
|
float autoTcReactiveScale = fsrScript.autoTcReactiveScale;
|
||||||
|
float autoTcReactiveMax = fsrScript.autoTcReactiveMax;
|
||||||
|
|
||||||
|
if(fsrScript.generateReactiveMask) {
|
||||||
|
EditorGUI.indentLevel++;
|
||||||
|
autoReactiveScale = EditorGUILayout.Slider(Styles.reactiveScaleText, fsrScript.autoReactiveScale, 0.0f, 1.0f);
|
||||||
|
autoReactiveThreshold = EditorGUILayout.Slider(Styles.reactiveThresholdText, fsrScript.autoReactiveThreshold, 0.0f, 1.0f);
|
||||||
|
autoReactiveBinaryValue = EditorGUILayout.Slider(Styles.reactiveBinaryValueText, fsrScript.autoReactiveBinaryValue, 0.0f, 1.0f);
|
||||||
|
EditorGUI.indentLevel--;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
EditorGUILayout.Space();
|
||||||
|
|
||||||
|
#if UNITY_BIRP
|
||||||
|
EditorGUILayout.LabelField("MipMap Settings", EditorStyles.boldLabel);
|
||||||
|
bool autoTextureUpdate = EditorGUILayout.Toggle(Styles.autoTextureUpdateText, fsrScript.autoTextureUpdate);
|
||||||
|
float mipMapUpdateFrequency = fsrScript.mipMapUpdateFrequency;
|
||||||
|
if(fsrScript.autoTextureUpdate) {
|
||||||
|
EditorGUI.indentLevel++;
|
||||||
|
mipMapUpdateFrequency = EditorGUILayout.FloatField(Styles.autoUpdateFrequencyText, fsrScript.mipMapUpdateFrequency);
|
||||||
|
EditorGUI.indentLevel--;
|
||||||
|
}
|
||||||
|
float mipmapBiasOverride = EditorGUILayout.Slider(Styles.mipmapBiasText, fsrScript.mipmapBiasOverride, 0.0f, 1.0f);
|
||||||
|
#endif
|
||||||
|
if(EditorGUI.EndChangeCheck()) {
|
||||||
|
EditorUtility.SetDirty(fsrScript);
|
||||||
|
|
||||||
|
Undo.RecordObject(target, "Changed Area Of Effect");
|
||||||
|
fsrScript.FSRQuality = fsrQuality;
|
||||||
|
fsrScript.antiGhosting = AntiGhosting;
|
||||||
|
fsrScript.sharpening = sharpening;
|
||||||
|
fsrScript.sharpness = sharpness;
|
||||||
|
|
||||||
|
fsrScript.generateReactiveMask = generateReactiveMask;
|
||||||
|
fsrScript.autoReactiveThreshold = autoReactiveThreshold;
|
||||||
|
fsrScript.autoReactiveScale = autoReactiveScale;
|
||||||
|
fsrScript.autoReactiveBinaryValue = autoReactiveBinaryValue;
|
||||||
|
|
||||||
|
fsrScript.generateTCMask = generateTCMask;
|
||||||
|
fsrScript.autoTcThreshold = autoTcThreshold;
|
||||||
|
fsrScript.autoTcScale = autoTcScale;
|
||||||
|
fsrScript.autoTcReactiveScale = autoTcReactiveScale;
|
||||||
|
fsrScript.autoTcReactiveMax = autoTcReactiveMax;
|
||||||
|
|
||||||
|
#if UNITY_BIRP
|
||||||
|
fsrScript.autoTextureUpdate = autoTextureUpdate;
|
||||||
|
fsrScript.mipMapUpdateFrequency = mipMapUpdateFrequency;
|
||||||
|
fsrScript.mipmapBiasOverride = mipmapBiasOverride;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static class Styles
|
||||||
|
{
|
||||||
|
public static GUIContent qualityText = new GUIContent("Quality", "Quality 1.5, Balanced 1.7, Performance 2, Ultra Performance 3");
|
||||||
|
public static GUIContent antiGhosting = new GUIContent("Anti Ghosting", "The Anti Ghosting value between 0 and 1, where 0 is no Anti Ghosting and 1 is the maximum amount.");
|
||||||
|
public static GUIContent sharpeningText = new GUIContent("Sharpening", "Enable an additional (RCAS) sharpening pass in the fsr algorithm.");
|
||||||
|
public static GUIContent sharpnessText = new GUIContent("Sharpness", "The sharpness value between 0 and 1, where 0 is no additional sharpness and 1 is maximum additional sharpness.");
|
||||||
|
public static GUIContent hdrText = new GUIContent("HDR", "Instructs FSR to use HDR in the algorithm, for better quality.");
|
||||||
|
public static GUIContent reactiveMaskText = new GUIContent("Reactive Mask", "");
|
||||||
|
public static GUIContent reactiveThresholdText = new GUIContent("Reactive Threshold", "Setting this value too small will cause visual instability. Larger values can cause ghosting. Recommended default value is 0.9f.");
|
||||||
|
public static GUIContent reactiveScaleText = new GUIContent("Reactive Scale", "Larger values result in more reactive pixels. Recommended default value is 0.2f");
|
||||||
|
public static GUIContent reactiveBinaryValueText = new GUIContent("Reactive Binary Value", "Recommended default value is 0.5f.");
|
||||||
|
|
||||||
|
|
||||||
|
public static GUIContent tcMaskText = new GUIContent("Transparency and Composition Mask", "");
|
||||||
|
|
||||||
|
public static GUIContent autoTcThresholdText = new GUIContent("T&C Threshold", "Setting this value too small will cause visual instability. Larger values can cause ghosting. Recommended default value is 0.05f.");
|
||||||
|
public static GUIContent autotcScaleText = new GUIContent("T&C Scale", "Smaller values will increase stability at hard edges of translucent objects. Recommended default value is 1.0f.");
|
||||||
|
public static GUIContent autoTcReactiveScaleText = new GUIContent("T&C Reactive Scale", "Maximum value reactivity can reach. Recommended default value is 5.0f.");
|
||||||
|
public static GUIContent autoTcReactiveMaxText = new GUIContent("T&C Max", "Maximum value reactivity can reach. Recommended default value is 0.9f.");
|
||||||
|
|
||||||
|
public static GUIContent mipmapBiasText = new GUIContent("Mipmap Bias Override", "An extra mipmap bias override for if AMD's recommended MipMap Bias values give artifacts");
|
||||||
|
public static GUIContent autoTextureUpdateText = new GUIContent("Auto Texture Update", "Wether the mipmap biases of all textures in the scene should automatically be updated");
|
||||||
|
public static GUIContent autoUpdateFrequencyText = new GUIContent("Update Frequency", "Interval in seconds in which the mipmap biases should be updated");
|
||||||
|
public static GUIContent debugText = new GUIContent("Debug", "Enables debugging in the FSR algorithm, which can help catch certain errors.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
11
Assets/AEG FSR/Editor/FSR3_Editor.cs.meta
Normal file
11
Assets/AEG FSR/Editor/FSR3_Editor.cs.meta
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: f9c2618bb9b8fae4db30b591f0ea73bb
|
||||||
|
MonoImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
104
Assets/AEG FSR/Editor/PipelineDefines.cs
Normal file
104
Assets/AEG FSR/Editor/PipelineDefines.cs
Normal file
@ -0,0 +1,104 @@
|
|||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
|
||||||
|
using UnityEditor;
|
||||||
|
using UnityEngine.Rendering;
|
||||||
|
|
||||||
|
namespace AEG.FSR
|
||||||
|
{
|
||||||
|
[InitializeOnLoad]
|
||||||
|
public class PipelineDefines
|
||||||
|
{
|
||||||
|
enum PipelineType
|
||||||
|
{
|
||||||
|
Unsupported,
|
||||||
|
BIRP,
|
||||||
|
URP,
|
||||||
|
HDRP
|
||||||
|
}
|
||||||
|
|
||||||
|
static PipelineDefines() {
|
||||||
|
UpdateDefines();
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Update the unity pipeline defines for URP
|
||||||
|
/// </summary>
|
||||||
|
static void UpdateDefines() {
|
||||||
|
var pipeline = GetPipeline();
|
||||||
|
|
||||||
|
if(pipeline == PipelineType.URP) {
|
||||||
|
AddDefine("UNITY_URP");
|
||||||
|
} else {
|
||||||
|
RemoveDefine("UNITY_URP");
|
||||||
|
}
|
||||||
|
if(pipeline == PipelineType.HDRP) {
|
||||||
|
AddDefine("UNITY_HDRP");
|
||||||
|
} else {
|
||||||
|
RemoveDefine("UNITY_HDRP");
|
||||||
|
}
|
||||||
|
if(pipeline == PipelineType.BIRP) {
|
||||||
|
AddDefine("UNITY_BIRP");
|
||||||
|
} else {
|
||||||
|
RemoveDefine("UNITY_BIRP");
|
||||||
|
}
|
||||||
|
|
||||||
|
AddDefine("AEG_FSR1");
|
||||||
|
AddDefine("AEG_FSR3");
|
||||||
|
}
|
||||||
|
|
||||||
|
static PipelineType GetPipeline() {
|
||||||
|
#if UNITY_2019_1_OR_NEWER
|
||||||
|
if(GraphicsSettings.renderPipelineAsset != null) {
|
||||||
|
var srpType = GraphicsSettings.renderPipelineAsset.GetType().ToString();
|
||||||
|
//HDRP
|
||||||
|
if(srpType.Contains("HDRenderPipelineAsset")) {
|
||||||
|
return PipelineType.HDRP;
|
||||||
|
}
|
||||||
|
//URP
|
||||||
|
else if(srpType.Contains("UniversalRenderPipelineAsset") || srpType.Contains("LightweightRenderPipelineAsset")) {
|
||||||
|
return PipelineType.URP;
|
||||||
|
} else
|
||||||
|
return PipelineType.Unsupported;
|
||||||
|
}
|
||||||
|
#elif UNITY_2017_1_OR_NEWER
|
||||||
|
if (GraphicsSettings.renderPipelineAsset != null) {
|
||||||
|
// SRP not supported before 2019
|
||||||
|
return PipelineType.Unsupported;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
//BIRP
|
||||||
|
return PipelineType.BIRP;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void AddDefine(string define) {
|
||||||
|
var definesList = GetDefines();
|
||||||
|
if(!definesList.Contains(define)) {
|
||||||
|
definesList.Add(define);
|
||||||
|
SetDefines(definesList);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void RemoveDefine(string define) {
|
||||||
|
var definesList = GetDefines();
|
||||||
|
if(definesList.Contains(define)) {
|
||||||
|
definesList.Remove(define);
|
||||||
|
SetDefines(definesList);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static List<string> GetDefines() {
|
||||||
|
var target = EditorUserBuildSettings.activeBuildTarget;
|
||||||
|
var buildTargetGroup = BuildPipeline.GetBuildTargetGroup(target);
|
||||||
|
var defines = PlayerSettings.GetScriptingDefineSymbolsForGroup(buildTargetGroup);
|
||||||
|
return defines.Split(';').ToList();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void SetDefines(List<string> definesList) {
|
||||||
|
var target = EditorUserBuildSettings.activeBuildTarget;
|
||||||
|
var buildTargetGroup = BuildPipeline.GetBuildTargetGroup(target);
|
||||||
|
var defines = string.Join(";", definesList.ToArray());
|
||||||
|
PlayerSettings.SetScriptingDefineSymbolsForGroup(buildTargetGroup, defines);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
11
Assets/AEG FSR/Editor/PipelineDefines.cs.meta
Normal file
11
Assets/AEG FSR/Editor/PipelineDefines.cs.meta
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 4ac315fb3a6afc24e80d9d5ecd91c635
|
||||||
|
MonoImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
@ -0,0 +1,18 @@
|
|||||||
|
{
|
||||||
|
"name": "com.alteregogames.aeg-fsr.Editor",
|
||||||
|
"rootNamespace": "AEG.FSR",
|
||||||
|
"references": [
|
||||||
|
"com.alteregogames.aeg-fsr.Runtime"
|
||||||
|
],
|
||||||
|
"includePlatforms": [
|
||||||
|
"Editor"
|
||||||
|
],
|
||||||
|
"excludePlatforms": [],
|
||||||
|
"allowUnsafeCode": false,
|
||||||
|
"overrideReferences": false,
|
||||||
|
"precompiledReferences": [],
|
||||||
|
"autoReferenced": true,
|
||||||
|
"defineConstraints": [],
|
||||||
|
"versionDefines": [],
|
||||||
|
"noEngineReferences": false
|
||||||
|
}
|
||||||
@ -0,0 +1,7 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 1fe6fe8bb843c0c4eb419e45ed5e1f7c
|
||||||
|
AssemblyDefinitionImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
1
Assets/AEG FSR/LICENSE.md
Normal file
1
Assets/AEG FSR/LICENSE.md
Normal file
@ -0,0 +1 @@
|
|||||||
|
All copyright lies with Alterego Games 2023. Do not use, copy, change without permission.
|
||||||
7
Assets/AEG FSR/LICENSE.md.meta
Normal file
7
Assets/AEG FSR/LICENSE.md.meta
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 484ad65439636d047ba3c2b9a13b7361
|
||||||
|
TextScriptImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
BIN
Assets/AEG FSR/Offline Documentation.pdf
Normal file
BIN
Assets/AEG FSR/Offline Documentation.pdf
Normal file
Binary file not shown.
7
Assets/AEG FSR/Offline Documentation.pdf.meta
Normal file
7
Assets/AEG FSR/Offline Documentation.pdf.meta
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: dc51fef46d95fca419783de0303e5df1
|
||||||
|
DefaultImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
1
Assets/AEG FSR/Online Documentation.txt
Normal file
1
Assets/AEG FSR/Online Documentation.txt
Normal file
@ -0,0 +1 @@
|
|||||||
|
https://docs.google.com/document/d/1vkKyCwL6TKdPUb2rWRMw7B3tEYyl_ZH9uyFqJqrQTwg
|
||||||
7
Assets/AEG FSR/Online Documentation.txt.meta
Normal file
7
Assets/AEG FSR/Online Documentation.txt.meta
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 87fc18c5e13ffdb4880068d8047d3864
|
||||||
|
TextScriptImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
8
Assets/AEG FSR/Runtime.meta
Normal file
8
Assets/AEG FSR/Runtime.meta
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: d8bedc0a77979514d97f1037e3343857
|
||||||
|
folderAsset: yes
|
||||||
|
DefaultImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
8
Assets/AEG FSR/Runtime/BIRP.meta
Normal file
8
Assets/AEG FSR/Runtime/BIRP.meta
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 443ab06e35b1e8b41956c8baab3a0eab
|
||||||
|
folderAsset: yes
|
||||||
|
DefaultImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
390
Assets/AEG FSR/Runtime/BIRP/FSR3_BIRP.cs
Normal file
390
Assets/AEG FSR/Runtime/BIRP/FSR3_BIRP.cs
Normal file
@ -0,0 +1,390 @@
|
|||||||
|
#if UNITY_BIRP
|
||||||
|
using System;
|
||||||
|
using UnityEngine;
|
||||||
|
using UnityEngine.Rendering;
|
||||||
|
using System.Collections;
|
||||||
|
using FidelityFX;
|
||||||
|
#if UNITY_EDITOR
|
||||||
|
using UnityEditor;
|
||||||
|
#endif
|
||||||
|
namespace AEG.FSR
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// FSR implementation for the Built-in RenderRipeline
|
||||||
|
/// </summary>
|
||||||
|
public class FSR3_BIRP : FSR3_BASE
|
||||||
|
{
|
||||||
|
// Commandbuffers
|
||||||
|
private CommandBuffer m_colorGrabPass;
|
||||||
|
private CommandBuffer m_fsrComputePass;
|
||||||
|
private CommandBuffer m_opaqueOnlyGrabPass;
|
||||||
|
private CommandBuffer m_afterOpaqueOnlyGrabPass;
|
||||||
|
private CommandBuffer m_blitToCamPass;
|
||||||
|
|
||||||
|
// Rendertextures
|
||||||
|
private RenderTexture m_opaqueOnlyColorBuffer;
|
||||||
|
private RenderTexture m_afterOpaqueOnlyColorBuffer;
|
||||||
|
private RenderTexture m_reactiveMaskOutput;
|
||||||
|
private RenderTexture m_colorBuffer;
|
||||||
|
private RenderTexture m_fsrOutput;
|
||||||
|
|
||||||
|
// Commandbuffer events
|
||||||
|
private const CameraEvent m_OPAQUE_ONLY_EVENT = CameraEvent.BeforeForwardAlpha;
|
||||||
|
private const CameraEvent m_AFTER_OPAQUE_ONLY_EVENT = CameraEvent.AfterForwardAlpha;
|
||||||
|
private const CameraEvent m_COLOR_EVENT = CameraEvent.BeforeImageEffects;
|
||||||
|
private const CameraEvent m_FSR_EVENT = CameraEvent.BeforeImageEffects;
|
||||||
|
private const CameraEvent m_BlITFSR_EVENT = CameraEvent.AfterImageEffects;
|
||||||
|
|
||||||
|
private Matrix4x4 m_jitterMatrix;
|
||||||
|
private Matrix4x4 m_projectionMatrix;
|
||||||
|
|
||||||
|
private readonly Fsr3.DispatchDescription m_dispatchDescription = new Fsr3.DispatchDescription();
|
||||||
|
private readonly Fsr3.GenerateReactiveDescription m_genReactiveDescription = new Fsr3.GenerateReactiveDescription();
|
||||||
|
private IFsr3Callbacks Callbacks { get; set; } = new Fsr3CallbacksBase();
|
||||||
|
private Fsr3Context m_context;
|
||||||
|
|
||||||
|
private bool initFirstFrame = false;
|
||||||
|
/// <summary>
|
||||||
|
/// <inheritdoc/>
|
||||||
|
/// </summary>
|
||||||
|
protected override void InitializeFSR() {
|
||||||
|
base.InitializeFSR();
|
||||||
|
m_mainCamera.depthTextureMode = DepthTextureMode.Depth | DepthTextureMode.MotionVectors;
|
||||||
|
|
||||||
|
m_colorGrabPass = new CommandBuffer { name = "AMD FSR: Color Grab Pass" };
|
||||||
|
m_opaqueOnlyGrabPass = new CommandBuffer { name = "AMD FSR: Opaque Only Grab Pass" };
|
||||||
|
m_afterOpaqueOnlyGrabPass = new CommandBuffer { name = "AMD FSR: After Opaque Only Grab Pass" };
|
||||||
|
m_fsrComputePass = new CommandBuffer { name = "AMD FSR: Compute Pass" };
|
||||||
|
m_blitToCamPass = new CommandBuffer { name = "AMD FSR: Blit to Camera" };
|
||||||
|
|
||||||
|
SendMessage("RemovePPV2CommandBuffers", SendMessageOptions.DontRequireReceiver);
|
||||||
|
SetupResolution();
|
||||||
|
|
||||||
|
if(!m_fsrInitialized) {
|
||||||
|
Camera.onPreRender += OnPreRenderCamera;
|
||||||
|
Camera.onPostRender += OnPostRenderCamera;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Sets up the buffers, initializes the fsr context, and sets up the command buffer
|
||||||
|
/// Must be recalled whenever the display resolution changes
|
||||||
|
/// </summary>
|
||||||
|
private void SetupCommandBuffer() {
|
||||||
|
ClearCommandBufferCoroutine();
|
||||||
|
|
||||||
|
if(m_colorBuffer) {
|
||||||
|
if(m_opaqueOnlyColorBuffer) {
|
||||||
|
m_opaqueOnlyColorBuffer.Release();
|
||||||
|
m_afterOpaqueOnlyColorBuffer.Release();
|
||||||
|
m_reactiveMaskOutput.Release();
|
||||||
|
}
|
||||||
|
m_colorBuffer.Release();
|
||||||
|
m_fsrOutput.Release();
|
||||||
|
}
|
||||||
|
|
||||||
|
m_renderWidth = (int)(m_displayWidth / m_scaleFactor);
|
||||||
|
m_renderHeight = (int)(m_displayHeight / m_scaleFactor);
|
||||||
|
|
||||||
|
m_colorBuffer = new RenderTexture(m_renderWidth, m_renderHeight, 0, RenderTextureFormat.Default);
|
||||||
|
m_colorBuffer.Create();
|
||||||
|
m_fsrOutput = new RenderTexture(m_displayWidth, m_displayHeight, 0, m_mainCamera.allowHDR ? RenderTextureFormat.DefaultHDR : RenderTextureFormat.Default);
|
||||||
|
m_fsrOutput.enableRandomWrite = true;
|
||||||
|
m_fsrOutput.Create();
|
||||||
|
|
||||||
|
|
||||||
|
m_dispatchDescription.InputResourceSize = new Vector2Int(m_renderWidth, m_renderHeight);
|
||||||
|
m_dispatchDescription.Color = m_colorBuffer;
|
||||||
|
if(m_mainCamera.actualRenderingPath == RenderingPath.Forward) {
|
||||||
|
m_dispatchDescription.Depth = BuiltinRenderTextureType.Depth;
|
||||||
|
} else {
|
||||||
|
m_dispatchDescription.Depth = BuiltinRenderTextureType.ResolvedDepth;
|
||||||
|
}
|
||||||
|
m_dispatchDescription.MotionVectors = BuiltinRenderTextureType.MotionVectors;
|
||||||
|
m_dispatchDescription.Output = m_fsrOutput;
|
||||||
|
|
||||||
|
if(generateReactiveMask) {
|
||||||
|
m_opaqueOnlyColorBuffer = new RenderTexture(m_colorBuffer);
|
||||||
|
m_opaqueOnlyColorBuffer.Create();
|
||||||
|
m_afterOpaqueOnlyColorBuffer = new RenderTexture(m_colorBuffer);
|
||||||
|
m_afterOpaqueOnlyColorBuffer.Create();
|
||||||
|
m_reactiveMaskOutput = new RenderTexture(m_colorBuffer);
|
||||||
|
m_reactiveMaskOutput.enableRandomWrite = true;
|
||||||
|
m_reactiveMaskOutput.Create();
|
||||||
|
|
||||||
|
m_genReactiveDescription.ColorOpaqueOnly = m_opaqueOnlyColorBuffer;
|
||||||
|
m_genReactiveDescription.ColorPreUpscale = m_afterOpaqueOnlyColorBuffer;
|
||||||
|
m_genReactiveDescription.OutReactive = m_reactiveMaskOutput;
|
||||||
|
m_dispatchDescription.Reactive = m_reactiveMaskOutput;
|
||||||
|
} else {
|
||||||
|
m_genReactiveDescription.ColorOpaqueOnly = null;
|
||||||
|
m_genReactiveDescription.ColorPreUpscale = null;
|
||||||
|
m_genReactiveDescription.OutReactive = null;
|
||||||
|
m_dispatchDescription.Reactive = null;
|
||||||
|
}
|
||||||
|
//Experimental! (disabled)
|
||||||
|
if(generateTCMask) {
|
||||||
|
if(generateReactiveMask) {
|
||||||
|
m_dispatchDescription.ColorOpaqueOnly = m_reactiveMaskOutput;
|
||||||
|
} else {
|
||||||
|
m_dispatchDescription.ColorOpaqueOnly = m_opaqueOnlyColorBuffer;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
m_dispatchDescription.ColorOpaqueOnly = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(m_fsrComputePass != null) {
|
||||||
|
m_mainCamera.RemoveCommandBuffer(m_COLOR_EVENT, m_colorGrabPass);
|
||||||
|
m_mainCamera.RemoveCommandBuffer(m_FSR_EVENT, m_fsrComputePass);
|
||||||
|
m_mainCamera.RemoveCommandBuffer(m_BlITFSR_EVENT, m_blitToCamPass);
|
||||||
|
|
||||||
|
if(m_opaqueOnlyGrabPass != null) {
|
||||||
|
m_mainCamera.RemoveCommandBuffer(m_OPAQUE_ONLY_EVENT, m_opaqueOnlyGrabPass);
|
||||||
|
m_mainCamera.RemoveCommandBuffer(m_AFTER_OPAQUE_ONLY_EVENT, m_afterOpaqueOnlyGrabPass);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
m_colorGrabPass.Clear();
|
||||||
|
m_fsrComputePass.Clear();
|
||||||
|
m_blitToCamPass.Clear();
|
||||||
|
|
||||||
|
m_colorGrabPass.Blit(BuiltinRenderTextureType.CameraTarget, m_colorBuffer);
|
||||||
|
|
||||||
|
if(generateReactiveMask) {
|
||||||
|
m_opaqueOnlyGrabPass.Clear();
|
||||||
|
m_opaqueOnlyGrabPass.Blit(BuiltinRenderTextureType.CameraTarget, m_opaqueOnlyColorBuffer);
|
||||||
|
|
||||||
|
m_afterOpaqueOnlyGrabPass.Clear();
|
||||||
|
m_afterOpaqueOnlyGrabPass.Blit(BuiltinRenderTextureType.CameraTarget, m_afterOpaqueOnlyColorBuffer);
|
||||||
|
}
|
||||||
|
|
||||||
|
m_blitToCamPass.Blit(m_fsrOutput, BuiltinRenderTextureType.None);
|
||||||
|
|
||||||
|
SendMessage("OverridePPV2TargetTexture", m_colorBuffer, SendMessageOptions.DontRequireReceiver);
|
||||||
|
buildCommandBuffers = StartCoroutine(BuildCommandBuffer());
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Built-in has no way to properly order commandbuffers, so we have to add them in the order we want ourselves.
|
||||||
|
/// </summary>
|
||||||
|
private Coroutine buildCommandBuffers;
|
||||||
|
private IEnumerator BuildCommandBuffer() {
|
||||||
|
SendMessage("RemovePPV2CommandBuffers", SendMessageOptions.DontRequireReceiver);
|
||||||
|
yield return null;
|
||||||
|
if(generateReactiveMask) {
|
||||||
|
if(m_opaqueOnlyGrabPass != null) {
|
||||||
|
m_mainCamera.AddCommandBuffer(m_OPAQUE_ONLY_EVENT, m_opaqueOnlyGrabPass);
|
||||||
|
m_mainCamera.AddCommandBuffer(m_AFTER_OPAQUE_ONLY_EVENT, m_afterOpaqueOnlyGrabPass);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
yield return null;
|
||||||
|
SendMessage("AddPPV2CommandBuffer", SendMessageOptions.DontRequireReceiver);
|
||||||
|
yield return null;
|
||||||
|
if(m_fsrComputePass != null) {
|
||||||
|
m_mainCamera.AddCommandBuffer(m_COLOR_EVENT, m_colorGrabPass);
|
||||||
|
m_mainCamera.AddCommandBuffer(m_FSR_EVENT, m_fsrComputePass);
|
||||||
|
m_mainCamera.AddCommandBuffer(m_BlITFSR_EVENT, m_blitToCamPass);
|
||||||
|
}
|
||||||
|
|
||||||
|
buildCommandBuffers = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void ClearCommandBufferCoroutine() {
|
||||||
|
if(buildCommandBuffers != null) {
|
||||||
|
StopCoroutine(buildCommandBuffers);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void OnPreRenderCamera(Camera camera) {
|
||||||
|
if(camera != m_mainCamera) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Set up the parameters to auto-generate a reactive mask
|
||||||
|
if(generateReactiveMask) {
|
||||||
|
m_genReactiveDescription.RenderSize = new Vector2Int(m_renderWidth, m_renderHeight);
|
||||||
|
m_genReactiveDescription.Scale = autoReactiveScale;
|
||||||
|
m_genReactiveDescription.CutoffThreshold = autoReactiveThreshold;
|
||||||
|
m_genReactiveDescription.BinaryValue = autoReactiveBinaryValue;
|
||||||
|
m_genReactiveDescription.Flags = reactiveFlags;
|
||||||
|
}
|
||||||
|
|
||||||
|
m_dispatchDescription.Exposure = null;
|
||||||
|
m_dispatchDescription.PreExposure = 1;
|
||||||
|
m_dispatchDescription.EnableSharpening = sharpening;
|
||||||
|
m_dispatchDescription.Sharpness = sharpness;
|
||||||
|
m_dispatchDescription.MotionVectorScale.x = -m_renderWidth;
|
||||||
|
m_dispatchDescription.MotionVectorScale.y = -m_renderHeight;
|
||||||
|
m_dispatchDescription.RenderSize = new Vector2Int(m_renderWidth, m_renderHeight);
|
||||||
|
m_dispatchDescription.FrameTimeDelta = Time.deltaTime;
|
||||||
|
m_dispatchDescription.CameraNear = m_mainCamera.nearClipPlane;
|
||||||
|
m_dispatchDescription.CameraFar = m_mainCamera.farClipPlane;
|
||||||
|
m_dispatchDescription.CameraFovAngleVertical = m_mainCamera.fieldOfView * Mathf.Deg2Rad;
|
||||||
|
m_dispatchDescription.ViewSpaceToMetersFactor = 1.0f;
|
||||||
|
m_dispatchDescription.Reset = m_resetCamera;
|
||||||
|
|
||||||
|
//Experimental! (disabled)
|
||||||
|
m_dispatchDescription.EnableAutoReactive = generateTCMask;
|
||||||
|
m_dispatchDescription.AutoTcThreshold = autoTcThreshold;
|
||||||
|
m_dispatchDescription.AutoTcScale = autoTcScale;
|
||||||
|
m_dispatchDescription.AutoReactiveScale = autoReactiveScale;
|
||||||
|
m_dispatchDescription.AutoReactiveMax = autoTcReactiveMax;
|
||||||
|
|
||||||
|
m_resetCamera = false;
|
||||||
|
|
||||||
|
if(SystemInfo.usesReversedZBuffer) {
|
||||||
|
// Swap the near and far clip plane distances as FSR3 expects this when using inverted depth
|
||||||
|
(m_dispatchDescription.CameraNear, m_dispatchDescription.CameraFar) = (m_dispatchDescription.CameraFar, m_dispatchDescription.CameraNear);
|
||||||
|
}
|
||||||
|
|
||||||
|
JitterTAA();
|
||||||
|
|
||||||
|
m_mainCamera.targetTexture = m_colorBuffer;
|
||||||
|
|
||||||
|
//Check if display resolution has changed
|
||||||
|
if(m_displayWidth != Display.main.renderingWidth || m_displayHeight != Display.main.renderingHeight || m_previousHDR != m_mainCamera.allowHDR) {
|
||||||
|
SetupResolution();
|
||||||
|
}
|
||||||
|
|
||||||
|
if(m_previousScaleFactor != m_scaleFactor || m_previousReactiveMask != generateReactiveMask || m_previousTCMask != generateTCMask || m_previousRenderingPath != m_mainCamera.actualRenderingPath || !initFirstFrame) {
|
||||||
|
initFirstFrame = true;
|
||||||
|
SetupFrameBuffers();
|
||||||
|
}
|
||||||
|
UpdateDispatch();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private void OnPostRenderCamera(Camera camera) {
|
||||||
|
if(camera != m_mainCamera) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
m_mainCamera.targetTexture = null;
|
||||||
|
|
||||||
|
m_mainCamera.ResetProjectionMatrix();
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// TAA Jitter
|
||||||
|
/// </summary>
|
||||||
|
private void JitterTAA() {
|
||||||
|
|
||||||
|
int jitterPhaseCount = Fsr3.GetJitterPhaseCount(m_renderWidth, (int)(m_renderWidth * m_scaleFactor));
|
||||||
|
|
||||||
|
Fsr3.GetJitterOffset(out float jitterX, out float jitterY, Time.frameCount, jitterPhaseCount);
|
||||||
|
m_dispatchDescription.JitterOffset = new Vector2(jitterX, jitterY);
|
||||||
|
|
||||||
|
jitterX = 2.0f * jitterX / (float)m_renderWidth;
|
||||||
|
jitterY = 2.0f * jitterY / (float)m_renderHeight;
|
||||||
|
|
||||||
|
jitterX += UnityEngine.Random.Range(-0.001f * antiGhosting, 0.001f * antiGhosting);
|
||||||
|
jitterY += UnityEngine.Random.Range(-0.001f * antiGhosting, 0.001f * antiGhosting);
|
||||||
|
|
||||||
|
m_jitterMatrix = Matrix4x4.Translate(new Vector2(jitterX, jitterY));
|
||||||
|
m_projectionMatrix = m_mainCamera.projectionMatrix;
|
||||||
|
m_mainCamera.nonJitteredProjectionMatrix = m_projectionMatrix;
|
||||||
|
m_mainCamera.projectionMatrix = m_jitterMatrix * m_projectionMatrix;
|
||||||
|
m_mainCamera.useJitteredProjectionMatrixForTransparentRendering = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Creates new buffers and sends them to the plugin
|
||||||
|
/// </summary>
|
||||||
|
private void SetupFrameBuffers() {
|
||||||
|
m_previousScaleFactor = m_scaleFactor;
|
||||||
|
m_previousReactiveMask = generateReactiveMask;
|
||||||
|
m_previousTCMask = generateTCMask;
|
||||||
|
|
||||||
|
SetupCommandBuffer();
|
||||||
|
|
||||||
|
m_previousRenderingPath = m_mainCamera.actualRenderingPath;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Creates new buffers, sends them to the plugin, and reintilized FSR to adjust the display size
|
||||||
|
/// </summary>
|
||||||
|
private void SetupResolution() {
|
||||||
|
m_displayWidth = Display.main.renderingWidth;
|
||||||
|
m_displayHeight = Display.main.renderingHeight;
|
||||||
|
|
||||||
|
m_previousHDR = m_mainCamera.allowHDR;
|
||||||
|
|
||||||
|
Fsr3.InitializationFlags flags = Fsr3.InitializationFlags.EnableAutoExposure;
|
||||||
|
|
||||||
|
if(m_mainCamera.allowHDR)
|
||||||
|
flags |= Fsr3.InitializationFlags.EnableHighDynamicRange;
|
||||||
|
if(enableF16)
|
||||||
|
flags |= Fsr3.InitializationFlags.EnableFP16Usage;
|
||||||
|
|
||||||
|
if(m_context != null) {
|
||||||
|
m_context.Destroy();
|
||||||
|
m_context = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
m_context = Fsr3.CreateContext(new Vector2Int(m_displayWidth, m_displayHeight), new Vector2Int((int)(m_displayWidth), (int)(m_displayHeight)), Callbacks, flags);
|
||||||
|
|
||||||
|
SetupFrameBuffers();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void UpdateDispatch() {
|
||||||
|
if(m_fsrComputePass != null) {
|
||||||
|
m_fsrComputePass.Clear();
|
||||||
|
if(generateReactiveMask) {
|
||||||
|
m_context.GenerateReactiveMask(m_genReactiveDescription, m_fsrComputePass);
|
||||||
|
}
|
||||||
|
m_context.Dispatch(m_dispatchDescription, m_fsrComputePass);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// <inheritdoc/>
|
||||||
|
/// </summary>
|
||||||
|
protected override void DisableFSR() {
|
||||||
|
base.DisableFSR();
|
||||||
|
Camera.onPreRender -= OnPreRenderCamera;
|
||||||
|
Camera.onPostRender -= OnPostRenderCamera;
|
||||||
|
|
||||||
|
initFirstFrame = false;
|
||||||
|
|
||||||
|
ClearCommandBufferCoroutine();
|
||||||
|
SendMessage("ResetPPV2CommandBuffer", SendMessageOptions.DontRequireReceiver);
|
||||||
|
SendMessage("ResetPPV2TargetTexture", SendMessageOptions.DontRequireReceiver);
|
||||||
|
|
||||||
|
OnResetAllMipMaps();
|
||||||
|
|
||||||
|
if(m_mainCamera != null) {
|
||||||
|
m_mainCamera.targetTexture = null;
|
||||||
|
m_mainCamera.ResetProjectionMatrix();
|
||||||
|
|
||||||
|
if(m_opaqueOnlyGrabPass != null) {
|
||||||
|
m_mainCamera.RemoveCommandBuffer(m_OPAQUE_ONLY_EVENT, m_opaqueOnlyGrabPass);
|
||||||
|
m_mainCamera.RemoveCommandBuffer(m_AFTER_OPAQUE_ONLY_EVENT, m_afterOpaqueOnlyGrabPass);
|
||||||
|
}
|
||||||
|
if(m_fsrComputePass != null) {
|
||||||
|
m_mainCamera.RemoveCommandBuffer(m_COLOR_EVENT, m_colorGrabPass);
|
||||||
|
m_mainCamera.RemoveCommandBuffer(m_FSR_EVENT, m_fsrComputePass);
|
||||||
|
m_mainCamera.RemoveCommandBuffer(m_BlITFSR_EVENT, m_blitToCamPass);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
m_fsrComputePass = m_colorGrabPass = m_opaqueOnlyGrabPass = m_afterOpaqueOnlyGrabPass = m_blitToCamPass = null;
|
||||||
|
|
||||||
|
if(m_colorBuffer) {
|
||||||
|
if(m_opaqueOnlyColorBuffer) {
|
||||||
|
m_opaqueOnlyColorBuffer.Release();
|
||||||
|
m_afterOpaqueOnlyColorBuffer.Release();
|
||||||
|
m_reactiveMaskOutput.Release();
|
||||||
|
}
|
||||||
|
m_colorBuffer.Release();
|
||||||
|
m_fsrOutput.Release();
|
||||||
|
}
|
||||||
|
|
||||||
|
if(m_context != null) {
|
||||||
|
m_context.Destroy();
|
||||||
|
m_context = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
11
Assets/AEG FSR/Runtime/BIRP/FSR3_BIRP.cs.meta
Normal file
11
Assets/AEG FSR/Runtime/BIRP/FSR3_BIRP.cs.meta
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: be4c116da5e2838419f6a3014139ae82
|
||||||
|
MonoImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
@ -0,0 +1,18 @@
|
|||||||
|
{
|
||||||
|
"name": "com.alteregogames.aeg-fsr.Runtime.BIRP",
|
||||||
|
"rootNamespace": "AEG.FSR",
|
||||||
|
"references": [
|
||||||
|
"com.alteregogames.aeg-fsr.Runtime"
|
||||||
|
],
|
||||||
|
"includePlatforms": [],
|
||||||
|
"excludePlatforms": [],
|
||||||
|
"allowUnsafeCode": false,
|
||||||
|
"overrideReferences": false,
|
||||||
|
"precompiledReferences": [],
|
||||||
|
"autoReferenced": true,
|
||||||
|
"defineConstraints": [
|
||||||
|
"UNITY_BIRP"
|
||||||
|
],
|
||||||
|
"versionDefines": [],
|
||||||
|
"noEngineReferences": false
|
||||||
|
}
|
||||||
@ -0,0 +1,7 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 31d5deaa26a442749a9d3a76f80b4afa
|
||||||
|
AssemblyDefinitionImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
16
Assets/AEG FSR/Runtime/Enums.cs
Normal file
16
Assets/AEG FSR/Runtime/Enums.cs
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
using System.Collections;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using UnityEngine;
|
||||||
|
|
||||||
|
namespace AEG.FSR
|
||||||
|
{
|
||||||
|
public enum FSR_Quality
|
||||||
|
{
|
||||||
|
Off,
|
||||||
|
TemporalAntiAliasingOnly,
|
||||||
|
Quality,
|
||||||
|
Balanced,
|
||||||
|
Performance,
|
||||||
|
UltraPerformance,
|
||||||
|
}
|
||||||
|
}
|
||||||
11
Assets/AEG FSR/Runtime/Enums.cs.meta
Normal file
11
Assets/AEG FSR/Runtime/Enums.cs.meta
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 6e183616e0b3a2a428399eb209c6a3ef
|
||||||
|
MonoImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
312
Assets/AEG FSR/Runtime/FSR3_BASE.cs
Normal file
312
Assets/AEG FSR/Runtime/FSR3_BASE.cs
Normal file
@ -0,0 +1,312 @@
|
|||||||
|
using System;
|
||||||
|
using System.Runtime.InteropServices;
|
||||||
|
using System.Runtime.CompilerServices;
|
||||||
|
|
||||||
|
using UnityEngine;
|
||||||
|
using FidelityFX;
|
||||||
|
|
||||||
|
[assembly: InternalsVisibleTo("com.alteregogames.aeg-fsr.Runtime.BIRP")]
|
||||||
|
[assembly: InternalsVisibleTo("com.alteregogames.aeg-fsr.Runtime.URP")]
|
||||||
|
[assembly: InternalsVisibleTo("com.alteregogames.aeg-fsr.Runtime.HDRP")]
|
||||||
|
|
||||||
|
namespace AEG.FSR
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Base script for FSR
|
||||||
|
/// </summary>
|
||||||
|
[RequireComponent(typeof(Camera))]
|
||||||
|
public abstract class FSR3_BASE : MonoBehaviour
|
||||||
|
{
|
||||||
|
//Public Variables
|
||||||
|
public FSR_Quality FSRQuality = FSR_Quality.Balanced;
|
||||||
|
[Range(0, 1)]
|
||||||
|
public float antiGhosting = 0.0f;
|
||||||
|
public static float FSRScaleFactor;
|
||||||
|
|
||||||
|
public bool sharpening = true;
|
||||||
|
public float sharpness = 0.5f;
|
||||||
|
|
||||||
|
public bool enableF16;
|
||||||
|
public bool enableAutoExposure = true;
|
||||||
|
public bool generateReactiveMask = true;
|
||||||
|
public bool generateTCMask = false;
|
||||||
|
|
||||||
|
public float autoReactiveScale = 0.9f;
|
||||||
|
public float autoReactiveThreshold = 0.05f;
|
||||||
|
public float autoReactiveBinaryValue = 0.5f;
|
||||||
|
|
||||||
|
public float autoTcThreshold = 0.05f;
|
||||||
|
public float autoTcScale = 1f;
|
||||||
|
public float autoTcReactiveScale = 5f;
|
||||||
|
public float autoTcReactiveMax = 0.9f;
|
||||||
|
|
||||||
|
public Fsr3.GenerateReactiveFlags reactiveFlags = Fsr3.GenerateReactiveFlags.ApplyTonemap | Fsr3.GenerateReactiveFlags.ApplyThreshold | Fsr3.GenerateReactiveFlags.UseComponentsMax;
|
||||||
|
|
||||||
|
public float mipmapBiasOverride = 1.0f;
|
||||||
|
public bool autoTextureUpdate = true;
|
||||||
|
public float mipMapUpdateFrequency = 2f;
|
||||||
|
|
||||||
|
//Protected Variables
|
||||||
|
protected bool m_fsrInitialized = false;
|
||||||
|
protected Camera m_mainCamera;
|
||||||
|
|
||||||
|
protected float m_scaleFactor = 1.5f;
|
||||||
|
protected int m_renderWidth, m_renderHeight;
|
||||||
|
protected int m_displayWidth, m_displayHeight;
|
||||||
|
|
||||||
|
protected float m_nearClipPlane, m_farClipPlane, m_fieldOfView;
|
||||||
|
|
||||||
|
protected FSR_Quality m_previousFsrQuality;
|
||||||
|
protected bool m_previousHDR;
|
||||||
|
|
||||||
|
protected bool m_previousReactiveMask;
|
||||||
|
protected bool m_previousTCMask;
|
||||||
|
protected float m_previousScaleFactor;
|
||||||
|
protected RenderingPath m_previousRenderingPath;
|
||||||
|
|
||||||
|
//Mipmap variables
|
||||||
|
protected Texture[] m_allTextures;
|
||||||
|
protected ulong m_previousLength;
|
||||||
|
protected float m_mipMapBias;
|
||||||
|
protected float m_prevMipMapBias;
|
||||||
|
protected float m_mipMapTimer = float.MaxValue;
|
||||||
|
|
||||||
|
public bool m_resetCamera = false;
|
||||||
|
|
||||||
|
#region Public API
|
||||||
|
/// <summary>
|
||||||
|
/// Set FSR Quality settings.
|
||||||
|
/// Quality = 1.5, Balanced = 1.7, Performance = 2, Ultra Performance = 3
|
||||||
|
/// </summary>
|
||||||
|
public void OnSetQuality(FSR_Quality value) {
|
||||||
|
m_previousFsrQuality = value;
|
||||||
|
FSRQuality = value;
|
||||||
|
|
||||||
|
if(value == FSR_Quality.Off) {
|
||||||
|
Initialize();
|
||||||
|
DisableFSR();
|
||||||
|
m_scaleFactor = 1;
|
||||||
|
} else {
|
||||||
|
switch(value) {
|
||||||
|
case FSR_Quality.TemporalAntiAliasingOnly:
|
||||||
|
m_scaleFactor = 1.0f;
|
||||||
|
break;
|
||||||
|
case FSR_Quality.Quality:
|
||||||
|
m_scaleFactor = 1.5f;
|
||||||
|
break;
|
||||||
|
case FSR_Quality.Balanced:
|
||||||
|
m_scaleFactor = 1.7f;
|
||||||
|
break;
|
||||||
|
case FSR_Quality.Performance:
|
||||||
|
m_scaleFactor = 2.0f;
|
||||||
|
break;
|
||||||
|
case FSR_Quality.UltraPerformance:
|
||||||
|
m_scaleFactor = 3.0f;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
Initialize();
|
||||||
|
}
|
||||||
|
FSRScaleFactor = m_scaleFactor;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void OnSetAdaptiveQuality(float _value) {
|
||||||
|
m_scaleFactor = _value;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Checks wether FSR is compatible using the current build settings
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
|
public bool OnIsSupported() {
|
||||||
|
bool fsr2Compatible = SystemInfo.supportsComputeShaders;
|
||||||
|
enableF16 = SystemInfo.IsFormatSupported(UnityEngine.Experimental.Rendering.GraphicsFormat.R16_SFloat, UnityEngine.Experimental.Rendering.FormatUsage.Render);
|
||||||
|
|
||||||
|
return fsr2Compatible;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Resets the camera for the next frame, clearing all the buffers saved from previous frames in order to prevent artifacts.
|
||||||
|
/// Should be called in or before PreRender oh the frame where the camera makes a jumpcut.
|
||||||
|
/// Is automatically disabled the frame after.
|
||||||
|
/// </summary>
|
||||||
|
public void OnResetCamera() {
|
||||||
|
m_resetCamera = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Updates a single texture to the set MipMap Bias.
|
||||||
|
/// Should be called when an object is instantiated, or when the ScaleFactor is changed.
|
||||||
|
/// </summary>
|
||||||
|
public void OnMipmapSingleTexture(Texture texture) {
|
||||||
|
texture.mipMapBias = m_mipMapBias;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Updates all textures currently loaded to the set MipMap Bias.
|
||||||
|
/// Should be called when a lot of new textures are loaded, or when the ScaleFactor is changed.
|
||||||
|
/// </summary>
|
||||||
|
public void OnMipMapAllTextures() {
|
||||||
|
m_allTextures = Resources.FindObjectsOfTypeAll(typeof(Texture)) as Texture[];
|
||||||
|
for(int i = 0; i < m_allTextures.Length; i++) {
|
||||||
|
m_allTextures[i].mipMapBias = m_mipMapBias;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// Resets all currently loaded textures to the default mipmap bias.
|
||||||
|
/// </summary>
|
||||||
|
public void OnResetAllMipMaps() {
|
||||||
|
m_prevMipMapBias = -1;
|
||||||
|
|
||||||
|
m_allTextures = Resources.FindObjectsOfTypeAll(typeof(Texture)) as Texture[];
|
||||||
|
for(int i = 0; i < m_allTextures.Length; i++) {
|
||||||
|
m_allTextures[i].mipMapBias = 0;
|
||||||
|
}
|
||||||
|
m_allTextures = null;
|
||||||
|
}
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
protected virtual void Initialize() {
|
||||||
|
bool fsr2Compatible = OnIsSupported();
|
||||||
|
|
||||||
|
//Reset mipmap timer so mipmap are instantly updated if automatic mip map is turned on
|
||||||
|
m_mipMapTimer = float.MaxValue;
|
||||||
|
|
||||||
|
if(m_fsrInitialized || !Application.isPlaying) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if(fsr2Compatible) {
|
||||||
|
InitializeFSR();
|
||||||
|
m_fsrInitialized = true;
|
||||||
|
} else {
|
||||||
|
Debug.LogWarning($"FSR 2 is not supported");
|
||||||
|
enabled = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Initializes everything in order to run FSR
|
||||||
|
/// </summary>
|
||||||
|
protected virtual void InitializeFSR() {
|
||||||
|
m_mainCamera = GetComponent<Camera>();
|
||||||
|
}
|
||||||
|
|
||||||
|
protected virtual void OnEnable() {
|
||||||
|
#if AMD_FIDELITY_FSR3_DEBUG
|
||||||
|
RegisterDebugCallback(OnDebugCallback);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
OnSetQuality(FSRQuality);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected virtual void Update() {
|
||||||
|
if(m_previousFsrQuality != FSRQuality) {
|
||||||
|
OnSetQuality(FSRQuality);
|
||||||
|
}
|
||||||
|
|
||||||
|
if(!m_fsrInitialized) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
#if UNITY_BIRP
|
||||||
|
if(autoTextureUpdate) {
|
||||||
|
UpdateMipMaps();
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
protected virtual void OnDisable() {
|
||||||
|
DisableFSR();
|
||||||
|
}
|
||||||
|
|
||||||
|
protected virtual void OnDestroy() {
|
||||||
|
DisableFSR();
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Disables FSR and cleans up
|
||||||
|
/// </summary>
|
||||||
|
protected virtual void DisableFSR() {
|
||||||
|
m_fsrInitialized = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#region Automatic Mip Map
|
||||||
|
#if UNITY_BIRP
|
||||||
|
/// <summary>
|
||||||
|
/// Automatically updates the mipmap of all loaded textures
|
||||||
|
/// </summary>
|
||||||
|
protected void UpdateMipMaps() {
|
||||||
|
m_mipMapTimer += Time.deltaTime;
|
||||||
|
|
||||||
|
if(m_mipMapTimer > mipMapUpdateFrequency) {
|
||||||
|
m_mipMapTimer = 0;
|
||||||
|
|
||||||
|
m_mipMapBias = (Mathf.Log((float)(m_renderWidth) / (float)(m_displayWidth), 2f) - 1) * mipmapBiasOverride;
|
||||||
|
|
||||||
|
if(m_previousLength != Texture.currentTextureMemory || m_prevMipMapBias != m_mipMapBias) {
|
||||||
|
m_prevMipMapBias = m_mipMapBias;
|
||||||
|
m_previousLength = Texture.currentTextureMemory;
|
||||||
|
|
||||||
|
OnMipMapAllTextures();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
|
||||||
|
#region Debug
|
||||||
|
|
||||||
|
#if AMD_FIDELITY_FSR3_DEBUG
|
||||||
|
/// <summary>
|
||||||
|
/// Register a callback to send debugging information
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="cb"></param>
|
||||||
|
[DllImport(m_DLL, CallingConvention = CallingConvention.Cdecl)]
|
||||||
|
static extern void RegisterDebugCallback(debugCallback cb);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Delegate for a debug callback
|
||||||
|
/// </summary>
|
||||||
|
delegate void debugCallback(IntPtr request, int messageType, int color, int size);
|
||||||
|
enum Color { red, green, blue, black, white, yellow, orange };
|
||||||
|
enum MessageType { Error, Warning, Info };
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Callback for debug messages send from the plugin
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="request">Debug message</param>
|
||||||
|
/// <param name="messageType">Message type</param>
|
||||||
|
/// <param name="color">Color to use in the console</param>
|
||||||
|
/// <param name="size">Size of the string</param>
|
||||||
|
static void OnDebugCallback(IntPtr request, int messageType, int color, int size)
|
||||||
|
{
|
||||||
|
//Ptr to string
|
||||||
|
string debug_string = Marshal.PtrToStringAnsi(request, size);
|
||||||
|
|
||||||
|
//Add Specified Color
|
||||||
|
debug_string =
|
||||||
|
String.Format("{0}{1}{2}",
|
||||||
|
$"<color={(Color)color}>",
|
||||||
|
debug_string,
|
||||||
|
"</color>"
|
||||||
|
);
|
||||||
|
|
||||||
|
switch ((MessageType)messageType)
|
||||||
|
{
|
||||||
|
case MessageType.Error:
|
||||||
|
Debug.LogError(debug_string);
|
||||||
|
break;
|
||||||
|
case MessageType.Warning:
|
||||||
|
Debug.LogWarning(debug_string);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
Debug.Log(debug_string);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
#endregion
|
||||||
|
}
|
||||||
|
}
|
||||||
11
Assets/AEG FSR/Runtime/FSR3_BASE.cs.meta
Normal file
11
Assets/AEG FSR/Runtime/FSR3_BASE.cs.meta
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 270ff55c81825d04e992a41dc662766a
|
||||||
|
MonoImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
8
Assets/AEG FSR/Runtime/Plugins.meta
Normal file
8
Assets/AEG FSR/Runtime/Plugins.meta
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 59fd08c4d986c3f4eb0b9f256856db2a
|
||||||
|
folderAsset: yes
|
||||||
|
DefaultImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
8
Assets/AEG FSR/Runtime/Plugins/Resources.meta
Normal file
8
Assets/AEG FSR/Runtime/Plugins/Resources.meta
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: e9f0008aec6b7a64eb49f90e1a8e3c18
|
||||||
|
folderAsset: yes
|
||||||
|
DefaultImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
8
Assets/AEG FSR/Runtime/Plugins/Resources/FSR1.meta
Normal file
8
Assets/AEG FSR/Runtime/Plugins/Resources/FSR1.meta
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 48842dea9c7003c4db12eef2194986fb
|
||||||
|
folderAsset: yes
|
||||||
|
DefaultImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
@ -0,0 +1,73 @@
|
|||||||
|
#pragma kernel KMain
|
||||||
|
#pragma kernel KInitialize
|
||||||
|
|
||||||
|
#define A_GPU 1
|
||||||
|
#define A_HLSL 1
|
||||||
|
#define FSR_EASU_F 1
|
||||||
|
|
||||||
|
#define float float
|
||||||
|
#define float2 float2
|
||||||
|
#define float3 float3
|
||||||
|
#define float4 float4
|
||||||
|
|
||||||
|
#include "ffx_a.hlsl"
|
||||||
|
|
||||||
|
|
||||||
|
RWStructuredBuffer<uint4> _EASUParameters;
|
||||||
|
|
||||||
|
float4 _EASUViewportSize;
|
||||||
|
float4 _EASUInputImageSize;
|
||||||
|
float4 _EASUOutputSize;
|
||||||
|
|
||||||
|
SamplerState s_linear_clamp_sampler;
|
||||||
|
Texture2D<AF4> InputTexture;
|
||||||
|
RWTexture2D<AF4> OutputTexture;
|
||||||
|
|
||||||
|
AF4 FsrEasuRF(AF2 p) { AF4 res = InputTexture.GatherRed(s_linear_clamp_sampler, p, ASU2(0, 0)); return res; }
|
||||||
|
AF4 FsrEasuGF(AF2 p) { AF4 res = InputTexture.GatherGreen(s_linear_clamp_sampler, p, ASU2(0, 0)); return res; }
|
||||||
|
AF4 FsrEasuBF(AF2 p) { AF4 res = InputTexture.GatherBlue(s_linear_clamp_sampler, p, ASU2(0, 0)); return res; }
|
||||||
|
|
||||||
|
#include "ffx_fsr1.hlsl"
|
||||||
|
//#include "UnityCG.cginc"
|
||||||
|
|
||||||
|
void Upscale(AU2 pos) {
|
||||||
|
AF3 c;
|
||||||
|
FsrEasuF(c.rgb, pos, _EASUParameters[0], _EASUParameters[1], _EASUParameters[2], _EASUParameters[3]);
|
||||||
|
OutputTexture[pos] = AF4(c, 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
//Main
|
||||||
|
[numthreads(64, 1, 1)]
|
||||||
|
void KMain(uint3 LocalThreadId : SV_GroupThreadID, uint3 WorkGroupId : SV_GroupID, uint3 dispatchThreadId : SV_DispatchThreadID)
|
||||||
|
{
|
||||||
|
// Do remapping of local xy in workgroup for a more PS-like swizzle pattern.
|
||||||
|
AU2 gxy = ARmp8x8(LocalThreadId.x) + AU2(WorkGroupId.x<<3u, WorkGroupId.y<<3u);
|
||||||
|
|
||||||
|
#ifdef _ALPHA
|
||||||
|
float2 uv = ((float2)gxy.xy + 0.5) * _EASUOutputSize.zw;
|
||||||
|
float alpha = InputImage.SampleLevel(s_linear_clamp_sampler, ClampAndScaleUVForBilinear(uv), 0).a;
|
||||||
|
#else
|
||||||
|
float alpha = 1.0;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
Upscale(gxy);
|
||||||
|
}
|
||||||
|
|
||||||
|
//Init
|
||||||
|
[numthreads(1,1,1)]
|
||||||
|
void KInitialize()
|
||||||
|
{
|
||||||
|
AU4 con0 = (AU4)0;
|
||||||
|
AU4 con1 = (AU4)0;
|
||||||
|
AU4 con2 = (AU4)0;
|
||||||
|
AU4 con3 = (AU4)0;
|
||||||
|
FsrEasuCon(con0,con1,con2,con3,
|
||||||
|
_EASUViewportSize.x, _EASUViewportSize.y,
|
||||||
|
_EASUInputImageSize.x,_EASUInputImageSize.y,
|
||||||
|
_EASUOutputSize.x, _EASUOutputSize.y);
|
||||||
|
|
||||||
|
_EASUParameters[0] = con0;
|
||||||
|
_EASUParameters[1] = con1;
|
||||||
|
_EASUParameters[2] = con2;
|
||||||
|
_EASUParameters[3] = con3;
|
||||||
|
}
|
||||||
@ -0,0 +1,8 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 4b4ecaf3c46dfc545be5f6c2e858f12c
|
||||||
|
ComputeShaderImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
currentAPIMask: 4194308
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
19
Assets/AEG FSR/Runtime/Plugins/Resources/FSR1/LICENSE.txt
Normal file
19
Assets/AEG FSR/Runtime/Plugins/Resources/FSR1/LICENSE.txt
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
// Copyright (c) 2021 Advanced Micro Devices, Inc. All rights reserved.
|
||||||
|
|
||||||
|
// 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.
|
||||||
@ -0,0 +1,7 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 260d0d882c7ad0d41a7df2bc5a3cf5f1
|
||||||
|
TextScriptImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
@ -0,0 +1,57 @@
|
|||||||
|
#pragma kernel KMain
|
||||||
|
#pragma kernel KInitialize
|
||||||
|
|
||||||
|
#define A_GPU 1
|
||||||
|
#define A_HLSL 1
|
||||||
|
#define FSR_RCAS_F 1
|
||||||
|
|
||||||
|
#define float float
|
||||||
|
#define float2 float2
|
||||||
|
#define float3 float3
|
||||||
|
#define float4 float4
|
||||||
|
|
||||||
|
#include "ffx_a.hlsl"
|
||||||
|
|
||||||
|
RWStructuredBuffer<uint4> _RCASParameters;
|
||||||
|
|
||||||
|
float _RCASScale;
|
||||||
|
|
||||||
|
SamplerState samLinearClamp;
|
||||||
|
Texture2D<AF4> InputTexture;
|
||||||
|
RWTexture2D<AF4> OutputTexture;
|
||||||
|
|
||||||
|
AF4 FsrRcasLoadF(ASU2 p) { return InputTexture.Load(int3(ASU2(p), 0)); }
|
||||||
|
void FsrRcasInputF(inout AF1 r, inout AF1 g, inout AF1 b) {}
|
||||||
|
|
||||||
|
#include "ffx_fsr1.hlsl"
|
||||||
|
//#include "UnityCG.cginc"
|
||||||
|
|
||||||
|
void Sharpen(AU2 pos) {
|
||||||
|
AF3 c;
|
||||||
|
FsrRcasF(c.r, c.g, c.b, pos, _RCASParameters[0]);
|
||||||
|
OutputTexture[pos] = AF4(c, 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
//Main
|
||||||
|
[numthreads(64, 1, 1)]
|
||||||
|
void KMain(uint3 LocalThreadId : SV_GroupThreadID, uint3 WorkGroupId : SV_GroupID, uint3 dispatchThreadId : SV_DispatchThreadID)
|
||||||
|
{
|
||||||
|
// Do remapping of local xy in workgroup for a more PS-like swizzle pattern.
|
||||||
|
AU2 gxy = ARmp8x8(LocalThreadId.x) + AU2(WorkGroupId.x << 3u, WorkGroupId.y << 3u);
|
||||||
|
#ifdef _ALPHA
|
||||||
|
float alpha = InputImage.SampleLevel(s_linear_clamp_sampler, gxy.xy, 0).a;
|
||||||
|
#else
|
||||||
|
float alpha = 1.0;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
Sharpen(gxy);
|
||||||
|
}
|
||||||
|
|
||||||
|
//Init
|
||||||
|
[numthreads(1,1,1)]
|
||||||
|
void KInitialize()
|
||||||
|
{
|
||||||
|
AU4 con;
|
||||||
|
FsrRcasCon(con, _RCASScale);
|
||||||
|
_RCASParameters[0] = con;
|
||||||
|
}
|
||||||
@ -0,0 +1,8 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 9cbfc0f225930d149ba504b5bd5906aa
|
||||||
|
ComputeShaderImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
currentAPIMask: 4194308
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
2656
Assets/AEG FSR/Runtime/Plugins/Resources/FSR1/ffx_a.hlsl
Normal file
2656
Assets/AEG FSR/Runtime/Plugins/Resources/FSR1/ffx_a.hlsl
Normal file
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,9 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: a1f876d966449794bbb092962d2d7fc9
|
||||||
|
ShaderImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
defaultTextures: []
|
||||||
|
nonModifiableTextures: []
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
1199
Assets/AEG FSR/Runtime/Plugins/Resources/FSR1/ffx_fsr1.hlsl
Normal file
1199
Assets/AEG FSR/Runtime/Plugins/Resources/FSR1/ffx_fsr1.hlsl
Normal file
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,9 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 68ca247feb098b247b34478c0d6e1712
|
||||||
|
ShaderImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
defaultTextures: []
|
||||||
|
nonModifiableTextures: []
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
8
Assets/AEG FSR/Runtime/Plugins/Resources/FSR3.meta
Normal file
8
Assets/AEG FSR/Runtime/Plugins/Resources/FSR3.meta
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 3915f68f4f2254b4b80980d89504c01d
|
||||||
|
folderAsset: yes
|
||||||
|
DefaultImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
@ -0,0 +1,41 @@
|
|||||||
|
// Copyright (c) 2023 Nico de Poel
|
||||||
|
//
|
||||||
|
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
// of this software and associated documentation files (the "Software"), to deal
|
||||||
|
// in the Software without restriction, including without limitation the rights
|
||||||
|
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
// copies of the Software, and to permit persons to whom the Software is
|
||||||
|
// furnished to do so, subject to the following conditions:
|
||||||
|
//
|
||||||
|
// The above copyright notice and this permission notice shall be included in all
|
||||||
|
// copies or substantial portions of the Software.
|
||||||
|
//
|
||||||
|
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||||
|
// THE SOFTWARE.
|
||||||
|
|
||||||
|
#pragma kernel CS
|
||||||
|
|
||||||
|
#pragma multi_compile_local __ FFX_HALF
|
||||||
|
#pragma multi_compile_local __ FFX_FSR3UPSCALER_OPTION_REPROJECT_USE_LANCZOS_TYPE
|
||||||
|
#pragma multi_compile_local __ FFX_FSR3UPSCALER_OPTION_HDR_COLOR_INPUT
|
||||||
|
#pragma multi_compile_local __ FFX_FSR3UPSCALER_OPTION_LOW_RESOLUTION_MOTION_VECTORS
|
||||||
|
#pragma multi_compile_local __ FFX_FSR3UPSCALER_OPTION_JITTERED_MOTION_VECTORS
|
||||||
|
#pragma multi_compile_local __ FFX_FSR3UPSCALER_OPTION_INVERTED_DEPTH
|
||||||
|
#pragma multi_compile_local __ FFX_FSR3UPSCALER_OPTION_APPLY_SHARPENING
|
||||||
|
|
||||||
|
#pragma multi_compile_local __ UNITY_FSR3UPSCALER_HDRP
|
||||||
|
|
||||||
|
#include "ffx_fsr3upscaler_unity_common.cginc"
|
||||||
|
|
||||||
|
// Ensure the correct value is defined for this keyword, as it is used to select one of multiple sampler functions
|
||||||
|
#ifdef FFX_FSR3UPSCALER_OPTION_REPROJECT_USE_LANCZOS_TYPE
|
||||||
|
#undef FFX_FSR3UPSCALER_OPTION_REPROJECT_USE_LANCZOS_TYPE
|
||||||
|
#define FFX_FSR3UPSCALER_OPTION_REPROJECT_USE_LANCZOS_TYPE 1
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include "shaders/ffx_fsr3upscaler_accumulate_pass.hlsl"
|
||||||
@ -0,0 +1,8 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: c9b45f0ae7673694ba57a4aadfe212e9
|
||||||
|
ComputeShaderImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
preprocessorOverride: 0
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
@ -0,0 +1,32 @@
|
|||||||
|
// Copyright (c) 2023 Nico de Poel
|
||||||
|
//
|
||||||
|
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
// of this software and associated documentation files (the "Software"), to deal
|
||||||
|
// in the Software without restriction, including without limitation the rights
|
||||||
|
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
// copies of the Software, and to permit persons to whom the Software is
|
||||||
|
// furnished to do so, subject to the following conditions:
|
||||||
|
//
|
||||||
|
// The above copyright notice and this permission notice shall be included in all
|
||||||
|
// copies or substantial portions of the Software.
|
||||||
|
//
|
||||||
|
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||||
|
// THE SOFTWARE.
|
||||||
|
|
||||||
|
#pragma kernel CS
|
||||||
|
|
||||||
|
#pragma multi_compile_local __ FFX_HALF
|
||||||
|
#pragma multi_compile_local __ FFX_FSR3UPSCALER_OPTION_LOW_RESOLUTION_MOTION_VECTORS
|
||||||
|
#pragma multi_compile_local __ FFX_FSR3UPSCALER_OPTION_JITTERED_MOTION_VECTORS
|
||||||
|
#pragma multi_compile_local __ FFX_FSR3UPSCALER_OPTION_INVERTED_DEPTH
|
||||||
|
|
||||||
|
#pragma multi_compile_local __ UNITY_FSR3UPSCALER_HDRP
|
||||||
|
|
||||||
|
#include "ffx_fsr3upscaler_unity_common.cginc"
|
||||||
|
|
||||||
|
#include "shaders/ffx_fsr3upscaler_autogen_reactive_pass.hlsl"
|
||||||
@ -0,0 +1,8 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 5716b91fdaa4e9e439df6b96a796fe6e
|
||||||
|
ComputeShaderImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
preprocessorOverride: 0
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
@ -0,0 +1,42 @@
|
|||||||
|
// Copyright (c) 2023 Nico de Poel
|
||||||
|
//
|
||||||
|
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
// of this software and associated documentation files (the "Software"), to deal
|
||||||
|
// in the Software without restriction, including without limitation the rights
|
||||||
|
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
// copies of the Software, and to permit persons to whom the Software is
|
||||||
|
// furnished to do so, subject to the following conditions:
|
||||||
|
//
|
||||||
|
// The above copyright notice and this permission notice shall be included in all
|
||||||
|
// copies or substantial portions of the Software.
|
||||||
|
//
|
||||||
|
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||||
|
// THE SOFTWARE.
|
||||||
|
|
||||||
|
#pragma kernel CS
|
||||||
|
|
||||||
|
#pragma multi_compile_local __ FFX_HALF
|
||||||
|
#pragma multi_compile_local __ FFX_FSR3UPSCALER_OPTION_LOW_RESOLUTION_MOTION_VECTORS
|
||||||
|
#pragma multi_compile_local __ FFX_FSR3UPSCALER_OPTION_JITTERED_MOTION_VECTORS
|
||||||
|
#pragma multi_compile_local __ FFX_FSR3UPSCALER_OPTION_INVERTED_DEPTH
|
||||||
|
|
||||||
|
#pragma multi_compile_local __ UNITY_FSR3UPSCALER_HDRP
|
||||||
|
|
||||||
|
#include "ffx_fsr3upscaler_unity_common.cginc"
|
||||||
|
|
||||||
|
// Wave operations require shader model 6.0; this can only be enabled when using DXC on D3D12
|
||||||
|
// These pragmas are commented out by default as Unity will sometimes ignore the #if's and try to enable these features anyway.
|
||||||
|
// Uncomment the below lines if you intend to try wave operations on DX12 with the DXC compiler.
|
||||||
|
//#if defined(UNITY_COMPILER_DXC) && defined(SHADER_API_D3D12)
|
||||||
|
//#pragma require WaveBasic // Required for WaveGetLaneIndex
|
||||||
|
//#pragma require WaveBallot // Required for WaveReadLaneAt
|
||||||
|
//#else
|
||||||
|
#define FFX_SPD_NO_WAVE_OPERATIONS
|
||||||
|
//#endif
|
||||||
|
|
||||||
|
#include "shaders/ffx_fsr3upscaler_compute_luminance_pyramid_pass.hlsl"
|
||||||
@ -0,0 +1,8 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: d253be05abcdc80428503d3e4cce3a36
|
||||||
|
ComputeShaderImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
preprocessorOverride: 0
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
@ -0,0 +1,32 @@
|
|||||||
|
// Copyright (c) 2023 Nico de Poel
|
||||||
|
//
|
||||||
|
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
// of this software and associated documentation files (the "Software"), to deal
|
||||||
|
// in the Software without restriction, including without limitation the rights
|
||||||
|
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
// copies of the Software, and to permit persons to whom the Software is
|
||||||
|
// furnished to do so, subject to the following conditions:
|
||||||
|
//
|
||||||
|
// The above copyright notice and this permission notice shall be included in all
|
||||||
|
// copies or substantial portions of the Software.
|
||||||
|
//
|
||||||
|
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||||
|
// THE SOFTWARE.
|
||||||
|
|
||||||
|
#pragma kernel CS
|
||||||
|
|
||||||
|
#pragma multi_compile_local __ FFX_HALF
|
||||||
|
#pragma multi_compile_local __ FFX_FSR3UPSCALER_OPTION_LOW_RESOLUTION_MOTION_VECTORS
|
||||||
|
#pragma multi_compile_local __ FFX_FSR3UPSCALER_OPTION_JITTERED_MOTION_VECTORS
|
||||||
|
#pragma multi_compile_local __ FFX_FSR3UPSCALER_OPTION_INVERTED_DEPTH
|
||||||
|
|
||||||
|
#pragma multi_compile_local __ UNITY_FSR3UPSCALER_HDRP
|
||||||
|
|
||||||
|
#include "ffx_fsr3upscaler_unity_common.cginc"
|
||||||
|
|
||||||
|
#include "shaders/ffx_fsr3upscaler_depth_clip_pass.hlsl"
|
||||||
@ -0,0 +1,8 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 20e44016ed34b0d4b8de499d1b566c69
|
||||||
|
ComputeShaderImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
preprocessorOverride: 0
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
@ -0,0 +1,30 @@
|
|||||||
|
// Copyright (c) 2023 Nico de Poel
|
||||||
|
//
|
||||||
|
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
// of this software and associated documentation files (the "Software"), to deal
|
||||||
|
// in the Software without restriction, including without limitation the rights
|
||||||
|
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
// copies of the Software, and to permit persons to whom the Software is
|
||||||
|
// furnished to do so, subject to the following conditions:
|
||||||
|
//
|
||||||
|
// The above copyright notice and this permission notice shall be included in all
|
||||||
|
// copies or substantial portions of the Software.
|
||||||
|
//
|
||||||
|
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||||
|
// THE SOFTWARE.
|
||||||
|
|
||||||
|
#pragma kernel CS
|
||||||
|
|
||||||
|
#pragma multi_compile_local __ FFX_HALF
|
||||||
|
#pragma multi_compile_local __ FFX_FSR3UPSCALER_OPTION_LOW_RESOLUTION_MOTION_VECTORS
|
||||||
|
#pragma multi_compile_local __ FFX_FSR3UPSCALER_OPTION_JITTERED_MOTION_VECTORS
|
||||||
|
#pragma multi_compile_local __ FFX_FSR3UPSCALER_OPTION_INVERTED_DEPTH
|
||||||
|
|
||||||
|
#include "ffx_fsr3upscaler_unity_common.cginc"
|
||||||
|
|
||||||
|
#include "shaders/ffx_fsr3upscaler_lock_pass.hlsl"
|
||||||
@ -0,0 +1,8 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: a135306e6d1857e43a86ef20db2a47fe
|
||||||
|
ComputeShaderImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
preprocessorOverride: 0
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
@ -0,0 +1,31 @@
|
|||||||
|
// Copyright (c) 2023 Nico de Poel
|
||||||
|
//
|
||||||
|
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
// of this software and associated documentation files (the "Software"), to deal
|
||||||
|
// in the Software without restriction, including without limitation the rights
|
||||||
|
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
// copies of the Software, and to permit persons to whom the Software is
|
||||||
|
// furnished to do so, subject to the following conditions:
|
||||||
|
//
|
||||||
|
// The above copyright notice and this permission notice shall be included in all
|
||||||
|
// copies or substantial portions of the Software.
|
||||||
|
//
|
||||||
|
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||||
|
// THE SOFTWARE.
|
||||||
|
|
||||||
|
#pragma kernel CS
|
||||||
|
|
||||||
|
#pragma multi_compile_local __ FFX_FSR3UPSCALER_OPTION_LOW_RESOLUTION_MOTION_VECTORS
|
||||||
|
#pragma multi_compile_local __ FFX_FSR3UPSCALER_OPTION_JITTERED_MOTION_VECTORS
|
||||||
|
#pragma multi_compile_local __ FFX_FSR3UPSCALER_OPTION_INVERTED_DEPTH
|
||||||
|
|
||||||
|
#pragma multi_compile_local __ UNITY_FSR3UPSCALER_HDRP
|
||||||
|
|
||||||
|
#include "ffx_fsr3upscaler_unity_common.cginc"
|
||||||
|
|
||||||
|
#include "shaders/ffx_fsr3upscaler_rcas_pass.hlsl"
|
||||||
@ -0,0 +1,8 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 7aaf5cfff022de2499e9b0412f947f6c
|
||||||
|
ComputeShaderImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
preprocessorOverride: 0
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
@ -0,0 +1,33 @@
|
|||||||
|
// Copyright (c) 2023 Nico de Poel
|
||||||
|
//
|
||||||
|
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
// of this software and associated documentation files (the "Software"), to deal
|
||||||
|
// in the Software without restriction, including without limitation the rights
|
||||||
|
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
// copies of the Software, and to permit persons to whom the Software is
|
||||||
|
// furnished to do so, subject to the following conditions:
|
||||||
|
//
|
||||||
|
// The above copyright notice and this permission notice shall be included in all
|
||||||
|
// copies or substantial portions of the Software.
|
||||||
|
//
|
||||||
|
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||||
|
// THE SOFTWARE.
|
||||||
|
|
||||||
|
#pragma kernel CS
|
||||||
|
|
||||||
|
#pragma multi_compile_local __ FFX_HALF
|
||||||
|
#pragma multi_compile_local __ FFX_FSR3UPSCALER_OPTION_HDR_COLOR_INPUT
|
||||||
|
#pragma multi_compile_local __ FFX_FSR3UPSCALER_OPTION_LOW_RESOLUTION_MOTION_VECTORS
|
||||||
|
#pragma multi_compile_local __ FFX_FSR3UPSCALER_OPTION_JITTERED_MOTION_VECTORS
|
||||||
|
#pragma multi_compile_local __ FFX_FSR3UPSCALER_OPTION_INVERTED_DEPTH
|
||||||
|
|
||||||
|
#pragma multi_compile_local __ UNITY_FSR3UPSCALER_HDRP
|
||||||
|
|
||||||
|
#include "ffx_fsr3upscaler_unity_common.cginc"
|
||||||
|
|
||||||
|
#include "shaders/ffx_fsr3upscaler_reconstruct_previous_depth_pass.hlsl"
|
||||||
@ -0,0 +1,8 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 4f59e5b9179d74844ae06a30ae1e0629
|
||||||
|
ComputeShaderImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
preprocessorOverride: 0
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
@ -0,0 +1,32 @@
|
|||||||
|
// Copyright (c) 2023 Nico de Poel
|
||||||
|
//
|
||||||
|
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
// of this software and associated documentation files (the "Software"), to deal
|
||||||
|
// in the Software without restriction, including without limitation the rights
|
||||||
|
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
// copies of the Software, and to permit persons to whom the Software is
|
||||||
|
// furnished to do so, subject to the following conditions:
|
||||||
|
//
|
||||||
|
// The above copyright notice and this permission notice shall be included in all
|
||||||
|
// copies or substantial portions of the Software.
|
||||||
|
//
|
||||||
|
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||||
|
// THE SOFTWARE.
|
||||||
|
|
||||||
|
#pragma kernel CS
|
||||||
|
|
||||||
|
#pragma multi_compile_local __ FFX_HALF
|
||||||
|
#pragma multi_compile_local __ FFX_FSR3UPSCALER_OPTION_LOW_RESOLUTION_MOTION_VECTORS
|
||||||
|
#pragma multi_compile_local __ FFX_FSR3UPSCALER_OPTION_JITTERED_MOTION_VECTORS
|
||||||
|
#pragma multi_compile_local __ FFX_FSR3UPSCALER_OPTION_INVERTED_DEPTH
|
||||||
|
|
||||||
|
#pragma multi_compile_local __ UNITY_FSR3UPSCALER_HDRP
|
||||||
|
|
||||||
|
#include "ffx_fsr3upscaler_unity_common.cginc"
|
||||||
|
|
||||||
|
#include "shaders/ffx_fsr3upscaler_tcr_autogen_pass.hlsl"
|
||||||
@ -0,0 +1,8 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 75cdc6ef23f08ed498d4da511923fcea
|
||||||
|
ComputeShaderImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
preprocessorOverride: 0
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
@ -0,0 +1,82 @@
|
|||||||
|
// Copyright (c) 2023 Nico de Poel
|
||||||
|
//
|
||||||
|
// 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.
|
||||||
|
|
||||||
|
// Suppress a few warnings produced by FFX's HLSL code
|
||||||
|
#pragma warning(disable: 3078) // Loop control variable conflicts
|
||||||
|
#pragma warning(disable: 3203) // Signed/unsigned mismatch
|
||||||
|
|
||||||
|
#define FFX_GPU // Compiling for GPU
|
||||||
|
#define FFX_HLSL // Compile for plain HLSL
|
||||||
|
|
||||||
|
// Use the DXC shader compiler on modern graphics APIs to enable a few advanced features
|
||||||
|
// The DXC-related pragmas are disabled by default, as DXC doesn't support all platforms yet and will break on some platforms when enabled.
|
||||||
|
// Consider this to be an experimental feature. If you want to benefit from 16-bit floating point and wave operations, and don't care about supporting older graphics APIs, then it's worth a try.
|
||||||
|
//#if defined(SHADER_API_D3D12) || defined(SHADER_API_VULKAN) || defined(SHADER_API_METAL)
|
||||||
|
//#pragma use_dxc // Using DXC will currently break DX11 support since DX11 and DX12 share the same shader bytecode in Unity.
|
||||||
|
//#endif
|
||||||
|
|
||||||
|
// Enable half precision data types on platforms that support it
|
||||||
|
//#if defined(UNITY_COMPILER_DXC) && defined(FFX_HALF)
|
||||||
|
//#pragma require Native16Bit
|
||||||
|
//#endif
|
||||||
|
|
||||||
|
// Hack to work around the lack of texture atomics on Metal
|
||||||
|
#if defined(SHADER_API_METAL)
|
||||||
|
#define InterlockedAdd(dest, val, orig) { (orig) = (dest); (dest) += (val); }
|
||||||
|
#define InterlockedMin(dest, val) { (dest) = min((dest), (val)); }
|
||||||
|
#define InterlockedMax(dest, val) { (dest) = max((dest), (val)); }
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// Workaround for HDRP using texture arrays for its camera buffers on some platforms
|
||||||
|
// The below defines are copied from: Packages/com.unity.render-pipelines.high-definition/Runtime/ShaderLibrary/TextureXR.hlsl
|
||||||
|
#if defined(UNITY_FSR3UPSCALER_HDRP)
|
||||||
|
// Must be in sync with C# with property useTexArray in TextureXR.cs
|
||||||
|
#if ((defined(SHADER_API_D3D11) || defined(SHADER_API_D3D12)) && !defined(SHADER_API_XBOXONE) && !defined(SHADER_API_GAMECORE)) || defined(SHADER_API_PSSL) || defined(SHADER_API_VULKAN)
|
||||||
|
#define UNITY_TEXTURE2D_X_ARRAY_SUPPORTED
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// Control if TEXTURE2D_X macros will expand to texture arrays
|
||||||
|
#if defined(UNITY_TEXTURE2D_X_ARRAY_SUPPORTED) && !defined(DISABLE_TEXTURE2D_X_ARRAY)
|
||||||
|
#define USE_TEXTURE2D_X_AS_ARRAY
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// Early defines for single-pass instancing
|
||||||
|
#if defined(STEREO_INSTANCING_ON) && defined(UNITY_TEXTURE2D_X_ARRAY_SUPPORTED)
|
||||||
|
#define UNITY_STEREO_INSTANCING_ENABLED
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// Helper macros to handle XR single-pass with Texture2DArray
|
||||||
|
#if defined(USE_TEXTURE2D_X_AS_ARRAY)
|
||||||
|
|
||||||
|
// Only single-pass stereo instancing used array indexing
|
||||||
|
#if defined(UNITY_STEREO_INSTANCING_ENABLED)
|
||||||
|
#define SLICE_ARRAY_INDEX unity_StereoEyeIndex
|
||||||
|
#else
|
||||||
|
#define SLICE_ARRAY_INDEX 0
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// Declare and sample camera buffers as texture arrays
|
||||||
|
#define UNITY_FSR3_TEX2D(type) Texture2DArray<type>
|
||||||
|
#define UNITY_FSR3_RWTEX2D(type) RWTexture2DArray<type>
|
||||||
|
#define UNITY_FSR3_POS(pxPos) FfxUInt32x3(pxPos, SLICE_ARRAY_INDEX)
|
||||||
|
#define UNITY_FSR3_UV(uv) FfxFloat32x3(uv, SLICE_ARRAY_INDEX)
|
||||||
|
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
@ -0,0 +1,7 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 3ce00ba677bb7e14bb91772fd68bfe6b
|
||||||
|
ShaderIncludeImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
@ -0,0 +1,8 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 8364d4f86c613ec4d999d062f5f773b8
|
||||||
|
folderAsset: yes
|
||||||
|
DefaultImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
@ -0,0 +1,79 @@
|
|||||||
|
// This file is part of the FidelityFX SDK.
|
||||||
|
//
|
||||||
|
// Copyright (c) 2023 Advanced Micro Devices, Inc. All rights reserved.
|
||||||
|
//
|
||||||
|
// 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 FSR3UPSCALER_BIND_SRV_INPUT_EXPOSURE 0
|
||||||
|
#define FSR3UPSCALER_BIND_SRV_DILATED_REACTIVE_MASKS 1
|
||||||
|
#if FFX_FSR3UPSCALER_OPTION_LOW_RESOLUTION_MOTION_VECTORS
|
||||||
|
#define FSR3UPSCALER_BIND_SRV_DILATED_MOTION_VECTORS 2
|
||||||
|
#else
|
||||||
|
#define FSR3UPSCALER_BIND_SRV_INPUT_MOTION_VECTORS 2
|
||||||
|
#endif
|
||||||
|
#define FSR3UPSCALER_BIND_SRV_INTERNAL_UPSCALED 3
|
||||||
|
#define FSR3UPSCALER_BIND_SRV_LOCK_STATUS 4
|
||||||
|
#define FSR3UPSCALER_BIND_SRV_PREPARED_INPUT_COLOR 5
|
||||||
|
#define FSR3UPSCALER_BIND_SRV_LANCZOS_LUT 6
|
||||||
|
#define FSR3UPSCALER_BIND_SRV_UPSCALE_MAXIMUM_BIAS_LUT 7
|
||||||
|
#define FSR3UPSCALER_BIND_SRV_SCENE_LUMINANCE_MIPS 8
|
||||||
|
#define FSR3UPSCALER_BIND_SRV_AUTO_EXPOSURE 9
|
||||||
|
#define FSR3UPSCALER_BIND_SRV_LUMA_HISTORY 10
|
||||||
|
|
||||||
|
#define FSR3UPSCALER_BIND_UAV_INTERNAL_UPSCALED 0
|
||||||
|
#define FSR3UPSCALER_BIND_UAV_LOCK_STATUS 1
|
||||||
|
#define FSR3UPSCALER_BIND_UAV_UPSCALED_OUTPUT 2
|
||||||
|
#define FSR3UPSCALER_BIND_UAV_NEW_LOCKS 3
|
||||||
|
#define FSR3UPSCALER_BIND_UAV_LUMA_HISTORY 4
|
||||||
|
|
||||||
|
#define FSR3UPSCALER_BIND_CB_FSR3UPSCALER 0
|
||||||
|
|
||||||
|
#include "fsr3upscaler/ffx_fsr3upscaler_callbacks_hlsl.h"
|
||||||
|
#include "fsr3upscaler/ffx_fsr3upscaler_common.h"
|
||||||
|
#include "fsr3upscaler/ffx_fsr3upscaler_sample.h"
|
||||||
|
#include "fsr3upscaler/ffx_fsr3upscaler_upsample.h"
|
||||||
|
#include "fsr3upscaler/ffx_fsr3upscaler_postprocess_lock_status.h"
|
||||||
|
#include "fsr3upscaler/ffx_fsr3upscaler_reproject.h"
|
||||||
|
#include "fsr3upscaler/ffx_fsr3upscaler_accumulate.h"
|
||||||
|
|
||||||
|
#ifndef FFX_FSR3UPSCALER_THREAD_GROUP_WIDTH
|
||||||
|
#define FFX_FSR3UPSCALER_THREAD_GROUP_WIDTH 8
|
||||||
|
#endif // #ifndef FFX_FSR3UPSCALER_THREAD_GROUP_WIDTH
|
||||||
|
#ifndef FFX_FSR3UPSCALER_THREAD_GROUP_HEIGHT
|
||||||
|
#define FFX_FSR3UPSCALER_THREAD_GROUP_HEIGHT 8
|
||||||
|
#endif // FFX_FSR3UPSCALER_THREAD_GROUP_HEIGHT
|
||||||
|
#ifndef FFX_FSR3UPSCALER_THREAD_GROUP_DEPTH
|
||||||
|
#define FFX_FSR3UPSCALER_THREAD_GROUP_DEPTH 1
|
||||||
|
#endif // #ifndef FFX_FSR3UPSCALER_THREAD_GROUP_DEPTH
|
||||||
|
#ifndef FFX_FSR3UPSCALER_NUM_THREADS
|
||||||
|
#define FFX_FSR3UPSCALER_NUM_THREADS [numthreads(FFX_FSR3UPSCALER_THREAD_GROUP_WIDTH, FFX_FSR3UPSCALER_THREAD_GROUP_HEIGHT, FFX_FSR3UPSCALER_THREAD_GROUP_DEPTH)]
|
||||||
|
#endif // #ifndef FFX_FSR3UPSCALER_NUM_THREADS
|
||||||
|
|
||||||
|
FFX_PREFER_WAVE64
|
||||||
|
FFX_FSR3UPSCALER_NUM_THREADS
|
||||||
|
FFX_FSR3UPSCALER_EMBED_ROOTSIG_CONTENT
|
||||||
|
void CS(uint2 uGroupId : SV_GroupID, uint2 uGroupThreadId : SV_GroupThreadID)
|
||||||
|
{
|
||||||
|
const uint GroupRows = (uint(DisplaySize().y) + FFX_FSR3UPSCALER_THREAD_GROUP_HEIGHT - 1) / FFX_FSR3UPSCALER_THREAD_GROUP_HEIGHT;
|
||||||
|
uGroupId.y = GroupRows - uGroupId.y - 1;
|
||||||
|
|
||||||
|
uint2 uDispatchThreadId = uGroupId * uint2(FFX_FSR3UPSCALER_THREAD_GROUP_WIDTH, FFX_FSR3UPSCALER_THREAD_GROUP_HEIGHT) + uGroupThreadId;
|
||||||
|
|
||||||
|
Accumulate(uDispatchThreadId);
|
||||||
|
}
|
||||||
@ -0,0 +1,7 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 507ab779c38eddb429cdcedf9c108d1b
|
||||||
|
ShaderIncludeImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
@ -0,0 +1,77 @@
|
|||||||
|
// This file is part of the FidelityFX SDK.
|
||||||
|
//
|
||||||
|
// Copyright (c) 2023 Advanced Micro Devices, Inc. All rights reserved.
|
||||||
|
//
|
||||||
|
// 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 FSR3UPSCALER_BIND_SRV_INPUT_OPAQUE_ONLY 0
|
||||||
|
#define FSR3UPSCALER_BIND_SRV_INPUT_COLOR 1
|
||||||
|
|
||||||
|
#define FSR3UPSCALER_BIND_UAV_AUTOREACTIVE 0
|
||||||
|
|
||||||
|
#define FSR3UPSCALER_BIND_CB_FSR3UPSCALER 0
|
||||||
|
#define FSR3UPSCALER_BIND_CB_REACTIVE 1
|
||||||
|
|
||||||
|
#include "fsr3upscaler/ffx_fsr3upscaler_callbacks_hlsl.h"
|
||||||
|
#include "fsr3upscaler/ffx_fsr3upscaler_common.h"
|
||||||
|
|
||||||
|
#ifndef FFX_FSR3UPSCALER_THREAD_GROUP_WIDTH
|
||||||
|
#define FFX_FSR3UPSCALER_THREAD_GROUP_WIDTH 8
|
||||||
|
#endif // #ifndef FFX_FSR3UPSCALER_THREAD_GROUP_WIDTH
|
||||||
|
#ifndef FFX_FSR3UPSCALER_THREAD_GROUP_HEIGHT
|
||||||
|
#define FFX_FSR3UPSCALER_THREAD_GROUP_HEIGHT 8
|
||||||
|
#endif // FFX_FSR3UPSCALER_THREAD_GROUP_HEIGHT
|
||||||
|
#ifndef FFX_FSR3UPSCALER_THREAD_GROUP_DEPTH
|
||||||
|
#define FFX_FSR3UPSCALER_THREAD_GROUP_DEPTH 1
|
||||||
|
#endif // #ifndef FFX_FSR3UPSCALER_THREAD_GROUP_DEPTH
|
||||||
|
#ifndef FFX_FSR3UPSCALER_NUM_THREADS
|
||||||
|
#define FFX_FSR3UPSCALER_NUM_THREADS [numthreads(FFX_FSR3UPSCALER_THREAD_GROUP_WIDTH, FFX_FSR3UPSCALER_THREAD_GROUP_HEIGHT, FFX_FSR3UPSCALER_THREAD_GROUP_DEPTH)]
|
||||||
|
#endif // #ifndef FFX_FSR3UPSCALER_NUM_THREADS
|
||||||
|
|
||||||
|
FFX_FSR3UPSCALER_NUM_THREADS
|
||||||
|
FFX_FSR3UPSCALER_EMBED_ROOTSIG_CONTENT
|
||||||
|
void CS(uint2 uGroupId : SV_GroupID, uint2 uGroupThreadId : SV_GroupThreadID)
|
||||||
|
{
|
||||||
|
uint2 uDispatchThreadId = uGroupId * uint2(FFX_FSR3UPSCALER_THREAD_GROUP_WIDTH, FFX_FSR3UPSCALER_THREAD_GROUP_HEIGHT) + uGroupThreadId;
|
||||||
|
|
||||||
|
float3 ColorPreAlpha = LoadOpaqueOnly( FFX_MIN16_I2(uDispatchThreadId) ).rgb;
|
||||||
|
float3 ColorPostAlpha = LoadInputColor(uDispatchThreadId).rgb;
|
||||||
|
|
||||||
|
if (GenReactiveFlags() & FFX_FSR3UPSCALER_AUTOREACTIVEFLAGS_APPLY_TONEMAP)
|
||||||
|
{
|
||||||
|
ColorPreAlpha = Tonemap(ColorPreAlpha);
|
||||||
|
ColorPostAlpha = Tonemap(ColorPostAlpha);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (GenReactiveFlags() & FFX_FSR3UPSCALER_AUTOREACTIVEFLAGS_APPLY_INVERSETONEMAP)
|
||||||
|
{
|
||||||
|
ColorPreAlpha = InverseTonemap(ColorPreAlpha);
|
||||||
|
ColorPostAlpha = InverseTonemap(ColorPostAlpha);
|
||||||
|
}
|
||||||
|
|
||||||
|
float out_reactive_value = 0.f;
|
||||||
|
float3 delta = abs(ColorPostAlpha - ColorPreAlpha);
|
||||||
|
|
||||||
|
out_reactive_value = (GenReactiveFlags() & FFX_FSR3UPSCALER_AUTOREACTIVEFLAGS_USE_COMPONENTS_MAX) ? max(delta.x, max(delta.y, delta.z)) : length(delta);
|
||||||
|
out_reactive_value *= GenReactiveScale();
|
||||||
|
|
||||||
|
out_reactive_value = (GenReactiveFlags() & FFX_FSR3UPSCALER_AUTOREACTIVEFLAGS_APPLY_THRESHOLD) ? (out_reactive_value < GenReactiveThreshold() ? 0 : GenReactiveBinaryValue()) : out_reactive_value;
|
||||||
|
|
||||||
|
rw_output_autoreactive[uDispatchThreadId] = out_reactive_value;
|
||||||
|
}
|
||||||
@ -0,0 +1,7 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 52cdb7a7c30cb614984908593ed19082
|
||||||
|
ShaderIncludeImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
@ -0,0 +1,55 @@
|
|||||||
|
// This file is part of the FidelityFX SDK.
|
||||||
|
//
|
||||||
|
// Copyright (c) 2023 Advanced Micro Devices, Inc. All rights reserved.
|
||||||
|
//
|
||||||
|
// 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 FSR3UPSCALER_BIND_SRV_INPUT_COLOR 0
|
||||||
|
|
||||||
|
#define FSR3UPSCALER_BIND_UAV_SPD_GLOBAL_ATOMIC 0
|
||||||
|
#define FSR3UPSCALER_BIND_UAV_EXPOSURE_MIP_LUMA_CHANGE 1
|
||||||
|
#define FSR3UPSCALER_BIND_UAV_EXPOSURE_MIP_5 2
|
||||||
|
#define FSR3UPSCALER_BIND_UAV_AUTO_EXPOSURE 3
|
||||||
|
|
||||||
|
#define FSR3UPSCALER_BIND_CB_FSR3UPSCALER 0
|
||||||
|
#define FSR3UPSCALER_BIND_CB_SPD 1
|
||||||
|
|
||||||
|
#include "fsr3upscaler/ffx_fsr3upscaler_callbacks_hlsl.h"
|
||||||
|
#include "fsr3upscaler/ffx_fsr3upscaler_common.h"
|
||||||
|
#include "fsr3upscaler/ffx_fsr3upscaler_compute_luminance_pyramid.h"
|
||||||
|
|
||||||
|
#ifndef FFX_FSR3UPSCALER_THREAD_GROUP_WIDTH
|
||||||
|
#define FFX_FSR3UPSCALER_THREAD_GROUP_WIDTH 256
|
||||||
|
#endif // #ifndef FFX_FSR3UPSCALER_THREAD_GROUP_WIDTH
|
||||||
|
#ifndef FFX_FSR3UPSCALER_THREAD_GROUP_HEIGHT
|
||||||
|
#define FFX_FSR3UPSCALER_THREAD_GROUP_HEIGHT 1
|
||||||
|
#endif // #ifndef FFX_FSR3UPSCALER_THREAD_GROUP_HEIGHT
|
||||||
|
#ifndef FFX_FSR3UPSCALER_THREAD_GROUP_DEPTH
|
||||||
|
#define FFX_FSR3UPSCALER_THREAD_GROUP_DEPTH 1
|
||||||
|
#endif // #ifndef FFX_FSR3UPSCALER_THREAD_GROUP_DEPTH
|
||||||
|
#ifndef FFX_FSR3UPSCALER_NUM_THREADS
|
||||||
|
#define FFX_FSR3UPSCALER_NUM_THREADS [numthreads(FFX_FSR3UPSCALER_THREAD_GROUP_WIDTH, FFX_FSR3UPSCALER_THREAD_GROUP_HEIGHT, FFX_FSR3UPSCALER_THREAD_GROUP_DEPTH)]
|
||||||
|
#endif // #ifndef FFX_FSR3UPSCALER_NUM_THREADS
|
||||||
|
|
||||||
|
FFX_FSR3UPSCALER_NUM_THREADS
|
||||||
|
FFX_FSR3UPSCALER_EMBED_CB2_ROOTSIG_CONTENT
|
||||||
|
void CS(uint3 WorkGroupId : SV_GroupID, uint LocalThreadIndex : SV_GroupIndex)
|
||||||
|
{
|
||||||
|
ComputeAutoExposure(WorkGroupId, LocalThreadIndex);
|
||||||
|
}
|
||||||
@ -0,0 +1,7 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 2d149b52ba0f5bb468a94a71dbbcb66f
|
||||||
|
ShaderIncludeImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
@ -0,0 +1,67 @@
|
|||||||
|
// This file is part of the FidelityFX SDK.
|
||||||
|
//
|
||||||
|
// Copyright (c) 2023 Advanced Micro Devices, Inc. All rights reserved.
|
||||||
|
//
|
||||||
|
// 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 FSR3UPSCALER_BIND_SRV_RECONSTRUCTED_PREV_NEAREST_DEPTH 0
|
||||||
|
#define FSR3UPSCALER_BIND_SRV_DILATED_MOTION_VECTORS 1
|
||||||
|
#define FSR3UPSCALER_BIND_SRV_DILATED_DEPTH 2
|
||||||
|
#define FSR3UPSCALER_BIND_SRV_REACTIVE_MASK 3
|
||||||
|
#define FSR3UPSCALER_BIND_SRV_TRANSPARENCY_AND_COMPOSITION_MASK 4
|
||||||
|
#define FSR3UPSCALER_BIND_SRV_PREVIOUS_DILATED_MOTION_VECTORS 5
|
||||||
|
#define FSR3UPSCALER_BIND_SRV_INPUT_MOTION_VECTORS 6
|
||||||
|
#define FSR3UPSCALER_BIND_SRV_INPUT_COLOR 7
|
||||||
|
#define FSR3UPSCALER_BIND_SRV_INPUT_DEPTH 8
|
||||||
|
#define FSR3UPSCALER_BIND_SRV_INPUT_EXPOSURE 9
|
||||||
|
|
||||||
|
#define FSR3UPSCALER_BIND_UAV_DILATED_REACTIVE_MASKS 0
|
||||||
|
#define FSR3UPSCALER_BIND_UAV_PREPARED_INPUT_COLOR 1
|
||||||
|
|
||||||
|
#define FSR3UPSCALER_BIND_CB_FSR3UPSCALER 0
|
||||||
|
|
||||||
|
#include "fsr3upscaler/ffx_fsr3upscaler_callbacks_hlsl.h"
|
||||||
|
#include "fsr3upscaler/ffx_fsr3upscaler_common.h"
|
||||||
|
#include "fsr3upscaler/ffx_fsr3upscaler_sample.h"
|
||||||
|
#include "fsr3upscaler/ffx_fsr3upscaler_depth_clip.h"
|
||||||
|
|
||||||
|
#ifndef FFX_FSR3UPSCALER_THREAD_GROUP_WIDTH
|
||||||
|
#define FFX_FSR3UPSCALER_THREAD_GROUP_WIDTH 8
|
||||||
|
#endif // #ifndef FFX_FSR3UPSCALER_THREAD_GROUP_WIDTH
|
||||||
|
#ifndef FFX_FSR3UPSCALER_THREAD_GROUP_HEIGHT
|
||||||
|
#define FFX_FSR3UPSCALER_THREAD_GROUP_HEIGHT 8
|
||||||
|
#endif // #ifndef FFX_FSR3UPSCALER_THREAD_GROUP_HEIGHT
|
||||||
|
#ifndef FFX_FSR3UPSCALER_THREAD_GROUP_DEPTH
|
||||||
|
#define FFX_FSR3UPSCALER_THREAD_GROUP_DEPTH 1
|
||||||
|
#endif // #ifndef FFX_FSR3UPSCALER_THREAD_GROUP_DEPTH
|
||||||
|
#ifndef FFX_FSR3UPSCALER_NUM_THREADS
|
||||||
|
#define FFX_FSR3UPSCALER_NUM_THREADS [numthreads(FFX_FSR3UPSCALER_THREAD_GROUP_WIDTH, FFX_FSR3UPSCALER_THREAD_GROUP_HEIGHT, FFX_FSR3UPSCALER_THREAD_GROUP_DEPTH)]
|
||||||
|
#endif // #ifndef FFX_FSR3UPSCALER_NUM_THREADS
|
||||||
|
|
||||||
|
FFX_PREFER_WAVE64
|
||||||
|
FFX_FSR3UPSCALER_NUM_THREADS
|
||||||
|
FFX_FSR3UPSCALER_EMBED_ROOTSIG_CONTENT
|
||||||
|
void CS(
|
||||||
|
int2 iGroupId : SV_GroupID,
|
||||||
|
int2 iDispatchThreadId : SV_DispatchThreadID,
|
||||||
|
int2 iGroupThreadId : SV_GroupThreadID,
|
||||||
|
int iGroupIndex : SV_GroupIndex)
|
||||||
|
{
|
||||||
|
DepthClip(iDispatchThreadId);
|
||||||
|
}
|
||||||
@ -0,0 +1,7 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: da435b71cf57e2247b80ae0f0f86d1f8
|
||||||
|
ShaderIncludeImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
@ -0,0 +1,56 @@
|
|||||||
|
// This file is part of the FidelityFX SDK.
|
||||||
|
//
|
||||||
|
// Copyright (c) 2023 Advanced Micro Devices, Inc. All rights reserved.
|
||||||
|
//
|
||||||
|
// 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 FSR3UPSCALER_BIND_SRV_LOCK_INPUT_LUMA 0
|
||||||
|
|
||||||
|
#define FSR3UPSCALER_BIND_UAV_NEW_LOCKS 0
|
||||||
|
#define FSR3UPSCALER_BIND_UAV_RECONSTRUCTED_PREV_NEAREST_DEPTH 1
|
||||||
|
|
||||||
|
#define FSR3UPSCALER_BIND_CB_FSR3UPSCALER 0
|
||||||
|
|
||||||
|
#include "fsr3upscaler/ffx_fsr3upscaler_callbacks_hlsl.h"
|
||||||
|
#include "fsr3upscaler/ffx_fsr3upscaler_common.h"
|
||||||
|
#include "fsr3upscaler/ffx_fsr3upscaler_sample.h"
|
||||||
|
#include "fsr3upscaler/ffx_fsr3upscaler_lock.h"
|
||||||
|
|
||||||
|
#ifndef FFX_FSR3UPSCALER_THREAD_GROUP_WIDTH
|
||||||
|
#define FFX_FSR3UPSCALER_THREAD_GROUP_WIDTH 8
|
||||||
|
#endif // #ifndef FFX_FSR3UPSCALER_THREAD_GROUP_WIDTH
|
||||||
|
#ifndef FFX_FSR3UPSCALER_THREAD_GROUP_HEIGHT
|
||||||
|
#define FFX_FSR3UPSCALER_THREAD_GROUP_HEIGHT 8
|
||||||
|
#endif // #ifndef FFX_FSR3UPSCALER_THREAD_GROUP_HEIGHT
|
||||||
|
#ifndef FFX_FSR3UPSCALER_THREAD_GROUP_DEPTH
|
||||||
|
#define FFX_FSR3UPSCALER_THREAD_GROUP_DEPTH 1
|
||||||
|
#endif // #ifndef FFX_FSR3UPSCALER_THREAD_GROUP_DEPTH
|
||||||
|
#ifndef FFX_FSR3UPSCALER_NUM_THREADS
|
||||||
|
#define FFX_FSR3UPSCALER_NUM_THREADS [numthreads(FFX_FSR3UPSCALER_THREAD_GROUP_WIDTH, FFX_FSR3UPSCALER_THREAD_GROUP_HEIGHT, FFX_FSR3UPSCALER_THREAD_GROUP_DEPTH)]
|
||||||
|
#endif // #ifndef FFX_FSR3UPSCALER_NUM_THREADS
|
||||||
|
|
||||||
|
FFX_PREFER_WAVE64
|
||||||
|
FFX_FSR3UPSCALER_NUM_THREADS
|
||||||
|
FFX_FSR3UPSCALER_EMBED_ROOTSIG_CONTENT
|
||||||
|
void CS(uint2 uGroupId : SV_GroupID, uint2 uGroupThreadId : SV_GroupThreadID)
|
||||||
|
{
|
||||||
|
uint2 uDispatchThreadId = uGroupId * uint2(FFX_FSR3UPSCALER_THREAD_GROUP_WIDTH, FFX_FSR3UPSCALER_THREAD_GROUP_HEIGHT) + uGroupThreadId;
|
||||||
|
|
||||||
|
ComputeLock(uDispatchThreadId);
|
||||||
|
}
|
||||||
@ -0,0 +1,7 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 98d2cbbda5e90dd4ebd1d70abbb63a09
|
||||||
|
ShaderIncludeImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
@ -0,0 +1,53 @@
|
|||||||
|
// This file is part of the FidelityFX SDK.
|
||||||
|
//
|
||||||
|
// Copyright (c) 2023 Advanced Micro Devices, Inc. All rights reserved.
|
||||||
|
//
|
||||||
|
// 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 FSR3UPSCALER_BIND_SRV_INPUT_EXPOSURE 0
|
||||||
|
#define FSR3UPSCALER_BIND_SRV_RCAS_INPUT 1
|
||||||
|
|
||||||
|
#define FSR3UPSCALER_BIND_UAV_UPSCALED_OUTPUT 0
|
||||||
|
|
||||||
|
#define FSR3UPSCALER_BIND_CB_FSR3UPSCALER 0
|
||||||
|
#define FSR3UPSCALER_BIND_CB_RCAS 1
|
||||||
|
|
||||||
|
#include "fsr3upscaler/ffx_fsr3upscaler_callbacks_hlsl.h"
|
||||||
|
#include "fsr3upscaler/ffx_fsr3upscaler_common.h"
|
||||||
|
#include "fsr3upscaler/ffx_fsr3upscaler_rcas.h"
|
||||||
|
|
||||||
|
#ifndef FFX_FSR3UPSCALER_THREAD_GROUP_WIDTH
|
||||||
|
#define FFX_FSR3UPSCALER_THREAD_GROUP_WIDTH 64
|
||||||
|
#endif // #ifndef FFX_FSR3UPSCALER_THREAD_GROUP_WIDTH
|
||||||
|
#ifndef FFX_FSR3UPSCALER_THREAD_GROUP_HEIGHT
|
||||||
|
#define FFX_FSR3UPSCALER_THREAD_GROUP_HEIGHT 1
|
||||||
|
#endif // #ifndef FFX_FSR3UPSCALER_THREAD_GROUP_HEIGHT
|
||||||
|
#ifndef FFX_FSR3UPSCALER_THREAD_GROUP_DEPTH
|
||||||
|
#define FFX_FSR3UPSCALER_THREAD_GROUP_DEPTH 1
|
||||||
|
#endif // #ifndef FFX_FSR3UPSCALER_THREAD_GROUP_DEPTH
|
||||||
|
#ifndef FFX_FSR3UPSCALER_NUM_THREADS
|
||||||
|
#define FFX_FSR3UPSCALER_NUM_THREADS [numthreads(FFX_FSR3UPSCALER_THREAD_GROUP_WIDTH, FFX_FSR3UPSCALER_THREAD_GROUP_HEIGHT, FFX_FSR3UPSCALER_THREAD_GROUP_DEPTH)]
|
||||||
|
#endif // #ifndef FFX_FSR3UPSCALER_NUM_THREADS
|
||||||
|
|
||||||
|
FFX_FSR3UPSCALER_NUM_THREADS
|
||||||
|
FFX_FSR3UPSCALER_EMBED_CB2_ROOTSIG_CONTENT
|
||||||
|
void CS(uint3 LocalThreadId : SV_GroupThreadID, uint3 WorkGroupId : SV_GroupID, uint3 Dtid : SV_DispatchThreadID)
|
||||||
|
{
|
||||||
|
RCAS(LocalThreadId, WorkGroupId, Dtid);
|
||||||
|
}
|
||||||
@ -0,0 +1,7 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 9a15fc73170a9bc478801c8fa4d8d574
|
||||||
|
ShaderIncludeImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
@ -0,0 +1,64 @@
|
|||||||
|
// This file is part of the FidelityFX SDK.
|
||||||
|
//
|
||||||
|
// Copyright (c) 2023 Advanced Micro Devices, Inc. All rights reserved.
|
||||||
|
//
|
||||||
|
// 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 FSR3UPSCALER_BIND_SRV_INPUT_MOTION_VECTORS 0
|
||||||
|
#define FSR3UPSCALER_BIND_SRV_INPUT_DEPTH 1
|
||||||
|
#define FSR3UPSCALER_BIND_SRV_INPUT_COLOR 2
|
||||||
|
#define FSR3UPSCALER_BIND_SRV_INPUT_EXPOSURE 3
|
||||||
|
|
||||||
|
#define FSR3UPSCALER_BIND_UAV_RECONSTRUCTED_PREV_NEAREST_DEPTH 0
|
||||||
|
#define FSR3UPSCALER_BIND_UAV_DILATED_MOTION_VECTORS 1
|
||||||
|
#define FSR3UPSCALER_BIND_UAV_DILATED_DEPTH 2
|
||||||
|
#define FSR3UPSCALER_BIND_UAV_LOCK_INPUT_LUMA 3
|
||||||
|
|
||||||
|
#define FSR3UPSCALER_BIND_CB_FSR3UPSCALER 0
|
||||||
|
|
||||||
|
#include "fsr3upscaler/ffx_fsr3upscaler_callbacks_hlsl.h"
|
||||||
|
#include "fsr3upscaler/ffx_fsr3upscaler_common.h"
|
||||||
|
#include "fsr3upscaler/ffx_fsr3upscaler_sample.h"
|
||||||
|
#include "fsr3upscaler/ffx_fsr3upscaler_reconstruct_dilated_velocity_and_previous_depth.h"
|
||||||
|
|
||||||
|
#ifndef FFX_FSR3UPSCALER_THREAD_GROUP_WIDTH
|
||||||
|
#define FFX_FSR3UPSCALER_THREAD_GROUP_WIDTH 8
|
||||||
|
#endif // #ifndef FFX_FSR3UPSCALER_THREAD_GROUP_WIDTH
|
||||||
|
#ifndef FFX_FSR3UPSCALER_THREAD_GROUP_HEIGHT
|
||||||
|
#define FFX_FSR3UPSCALER_THREAD_GROUP_HEIGHT 8
|
||||||
|
#endif // #ifndef FFX_FSR3UPSCALER_THREAD_GROUP_HEIGHT
|
||||||
|
#ifndef FFX_FSR3UPSCALER_THREAD_GROUP_DEPTH
|
||||||
|
#define FFX_FSR3UPSCALER_THREAD_GROUP_DEPTH 1
|
||||||
|
#endif // #ifndef FFX_FSR3UPSCALER_THREAD_GROUP_DEPTH
|
||||||
|
#ifndef FFX_FSR3UPSCALER_NUM_THREADS
|
||||||
|
#define FFX_FSR3UPSCALER_NUM_THREADS [numthreads(FFX_FSR3UPSCALER_THREAD_GROUP_WIDTH, FFX_FSR3UPSCALER_THREAD_GROUP_HEIGHT, FFX_FSR3UPSCALER_THREAD_GROUP_DEPTH)]
|
||||||
|
#endif // #ifndef FFX_FSR3UPSCALER_NUM_THREADS
|
||||||
|
|
||||||
|
FFX_PREFER_WAVE64
|
||||||
|
FFX_FSR3UPSCALER_NUM_THREADS
|
||||||
|
FFX_FSR3UPSCALER_EMBED_ROOTSIG_CONTENT
|
||||||
|
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: bafb3726a76b97a49bb343d8a4323754
|
||||||
|
ShaderIncludeImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
@ -0,0 +1,90 @@
|
|||||||
|
// This file is part of the FidelityFX SDK.
|
||||||
|
//
|
||||||
|
// Copyright (c) 2022-2023 Advanced Micro Devices, Inc. All rights reserved.
|
||||||
|
//
|
||||||
|
// 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 FSR3UPSCALER_BIND_SRV_INPUT_OPAQUE_ONLY 0
|
||||||
|
#define FSR3UPSCALER_BIND_SRV_INPUT_COLOR 1
|
||||||
|
#define FSR3UPSCALER_BIND_SRV_INPUT_MOTION_VECTORS 2
|
||||||
|
#define FSR3UPSCALER_BIND_SRV_PREV_PRE_ALPHA_COLOR 3
|
||||||
|
#define FSR3UPSCALER_BIND_SRV_PREV_POST_ALPHA_COLOR 4
|
||||||
|
#define FSR3UPSCALER_BIND_SRV_REACTIVE_MASK 4
|
||||||
|
#define FSR3UPSCALER_BIND_SRV_TRANSPARENCY_AND_COMPOSITION_MASK 5
|
||||||
|
|
||||||
|
#define FSR3UPSCALER_BIND_UAV_AUTOREACTIVE 0
|
||||||
|
#define FSR3UPSCALER_BIND_UAV_AUTOCOMPOSITION 1
|
||||||
|
#define FSR3UPSCALER_BIND_UAV_PREV_PRE_ALPHA_COLOR 2
|
||||||
|
#define FSR3UPSCALER_BIND_UAV_PREV_POST_ALPHA_COLOR 3
|
||||||
|
|
||||||
|
#define FSR3UPSCALER_BIND_CB_FSR3UPSCALER 0
|
||||||
|
#define FSR3UPSCALER_BIND_CB_AUTOREACTIVE 1
|
||||||
|
|
||||||
|
#include "fsr3upscaler/ffx_fsr3upscaler_callbacks_hlsl.h"
|
||||||
|
#include "fsr3upscaler/ffx_fsr3upscaler_common.h"
|
||||||
|
#include "fsr3upscaler/ffx_fsr3upscaler_tcr_autogen.h"
|
||||||
|
|
||||||
|
#ifndef FFX_FSR3UPSCALER_THREAD_GROUP_WIDTH
|
||||||
|
#define FFX_FSR3UPSCALER_THREAD_GROUP_WIDTH 8
|
||||||
|
#endif // #ifndef FFX_FSR3UPSCALER_THREAD_GROUP_WIDTH
|
||||||
|
#ifndef FFX_FSR3UPSCALER_THREAD_GROUP_HEIGHT
|
||||||
|
#define FFX_FSR3UPSCALER_THREAD_GROUP_HEIGHT 8
|
||||||
|
#endif // FFX_FSR3UPSCALER_THREAD_GROUP_HEIGHT
|
||||||
|
#ifndef FFX_FSR3UPSCALER_THREAD_GROUP_DEPTH
|
||||||
|
#define FFX_FSR3UPSCALER_THREAD_GROUP_DEPTH 1
|
||||||
|
#endif // #ifndef FFX_FSR3UPSCALER_THREAD_GROUP_DEPTH
|
||||||
|
#ifndef FFX_FSR3UPSCALER_NUM_THREADS
|
||||||
|
#define FFX_FSR3UPSCALER_NUM_THREADS [numthreads(FFX_FSR3UPSCALER_THREAD_GROUP_WIDTH, FFX_FSR3UPSCALER_THREAD_GROUP_HEIGHT, FFX_FSR3UPSCALER_THREAD_GROUP_DEPTH)]
|
||||||
|
#endif // #ifndef FFX_FSR3UPSCALER_NUM_THREADS
|
||||||
|
|
||||||
|
FFX_FSR3UPSCALER_NUM_THREADS
|
||||||
|
FFX_FSR3UPSCALER_EMBED_ROOTSIG_CONTENT
|
||||||
|
void CS(uint2 uGroupId : SV_GroupID, uint2 uGroupThreadId : SV_GroupThreadID)
|
||||||
|
{
|
||||||
|
FFX_MIN16_I2 uDispatchThreadId = FFX_MIN16_I2(uGroupId * uint2(FFX_FSR3UPSCALER_THREAD_GROUP_WIDTH, FFX_FSR3UPSCALER_THREAD_GROUP_HEIGHT) + uGroupThreadId);
|
||||||
|
|
||||||
|
// ToDo: take into account jitter (i.e. add delta of previous jitter and current jitter to previous UV
|
||||||
|
// fetch pre- and post-alpha color values
|
||||||
|
FFX_MIN16_F2 fUv = ( FFX_MIN16_F2(uDispatchThreadId) + FFX_MIN16_F2(0.5f, 0.5f) ) / FFX_MIN16_F2( RenderSize() );
|
||||||
|
FFX_MIN16_F2 fPrevUV = fUv + FFX_MIN16_F2( LoadInputMotionVector(uDispatchThreadId) );
|
||||||
|
FFX_MIN16_I2 iPrevIdx = FFX_MIN16_I2(fPrevUV * FFX_MIN16_F2(RenderSize()) - 0.5f);
|
||||||
|
|
||||||
|
FFX_MIN16_F3 colorPreAlpha = FFX_MIN16_F3( LoadOpaqueOnly( uDispatchThreadId ) );
|
||||||
|
FFX_MIN16_F3 colorPostAlpha = FFX_MIN16_F3( LoadInputColor( uDispatchThreadId ) );
|
||||||
|
|
||||||
|
FFX_MIN16_F2 outReactiveMask = 0;
|
||||||
|
|
||||||
|
outReactiveMask.y = ComputeTransparencyAndComposition(uDispatchThreadId, iPrevIdx);
|
||||||
|
|
||||||
|
if (outReactiveMask.y > 0.5f)
|
||||||
|
{
|
||||||
|
outReactiveMask.x = ComputeReactive(uDispatchThreadId, iPrevIdx);
|
||||||
|
outReactiveMask.x *= FFX_MIN16_F(fReactiveScale);
|
||||||
|
outReactiveMask.x = outReactiveMask.x < fReactiveMax ? outReactiveMask.x : FFX_MIN16_F( fReactiveMax );
|
||||||
|
}
|
||||||
|
|
||||||
|
outReactiveMask.y *= FFX_MIN16_F(fTcScale );
|
||||||
|
|
||||||
|
outReactiveMask.x = max( outReactiveMask.x, FFX_MIN16_F( LoadReactiveMask(uDispatchThreadId) ) );
|
||||||
|
outReactiveMask.y = max( outReactiveMask.y, FFX_MIN16_F( LoadTransparencyAndCompositionMask(uDispatchThreadId) ) );
|
||||||
|
|
||||||
|
StoreAutoReactive(uDispatchThreadId, outReactiveMask);
|
||||||
|
|
||||||
|
StorePrevPreAlpha(uDispatchThreadId, colorPreAlpha);
|
||||||
|
StorePrevPostAlpha(uDispatchThreadId, colorPostAlpha);
|
||||||
|
}
|
||||||
@ -0,0 +1,7 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 712d171118b59fc4fb28d0d487060d42
|
||||||
|
ShaderIncludeImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
@ -0,0 +1,8 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: ae9c6d015ae76544f9e8117e79ea862b
|
||||||
|
folderAsset: yes
|
||||||
|
DefaultImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
@ -0,0 +1,616 @@
|
|||||||
|
// This file is part of the FidelityFX SDK.
|
||||||
|
//
|
||||||
|
// Copyright (c) 2023 Advanced Micro Devices, Inc. All rights reserved.
|
||||||
|
//
|
||||||
|
// 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_COMMON_TYPES_H
|
||||||
|
#define FFX_COMMON_TYPES_H
|
||||||
|
|
||||||
|
#if defined(FFX_CPU)
|
||||||
|
#define FFX_PARAMETER_IN
|
||||||
|
#define FFX_PARAMETER_OUT
|
||||||
|
#define FFX_PARAMETER_INOUT
|
||||||
|
#define FFX_PARAMETER_UNIFORM
|
||||||
|
#elif defined(FFX_HLSL)
|
||||||
|
#define FFX_PARAMETER_IN in
|
||||||
|
#define FFX_PARAMETER_OUT out
|
||||||
|
#define FFX_PARAMETER_INOUT inout
|
||||||
|
#define FFX_PARAMETER_UNIFORM uniform
|
||||||
|
#elif defined(FFX_GLSL)
|
||||||
|
#define FFX_PARAMETER_IN in
|
||||||
|
#define FFX_PARAMETER_OUT out
|
||||||
|
#define FFX_PARAMETER_INOUT inout
|
||||||
|
#define FFX_PARAMETER_UNIFORM const //[cacao_placeholder] until a better fit is found!
|
||||||
|
#endif // #if defined(FFX_CPU)
|
||||||
|
|
||||||
|
#if defined(FFX_CPU)
|
||||||
|
/// A typedef for a boolean value.
|
||||||
|
///
|
||||||
|
/// @ingroup CPUTypes
|
||||||
|
typedef bool FfxBoolean;
|
||||||
|
|
||||||
|
/// A typedef for a unsigned 8bit integer.
|
||||||
|
///
|
||||||
|
/// @ingroup CPUTypes
|
||||||
|
typedef uint8_t FfxUInt8;
|
||||||
|
|
||||||
|
/// A typedef for a unsigned 16bit integer.
|
||||||
|
///
|
||||||
|
/// @ingroup CPUTypes
|
||||||
|
typedef uint16_t FfxUInt16;
|
||||||
|
|
||||||
|
/// A typedef for a unsigned 32bit integer.
|
||||||
|
///
|
||||||
|
/// @ingroup CPUTypes
|
||||||
|
typedef uint32_t FfxUInt32;
|
||||||
|
|
||||||
|
/// A typedef for a unsigned 64bit integer.
|
||||||
|
///
|
||||||
|
/// @ingroup CPUTypes
|
||||||
|
typedef uint64_t FfxUInt64;
|
||||||
|
|
||||||
|
/// A typedef for a signed 8bit integer.
|
||||||
|
///
|
||||||
|
/// @ingroup CPUTypes
|
||||||
|
typedef int8_t FfxInt8;
|
||||||
|
|
||||||
|
/// A typedef for a signed 16bit integer.
|
||||||
|
///
|
||||||
|
/// @ingroup CPUTypes
|
||||||
|
typedef int16_t FfxInt16;
|
||||||
|
|
||||||
|
/// A typedef for a signed 32bit integer.
|
||||||
|
///
|
||||||
|
/// @ingroup CPUTypes
|
||||||
|
typedef int32_t FfxInt32;
|
||||||
|
|
||||||
|
/// A typedef for a signed 64bit integer.
|
||||||
|
///
|
||||||
|
/// @ingroup CPUTypes
|
||||||
|
typedef int64_t FfxInt64;
|
||||||
|
|
||||||
|
/// A typedef for a floating point value.
|
||||||
|
///
|
||||||
|
/// @ingroup CPUTypes
|
||||||
|
typedef float FfxFloat32;
|
||||||
|
|
||||||
|
/// A typedef for a 2-dimensional floating point value.
|
||||||
|
///
|
||||||
|
/// @ingroup CPUTypes
|
||||||
|
typedef float FfxFloat32x2[2];
|
||||||
|
|
||||||
|
/// A typedef for a 3-dimensional floating point value.
|
||||||
|
///
|
||||||
|
/// @ingroup CPUTypes
|
||||||
|
typedef float FfxFloat32x3[3];
|
||||||
|
|
||||||
|
/// A typedef for a 4-dimensional floating point value.
|
||||||
|
///
|
||||||
|
/// @ingroup CPUTypes
|
||||||
|
typedef float FfxFloat32x4[4];
|
||||||
|
|
||||||
|
/// A typedef for a 2-dimensional 32bit unsigned integer.
|
||||||
|
///
|
||||||
|
/// @ingroup CPUTypes
|
||||||
|
typedef uint32_t FfxUInt32x2[2];
|
||||||
|
|
||||||
|
/// A typedef for a 3-dimensional 32bit unsigned integer.
|
||||||
|
///
|
||||||
|
/// @ingroup CPUTypes
|
||||||
|
typedef uint32_t FfxUInt32x3[3];
|
||||||
|
|
||||||
|
/// A typedef for a 4-dimensional 32bit unsigned integer.
|
||||||
|
///
|
||||||
|
/// @ingroup CPUTypes
|
||||||
|
typedef uint32_t FfxUInt32x4[4];
|
||||||
|
#endif // #if defined(FFX_CPU)
|
||||||
|
|
||||||
|
#if defined(FFX_HLSL)
|
||||||
|
|
||||||
|
#define FfxFloat32Mat4 matrix <float, 4, 4>
|
||||||
|
#define FfxFloat32Mat3 matrix <float, 3, 3>
|
||||||
|
|
||||||
|
/// A typedef for a boolean value.
|
||||||
|
///
|
||||||
|
/// @ingroup HLSLTypes
|
||||||
|
typedef bool FfxBoolean;
|
||||||
|
|
||||||
|
#if FFX_HLSL_SM>=62
|
||||||
|
|
||||||
|
/// @defgroup HLSL62Types HLSL 6.2 And Above Types
|
||||||
|
/// HLSL 6.2 and above type defines for all commonly used variables
|
||||||
|
///
|
||||||
|
/// @ingroup HLSLTypes
|
||||||
|
|
||||||
|
/// A typedef for a floating point value.
|
||||||
|
///
|
||||||
|
/// @ingroup HLSL62Types
|
||||||
|
typedef float32_t FfxFloat32;
|
||||||
|
|
||||||
|
/// A typedef for a 2-dimensional floating point value.
|
||||||
|
///
|
||||||
|
/// @ingroup HLSL62Types
|
||||||
|
typedef float32_t2 FfxFloat32x2;
|
||||||
|
|
||||||
|
/// A typedef for a 3-dimensional floating point value.
|
||||||
|
///
|
||||||
|
/// @ingroup HLSL62Types
|
||||||
|
typedef float32_t3 FfxFloat32x3;
|
||||||
|
|
||||||
|
/// A typedef for a 4-dimensional floating point value.
|
||||||
|
///
|
||||||
|
/// @ingroup HLSL62Types
|
||||||
|
typedef float32_t4 FfxFloat32x4;
|
||||||
|
|
||||||
|
/// A [cacao_placeholder] typedef for matrix type until confirmed.
|
||||||
|
typedef float4x4 FfxFloat32x4x4;
|
||||||
|
typedef float3x3 FfxFloat32x3x3;
|
||||||
|
typedef float2x2 FfxFloat32x2x2;
|
||||||
|
|
||||||
|
/// A typedef for a unsigned 32bit integer.
|
||||||
|
///
|
||||||
|
/// @ingroup HLSL62Types
|
||||||
|
typedef uint32_t FfxUInt32;
|
||||||
|
|
||||||
|
/// A typedef for a 2-dimensional 32bit unsigned integer.
|
||||||
|
///
|
||||||
|
/// @ingroup HLSL62Types
|
||||||
|
typedef uint32_t2 FfxUInt32x2;
|
||||||
|
|
||||||
|
/// A typedef for a 3-dimensional 32bit unsigned integer.
|
||||||
|
///
|
||||||
|
/// @ingroup HLSL62Types
|
||||||
|
typedef uint32_t3 FfxUInt32x3;
|
||||||
|
|
||||||
|
/// A typedef for a 4-dimensional 32bit unsigned integer.
|
||||||
|
///
|
||||||
|
/// @ingroup HLSL62Types
|
||||||
|
typedef uint32_t4 FfxUInt32x4;
|
||||||
|
|
||||||
|
/// A typedef for a signed 32bit integer.
|
||||||
|
///
|
||||||
|
/// @ingroup HLSL62Types
|
||||||
|
typedef int32_t FfxInt32;
|
||||||
|
|
||||||
|
/// A typedef for a 2-dimensional signed 32bit integer.
|
||||||
|
///
|
||||||
|
/// @ingroup HLSL62Types
|
||||||
|
typedef int32_t2 FfxInt32x2;
|
||||||
|
|
||||||
|
/// A typedef for a 3-dimensional signed 32bit integer.
|
||||||
|
///
|
||||||
|
/// @ingroup HLSL62Types
|
||||||
|
typedef int32_t3 FfxInt32x3;
|
||||||
|
|
||||||
|
/// A typedef for a 4-dimensional signed 32bit integer.
|
||||||
|
///
|
||||||
|
/// @ingroup HLSL62Types
|
||||||
|
typedef int32_t4 FfxInt32x4;
|
||||||
|
|
||||||
|
#else // #if FFX_HLSL_SM>=62
|
||||||
|
|
||||||
|
/// @defgroup HLSLBaseTypes HLSL 6.1 And Below Types
|
||||||
|
/// HLSL 6.1 and below type defines for all commonly used variables
|
||||||
|
///
|
||||||
|
/// @ingroup HLSLTypes
|
||||||
|
|
||||||
|
#define FfxFloat32 float
|
||||||
|
#define FfxFloat32x2 float2
|
||||||
|
#define FfxFloat32x3 float3
|
||||||
|
#define FfxFloat32x4 float4
|
||||||
|
|
||||||
|
/// A [cacao_placeholder] typedef for matrix type until confirmed.
|
||||||
|
#define FfxFloat32x4x4 float4x4
|
||||||
|
#define FfxFloat32x3x3 float3x3
|
||||||
|
#define FfxFloat32x2x2 float2x2
|
||||||
|
|
||||||
|
/// A typedef for a unsigned 32bit integer.
|
||||||
|
///
|
||||||
|
/// @ingroup GPU
|
||||||
|
typedef uint FfxUInt32;
|
||||||
|
typedef uint2 FfxUInt32x2;
|
||||||
|
typedef uint3 FfxUInt32x3;
|
||||||
|
typedef uint4 FfxUInt32x4;
|
||||||
|
|
||||||
|
typedef int FfxInt32;
|
||||||
|
typedef int2 FfxInt32x2;
|
||||||
|
typedef int3 FfxInt32x3;
|
||||||
|
typedef int4 FfxInt32x4;
|
||||||
|
|
||||||
|
#endif // #if FFX_HLSL_SM>=62
|
||||||
|
|
||||||
|
#if FFX_HALF
|
||||||
|
|
||||||
|
#if FFX_HLSL_SM >= 62
|
||||||
|
|
||||||
|
typedef float16_t FfxFloat16;
|
||||||
|
typedef float16_t2 FfxFloat16x2;
|
||||||
|
typedef float16_t3 FfxFloat16x3;
|
||||||
|
typedef float16_t4 FfxFloat16x4;
|
||||||
|
|
||||||
|
/// A typedef for an unsigned 16bit integer.
|
||||||
|
///
|
||||||
|
/// @ingroup HLSLTypes
|
||||||
|
typedef uint16_t FfxUInt16;
|
||||||
|
typedef uint16_t2 FfxUInt16x2;
|
||||||
|
typedef uint16_t3 FfxUInt16x3;
|
||||||
|
typedef uint16_t4 FfxUInt16x4;
|
||||||
|
|
||||||
|
/// A typedef for a signed 16bit integer.
|
||||||
|
///
|
||||||
|
/// @ingroup HLSLTypes
|
||||||
|
typedef int16_t FfxInt16;
|
||||||
|
typedef int16_t2 FfxInt16x2;
|
||||||
|
typedef int16_t3 FfxInt16x3;
|
||||||
|
typedef int16_t4 FfxInt16x4;
|
||||||
|
#elif SHADER_API_PSSL
|
||||||
|
#pragma argument(realtypes) // Enable true 16-bit types
|
||||||
|
|
||||||
|
typedef half FfxFloat16;
|
||||||
|
typedef half2 FfxFloat16x2;
|
||||||
|
typedef half3 FfxFloat16x3;
|
||||||
|
typedef half4 FfxFloat16x4;
|
||||||
|
|
||||||
|
/// A typedef for an unsigned 16bit integer.
|
||||||
|
///
|
||||||
|
/// @ingroup GPU
|
||||||
|
typedef ushort FfxUInt16;
|
||||||
|
typedef ushort2 FfxUInt16x2;
|
||||||
|
typedef ushort3 FfxUInt16x3;
|
||||||
|
typedef ushort4 FfxUInt16x4;
|
||||||
|
|
||||||
|
/// A typedef for a signed 16bit integer.
|
||||||
|
///
|
||||||
|
/// @ingroup GPU
|
||||||
|
typedef short FfxInt16;
|
||||||
|
typedef short2 FfxInt16x2;
|
||||||
|
typedef short3 FfxInt16x3;
|
||||||
|
typedef short4 FfxInt16x4;
|
||||||
|
#else // #if FFX_HLSL_SM>=62
|
||||||
|
typedef min16float FfxFloat16;
|
||||||
|
typedef min16float2 FfxFloat16x2;
|
||||||
|
typedef min16float3 FfxFloat16x3;
|
||||||
|
typedef min16float4 FfxFloat16x4;
|
||||||
|
|
||||||
|
/// A typedef for an unsigned 16bit integer.
|
||||||
|
///
|
||||||
|
/// @ingroup HLSLTypes
|
||||||
|
typedef min16uint FfxUInt16;
|
||||||
|
typedef min16uint2 FfxUInt16x2;
|
||||||
|
typedef min16uint3 FfxUInt16x3;
|
||||||
|
typedef min16uint4 FfxUInt16x4;
|
||||||
|
|
||||||
|
/// A typedef for a signed 16bit integer.
|
||||||
|
///
|
||||||
|
/// @ingroup HLSLTypes
|
||||||
|
typedef min16int FfxInt16;
|
||||||
|
typedef min16int2 FfxInt16x2;
|
||||||
|
typedef min16int3 FfxInt16x3;
|
||||||
|
typedef min16int4 FfxInt16x4;
|
||||||
|
#endif // #if FFX_HLSL_SM>=62
|
||||||
|
|
||||||
|
#endif // FFX_HALF
|
||||||
|
|
||||||
|
#endif // #if defined(FFX_HLSL)
|
||||||
|
|
||||||
|
#if defined(FFX_GLSL)
|
||||||
|
|
||||||
|
#define FfxFloat32Mat4 mat4
|
||||||
|
#define FfxFloat32Mat3 mat3
|
||||||
|
|
||||||
|
/// A typedef for a boolean value.
|
||||||
|
///
|
||||||
|
/// @ingroup GLSLTypes
|
||||||
|
#define FfxBoolean bool
|
||||||
|
#define FfxFloat32 float
|
||||||
|
#define FfxFloat32x2 vec2
|
||||||
|
#define FfxFloat32x3 vec3
|
||||||
|
#define FfxFloat32x4 vec4
|
||||||
|
#define FfxUInt32 uint
|
||||||
|
#define FfxUInt32x2 uvec2
|
||||||
|
#define FfxUInt32x3 uvec3
|
||||||
|
#define FfxUInt32x4 uvec4
|
||||||
|
#define FfxInt32 int
|
||||||
|
#define FfxInt32x2 ivec2
|
||||||
|
#define FfxInt32x3 ivec3
|
||||||
|
#define FfxInt32x4 ivec4
|
||||||
|
|
||||||
|
/// A [cacao_placeholder] typedef for matrix type until confirmed.
|
||||||
|
#define FfxFloat32x4x4 mat4
|
||||||
|
#define FfxFloat32x3x3 mat3
|
||||||
|
#define FfxFloat32x2x2 mat2
|
||||||
|
|
||||||
|
#if FFX_HALF
|
||||||
|
#define FfxFloat16 float16_t
|
||||||
|
#define FfxFloat16x2 f16vec2
|
||||||
|
#define FfxFloat16x3 f16vec3
|
||||||
|
#define FfxFloat16x4 f16vec4
|
||||||
|
#define FfxUInt16 uint16_t
|
||||||
|
#define FfxUInt16x2 u16vec2
|
||||||
|
#define FfxUInt16x3 u16vec3
|
||||||
|
#define FfxUInt16x4 u16vec4
|
||||||
|
#define FfxInt16 int16_t
|
||||||
|
#define FfxInt16x2 i16vec2
|
||||||
|
#define FfxInt16x3 i16vec3
|
||||||
|
#define FfxInt16x4 i16vec4
|
||||||
|
#endif // FFX_HALF
|
||||||
|
#endif // #if defined(FFX_GLSL)
|
||||||
|
|
||||||
|
// Global toggles:
|
||||||
|
// #define FFX_HALF (1)
|
||||||
|
// #define FFX_HLSL_SM (62)
|
||||||
|
|
||||||
|
#if FFX_HALF && !defined(SHADER_API_PSSL)
|
||||||
|
|
||||||
|
#if FFX_HLSL_SM >= 62
|
||||||
|
|
||||||
|
#define FFX_MIN16_SCALAR( TypeName, BaseComponentType ) typedef BaseComponentType##16_t TypeName;
|
||||||
|
#define FFX_MIN16_VECTOR( TypeName, BaseComponentType, COL ) typedef vector<BaseComponentType##16_t, COL> TypeName;
|
||||||
|
#define FFX_MIN16_MATRIX( TypeName, BaseComponentType, ROW, COL ) typedef matrix<BaseComponentType##16_t, ROW, COL> TypeName;
|
||||||
|
|
||||||
|
#define FFX_16BIT_SCALAR( TypeName, BaseComponentType ) typedef BaseComponentType##16_t TypeName;
|
||||||
|
#define FFX_16BIT_VECTOR( TypeName, BaseComponentType, COL ) typedef vector<BaseComponentType##16_t, COL> TypeName;
|
||||||
|
#define FFX_16BIT_MATRIX( TypeName, BaseComponentType, ROW, COL ) typedef matrix<BaseComponentType##16_t, ROW, COL> TypeName;
|
||||||
|
|
||||||
|
#else //FFX_HLSL_SM>=62
|
||||||
|
|
||||||
|
#define FFX_MIN16_SCALAR( TypeName, BaseComponentType ) typedef min16##BaseComponentType TypeName;
|
||||||
|
#define FFX_MIN16_VECTOR( TypeName, BaseComponentType, COL ) typedef vector<min16##BaseComponentType, COL> TypeName;
|
||||||
|
#define FFX_MIN16_MATRIX( TypeName, BaseComponentType, ROW, COL ) typedef matrix<min16##BaseComponentType, ROW, COL> TypeName;
|
||||||
|
|
||||||
|
#define FFX_16BIT_SCALAR( TypeName, BaseComponentType ) FFX_MIN16_SCALAR( TypeName, BaseComponentType );
|
||||||
|
#define FFX_16BIT_VECTOR( TypeName, BaseComponentType, COL ) FFX_MIN16_VECTOR( TypeName, BaseComponentType, COL );
|
||||||
|
#define FFX_16BIT_MATRIX( TypeName, BaseComponentType, ROW, COL ) FFX_MIN16_MATRIX( TypeName, BaseComponentType, ROW, COL );
|
||||||
|
|
||||||
|
#endif //FFX_HLSL_SM>=62
|
||||||
|
|
||||||
|
#else //FFX_HALF
|
||||||
|
|
||||||
|
#define FFX_MIN16_SCALAR( TypeName, BaseComponentType ) typedef BaseComponentType TypeName;
|
||||||
|
#define FFX_MIN16_VECTOR( TypeName, BaseComponentType, COL ) typedef vector<BaseComponentType, COL> TypeName;
|
||||||
|
#define FFX_MIN16_MATRIX( TypeName, BaseComponentType, ROW, COL ) typedef matrix<BaseComponentType, ROW, COL> TypeName;
|
||||||
|
|
||||||
|
#define FFX_16BIT_SCALAR( TypeName, BaseComponentType ) typedef BaseComponentType TypeName;
|
||||||
|
#define FFX_16BIT_VECTOR( TypeName, BaseComponentType, COL ) typedef vector<BaseComponentType, COL> TypeName;
|
||||||
|
#define FFX_16BIT_MATRIX( TypeName, BaseComponentType, ROW, COL ) typedef matrix<BaseComponentType, ROW, COL> TypeName;
|
||||||
|
|
||||||
|
#endif //FFX_HALF
|
||||||
|
|
||||||
|
#if defined(FFX_GPU)
|
||||||
|
// Common typedefs:
|
||||||
|
#if defined(FFX_HLSL) && !defined(SHADER_API_PSSL)
|
||||||
|
FFX_MIN16_SCALAR( FFX_MIN16_F , float );
|
||||||
|
FFX_MIN16_VECTOR( FFX_MIN16_F2, float, 2 );
|
||||||
|
FFX_MIN16_VECTOR( FFX_MIN16_F3, float, 3 );
|
||||||
|
FFX_MIN16_VECTOR( FFX_MIN16_F4, float, 4 );
|
||||||
|
|
||||||
|
FFX_MIN16_SCALAR( FFX_MIN16_I, int );
|
||||||
|
FFX_MIN16_VECTOR( FFX_MIN16_I2, int, 2 );
|
||||||
|
FFX_MIN16_VECTOR( FFX_MIN16_I3, int, 3 );
|
||||||
|
FFX_MIN16_VECTOR( FFX_MIN16_I4, int, 4 );
|
||||||
|
|
||||||
|
FFX_MIN16_SCALAR( FFX_MIN16_U, uint );
|
||||||
|
FFX_MIN16_VECTOR( FFX_MIN16_U2, uint, 2 );
|
||||||
|
FFX_MIN16_VECTOR( FFX_MIN16_U3, uint, 3 );
|
||||||
|
FFX_MIN16_VECTOR( FFX_MIN16_U4, uint, 4 );
|
||||||
|
|
||||||
|
FFX_16BIT_SCALAR( FFX_F16_t , float );
|
||||||
|
FFX_16BIT_VECTOR( FFX_F16_t2, float, 2 );
|
||||||
|
FFX_16BIT_VECTOR( FFX_F16_t3, float, 3 );
|
||||||
|
FFX_16BIT_VECTOR( FFX_F16_t4, float, 4 );
|
||||||
|
|
||||||
|
FFX_16BIT_SCALAR( FFX_I16_t, int );
|
||||||
|
FFX_16BIT_VECTOR( FFX_I16_t2, int, 2 );
|
||||||
|
FFX_16BIT_VECTOR( FFX_I16_t3, int, 3 );
|
||||||
|
FFX_16BIT_VECTOR( FFX_I16_t4, int, 4 );
|
||||||
|
|
||||||
|
FFX_16BIT_SCALAR( FFX_U16_t, uint );
|
||||||
|
FFX_16BIT_VECTOR( FFX_U16_t2, uint, 2 );
|
||||||
|
FFX_16BIT_VECTOR( FFX_U16_t3, uint, 3 );
|
||||||
|
FFX_16BIT_VECTOR( FFX_U16_t4, uint, 4 );
|
||||||
|
|
||||||
|
#define TYPEDEF_MIN16_TYPES(Prefix) \
|
||||||
|
typedef FFX_MIN16_F Prefix##_F; \
|
||||||
|
typedef FFX_MIN16_F2 Prefix##_F2; \
|
||||||
|
typedef FFX_MIN16_F3 Prefix##_F3; \
|
||||||
|
typedef FFX_MIN16_F4 Prefix##_F4; \
|
||||||
|
typedef FFX_MIN16_I Prefix##_I; \
|
||||||
|
typedef FFX_MIN16_I2 Prefix##_I2; \
|
||||||
|
typedef FFX_MIN16_I3 Prefix##_I3; \
|
||||||
|
typedef FFX_MIN16_I4 Prefix##_I4; \
|
||||||
|
typedef FFX_MIN16_U Prefix##_U; \
|
||||||
|
typedef FFX_MIN16_U2 Prefix##_U2; \
|
||||||
|
typedef FFX_MIN16_U3 Prefix##_U3; \
|
||||||
|
typedef FFX_MIN16_U4 Prefix##_U4;
|
||||||
|
|
||||||
|
#define TYPEDEF_16BIT_TYPES(Prefix) \
|
||||||
|
typedef FFX_16BIT_F Prefix##_F; \
|
||||||
|
typedef FFX_16BIT_F2 Prefix##_F2; \
|
||||||
|
typedef FFX_16BIT_F3 Prefix##_F3; \
|
||||||
|
typedef FFX_16BIT_F4 Prefix##_F4; \
|
||||||
|
typedef FFX_16BIT_I Prefix##_I; \
|
||||||
|
typedef FFX_16BIT_I2 Prefix##_I2; \
|
||||||
|
typedef FFX_16BIT_I3 Prefix##_I3; \
|
||||||
|
typedef FFX_16BIT_I4 Prefix##_I4; \
|
||||||
|
typedef FFX_16BIT_U Prefix##_U; \
|
||||||
|
typedef FFX_16BIT_U2 Prefix##_U2; \
|
||||||
|
typedef FFX_16BIT_U3 Prefix##_U3; \
|
||||||
|
typedef FFX_16BIT_U4 Prefix##_U4;
|
||||||
|
|
||||||
|
#define TYPEDEF_FULL_PRECISION_TYPES(Prefix) \
|
||||||
|
typedef FfxFloat32 Prefix##_F; \
|
||||||
|
typedef FfxFloat32x2 Prefix##_F2; \
|
||||||
|
typedef FfxFloat32x3 Prefix##_F3; \
|
||||||
|
typedef FfxFloat32x4 Prefix##_F4; \
|
||||||
|
typedef FfxInt32 Prefix##_I; \
|
||||||
|
typedef FfxInt32x2 Prefix##_I2; \
|
||||||
|
typedef FfxInt32x3 Prefix##_I3; \
|
||||||
|
typedef FfxInt32x4 Prefix##_I4; \
|
||||||
|
typedef FfxUInt32 Prefix##_U; \
|
||||||
|
typedef FfxUInt32x2 Prefix##_U2; \
|
||||||
|
typedef FfxUInt32x3 Prefix##_U3; \
|
||||||
|
typedef FfxUInt32x4 Prefix##_U4;
|
||||||
|
#endif // #if defined(FFX_HLSL)
|
||||||
|
|
||||||
|
#if defined(SHADER_API_PSSL)
|
||||||
|
|
||||||
|
#define unorm
|
||||||
|
#define globallycoherent
|
||||||
|
|
||||||
|
#if FFX_HALF
|
||||||
|
|
||||||
|
#define FFX_MIN16_F half
|
||||||
|
#define FFX_MIN16_F2 half2
|
||||||
|
#define FFX_MIN16_F3 half3
|
||||||
|
#define FFX_MIN16_F4 half4
|
||||||
|
|
||||||
|
#define FFX_MIN16_I short
|
||||||
|
#define FFX_MIN16_I2 short2
|
||||||
|
#define FFX_MIN16_I3 short3
|
||||||
|
#define FFX_MIN16_I4 short4
|
||||||
|
|
||||||
|
#define FFX_MIN16_U ushort
|
||||||
|
#define FFX_MIN16_U2 ushort2
|
||||||
|
#define FFX_MIN16_U3 ushort3
|
||||||
|
#define FFX_MIN16_U4 ushort4
|
||||||
|
|
||||||
|
#define FFX_16BIT_F half
|
||||||
|
#define FFX_16BIT_F2 half2
|
||||||
|
#define FFX_16BIT_F3 half3
|
||||||
|
#define FFX_16BIT_F4 half4
|
||||||
|
|
||||||
|
#define FFX_16BIT_I short
|
||||||
|
#define FFX_16BIT_I2 short2
|
||||||
|
#define FFX_16BIT_I3 short3
|
||||||
|
#define FFX_16BIT_I4 short4
|
||||||
|
|
||||||
|
#define FFX_16BIT_U ushort
|
||||||
|
#define FFX_16BIT_U2 ushort2
|
||||||
|
#define FFX_16BIT_U3 ushort3
|
||||||
|
#define FFX_16BIT_U4 ushort4
|
||||||
|
|
||||||
|
#else // FFX_HALF
|
||||||
|
|
||||||
|
#define FFX_MIN16_F float
|
||||||
|
#define FFX_MIN16_F2 float2
|
||||||
|
#define FFX_MIN16_F3 float3
|
||||||
|
#define FFX_MIN16_F4 float4
|
||||||
|
|
||||||
|
#define FFX_MIN16_I int
|
||||||
|
#define FFX_MIN16_I2 int2
|
||||||
|
#define FFX_MIN16_I3 int3
|
||||||
|
#define FFX_MIN16_I4 int4
|
||||||
|
|
||||||
|
#define FFX_MIN16_U uint
|
||||||
|
#define FFX_MIN16_U2 uint2
|
||||||
|
#define FFX_MIN16_U3 uint3
|
||||||
|
#define FFX_MIN16_U4 uint4
|
||||||
|
|
||||||
|
#define FFX_16BIT_F float
|
||||||
|
#define FFX_16BIT_F2 float2
|
||||||
|
#define FFX_16BIT_F3 float3
|
||||||
|
#define FFX_16BIT_F4 float4
|
||||||
|
|
||||||
|
#define FFX_16BIT_I int
|
||||||
|
#define FFX_16BIT_I2 int2
|
||||||
|
#define FFX_16BIT_I3 int3
|
||||||
|
#define FFX_16BIT_I4 int4
|
||||||
|
|
||||||
|
#define FFX_16BIT_U uint
|
||||||
|
#define FFX_16BIT_U2 uint2
|
||||||
|
#define FFX_16BIT_U3 uint3
|
||||||
|
#define FFX_16BIT_U4 uint4
|
||||||
|
|
||||||
|
#endif // FFX_HALF
|
||||||
|
|
||||||
|
#endif // #if defined(SHADER_API_PSSL)
|
||||||
|
|
||||||
|
#if defined(FFX_GLSL)
|
||||||
|
|
||||||
|
#if FFX_HALF
|
||||||
|
|
||||||
|
#define FFX_MIN16_F float16_t
|
||||||
|
#define FFX_MIN16_F2 f16vec2
|
||||||
|
#define FFX_MIN16_F3 f16vec3
|
||||||
|
#define FFX_MIN16_F4 f16vec4
|
||||||
|
|
||||||
|
#define FFX_MIN16_I int16_t
|
||||||
|
#define FFX_MIN16_I2 i16vec2
|
||||||
|
#define FFX_MIN16_I3 i16vec3
|
||||||
|
#define FFX_MIN16_I4 i16vec4
|
||||||
|
|
||||||
|
#define FFX_MIN16_U uint16_t
|
||||||
|
#define FFX_MIN16_U2 u16vec2
|
||||||
|
#define FFX_MIN16_U3 u16vec3
|
||||||
|
#define FFX_MIN16_U4 u16vec4
|
||||||
|
|
||||||
|
#define FFX_16BIT_F float16_t
|
||||||
|
#define FFX_16BIT_F2 f16vec2
|
||||||
|
#define FFX_16BIT_F3 f16vec3
|
||||||
|
#define FFX_16BIT_F4 f16vec4
|
||||||
|
|
||||||
|
#define FFX_16BIT_I int16_t
|
||||||
|
#define FFX_16BIT_I2 i16vec2
|
||||||
|
#define FFX_16BIT_I3 i16vec3
|
||||||
|
#define FFX_16BIT_I4 i16vec4
|
||||||
|
|
||||||
|
#define FFX_16BIT_U uint16_t
|
||||||
|
#define FFX_16BIT_U2 u16vec2
|
||||||
|
#define FFX_16BIT_U3 u16vec3
|
||||||
|
#define FFX_16BIT_U4 u16vec4
|
||||||
|
|
||||||
|
#else // FFX_HALF
|
||||||
|
|
||||||
|
#define FFX_MIN16_F float
|
||||||
|
#define FFX_MIN16_F2 vec2
|
||||||
|
#define FFX_MIN16_F3 vec3
|
||||||
|
#define FFX_MIN16_F4 vec4
|
||||||
|
|
||||||
|
#define FFX_MIN16_I int
|
||||||
|
#define FFX_MIN16_I2 ivec2
|
||||||
|
#define FFX_MIN16_I3 ivec3
|
||||||
|
#define FFX_MIN16_I4 ivec4
|
||||||
|
|
||||||
|
#define FFX_MIN16_U uint
|
||||||
|
#define FFX_MIN16_U2 uvec2
|
||||||
|
#define FFX_MIN16_U3 uvec3
|
||||||
|
#define FFX_MIN16_U4 uvec4
|
||||||
|
|
||||||
|
#define FFX_16BIT_F float
|
||||||
|
#define FFX_16BIT_F2 vec2
|
||||||
|
#define FFX_16BIT_F3 vec3
|
||||||
|
#define FFX_16BIT_F4 vec4
|
||||||
|
|
||||||
|
#define FFX_16BIT_I int
|
||||||
|
#define FFX_16BIT_I2 ivec2
|
||||||
|
#define FFX_16BIT_I3 ivec3
|
||||||
|
#define FFX_16BIT_I4 ivec4
|
||||||
|
|
||||||
|
#define FFX_16BIT_U uint
|
||||||
|
#define FFX_16BIT_U2 uvec2
|
||||||
|
#define FFX_16BIT_U3 uvec3
|
||||||
|
#define FFX_16BIT_U4 uvec4
|
||||||
|
|
||||||
|
#endif // FFX_HALF
|
||||||
|
|
||||||
|
#endif // #if defined(FFX_GLSL)
|
||||||
|
|
||||||
|
#endif // #if defined(FFX_GPU)
|
||||||
|
#endif // #ifndef FFX_COMMON_TYPES_H
|
||||||
@ -0,0 +1,27 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 7974b728d5c1b6d4a8a8e3965d03f96d
|
||||||
|
PluginImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
iconMap: {}
|
||||||
|
executionOrder: {}
|
||||||
|
defineConstraints: []
|
||||||
|
isPreloaded: 0
|
||||||
|
isOverridable: 0
|
||||||
|
isExplicitlyReferenced: 0
|
||||||
|
validateReferences: 1
|
||||||
|
platformData:
|
||||||
|
- first:
|
||||||
|
Any:
|
||||||
|
second:
|
||||||
|
enabled: 1
|
||||||
|
settings: {}
|
||||||
|
- first:
|
||||||
|
Editor: Editor
|
||||||
|
second:
|
||||||
|
enabled: 0
|
||||||
|
settings:
|
||||||
|
DefaultValueInitialized: true
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
@ -0,0 +1,80 @@
|
|||||||
|
// This file is part of the FidelityFX SDK.
|
||||||
|
//
|
||||||
|
// Copyright (c) 2023 Advanced Micro Devices, Inc. All rights reserved.
|
||||||
|
//
|
||||||
|
// 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.
|
||||||
|
|
||||||
|
|
||||||
|
/// @defgroup FfxGPU GPU
|
||||||
|
/// The FidelityFX SDK GPU References
|
||||||
|
///
|
||||||
|
/// @ingroup ffxSDK
|
||||||
|
|
||||||
|
/// @defgroup FfxHLSL HLSL References
|
||||||
|
/// FidelityFX SDK HLSL GPU References
|
||||||
|
///
|
||||||
|
/// @ingroup FfxGPU
|
||||||
|
|
||||||
|
/// @defgroup FfxGLSL GLSL References
|
||||||
|
/// FidelityFX SDK GLSL GPU References
|
||||||
|
///
|
||||||
|
/// @ingroup FfxGPU
|
||||||
|
|
||||||
|
/// @defgroup FfxGPUEffects FidelityFX GPU References
|
||||||
|
/// FidelityFX Effect GPU Reference Documentation
|
||||||
|
///
|
||||||
|
/// @ingroup FfxGPU
|
||||||
|
|
||||||
|
/// @defgroup GPUCore GPU Core
|
||||||
|
/// GPU defines and functions
|
||||||
|
///
|
||||||
|
/// @ingroup FfxGPU
|
||||||
|
|
||||||
|
#if !defined(FFX_CORE_H)
|
||||||
|
#define FFX_CORE_H
|
||||||
|
|
||||||
|
#ifdef __hlsl_dx_compiler
|
||||||
|
#pragma dxc diagnostic push
|
||||||
|
#pragma dxc diagnostic ignored "-Wambig-lit-shift"
|
||||||
|
#endif //__hlsl_dx_compiler
|
||||||
|
|
||||||
|
#include "ffx_common_types.h"
|
||||||
|
|
||||||
|
#if defined(FFX_CPU)
|
||||||
|
#include "ffx_core_cpu.h"
|
||||||
|
#endif // #if defined(FFX_CPU)
|
||||||
|
|
||||||
|
#if defined(FFX_GLSL) && defined(FFX_GPU)
|
||||||
|
#include "ffx_core_glsl.h"
|
||||||
|
#endif // #if defined(FFX_GLSL) && defined(FFX_GPU)
|
||||||
|
|
||||||
|
#if defined(FFX_HLSL) && defined(FFX_GPU)
|
||||||
|
#include "ffx_core_hlsl.h"
|
||||||
|
#endif // #if defined(FFX_HLSL) && defined(FFX_GPU)
|
||||||
|
|
||||||
|
#if defined(FFX_GPU)
|
||||||
|
#include "ffx_core_gpu_common.h"
|
||||||
|
#include "ffx_core_gpu_common_half.h"
|
||||||
|
#include "ffx_core_portability.h"
|
||||||
|
#endif // #if defined(FFX_GPU)
|
||||||
|
|
||||||
|
#ifdef __hlsl_dx_compiler
|
||||||
|
#pragma dxc diagnostic pop
|
||||||
|
#endif //__hlsl_dx_compiler
|
||||||
|
|
||||||
|
#endif // #if !defined(FFX_CORE_H)
|
||||||
@ -0,0 +1,27 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: b91c5f52b89ff554dacb51045a802ed8
|
||||||
|
PluginImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
iconMap: {}
|
||||||
|
executionOrder: {}
|
||||||
|
defineConstraints: []
|
||||||
|
isPreloaded: 0
|
||||||
|
isOverridable: 0
|
||||||
|
isExplicitlyReferenced: 0
|
||||||
|
validateReferences: 1
|
||||||
|
platformData:
|
||||||
|
- first:
|
||||||
|
Any:
|
||||||
|
second:
|
||||||
|
enabled: 1
|
||||||
|
settings: {}
|
||||||
|
- first:
|
||||||
|
Editor: Editor
|
||||||
|
second:
|
||||||
|
enabled: 0
|
||||||
|
settings:
|
||||||
|
DefaultValueInitialized: true
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
@ -0,0 +1,338 @@
|
|||||||
|
// This file is part of the FidelityFX SDK.
|
||||||
|
//
|
||||||
|
// Copyright (c) 2023 Advanced Micro Devices, Inc. All rights reserved.
|
||||||
|
//
|
||||||
|
// 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.
|
||||||
|
|
||||||
|
|
||||||
|
/// A define for a true value in a boolean expression.
|
||||||
|
///
|
||||||
|
/// @ingroup CPUTypes
|
||||||
|
#define FFX_TRUE (1)
|
||||||
|
|
||||||
|
/// A define for a false value in a boolean expression.
|
||||||
|
///
|
||||||
|
/// @ingroup CPUTypes
|
||||||
|
#define FFX_FALSE (0)
|
||||||
|
|
||||||
|
#if !defined(FFX_STATIC)
|
||||||
|
/// A define to abstract declaration of static variables and functions.
|
||||||
|
///
|
||||||
|
/// @ingroup CPUTypes
|
||||||
|
#define FFX_STATIC static
|
||||||
|
#endif // #if !defined(FFX_STATIC)
|
||||||
|
|
||||||
|
/// @defgroup CPUCore CPU Core
|
||||||
|
/// Core CPU-side defines and functions
|
||||||
|
///
|
||||||
|
/// @ingroup ffxHost
|
||||||
|
|
||||||
|
#ifdef __clang__
|
||||||
|
#pragma clang diagnostic ignored "-Wunused-variable"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/// Interpret the bit layout of an IEEE-754 floating point value as an unsigned integer.
|
||||||
|
///
|
||||||
|
/// @param [in] x A 32bit floating value.
|
||||||
|
///
|
||||||
|
/// @returns
|
||||||
|
/// An unsigned 32bit integer value containing the bit pattern of <c><i>x</i></c>.
|
||||||
|
///
|
||||||
|
/// @ingroup CPUCore
|
||||||
|
FFX_STATIC FfxUInt32 ffxAsUInt32(FfxFloat32 x)
|
||||||
|
{
|
||||||
|
union
|
||||||
|
{
|
||||||
|
FfxFloat32 f;
|
||||||
|
FfxUInt32 u;
|
||||||
|
} bits;
|
||||||
|
|
||||||
|
bits.f = x;
|
||||||
|
return bits.u;
|
||||||
|
}
|
||||||
|
|
||||||
|
FFX_STATIC FfxFloat32 ffxDot2(FfxFloat32x2 a, FfxFloat32x2 b)
|
||||||
|
{
|
||||||
|
return a[0] * b[0] + a[1] * b[1];
|
||||||
|
}
|
||||||
|
|
||||||
|
FFX_STATIC FfxFloat32 ffxDot3(FfxFloat32x3 a, FfxFloat32x3 b)
|
||||||
|
{
|
||||||
|
return a[0] * b[0] + a[1] * b[1] + a[2] * b[2];
|
||||||
|
}
|
||||||
|
|
||||||
|
FFX_STATIC FfxFloat32 ffxDot4(FfxFloat32x4 a, FfxFloat32x4 b)
|
||||||
|
{
|
||||||
|
return a[0] * b[0] + a[1] * b[1] + a[2] * b[2] + a[3] * b[3];
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Compute the linear interopation between two values.
|
||||||
|
///
|
||||||
|
/// Implemented by calling the GLSL <c><i>mix</i></c> instrinsic function. Implements the
|
||||||
|
/// following math:
|
||||||
|
///
|
||||||
|
/// (1 - t) * x + t * y
|
||||||
|
///
|
||||||
|
/// @param [in] x The first value to lerp between.
|
||||||
|
/// @param [in] y The second value to lerp between.
|
||||||
|
/// @param [in] t The value to determine how much of <c><i>x</i></c> and how much of <c><i>y</i></c>.
|
||||||
|
///
|
||||||
|
/// @returns
|
||||||
|
/// A linearly interpolated value between <c><i>x</i></c> and <c><i>y</i></c> according to <c><i>t</i></c>.
|
||||||
|
///
|
||||||
|
/// @ingroup CPUCore
|
||||||
|
FFX_STATIC FfxFloat32 ffxLerp(FfxFloat32 x, FfxFloat32 y, FfxFloat32 t)
|
||||||
|
{
|
||||||
|
return y * t + (-x * t + x);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Compute the reciprocal of a value.
|
||||||
|
///
|
||||||
|
/// @param [in] x The value to compute the reciprocal for.
|
||||||
|
///
|
||||||
|
/// @returns
|
||||||
|
/// The reciprocal value of <c><i>x</i></c>.
|
||||||
|
///
|
||||||
|
/// @ingroup CPUCore
|
||||||
|
FFX_STATIC FfxFloat32 ffxReciprocal(FfxFloat32 x)
|
||||||
|
{
|
||||||
|
return 1.0f / x;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Compute the square root of a value.
|
||||||
|
///
|
||||||
|
/// @param [in] x The first value to compute the min of.
|
||||||
|
///
|
||||||
|
/// @returns
|
||||||
|
/// The the square root of <c><i>x</i></c>.
|
||||||
|
///
|
||||||
|
/// @ingroup CPUCore
|
||||||
|
FFX_STATIC FfxFloat32 ffxSqrt(FfxFloat32 x)
|
||||||
|
{
|
||||||
|
return sqrt(x);
|
||||||
|
}
|
||||||
|
|
||||||
|
FFX_STATIC FfxUInt32 AShrSU1(FfxUInt32 a, FfxUInt32 b)
|
||||||
|
{
|
||||||
|
return FfxUInt32(FfxInt32(a) >> FfxInt32(b));
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Compute the factional part of a decimal value.
|
||||||
|
///
|
||||||
|
/// This function calculates <c><i>x - floor(x)</i></c>.
|
||||||
|
///
|
||||||
|
/// @param [in] x The value to compute the fractional part from.
|
||||||
|
///
|
||||||
|
/// @returns
|
||||||
|
/// The fractional part of <c><i>x</i></c>.
|
||||||
|
///
|
||||||
|
/// @ingroup CPUCore
|
||||||
|
FFX_STATIC FfxFloat32 ffxFract(FfxFloat32 x)
|
||||||
|
{
|
||||||
|
return x - floor(x);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Compute the reciprocal square root of a value.
|
||||||
|
///
|
||||||
|
/// @param [in] x The value to compute the reciprocal for.
|
||||||
|
///
|
||||||
|
/// @returns
|
||||||
|
/// The reciprocal square root value of <c><i>x</i></c>.
|
||||||
|
///
|
||||||
|
/// @ingroup CPUCore
|
||||||
|
FFX_STATIC FfxFloat32 rsqrt(FfxFloat32 x)
|
||||||
|
{
|
||||||
|
return ffxReciprocal(ffxSqrt(x));
|
||||||
|
}
|
||||||
|
|
||||||
|
FFX_STATIC FfxFloat32 ffxMin(FfxFloat32 x, FfxFloat32 y)
|
||||||
|
{
|
||||||
|
return x < y ? x : y;
|
||||||
|
}
|
||||||
|
|
||||||
|
FFX_STATIC FfxUInt32 ffxMin(FfxUInt32 x, FfxUInt32 y)
|
||||||
|
{
|
||||||
|
return x < y ? x : y;
|
||||||
|
}
|
||||||
|
|
||||||
|
FFX_STATIC FfxFloat32 ffxMax(FfxFloat32 x, FfxFloat32 y)
|
||||||
|
{
|
||||||
|
return x > y ? x : y;
|
||||||
|
}
|
||||||
|
|
||||||
|
FFX_STATIC FfxUInt32 ffxMax(FfxUInt32 x, FfxUInt32 y)
|
||||||
|
{
|
||||||
|
return x > y ? x : y;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Clamp a value to a [0..1] range.
|
||||||
|
///
|
||||||
|
/// @param [in] x The value to clamp to [0..1] range.
|
||||||
|
///
|
||||||
|
/// @returns
|
||||||
|
/// The clamped version of <c><i>x</i></c>.
|
||||||
|
///
|
||||||
|
/// @ingroup CPUCore
|
||||||
|
FFX_STATIC FfxFloat32 ffxSaturate(FfxFloat32 x)
|
||||||
|
{
|
||||||
|
return ffxMin(1.0f, ffxMax(0.0f, x));
|
||||||
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
FFX_STATIC void opAAddOneF3(FfxFloat32x3 d, FfxFloat32x3 a, FfxFloat32 b)
|
||||||
|
{
|
||||||
|
d[0] = a[0] + b;
|
||||||
|
d[1] = a[1] + b;
|
||||||
|
d[2] = a[2] + b;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
FFX_STATIC void opACpyF3(FfxFloat32x3 d, FfxFloat32x3 a)
|
||||||
|
{
|
||||||
|
d[0] = a[0];
|
||||||
|
d[1] = a[1];
|
||||||
|
d[2] = a[2];
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
FFX_STATIC void opAMulF3(FfxFloat32x3 d, FfxFloat32x3 a, FfxFloat32x3 b)
|
||||||
|
{
|
||||||
|
d[0] = a[0] * b[0];
|
||||||
|
d[1] = a[1] * b[1];
|
||||||
|
d[2] = a[2] * b[2];
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
FFX_STATIC void opAMulOneF3(FfxFloat32x3 d, FfxFloat32x3 a, FfxFloat32 b)
|
||||||
|
{
|
||||||
|
d[0] = a[0] * b;
|
||||||
|
d[1] = a[1] * b;
|
||||||
|
d[2] = a[2] * b;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
FFX_STATIC void opARcpF3(FfxFloat32x3 d, FfxFloat32x3 a)
|
||||||
|
{
|
||||||
|
d[0] = ffxReciprocal(a[0]);
|
||||||
|
d[1] = ffxReciprocal(a[1]);
|
||||||
|
d[2] = ffxReciprocal(a[2]);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Convert FfxFloat32 to half (in lower 16-bits of output).
|
||||||
|
///
|
||||||
|
/// This function implements the same fast technique that is documented here: ftp://ftp.fox-toolkit.org/pub/fasthalffloatconversion.pdf
|
||||||
|
///
|
||||||
|
/// The function supports denormals.
|
||||||
|
///
|
||||||
|
/// Some conversion rules are to make computations possibly "safer" on the GPU,
|
||||||
|
/// -INF & -NaN -> -65504
|
||||||
|
/// +INF & +NaN -> +65504
|
||||||
|
///
|
||||||
|
/// @param [in] f The 32bit floating point value to convert.
|
||||||
|
///
|
||||||
|
/// @returns
|
||||||
|
/// The closest 16bit floating point value to <c><i>f</i></c>.
|
||||||
|
///
|
||||||
|
/// @ingroup CPUCore
|
||||||
|
FFX_STATIC FfxUInt32 f32tof16(FfxFloat32 f)
|
||||||
|
{
|
||||||
|
static FfxUInt16 base[512] = {
|
||||||
|
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
|
||||||
|
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
|
||||||
|
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
|
||||||
|
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
|
||||||
|
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
|
||||||
|
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0001, 0x0002, 0x0004, 0x0008, 0x0010, 0x0020, 0x0040, 0x0080, 0x0100, 0x0200, 0x0400,
|
||||||
|
0x0800, 0x0c00, 0x1000, 0x1400, 0x1800, 0x1c00, 0x2000, 0x2400, 0x2800, 0x2c00, 0x3000, 0x3400, 0x3800, 0x3c00, 0x4000, 0x4400, 0x4800, 0x4c00, 0x5000,
|
||||||
|
0x5400, 0x5800, 0x5c00, 0x6000, 0x6400, 0x6800, 0x6c00, 0x7000, 0x7400, 0x7800, 0x7bff, 0x7bff, 0x7bff, 0x7bff, 0x7bff, 0x7bff, 0x7bff, 0x7bff, 0x7bff,
|
||||||
|
0x7bff, 0x7bff, 0x7bff, 0x7bff, 0x7bff, 0x7bff, 0x7bff, 0x7bff, 0x7bff, 0x7bff, 0x7bff, 0x7bff, 0x7bff, 0x7bff, 0x7bff, 0x7bff, 0x7bff, 0x7bff, 0x7bff,
|
||||||
|
0x7bff, 0x7bff, 0x7bff, 0x7bff, 0x7bff, 0x7bff, 0x7bff, 0x7bff, 0x7bff, 0x7bff, 0x7bff, 0x7bff, 0x7bff, 0x7bff, 0x7bff, 0x7bff, 0x7bff, 0x7bff, 0x7bff,
|
||||||
|
0x7bff, 0x7bff, 0x7bff, 0x7bff, 0x7bff, 0x7bff, 0x7bff, 0x7bff, 0x7bff, 0x7bff, 0x7bff, 0x7bff, 0x7bff, 0x7bff, 0x7bff, 0x7bff, 0x7bff, 0x7bff, 0x7bff,
|
||||||
|
0x7bff, 0x7bff, 0x7bff, 0x7bff, 0x7bff, 0x7bff, 0x7bff, 0x7bff, 0x7bff, 0x7bff, 0x7bff, 0x7bff, 0x7bff, 0x7bff, 0x7bff, 0x7bff, 0x7bff, 0x7bff, 0x7bff,
|
||||||
|
0x7bff, 0x7bff, 0x7bff, 0x7bff, 0x7bff, 0x7bff, 0x7bff, 0x7bff, 0x7bff, 0x7bff, 0x7bff, 0x7bff, 0x7bff, 0x7bff, 0x7bff, 0x7bff, 0x7bff, 0x7bff, 0x7bff,
|
||||||
|
0x7bff, 0x7bff, 0x7bff, 0x7bff, 0x7bff, 0x7bff, 0x7bff, 0x7bff, 0x7bff, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000,
|
||||||
|
0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000,
|
||||||
|
0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000,
|
||||||
|
0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000,
|
||||||
|
0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000,
|
||||||
|
0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8001, 0x8002,
|
||||||
|
0x8004, 0x8008, 0x8010, 0x8020, 0x8040, 0x8080, 0x8100, 0x8200, 0x8400, 0x8800, 0x8c00, 0x9000, 0x9400, 0x9800, 0x9c00, 0xa000, 0xa400, 0xa800, 0xac00,
|
||||||
|
0xb000, 0xb400, 0xb800, 0xbc00, 0xc000, 0xc400, 0xc800, 0xcc00, 0xd000, 0xd400, 0xd800, 0xdc00, 0xe000, 0xe400, 0xe800, 0xec00, 0xf000, 0xf400, 0xf800,
|
||||||
|
0xfbff, 0xfbff, 0xfbff, 0xfbff, 0xfbff, 0xfbff, 0xfbff, 0xfbff, 0xfbff, 0xfbff, 0xfbff, 0xfbff, 0xfbff, 0xfbff, 0xfbff, 0xfbff, 0xfbff, 0xfbff, 0xfbff,
|
||||||
|
0xfbff, 0xfbff, 0xfbff, 0xfbff, 0xfbff, 0xfbff, 0xfbff, 0xfbff, 0xfbff, 0xfbff, 0xfbff, 0xfbff, 0xfbff, 0xfbff, 0xfbff, 0xfbff, 0xfbff, 0xfbff, 0xfbff,
|
||||||
|
0xfbff, 0xfbff, 0xfbff, 0xfbff, 0xfbff, 0xfbff, 0xfbff, 0xfbff, 0xfbff, 0xfbff, 0xfbff, 0xfbff, 0xfbff, 0xfbff, 0xfbff, 0xfbff, 0xfbff, 0xfbff, 0xfbff,
|
||||||
|
0xfbff, 0xfbff, 0xfbff, 0xfbff, 0xfbff, 0xfbff, 0xfbff, 0xfbff, 0xfbff, 0xfbff, 0xfbff, 0xfbff, 0xfbff, 0xfbff, 0xfbff, 0xfbff, 0xfbff, 0xfbff, 0xfbff,
|
||||||
|
0xfbff, 0xfbff, 0xfbff, 0xfbff, 0xfbff, 0xfbff, 0xfbff, 0xfbff, 0xfbff, 0xfbff, 0xfbff, 0xfbff, 0xfbff, 0xfbff, 0xfbff, 0xfbff, 0xfbff, 0xfbff, 0xfbff,
|
||||||
|
0xfbff, 0xfbff, 0xfbff, 0xfbff, 0xfbff, 0xfbff, 0xfbff, 0xfbff, 0xfbff, 0xfbff, 0xfbff, 0xfbff, 0xfbff, 0xfbff, 0xfbff, 0xfbff, 0xfbff, 0xfbff
|
||||||
|
};
|
||||||
|
|
||||||
|
static FfxUInt8 shift[512] = {
|
||||||
|
0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18,
|
||||||
|
0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18,
|
||||||
|
0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18,
|
||||||
|
0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18,
|
||||||
|
0x18, 0x18, 0x18, 0x17, 0x16, 0x15, 0x14, 0x13, 0x12, 0x11, 0x10, 0x0f, 0x0e, 0x0d, 0x0d, 0x0d, 0x0d, 0x0d, 0x0d, 0x0d, 0x0d, 0x0d, 0x0d, 0x0d, 0x0d,
|
||||||
|
0x0d, 0x0d, 0x0d, 0x0d, 0x0d, 0x0d, 0x0d, 0x0d, 0x0d, 0x0d, 0x0d, 0x0d, 0x0d, 0x0d, 0x0d, 0x0d, 0x0d, 0x0d, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18,
|
||||||
|
0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18,
|
||||||
|
0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18,
|
||||||
|
0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18,
|
||||||
|
0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18,
|
||||||
|
0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18,
|
||||||
|
0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18,
|
||||||
|
0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18,
|
||||||
|
0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18,
|
||||||
|
0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x17, 0x16, 0x15, 0x14, 0x13, 0x12, 0x11, 0x10, 0x0f, 0x0e, 0x0d, 0x0d, 0x0d, 0x0d, 0x0d, 0x0d,
|
||||||
|
0x0d, 0x0d, 0x0d, 0x0d, 0x0d, 0x0d, 0x0d, 0x0d, 0x0d, 0x0d, 0x0d, 0x0d, 0x0d, 0x0d, 0x0d, 0x0d, 0x0d, 0x0d, 0x0d, 0x0d, 0x0d, 0x0d, 0x0d, 0x0d, 0x18,
|
||||||
|
0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18,
|
||||||
|
0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18,
|
||||||
|
0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18,
|
||||||
|
0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18,
|
||||||
|
0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18
|
||||||
|
};
|
||||||
|
|
||||||
|
union
|
||||||
|
{
|
||||||
|
FfxFloat32 f;
|
||||||
|
FfxUInt32 u;
|
||||||
|
} bits;
|
||||||
|
|
||||||
|
bits.f = f;
|
||||||
|
FfxUInt32 u = bits.u;
|
||||||
|
FfxUInt32 i = u >> 23;
|
||||||
|
return (FfxUInt32)(base[i]) + ((u & 0x7fffff) >> shift[i]);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Pack 2x32-bit floating point values in a single 32bit value.
|
||||||
|
///
|
||||||
|
/// This function first converts each component of <c><i>value</i></c> into their nearest 16-bit floating
|
||||||
|
/// point representation, and then stores the X and Y components in the lower and upper 16 bits of the
|
||||||
|
/// 32bit unsigned integer respectively.
|
||||||
|
///
|
||||||
|
/// @param [in] x A 2-dimensional floating point value to convert and pack.
|
||||||
|
///
|
||||||
|
/// @returns
|
||||||
|
/// A packed 32bit value containing 2 16bit floating point values.
|
||||||
|
///
|
||||||
|
/// @ingroup CPUCore
|
||||||
|
FFX_STATIC FfxUInt32 packHalf2x16(FfxFloat32x2 x)
|
||||||
|
{
|
||||||
|
return f32tof16(x[0]) + (f32tof16(x[1]) << 16);
|
||||||
|
}
|
||||||
@ -0,0 +1,27 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 4c88c0b7a4dec1e479272449c19ca981
|
||||||
|
PluginImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
iconMap: {}
|
||||||
|
executionOrder: {}
|
||||||
|
defineConstraints: []
|
||||||
|
isPreloaded: 0
|
||||||
|
isOverridable: 0
|
||||||
|
isExplicitlyReferenced: 0
|
||||||
|
validateReferences: 1
|
||||||
|
platformData:
|
||||||
|
- first:
|
||||||
|
Any:
|
||||||
|
second:
|
||||||
|
enabled: 1
|
||||||
|
settings: {}
|
||||||
|
- first:
|
||||||
|
Editor: Editor
|
||||||
|
second:
|
||||||
|
enabled: 0
|
||||||
|
settings:
|
||||||
|
DefaultValueInitialized: true
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,27 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 05b921699d1374a429e32afca13137e2
|
||||||
|
PluginImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
iconMap: {}
|
||||||
|
executionOrder: {}
|
||||||
|
defineConstraints: []
|
||||||
|
isPreloaded: 0
|
||||||
|
isOverridable: 0
|
||||||
|
isExplicitlyReferenced: 0
|
||||||
|
validateReferences: 1
|
||||||
|
platformData:
|
||||||
|
- first:
|
||||||
|
Any:
|
||||||
|
second:
|
||||||
|
enabled: 1
|
||||||
|
settings: {}
|
||||||
|
- first:
|
||||||
|
Editor: Editor
|
||||||
|
second:
|
||||||
|
enabled: 0
|
||||||
|
settings:
|
||||||
|
DefaultValueInitialized: true
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,27 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 1bdb323791a91a5438ee8e1e63187840
|
||||||
|
PluginImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
iconMap: {}
|
||||||
|
executionOrder: {}
|
||||||
|
defineConstraints: []
|
||||||
|
isPreloaded: 0
|
||||||
|
isOverridable: 0
|
||||||
|
isExplicitlyReferenced: 0
|
||||||
|
validateReferences: 1
|
||||||
|
platformData:
|
||||||
|
- first:
|
||||||
|
Any:
|
||||||
|
second:
|
||||||
|
enabled: 1
|
||||||
|
settings: {}
|
||||||
|
- first:
|
||||||
|
Editor: Editor
|
||||||
|
second:
|
||||||
|
enabled: 0
|
||||||
|
settings:
|
||||||
|
DefaultValueInitialized: true
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,27 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 299f67e8b7e1d1a48a577bf8b328ac92
|
||||||
|
PluginImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
iconMap: {}
|
||||||
|
executionOrder: {}
|
||||||
|
defineConstraints: []
|
||||||
|
isPreloaded: 0
|
||||||
|
isOverridable: 0
|
||||||
|
isExplicitlyReferenced: 0
|
||||||
|
validateReferences: 1
|
||||||
|
platformData:
|
||||||
|
- first:
|
||||||
|
Any:
|
||||||
|
second:
|
||||||
|
enabled: 1
|
||||||
|
settings: {}
|
||||||
|
- first:
|
||||||
|
Editor: Editor
|
||||||
|
second:
|
||||||
|
enabled: 0
|
||||||
|
settings:
|
||||||
|
DefaultValueInitialized: true
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
@ -0,0 +1,51 @@
|
|||||||
|
// This file is part of the FidelityFX SDK.
|
||||||
|
//
|
||||||
|
// Copyright (c) 2023 Advanced Micro Devices, Inc. All rights reserved.
|
||||||
|
//
|
||||||
|
// 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.
|
||||||
|
|
||||||
|
|
||||||
|
FfxFloat32x3 opAAddOneF3(FfxFloat32x3 d, FfxFloat32x3 a, FfxFloat32 b)
|
||||||
|
{
|
||||||
|
d = a + ffxBroadcast3(b);
|
||||||
|
return d;
|
||||||
|
}
|
||||||
|
|
||||||
|
FfxFloat32x3 opACpyF3(FfxFloat32x3 d, FfxFloat32x3 a)
|
||||||
|
{
|
||||||
|
d = a;
|
||||||
|
return d;
|
||||||
|
}
|
||||||
|
|
||||||
|
FfxFloat32x3 opAMulF3(FfxFloat32x3 d, FfxFloat32x3 a, FfxFloat32x3 b)
|
||||||
|
{
|
||||||
|
d = a * b;
|
||||||
|
return d;
|
||||||
|
}
|
||||||
|
|
||||||
|
FfxFloat32x3 opAMulOneF3(FfxFloat32x3 d, FfxFloat32x3 a, FfxFloat32 b)
|
||||||
|
{
|
||||||
|
d = a * ffxBroadcast3(b);
|
||||||
|
return d;
|
||||||
|
}
|
||||||
|
|
||||||
|
FfxFloat32x3 opARcpF3(FfxFloat32x3 d, FfxFloat32x3 a)
|
||||||
|
{
|
||||||
|
d = rcp(a);
|
||||||
|
return d;
|
||||||
|
}
|
||||||
@ -0,0 +1,27 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 8d2ace0bd52e0e1438e08ddaccd3ba24
|
||||||
|
PluginImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
iconMap: {}
|
||||||
|
executionOrder: {}
|
||||||
|
defineConstraints: []
|
||||||
|
isPreloaded: 0
|
||||||
|
isOverridable: 0
|
||||||
|
isExplicitlyReferenced: 0
|
||||||
|
validateReferences: 1
|
||||||
|
platformData:
|
||||||
|
- first:
|
||||||
|
Any:
|
||||||
|
second:
|
||||||
|
enabled: 1
|
||||||
|
settings: {}
|
||||||
|
- first:
|
||||||
|
Editor: Editor
|
||||||
|
second:
|
||||||
|
enabled: 0
|
||||||
|
settings:
|
||||||
|
DefaultValueInitialized: true
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
@ -0,0 +1,288 @@
|
|||||||
|
// This file is part of the FidelityFX SDK.
|
||||||
|
//
|
||||||
|
// Copyright (c) 2023 Advanced Micro Devices, Inc. All rights reserved.
|
||||||
|
//
|
||||||
|
// 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_FSR3UPSCALER_ACCUMULATE_H
|
||||||
|
#define FFX_FSR3UPSCALER_ACCUMULATE_H
|
||||||
|
|
||||||
|
FfxFloat32 GetPxHrVelocity(FfxFloat32x2 fMotionVector)
|
||||||
|
{
|
||||||
|
return length(fMotionVector * DisplaySize());
|
||||||
|
}
|
||||||
|
#if FFX_HALF
|
||||||
|
FFX_MIN16_F GetPxHrVelocity(FFX_MIN16_F2 fMotionVector)
|
||||||
|
{
|
||||||
|
return length(fMotionVector * FFX_MIN16_F2(DisplaySize()));
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
void Accumulate(const AccumulationPassCommonParams params, FFX_PARAMETER_INOUT FfxFloat32x3 fHistoryColor, FfxFloat32x3 fAccumulation, FFX_PARAMETER_IN FfxFloat32x4 fUpsampledColorAndWeight)
|
||||||
|
{
|
||||||
|
// Aviod invalid values when accumulation and upsampled weight is 0
|
||||||
|
fAccumulation = ffxMax(FSR3UPSCALER_EPSILON.xxx, fAccumulation + fUpsampledColorAndWeight.www);
|
||||||
|
|
||||||
|
#if FFX_FSR3UPSCALER_OPTION_HDR_COLOR_INPUT
|
||||||
|
//YCoCg -> RGB -> Tonemap -> YCoCg (Use RGB tonemapper to avoid color desaturation)
|
||||||
|
fUpsampledColorAndWeight.xyz = RGBToYCoCg(Tonemap(YCoCgToRGB(fUpsampledColorAndWeight.xyz)));
|
||||||
|
fHistoryColor = RGBToYCoCg(Tonemap(YCoCgToRGB(fHistoryColor)));
|
||||||
|
#endif
|
||||||
|
|
||||||
|
const FfxFloat32x3 fAlpha = fUpsampledColorAndWeight.www / fAccumulation;
|
||||||
|
fHistoryColor = ffxLerp(fHistoryColor, fUpsampledColorAndWeight.xyz, fAlpha);
|
||||||
|
|
||||||
|
fHistoryColor = YCoCgToRGB(fHistoryColor);
|
||||||
|
|
||||||
|
#if FFX_FSR3UPSCALER_OPTION_HDR_COLOR_INPUT
|
||||||
|
fHistoryColor = InverseTonemap(fHistoryColor);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
void RectifyHistory(
|
||||||
|
const AccumulationPassCommonParams params,
|
||||||
|
RectificationBox clippingBox,
|
||||||
|
FFX_PARAMETER_INOUT FfxFloat32x3 fHistoryColor,
|
||||||
|
FFX_PARAMETER_INOUT FfxFloat32x3 fAccumulation,
|
||||||
|
FfxFloat32 fLockContributionThisFrame,
|
||||||
|
FfxFloat32 fTemporalReactiveFactor,
|
||||||
|
FfxFloat32 fLumaInstabilityFactor)
|
||||||
|
{
|
||||||
|
const FfxFloat32 fVecolityFactor = ffxSaturate(params.fHrVelocity / 20.0f);
|
||||||
|
const FfxFloat32 fBoxScaleT = ffxMax(params.fDepthClipFactor, ffxMax(params.fAccumulationMask, fVecolityFactor));
|
||||||
|
const FfxFloat32 fBoxScale = ffxLerp(3.0f, 1.0f, fBoxScaleT);
|
||||||
|
|
||||||
|
const FfxFloat32x3 fScaledBoxVec = clippingBox.boxVec * fBoxScale;
|
||||||
|
const FfxFloat32x3 boxMin = clippingBox.boxCenter - fScaledBoxVec;
|
||||||
|
const FfxFloat32x3 boxMax = clippingBox.boxCenter + fScaledBoxVec;
|
||||||
|
|
||||||
|
if (any(FFX_GREATER_THAN(boxMin, fHistoryColor)) || any(FFX_GREATER_THAN(fHistoryColor, boxMax))) {
|
||||||
|
|
||||||
|
const FfxFloat32x3 fClampedHistoryColor = clamp(fHistoryColor, boxMin, boxMax);
|
||||||
|
|
||||||
|
FfxFloat32x3 fHistoryContribution = ffxMax(fLumaInstabilityFactor, fLockContributionThisFrame).xxx;
|
||||||
|
|
||||||
|
const FfxFloat32 fReactiveFactor = params.fDilatedReactiveFactor;
|
||||||
|
const FfxFloat32 fReactiveContribution = 1.0f - ffxPow(fReactiveFactor, 1.0f / 2.0f);
|
||||||
|
fHistoryContribution *= fReactiveContribution;
|
||||||
|
|
||||||
|
// Scale history color using rectification info, also using accumulation mask to avoid potential invalid color protection
|
||||||
|
fHistoryColor = ffxLerp(fClampedHistoryColor, fHistoryColor, ffxSaturate(fHistoryContribution));
|
||||||
|
|
||||||
|
// Scale accumulation using rectification info
|
||||||
|
const FfxFloat32x3 fAccumulationMin = ffxMin(fAccumulation, FFX_BROADCAST_FLOAT32X3(0.1f));
|
||||||
|
fAccumulation = ffxLerp(fAccumulationMin, fAccumulation, ffxSaturate(fHistoryContribution));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void WriteUpscaledOutput(FfxInt32x2 iPxHrPos, FfxFloat32x3 fUpscaledColor)
|
||||||
|
{
|
||||||
|
StoreUpscaledOutput(iPxHrPos, fUpscaledColor);
|
||||||
|
}
|
||||||
|
|
||||||
|
void FinalizeLockStatus(const AccumulationPassCommonParams params, FfxFloat32x2 fLockStatus, FfxFloat32 fUpsampledWeight)
|
||||||
|
{
|
||||||
|
// we expect similar motion for next frame
|
||||||
|
// kill lock if that location is outside screen, avoid locks to be clamped to screen borders
|
||||||
|
FfxFloat32x2 fEstimatedUvNextFrame = params.fHrUv - params.fMotionVector;
|
||||||
|
if (IsUvInside(fEstimatedUvNextFrame) == false) {
|
||||||
|
KillLock(fLockStatus);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
// Decrease lock lifetime
|
||||||
|
const FfxFloat32 fLifetimeDecreaseLanczosMax = FfxFloat32(JitterSequenceLength()) * FfxFloat32(fAverageLanczosWeightPerFrame);
|
||||||
|
const FfxFloat32 fLifetimeDecrease = FfxFloat32(fUpsampledWeight / fLifetimeDecreaseLanczosMax);
|
||||||
|
fLockStatus[LOCK_LIFETIME_REMAINING] = ffxMax(FfxFloat32(0), fLockStatus[LOCK_LIFETIME_REMAINING] - fLifetimeDecrease);
|
||||||
|
}
|
||||||
|
|
||||||
|
StoreLockStatus(params.iPxHrPos, fLockStatus);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
FfxFloat32x3 ComputeBaseAccumulationWeight(const AccumulationPassCommonParams params, FfxFloat32 fThisFrameReactiveFactor, FfxBoolean bInMotionLastFrame, FfxFloat32 fUpsampledWeight, LockState lockState)
|
||||||
|
{
|
||||||
|
// Always assume max accumulation was reached
|
||||||
|
FfxFloat32 fBaseAccumulation = fMaxAccumulationLanczosWeight * FfxFloat32(params.bIsExistingSample) * (1.0f - fThisFrameReactiveFactor) * (1.0f - params.fDepthClipFactor);
|
||||||
|
|
||||||
|
fBaseAccumulation = ffxMin(fBaseAccumulation, ffxLerp(fBaseAccumulation, fUpsampledWeight * 10.0f, ffxMax(FfxFloat32(bInMotionLastFrame), ffxSaturate(params.fHrVelocity * FfxFloat32(10)))));
|
||||||
|
|
||||||
|
fBaseAccumulation = ffxMin(fBaseAccumulation, ffxLerp(fBaseAccumulation, fUpsampledWeight, ffxSaturate(params.fHrVelocity / FfxFloat32(20))));
|
||||||
|
|
||||||
|
return fBaseAccumulation.xxx;
|
||||||
|
}
|
||||||
|
|
||||||
|
FfxFloat32 ComputeLumaInstabilityFactor(const AccumulationPassCommonParams params, RectificationBox clippingBox, FfxFloat32 fThisFrameReactiveFactor, FfxFloat32 fLuminanceDiff)
|
||||||
|
{
|
||||||
|
const FfxFloat32 fUnormThreshold = 1.0f / 255.0f;
|
||||||
|
const FfxInt32 N_MINUS_1 = 0;
|
||||||
|
const FfxInt32 N_MINUS_2 = 1;
|
||||||
|
const FfxInt32 N_MINUS_3 = 2;
|
||||||
|
const FfxInt32 N_MINUS_4 = 3;
|
||||||
|
|
||||||
|
FfxFloat32 fCurrentFrameLuma = clippingBox.boxCenter.x;
|
||||||
|
|
||||||
|
#if FFX_FSR3UPSCALER_OPTION_HDR_COLOR_INPUT
|
||||||
|
fCurrentFrameLuma = fCurrentFrameLuma / (1.0f + ffxMax(0.0f, fCurrentFrameLuma));
|
||||||
|
#endif
|
||||||
|
|
||||||
|
fCurrentFrameLuma = round(fCurrentFrameLuma * 255.0f) / 255.0f;
|
||||||
|
|
||||||
|
const FfxBoolean bSampleLumaHistory = (ffxMax(ffxMax(params.fDepthClipFactor, params.fAccumulationMask), fLuminanceDiff) < 0.1f) && (params.bIsNewSample == false);
|
||||||
|
FfxFloat32x4 fCurrentFrameLumaHistory = bSampleLumaHistory ? SampleLumaHistory(params.fReprojectedHrUv) : FFX_BROADCAST_FLOAT32X4(0.0f);
|
||||||
|
|
||||||
|
FfxFloat32 fLumaInstability = 0.0f;
|
||||||
|
FfxFloat32 fDiffs0 = (fCurrentFrameLuma - fCurrentFrameLumaHistory[N_MINUS_1]);
|
||||||
|
|
||||||
|
FfxFloat32 fMin = abs(fDiffs0);
|
||||||
|
|
||||||
|
if (fMin >= fUnormThreshold) {
|
||||||
|
for (int i = N_MINUS_2; i <= N_MINUS_4; i++) {
|
||||||
|
FfxFloat32 fDiffs1 = (fCurrentFrameLuma - fCurrentFrameLumaHistory[i]);
|
||||||
|
|
||||||
|
if (sign(fDiffs0) == sign(fDiffs1)) {
|
||||||
|
|
||||||
|
// Scale difference to protect historically similar values
|
||||||
|
const FfxFloat32 fMinBias = 1.0f;
|
||||||
|
fMin = ffxMin(fMin, abs(fDiffs1) * fMinBias);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const FfxFloat32 fBoxSize = clippingBox.boxVec.x;
|
||||||
|
const FfxFloat32 fBoxSizeFactor = ffxPow(ffxSaturate(fBoxSize / 0.1f), 6.0f);
|
||||||
|
|
||||||
|
fLumaInstability = FfxFloat32(fMin != abs(fDiffs0)) * fBoxSizeFactor;
|
||||||
|
fLumaInstability = FfxFloat32(fLumaInstability > fUnormThreshold);
|
||||||
|
|
||||||
|
fLumaInstability *= 1.0f - ffxMax(params.fAccumulationMask, ffxPow(fThisFrameReactiveFactor, 1.0f / 6.0f));
|
||||||
|
}
|
||||||
|
|
||||||
|
//shift history
|
||||||
|
fCurrentFrameLumaHistory[N_MINUS_4] = fCurrentFrameLumaHistory[N_MINUS_3];
|
||||||
|
fCurrentFrameLumaHistory[N_MINUS_3] = fCurrentFrameLumaHistory[N_MINUS_2];
|
||||||
|
fCurrentFrameLumaHistory[N_MINUS_2] = fCurrentFrameLumaHistory[N_MINUS_1];
|
||||||
|
fCurrentFrameLumaHistory[N_MINUS_1] = fCurrentFrameLuma;
|
||||||
|
|
||||||
|
StoreLumaHistory(params.iPxHrPos, fCurrentFrameLumaHistory);
|
||||||
|
|
||||||
|
return fLumaInstability * FfxFloat32(fCurrentFrameLumaHistory[N_MINUS_4] != 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
FfxFloat32 ComputeTemporalReactiveFactor(const AccumulationPassCommonParams params, FfxFloat32 fTemporalReactiveFactor)
|
||||||
|
{
|
||||||
|
FfxFloat32 fNewFactor = ffxMin(0.99f, fTemporalReactiveFactor);
|
||||||
|
|
||||||
|
fNewFactor = ffxMax(fNewFactor, ffxLerp(fNewFactor, 0.4f, ffxSaturate(params.fHrVelocity)));
|
||||||
|
|
||||||
|
fNewFactor = ffxMax(fNewFactor * fNewFactor, ffxMax(params.fDepthClipFactor * 0.1f, params.fDilatedReactiveFactor));
|
||||||
|
|
||||||
|
// Force reactive factor for new samples
|
||||||
|
fNewFactor = params.bIsNewSample ? 1.0f : fNewFactor;
|
||||||
|
|
||||||
|
if (ffxSaturate(params.fHrVelocity * 10.0f) >= 1.0f) {
|
||||||
|
fNewFactor = ffxMax(FSR3UPSCALER_EPSILON, fNewFactor) * -1.0f;
|
||||||
|
}
|
||||||
|
|
||||||
|
return fNewFactor;
|
||||||
|
}
|
||||||
|
|
||||||
|
AccumulationPassCommonParams InitParams(FfxInt32x2 iPxHrPos)
|
||||||
|
{
|
||||||
|
AccumulationPassCommonParams params;
|
||||||
|
|
||||||
|
params.iPxHrPos = iPxHrPos;
|
||||||
|
const FfxFloat32x2 fHrUv = (iPxHrPos + 0.5f) / DisplaySize();
|
||||||
|
params.fHrUv = fHrUv;
|
||||||
|
|
||||||
|
const FfxFloat32x2 fLrUvJittered = fHrUv + Jitter() / RenderSize();
|
||||||
|
params.fLrUv_HwSampler = ClampUv(fLrUvJittered, RenderSize(), MaxRenderSize());
|
||||||
|
|
||||||
|
params.fMotionVector = GetMotionVector(iPxHrPos, fHrUv);
|
||||||
|
params.fHrVelocity = GetPxHrVelocity(params.fMotionVector);
|
||||||
|
|
||||||
|
ComputeReprojectedUVs(params, params.fReprojectedHrUv, params.bIsExistingSample);
|
||||||
|
|
||||||
|
params.fDepthClipFactor = ffxSaturate(SampleDepthClip(params.fLrUv_HwSampler));
|
||||||
|
|
||||||
|
const FfxFloat32x2 fDilatedReactiveMasks = SampleDilatedReactiveMasks(params.fLrUv_HwSampler);
|
||||||
|
params.fDilatedReactiveFactor = fDilatedReactiveMasks.x;
|
||||||
|
params.fAccumulationMask = fDilatedReactiveMasks.y;
|
||||||
|
params.bIsResetFrame = (0 == FrameIndex());
|
||||||
|
|
||||||
|
params.bIsNewSample = (params.bIsExistingSample == false || params.bIsResetFrame);
|
||||||
|
|
||||||
|
return params;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Accumulate(FfxInt32x2 iPxHrPos)
|
||||||
|
{
|
||||||
|
const AccumulationPassCommonParams params = InitParams(iPxHrPos);
|
||||||
|
|
||||||
|
FfxFloat32x3 fHistoryColor = FfxFloat32x3(0, 0, 0);
|
||||||
|
FfxFloat32x2 fLockStatus;
|
||||||
|
InitializeNewLockSample(fLockStatus);
|
||||||
|
|
||||||
|
FfxFloat32 fTemporalReactiveFactor = 0.0f;
|
||||||
|
FfxBoolean bInMotionLastFrame = FFX_FALSE;
|
||||||
|
LockState lockState = { FFX_FALSE , FFX_FALSE };
|
||||||
|
if (params.bIsExistingSample && !params.bIsResetFrame) {
|
||||||
|
ReprojectHistoryColor(params, fHistoryColor, fTemporalReactiveFactor, bInMotionLastFrame);
|
||||||
|
lockState = ReprojectHistoryLockStatus(params, fLockStatus);
|
||||||
|
}
|
||||||
|
|
||||||
|
FfxFloat32 fThisFrameReactiveFactor = ffxMax(params.fDilatedReactiveFactor, fTemporalReactiveFactor);
|
||||||
|
|
||||||
|
FfxFloat32 fLuminanceDiff = 0.0f;
|
||||||
|
FfxFloat32 fLockContributionThisFrame = 0.0f;
|
||||||
|
UpdateLockStatus(params, fThisFrameReactiveFactor, lockState, fLockStatus, fLockContributionThisFrame, fLuminanceDiff);
|
||||||
|
|
||||||
|
// Load upsampled input color
|
||||||
|
RectificationBox clippingBox;
|
||||||
|
FfxFloat32x4 fUpsampledColorAndWeight = ComputeUpsampledColorAndWeight(params, clippingBox, fThisFrameReactiveFactor);
|
||||||
|
|
||||||
|
const FfxFloat32 fLumaInstabilityFactor = ComputeLumaInstabilityFactor(params, clippingBox, fThisFrameReactiveFactor, fLuminanceDiff);
|
||||||
|
|
||||||
|
|
||||||
|
FfxFloat32x3 fAccumulation = ComputeBaseAccumulationWeight(params, fThisFrameReactiveFactor, bInMotionLastFrame, fUpsampledColorAndWeight.w, lockState);
|
||||||
|
|
||||||
|
if (params.bIsNewSample) {
|
||||||
|
fHistoryColor = YCoCgToRGB(fUpsampledColorAndWeight.xyz);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
RectifyHistory(params, clippingBox, fHistoryColor, fAccumulation, fLockContributionThisFrame, fThisFrameReactiveFactor, fLumaInstabilityFactor);
|
||||||
|
|
||||||
|
Accumulate(params, fHistoryColor, fAccumulation, fUpsampledColorAndWeight);
|
||||||
|
}
|
||||||
|
|
||||||
|
fHistoryColor = UnprepareRgb(fHistoryColor, Exposure());
|
||||||
|
|
||||||
|
FinalizeLockStatus(params, fLockStatus, fUpsampledColorAndWeight.w);
|
||||||
|
|
||||||
|
// Get new temporal reactive factor
|
||||||
|
fTemporalReactiveFactor = ComputeTemporalReactiveFactor(params, fThisFrameReactiveFactor);
|
||||||
|
|
||||||
|
StoreInternalColorAndWeight(iPxHrPos, FfxFloat32x4(fHistoryColor, fTemporalReactiveFactor));
|
||||||
|
|
||||||
|
// Output final color when RCAS is disabled
|
||||||
|
#if FFX_FSR3UPSCALER_OPTION_APPLY_SHARPENING == 0
|
||||||
|
WriteUpscaledOutput(iPxHrPos, fHistoryColor);
|
||||||
|
#endif
|
||||||
|
StoreNewLocks(iPxHrPos, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif // FFX_FSR3UPSCALER_ACCUMULATE_H
|
||||||
@ -0,0 +1,27 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 3fc2f7a2c8c31324a949e1761bf599cc
|
||||||
|
PluginImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
iconMap: {}
|
||||||
|
executionOrder: {}
|
||||||
|
defineConstraints: []
|
||||||
|
isPreloaded: 0
|
||||||
|
isOverridable: 0
|
||||||
|
isExplicitlyReferenced: 0
|
||||||
|
validateReferences: 1
|
||||||
|
platformData:
|
||||||
|
- first:
|
||||||
|
Any:
|
||||||
|
second:
|
||||||
|
enabled: 1
|
||||||
|
settings: {}
|
||||||
|
- first:
|
||||||
|
Editor: Editor
|
||||||
|
second:
|
||||||
|
enabled: 0
|
||||||
|
settings:
|
||||||
|
DefaultValueInitialized: true
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
@ -0,0 +1,928 @@
|
|||||||
|
// This file is part of the FidelityFX SDK.
|
||||||
|
//
|
||||||
|
// Copyright (c) 2023 Advanced Micro Devices, Inc. All rights reserved.
|
||||||
|
//
|
||||||
|
// 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_fsr3upscaler_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)
|
||||||
|
#ifndef FFX_PREFER_WAVE64
|
||||||
|
#define FFX_PREFER_WAVE64
|
||||||
|
#endif // FFX_PREFER_WAVE64
|
||||||
|
|
||||||
|
#if defined(FFX_GPU)
|
||||||
|
#pragma warning(disable: 3205) // conversion from larger type to smaller
|
||||||
|
#endif // #if defined(FFX_GPU)
|
||||||
|
|
||||||
|
#define DECLARE_SRV_REGISTER(regIndex) t##regIndex
|
||||||
|
#define DECLARE_UAV_REGISTER(regIndex) u##regIndex
|
||||||
|
#define DECLARE_CB_REGISTER(regIndex) b##regIndex
|
||||||
|
#define FFX_FSR3UPSCALER_DECLARE_SRV(regIndex) register(DECLARE_SRV_REGISTER(regIndex))
|
||||||
|
#define FFX_FSR3UPSCALER_DECLARE_UAV(regIndex) register(DECLARE_UAV_REGISTER(regIndex))
|
||||||
|
#define FFX_FSR3UPSCALER_DECLARE_CB(regIndex) register(DECLARE_CB_REGISTER(regIndex))
|
||||||
|
|
||||||
|
#if defined(FSR3UPSCALER_BIND_CB_FSR3UPSCALER)
|
||||||
|
cbuffer cbFSR3Upscaler : FFX_FSR3UPSCALER_DECLARE_CB(FSR3UPSCALER_BIND_CB_FSR3UPSCALER)
|
||||||
|
{
|
||||||
|
FfxInt32x2 iRenderSize;
|
||||||
|
FfxInt32x2 iMaxRenderSize;
|
||||||
|
FfxInt32x2 iDisplaySize;
|
||||||
|
FfxInt32x2 iInputColorResourceDimensions;
|
||||||
|
FfxInt32x2 iLumaMipDimensions;
|
||||||
|
FfxInt32 iLumaMipLevelToUse;
|
||||||
|
FfxInt32 iFrameIndex;
|
||||||
|
|
||||||
|
FfxFloat32x4 fDeviceToViewDepth;
|
||||||
|
FfxFloat32x2 fJitter;
|
||||||
|
FfxFloat32x2 fMotionVectorScale;
|
||||||
|
FfxFloat32x2 fDownscaleFactor;
|
||||||
|
FfxFloat32x2 fMotionVectorJitterCancellation;
|
||||||
|
FfxFloat32 fPreExposure;
|
||||||
|
FfxFloat32 fPreviousFramePreExposure;
|
||||||
|
FfxFloat32 fTanHalfFOV;
|
||||||
|
FfxFloat32 fJitterSequenceLength;
|
||||||
|
FfxFloat32 fDeltaTime;
|
||||||
|
FfxFloat32 fDynamicResChangeFactor;
|
||||||
|
FfxFloat32 fViewSpaceToMetersFactor;
|
||||||
|
|
||||||
|
FfxInt32 iDummy;
|
||||||
|
};
|
||||||
|
|
||||||
|
#define FFX_FSR3UPSCALER_CONSTANT_BUFFER_1_SIZE (sizeof(cbFSR3Upscaler) / 4) // Number of 32-bit values. This must be kept in sync with the cbFSR3Upscaler size.
|
||||||
|
|
||||||
|
/* Define getter functions in the order they are defined in the CB! */
|
||||||
|
FfxInt32x2 RenderSize()
|
||||||
|
{
|
||||||
|
return iRenderSize;
|
||||||
|
}
|
||||||
|
|
||||||
|
FfxInt32x2 MaxRenderSize()
|
||||||
|
{
|
||||||
|
return iMaxRenderSize;
|
||||||
|
}
|
||||||
|
|
||||||
|
FfxInt32x2 DisplaySize()
|
||||||
|
{
|
||||||
|
return iDisplaySize;
|
||||||
|
}
|
||||||
|
|
||||||
|
FfxInt32x2 InputColorResourceDimensions()
|
||||||
|
{
|
||||||
|
return iInputColorResourceDimensions;
|
||||||
|
}
|
||||||
|
|
||||||
|
FfxInt32x2 LumaMipDimensions()
|
||||||
|
{
|
||||||
|
return iLumaMipDimensions;
|
||||||
|
}
|
||||||
|
|
||||||
|
FfxInt32 LumaMipLevelToUse()
|
||||||
|
{
|
||||||
|
return iLumaMipLevelToUse;
|
||||||
|
}
|
||||||
|
|
||||||
|
FfxInt32 FrameIndex()
|
||||||
|
{
|
||||||
|
return iFrameIndex;
|
||||||
|
}
|
||||||
|
|
||||||
|
FfxFloat32x2 Jitter()
|
||||||
|
{
|
||||||
|
return fJitter;
|
||||||
|
}
|
||||||
|
|
||||||
|
FfxFloat32x4 DeviceToViewSpaceTransformFactors()
|
||||||
|
{
|
||||||
|
return fDeviceToViewDepth;
|
||||||
|
}
|
||||||
|
|
||||||
|
FfxFloat32x2 MotionVectorScale()
|
||||||
|
{
|
||||||
|
return fMotionVectorScale;
|
||||||
|
}
|
||||||
|
|
||||||
|
FfxFloat32x2 DownscaleFactor()
|
||||||
|
{
|
||||||
|
return fDownscaleFactor;
|
||||||
|
}
|
||||||
|
|
||||||
|
FfxFloat32x2 MotionVectorJitterCancellation()
|
||||||
|
{
|
||||||
|
return fMotionVectorJitterCancellation;
|
||||||
|
}
|
||||||
|
|
||||||
|
FfxFloat32 PreExposure()
|
||||||
|
{
|
||||||
|
return fPreExposure;
|
||||||
|
}
|
||||||
|
|
||||||
|
FfxFloat32 PreviousFramePreExposure()
|
||||||
|
{
|
||||||
|
return fPreviousFramePreExposure;
|
||||||
|
}
|
||||||
|
|
||||||
|
FfxFloat32 TanHalfFoV()
|
||||||
|
{
|
||||||
|
return fTanHalfFOV;
|
||||||
|
}
|
||||||
|
|
||||||
|
FfxFloat32 JitterSequenceLength()
|
||||||
|
{
|
||||||
|
return fJitterSequenceLength;
|
||||||
|
}
|
||||||
|
|
||||||
|
FfxFloat32 DeltaTime()
|
||||||
|
{
|
||||||
|
return fDeltaTime;
|
||||||
|
}
|
||||||
|
|
||||||
|
FfxFloat32 DynamicResChangeFactor()
|
||||||
|
{
|
||||||
|
return fDynamicResChangeFactor;
|
||||||
|
}
|
||||||
|
|
||||||
|
FfxFloat32 ViewSpaceToMetersFactor()
|
||||||
|
{
|
||||||
|
return fViewSpaceToMetersFactor;
|
||||||
|
}
|
||||||
|
#endif // #if defined(FSR3UPSCALER_BIND_CB_FSR3UPSCALER)
|
||||||
|
|
||||||
|
#define FFX_FSR3UPSCALER_ROOTSIG_STRINGIFY(p) FFX_FSR3UPSCALER_ROOTSIG_STR(p)
|
||||||
|
#define FFX_FSR3UPSCALER_ROOTSIG_STR(p) #p
|
||||||
|
#define FFX_FSR3UPSCALER_ROOTSIG [RootSignature( "DescriptorTable(UAV(u0, numDescriptors = " FFX_FSR3UPSCALER_ROOTSIG_STRINGIFY(FFX_FSR3UPSCALER_RESOURCE_IDENTIFIER_COUNT) ")), " \
|
||||||
|
"DescriptorTable(SRV(t0, numDescriptors = " FFX_FSR3UPSCALER_ROOTSIG_STRINGIFY(FFX_FSR3UPSCALER_RESOURCE_IDENTIFIER_COUNT) ")), " \
|
||||||
|
"RootConstants(num32BitConstants=" FFX_FSR3UPSCALER_ROOTSIG_STRINGIFY(FFX_FSR3UPSCALER_CONSTANT_BUFFER_1_SIZE) ", 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_FSR3UPSCALER_CONSTANT_BUFFER_2_SIZE 6 // Number of 32-bit values. This must be kept in sync with max( cbRCAS , cbSPD) size.
|
||||||
|
|
||||||
|
#define FFX_FSR3UPSCALER_CB2_ROOTSIG [RootSignature( "DescriptorTable(UAV(u0, numDescriptors = " FFX_FSR3UPSCALER_ROOTSIG_STRINGIFY(FFX_FSR3UPSCALER_RESOURCE_IDENTIFIER_COUNT) ")), " \
|
||||||
|
"DescriptorTable(SRV(t0, numDescriptors = " FFX_FSR3UPSCALER_ROOTSIG_STRINGIFY(FFX_FSR3UPSCALER_RESOURCE_IDENTIFIER_COUNT) ")), " \
|
||||||
|
"RootConstants(num32BitConstants=" FFX_FSR3UPSCALER_ROOTSIG_STRINGIFY(FFX_FSR3UPSCALER_CONSTANT_BUFFER_1_SIZE) ", b0), " \
|
||||||
|
"RootConstants(num32BitConstants=" FFX_FSR3UPSCALER_ROOTSIG_STRINGIFY(FFX_FSR3UPSCALER_CONSTANT_BUFFER_2_SIZE) ", b1), " \
|
||||||
|
"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_FSR3UPSCALER_EMBED_ROOTSIG)
|
||||||
|
#define FFX_FSR3UPSCALER_EMBED_ROOTSIG_CONTENT FFX_FSR3UPSCALER_ROOTSIG
|
||||||
|
#define FFX_FSR3UPSCALER_EMBED_CB2_ROOTSIG_CONTENT FFX_FSR3UPSCALER_CB2_ROOTSIG
|
||||||
|
#else
|
||||||
|
#define FFX_FSR3UPSCALER_EMBED_ROOTSIG_CONTENT
|
||||||
|
#define FFX_FSR3UPSCALER_EMBED_CB2_ROOTSIG_CONTENT
|
||||||
|
#endif // #if FFX_FSR3UPSCALER_EMBED_ROOTSIG
|
||||||
|
|
||||||
|
#if defined(FSR3UPSCALER_BIND_CB_AUTOREACTIVE)
|
||||||
|
cbuffer cbGenerateReactive : FFX_FSR3UPSCALER_DECLARE_CB(FSR3UPSCALER_BIND_CB_AUTOREACTIVE)
|
||||||
|
{
|
||||||
|
FfxFloat32 fTcThreshold; // 0.1 is a good starting value, lower will result in more TC pixels
|
||||||
|
FfxFloat32 fTcScale;
|
||||||
|
FfxFloat32 fReactiveScale;
|
||||||
|
FfxFloat32 fReactiveMax;
|
||||||
|
};
|
||||||
|
|
||||||
|
FfxFloat32 TcThreshold()
|
||||||
|
{
|
||||||
|
return fTcThreshold;
|
||||||
|
}
|
||||||
|
|
||||||
|
FfxFloat32 TcScale()
|
||||||
|
{
|
||||||
|
return fTcScale;
|
||||||
|
}
|
||||||
|
|
||||||
|
FfxFloat32 ReactiveScale()
|
||||||
|
{
|
||||||
|
return fReactiveScale;
|
||||||
|
}
|
||||||
|
|
||||||
|
FfxFloat32 ReactiveMax()
|
||||||
|
{
|
||||||
|
return fReactiveMax;
|
||||||
|
}
|
||||||
|
#endif // #if defined(FSR3UPSCALER_BIND_CB_AUTOREACTIVE)
|
||||||
|
|
||||||
|
#if defined(FSR3UPSCALER_BIND_CB_RCAS)
|
||||||
|
cbuffer cbRCAS : FFX_FSR3UPSCALER_DECLARE_CB(FSR3UPSCALER_BIND_CB_RCAS)
|
||||||
|
{
|
||||||
|
FfxUInt32x4 rcasConfig;
|
||||||
|
};
|
||||||
|
|
||||||
|
FfxUInt32x4 RCASConfig()
|
||||||
|
{
|
||||||
|
return rcasConfig;
|
||||||
|
}
|
||||||
|
#endif // #if defined(FSR3UPSCALER_BIND_CB_RCAS)
|
||||||
|
|
||||||
|
|
||||||
|
#if defined(FSR3UPSCALER_BIND_CB_REACTIVE)
|
||||||
|
cbuffer cbGenerateReactive : FFX_FSR3UPSCALER_DECLARE_CB(FSR3UPSCALER_BIND_CB_REACTIVE)
|
||||||
|
{
|
||||||
|
FfxFloat32 gen_reactive_scale;
|
||||||
|
FfxFloat32 gen_reactive_threshold;
|
||||||
|
FfxFloat32 gen_reactive_binaryValue;
|
||||||
|
FfxUInt32 gen_reactive_flags;
|
||||||
|
};
|
||||||
|
|
||||||
|
FfxFloat32 GenReactiveScale()
|
||||||
|
{
|
||||||
|
return gen_reactive_scale;
|
||||||
|
}
|
||||||
|
|
||||||
|
FfxFloat32 GenReactiveThreshold()
|
||||||
|
{
|
||||||
|
return gen_reactive_threshold;
|
||||||
|
}
|
||||||
|
|
||||||
|
FfxFloat32 GenReactiveBinaryValue()
|
||||||
|
{
|
||||||
|
return gen_reactive_binaryValue;
|
||||||
|
}
|
||||||
|
|
||||||
|
FfxUInt32 GenReactiveFlags()
|
||||||
|
{
|
||||||
|
return gen_reactive_flags;
|
||||||
|
}
|
||||||
|
#endif // #if defined(FSR3UPSCALER_BIND_CB_REACTIVE)
|
||||||
|
|
||||||
|
#if defined(FSR3UPSCALER_BIND_CB_SPD)
|
||||||
|
cbuffer cbSPD : FFX_FSR3UPSCALER_DECLARE_CB(FSR3UPSCALER_BIND_CB_SPD) {
|
||||||
|
|
||||||
|
FfxUInt32 mips;
|
||||||
|
FfxUInt32 numWorkGroups;
|
||||||
|
FfxUInt32x2 workGroupOffset;
|
||||||
|
FfxUInt32x2 renderSize;
|
||||||
|
};
|
||||||
|
|
||||||
|
FfxUInt32 MipCount()
|
||||||
|
{
|
||||||
|
return mips;
|
||||||
|
}
|
||||||
|
|
||||||
|
FfxUInt32 NumWorkGroups()
|
||||||
|
{
|
||||||
|
return numWorkGroups;
|
||||||
|
}
|
||||||
|
|
||||||
|
FfxUInt32x2 WorkGroupOffset()
|
||||||
|
{
|
||||||
|
return workGroupOffset;
|
||||||
|
}
|
||||||
|
|
||||||
|
FfxUInt32x2 SPD_RenderSize()
|
||||||
|
{
|
||||||
|
return renderSize;
|
||||||
|
}
|
||||||
|
#endif // #if defined(FSR3UPSCALER_BIND_CB_SPD)
|
||||||
|
|
||||||
|
// Declare and sample camera buffers as regular textures, unless overridden
|
||||||
|
#if !defined(UNITY_FSR3_TEX2D)
|
||||||
|
#define UNITY_FSR3_TEX2D(type) Texture2D<type>
|
||||||
|
#endif
|
||||||
|
#if !defined(UNITY_FSR3_RWTEX2D)
|
||||||
|
#define UNITY_FSR3_RWTEX2D(type) RWTexture2D<type>
|
||||||
|
#endif
|
||||||
|
#if !defined(UNITY_FSR3_POS)
|
||||||
|
#define UNITY_FSR3_POS(pxPos) (pxPos)
|
||||||
|
#endif
|
||||||
|
#if !defined(UNITY_FSR3_UV)
|
||||||
|
#define UNITY_FSR3_UV(uv) (uv)
|
||||||
|
#endif
|
||||||
|
|
||||||
|
SamplerState s_PointClamp : register(s0);
|
||||||
|
SamplerState s_LinearClamp : register(s1);
|
||||||
|
|
||||||
|
// SRVs
|
||||||
|
#if defined FSR3UPSCALER_BIND_SRV_INPUT_COLOR
|
||||||
|
UNITY_FSR3_TEX2D(FfxFloat32x4) r_input_color_jittered : FFX_FSR3UPSCALER_DECLARE_SRV(FSR3UPSCALER_BIND_SRV_INPUT_COLOR);
|
||||||
|
#endif
|
||||||
|
#if defined FSR3UPSCALER_BIND_SRV_INPUT_OPAQUE_ONLY
|
||||||
|
UNITY_FSR3_TEX2D(FfxFloat32x4) r_input_opaque_only : FFX_FSR3UPSCALER_DECLARE_SRV(FSR3UPSCALER_BIND_SRV_INPUT_OPAQUE_ONLY);
|
||||||
|
#endif
|
||||||
|
#if defined FSR3UPSCALER_BIND_SRV_INPUT_MOTION_VECTORS
|
||||||
|
UNITY_FSR3_TEX2D(FfxFloat32x4) r_input_motion_vectors : FFX_FSR3UPSCALER_DECLARE_SRV(FSR3UPSCALER_BIND_SRV_INPUT_MOTION_VECTORS);
|
||||||
|
#endif
|
||||||
|
#if defined FSR3UPSCALER_BIND_SRV_INPUT_DEPTH
|
||||||
|
UNITY_FSR3_TEX2D(FfxFloat32) r_input_depth : FFX_FSR3UPSCALER_DECLARE_SRV(FSR3UPSCALER_BIND_SRV_INPUT_DEPTH);
|
||||||
|
#endif
|
||||||
|
#if defined FSR3UPSCALER_BIND_SRV_INPUT_EXPOSURE
|
||||||
|
Texture2D<FfxFloat32x2> r_input_exposure : FFX_FSR3UPSCALER_DECLARE_SRV(FSR3UPSCALER_BIND_SRV_INPUT_EXPOSURE);
|
||||||
|
#endif
|
||||||
|
#if defined FSR3UPSCALER_BIND_SRV_AUTO_EXPOSURE
|
||||||
|
Texture2D<FfxFloat32x2> r_auto_exposure : FFX_FSR3UPSCALER_DECLARE_SRV(FSR3UPSCALER_BIND_SRV_AUTO_EXPOSURE);
|
||||||
|
#endif
|
||||||
|
#if defined FSR3UPSCALER_BIND_SRV_REACTIVE_MASK
|
||||||
|
Texture2D<FfxFloat32> r_reactive_mask : FFX_FSR3UPSCALER_DECLARE_SRV(FSR3UPSCALER_BIND_SRV_REACTIVE_MASK);
|
||||||
|
#endif
|
||||||
|
#if defined FSR3UPSCALER_BIND_SRV_TRANSPARENCY_AND_COMPOSITION_MASK
|
||||||
|
Texture2D<FfxFloat32> r_transparency_and_composition_mask : FFX_FSR3UPSCALER_DECLARE_SRV(FSR3UPSCALER_BIND_SRV_TRANSPARENCY_AND_COMPOSITION_MASK);
|
||||||
|
#endif
|
||||||
|
#if defined FSR3UPSCALER_BIND_SRV_RECONSTRUCTED_PREV_NEAREST_DEPTH
|
||||||
|
Texture2D<FfxUInt32> r_reconstructed_previous_nearest_depth : FFX_FSR3UPSCALER_DECLARE_SRV(FSR3UPSCALER_BIND_SRV_RECONSTRUCTED_PREV_NEAREST_DEPTH);
|
||||||
|
#endif
|
||||||
|
#if defined FSR3UPSCALER_BIND_SRV_DILATED_MOTION_VECTORS
|
||||||
|
Texture2D<FfxFloat32x2> r_dilated_motion_vectors : FFX_FSR3UPSCALER_DECLARE_SRV(FSR3UPSCALER_BIND_SRV_DILATED_MOTION_VECTORS);
|
||||||
|
#endif
|
||||||
|
#if defined FSR3UPSCALER_BIND_SRV_PREVIOUS_DILATED_MOTION_VECTORS
|
||||||
|
Texture2D<FfxFloat32x2> r_previous_dilated_motion_vectors : FFX_FSR3UPSCALER_DECLARE_SRV(FSR3UPSCALER_BIND_SRV_PREVIOUS_DILATED_MOTION_VECTORS);
|
||||||
|
#endif
|
||||||
|
#if defined FSR3UPSCALER_BIND_SRV_DILATED_DEPTH
|
||||||
|
Texture2D<FfxFloat32> r_dilated_depth : FFX_FSR3UPSCALER_DECLARE_SRV(FSR3UPSCALER_BIND_SRV_DILATED_DEPTH);
|
||||||
|
#endif
|
||||||
|
#if defined FSR3UPSCALER_BIND_SRV_INTERNAL_UPSCALED
|
||||||
|
Texture2D<FfxFloat32x4> r_internal_upscaled_color : FFX_FSR3UPSCALER_DECLARE_SRV(FSR3UPSCALER_BIND_SRV_INTERNAL_UPSCALED);
|
||||||
|
#endif
|
||||||
|
#if defined FSR3UPSCALER_BIND_SRV_LOCK_STATUS
|
||||||
|
Texture2D<unorm FfxFloat32x2> r_lock_status : FFX_FSR3UPSCALER_DECLARE_SRV(FSR3UPSCALER_BIND_SRV_LOCK_STATUS);
|
||||||
|
#endif
|
||||||
|
#if defined FSR3UPSCALER_BIND_SRV_LOCK_INPUT_LUMA
|
||||||
|
Texture2D<FfxFloat32> r_lock_input_luma : FFX_FSR3UPSCALER_DECLARE_SRV(FSR3UPSCALER_BIND_SRV_LOCK_INPUT_LUMA);
|
||||||
|
#endif
|
||||||
|
#if defined FSR3UPSCALER_BIND_SRV_NEW_LOCKS
|
||||||
|
Texture2D<unorm FfxFloat32> r_new_locks : FFX_FSR3UPSCALER_DECLARE_SRV(FSR3UPSCALER_BIND_SRV_NEW_LOCKS);
|
||||||
|
#endif
|
||||||
|
#if defined FSR3UPSCALER_BIND_SRV_PREPARED_INPUT_COLOR
|
||||||
|
Texture2D<FfxFloat32x4> r_prepared_input_color : FFX_FSR3UPSCALER_DECLARE_SRV(FSR3UPSCALER_BIND_SRV_PREPARED_INPUT_COLOR);
|
||||||
|
#endif
|
||||||
|
#if defined FSR3UPSCALER_BIND_SRV_LUMA_HISTORY
|
||||||
|
Texture2D<unorm FfxFloat32x4> r_luma_history : FFX_FSR3UPSCALER_DECLARE_SRV(FSR3UPSCALER_BIND_SRV_LUMA_HISTORY);
|
||||||
|
#endif
|
||||||
|
#if defined FSR3UPSCALER_BIND_SRV_RCAS_INPUT
|
||||||
|
Texture2D<FfxFloat32x4> r_rcas_input : FFX_FSR3UPSCALER_DECLARE_SRV(FSR3UPSCALER_BIND_SRV_RCAS_INPUT);
|
||||||
|
#endif
|
||||||
|
#if defined FSR3UPSCALER_BIND_SRV_LANCZOS_LUT
|
||||||
|
Texture2D<FfxFloat32> r_lanczos_lut : FFX_FSR3UPSCALER_DECLARE_SRV(FSR3UPSCALER_BIND_SRV_LANCZOS_LUT);
|
||||||
|
#endif
|
||||||
|
#if defined FSR3UPSCALER_BIND_SRV_SCENE_LUMINANCE_MIPS
|
||||||
|
Texture2D<FfxFloat32> r_imgMips : FFX_FSR3UPSCALER_DECLARE_SRV(FSR3UPSCALER_BIND_SRV_SCENE_LUMINANCE_MIPS);
|
||||||
|
#endif
|
||||||
|
#if defined FSR3UPSCALER_BIND_SRV_UPSCALE_MAXIMUM_BIAS_LUT
|
||||||
|
Texture2D<FfxFloat32> r_upsample_maximum_bias_lut : FFX_FSR3UPSCALER_DECLARE_SRV(FSR3UPSCALER_BIND_SRV_UPSCALE_MAXIMUM_BIAS_LUT);
|
||||||
|
#endif
|
||||||
|
#if defined FSR3UPSCALER_BIND_SRV_DILATED_REACTIVE_MASKS
|
||||||
|
Texture2D<unorm FfxFloat32x2> r_dilated_reactive_masks : FFX_FSR3UPSCALER_DECLARE_SRV(FSR3UPSCALER_BIND_SRV_DILATED_REACTIVE_MASKS);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined FSR3UPSCALER_BIND_SRV_PREV_PRE_ALPHA_COLOR
|
||||||
|
Texture2D<float3> r_input_prev_color_pre_alpha : FFX_FSR3UPSCALER_DECLARE_SRV(FFX_FSR3UPSCALER_RESOURCE_IDENTIFIER_PREV_PRE_ALPHA_COLOR);
|
||||||
|
#endif
|
||||||
|
#if defined FSR3UPSCALER_BIND_SRV_PREV_POST_ALPHA_COLOR
|
||||||
|
Texture2D<float3> r_input_prev_color_post_alpha : FFX_FSR3UPSCALER_DECLARE_SRV(FFX_FSR3UPSCALER_RESOURCE_IDENTIFIER_PREV_POST_ALPHA_COLOR);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// UAV declarations
|
||||||
|
#if defined FSR3UPSCALER_BIND_UAV_RECONSTRUCTED_PREV_NEAREST_DEPTH
|
||||||
|
RWTexture2D<FfxUInt32> rw_reconstructed_previous_nearest_depth : FFX_FSR3UPSCALER_DECLARE_UAV(FSR3UPSCALER_BIND_UAV_RECONSTRUCTED_PREV_NEAREST_DEPTH);
|
||||||
|
#endif
|
||||||
|
#if defined FSR3UPSCALER_BIND_UAV_DILATED_MOTION_VECTORS
|
||||||
|
RWTexture2D<FfxFloat32x2> rw_dilated_motion_vectors : FFX_FSR3UPSCALER_DECLARE_UAV(FSR3UPSCALER_BIND_UAV_DILATED_MOTION_VECTORS);
|
||||||
|
#endif
|
||||||
|
#if defined FSR3UPSCALER_BIND_UAV_DILATED_DEPTH
|
||||||
|
RWTexture2D<FfxFloat32> rw_dilated_depth : FFX_FSR3UPSCALER_DECLARE_UAV(FSR3UPSCALER_BIND_UAV_DILATED_DEPTH);
|
||||||
|
#endif
|
||||||
|
#if defined FSR3UPSCALER_BIND_UAV_INTERNAL_UPSCALED
|
||||||
|
RWTexture2D<FfxFloat32x4> rw_internal_upscaled_color : FFX_FSR3UPSCALER_DECLARE_UAV(FSR3UPSCALER_BIND_UAV_INTERNAL_UPSCALED);
|
||||||
|
#endif
|
||||||
|
#if defined FSR3UPSCALER_BIND_UAV_LOCK_STATUS
|
||||||
|
RWTexture2D<unorm FfxFloat32x2> rw_lock_status : FFX_FSR3UPSCALER_DECLARE_UAV(FSR3UPSCALER_BIND_UAV_LOCK_STATUS);
|
||||||
|
#endif
|
||||||
|
#if defined FSR3UPSCALER_BIND_UAV_LOCK_INPUT_LUMA
|
||||||
|
RWTexture2D<FfxFloat32> rw_lock_input_luma : FFX_FSR3UPSCALER_DECLARE_UAV(FSR3UPSCALER_BIND_UAV_LOCK_INPUT_LUMA);
|
||||||
|
#endif
|
||||||
|
#if defined FSR3UPSCALER_BIND_UAV_NEW_LOCKS
|
||||||
|
RWTexture2D<unorm FfxFloat32> rw_new_locks : FFX_FSR3UPSCALER_DECLARE_UAV(FSR3UPSCALER_BIND_UAV_NEW_LOCKS);
|
||||||
|
#endif
|
||||||
|
#if defined FSR3UPSCALER_BIND_UAV_PREPARED_INPUT_COLOR
|
||||||
|
RWTexture2D<FfxFloat32x4> rw_prepared_input_color : FFX_FSR3UPSCALER_DECLARE_UAV(FSR3UPSCALER_BIND_UAV_PREPARED_INPUT_COLOR);
|
||||||
|
#endif
|
||||||
|
#if defined FSR3UPSCALER_BIND_UAV_LUMA_HISTORY
|
||||||
|
RWTexture2D<FfxFloat32x4> rw_luma_history : FFX_FSR3UPSCALER_DECLARE_UAV(FSR3UPSCALER_BIND_UAV_LUMA_HISTORY);
|
||||||
|
#endif
|
||||||
|
#if defined FSR3UPSCALER_BIND_UAV_UPSCALED_OUTPUT
|
||||||
|
UNITY_FSR3_RWTEX2D(FfxFloat32x4) rw_upscaled_output : FFX_FSR3UPSCALER_DECLARE_UAV(FSR3UPSCALER_BIND_UAV_UPSCALED_OUTPUT);
|
||||||
|
#endif
|
||||||
|
#if defined FSR3UPSCALER_BIND_UAV_EXPOSURE_MIP_LUMA_CHANGE
|
||||||
|
globallycoherent RWTexture2D<FfxFloat32> rw_img_mip_shading_change : FFX_FSR3UPSCALER_DECLARE_UAV(FSR3UPSCALER_BIND_UAV_EXPOSURE_MIP_LUMA_CHANGE);
|
||||||
|
#endif
|
||||||
|
#if defined FSR3UPSCALER_BIND_UAV_EXPOSURE_MIP_5
|
||||||
|
globallycoherent RWTexture2D<FfxFloat32> rw_img_mip_5 : FFX_FSR3UPSCALER_DECLARE_UAV(FSR3UPSCALER_BIND_UAV_EXPOSURE_MIP_5);
|
||||||
|
#endif
|
||||||
|
#if defined FSR3UPSCALER_BIND_UAV_DILATED_REACTIVE_MASKS
|
||||||
|
RWTexture2D<unorm FfxFloat32x2> rw_dilated_reactive_masks : FFX_FSR3UPSCALER_DECLARE_UAV(FSR3UPSCALER_BIND_UAV_DILATED_REACTIVE_MASKS);
|
||||||
|
#endif
|
||||||
|
#if defined FSR3UPSCALER_BIND_UAV_EXPOSURE
|
||||||
|
RWTexture2D<FfxFloat32x2> rw_exposure : FFX_FSR3UPSCALER_DECLARE_UAV(FSR3UPSCALER_BIND_UAV_EXPOSURE);
|
||||||
|
#endif
|
||||||
|
#if defined FSR3UPSCALER_BIND_UAV_AUTO_EXPOSURE
|
||||||
|
RWTexture2D<FfxFloat32x2> rw_auto_exposure : FFX_FSR3UPSCALER_DECLARE_UAV(FSR3UPSCALER_BIND_UAV_AUTO_EXPOSURE);
|
||||||
|
#endif
|
||||||
|
#if defined FSR3UPSCALER_BIND_UAV_SPD_GLOBAL_ATOMIC
|
||||||
|
globallycoherent RWTexture2D<FfxUInt32> rw_spd_global_atomic : FFX_FSR3UPSCALER_DECLARE_UAV(FSR3UPSCALER_BIND_UAV_SPD_GLOBAL_ATOMIC);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined FSR3UPSCALER_BIND_UAV_AUTOREACTIVE
|
||||||
|
RWTexture2D<float> rw_output_autoreactive : FFX_FSR3UPSCALER_DECLARE_UAV(FSR3UPSCALER_BIND_UAV_AUTOREACTIVE);
|
||||||
|
#endif
|
||||||
|
#if defined FSR3UPSCALER_BIND_UAV_AUTOCOMPOSITION
|
||||||
|
RWTexture2D<float> rw_output_autocomposition : FFX_FSR3UPSCALER_DECLARE_UAV(FSR3UPSCALER_BIND_UAV_AUTOCOMPOSITION);
|
||||||
|
#endif
|
||||||
|
#if defined FSR3UPSCALER_BIND_UAV_PREV_PRE_ALPHA_COLOR
|
||||||
|
RWTexture2D<float3> rw_output_prev_color_pre_alpha : FFX_FSR3UPSCALER_DECLARE_UAV(FSR3UPSCALER_BIND_UAV_PREV_PRE_ALPHA_COLOR);
|
||||||
|
#endif
|
||||||
|
#if defined FSR3UPSCALER_BIND_UAV_PREV_POST_ALPHA_COLOR
|
||||||
|
RWTexture2D<float3> rw_output_prev_color_post_alpha : FFX_FSR3UPSCALER_DECLARE_UAV(FSR3UPSCALER_BIND_UAV_PREV_POST_ALPHA_COLOR);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined(FSR3UPSCALER_BIND_SRV_SCENE_LUMINANCE_MIPS)
|
||||||
|
FfxFloat32 LoadMipLuma(FfxUInt32x2 iPxPos, FfxUInt32 mipLevel)
|
||||||
|
{
|
||||||
|
return r_imgMips.mips[mipLevel][iPxPos];
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined(FSR3UPSCALER_BIND_SRV_SCENE_LUMINANCE_MIPS)
|
||||||
|
FfxFloat32 SampleMipLuma(FfxFloat32x2 fUV, FfxUInt32 mipLevel)
|
||||||
|
{
|
||||||
|
return r_imgMips.SampleLevel(s_LinearClamp, fUV, mipLevel);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined(FSR3UPSCALER_BIND_SRV_INPUT_DEPTH)
|
||||||
|
FfxFloat32 LoadInputDepth(FfxUInt32x2 iPxPos)
|
||||||
|
{
|
||||||
|
return r_input_depth[UNITY_FSR3_POS(iPxPos)];
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined(FSR3UPSCALER_BIND_SRV_INPUT_DEPTH)
|
||||||
|
FfxFloat32 SampleInputDepth(FfxFloat32x2 fUV)
|
||||||
|
{
|
||||||
|
return r_input_depth.SampleLevel(s_LinearClamp, UNITY_FSR3_UV(fUV), 0).x;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined(FSR3UPSCALER_BIND_SRV_REACTIVE_MASK)
|
||||||
|
FfxFloat32 LoadReactiveMask(FfxUInt32x2 iPxPos)
|
||||||
|
{
|
||||||
|
return r_reactive_mask[iPxPos];
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined(FSR3UPSCALER_BIND_SRV_TRANSPARENCY_AND_COMPOSITION_MASK)
|
||||||
|
FfxFloat32 LoadTransparencyAndCompositionMask(FfxUInt32x2 iPxPos)
|
||||||
|
{
|
||||||
|
return r_transparency_and_composition_mask[iPxPos];
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined(FSR3UPSCALER_BIND_SRV_INPUT_COLOR)
|
||||||
|
FfxFloat32x3 LoadInputColor(FfxUInt32x2 iPxPos)
|
||||||
|
{
|
||||||
|
return r_input_color_jittered[UNITY_FSR3_POS(iPxPos)].rgb;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined(FSR3UPSCALER_BIND_SRV_INPUT_COLOR)
|
||||||
|
FfxFloat32x3 SampleInputColor(FfxFloat32x2 fUV)
|
||||||
|
{
|
||||||
|
return r_input_color_jittered.SampleLevel(s_LinearClamp, UNITY_FSR3_UV(fUV), 0).rgb;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined(FSR3UPSCALER_BIND_SRV_PREPARED_INPUT_COLOR)
|
||||||
|
FfxFloat32x3 LoadPreparedInputColor(FfxUInt32x2 iPxPos)
|
||||||
|
{
|
||||||
|
return r_prepared_input_color[iPxPos].xyz;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined(FSR3UPSCALER_BIND_SRV_INPUT_MOTION_VECTORS)
|
||||||
|
FfxFloat32x2 LoadInputMotionVector(FfxUInt32x2 iPxDilatedMotionVectorPos)
|
||||||
|
{
|
||||||
|
FfxFloat32x2 fSrcMotionVector = r_input_motion_vectors[UNITY_FSR3_POS(iPxDilatedMotionVectorPos)].xy;
|
||||||
|
|
||||||
|
FfxFloat32x2 fUvMotionVector = fSrcMotionVector * MotionVectorScale();
|
||||||
|
|
||||||
|
#if FFX_FSR3UPSCALER_OPTION_JITTERED_MOTION_VECTORS
|
||||||
|
fUvMotionVector -= MotionVectorJitterCancellation();
|
||||||
|
#endif
|
||||||
|
|
||||||
|
return fUvMotionVector;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined(FSR3UPSCALER_BIND_SRV_INTERNAL_UPSCALED)
|
||||||
|
FfxFloat32x4 LoadHistory(FfxUInt32x2 iPxHistory)
|
||||||
|
{
|
||||||
|
return r_internal_upscaled_color[iPxHistory];
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined(FSR3UPSCALER_BIND_UAV_LUMA_HISTORY)
|
||||||
|
void StoreLumaHistory(FfxUInt32x2 iPxPos, FfxFloat32x4 fLumaHistory)
|
||||||
|
{
|
||||||
|
rw_luma_history[iPxPos] = fLumaHistory;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined(FSR3UPSCALER_BIND_SRV_LUMA_HISTORY)
|
||||||
|
FfxFloat32x4 SampleLumaHistory(FfxFloat32x2 fUV)
|
||||||
|
{
|
||||||
|
return r_luma_history.SampleLevel(s_LinearClamp, fUV, 0);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
FfxFloat32x4 LoadRCAS_Input(FfxInt32x2 iPxPos)
|
||||||
|
{
|
||||||
|
#if defined(FSR3UPSCALER_BIND_SRV_RCAS_INPUT)
|
||||||
|
return r_rcas_input[iPxPos];
|
||||||
|
#else
|
||||||
|
return 0.0;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
#if defined(FSR3UPSCALER_BIND_UAV_INTERNAL_UPSCALED)
|
||||||
|
void StoreReprojectedHistory(FfxUInt32x2 iPxHistory, FfxFloat32x4 fHistory)
|
||||||
|
{
|
||||||
|
rw_internal_upscaled_color[iPxHistory] = fHistory;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined(FSR3UPSCALER_BIND_UAV_INTERNAL_UPSCALED)
|
||||||
|
void StoreInternalColorAndWeight(FfxUInt32x2 iPxPos, FfxFloat32x4 fColorAndWeight)
|
||||||
|
{
|
||||||
|
rw_internal_upscaled_color[iPxPos] = fColorAndWeight;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined(FSR3UPSCALER_BIND_UAV_UPSCALED_OUTPUT)
|
||||||
|
void StoreUpscaledOutput(FfxUInt32x2 iPxPos, FfxFloat32x3 fColor)
|
||||||
|
{
|
||||||
|
rw_upscaled_output[UNITY_FSR3_POS(iPxPos)] = FfxFloat32x4(fColor, 1.f);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
//LOCK_LIFETIME_REMAINING == 0
|
||||||
|
//Should make LockInitialLifetime() return a const 1.0f later
|
||||||
|
#if defined(FSR3UPSCALER_BIND_SRV_LOCK_STATUS)
|
||||||
|
FfxFloat32x2 LoadLockStatus(FfxUInt32x2 iPxPos)
|
||||||
|
{
|
||||||
|
return r_lock_status[iPxPos];
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined(FSR3UPSCALER_BIND_UAV_LOCK_STATUS)
|
||||||
|
void StoreLockStatus(FfxUInt32x2 iPxPos, FfxFloat32x2 fLockStatus)
|
||||||
|
{
|
||||||
|
rw_lock_status[iPxPos] = fLockStatus;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined(FSR3UPSCALER_BIND_SRV_LOCK_INPUT_LUMA)
|
||||||
|
FfxFloat32 LoadLockInputLuma(FfxUInt32x2 iPxPos)
|
||||||
|
{
|
||||||
|
return r_lock_input_luma[iPxPos];
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined(FSR3UPSCALER_BIND_UAV_LOCK_INPUT_LUMA)
|
||||||
|
void StoreLockInputLuma(FfxUInt32x2 iPxPos, FfxFloat32 fLuma)
|
||||||
|
{
|
||||||
|
rw_lock_input_luma[iPxPos] = fLuma;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined(FSR3UPSCALER_BIND_SRV_NEW_LOCKS)
|
||||||
|
FfxFloat32 LoadNewLocks(FfxUInt32x2 iPxPos)
|
||||||
|
{
|
||||||
|
return r_new_locks[iPxPos];
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined(FSR3UPSCALER_BIND_UAV_NEW_LOCKS)
|
||||||
|
FfxFloat32 LoadRwNewLocks(FfxUInt32x2 iPxPos)
|
||||||
|
{
|
||||||
|
return rw_new_locks[iPxPos];
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined(FSR3UPSCALER_BIND_UAV_NEW_LOCKS)
|
||||||
|
void StoreNewLocks(FfxUInt32x2 iPxPos, FfxFloat32 newLock)
|
||||||
|
{
|
||||||
|
rw_new_locks[iPxPos] = newLock;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined(FSR3UPSCALER_BIND_UAV_PREPARED_INPUT_COLOR)
|
||||||
|
void StorePreparedInputColor(FFX_PARAMETER_IN FfxUInt32x2 iPxPos, FFX_PARAMETER_IN FfxFloat32x4 fTonemapped)
|
||||||
|
{
|
||||||
|
rw_prepared_input_color[iPxPos] = fTonemapped;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined(FSR3UPSCALER_BIND_SRV_PREPARED_INPUT_COLOR)
|
||||||
|
FfxFloat32 SampleDepthClip(FfxFloat32x2 fUV)
|
||||||
|
{
|
||||||
|
return r_prepared_input_color.SampleLevel(s_LinearClamp, fUV, 0).w;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined(FSR3UPSCALER_BIND_SRV_LOCK_STATUS)
|
||||||
|
FfxFloat32x2 SampleLockStatus(FfxFloat32x2 fUV)
|
||||||
|
{
|
||||||
|
FfxFloat32x2 fLockStatus = r_lock_status.SampleLevel(s_LinearClamp, fUV, 0);
|
||||||
|
return fLockStatus;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined(FSR3UPSCALER_BIND_SRV_RECONSTRUCTED_PREV_NEAREST_DEPTH)
|
||||||
|
FfxFloat32 LoadReconstructedPrevDepth(FfxUInt32x2 iPxPos)
|
||||||
|
{
|
||||||
|
return asfloat(r_reconstructed_previous_nearest_depth[iPxPos]);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined(FSR3UPSCALER_BIND_UAV_RECONSTRUCTED_PREV_NEAREST_DEPTH)
|
||||||
|
void StoreReconstructedDepth(FfxUInt32x2 iPxSample, FfxFloat32 fDepth)
|
||||||
|
{
|
||||||
|
FfxUInt32 uDepth = asuint(fDepth);
|
||||||
|
|
||||||
|
#if FFX_FSR3UPSCALER_OPTION_INVERTED_DEPTH
|
||||||
|
InterlockedMax(rw_reconstructed_previous_nearest_depth[iPxSample], uDepth);
|
||||||
|
#else
|
||||||
|
InterlockedMin(rw_reconstructed_previous_nearest_depth[iPxSample], uDepth); // min for standard, max for inverted depth
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined(FSR3UPSCALER_BIND_UAV_RECONSTRUCTED_PREV_NEAREST_DEPTH)
|
||||||
|
void SetReconstructedDepth(FfxUInt32x2 iPxSample, const FfxUInt32 uValue)
|
||||||
|
{
|
||||||
|
rw_reconstructed_previous_nearest_depth[iPxSample] = uValue;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined(FSR3UPSCALER_BIND_UAV_DILATED_DEPTH)
|
||||||
|
void StoreDilatedDepth(FFX_PARAMETER_IN FfxUInt32x2 iPxPos, FFX_PARAMETER_IN FfxFloat32 fDepth)
|
||||||
|
{
|
||||||
|
rw_dilated_depth[iPxPos] = fDepth;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined(FSR3UPSCALER_BIND_UAV_DILATED_MOTION_VECTORS)
|
||||||
|
void StoreDilatedMotionVector(FFX_PARAMETER_IN FfxUInt32x2 iPxPos, FFX_PARAMETER_IN FfxFloat32x2 fMotionVector)
|
||||||
|
{
|
||||||
|
rw_dilated_motion_vectors[iPxPos] = fMotionVector;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined(FSR3UPSCALER_BIND_SRV_DILATED_MOTION_VECTORS)
|
||||||
|
FfxFloat32x2 LoadDilatedMotionVector(FfxUInt32x2 iPxInput)
|
||||||
|
{
|
||||||
|
return r_dilated_motion_vectors[iPxInput].xy;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined(FSR3UPSCALER_BIND_SRV_PREVIOUS_DILATED_MOTION_VECTORS)
|
||||||
|
FfxFloat32x2 LoadPreviousDilatedMotionVector(FfxUInt32x2 iPxInput)
|
||||||
|
{
|
||||||
|
return r_previous_dilated_motion_vectors[iPxInput].xy;
|
||||||
|
}
|
||||||
|
|
||||||
|
FfxFloat32x2 SamplePreviousDilatedMotionVector(FfxFloat32x2 uv)
|
||||||
|
{
|
||||||
|
return r_previous_dilated_motion_vectors.SampleLevel(s_LinearClamp, uv, 0).xy;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined(FSR3UPSCALER_BIND_SRV_DILATED_DEPTH)
|
||||||
|
FfxFloat32 LoadDilatedDepth(FfxUInt32x2 iPxInput)
|
||||||
|
{
|
||||||
|
return r_dilated_depth[iPxInput];
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined(FSR3UPSCALER_BIND_SRV_INPUT_EXPOSURE)
|
||||||
|
FfxFloat32 Exposure()
|
||||||
|
{
|
||||||
|
FfxFloat32 exposure = r_input_exposure[FfxUInt32x2(0, 0)].x;
|
||||||
|
|
||||||
|
if (exposure == 0.0f) {
|
||||||
|
exposure = 1.0f;
|
||||||
|
}
|
||||||
|
|
||||||
|
return exposure;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined(FSR3UPSCALER_BIND_SRV_AUTO_EXPOSURE)
|
||||||
|
FfxFloat32 AutoExposure()
|
||||||
|
{
|
||||||
|
FfxFloat32 exposure = r_auto_exposure[FfxUInt32x2(0, 0)].x;
|
||||||
|
|
||||||
|
if (exposure == 0.0f) {
|
||||||
|
exposure = 1.0f;
|
||||||
|
}
|
||||||
|
|
||||||
|
return exposure;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
FfxFloat32 SampleLanczos2Weight(FfxFloat32 x)
|
||||||
|
{
|
||||||
|
#if defined(FSR3UPSCALER_BIND_SRV_LANCZOS_LUT)
|
||||||
|
return r_lanczos_lut.SampleLevel(s_LinearClamp, FfxFloat32x2(x / 2, 0.5f), 0);
|
||||||
|
#else
|
||||||
|
return 0.f;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
#if defined(FSR3UPSCALER_BIND_SRV_UPSCALE_MAXIMUM_BIAS_LUT)
|
||||||
|
FfxFloat32 SampleUpsampleMaximumBias(FfxFloat32x2 uv)
|
||||||
|
{
|
||||||
|
// Stored as a SNORM, so make sure to multiply by 2 to retrieve the actual expected range.
|
||||||
|
return FfxFloat32(2.0) * r_upsample_maximum_bias_lut.SampleLevel(s_LinearClamp, abs(uv) * 2.0, 0);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined(FSR3UPSCALER_BIND_SRV_DILATED_REACTIVE_MASKS)
|
||||||
|
FfxFloat32x2 SampleDilatedReactiveMasks(FfxFloat32x2 fUV)
|
||||||
|
{
|
||||||
|
return r_dilated_reactive_masks.SampleLevel(s_LinearClamp, fUV, 0);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined(FSR3UPSCALER_BIND_SRV_DILATED_REACTIVE_MASKS)
|
||||||
|
FfxFloat32x2 LoadDilatedReactiveMasks(FFX_PARAMETER_IN FfxUInt32x2 iPxPos)
|
||||||
|
{
|
||||||
|
return r_dilated_reactive_masks[iPxPos];
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined(FSR3UPSCALER_BIND_UAV_DILATED_REACTIVE_MASKS)
|
||||||
|
void StoreDilatedReactiveMasks(FFX_PARAMETER_IN FfxUInt32x2 iPxPos, FFX_PARAMETER_IN FfxFloat32x2 fDilatedReactiveMasks)
|
||||||
|
{
|
||||||
|
rw_dilated_reactive_masks[iPxPos] = fDilatedReactiveMasks;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined(FSR3UPSCALER_BIND_SRV_INPUT_OPAQUE_ONLY)
|
||||||
|
FfxFloat32x3 LoadOpaqueOnly(FFX_PARAMETER_IN FFX_MIN16_I2 iPxPos)
|
||||||
|
{
|
||||||
|
return r_input_opaque_only[UNITY_FSR3_POS(iPxPos)].xyz;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined(FSR3UPSCALER_BIND_SRV_PREV_PRE_ALPHA_COLOR)
|
||||||
|
FfxFloat32x3 LoadPrevPreAlpha(FFX_PARAMETER_IN FFX_MIN16_I2 iPxPos)
|
||||||
|
{
|
||||||
|
return r_input_prev_color_pre_alpha[iPxPos];
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined(FSR3UPSCALER_BIND_SRV_PREV_POST_ALPHA_COLOR)
|
||||||
|
FfxFloat32x3 LoadPrevPostAlpha(FFX_PARAMETER_IN FFX_MIN16_I2 iPxPos)
|
||||||
|
{
|
||||||
|
return r_input_prev_color_post_alpha[iPxPos];
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined(FSR3UPSCALER_BIND_UAV_AUTOREACTIVE)
|
||||||
|
#if defined(FSR3UPSCALER_BIND_UAV_AUTOCOMPOSITION)
|
||||||
|
void StoreAutoReactive(FFX_PARAMETER_IN FFX_MIN16_I2 iPxPos, FFX_PARAMETER_IN FFX_MIN16_F2 fReactive)
|
||||||
|
{
|
||||||
|
rw_output_autoreactive[iPxPos] = fReactive.x;
|
||||||
|
|
||||||
|
rw_output_autocomposition[iPxPos] = fReactive.y;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined(FSR3UPSCALER_BIND_UAV_PREV_PRE_ALPHA_COLOR)
|
||||||
|
void StorePrevPreAlpha(FFX_PARAMETER_IN FFX_MIN16_I2 iPxPos, FFX_PARAMETER_IN FFX_MIN16_F3 color)
|
||||||
|
{
|
||||||
|
rw_output_prev_color_pre_alpha[iPxPos] = color;
|
||||||
|
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined(FSR3UPSCALER_BIND_UAV_PREV_POST_ALPHA_COLOR)
|
||||||
|
void StorePrevPostAlpha(FFX_PARAMETER_IN FFX_MIN16_I2 iPxPos, FFX_PARAMETER_IN FFX_MIN16_F3 color)
|
||||||
|
{
|
||||||
|
rw_output_prev_color_post_alpha[iPxPos] = color;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
FfxFloat32x2 SPD_LoadExposureBuffer()
|
||||||
|
{
|
||||||
|
#if defined FSR3UPSCALER_BIND_UAV_AUTO_EXPOSURE
|
||||||
|
return rw_auto_exposure[FfxInt32x2(0, 0)];
|
||||||
|
#else
|
||||||
|
return FfxFloat32x2(0.f, 0.f);
|
||||||
|
#endif // #if defined FSR3UPSCALER_BIND_UAV_AUTO_EXPOSURE
|
||||||
|
}
|
||||||
|
|
||||||
|
void SPD_SetExposureBuffer(FfxFloat32x2 value)
|
||||||
|
{
|
||||||
|
#if defined FSR3UPSCALER_BIND_UAV_AUTO_EXPOSURE
|
||||||
|
rw_auto_exposure[FfxInt32x2(0, 0)] = value;
|
||||||
|
#endif // #if defined FSR3UPSCALER_BIND_UAV_AUTO_EXPOSURE
|
||||||
|
}
|
||||||
|
|
||||||
|
FfxFloat32x4 SPD_LoadMipmap5(FfxInt32x2 iPxPos)
|
||||||
|
{
|
||||||
|
#if defined FSR3UPSCALER_BIND_UAV_EXPOSURE_MIP_5
|
||||||
|
return FfxFloat32x4(rw_img_mip_5[iPxPos], 0, 0, 0);
|
||||||
|
#else
|
||||||
|
return FfxFloat32x4(0.f, 0.f, 0.f, 0.f);
|
||||||
|
#endif // #if defined FSR3UPSCALER_BIND_UAV_EXPOSURE_MIP_5
|
||||||
|
}
|
||||||
|
|
||||||
|
void SPD_SetMipmap(FfxInt32x2 iPxPos, FfxUInt32 slice, FfxFloat32 value)
|
||||||
|
{
|
||||||
|
switch (slice)
|
||||||
|
{
|
||||||
|
case FFX_FSR3UPSCALER_SHADING_CHANGE_MIP_LEVEL:
|
||||||
|
#if defined FSR3UPSCALER_BIND_UAV_EXPOSURE_MIP_LUMA_CHANGE
|
||||||
|
rw_img_mip_shading_change[iPxPos] = value;
|
||||||
|
#endif // #if defined FSR3UPSCALER_BIND_UAV_EXPOSURE_MIP_LUMA_CHANGE
|
||||||
|
break;
|
||||||
|
case 5:
|
||||||
|
#if defined FSR3UPSCALER_BIND_UAV_EXPOSURE_MIP_5
|
||||||
|
rw_img_mip_5[iPxPos] = value;
|
||||||
|
#endif // #if defined FSR3UPSCALER_BIND_UAV_EXPOSURE_MIP_5
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
|
||||||
|
// avoid flattened side effect
|
||||||
|
#if defined(FSR3UPSCALER_BIND_UAV_EXPOSURE_MIP_LUMA_CHANGE)
|
||||||
|
rw_img_mip_shading_change[iPxPos] = rw_img_mip_shading_change[iPxPos];
|
||||||
|
#elif defined(FSR3UPSCALER_BIND_UAV_EXPOSURE_MIP_5)
|
||||||
|
rw_img_mip_5[iPxPos] = rw_img_mip_5[iPxPos];
|
||||||
|
#endif // #if defined FSR3UPSCALER_BIND_UAV_EXPOSURE_MIP_5
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void SPD_IncreaseAtomicCounter(inout FfxUInt32 spdCounter)
|
||||||
|
{
|
||||||
|
#if defined FSR3UPSCALER_BIND_UAV_SPD_GLOBAL_ATOMIC
|
||||||
|
InterlockedAdd(rw_spd_global_atomic[FfxInt32x2(0, 0)], 1, spdCounter);
|
||||||
|
#endif // #if defined FSR3UPSCALER_BIND_UAV_SPD_GLOBAL_ATOMIC
|
||||||
|
}
|
||||||
|
|
||||||
|
void SPD_ResetAtomicCounter()
|
||||||
|
{
|
||||||
|
#if defined FSR3UPSCALER_BIND_UAV_SPD_GLOBAL_ATOMIC
|
||||||
|
rw_spd_global_atomic[FfxInt32x2(0, 0)] = 0;
|
||||||
|
#endif // #if defined FSR3UPSCALER_BIND_UAV_SPD_GLOBAL_ATOMIC
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif // #if defined(FFX_GPU)
|
||||||
@ -0,0 +1,27 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: ba849fdeb042e7f458c81408414db834
|
||||||
|
PluginImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
iconMap: {}
|
||||||
|
executionOrder: {}
|
||||||
|
defineConstraints: []
|
||||||
|
isPreloaded: 0
|
||||||
|
isOverridable: 0
|
||||||
|
isExplicitlyReferenced: 0
|
||||||
|
validateReferences: 1
|
||||||
|
platformData:
|
||||||
|
- first:
|
||||||
|
Any:
|
||||||
|
second:
|
||||||
|
enabled: 1
|
||||||
|
settings: {}
|
||||||
|
- first:
|
||||||
|
Editor: Editor
|
||||||
|
second:
|
||||||
|
enabled: 0
|
||||||
|
settings:
|
||||||
|
DefaultValueInitialized: true
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
@ -0,0 +1,566 @@
|
|||||||
|
// This file is part of the FidelityFX SDK.
|
||||||
|
//
|
||||||
|
// Copyright (c) 2023 Advanced Micro Devices, Inc. All rights reserved.
|
||||||
|
//
|
||||||
|
// 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_FSR3UPSCALER_COMMON_H)
|
||||||
|
#define FFX_FSR3UPSCALER_COMMON_H
|
||||||
|
|
||||||
|
#if defined(FFX_CPU) || defined(FFX_GPU)
|
||||||
|
//Locks
|
||||||
|
#define LOCK_LIFETIME_REMAINING 0
|
||||||
|
#define LOCK_TEMPORAL_LUMA 1
|
||||||
|
#endif // #if defined(FFX_CPU) || defined(FFX_GPU)
|
||||||
|
|
||||||
|
#if defined(FFX_GPU)
|
||||||
|
FFX_STATIC const FfxFloat32 FSR3UPSCALER_FP16_MIN = 6.10e-05f;
|
||||||
|
FFX_STATIC const FfxFloat32 FSR3UPSCALER_FP16_MAX = 65504.0f;
|
||||||
|
FFX_STATIC const FfxFloat32 FSR3UPSCALER_EPSILON = 1e-03f;
|
||||||
|
FFX_STATIC const FfxFloat32 FSR3UPSCALER_TONEMAP_EPSILON = 1.0f / FSR3UPSCALER_FP16_MAX;
|
||||||
|
FFX_STATIC const FfxFloat32 FSR3UPSCALER_FLT_MAX = 3.402823466e+38f;
|
||||||
|
FFX_STATIC const FfxFloat32 FSR3UPSCALER_FLT_MIN = 1.175494351e-38f;
|
||||||
|
|
||||||
|
// treat vector truncation warnings as errors
|
||||||
|
#pragma warning(error: 3206)
|
||||||
|
|
||||||
|
// suppress warnings
|
||||||
|
#pragma warning(disable: 3205) // conversion from larger type to smaller
|
||||||
|
#pragma warning(disable: 3571) // in ffxPow(f, e), f could be negative
|
||||||
|
|
||||||
|
// Reconstructed depth usage
|
||||||
|
FFX_STATIC const FfxFloat32 fReconstructedDepthBilinearWeightThreshold = 0.01f;
|
||||||
|
|
||||||
|
// Accumulation
|
||||||
|
FFX_STATIC const FfxFloat32 fUpsampleLanczosWeightScale = 1.0f / 12.0f;
|
||||||
|
FFX_STATIC const FfxFloat32 fMaxAccumulationLanczosWeight = 1.0f;
|
||||||
|
FFX_STATIC const FfxFloat32 fAverageLanczosWeightPerFrame = 0.74f * fUpsampleLanczosWeightScale; // Average lanczos weight for jitter accumulated samples
|
||||||
|
FFX_STATIC const FfxFloat32 fAccumulationMaxOnMotion = 3.0f * fUpsampleLanczosWeightScale;
|
||||||
|
|
||||||
|
// Auto exposure
|
||||||
|
FFX_STATIC const FfxFloat32 resetAutoExposureAverageSmoothing = 1e8f;
|
||||||
|
|
||||||
|
struct AccumulationPassCommonParams
|
||||||
|
{
|
||||||
|
FfxInt32x2 iPxHrPos;
|
||||||
|
FfxFloat32x2 fHrUv;
|
||||||
|
FfxFloat32x2 fLrUv_HwSampler;
|
||||||
|
FfxFloat32x2 fMotionVector;
|
||||||
|
FfxFloat32x2 fReprojectedHrUv;
|
||||||
|
FfxFloat32 fHrVelocity;
|
||||||
|
FfxFloat32 fDepthClipFactor;
|
||||||
|
FfxFloat32 fDilatedReactiveFactor;
|
||||||
|
FfxFloat32 fAccumulationMask;
|
||||||
|
|
||||||
|
FfxBoolean bIsResetFrame;
|
||||||
|
FfxBoolean bIsExistingSample;
|
||||||
|
FfxBoolean bIsNewSample;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct LockState
|
||||||
|
{
|
||||||
|
FfxBoolean NewLock; //Set for both unique new and re-locked new
|
||||||
|
FfxBoolean WasLockedPrevFrame; //Set to identify if the pixel was already locked (relock)
|
||||||
|
};
|
||||||
|
|
||||||
|
void InitializeNewLockSample(FFX_PARAMETER_OUT FfxFloat32x2 fLockStatus)
|
||||||
|
{
|
||||||
|
fLockStatus = FfxFloat32x2(0, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
#if FFX_HALF
|
||||||
|
void InitializeNewLockSample(FFX_PARAMETER_OUT FFX_MIN16_F2 fLockStatus)
|
||||||
|
{
|
||||||
|
fLockStatus = FFX_MIN16_F2(0, 0);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
void KillLock(FFX_PARAMETER_INOUT FfxFloat32x2 fLockStatus)
|
||||||
|
{
|
||||||
|
fLockStatus[LOCK_LIFETIME_REMAINING] = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
#if FFX_HALF
|
||||||
|
void KillLock(FFX_PARAMETER_INOUT FFX_MIN16_F2 fLockStatus)
|
||||||
|
{
|
||||||
|
fLockStatus[LOCK_LIFETIME_REMAINING] = FFX_MIN16_F(0);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
struct RectificationBox
|
||||||
|
{
|
||||||
|
FfxFloat32x3 boxCenter;
|
||||||
|
FfxFloat32x3 boxVec;
|
||||||
|
FfxFloat32x3 aabbMin;
|
||||||
|
FfxFloat32x3 aabbMax;
|
||||||
|
FfxFloat32 fBoxCenterWeight;
|
||||||
|
};
|
||||||
|
#if FFX_HALF
|
||||||
|
struct RectificationBoxMin16
|
||||||
|
{
|
||||||
|
FFX_MIN16_F3 boxCenter;
|
||||||
|
FFX_MIN16_F3 boxVec;
|
||||||
|
FFX_MIN16_F3 aabbMin;
|
||||||
|
FFX_MIN16_F3 aabbMax;
|
||||||
|
FFX_MIN16_F fBoxCenterWeight;
|
||||||
|
};
|
||||||
|
#endif
|
||||||
|
|
||||||
|
void RectificationBoxReset(FFX_PARAMETER_INOUT RectificationBox rectificationBox)
|
||||||
|
{
|
||||||
|
rectificationBox.fBoxCenterWeight = FfxFloat32(0);
|
||||||
|
|
||||||
|
rectificationBox.boxCenter = FfxFloat32x3(0, 0, 0);
|
||||||
|
rectificationBox.boxVec = FfxFloat32x3(0, 0, 0);
|
||||||
|
rectificationBox.aabbMin = FfxFloat32x3(FSR3UPSCALER_FLT_MAX, FSR3UPSCALER_FLT_MAX, FSR3UPSCALER_FLT_MAX);
|
||||||
|
rectificationBox.aabbMax = -FfxFloat32x3(FSR3UPSCALER_FLT_MAX, FSR3UPSCALER_FLT_MAX, FSR3UPSCALER_FLT_MAX);
|
||||||
|
}
|
||||||
|
#if FFX_HALF
|
||||||
|
void RectificationBoxReset(FFX_PARAMETER_INOUT RectificationBoxMin16 rectificationBox)
|
||||||
|
{
|
||||||
|
rectificationBox.fBoxCenterWeight = FFX_MIN16_F(0);
|
||||||
|
|
||||||
|
rectificationBox.boxCenter = FFX_MIN16_F3(0, 0, 0);
|
||||||
|
rectificationBox.boxVec = FFX_MIN16_F3(0, 0, 0);
|
||||||
|
rectificationBox.aabbMin = FFX_MIN16_F3(FSR3UPSCALER_FP16_MAX, FSR3UPSCALER_FP16_MAX, FSR3UPSCALER_FP16_MAX);
|
||||||
|
rectificationBox.aabbMax = -FFX_MIN16_F3(FSR3UPSCALER_FP16_MAX, FSR3UPSCALER_FP16_MAX, FSR3UPSCALER_FP16_MAX);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
void RectificationBoxAddInitialSample(FFX_PARAMETER_INOUT RectificationBox rectificationBox, const FfxFloat32x3 colorSample, const FfxFloat32 fSampleWeight)
|
||||||
|
{
|
||||||
|
rectificationBox.aabbMin = colorSample;
|
||||||
|
rectificationBox.aabbMax = colorSample;
|
||||||
|
|
||||||
|
FfxFloat32x3 weightedSample = colorSample * fSampleWeight;
|
||||||
|
rectificationBox.boxCenter = weightedSample;
|
||||||
|
rectificationBox.boxVec = colorSample * weightedSample;
|
||||||
|
rectificationBox.fBoxCenterWeight = fSampleWeight;
|
||||||
|
}
|
||||||
|
|
||||||
|
void RectificationBoxAddSample(FfxBoolean bInitialSample, FFX_PARAMETER_INOUT RectificationBox rectificationBox, const FfxFloat32x3 colorSample, const FfxFloat32 fSampleWeight)
|
||||||
|
{
|
||||||
|
if (bInitialSample) {
|
||||||
|
RectificationBoxAddInitialSample(rectificationBox, colorSample, fSampleWeight);
|
||||||
|
} else {
|
||||||
|
rectificationBox.aabbMin = ffxMin(rectificationBox.aabbMin, colorSample);
|
||||||
|
rectificationBox.aabbMax = ffxMax(rectificationBox.aabbMax, colorSample);
|
||||||
|
|
||||||
|
FfxFloat32x3 weightedSample = colorSample * fSampleWeight;
|
||||||
|
rectificationBox.boxCenter += weightedSample;
|
||||||
|
rectificationBox.boxVec += colorSample * weightedSample;
|
||||||
|
rectificationBox.fBoxCenterWeight += fSampleWeight;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#if FFX_HALF
|
||||||
|
void RectificationBoxAddInitialSample(FFX_PARAMETER_INOUT RectificationBoxMin16 rectificationBox, const FFX_MIN16_F3 colorSample, const FFX_MIN16_F fSampleWeight)
|
||||||
|
{
|
||||||
|
rectificationBox.aabbMin = colorSample;
|
||||||
|
rectificationBox.aabbMax = colorSample;
|
||||||
|
|
||||||
|
FFX_MIN16_F3 weightedSample = colorSample * fSampleWeight;
|
||||||
|
rectificationBox.boxCenter = weightedSample;
|
||||||
|
rectificationBox.boxVec = colorSample * weightedSample;
|
||||||
|
rectificationBox.fBoxCenterWeight = fSampleWeight;
|
||||||
|
}
|
||||||
|
|
||||||
|
void RectificationBoxAddSample(FfxBoolean bInitialSample, FFX_PARAMETER_INOUT RectificationBoxMin16 rectificationBox, const FFX_MIN16_F3 colorSample, const FFX_MIN16_F fSampleWeight)
|
||||||
|
{
|
||||||
|
if (bInitialSample) {
|
||||||
|
RectificationBoxAddInitialSample(rectificationBox, colorSample, fSampleWeight);
|
||||||
|
} else {
|
||||||
|
rectificationBox.aabbMin = ffxMin(rectificationBox.aabbMin, colorSample);
|
||||||
|
rectificationBox.aabbMax = ffxMax(rectificationBox.aabbMax, colorSample);
|
||||||
|
|
||||||
|
FFX_MIN16_F3 weightedSample = colorSample * fSampleWeight;
|
||||||
|
rectificationBox.boxCenter += weightedSample;
|
||||||
|
rectificationBox.boxVec += colorSample * weightedSample;
|
||||||
|
rectificationBox.fBoxCenterWeight += fSampleWeight;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
void RectificationBoxComputeVarianceBoxData(FFX_PARAMETER_INOUT RectificationBox rectificationBox)
|
||||||
|
{
|
||||||
|
rectificationBox.fBoxCenterWeight = (abs(rectificationBox.fBoxCenterWeight) > FfxFloat32(FSR3UPSCALER_EPSILON) ? rectificationBox.fBoxCenterWeight : FfxFloat32(1.f));
|
||||||
|
rectificationBox.boxCenter /= rectificationBox.fBoxCenterWeight;
|
||||||
|
rectificationBox.boxVec /= rectificationBox.fBoxCenterWeight;
|
||||||
|
FfxFloat32x3 stdDev = sqrt(abs(rectificationBox.boxVec - rectificationBox.boxCenter * rectificationBox.boxCenter));
|
||||||
|
rectificationBox.boxVec = stdDev;
|
||||||
|
}
|
||||||
|
#if FFX_HALF
|
||||||
|
void RectificationBoxComputeVarianceBoxData(FFX_PARAMETER_INOUT RectificationBoxMin16 rectificationBox)
|
||||||
|
{
|
||||||
|
rectificationBox.fBoxCenterWeight = (abs(rectificationBox.fBoxCenterWeight) > FFX_MIN16_F(FSR3UPSCALER_EPSILON) ? rectificationBox.fBoxCenterWeight : FFX_MIN16_F(1.f));
|
||||||
|
rectificationBox.boxCenter /= rectificationBox.fBoxCenterWeight;
|
||||||
|
rectificationBox.boxVec /= rectificationBox.fBoxCenterWeight;
|
||||||
|
FFX_MIN16_F3 stdDev = sqrt(abs(rectificationBox.boxVec - rectificationBox.boxCenter * rectificationBox.boxCenter));
|
||||||
|
rectificationBox.boxVec = stdDev;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
FfxFloat32x3 SafeRcp3(FfxFloat32x3 v)
|
||||||
|
{
|
||||||
|
return (all(FFX_NOT_EQUAL(v, FfxFloat32x3(0, 0, 0)))) ? (FfxFloat32x3(1, 1, 1) / v) : FfxFloat32x3(0, 0, 0);
|
||||||
|
}
|
||||||
|
#if FFX_HALF
|
||||||
|
FFX_MIN16_F3 SafeRcp3(FFX_MIN16_F3 v)
|
||||||
|
{
|
||||||
|
return (all(FFX_NOT_EQUAL(v, FFX_MIN16_F3(0, 0, 0)))) ? (FFX_MIN16_F3(1, 1, 1) / v) : FFX_MIN16_F3(0, 0, 0);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
FfxFloat32 MinDividedByMax(const FfxFloat32 v0, const FfxFloat32 v1)
|
||||||
|
{
|
||||||
|
const FfxFloat32 m = ffxMax(v0, v1);
|
||||||
|
return m != 0 ? ffxMin(v0, v1) / m : 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
#if FFX_HALF
|
||||||
|
FFX_MIN16_F MinDividedByMax(const FFX_MIN16_F v0, const FFX_MIN16_F v1)
|
||||||
|
{
|
||||||
|
const FFX_MIN16_F m = ffxMax(v0, v1);
|
||||||
|
return m != FFX_MIN16_F(0) ? ffxMin(v0, v1) / m : FFX_MIN16_F(0);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
FfxFloat32x3 YCoCgToRGB(FfxFloat32x3 fYCoCg)
|
||||||
|
{
|
||||||
|
FfxFloat32x3 fRgb;
|
||||||
|
|
||||||
|
fRgb = FfxFloat32x3(
|
||||||
|
fYCoCg.x + fYCoCg.y - fYCoCg.z,
|
||||||
|
fYCoCg.x + fYCoCg.z,
|
||||||
|
fYCoCg.x - fYCoCg.y - fYCoCg.z);
|
||||||
|
|
||||||
|
return fRgb;
|
||||||
|
}
|
||||||
|
#if FFX_HALF
|
||||||
|
FFX_MIN16_F3 YCoCgToRGB(FFX_MIN16_F3 fYCoCg)
|
||||||
|
{
|
||||||
|
FFX_MIN16_F3 fRgb;
|
||||||
|
|
||||||
|
fRgb = FFX_MIN16_F3(
|
||||||
|
fYCoCg.x + fYCoCg.y - fYCoCg.z,
|
||||||
|
fYCoCg.x + fYCoCg.z,
|
||||||
|
fYCoCg.x - fYCoCg.y - fYCoCg.z);
|
||||||
|
|
||||||
|
return fRgb;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
FfxFloat32x3 RGBToYCoCg(FfxFloat32x3 fRgb)
|
||||||
|
{
|
||||||
|
FfxFloat32x3 fYCoCg;
|
||||||
|
|
||||||
|
fYCoCg = FfxFloat32x3(
|
||||||
|
0.25f * fRgb.r + 0.5f * fRgb.g + 0.25f * fRgb.b,
|
||||||
|
0.5f * fRgb.r - 0.5f * fRgb.b,
|
||||||
|
-0.25f * fRgb.r + 0.5f * fRgb.g - 0.25f * fRgb.b);
|
||||||
|
|
||||||
|
return fYCoCg;
|
||||||
|
}
|
||||||
|
#if FFX_HALF
|
||||||
|
FFX_MIN16_F3 RGBToYCoCg(FFX_MIN16_F3 fRgb)
|
||||||
|
{
|
||||||
|
FFX_MIN16_F3 fYCoCg;
|
||||||
|
|
||||||
|
fYCoCg = FFX_MIN16_F3(
|
||||||
|
0.25 * fRgb.r + 0.5 * fRgb.g + 0.25 * fRgb.b,
|
||||||
|
0.5 * fRgb.r - 0.5 * fRgb.b,
|
||||||
|
-0.25 * fRgb.r + 0.5 * fRgb.g - 0.25 * fRgb.b);
|
||||||
|
|
||||||
|
return fYCoCg;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
FfxFloat32 RGBToLuma(FfxFloat32x3 fLinearRgb)
|
||||||
|
{
|
||||||
|
return dot(fLinearRgb, FfxFloat32x3(0.2126f, 0.7152f, 0.0722f));
|
||||||
|
}
|
||||||
|
#if FFX_HALF
|
||||||
|
FFX_MIN16_F RGBToLuma(FFX_MIN16_F3 fLinearRgb)
|
||||||
|
{
|
||||||
|
return dot(fLinearRgb, FFX_MIN16_F3(0.2126f, 0.7152f, 0.0722f));
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
FfxFloat32 RGBToPerceivedLuma(FfxFloat32x3 fLinearRgb)
|
||||||
|
{
|
||||||
|
FfxFloat32 fLuminance = RGBToLuma(fLinearRgb);
|
||||||
|
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
#if FFX_HALF
|
||||||
|
FFX_MIN16_F RGBToPerceivedLuma(FFX_MIN16_F3 fLinearRgb)
|
||||||
|
{
|
||||||
|
FFX_MIN16_F fLuminance = RGBToLuma(fLinearRgb);
|
||||||
|
|
||||||
|
FFX_MIN16_F fPercievedLuminance = FFX_MIN16_F(0);
|
||||||
|
if (fLuminance <= FFX_MIN16_F(216.0f / 24389.0f)) {
|
||||||
|
fPercievedLuminance = fLuminance * FFX_MIN16_F(24389.0f / 27.0f);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
fPercievedLuminance = ffxPow(fLuminance, FFX_MIN16_F(1.0f / 3.0f)) * FFX_MIN16_F(116.0f) - FFX_MIN16_F(16.0f);
|
||||||
|
}
|
||||||
|
|
||||||
|
return fPercievedLuminance * FFX_MIN16_F(0.01f);
|
||||||
|
}
|
||||||
|
#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(FSR3UPSCALER_TONEMAP_EPSILON, 1.f - ffxMax(fRgb.r, ffxMax(fRgb.g, fRgb.b))).xxx;
|
||||||
|
}
|
||||||
|
|
||||||
|
#if FFX_HALF
|
||||||
|
FFX_MIN16_F3 Tonemap(FFX_MIN16_F3 fRgb)
|
||||||
|
{
|
||||||
|
return fRgb / (ffxMax(ffxMax(FFX_MIN16_F(0.f), fRgb.r), ffxMax(fRgb.g, fRgb.b)) + FFX_MIN16_F(1.f)).xxx;
|
||||||
|
}
|
||||||
|
|
||||||
|
FFX_MIN16_F3 InverseTonemap(FFX_MIN16_F3 fRgb)
|
||||||
|
{
|
||||||
|
return fRgb / ffxMax(FFX_MIN16_F(FSR3UPSCALER_TONEMAP_EPSILON), FFX_MIN16_F(1.f) - ffxMax(fRgb.r, ffxMax(fRgb.g, fRgb.b))).xxx;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
FfxInt32x2 ClampLoad(FfxInt32x2 iPxSample, FfxInt32x2 iPxOffset, FfxInt32x2 iTextureSize)
|
||||||
|
{
|
||||||
|
FfxInt32x2 result = iPxSample + iPxOffset;
|
||||||
|
result.x = (iPxOffset.x < 0) ? ffxMax(result.x, 0) : result.x;
|
||||||
|
result.x = (iPxOffset.x > 0) ? ffxMin(result.x, iTextureSize.x - 1) : result.x;
|
||||||
|
result.y = (iPxOffset.y < 0) ? ffxMax(result.y, 0) : result.y;
|
||||||
|
result.y = (iPxOffset.y > 0) ? ffxMin(result.y, iTextureSize.y - 1) : result.y;
|
||||||
|
return result;
|
||||||
|
|
||||||
|
// return ffxMed3(iPxSample + iPxOffset, FfxInt32x2(0, 0), iTextureSize - FfxInt32x2(1, 1));
|
||||||
|
}
|
||||||
|
#if FFX_HALF
|
||||||
|
FFX_MIN16_I2 ClampLoad(FFX_MIN16_I2 iPxSample, FFX_MIN16_I2 iPxOffset, FFX_MIN16_I2 iTextureSize)
|
||||||
|
{
|
||||||
|
FFX_MIN16_I2 result = iPxSample + iPxOffset;
|
||||||
|
result.x = (iPxOffset.x < 0) ? ffxMax(result.x, FFX_MIN16_I(0)) : result.x;
|
||||||
|
result.x = (iPxOffset.x > 0) ? ffxMin(result.x, iTextureSize.x - FFX_MIN16_I(1)) : result.x;
|
||||||
|
result.y = (iPxOffset.y < 0) ? ffxMax(result.y, FFX_MIN16_I(0)) : result.y;
|
||||||
|
result.y = (iPxOffset.y > 0) ? ffxMin(result.y, iTextureSize.y - FFX_MIN16_I(1)) : result.y;
|
||||||
|
return result;
|
||||||
|
|
||||||
|
// return ffxMed3Half(iPxSample + iPxOffset, FFX_MIN16_I2(0, 0), iTextureSize - FFX_MIN16_I2(1, 1));
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
FfxFloat32x2 ClampUv(FfxFloat32x2 fUv, FfxInt32x2 iTextureSize, FfxInt32x2 iResourceSize)
|
||||||
|
{
|
||||||
|
const FfxFloat32x2 fSampleLocation = fUv * iTextureSize;
|
||||||
|
const FfxFloat32x2 fClampedLocation = ffxMax(FfxFloat32x2(0.5f, 0.5f), ffxMin(fSampleLocation, FfxFloat32x2(iTextureSize) - FfxFloat32x2(0.5f, 0.5f)));
|
||||||
|
const FfxFloat32x2 fClampedUv = fClampedLocation / FfxFloat32x2(iResourceSize);
|
||||||
|
|
||||||
|
return fClampedUv;
|
||||||
|
}
|
||||||
|
|
||||||
|
FfxBoolean IsOnScreen(FfxInt32x2 pos, FfxInt32x2 size)
|
||||||
|
{
|
||||||
|
return all(FFX_LESS_THAN(FfxUInt32x2(pos), FfxUInt32x2(size)));
|
||||||
|
}
|
||||||
|
#if FFX_HALF
|
||||||
|
FfxBoolean IsOnScreen(FFX_MIN16_I2 pos, FFX_MIN16_I2 size)
|
||||||
|
{
|
||||||
|
return all(FFX_LESS_THAN(FFX_MIN16_U2(pos), FFX_MIN16_U2(size)));
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
FfxFloat32 ComputeAutoExposureFromLavg(FfxFloat32 Lavg)
|
||||||
|
{
|
||||||
|
Lavg = exp(Lavg);
|
||||||
|
|
||||||
|
const FfxFloat32 S = 100.0f; //ISO arithmetic speed
|
||||||
|
const FfxFloat32 K = 12.5f;
|
||||||
|
FfxFloat32 ExposureISO100 = log2((Lavg * S) / K);
|
||||||
|
|
||||||
|
const FfxFloat32 q = 0.65f;
|
||||||
|
FfxFloat32 Lmax = (78.0f / (q * S)) * ffxPow(2.0f, ExposureISO100);
|
||||||
|
|
||||||
|
return 1 / Lmax;
|
||||||
|
}
|
||||||
|
#if FFX_HALF
|
||||||
|
FFX_MIN16_F ComputeAutoExposureFromLavg(FFX_MIN16_F Lavg)
|
||||||
|
{
|
||||||
|
Lavg = exp(Lavg);
|
||||||
|
|
||||||
|
const FFX_MIN16_F S = FFX_MIN16_F(100.0f); //ISO arithmetic speed
|
||||||
|
const FFX_MIN16_F K = FFX_MIN16_F(12.5f);
|
||||||
|
const FFX_MIN16_F ExposureISO100 = log2((Lavg * S) / K);
|
||||||
|
|
||||||
|
const FFX_MIN16_F q = FFX_MIN16_F(0.65f);
|
||||||
|
const FFX_MIN16_F Lmax = (FFX_MIN16_F(78.0f) / (q * S)) * ffxPow(FFX_MIN16_F(2.0f), ExposureISO100);
|
||||||
|
|
||||||
|
return FFX_MIN16_F(1) / Lmax;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
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
|
||||||
|
|
||||||
|
FfxFloat32x2 ComputeNdc(FfxFloat32x2 fPxPos, FfxInt32x2 iSize)
|
||||||
|
{
|
||||||
|
return fPxPos / FfxFloat32x2(iSize) * FfxFloat32x2(2.0f, -2.0f) + FfxFloat32x2(-1.0f, 1.0f);
|
||||||
|
}
|
||||||
|
|
||||||
|
FfxFloat32 GetViewSpaceDepth(FfxFloat32 fDeviceDepth)
|
||||||
|
{
|
||||||
|
const FfxFloat32x4 fDeviceToViewDepth = DeviceToViewSpaceTransformFactors();
|
||||||
|
|
||||||
|
// fDeviceToViewDepth details found in ffx_fsr3upscaler.cpp
|
||||||
|
return (fDeviceToViewDepth[1] / (fDeviceDepth - fDeviceToViewDepth[0]));
|
||||||
|
}
|
||||||
|
|
||||||
|
FfxFloat32 GetViewSpaceDepthInMeters(FfxFloat32 fDeviceDepth)
|
||||||
|
{
|
||||||
|
return GetViewSpaceDepth(fDeviceDepth) * ViewSpaceToMetersFactor();
|
||||||
|
}
|
||||||
|
|
||||||
|
FfxFloat32x3 GetViewSpacePosition(FfxInt32x2 iViewportPos, FfxInt32x2 iViewportSize, FfxFloat32 fDeviceDepth)
|
||||||
|
{
|
||||||
|
const FfxFloat32x4 fDeviceToViewDepth = DeviceToViewSpaceTransformFactors();
|
||||||
|
|
||||||
|
const FfxFloat32 Z = GetViewSpaceDepth(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);
|
||||||
|
}
|
||||||
|
|
||||||
|
FfxFloat32x3 GetViewSpacePositionInMeters(FfxInt32x2 iViewportPos, FfxInt32x2 iViewportSize, FfxFloat32 fDeviceDepth)
|
||||||
|
{
|
||||||
|
return GetViewSpacePosition(iViewportPos, iViewportSize, fDeviceDepth) * ViewSpaceToMetersFactor();
|
||||||
|
}
|
||||||
|
|
||||||
|
FfxFloat32 GetMaxDistanceInMeters()
|
||||||
|
{
|
||||||
|
#if FFX_FSR3UPSCALER_OPTION_INVERTED_DEPTH
|
||||||
|
return GetViewSpaceDepth(0.0f) * ViewSpaceToMetersFactor();
|
||||||
|
#else
|
||||||
|
return GetViewSpaceDepth(1.0f) * ViewSpaceToMetersFactor();
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
FfxFloat32x3 PrepareRgb(FfxFloat32x3 fRgb, FfxFloat32 fExposure, FfxFloat32 fPreExposure)
|
||||||
|
{
|
||||||
|
fRgb /= fPreExposure;
|
||||||
|
fRgb *= fExposure;
|
||||||
|
|
||||||
|
fRgb = clamp(fRgb, 0.0f, FSR3UPSCALER_FP16_MAX);
|
||||||
|
|
||||||
|
return fRgb;
|
||||||
|
}
|
||||||
|
|
||||||
|
FfxFloat32x3 UnprepareRgb(FfxFloat32x3 fRgb, FfxFloat32 fExposure)
|
||||||
|
{
|
||||||
|
fRgb /= fExposure;
|
||||||
|
fRgb *= PreExposure();
|
||||||
|
|
||||||
|
return fRgb;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
|
struct PlaneData
|
||||||
|
{
|
||||||
|
FfxFloat32x3 fNormal;
|
||||||
|
FfxFloat32 fDistanceFromOrigin;
|
||||||
|
};
|
||||||
|
|
||||||
|
PlaneData GetPlaneFromPoints(FfxFloat32x3 fP0, FfxFloat32x3 fP1, FfxFloat32x3 fP2)
|
||||||
|
{
|
||||||
|
PlaneData plane;
|
||||||
|
|
||||||
|
FfxFloat32x3 v0 = fP0 - fP1;
|
||||||
|
FfxFloat32x3 v1 = fP0 - fP2;
|
||||||
|
plane.fNormal = normalize(cross(v0, v1));
|
||||||
|
plane.fDistanceFromOrigin = -dot(fP0, plane.fNormal);
|
||||||
|
|
||||||
|
return plane;
|
||||||
|
}
|
||||||
|
|
||||||
|
FfxFloat32 PointToPlaneDistance(PlaneData plane, FfxFloat32x3 fPoint)
|
||||||
|
{
|
||||||
|
return abs(dot(plane.fNormal, fPoint) + plane.fDistanceFromOrigin);
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif // #if defined(FFX_GPU)
|
||||||
|
|
||||||
|
#endif //!defined(FFX_FSR3UPSCALER_COMMON_H)
|
||||||
@ -0,0 +1,27 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 6a638bec681caac4fa8e2ca198726694
|
||||||
|
PluginImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
iconMap: {}
|
||||||
|
executionOrder: {}
|
||||||
|
defineConstraints: []
|
||||||
|
isPreloaded: 0
|
||||||
|
isOverridable: 0
|
||||||
|
isExplicitlyReferenced: 0
|
||||||
|
validateReferences: 1
|
||||||
|
platformData:
|
||||||
|
- first:
|
||||||
|
Any:
|
||||||
|
second:
|
||||||
|
enabled: 1
|
||||||
|
settings: {}
|
||||||
|
- first:
|
||||||
|
Editor: Editor
|
||||||
|
second:
|
||||||
|
enabled: 0
|
||||||
|
settings:
|
||||||
|
DefaultValueInitialized: true
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
@ -0,0 +1,176 @@
|
|||||||
|
// This file is part of the FidelityFX SDK.
|
||||||
|
//
|
||||||
|
// Copyright (c) 2023 Advanced Micro Devices, Inc. All rights reserved.
|
||||||
|
//
|
||||||
|
// 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.
|
||||||
|
|
||||||
|
|
||||||
|
FFX_GROUPSHARED FfxUInt32 spdCounter;
|
||||||
|
|
||||||
|
void SpdIncreaseAtomicCounter(FfxUInt32 slice)
|
||||||
|
{
|
||||||
|
SPD_IncreaseAtomicCounter(spdCounter);
|
||||||
|
}
|
||||||
|
|
||||||
|
FfxUInt32 SpdGetAtomicCounter()
|
||||||
|
{
|
||||||
|
return spdCounter;
|
||||||
|
}
|
||||||
|
|
||||||
|
void SpdResetAtomicCounter(FfxUInt32 slice)
|
||||||
|
{
|
||||||
|
SPD_ResetAtomicCounter();
|
||||||
|
}
|
||||||
|
|
||||||
|
#ifndef SPD_PACKED_ONLY
|
||||||
|
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(FfxFloat32x2 tex, FfxUInt32 slice)
|
||||||
|
{
|
||||||
|
FfxFloat32x2 fUv = (tex + 0.5f + Jitter()) / RenderSize();
|
||||||
|
fUv = ClampUv(fUv, RenderSize(), InputColorResourceDimensions());
|
||||||
|
FfxFloat32x3 fRgb = SampleInputColor(fUv);
|
||||||
|
|
||||||
|
fRgb /= PreExposure();
|
||||||
|
|
||||||
|
//compute log luma
|
||||||
|
const FfxFloat32 fLogLuma = log(ffxMax(FSR3UPSCALER_EPSILON, RGBToLuma(fRgb)));
|
||||||
|
|
||||||
|
// Make sure out of screen pixels contribute no value to the end result
|
||||||
|
const FfxFloat32 result = all(FFX_LESS_THAN(tex, RenderSize())) ? fLogLuma : 0.0f;
|
||||||
|
|
||||||
|
return FfxFloat32x4(result, 0, 0, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
FfxFloat32x4 SpdLoad(FfxInt32x2 tex, FfxUInt32 slice)
|
||||||
|
{
|
||||||
|
return SPD_LoadMipmap5(tex);
|
||||||
|
}
|
||||||
|
|
||||||
|
void SpdStore(FfxInt32x2 pix, FfxFloat32x4 outValue, FfxUInt32 index, FfxUInt32 slice)
|
||||||
|
{
|
||||||
|
if (index == LumaMipLevelToUse() || index == 5)
|
||||||
|
{
|
||||||
|
SPD_SetMipmap(pix, index, outValue.r);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (index == MipCount() - 1) { //accumulate on 1x1 level
|
||||||
|
|
||||||
|
if (all(FFX_EQUAL(pix, FfxInt32x2(0, 0))))
|
||||||
|
{
|
||||||
|
FfxFloat32 prev = SPD_LoadExposureBuffer().y;
|
||||||
|
FfxFloat32 result = outValue.r;
|
||||||
|
|
||||||
|
if (prev < resetAutoExposureAverageSmoothing) // Compare Lavg, so small or negative values
|
||||||
|
{
|
||||||
|
FfxFloat32 rate = 1.0f;
|
||||||
|
result = prev + (result - prev) * (1 - exp(-DeltaTime() * rate));
|
||||||
|
}
|
||||||
|
FfxFloat32x2 spdOutput = FfxFloat32x2(ComputeAutoExposureFromLavg(result), result);
|
||||||
|
SPD_SetExposureBuffer(spdOutput);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
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.25f;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// define fetch and store functions Packed
|
||||||
|
#if FFX_HALF
|
||||||
|
|
||||||
|
FFX_GROUPSHARED FfxFloat16x2 spdIntermediateRG[16][16];
|
||||||
|
FFX_GROUPSHARED FfxFloat16x2 spdIntermediateBA[16][16];
|
||||||
|
|
||||||
|
FfxFloat16x4 SpdLoadSourceImageH(FfxFloat32x2 tex, FfxUInt32 slice)
|
||||||
|
{
|
||||||
|
return FfxFloat16x4(0, 0, 0, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
FfxFloat16x4 SpdLoadH(FfxInt32x2 p, FfxUInt32 slice)
|
||||||
|
{
|
||||||
|
return FfxFloat16x4(0, 0, 0, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
void SpdStoreH(FfxInt32x2 p, FfxFloat16x4 value, FfxUInt32 mip, FfxUInt32 slice)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
FfxFloat16x4 SpdLoadIntermediateH(FfxUInt32 x, FfxUInt32 y)
|
||||||
|
{
|
||||||
|
return FfxFloat16x4(
|
||||||
|
spdIntermediateRG[x][y].x,
|
||||||
|
spdIntermediateRG[x][y].y,
|
||||||
|
spdIntermediateBA[x][y].x,
|
||||||
|
spdIntermediateBA[x][y].y);
|
||||||
|
}
|
||||||
|
|
||||||
|
void SpdStoreIntermediateH(FfxUInt32 x, FfxUInt32 y, FfxFloat16x4 value)
|
||||||
|
{
|
||||||
|
spdIntermediateRG[x][y] = value.xy;
|
||||||
|
spdIntermediateBA[x][y] = value.zw;
|
||||||
|
}
|
||||||
|
|
||||||
|
FfxFloat16x4 SpdReduce4H(FfxFloat16x4 v0, FfxFloat16x4 v1, FfxFloat16x4 v2, FfxFloat16x4 v3)
|
||||||
|
{
|
||||||
|
return (v0 + v1 + v2 + v3) * FfxFloat16(0.25);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include "spd/ffx_spd.h"
|
||||||
|
|
||||||
|
void ComputeAutoExposure(FfxUInt32x3 WorkGroupId, FfxUInt32 LocalThreadIndex)
|
||||||
|
{
|
||||||
|
#if FFX_HALF
|
||||||
|
SpdDownsampleH(
|
||||||
|
FfxUInt32x2(WorkGroupId.xy),
|
||||||
|
FfxUInt32(LocalThreadIndex),
|
||||||
|
FfxUInt32(MipCount()),
|
||||||
|
FfxUInt32(NumWorkGroups()),
|
||||||
|
FfxUInt32(WorkGroupId.z),
|
||||||
|
FfxUInt32x2(WorkGroupOffset()));
|
||||||
|
#else
|
||||||
|
SpdDownsample(
|
||||||
|
FfxUInt32x2(WorkGroupId.xy),
|
||||||
|
FfxUInt32(LocalThreadIndex),
|
||||||
|
FfxUInt32(MipCount()),
|
||||||
|
FfxUInt32(NumWorkGroups()),
|
||||||
|
FfxUInt32(WorkGroupId.z),
|
||||||
|
FfxUInt32x2(WorkGroupOffset()));
|
||||||
|
#endif
|
||||||
|
}
|
||||||
@ -0,0 +1,27 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 61bd10363d44ee2478461c9e9efbcb67
|
||||||
|
PluginImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
iconMap: {}
|
||||||
|
executionOrder: {}
|
||||||
|
defineConstraints: []
|
||||||
|
isPreloaded: 0
|
||||||
|
isOverridable: 0
|
||||||
|
isExplicitlyReferenced: 0
|
||||||
|
validateReferences: 1
|
||||||
|
platformData:
|
||||||
|
- first:
|
||||||
|
Any:
|
||||||
|
second:
|
||||||
|
enabled: 1
|
||||||
|
settings: {}
|
||||||
|
- first:
|
||||||
|
Editor: Editor
|
||||||
|
second:
|
||||||
|
enabled: 0
|
||||||
|
settings:
|
||||||
|
DefaultValueInitialized: true
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
@ -0,0 +1,259 @@
|
|||||||
|
// This file is part of the FidelityFX SDK.
|
||||||
|
//
|
||||||
|
// Copyright (c) 2023 Advanced Micro Devices, Inc. All rights reserved.
|
||||||
|
//
|
||||||
|
// 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_FSR3UPSCALER_DEPTH_CLIP_H
|
||||||
|
#define FFX_FSR3UPSCALER_DEPTH_CLIP_H
|
||||||
|
|
||||||
|
FFX_STATIC const FfxFloat32 DepthClipBaseScale = 4.0f;
|
||||||
|
|
||||||
|
FfxFloat32 ComputeDepthClip(FfxFloat32x2 fUvSample, FfxFloat32 fCurrentDepthSample)
|
||||||
|
{
|
||||||
|
FfxFloat32 fCurrentDepthViewSpace = GetViewSpaceDepth(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 = LoadReconstructedPrevDepth(iSamplePos);
|
||||||
|
const FfxFloat32 fPrevNearestDepthViewSpace = GetViewSpaceDepth(fPrevDepthSample);
|
||||||
|
|
||||||
|
const FfxFloat32 fDepthDiff = fCurrentDepthViewSpace - fPrevNearestDepthViewSpace;
|
||||||
|
|
||||||
|
if (fDepthDiff > 0.0f) {
|
||||||
|
|
||||||
|
#if FFX_FSR3UPSCALER_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 = ffxMax(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 += ffxPow(ffxSaturate(FfxFloat32(fRequiredDepthSeparation / fDepthDiff)), fPower) * fWeight;
|
||||||
|
fWeightSum += fWeight;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return (fWeightSum > 0) ? ffxSaturate(1.0f - fDepth / fWeightSum) : 0.0f;
|
||||||
|
}
|
||||||
|
|
||||||
|
FfxFloat32 ComputeMotionDivergence(FfxInt32x2 iPxPos, FfxInt32x2 iPxInputMotionVectorSize)
|
||||||
|
{
|
||||||
|
FfxFloat32 minconvergence = 1.0f;
|
||||||
|
|
||||||
|
FfxFloat32x2 fMotionVectorNucleus = LoadInputMotionVector(iPxPos);
|
||||||
|
FfxFloat32 fNucleusVelocityLr = length(fMotionVectorNucleus * RenderSize());
|
||||||
|
FfxFloat32 fMaxVelocityUv = length(fMotionVectorNucleus);
|
||||||
|
|
||||||
|
const FfxFloat32 MotionVectorVelocityEpsilon = 1e-02f;
|
||||||
|
|
||||||
|
if (fNucleusVelocityLr > MotionVectorVelocityEpsilon) {
|
||||||
|
for (FfxInt32 y = -1; y <= 1; ++y) {
|
||||||
|
for (FfxInt32 x = -1; x <= 1; ++x) {
|
||||||
|
|
||||||
|
FfxInt32x2 sp = ClampLoad(iPxPos, FfxInt32x2(x, y), iPxInputMotionVectorSize);
|
||||||
|
|
||||||
|
FfxFloat32x2 fMotionVector = LoadInputMotionVector(sp);
|
||||||
|
FfxFloat32 fVelocityUv = length(fMotionVector);
|
||||||
|
|
||||||
|
fMaxVelocityUv = ffxMax(fVelocityUv, fMaxVelocityUv);
|
||||||
|
fVelocityUv = ffxMax(fVelocityUv, fMaxVelocityUv);
|
||||||
|
minconvergence = ffxMin(minconvergence, dot(fMotionVector / fVelocityUv, fMotionVectorNucleus / fVelocityUv));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return ffxSaturate(1.0f - minconvergence) * ffxSaturate(fMaxVelocityUv / 0.01f);
|
||||||
|
}
|
||||||
|
|
||||||
|
FfxFloat32 ComputeDepthDivergence(FfxInt32x2 iPxPos)
|
||||||
|
{
|
||||||
|
const FfxFloat32 fMaxDistInMeters = GetMaxDistanceInMeters();
|
||||||
|
FfxFloat32 fDepthMax = 0.0f;
|
||||||
|
FfxFloat32 fDepthMin = fMaxDistInMeters;
|
||||||
|
|
||||||
|
FfxInt32 iMaxDistFound = 0;
|
||||||
|
|
||||||
|
for (FfxInt32 y = -1; y < 2; y++) {
|
||||||
|
for (FfxInt32 x = -1; x < 2; x++) {
|
||||||
|
|
||||||
|
const FfxInt32x2 iOffset = FfxInt32x2(x, y);
|
||||||
|
const FfxInt32x2 iSamplePos = iPxPos + iOffset;
|
||||||
|
|
||||||
|
const FfxFloat32 fOnScreenFactor = IsOnScreen(iSamplePos, RenderSize()) ? 1.0f : 0.0f;
|
||||||
|
FfxFloat32 fDepth = GetViewSpaceDepthInMeters(LoadDilatedDepth(iSamplePos)) * fOnScreenFactor;
|
||||||
|
|
||||||
|
iMaxDistFound |= FfxInt32(fMaxDistInMeters == fDepth);
|
||||||
|
|
||||||
|
fDepthMin = ffxMin(fDepthMin, fDepth);
|
||||||
|
fDepthMax = ffxMax(fDepthMax, fDepth);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return (1.0f - fDepthMin / fDepthMax) * (FfxBoolean(iMaxDistFound) ? 0.0f : 1.0f);
|
||||||
|
}
|
||||||
|
|
||||||
|
FfxFloat32 ComputeTemporalMotionDivergence(FfxInt32x2 iPxPos)
|
||||||
|
{
|
||||||
|
const FfxFloat32x2 fUv = FfxFloat32x2(iPxPos + 0.5f) / RenderSize();
|
||||||
|
|
||||||
|
FfxFloat32x2 fMotionVector = LoadDilatedMotionVector(iPxPos);
|
||||||
|
FfxFloat32x2 fReprojectedUv = fUv + fMotionVector;
|
||||||
|
fReprojectedUv = ClampUv(fReprojectedUv, RenderSize(), MaxRenderSize());
|
||||||
|
FfxFloat32x2 fPrevMotionVector = SamplePreviousDilatedMotionVector(fReprojectedUv);
|
||||||
|
|
||||||
|
float fPxDistance = length(fMotionVector * DisplaySize());
|
||||||
|
return fPxDistance > 1.0f ? ffxLerp(0.0f, 1.0f - ffxSaturate(length(fPrevMotionVector) / length(fMotionVector)), ffxSaturate(ffxPow(fPxDistance / 20.0f, 3.0f))) : 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
void PreProcessReactiveMasks(FfxInt32x2 iPxLrPos, FfxFloat32 fMotionDivergence)
|
||||||
|
{
|
||||||
|
// Compensate for bilinear sampling in accumulation pass
|
||||||
|
|
||||||
|
FfxFloat32x3 fReferenceColor = LoadInputColor(iPxLrPos).xyz;
|
||||||
|
FfxFloat32x2 fReactiveFactor = FfxFloat32x2(0.0f, fMotionDivergence);
|
||||||
|
|
||||||
|
float fMasksSum = 0.0f;
|
||||||
|
|
||||||
|
FfxFloat32x3 fColorSamples[9];
|
||||||
|
FfxFloat32 fReactiveSamples[9];
|
||||||
|
FfxFloat32 fTransparencyAndCompositionSamples[9];
|
||||||
|
|
||||||
|
FFX_UNROLL
|
||||||
|
for (FfxInt32 y = -1; y < 2; y++) {
|
||||||
|
FFX_UNROLL
|
||||||
|
for (FfxInt32 x = -1; x < 2; x++) {
|
||||||
|
|
||||||
|
const FfxInt32x2 sampleCoord = ClampLoad(iPxLrPos, FfxInt32x2(x, y), FfxInt32x2(RenderSize()));
|
||||||
|
|
||||||
|
FfxInt32 sampleIdx = (y + 1) * 3 + x + 1;
|
||||||
|
|
||||||
|
FfxFloat32x3 fColorSample = LoadInputColor(sampleCoord).xyz;
|
||||||
|
FfxFloat32 fReactiveSample = LoadReactiveMask(sampleCoord);
|
||||||
|
FfxFloat32 fTransparencyAndCompositionSample = LoadTransparencyAndCompositionMask(sampleCoord);
|
||||||
|
|
||||||
|
fColorSamples[sampleIdx] = fColorSample;
|
||||||
|
fReactiveSamples[sampleIdx] = fReactiveSample;
|
||||||
|
fTransparencyAndCompositionSamples[sampleIdx] = fTransparencyAndCompositionSample;
|
||||||
|
|
||||||
|
fMasksSum += (fReactiveSample + fTransparencyAndCompositionSample);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (fMasksSum > 0)
|
||||||
|
{
|
||||||
|
for (FfxInt32 sampleIdx = 0; sampleIdx < 9; sampleIdx++)
|
||||||
|
{
|
||||||
|
FfxFloat32x3 fColorSample = fColorSamples[sampleIdx];
|
||||||
|
FfxFloat32 fReactiveSample = fReactiveSamples[sampleIdx];
|
||||||
|
FfxFloat32 fTransparencyAndCompositionSample = fTransparencyAndCompositionSamples[sampleIdx];
|
||||||
|
|
||||||
|
const FfxFloat32 fMaxLenSq = ffxMax(dot(fReferenceColor, fReferenceColor), dot(fColorSample, fColorSample));
|
||||||
|
const FfxFloat32 fSimilarity = dot(fReferenceColor, fColorSample) / fMaxLenSq;
|
||||||
|
|
||||||
|
// Increase power for non-similar samples
|
||||||
|
const FfxFloat32 fPowerBiasMax = 6.0f;
|
||||||
|
const FfxFloat32 fSimilarityPower = 1.0f + (fPowerBiasMax - fSimilarity * fPowerBiasMax);
|
||||||
|
const FfxFloat32 fWeightedReactiveSample = ffxPow(fReactiveSample, fSimilarityPower);
|
||||||
|
const FfxFloat32 fWeightedTransparencyAndCompositionSample = ffxPow(fTransparencyAndCompositionSample, fSimilarityPower);
|
||||||
|
|
||||||
|
fReactiveFactor = ffxMax(fReactiveFactor, FfxFloat32x2(fWeightedReactiveSample, fWeightedTransparencyAndCompositionSample));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
StoreDilatedReactiveMasks(iPxLrPos, fReactiveFactor);
|
||||||
|
}
|
||||||
|
|
||||||
|
FfxFloat32x3 ComputePreparedInputColor(FfxInt32x2 iPxLrPos)
|
||||||
|
{
|
||||||
|
//We assume linear data. if non-linear input (sRGB, ...),
|
||||||
|
//then we should convert to linear first and back to sRGB on output.
|
||||||
|
FfxFloat32x3 fRgb = ffxMax(FfxFloat32x3(0, 0, 0), LoadInputColor(iPxLrPos));
|
||||||
|
|
||||||
|
fRgb = PrepareRgb(fRgb, Exposure(), PreExposure());
|
||||||
|
|
||||||
|
const FfxFloat32x3 fPreparedYCoCg = RGBToYCoCg(fRgb);
|
||||||
|
|
||||||
|
return fPreparedYCoCg;
|
||||||
|
}
|
||||||
|
|
||||||
|
FfxFloat32 EvaluateSurface(FfxInt32x2 iPxPos, FfxFloat32x2 fMotionVector)
|
||||||
|
{
|
||||||
|
FfxFloat32 d0 = GetViewSpaceDepth(LoadReconstructedPrevDepth(iPxPos + FfxInt32x2(0, -1)));
|
||||||
|
FfxFloat32 d1 = GetViewSpaceDepth(LoadReconstructedPrevDepth(iPxPos + FfxInt32x2(0, 0)));
|
||||||
|
FfxFloat32 d2 = GetViewSpaceDepth(LoadReconstructedPrevDepth(iPxPos + FfxInt32x2(0, 1)));
|
||||||
|
|
||||||
|
return 1.0f - FfxFloat32(((d0 - d1) > (d1 * 0.01f)) && ((d1 - d2) > (d2 * 0.01f)));
|
||||||
|
}
|
||||||
|
|
||||||
|
void DepthClip(FfxInt32x2 iPxPos)
|
||||||
|
{
|
||||||
|
FfxFloat32x2 fDepthUv = (iPxPos + 0.5f) / RenderSize();
|
||||||
|
FfxFloat32x2 fMotionVector = LoadDilatedMotionVector(iPxPos);
|
||||||
|
|
||||||
|
// Discard tiny mvs
|
||||||
|
fMotionVector *= FfxFloat32(length(fMotionVector * DisplaySize()) > 0.01f);
|
||||||
|
|
||||||
|
const FfxFloat32x2 fDilatedUv = fDepthUv + fMotionVector;
|
||||||
|
const FfxFloat32 fDilatedDepth = LoadDilatedDepth(iPxPos);
|
||||||
|
const FfxFloat32 fCurrentDepthViewSpace = GetViewSpaceDepth(LoadInputDepth(iPxPos));
|
||||||
|
|
||||||
|
// Compute prepared input color and depth clip
|
||||||
|
FfxFloat32 fDepthClip = ComputeDepthClip(fDilatedUv, fDilatedDepth) * EvaluateSurface(iPxPos, fMotionVector);
|
||||||
|
FfxFloat32x3 fPreparedYCoCg = ComputePreparedInputColor(iPxPos);
|
||||||
|
StorePreparedInputColor(iPxPos, FfxFloat32x4(fPreparedYCoCg, fDepthClip));
|
||||||
|
|
||||||
|
// Compute dilated reactive mask
|
||||||
|
#if FFX_FSR3UPSCALER_OPTION_LOW_RESOLUTION_MOTION_VECTORS
|
||||||
|
FfxInt32x2 iSamplePos = iPxPos;
|
||||||
|
#else
|
||||||
|
FfxInt32x2 iSamplePos = ComputeHrPosFromLrPos(iPxPos);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
FfxFloat32 fMotionDivergence = ComputeMotionDivergence(iSamplePos, RenderSize());
|
||||||
|
FfxFloat32 fTemporalMotionDifference = ffxSaturate(ComputeTemporalMotionDivergence(iPxPos) - ComputeDepthDivergence(iPxPos));
|
||||||
|
|
||||||
|
PreProcessReactiveMasks(iPxPos, ffxMax(fTemporalMotionDifference, fMotionDivergence));
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif //!defined( FFX_FSR3UPSCALER_DEPTH_CLIPH )
|
||||||
@ -0,0 +1,27 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 7c662249d70c4434da4f2da00e432c38
|
||||||
|
PluginImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
iconMap: {}
|
||||||
|
executionOrder: {}
|
||||||
|
defineConstraints: []
|
||||||
|
isPreloaded: 0
|
||||||
|
isOverridable: 0
|
||||||
|
isExplicitlyReferenced: 0
|
||||||
|
validateReferences: 1
|
||||||
|
platformData:
|
||||||
|
- first:
|
||||||
|
Any:
|
||||||
|
second:
|
||||||
|
enabled: 1
|
||||||
|
settings: {}
|
||||||
|
- first:
|
||||||
|
Editor: Editor
|
||||||
|
second:
|
||||||
|
enabled: 0
|
||||||
|
settings:
|
||||||
|
DefaultValueInitialized: true
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
@ -0,0 +1,116 @@
|
|||||||
|
// This file is part of the FidelityFX SDK.
|
||||||
|
//
|
||||||
|
// Copyright (c) 2023 Advanced Micro Devices, Inc. All rights reserved.
|
||||||
|
//
|
||||||
|
// 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_FSR3UPSCALER_LOCK_H
|
||||||
|
#define FFX_FSR3UPSCALER_LOCK_H
|
||||||
|
|
||||||
|
void ClearResourcesForNextFrame(in FfxInt32x2 iPxHrPos)
|
||||||
|
{
|
||||||
|
if (all(FFX_LESS_THAN(iPxHrPos, FfxInt32x2(RenderSize()))))
|
||||||
|
{
|
||||||
|
#if FFX_FSR3UPSCALER_OPTION_INVERTED_DEPTH
|
||||||
|
const FfxUInt32 farZ = 0x0;
|
||||||
|
#else
|
||||||
|
const FfxUInt32 farZ = 0x3f800000;
|
||||||
|
#endif
|
||||||
|
SetReconstructedDepth(iPxHrPos, farZ);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
FfxBoolean ComputeThinFeatureConfidence(FfxInt32x2 pos)
|
||||||
|
{
|
||||||
|
const FfxInt32 RADIUS = 1;
|
||||||
|
|
||||||
|
FfxFloat32 fNucleus = LoadLockInputLuma(pos);
|
||||||
|
|
||||||
|
FfxFloat32 similar_threshold = 1.05f;
|
||||||
|
FfxFloat32 dissimilarLumaMin = FSR3UPSCALER_FLT_MAX;
|
||||||
|
FfxFloat32 dissimilarLumaMax = 0;
|
||||||
|
|
||||||
|
/*
|
||||||
|
0 1 2
|
||||||
|
3 4 5
|
||||||
|
6 7 8
|
||||||
|
*/
|
||||||
|
|
||||||
|
#define SETBIT(x) (1U << x)
|
||||||
|
|
||||||
|
FfxUInt32 mask = SETBIT(4); //flag fNucleus as similar
|
||||||
|
|
||||||
|
const FfxUInt32 uNumRejectionMasks = 4;
|
||||||
|
const FfxUInt32 uRejectionMasks[uNumRejectionMasks] = {
|
||||||
|
SETBIT(0) | SETBIT(1) | SETBIT(3) | SETBIT(4), //Upper left
|
||||||
|
SETBIT(1) | SETBIT(2) | SETBIT(4) | SETBIT(5), //Upper right
|
||||||
|
SETBIT(3) | SETBIT(4) | SETBIT(6) | SETBIT(7), //Lower left
|
||||||
|
SETBIT(4) | SETBIT(5) | SETBIT(7) | SETBIT(8), //Lower right
|
||||||
|
};
|
||||||
|
|
||||||
|
FfxInt32 idx = 0;
|
||||||
|
FFX_UNROLL
|
||||||
|
for (FfxInt32 y = -RADIUS; y <= RADIUS; y++) {
|
||||||
|
FFX_UNROLL
|
||||||
|
for (FfxInt32 x = -RADIUS; x <= RADIUS; x++, idx++) {
|
||||||
|
if (x == 0 && y == 0) continue;
|
||||||
|
|
||||||
|
FfxInt32x2 samplePos = ClampLoad(pos, FfxInt32x2(x, y), FfxInt32x2(RenderSize()));
|
||||||
|
|
||||||
|
FfxFloat32 sampleLuma = LoadLockInputLuma(samplePos);
|
||||||
|
FfxFloat32 difference = ffxMax(sampleLuma, fNucleus) / ffxMin(sampleLuma, fNucleus);
|
||||||
|
|
||||||
|
if (difference > 0 && (difference < similar_threshold)) {
|
||||||
|
mask |= SETBIT(idx);
|
||||||
|
} else {
|
||||||
|
dissimilarLumaMin = ffxMin(dissimilarLumaMin, sampleLuma);
|
||||||
|
dissimilarLumaMax = ffxMax(dissimilarLumaMax, sampleLuma);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
FfxBoolean isRidge = fNucleus > dissimilarLumaMax || fNucleus < dissimilarLumaMin;
|
||||||
|
|
||||||
|
if (FFX_FALSE == isRidge) {
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
FFX_UNROLL
|
||||||
|
for (FfxInt32 i = 0; i < 4; i++) {
|
||||||
|
|
||||||
|
if ((mask & uRejectionMasks[i]) == uRejectionMasks[i]) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
void ComputeLock(FfxInt32x2 iPxLrPos)
|
||||||
|
{
|
||||||
|
if (ComputeThinFeatureConfidence(iPxLrPos))
|
||||||
|
{
|
||||||
|
StoreNewLocks(ComputeHrPosFromLrPos(iPxLrPos), 1.f);
|
||||||
|
}
|
||||||
|
|
||||||
|
// ClearResourcesForNextFrame(iPxLrPos);
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif // FFX_FSR3UPSCALER_LOCK_H
|
||||||
@ -0,0 +1,27 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: c7e9f53dd040b2645af5ccd936a94b0e
|
||||||
|
PluginImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
iconMap: {}
|
||||||
|
executionOrder: {}
|
||||||
|
defineConstraints: []
|
||||||
|
isPreloaded: 0
|
||||||
|
isOverridable: 0
|
||||||
|
isExplicitlyReferenced: 0
|
||||||
|
validateReferences: 1
|
||||||
|
platformData:
|
||||||
|
- first:
|
||||||
|
Any:
|
||||||
|
second:
|
||||||
|
enabled: 1
|
||||||
|
settings: {}
|
||||||
|
- first:
|
||||||
|
Editor: Editor
|
||||||
|
second:
|
||||||
|
enabled: 0
|
||||||
|
settings:
|
||||||
|
DefaultValueInitialized: true
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user