sync
This commit is contained in:
parent
7a6c54e876
commit
20c56fed0a
@ -28,7 +28,7 @@ MonoBehaviour:
|
|||||||
m_SupportsHDR: 1
|
m_SupportsHDR: 1
|
||||||
m_HDRColorBufferPrecision: 0
|
m_HDRColorBufferPrecision: 0
|
||||||
m_MSAA: 1
|
m_MSAA: 1
|
||||||
m_RenderScale: 0.6667969
|
m_RenderScale: 1
|
||||||
m_UpscalingFilter: 1
|
m_UpscalingFilter: 1
|
||||||
m_FsrOverrideSharpness: 1
|
m_FsrOverrideSharpness: 1
|
||||||
m_FsrSharpness: 1
|
m_FsrSharpness: 1
|
||||||
@ -73,7 +73,7 @@ MonoBehaviour:
|
|||||||
m_UseAdaptivePerformance: 1
|
m_UseAdaptivePerformance: 1
|
||||||
m_ColorGradingMode: 0
|
m_ColorGradingMode: 0
|
||||||
m_ColorGradingLutSize: 32
|
m_ColorGradingLutSize: 32
|
||||||
m_UseFastSRGBLinearConversion: 1
|
m_UseFastSRGBLinearConversion: 0
|
||||||
m_SupportDataDrivenLensFlare: 0
|
m_SupportDataDrivenLensFlare: 0
|
||||||
m_ShadowType: 1
|
m_ShadowType: 1
|
||||||
m_LocalShadowsSupported: 0
|
m_LocalShadowsSupported: 0
|
||||||
@ -114,5 +114,5 @@ MonoBehaviour:
|
|||||||
m_PrefilterNativeRenderPass: 1
|
m_PrefilterNativeRenderPass: 1
|
||||||
m_ShaderVariantLogLevel: 0
|
m_ShaderVariantLogLevel: 0
|
||||||
m_ShadowCascades: 0
|
m_ShadowCascades: 0
|
||||||
superResolution: 16
|
superResolution: 3
|
||||||
vrsRate: 0
|
vrsRate: 0
|
||||||
|
|||||||
@ -125,6 +125,27 @@ MonoBehaviour:
|
|||||||
superResolution: 4
|
superResolution: 4
|
||||||
spatialUpScaleSettings:
|
spatialUpScaleSettings:
|
||||||
sharpness: 0.35
|
sharpness: 0.35
|
||||||
|
--- !u!114 &-4150689035588204578
|
||||||
|
MonoBehaviour:
|
||||||
|
m_ObjectHideFlags: 0
|
||||||
|
m_CorrespondingSourceObject: {fileID: 0}
|
||||||
|
m_PrefabInstance: {fileID: 0}
|
||||||
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
m_GameObject: {fileID: 0}
|
||||||
|
m_Enabled: 1
|
||||||
|
m_EditorHideFlags: 0
|
||||||
|
m_Script: {fileID: 11500000, guid: a0b8751ae563c82438124306d98fffd5, type: 3}
|
||||||
|
m_Name: HziCullingFeature
|
||||||
|
m_EditorClassIdentifier:
|
||||||
|
m_Active: 1
|
||||||
|
settings:
|
||||||
|
UseTowCullPass: 0
|
||||||
|
UseTextureAABB: 1
|
||||||
|
UseCompute: 0
|
||||||
|
CullMat: {fileID: 2100000, guid: ce13e27ede10980489261083a699b449, type: 2}
|
||||||
|
CullShader: {fileID: 7200000, guid: 029fde5b4200eeb4e919fe924f26fdd8, type: 3}
|
||||||
|
CullTextureSize: 64
|
||||||
|
UseThreeFrameReadback: 1
|
||||||
--- !u!114 &-2621301742936824463
|
--- !u!114 &-2621301742936824463
|
||||||
MonoBehaviour:
|
MonoBehaviour:
|
||||||
m_ObjectHideFlags: 0
|
m_ObjectHideFlags: 0
|
||||||
@ -203,9 +224,10 @@ MonoBehaviour:
|
|||||||
settings:
|
settings:
|
||||||
PyramidFunc: 0
|
PyramidFunc: 0
|
||||||
SkipThreeMip: 0
|
SkipThreeMip: 0
|
||||||
ComputeShader: {fileID: 0}
|
UseThreeFrameReadback: 0
|
||||||
Spd: {fileID: 0}
|
ComputeShader: {fileID: 7200000, guid: b10c09f63c5a5864ca12e07b1b361d56, type: 3}
|
||||||
CopyDepth: {fileID: 0}
|
Spd: {fileID: 7200000, guid: 2c0519b45f80f5c47b4ee3edb2e7931b, type: 3}
|
||||||
|
CopyDepth: {fileID: 2100000, guid: 5f8ec7ea87b60a1448091fade6a0e68f, type: 2}
|
||||||
--- !u!114 &-1133205096357012623
|
--- !u!114 &-1133205096357012623
|
||||||
MonoBehaviour:
|
MonoBehaviour:
|
||||||
m_ObjectHideFlags: 0
|
m_ObjectHideFlags: 0
|
||||||
@ -271,7 +293,8 @@ MonoBehaviour:
|
|||||||
- {fileID: 4071882023117421450}
|
- {fileID: 4071882023117421450}
|
||||||
- {fileID: -7284859345190182597}
|
- {fileID: -7284859345190182597}
|
||||||
- {fileID: -1629415145513658388}
|
- {fileID: -1629415145513658388}
|
||||||
m_RendererFeatureMap: bc3f630842f2e70dd6a559c442a94bfd4529d15534f2d3de228858dca8d12222716523fbf3439fdb7a327b7bff4bdd446ac59dfa966ffa88ca6373cd5da9013d6cff55ca297e5e908a7b3653203b82383b2141bb05fbe69aec5704e48e2763e9
|
- {fileID: -4150689035588204578}
|
||||||
|
m_RendererFeatureMap: bc3f630842f2e70dd6a559c442a94bfd4529d15534f2d3de228858dca8d12222716523fbf3439fdb7a327b7bff4bdd446ac59dfa966ffa88ca6373cd5da9013d6cff55ca297e5e908a7b3653203b82383b2141bb05fbe69aec5704e48e2763e9de07a83c50ca65c6
|
||||||
m_UseNativeRenderPass: 0
|
m_UseNativeRenderPass: 0
|
||||||
postProcessData: {fileID: 11400000, guid: 41439944d30ece34e96484bdb6645b55, type: 2}
|
postProcessData: {fileID: 11400000, guid: 41439944d30ece34e96484bdb6645b55, type: 2}
|
||||||
shaders:
|
shaders:
|
||||||
@ -421,7 +444,7 @@ MonoBehaviour:
|
|||||||
m_Name: XESS2
|
m_Name: XESS2
|
||||||
m_EditorClassIdentifier:
|
m_EditorClassIdentifier:
|
||||||
m_Active: 0
|
m_Active: 0
|
||||||
Quality: 104
|
Quality: 106
|
||||||
--- !u!114 &4395980931634258890
|
--- !u!114 &4395980931634258890
|
||||||
MonoBehaviour:
|
MonoBehaviour:
|
||||||
m_ObjectHideFlags: 0
|
m_ObjectHideFlags: 0
|
||||||
|
|||||||
17
Packages/com.unity.render-pipelines.universal@14.0.11/Runtime/OcclusionCulling/CullDebug.cs
vendored
Normal file
17
Packages/com.unity.render-pipelines.universal@14.0.11/Runtime/OcclusionCulling/CullDebug.cs
vendored
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
using UnityEngine;
|
||||||
|
|
||||||
|
public class CullDebug : MonoBehaviour
|
||||||
|
{
|
||||||
|
public int Index;
|
||||||
|
public Vector3 Position;
|
||||||
|
public Vector3 Size;
|
||||||
|
public bool IsCulled = false;
|
||||||
|
|
||||||
|
private void OnDrawGizmos()
|
||||||
|
{
|
||||||
|
var col = Gizmos.color;
|
||||||
|
Gizmos.color = Color.green;
|
||||||
|
Gizmos.DrawWireCube(Position, Size);
|
||||||
|
Gizmos.color = col;
|
||||||
|
}
|
||||||
|
}
|
||||||
11
Packages/com.unity.render-pipelines.universal@14.0.11/Runtime/OcclusionCulling/CullDebug.cs.meta
vendored
Normal file
11
Packages/com.unity.render-pipelines.universal@14.0.11/Runtime/OcclusionCulling/CullDebug.cs.meta
vendored
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: dab00d3922eb1ec4494d2db2fbb0c6c4
|
||||||
|
MonoImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
@ -1,7 +1,6 @@
|
|||||||
using Codice.Client.GameUI.Update;
|
|
||||||
using System;
|
using System;
|
||||||
using Unity.Burst.CompilerServices;
|
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
|
using UnityEngine.Experimental.Rendering;
|
||||||
using UnityEngine.Rendering;
|
using UnityEngine.Rendering;
|
||||||
using UnityEngine.Rendering.Universal;
|
using UnityEngine.Rendering.Universal;
|
||||||
|
|
||||||
@ -21,6 +20,7 @@ namespace X.Rendering.Feature
|
|||||||
{
|
{
|
||||||
public EDepthPyramidFunc PyramidFunc = EDepthPyramidFunc.CopyDepth;
|
public EDepthPyramidFunc PyramidFunc = EDepthPyramidFunc.CopyDepth;
|
||||||
public bool SkipThreeMip;
|
public bool SkipThreeMip;
|
||||||
|
// 留历史 depth,做 tow pass cull
|
||||||
public bool UseThreeFrameReadback;
|
public bool UseThreeFrameReadback;
|
||||||
public ComputeShader ComputeShader;
|
public ComputeShader ComputeShader;
|
||||||
public ComputeShader Spd;
|
public ComputeShader Spd;
|
||||||
@ -56,11 +56,6 @@ namespace X.Rendering.Feature
|
|||||||
|
|
||||||
internal class HizPass : ScriptableRenderPass, IDisposable
|
internal class HizPass : ScriptableRenderPass, IDisposable
|
||||||
{
|
{
|
||||||
private static readonly int depthTextureId = Shader.PropertyToID("_CameraDepthTexture");
|
|
||||||
private static readonly int depthInputId = Shader.PropertyToID("_InputDepth");
|
|
||||||
private static readonly int depthPyramidTexId = Shader.PropertyToID("_DepthPyramidTexture");
|
|
||||||
private static readonly int inputScaleAndMaxIndexId = Shader.PropertyToID("_InputScaleAndMaxIndex");
|
|
||||||
|
|
||||||
private readonly Settings settings;
|
private readonly Settings settings;
|
||||||
private ProfilingSampler profiler;
|
private ProfilingSampler profiler;
|
||||||
|
|
||||||
@ -71,18 +66,22 @@ namespace X.Rendering.Feature
|
|||||||
private int mipLevelCount;
|
private int mipLevelCount;
|
||||||
private Vector2Int[] mipLevelOffsets;
|
private Vector2Int[] mipLevelOffsets;
|
||||||
private Vector2Int[] mipLevelSizes;
|
private Vector2Int[] mipLevelSizes;
|
||||||
private Vector4[] mipOffsetAndSizes = new Vector4[32];
|
private Vector4[] mipOffsetAndSizes = new Vector4[16];
|
||||||
|
|
||||||
private RTHandle[] depthPyramidTexs = new RTHandle[3];
|
private RTHandle[] depthPyramidTexs = new RTHandle[3];
|
||||||
private static string[] depthPyramidNames = new string[3] { "_DepthPyramidTextureA", "_DepthPyramidTextureB", "_DepthPyramidTextureC" };
|
private static string[] depthPyramidNames = new string[3] { "_DepthPyramidTextureA", "_DepthPyramidTextureB", "_DepthPyramidTextureC" };
|
||||||
|
|
||||||
|
RenderTexture SpdAtomicCounter;
|
||||||
|
|
||||||
public HizPass(Settings settings)
|
public HizPass(Settings settings)
|
||||||
{
|
{
|
||||||
renderPassEvent = RenderPassEvent.BeforeRenderingPostProcessing;
|
renderPassEvent = RenderPassEvent.BeforeRenderingPostProcessing;
|
||||||
profiler = new("DepthPyramid");
|
profiler = new("DepthPyramid");
|
||||||
this.settings = settings;
|
this.settings = settings;
|
||||||
mipLevelOffsets = new Vector2Int[32];
|
mipLevelOffsets = new Vector2Int[16];
|
||||||
mipLevelSizes = new Vector2Int[32];
|
mipLevelSizes = new Vector2Int[16];
|
||||||
|
SpdAtomicCounter = new RenderTexture(1, 1, 0, GraphicsFormat.R32_UInt) { name = "FSR2_SpdAtomicCounter", enableRandomWrite = true };
|
||||||
|
SpdAtomicCounter.Create();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static int HizIndex { get; private set; }
|
public static int HizIndex { get; private set; }
|
||||||
@ -112,8 +111,9 @@ namespace X.Rendering.Feature
|
|||||||
cachedSkipThreeMip = settings.SkipThreeMip;
|
cachedSkipThreeMip = settings.SkipThreeMip;
|
||||||
|
|
||||||
mip0SizeNOP = viewportSize;
|
mip0SizeNOP = viewportSize;
|
||||||
int resizeX = Mathf.IsPowerOfTwo(viewportSize.x) ? viewportSize.x : Mathf.NextPowerOfTwo(viewportSize.x);
|
// PowerOfTwo 不会留缝隙
|
||||||
int resizeY = Mathf.IsPowerOfTwo(viewportSize.y) ? viewportSize.y : Mathf.NextPowerOfTwo(viewportSize.y);
|
int resizeX = settings.PyramidFunc == EDepthPyramidFunc.SPD || Mathf.IsPowerOfTwo(viewportSize.x) ? viewportSize.x : Mathf.NextPowerOfTwo(viewportSize.x);
|
||||||
|
int resizeY = settings.PyramidFunc == EDepthPyramidFunc.SPD || Mathf.IsPowerOfTwo(viewportSize.y) ? viewportSize.y : Mathf.NextPowerOfTwo(viewportSize.y);
|
||||||
Vector2Int hardwareTextureSize = new Vector2Int(resizeX, resizeY);
|
Vector2Int hardwareTextureSize = new Vector2Int(resizeX, resizeY);
|
||||||
mipLevelOffsets[0] = Vector2Int.zero;
|
mipLevelOffsets[0] = Vector2Int.zero;
|
||||||
mipLevelSizes[0] = Vector2Int.zero;
|
mipLevelSizes[0] = Vector2Int.zero;
|
||||||
@ -179,17 +179,27 @@ namespace X.Rendering.Feature
|
|||||||
var sampleName = "DepthDownSample";
|
var sampleName = "DepthDownSample";
|
||||||
cmd.BeginSample(sampleName);
|
cmd.BeginSample(sampleName);
|
||||||
cmd.SetViewProjectionMatrices(Matrix4x4.identity, Matrix4x4.identity);
|
cmd.SetViewProjectionMatrices(Matrix4x4.identity, Matrix4x4.identity);
|
||||||
cmd.SetGlobalTexture(depthInputId, depthTex);
|
cmd.SetGlobalTexture(HizShaderIds.DepthInputId, depthTex);
|
||||||
for (int i = 1; i < mipLevelCount; i++)
|
for (int i = 1; i < mipLevelCount; i++)
|
||||||
{
|
{
|
||||||
|
var index = i;
|
||||||
|
if (settings.SkipThreeMip && i < 3 + 1)
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
else if (settings.SkipThreeMip && i == 3 + 1)
|
||||||
|
{
|
||||||
|
index = 1;
|
||||||
|
}
|
||||||
|
|
||||||
var mipSize = mipLevelSizes[i];
|
var mipSize = mipLevelSizes[i];
|
||||||
var inputMipSize = i == 1 ? mip0SizeNOP : mipLevelSizes[i - 1];
|
var inputMipSize = index == 1 ? mip0SizeNOP : mipLevelSizes[i - 1];
|
||||||
var texId = depthMipId[i];
|
var texId = depthMipId[i];
|
||||||
cmd.SetGlobalVector(inputScaleAndMaxIndexId, new Vector4(inputMipSize.x / (float)mipSize.x, inputMipSize.y / (float)mipSize.y, inputMipSize.x - 1, inputMipSize.y - 1));
|
cmd.SetGlobalVector(HizShaderIds.InputScaleAndMaxIndexId, new Vector4(inputMipSize.x / (float)mipSize.x, inputMipSize.y / (float)mipSize.y, inputMipSize.x - 1, inputMipSize.y - 1));
|
||||||
cmd.GetTemporaryRT(texId, mipSize.x, mipSize.y, 0, FilterMode.Point, RenderTextureFormat.RFloat);
|
cmd.GetTemporaryRT(texId, mipSize.x, mipSize.y, 0, FilterMode.Point, RenderTextureFormat.RFloat);
|
||||||
cmd.SetRenderTarget(texId, RenderBufferLoadAction.DontCare, RenderBufferStoreAction.Store);
|
cmd.SetRenderTarget(texId, RenderBufferLoadAction.DontCare, RenderBufferStoreAction.Store);
|
||||||
cmd.DrawMesh(RenderingUtils.fullscreenMesh, Matrix4x4.identity, settings.CopyDepth, 0, 0);
|
cmd.DrawMesh(RenderingUtils.fullscreenMesh, Matrix4x4.identity, settings.CopyDepth, 0, 0);
|
||||||
cmd.SetGlobalTexture(depthInputId, texId);
|
cmd.SetGlobalTexture(HizShaderIds.DepthInputId, texId);
|
||||||
}
|
}
|
||||||
|
|
||||||
cmd.EndSample(sampleName);
|
cmd.EndSample(sampleName);
|
||||||
@ -212,8 +222,13 @@ namespace X.Rendering.Feature
|
|||||||
cmd.SetRenderTarget(hizRt, RenderBufferLoadAction.DontCare, RenderBufferStoreAction.Store);
|
cmd.SetRenderTarget(hizRt, RenderBufferLoadAction.DontCare, RenderBufferStoreAction.Store);
|
||||||
for (int i = 1; i < mipLevelCount; i++)
|
for (int i = 1; i < mipLevelCount; i++)
|
||||||
{
|
{
|
||||||
|
if (settings.SkipThreeMip && i < 3 + 1)
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
var texId = depthMipId[i];
|
var texId = depthMipId[i];
|
||||||
cmd.SetGlobalTexture(depthInputId, texId);
|
cmd.SetGlobalTexture(HizShaderIds.DepthInputId, texId);
|
||||||
var mipSize = mipLevelSizes[i];
|
var mipSize = mipLevelSizes[i];
|
||||||
var mipOffset = mipLevelOffsets[i];
|
var mipOffset = mipLevelOffsets[i];
|
||||||
mipOffsetAndSizes[i] = new (mipOffset.x, mipOffset.y, mipSize.x, mipSize.y);
|
mipOffsetAndSizes[i] = new (mipOffset.x, mipOffset.y, mipSize.x, mipSize.y);
|
||||||
@ -221,7 +236,7 @@ namespace X.Rendering.Feature
|
|||||||
cmd.DrawMesh(RenderingUtils.fullscreenMesh, Matrix4x4.identity, settings.CopyDepth, 0, 1);
|
cmd.DrawMesh(RenderingUtils.fullscreenMesh, Matrix4x4.identity, settings.CopyDepth, 0, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
cmd.SetGlobalTexture(depthPyramidTexId, hizRt);
|
cmd.SetGlobalTexture(HizShaderIds.DepthPyramidTexId, hizRt);
|
||||||
cmd.EndSample(sampleName);
|
cmd.EndSample(sampleName);
|
||||||
|
|
||||||
for (int i = 0; i < depthMipId.Length; i++)
|
for (int i = 0; i < depthMipId.Length; i++)
|
||||||
@ -273,7 +288,7 @@ namespace X.Rendering.Feature
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
cmd.SetComputeTextureParam(settings.ComputeShader, kernelId, depthInputId, i == 0 ? depthTex : hizBuffer);
|
cmd.SetComputeTextureParam(settings.ComputeShader, kernelId, HizShaderIds.DepthInputId, i == 0 ? depthTex : hizBuffer);
|
||||||
cmd.SetComputeTextureParam(settings.ComputeShader, kernelId, "_DepthMipChain", hizBuffer);
|
cmd.SetComputeTextureParam(settings.ComputeShader, kernelId, "_DepthMipChain", hizBuffer);
|
||||||
|
|
||||||
int inputMipIndex = startMip;
|
int inputMipIndex = startMip;
|
||||||
@ -303,19 +318,51 @@ namespace X.Rendering.Feature
|
|||||||
cmd.DispatchCompute(settings.ComputeShader, kernelId, Mathf.CeilToInt(outputMipSize.x / 8f), Mathf.CeilToInt(outputMipSize.y / 8f), 1);
|
cmd.DispatchCompute(settings.ComputeShader, kernelId, Mathf.CeilToInt(outputMipSize.x / 8f), Mathf.CeilToInt(outputMipSize.y / 8f), 1);
|
||||||
mipCnt = mipCnt - 4;
|
mipCnt = mipCnt - 4;
|
||||||
}
|
}
|
||||||
cmd.SetGlobalTexture(depthPyramidTexId, hizBuffer);
|
cmd.SetGlobalTexture(HizShaderIds.DepthPyramidTexId, hizBuffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void DoSpdDepth(CommandBuffer cmd, Texture depthTex)
|
private void DoSpdDepth(CommandBuffer cmd, Texture depthTex)
|
||||||
{
|
{
|
||||||
|
var hizIndex = GetHizIndex();
|
||||||
|
RTHandle hizBuffer = depthPyramidTexs[hizIndex];
|
||||||
|
|
||||||
|
RenderingUtils.ReAllocateIfNeeded(ref hizBuffer, new RenderTextureDescriptor()
|
||||||
|
{
|
||||||
|
width = depthPyramidTextureSize.x,
|
||||||
|
height = depthPyramidTextureSize.y,
|
||||||
|
dimension = TextureDimension.Tex2D,
|
||||||
|
colorFormat = RenderTextureFormat.RFloat,
|
||||||
|
msaaSamples = 1,
|
||||||
|
enableRandomWrite = true,
|
||||||
|
}, filterMode: FilterMode.Point, name: depthPyramidNames[hizIndex]);
|
||||||
|
depthPyramidTexs[hizIndex] = hizBuffer;
|
||||||
|
|
||||||
|
var dispatchX = Mathf.CeilToInt(mip0SizeNOP.x / 64f);
|
||||||
|
var dispatchY = Mathf.CeilToInt(mip0SizeNOP.y / 64f);
|
||||||
|
cmd.SetComputeIntParam(settings.Spd, "mips", mipLevelCount);
|
||||||
|
cmd.SetComputeIntParam(settings.Spd, "numWorkGroups", dispatchX);
|
||||||
|
|
||||||
|
for (int i = 0; i < mipLevelCount; i++)
|
||||||
|
{
|
||||||
|
var mipSize = mipLevelSizes[i];
|
||||||
|
var mipOffset = mipLevelOffsets[i];
|
||||||
|
mipOffsetAndSizes[i] = new(mipOffset.x, mipOffset.y, mipSize.x, mipSize.y);
|
||||||
|
}
|
||||||
|
cmd.SetComputeVectorArrayParam(settings.Spd, "_MipOffsetAndSizeArray", mipOffsetAndSizes);
|
||||||
|
|
||||||
|
cmd.SetComputeTextureParam(settings.Spd, 0, "_InputDepth", depthTex);
|
||||||
|
cmd.SetComputeTextureParam(settings.Spd, 0, "_OutDepth", hizBuffer);
|
||||||
|
cmd.SetComputeTextureParam(settings.Spd, 0, "rw_internal_global_atomic", SpdAtomicCounter);
|
||||||
|
|
||||||
|
cmd.DispatchCompute(settings.Spd, 0, dispatchX, dispatchY, 1);
|
||||||
|
cmd.SetGlobalTexture(HizShaderIds.DepthPyramidTexId, hizBuffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void Execute(ScriptableRenderContext context, ref RenderingData renderingData)
|
public override void Execute(ScriptableRenderContext context, ref RenderingData renderingData)
|
||||||
{
|
{
|
||||||
var cmd = renderingData.commandBuffer;
|
var cmd = renderingData.commandBuffer;
|
||||||
using var soc = new ProfilingScope(cmd, profiler);
|
using var soc = new ProfilingScope(cmd, profiler);
|
||||||
Texture depthTex = Shader.GetGlobalTexture(depthTextureId);
|
Texture depthTex = Shader.GetGlobalTexture(HizShaderIds.CameraDepthTextureId);
|
||||||
if(depthTex == null)
|
if(depthTex == null)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
@ -337,10 +384,20 @@ namespace X.Rendering.Feature
|
|||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
cmd.SetGlobalVector(HizShaderIds.Mip0SizeId, new Vector4(mip0SizeNOP.x, mip0SizeNOP.y, 0, 0));
|
||||||
|
cmd.SetGlobalVector(HizShaderIds.MipmapLevelMinMaxIndexId, new Vector4(1, mipLevelCount, 0, 0));
|
||||||
|
cmd.SetGlobalVectorArray(HizShaderIds.MipOffsetAndSizeArrayId, mipOffsetAndSizes);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Dispose()
|
public void Dispose()
|
||||||
{
|
{
|
||||||
|
if (SpdAtomicCounter != null)
|
||||||
|
{
|
||||||
|
SpdAtomicCounter.Release();
|
||||||
|
SpdAtomicCounter = null;
|
||||||
|
}
|
||||||
|
|
||||||
for (int i = 0; i < depthPyramidTexs.Length; i++)
|
for (int i = 0; i < depthPyramidTexs.Length; i++)
|
||||||
{
|
{
|
||||||
var rt = depthPyramidTexs[i];
|
var rt = depthPyramidTexs[i];
|
||||||
|
|||||||
21
Packages/com.unity.render-pipelines.universal@14.0.11/Runtime/OcclusionCulling/HizShaderIds.cs
vendored
Normal file
21
Packages/com.unity.render-pipelines.universal@14.0.11/Runtime/OcclusionCulling/HizShaderIds.cs
vendored
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
using UnityEngine;
|
||||||
|
|
||||||
|
namespace X.Rendering.Feature
|
||||||
|
{
|
||||||
|
internal static class HizShaderIds
|
||||||
|
{
|
||||||
|
internal static readonly int CameraDepthTextureId = Shader.PropertyToID("_CameraDepthTexture");
|
||||||
|
internal static readonly int DepthInputId = Shader.PropertyToID("_InputDepth");
|
||||||
|
internal static readonly int DepthPyramidTexId = Shader.PropertyToID("_DepthPyramidTexture");
|
||||||
|
internal static readonly int InputScaleAndMaxIndexId = Shader.PropertyToID("_InputScaleAndMaxIndex");
|
||||||
|
|
||||||
|
internal static readonly int ObjectAABBCenterId = Shader.PropertyToID("_ObjectAABBTexture0");
|
||||||
|
internal static readonly int ObjectAABBSizeId = Shader.PropertyToID("_ObjectAABBTexture1");
|
||||||
|
internal static readonly int GPUCullingVPId = Shader.PropertyToID("_GPUCullingVP");
|
||||||
|
internal static readonly int MipmapLevelMinMaxIndexId = Shader.PropertyToID("_MipmapLevelMinMaxIndex");
|
||||||
|
internal static readonly int Mip0SizeId = Shader.PropertyToID("_Mip0Size");
|
||||||
|
internal static readonly int MipOffsetAndSizeArrayId = Shader.PropertyToID("_MipOffsetAndSize");
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,11 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: f821bd9bdc49933439e3e92efe04bee3
|
||||||
|
MonoImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
@ -1,10 +1,146 @@
|
|||||||
using System;
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using Unity.Collections;
|
||||||
|
using Unity.Mathematics;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
|
using UnityEngine.Experimental.Rendering;
|
||||||
using UnityEngine.Rendering;
|
using UnityEngine.Rendering;
|
||||||
using UnityEngine.Rendering.Universal;
|
using UnityEngine.Rendering.Universal;
|
||||||
|
using static X.Rendering.Feature.HziCullingFeature;
|
||||||
|
|
||||||
namespace X.Rendering.Feature
|
namespace X.Rendering.Feature
|
||||||
{
|
{
|
||||||
|
public class SceneRenderObjects
|
||||||
|
{
|
||||||
|
private static SceneRenderObjects intstance;
|
||||||
|
public static SceneRenderObjects Instance => intstance;
|
||||||
|
|
||||||
|
private float4[] centers;
|
||||||
|
private float4[] sizes;
|
||||||
|
|
||||||
|
private float3x2[] aabbs;
|
||||||
|
|
||||||
|
List<Renderer> renderers = new();
|
||||||
|
|
||||||
|
static SceneRenderObjects()
|
||||||
|
{
|
||||||
|
intstance = new SceneRenderObjects();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Register(Renderer renderer)
|
||||||
|
{
|
||||||
|
if(!renderers.Contains(renderer))
|
||||||
|
{
|
||||||
|
renderers.Add(renderer);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void UnRegister(Renderer renderer)
|
||||||
|
{
|
||||||
|
renderers.Remove(renderer);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void UpdateAABB(ComputeBuffer aabbBuffer)
|
||||||
|
{
|
||||||
|
if(aabbBuffer == null || aabbs.Length != renderers.Count)
|
||||||
|
{
|
||||||
|
aabbs = new float3x2[renderers.Count];
|
||||||
|
}
|
||||||
|
for (int i = 0; i < renderers.Count; i++)
|
||||||
|
{
|
||||||
|
var rdr = renderers[i];
|
||||||
|
if (rdr != null)
|
||||||
|
{
|
||||||
|
Bounds bounds = rdr.bounds;
|
||||||
|
aabbs[i] = new float3x2(bounds.center,bounds.size);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
aabbs[i] = float3x2.zero;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
aabbBuffer.SetData(aabbs);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void UpdateAABB(Texture2D centerTex, Texture2D sizeTex)
|
||||||
|
{
|
||||||
|
if (centers == null || centers.Length != centerTex.width * centerTex.height)
|
||||||
|
{
|
||||||
|
centers = new float4[centerTex.width * centerTex.height];
|
||||||
|
sizes = new float4[centerTex.width * centerTex.height];
|
||||||
|
}
|
||||||
|
|
||||||
|
if (renderers.Count == 0)
|
||||||
|
{
|
||||||
|
foreach (var item in GameObject.FindObjectsOfType<MeshRenderer>())
|
||||||
|
{
|
||||||
|
Register(item);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
int nullCnt = 0;
|
||||||
|
for (int i = 0; i < renderers.Count; i++)
|
||||||
|
{
|
||||||
|
var rdr = renderers[i];
|
||||||
|
if (rdr != null)
|
||||||
|
{
|
||||||
|
Bounds bounds = rdr.bounds;
|
||||||
|
centers[i] = new float4(bounds.center, 1);
|
||||||
|
sizes[i] = new float4(bounds.size, 1);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
nullCnt++;
|
||||||
|
centers[i] = float4.zero;
|
||||||
|
sizes[i] = float4.zero;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (nullCnt == renderers.Count)
|
||||||
|
{
|
||||||
|
renderers.Clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
centerTex.SetPixelData(centers, 0);
|
||||||
|
centerTex.Apply();
|
||||||
|
sizeTex.SetPixelData(sizes, 0);
|
||||||
|
sizeTex.Apply();
|
||||||
|
}
|
||||||
|
|
||||||
|
internal void ApplyCull(CullResult cullResult)
|
||||||
|
{
|
||||||
|
if (cullResult.ReadDone)
|
||||||
|
{
|
||||||
|
for (var i = 0; i < renderers.Count; i++)
|
||||||
|
{
|
||||||
|
var rdr = renderers[i];
|
||||||
|
if (rdr)
|
||||||
|
{
|
||||||
|
#if UNITY_EDITOR
|
||||||
|
if(rdr.GetComponent<CullDebug>() is CullDebug cullDebug && cullDebug)
|
||||||
|
{
|
||||||
|
cullDebug.Index = i;
|
||||||
|
cullDebug.IsCulled = cullResult.ResultArray[i] > 0;
|
||||||
|
cullDebug.Position = centers[i].xyz;
|
||||||
|
cullDebug.Size = sizes[i].xyz;
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
//if (cullResult.ResultArray[i] > 0)
|
||||||
|
//{
|
||||||
|
// rdr.renderingLayerMask = 0;
|
||||||
|
//}
|
||||||
|
//else
|
||||||
|
{
|
||||||
|
rdr.renderingLayerMask = 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public class HziCullingFeature : ScriptableRendererFeature
|
public class HziCullingFeature : ScriptableRendererFeature
|
||||||
{
|
{
|
||||||
[Serializable]
|
[Serializable]
|
||||||
@ -13,6 +149,13 @@ namespace X.Rendering.Feature
|
|||||||
//TODO: 通过使用上一帧的摄像机位置(包括矩阵)和上一帧的深度图做剔除,储存已经被剔除的物体和未被剔除的物体,然后绘制未被剔除的物体到GBuffer(包含深度图),
|
//TODO: 通过使用上一帧的摄像机位置(包括矩阵)和上一帧的深度图做剔除,储存已经被剔除的物体和未被剔除的物体,然后绘制未被剔除的物体到GBuffer(包含深度图),
|
||||||
//再二次生成HiZ DepthTexture,并对已经被剔除的物体使用一遍新的深度和当前摄像机的位置做一次剔除判断
|
//再二次生成HiZ DepthTexture,并对已经被剔除的物体使用一遍新的深度和当前摄像机的位置做一次剔除判断
|
||||||
public bool UseTowCullPass;
|
public bool UseTowCullPass;
|
||||||
|
public bool UseTextureAABB = true;
|
||||||
|
public bool UseCompute;
|
||||||
|
public Material CullMat;
|
||||||
|
public ComputeShader CullShader;
|
||||||
|
[Range(32, 128)]
|
||||||
|
public int CullTextureSize = 64;
|
||||||
|
public bool UseThreeFrameReadback = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
[SerializeField]
|
[SerializeField]
|
||||||
@ -32,23 +175,160 @@ namespace X.Rendering.Feature
|
|||||||
cullPass = new(settings);
|
cullPass = new(settings);
|
||||||
}
|
}
|
||||||
|
|
||||||
internal class CullPass : ScriptableRenderPass
|
protected override void Dispose(bool disposing)
|
||||||
|
{
|
||||||
|
base.Dispose(disposing);
|
||||||
|
cullPass.Dispose();
|
||||||
|
}
|
||||||
|
|
||||||
|
internal class CullResult : IDisposable
|
||||||
|
{
|
||||||
|
public RenderTexture ResultTex;
|
||||||
|
public NativeArray<half> ResultArray;
|
||||||
|
public bool ReadDone = false;
|
||||||
|
public Action<AsyncGPUReadbackRequest> ReadBackAction;
|
||||||
|
|
||||||
|
private void ReadBack(AsyncGPUReadbackRequest readback)
|
||||||
|
{
|
||||||
|
if (readback.done && !readback.hasError)
|
||||||
|
{
|
||||||
|
var data = readback.GetData<half>();
|
||||||
|
if (ResultArray.IsCreated)
|
||||||
|
{
|
||||||
|
ResultArray.CopyFrom(data);
|
||||||
|
}
|
||||||
|
ReadDone = true;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
ReadDone = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public CullResult CreateResources(int texSize)
|
||||||
|
{
|
||||||
|
ResultArray.Dispose();
|
||||||
|
ResultArray = new NativeArray<half>(texSize * texSize, Allocator.Persistent);
|
||||||
|
if(ResultTex != null)
|
||||||
|
{
|
||||||
|
ResultTex.Release();
|
||||||
|
}
|
||||||
|
|
||||||
|
ResultTex = new(texSize, texSize, 0, GraphicsFormat.R16_SFloat);
|
||||||
|
ResultTex.filterMode = FilterMode.Point;
|
||||||
|
ReadBackAction = ReadBack;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Dispose()
|
||||||
|
{
|
||||||
|
if (ResultTex != null)
|
||||||
|
{
|
||||||
|
ResultTex.Release();
|
||||||
|
}
|
||||||
|
ResultTex = null;
|
||||||
|
ResultArray.Dispose();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
internal class CullPass : ScriptableRenderPass, IDisposable
|
||||||
{
|
{
|
||||||
private Settings settings;
|
private Settings settings;
|
||||||
private ProfilingSampler profiler;
|
private ProfilingSampler profiler;
|
||||||
|
Texture2D centerTex;
|
||||||
|
Texture2D sizeTex;
|
||||||
|
CullResult[] cullResults;
|
||||||
public CullPass(Settings settings)
|
public CullPass(Settings settings)
|
||||||
{
|
{
|
||||||
profiler = new("Hi-Z Culling");
|
profiler = new("Hi-Z Culling");
|
||||||
this.settings = settings;
|
this.settings = settings;
|
||||||
|
int texSize = settings.CullTextureSize;
|
||||||
|
centerTex = new Texture2D(texSize, texSize, GraphicsFormat.R32G32B32A32_SFloat, TextureCreationFlags.None);
|
||||||
|
centerTex.filterMode = FilterMode.Point;
|
||||||
|
sizeTex = new Texture2D(texSize, texSize, GraphicsFormat.R32G32B32A32_SFloat, TextureCreationFlags.None);
|
||||||
|
sizeTex.filterMode = FilterMode.Point;
|
||||||
|
cullResults = new CullResult[3]
|
||||||
|
{
|
||||||
|
new CullResult().CreateResources(texSize),
|
||||||
|
new CullResult().CreateResources(texSize),
|
||||||
|
new CullResult().CreateResources(texSize),
|
||||||
|
};
|
||||||
|
|
||||||
|
renderPassEvent = RenderPassEvent.AfterRendering;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Dispose()
|
||||||
|
{
|
||||||
|
Texture.DestroyImmediate(centerTex);
|
||||||
|
Texture.DestroyImmediate(sizeTex);
|
||||||
|
for (int i = 0; i < cullResults.Length; i++)
|
||||||
|
{
|
||||||
|
cullResults[i]?.Dispose();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private int GetHizIndex()
|
||||||
|
{
|
||||||
|
if (settings.UseThreeFrameReadback)
|
||||||
|
{
|
||||||
|
return Time.frameCount % 3;
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
private int GetLastCullIndex(int hizIndex)
|
||||||
|
{
|
||||||
|
switch (hizIndex)
|
||||||
|
{
|
||||||
|
case 0:
|
||||||
|
return 1;
|
||||||
|
case 1:
|
||||||
|
return 2;
|
||||||
|
case 2:
|
||||||
|
return 0;
|
||||||
|
default:
|
||||||
|
throw new ArgumentException("参数错误 hizIndex:" + hizIndex);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void Execute(ScriptableRenderContext context, ref RenderingData renderingData)
|
public override void Execute(ScriptableRenderContext context, ref RenderingData renderingData)
|
||||||
{
|
{
|
||||||
var cmd = renderingData.commandBuffer;
|
var cmd = CommandBufferPool.Get("HizBuf");
|
||||||
using var soc = new ProfilingScope(cmd, profiler);
|
using var soc = new ProfilingScope(cmd, profiler);
|
||||||
|
cmd.Clear();
|
||||||
|
if (settings.UseTextureAABB)
|
||||||
|
{
|
||||||
|
SceneRenderObjects.Instance.UpdateAABB(centerTex, sizeTex);
|
||||||
|
}
|
||||||
|
var hizIndex = GetHizIndex();
|
||||||
|
var cullResult = cullResults[hizIndex];
|
||||||
|
SceneRenderObjects.Instance.ApplyCull(cullResults[GetLastCullIndex(hizIndex)]);
|
||||||
|
cullResult.ReadDone = false;
|
||||||
|
var world2Project = renderingData.cameraData.GetGPUProjectionMatrix() * renderingData.cameraData.GetViewMatrix();
|
||||||
|
if(settings.UseCompute)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
world2Project.m11 *= -1;
|
||||||
|
world2Project.m13 *= -1;
|
||||||
|
|
||||||
|
cmd.SetGlobalMatrix(HizShaderIds.GPUCullingVPId, world2Project);
|
||||||
|
cmd.SetGlobalTexture(HizShaderIds.ObjectAABBCenterId, centerTex);
|
||||||
|
cmd.SetGlobalTexture(HizShaderIds.ObjectAABBSizeId, sizeTex);
|
||||||
|
cmd.SetRenderTarget(cullResult.ResultTex, RenderBufferLoadAction.DontCare, RenderBufferStoreAction.Store);
|
||||||
|
cmd.DrawMesh(RenderingUtils.fullscreenMesh, Matrix4x4.identity, settings.CullMat, 0, 0);
|
||||||
|
var temp = new NativeArray<half>(centerTex.width * sizeTex.height, Allocator.Persistent);
|
||||||
|
cmd.RequestAsyncReadbackIntoNativeArray(ref temp, cullResult.ResultTex, 0, cullResult.ReadBackAction);
|
||||||
|
//cmd.RequestAsyncReadbackIntoNativeArray(ref cullResult.ResultArray, cullResult.ResultTex, 0, cullResult.ReadBackAction);
|
||||||
|
}
|
||||||
|
context.ExecuteCommandBuffer(cmd);
|
||||||
|
CommandBufferPool.Release(cmd);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -0,0 +1,29 @@
|
|||||||
|
%YAML 1.1
|
||||||
|
%TAG !u! tag:unity3d.com,2011:
|
||||||
|
--- !u!21 &2100000
|
||||||
|
Material:
|
||||||
|
serializedVersion: 8
|
||||||
|
m_ObjectHideFlags: 0
|
||||||
|
m_CorrespondingSourceObject: {fileID: 0}
|
||||||
|
m_PrefabInstance: {fileID: 0}
|
||||||
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
m_Name: Hidden_HizCull
|
||||||
|
m_Shader: {fileID: 4800000, guid: 1cd43651e6c755046991faf6246110fa, type: 3}
|
||||||
|
m_Parent: {fileID: 0}
|
||||||
|
m_ModifiedSerializedProperties: 0
|
||||||
|
m_ValidKeywords: []
|
||||||
|
m_InvalidKeywords: []
|
||||||
|
m_LightmapFlags: 4
|
||||||
|
m_EnableInstancingVariants: 0
|
||||||
|
m_DoubleSidedGI: 0
|
||||||
|
m_CustomRenderQueue: -1
|
||||||
|
stringTagMap: {}
|
||||||
|
disabledShaderPasses: []
|
||||||
|
m_LockedProperties:
|
||||||
|
m_SavedProperties:
|
||||||
|
serializedVersion: 3
|
||||||
|
m_TexEnvs: []
|
||||||
|
m_Ints: []
|
||||||
|
m_Floats: []
|
||||||
|
m_Colors: []
|
||||||
|
m_BuildTextureStacks: []
|
||||||
@ -0,0 +1,8 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: ce13e27ede10980489261083a699b449
|
||||||
|
NativeFormatImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
mainObjectFileID: 2100000
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
@ -0,0 +1,14 @@
|
|||||||
|
// Each #kernel tells which function to compile; you can have many kernels
|
||||||
|
#pragma kernel CSMain
|
||||||
|
|
||||||
|
// Create a RenderTexture with enableRandomWrite flag and set it
|
||||||
|
// with cs.SetTexture
|
||||||
|
RWTexture2D<float4> Result;
|
||||||
|
|
||||||
|
[numthreads(8,8,1)]
|
||||||
|
void CSMain (uint3 id : SV_DispatchThreadID)
|
||||||
|
{
|
||||||
|
// TODO: insert actual code here!
|
||||||
|
|
||||||
|
Result[id.xy] = float4(id.x & id.y, (id.x & 15)/15.0, (id.y & 15)/15.0, 0.0);
|
||||||
|
}
|
||||||
@ -0,0 +1,7 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 029fde5b4200eeb4e919fe924f26fdd8
|
||||||
|
ComputeShaderImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
@ -0,0 +1,135 @@
|
|||||||
|
Shader "Hidden/HizCull"
|
||||||
|
{
|
||||||
|
SubShader
|
||||||
|
{
|
||||||
|
Pass
|
||||||
|
{
|
||||||
|
HLSLPROGRAM
|
||||||
|
#pragma vertex Vertex
|
||||||
|
#pragma fragment CullFrag
|
||||||
|
#pragma enable_d3d11_debug_symbols
|
||||||
|
|
||||||
|
#include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Core.hlsl"
|
||||||
|
|
||||||
|
struct Attributes
|
||||||
|
{
|
||||||
|
float4 positionOS : POSITION;
|
||||||
|
float2 texcoord : TEXCOORD0;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct Varyings
|
||||||
|
{
|
||||||
|
float2 uv : TEXCOORD0;
|
||||||
|
float4 positionCS : SV_POSITION;
|
||||||
|
};
|
||||||
|
|
||||||
|
Varyings Vertex(Attributes input)
|
||||||
|
{
|
||||||
|
Varyings output = (Varyings)0;
|
||||||
|
output.positionCS = TransformObjectToHClip(input.positionOS.xyz);
|
||||||
|
output.uv = input.texcoord;
|
||||||
|
return output;
|
||||||
|
}
|
||||||
|
|
||||||
|
TEXTURE2D(_ObjectAABBTexture0);
|
||||||
|
SAMPLER(sampler_ObjectAABBTexture0);
|
||||||
|
TEXTURE2D(_ObjectAABBTexture1);
|
||||||
|
SAMPLER(sampler_ObjectAABBTexture1);
|
||||||
|
|
||||||
|
|
||||||
|
TEXTURE2D(_DepthPyramidTexture);
|
||||||
|
SAMPLER(sampler_DepthPyramidTexture);
|
||||||
|
float4x4 _GPUCullingVP;
|
||||||
|
float2 _MipmapLevelMinMaxIndex;
|
||||||
|
float2 _Mip0Size;
|
||||||
|
float4 _MipOffsetAndSize[16];
|
||||||
|
|
||||||
|
static const float3 aggressiveExtentArray[8] =
|
||||||
|
{
|
||||||
|
float3(1, 1, 1),
|
||||||
|
float3(1, 1, -1),
|
||||||
|
float3(1, -1, 1),
|
||||||
|
float3(1, -1, -1),
|
||||||
|
float3(-1, 1, 1),
|
||||||
|
float3(-1, 1, -1),
|
||||||
|
float3(-1, -1, 1),
|
||||||
|
float3(-1, -1, -1)
|
||||||
|
};
|
||||||
|
|
||||||
|
half CullFrag(Varyings input) : SV_Target
|
||||||
|
{
|
||||||
|
float2 uv = input.uv;
|
||||||
|
float4 aabbCenter = SAMPLE_TEXTURE2D_LOD(_ObjectAABBTexture0, sampler_ObjectAABBTexture0, uv,0.0);
|
||||||
|
float4 aabbSize = SAMPLE_TEXTURE2D_LOD(_ObjectAABBTexture1, sampler_ObjectAABBTexture1, uv, 0.0);
|
||||||
|
float3 aabbExtent = aabbSize.xyz * 0.5;//贴图可以直接存extent
|
||||||
|
UNITY_BRANCH
|
||||||
|
if (aabbCenter.a == 0.0)
|
||||||
|
{
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
#ifdef UNITY_REVERSED_Z
|
||||||
|
float minZ = 0;
|
||||||
|
#else
|
||||||
|
float minZ = 1;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
float2 maxXY = 0;
|
||||||
|
float2 minXY = 1;
|
||||||
|
for(uint i = 0; i < 8; ++i)
|
||||||
|
{
|
||||||
|
float3 boxCorner = aabbCenter + aabbExtent * aggressiveExtentArray[i];
|
||||||
|
float4 clipPos = mul(_GPUCullingVP, float4(boxCorner, 1));
|
||||||
|
clipPos /= clipPos.w;
|
||||||
|
minXY = min(clipPos.xy, minXY);
|
||||||
|
maxXY = max(clipPos.xy, maxXY);
|
||||||
|
#ifdef UNITY_REVERSED_Z
|
||||||
|
minZ = max(minZ, clipPos.z);
|
||||||
|
#else
|
||||||
|
minZ = min(minZ, clipPos.z);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
float4 boxUVs = float4(minXY, maxXY);
|
||||||
|
boxUVs = saturate(boxUVs * 0.5 + 0.5);
|
||||||
|
float2 size = (boxUVs.zw - boxUVs.xy) * _Mip0Size.xy;
|
||||||
|
float mip = (log2(max(size.x, size.y) / 2.0f));
|
||||||
|
|
||||||
|
mip = ceil(mip);
|
||||||
|
mip = clamp(mip, _MipmapLevelMinMaxIndex.x, _MipmapLevelMinMaxIndex.y);
|
||||||
|
|
||||||
|
// float level_lower = max(mip - 1, 0);
|
||||||
|
// float2 scale = exp2(-level_lower) / _Mip0Size.xy;
|
||||||
|
// float2 a = floor(boxUVs.xy*scale);
|
||||||
|
// float2 b = ceil(boxUVs.zw*scale);
|
||||||
|
// float2 dims = b - a;
|
||||||
|
//
|
||||||
|
// // Use the lower level if we only touch <= 2 texels in both dimensions
|
||||||
|
// if (dims.x <= 2 && dims.y <= 2)
|
||||||
|
// mip = level_lower;
|
||||||
|
|
||||||
|
float4 offsetAndSize = _MipOffsetAndSize[mip];
|
||||||
|
int4 pxMinMax = boxUVs * offsetAndSize.zwzw + offsetAndSize.xyxy;
|
||||||
|
|
||||||
|
float4 depth = float4(LOAD_TEXTURE2D_LOD(_DepthPyramidTexture, pxMinMax.xy,0).r,
|
||||||
|
LOAD_TEXTURE2D_LOD(_DepthPyramidTexture, pxMinMax.zy,0).r,
|
||||||
|
LOAD_TEXTURE2D_LOD(_DepthPyramidTexture, pxMinMax.xw,0).r,
|
||||||
|
LOAD_TEXTURE2D_LOD(_DepthPyramidTexture, pxMinMax.zw,0).r
|
||||||
|
);
|
||||||
|
|
||||||
|
#ifdef UNITY_REVERSED_Z
|
||||||
|
depth.xy = min(depth.xy, depth.zw);
|
||||||
|
depth.x = min(depth.x, depth.y);
|
||||||
|
return minZ >= depth.x ? 0 : 1;
|
||||||
|
#else
|
||||||
|
depth.xy = max(depth.xy, depth.zw);
|
||||||
|
depth.x = max(depth.x, depth.y);
|
||||||
|
return minZ <= depth.x ? 1 : 0;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
ENDHLSL
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,11 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 1cd43651e6c755046991faf6246110fa
|
||||||
|
MonoImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
@ -1,14 +1,126 @@
|
|||||||
// Each #kernel tells which function to compile; you can have many kernels
|
// Each #kernel tells which function to compile; you can have many kernels
|
||||||
#pragma kernel CSMain
|
#pragma kernel CSMain
|
||||||
|
#define FFX_SPD_NO_WAVE_OPERATIONS 1
|
||||||
|
// #pragma multi_compile FFX_SPD_NO_WAVE_OPERATIONS _
|
||||||
|
|
||||||
// Create a RenderTexture with enableRandomWrite flag and set it
|
#define FFX_GPU 1
|
||||||
// with cs.SetTexture
|
#define FFX_HLSL 1
|
||||||
RWTexture2D<float4> Result;
|
#define FFX_HALF 1
|
||||||
|
|
||||||
[numthreads(8,8,1)]
|
#define FFXM_GPU 1
|
||||||
void CSMain (uint3 id : SV_DispatchThreadID)
|
#define FFXM_HALF 1
|
||||||
{
|
#define FFXM_HLSL 1
|
||||||
// TODO: insert actual code here!
|
|
||||||
|
|
||||||
Result[id.xy] = float4(id.x & id.y, (id.x & 15)/15.0, (id.y & 15)/15.0, 0.0);
|
#include "ffx/ffx_core.h"
|
||||||
|
#include "ffx/ffx_common_types.h"
|
||||||
|
|
||||||
|
FFX_GROUPSHARED FfxFloat32 spdIntermediate[16][16];
|
||||||
|
void SpdStoreIntermediate(FfxUInt32 x, FfxUInt32 y, FfxFloat32x4 value) {
|
||||||
|
spdIntermediate[x][y] = value.x;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
FfxFloat32x4 SpdLoadIntermediate(FfxUInt32 x, FfxUInt32 y) {
|
||||||
|
FfxFloat32 f = spdIntermediate[x][y];
|
||||||
|
return FfxFloat32x4(f.x, f.x, f.x, f.x);
|
||||||
|
}
|
||||||
|
|
||||||
|
FFX_GROUPSHARED FfxFloat32 spdIntermediateH[16][16];
|
||||||
|
void SpdStoreIntermediateH(FfxUInt32 x, FfxUInt32 y, FfxFloat32x4 value) {
|
||||||
|
spdIntermediateH[x][y] = value.x;
|
||||||
|
}
|
||||||
|
|
||||||
|
FfxFloat32x4 SpdLoadIntermediateH(FfxUInt32 x, FfxUInt32 y) {
|
||||||
|
FfxFloat32 f = spdIntermediateH[x][y];
|
||||||
|
return FfxFloat32x4(f.x, f.x, f.x, f.x);
|
||||||
|
}
|
||||||
|
|
||||||
|
FfxFloat32x4 SpdReduce4(FfxFloat32x4 v0, FfxFloat32x4 v1, FfxFloat32x4 v2, FfxFloat32x4 v3) {
|
||||||
|
#if FFX_SSSR_OPTION_INVERTED_DEPTH
|
||||||
|
return max(max(v0, v1), max(v2, v3));
|
||||||
|
#else
|
||||||
|
return min(min(v0, v1), min(v2, v3));
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
FfxFloat16x4 SpdReduce4H(FfxFloat16x4 v0, FfxFloat16x4 v1, FfxFloat16x4 v2, FfxFloat16x4 v3) {
|
||||||
|
#if FFX_SSSR_OPTION_INVERTED_DEPTH
|
||||||
|
return max(max(v0, v1), max(v2, v3));
|
||||||
|
#else
|
||||||
|
return min(min(v0, v1), min(v2, v3));
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
Texture2D<FfxFloat32> _InputDepth;
|
||||||
|
RWTexture2D<FfxFloat32> _OutDepth;
|
||||||
|
float4 _MipOffsetAndSizeArray[16];
|
||||||
|
|
||||||
|
FfxFloat32x4 SpdLoad(FfxInt32x2 coordinate, FfxUInt32 slice)
|
||||||
|
{
|
||||||
|
return _InputDepth[coordinate].xxxx; // 5 -> 6 as we store a copy of the depth buffer at index 0
|
||||||
|
}
|
||||||
|
|
||||||
|
void SpdStore(FfxInt32x2 pix, FfxFloat32x4 outValue, FfxUInt32 coordinate, FfxUInt32 slice)
|
||||||
|
{
|
||||||
|
uint4 cur = _MipOffsetAndSizeArray[coordinate + 1];
|
||||||
|
_OutDepth[pix + cur.xy] = outValue.x; // + 1 as we store a copy of the depth buffer at index 0
|
||||||
|
}
|
||||||
|
|
||||||
|
FfxFloat32x4 SpdLoadH(FfxInt32x2 coordinate, FfxUInt32 slice)
|
||||||
|
{
|
||||||
|
return _InputDepth[coordinate].xxxx; // 5 -> 6 as we store a copy of the depth buffer at index 0
|
||||||
|
}
|
||||||
|
|
||||||
|
void SpdStoreH(FfxInt32x2 pix, FfxFloat32x4 outValue, FfxUInt32 coordinate, FfxUInt32 slice)
|
||||||
|
{
|
||||||
|
uint4 cur = _MipOffsetAndSizeArray[coordinate + 1];
|
||||||
|
_OutDepth[pix + cur.xy] = outValue.x; // + 1 as we store a copy of the depth buffer at index 0
|
||||||
|
}
|
||||||
|
|
||||||
|
FfxFloat32x4 SpdLoadSourceImage(FfxInt32x2 coordinate, FfxUInt32 slice)
|
||||||
|
{
|
||||||
|
return _InputDepth[coordinate].xxxx;
|
||||||
|
}
|
||||||
|
|
||||||
|
FfxFloat32x4 SpdLoadSourceImageH(FfxInt32x2 coordinate, FfxUInt32 slice)
|
||||||
|
{
|
||||||
|
return _InputDepth[coordinate].xxxx;
|
||||||
|
}
|
||||||
|
|
||||||
|
FfxUInt32 mips;
|
||||||
|
FfxUInt32 numWorkGroups;
|
||||||
|
FFX_GROUPSHARED FfxUInt32 spdCounter;
|
||||||
|
RWTexture2D<FfxUInt32> rw_internal_global_atomic;
|
||||||
|
|
||||||
|
void IncreaseAtomicCounter(FFX_PARAMETER_IN FfxUInt32 slice, FFX_PARAMETER_INOUT FfxUInt32 counter)
|
||||||
|
{
|
||||||
|
InterlockedAdd(rw_internal_global_atomic[FfxInt32x2(0, 0)] , 1, counter);
|
||||||
|
}
|
||||||
|
|
||||||
|
void ResetAtomicCounter(FFX_PARAMETER_IN FfxUInt32 slice)
|
||||||
|
{
|
||||||
|
rw_internal_global_atomic[FfxInt32x2(0, 0)] = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
FfxUInt32 SpdGetAtomicCounter()
|
||||||
|
{
|
||||||
|
return spdCounter;
|
||||||
|
}
|
||||||
|
|
||||||
|
void SpdResetAtomicCounter(FfxUInt32 slice)
|
||||||
|
{
|
||||||
|
ResetAtomicCounter(slice);
|
||||||
|
}
|
||||||
|
|
||||||
|
void SpdIncreaseAtomicCounter(FfxUInt32 slice)
|
||||||
|
{
|
||||||
|
IncreaseAtomicCounter(slice, spdCounter);
|
||||||
|
}
|
||||||
|
#include "ffx/ffx_spd.h"
|
||||||
|
|
||||||
|
[numthreads(256,1,1)]
|
||||||
|
void CSMain (uint LocalThreadIndex : SV_GroupIndex, uint3 WorkGroupId : SV_GroupID)
|
||||||
|
{
|
||||||
|
SpdDownsampleH(WorkGroupId.xy, LocalThreadIndex, mips, numWorkGroups, WorkGroupId.z, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -0,0 +1,8 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 7ffb36fd571dced4d9a653922e758cea
|
||||||
|
folderAsset: yes
|
||||||
|
DefaultImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
@ -0,0 +1,558 @@
|
|||||||
|
// This file is part of the FidelityFX SDK.
|
||||||
|
//
|
||||||
|
// Copyright (C) 2024 Advanced Micro Devices, Inc.
|
||||||
|
//
|
||||||
|
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
// of this software and associated documentation files(the "Software"), to deal
|
||||||
|
// in the Software without restriction, including without limitation the rights
|
||||||
|
// to use, copy, modify, merge, publish, distribute, sublicense, and /or sell
|
||||||
|
// copies of the Software, and to permit persons to whom the Software is
|
||||||
|
// furnished to do so, subject to the following conditions :
|
||||||
|
//
|
||||||
|
// The above copyright notice and this permission notice shall be included in
|
||||||
|
// all copies or substantial portions of the Software.
|
||||||
|
//
|
||||||
|
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||||
|
// THE SOFTWARE.
|
||||||
|
|
||||||
|
#ifndef FFX_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 2x2 floating point matrix.
|
||||||
|
///
|
||||||
|
/// @ingroup CPUTypes
|
||||||
|
typedef float FfxFloat32x2x2[4];
|
||||||
|
|
||||||
|
/// A typedef for a 3x3 floating point matrix.
|
||||||
|
///
|
||||||
|
/// @ingroup CPUTypes
|
||||||
|
typedef float FfxFloat32x3x3[9];
|
||||||
|
|
||||||
|
/// A typedef for a 3x4 floating point matrix.
|
||||||
|
///
|
||||||
|
/// @ingroup CPUTypes
|
||||||
|
typedef float FfxFloat32x3x4[12];
|
||||||
|
|
||||||
|
/// A typedef for a 4x4 floating point matrix.
|
||||||
|
///
|
||||||
|
/// @ingroup CPUTypes
|
||||||
|
typedef float FfxFloat32x4x4[16];
|
||||||
|
|
||||||
|
/// A typedef for a 2-dimensional 32bit signed integer.
|
||||||
|
///
|
||||||
|
/// @ingroup CPUTypes
|
||||||
|
typedef int32_t FfxInt32x2[2];
|
||||||
|
|
||||||
|
/// A typedef for a 3-dimensional 32bit signed integer.
|
||||||
|
///
|
||||||
|
/// @ingroup CPUTypes
|
||||||
|
typedef int32_t FfxInt32x3[3];
|
||||||
|
|
||||||
|
/// A typedef for a 4-dimensional 32bit signed integer.
|
||||||
|
///
|
||||||
|
/// @ingroup CPUTypes
|
||||||
|
typedef int32_t FfxInt32x4[4];
|
||||||
|
|
||||||
|
/// A typedef for a 2-dimensional 32bit usigned 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 float3x4 FfxFloat32x3x4;
|
||||||
|
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 FfxFloat32x3x4 float3x4
|
||||||
|
#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;
|
||||||
|
#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 FfxFloat32x3x4 mat4x3
|
||||||
|
#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
|
||||||
|
|
||||||
|
#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)
|
||||||
|
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(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: 7db508df1f69cd949909e1597a58f09b
|
||||||
|
PluginImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
iconMap: {}
|
||||||
|
executionOrder: {}
|
||||||
|
defineConstraints: []
|
||||||
|
isPreloaded: 0
|
||||||
|
isOverridable: 1
|
||||||
|
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) 2024 Advanced Micro Devices, Inc.
|
||||||
|
//
|
||||||
|
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
// of this software and associated documentation files(the "Software"), to deal
|
||||||
|
// in the Software without restriction, including without limitation the rights
|
||||||
|
// to use, copy, modify, merge, publish, distribute, sublicense, and /or sell
|
||||||
|
// copies of the Software, and to permit persons to whom the Software is
|
||||||
|
// furnished to do so, subject to the following conditions :
|
||||||
|
//
|
||||||
|
// The above copyright notice and this permission notice shall be included in
|
||||||
|
// all copies or substantial portions of the Software.
|
||||||
|
//
|
||||||
|
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||||
|
// THE SOFTWARE.
|
||||||
|
|
||||||
|
/// @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: 59fa5955b83fd5a45a2c8698750e7314
|
||||||
|
PluginImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
iconMap: {}
|
||||||
|
executionOrder: {}
|
||||||
|
defineConstraints: []
|
||||||
|
isPreloaded: 0
|
||||||
|
isOverridable: 1
|
||||||
|
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: eead56bcc49293d4385163969a9a0307
|
||||||
|
PluginImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
iconMap: {}
|
||||||
|
executionOrder: {}
|
||||||
|
defineConstraints: []
|
||||||
|
isPreloaded: 0
|
||||||
|
isOverridable: 1
|
||||||
|
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: 3074a00f29f9e3c448fc5c28b6b90f24
|
||||||
|
PluginImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
iconMap: {}
|
||||||
|
executionOrder: {}
|
||||||
|
defineConstraints: []
|
||||||
|
isPreloaded: 0
|
||||||
|
isOverridable: 1
|
||||||
|
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: c98f28ee15ed8494c89aaedd91dd8d3d
|
||||||
|
PluginImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
iconMap: {}
|
||||||
|
executionOrder: {}
|
||||||
|
defineConstraints: []
|
||||||
|
isPreloaded: 0
|
||||||
|
isOverridable: 1
|
||||||
|
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,46 @@
|
|||||||
|
// This file is part of the FidelityFX SDK.
|
||||||
|
//
|
||||||
|
// Copyright (C) 2024 Advanced Micro Devices, Inc.
|
||||||
|
//
|
||||||
|
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
// of this software and associated documentation files(the "Software"), to deal
|
||||||
|
// in the Software without restriction, including without limitation the rights
|
||||||
|
// to use, copy, modify, merge, publish, distribute, sublicense, and /or sell
|
||||||
|
// copies of the Software, and to permit persons to whom the Software is
|
||||||
|
// furnished to do so, subject to the following conditions :
|
||||||
|
//
|
||||||
|
// The above copyright notice and this permission notice shall be included in
|
||||||
|
// all copies or substantial portions of the Software.
|
||||||
|
//
|
||||||
|
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||||
|
// THE SOFTWARE.
|
||||||
|
|
||||||
|
void ffxOpAAddOneF3(FFX_PARAMETER_OUT FfxFloat32x3 d, FfxFloat32x3 a, FfxFloat32 b)
|
||||||
|
{
|
||||||
|
d = a + ffxBroadcast3(b);
|
||||||
|
}
|
||||||
|
|
||||||
|
void ffxOpACpyF3(FFX_PARAMETER_OUT FfxFloat32x3 d, FfxFloat32x3 a)
|
||||||
|
{
|
||||||
|
d = a;
|
||||||
|
}
|
||||||
|
|
||||||
|
void ffxOpAMulF3(FFX_PARAMETER_OUT FfxFloat32x3 d, FfxFloat32x3 a, FfxFloat32x3 b)
|
||||||
|
{
|
||||||
|
d = a * b;
|
||||||
|
}
|
||||||
|
|
||||||
|
void ffxOpAMulOneF3(FFX_PARAMETER_OUT FfxFloat32x3 d, FfxFloat32x3 a, FfxFloat32 b)
|
||||||
|
{
|
||||||
|
d = a * b;
|
||||||
|
}
|
||||||
|
|
||||||
|
void ffxOpARcpF3(FFX_PARAMETER_OUT FfxFloat32x3 d, FfxFloat32x3 a)
|
||||||
|
{
|
||||||
|
d = ffxReciprocal(a);
|
||||||
|
}
|
||||||
@ -0,0 +1,27 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 9943ca8c436885d448cc133e640fd4b2
|
||||||
|
PluginImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
iconMap: {}
|
||||||
|
executionOrder: {}
|
||||||
|
defineConstraints: []
|
||||||
|
isPreloaded: 0
|
||||||
|
isOverridable: 1
|
||||||
|
isExplicitlyReferenced: 0
|
||||||
|
validateReferences: 1
|
||||||
|
platformData:
|
||||||
|
- first:
|
||||||
|
Any:
|
||||||
|
second:
|
||||||
|
enabled: 1
|
||||||
|
settings: {}
|
||||||
|
- first:
|
||||||
|
Editor: Editor
|
||||||
|
second:
|
||||||
|
enabled: 0
|
||||||
|
settings:
|
||||||
|
DefaultValueInitialized: true
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
1014
Packages/com.unity.render-pipelines.universal@14.0.11/Runtime/OcclusionCulling/Shaders/ffx/ffx_spd.h
vendored
Normal file
1014
Packages/com.unity.render-pipelines.universal@14.0.11/Runtime/OcclusionCulling/Shaders/ffx/ffx_spd.h
vendored
Normal file
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,27 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 8e323410b1a2e304dad4767b57398f10
|
||||||
|
PluginImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
iconMap: {}
|
||||||
|
executionOrder: {}
|
||||||
|
defineConstraints: []
|
||||||
|
isPreloaded: 0
|
||||||
|
isOverridable: 1
|
||||||
|
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,218 @@
|
|||||||
|
// This file is part of the FidelityFX SDK.
|
||||||
|
//
|
||||||
|
// Copyright (C) 2024 Advanced Micro Devices, Inc.
|
||||||
|
//
|
||||||
|
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
// of this software and associated documentation files(the "Software"), to deal
|
||||||
|
// in the Software without restriction, including without limitation the rights
|
||||||
|
// to use, copy, modify, merge, publish, distribute, sublicense, and /or sell
|
||||||
|
// copies of the Software, and to permit persons to whom the Software is
|
||||||
|
// furnished to do so, subject to the following conditions :
|
||||||
|
//
|
||||||
|
// The above copyright notice and this permission notice shall be included in
|
||||||
|
// all copies or substantial portions of the Software.
|
||||||
|
//
|
||||||
|
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||||
|
// THE SOFTWARE.
|
||||||
|
|
||||||
|
#include "ffx_spd_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
|
||||||
|
|
||||||
|
#ifndef FFX_PREFER_WAVE64
|
||||||
|
#define FFX_PREFER_WAVE64
|
||||||
|
#endif // #ifndef FFX_PREFER_WAVE64
|
||||||
|
|
||||||
|
#pragma warning(disable: 3205) // conversion from larger type to smaller
|
||||||
|
|
||||||
|
#define FFX_DECLARE_SRV_REGISTER(regIndex) t##regIndex
|
||||||
|
#define FFX_DECLARE_UAV_REGISTER(regIndex) u##regIndex
|
||||||
|
#define FFX_DECLARE_CB_REGISTER(regIndex) b##regIndex
|
||||||
|
#define FFX_SPD_DECLARE_SRV(regIndex) register(FFX_DECLARE_SRV_REGISTER(regIndex))
|
||||||
|
#define FFX_SPD_DECLARE_UAV(regIndex) register(FFX_DECLARE_UAV_REGISTER(regIndex))
|
||||||
|
#define FFX_SPD_DECLARE_CB(regIndex) register(FFX_DECLARE_CB_REGISTER(regIndex))
|
||||||
|
|
||||||
|
#if defined(FFX_SPD_BIND_CB_SPD)
|
||||||
|
cbuffer cbSPD : FFX_SPD_DECLARE_CB(FFX_SPD_BIND_CB_SPD)
|
||||||
|
{
|
||||||
|
FfxUInt32 mips;
|
||||||
|
FfxUInt32 numWorkGroups;
|
||||||
|
FfxUInt32x2 workGroupOffset;
|
||||||
|
FfxFloat32x2 invInputSize; // Only used for linear sampling mode
|
||||||
|
FfxFloat32x2 padding;
|
||||||
|
|
||||||
|
#define FFX_SPD_CONSTANT_BUFFER_1_SIZE 8 // Number of 32-bit values. This must be kept in sync with the cbSPD size.
|
||||||
|
};
|
||||||
|
#else
|
||||||
|
#define mips 0
|
||||||
|
#define numWorkGroups 0
|
||||||
|
#define workGroupOffset 0
|
||||||
|
#define invInputSize 0
|
||||||
|
#define padding 0
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#define FFX_SPD_ROOTSIG_STRINGIFY(p) FFX_SPD_ROOTSIG_STR(p)
|
||||||
|
#define FFX_SPD_ROOTSIG_STR(p) #p
|
||||||
|
#define FFX_SPD_ROOTSIG [RootSignature( "DescriptorTable(UAV(u0, numDescriptors = " FFX_SPD_ROOTSIG_STRINGIFY(FFX_SPD_RESOURCE_IDENTIFIER_COUNT) ")), " \
|
||||||
|
"DescriptorTable(SRV(t0, numDescriptors = " FFX_SPD_ROOTSIG_STRINGIFY(FFX_SPD_RESOURCE_IDENTIFIER_COUNT) ")), " \
|
||||||
|
"CBV(b0), " \
|
||||||
|
"StaticSampler(s0, filter = FILTER_MIN_MAG_LINEAR_MIP_POINT, " \
|
||||||
|
"addressU = TEXTURE_ADDRESS_CLAMP, " \
|
||||||
|
"addressV = TEXTURE_ADDRESS_CLAMP, " \
|
||||||
|
"addressW = TEXTURE_ADDRESS_CLAMP, " \
|
||||||
|
"comparisonFunc = COMPARISON_NEVER, " \
|
||||||
|
"borderColor = STATIC_BORDER_COLOR_TRANSPARENT_BLACK)" )]
|
||||||
|
|
||||||
|
#if defined(FFX_SPD_EMBED_ROOTSIG)
|
||||||
|
#define FFX_SPD_EMBED_ROOTSIG_CONTENT FFX_SPD_ROOTSIG
|
||||||
|
#else
|
||||||
|
#define FFX_SPD_EMBED_ROOTSIG_CONTENT
|
||||||
|
#endif // #if FFX_SPD_EMBED_ROOTSIG
|
||||||
|
|
||||||
|
FfxUInt32 Mips()
|
||||||
|
{
|
||||||
|
return mips;
|
||||||
|
}
|
||||||
|
|
||||||
|
FfxUInt32 NumWorkGroups()
|
||||||
|
{
|
||||||
|
return numWorkGroups;
|
||||||
|
}
|
||||||
|
|
||||||
|
FfxUInt32x2 WorkGroupOffset()
|
||||||
|
{
|
||||||
|
return workGroupOffset;
|
||||||
|
}
|
||||||
|
|
||||||
|
FfxFloat32x2 InvInputSize()
|
||||||
|
{
|
||||||
|
return invInputSize;
|
||||||
|
}
|
||||||
|
|
||||||
|
SamplerState s_LinearClamp : register(s0);
|
||||||
|
|
||||||
|
// SRVs
|
||||||
|
#if defined(FFX_SPD_BIND_SRV_INPUT_DOWNSAMPLE_SRC)
|
||||||
|
Texture2DArray<FfxFloat32x4> r_input_downsample_src : FFX_SPD_DECLARE_SRV(FFX_SPD_BIND_SRV_INPUT_DOWNSAMPLE_SRC);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// UAV declarations
|
||||||
|
#if defined(FFX_SPD_BIND_UAV_INTERNAL_GLOBAL_ATOMIC)
|
||||||
|
struct SpdGlobalAtomicBuffer { FfxUInt32 counter[6]; };
|
||||||
|
globallycoherent RWStructuredBuffer<SpdGlobalAtomicBuffer> rw_internal_global_atomic : FFX_SPD_DECLARE_UAV(FFX_SPD_BIND_UAV_INTERNAL_GLOBAL_ATOMIC);
|
||||||
|
#endif
|
||||||
|
#if defined(FFX_SPD_BIND_UAV_INPUT_DOWNSAMPLE_SRC_MID_MIPMAP)
|
||||||
|
globallycoherent RWTexture2DArray<FfxFloat32x4> rw_input_downsample_src_mid_mip : FFX_SPD_DECLARE_UAV(FFX_SPD_BIND_UAV_INPUT_DOWNSAMPLE_SRC_MID_MIPMAP);
|
||||||
|
#endif
|
||||||
|
#if defined(FFX_SPD_BIND_UAV_INPUT_DOWNSAMPLE_SRC_MIPS)
|
||||||
|
RWTexture2DArray<FfxFloat32x4> rw_input_downsample_src_mips[SPD_MAX_MIP_LEVELS+1] : FFX_SPD_DECLARE_UAV(FFX_SPD_BIND_UAV_INPUT_DOWNSAMPLE_SRC_MIPS);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if FFX_HALF
|
||||||
|
|
||||||
|
#if defined(FFX_SPD_BIND_SRV_INPUT_DOWNSAMPLE_SRC)
|
||||||
|
FfxFloat16x4 SampleSrcImageH(FfxFloat32x2 uv, FfxUInt32 slice)
|
||||||
|
{
|
||||||
|
FfxFloat32x2 textureCoord = FfxFloat32x2(uv) * InvInputSize() + InvInputSize();
|
||||||
|
FfxFloat32x4 result = r_input_downsample_src.SampleLevel(s_LinearClamp, FfxFloat32x3(textureCoord, slice), 0);
|
||||||
|
return FfxFloat16x4(ffxSrgbFromLinear(result.x), ffxSrgbFromLinear(result.y), ffxSrgbFromLinear(result.z), result.w);
|
||||||
|
}
|
||||||
|
#endif // defined(FFX_SPD_BIND_SRV_INPUT_DOWNSAMPLE_SRC)
|
||||||
|
|
||||||
|
#if defined(FFX_SPD_BIND_UAV_INPUT_DOWNSAMPLE_SRC_MIPS)
|
||||||
|
FfxFloat16x4 LoadSrcImageH(FfxFloat32x2 uv, FfxUInt32 slice)
|
||||||
|
{
|
||||||
|
return FfxFloat16x4(rw_input_downsample_src_mips[0][FfxUInt32x3(uv, slice)]);
|
||||||
|
}
|
||||||
|
#endif // defined(FFX_SPD_BIND_UAV_INPUT_DOWNSAMPLE_SRC_MIPS)
|
||||||
|
|
||||||
|
#if defined(FFX_SPD_BIND_UAV_INPUT_DOWNSAMPLE_SRC_MIPS)
|
||||||
|
void StoreSrcMipH(FfxFloat16x4 value, FfxInt32x2 uv, FfxUInt32 slice, FfxUInt32 mip)
|
||||||
|
{
|
||||||
|
rw_input_downsample_src_mips[mip][FfxUInt32x3(uv, slice)] = FfxFloat32x4(value);
|
||||||
|
}
|
||||||
|
#endif // defined(FFX_SPD_BIND_UAV_INPUT_DOWNSAMPLE_SRC_MIPS)
|
||||||
|
|
||||||
|
#if defined(FFX_SPD_BIND_UAV_INPUT_DOWNSAMPLE_SRC_MID_MIPMAP)
|
||||||
|
FfxFloat16x4 LoadMidMipH(FfxInt32x2 uv, FfxUInt32 slice)
|
||||||
|
{
|
||||||
|
return FfxFloat16x4(rw_input_downsample_src_mid_mip[FfxUInt32x3(uv, slice)]);
|
||||||
|
}
|
||||||
|
#endif // defined(FFX_SPD_BIND_UAV_INPUT_DOWNSAMPLE_SRC_MID_MIPMAP)
|
||||||
|
|
||||||
|
#if defined(FFX_SPD_BIND_UAV_INPUT_DOWNSAMPLE_SRC_MID_MIPMAP)
|
||||||
|
void StoreMidMipH(FfxFloat16x4 value, FfxInt32x2 uv, FfxUInt32 slice)
|
||||||
|
{
|
||||||
|
rw_input_downsample_src_mid_mip[FfxUInt32x3(uv, slice)] = FfxFloat32x4(value);
|
||||||
|
}
|
||||||
|
#endif // defined(FFX_SPD_BIND_UAV_INPUT_DOWNSAMPLE_SRC_MID_MIPMAP)
|
||||||
|
|
||||||
|
#else // FFX_HALF
|
||||||
|
|
||||||
|
#if defined(FFX_SPD_BIND_SRV_INPUT_DOWNSAMPLE_SRC)
|
||||||
|
FfxFloat32x4 SampleSrcImage(FfxInt32x2 uv, FfxUInt32 slice)
|
||||||
|
{
|
||||||
|
FfxFloat32x2 textureCoord = FfxFloat32x2(uv) * InvInputSize() + InvInputSize();
|
||||||
|
FfxFloat32x4 result = r_input_downsample_src.SampleLevel(s_LinearClamp, FfxFloat32x3(textureCoord, slice), 0);
|
||||||
|
return FfxFloat32x4(ffxSrgbFromLinear(result.x), ffxSrgbFromLinear(result.y), ffxSrgbFromLinear(result.z), result.w);
|
||||||
|
}
|
||||||
|
#endif // defined(FFX_SPD_BIND_SRV_INPUT_DOWNSAMPLE_SRC)
|
||||||
|
|
||||||
|
#if defined(FFX_SPD_BIND_UAV_INPUT_DOWNSAMPLE_SRC_MIPS)
|
||||||
|
FfxFloat32x4 LoadSrcImage(FfxInt32x2 uv, FfxUInt32 slice)
|
||||||
|
{
|
||||||
|
return rw_input_downsample_src_mips[0][FfxUInt32x3(uv, slice)];
|
||||||
|
}
|
||||||
|
#endif // defined(FFX_SPD_BIND_UAV_INPUT_DOWNSAMPLE_SRC_MIPS)
|
||||||
|
|
||||||
|
#if defined(FFX_SPD_BIND_UAV_INPUT_DOWNSAMPLE_SRC_MIPS)
|
||||||
|
void StoreSrcMip(FfxFloat32x4 value, FfxInt32x2 uv, FfxUInt32 slice, FfxUInt32 mip)
|
||||||
|
{
|
||||||
|
rw_input_downsample_src_mips[mip][FfxUInt32x3(uv, slice)] = value;
|
||||||
|
}
|
||||||
|
#endif // defined(FFX_SPD_BIND_UAV_INPUT_DOWNSAMPLE_SRC_MIPS)
|
||||||
|
|
||||||
|
#if defined(FFX_SPD_BIND_UAV_INPUT_DOWNSAMPLE_SRC_MID_MIPMAP)
|
||||||
|
FfxFloat32x4 LoadMidMip(FfxInt32x2 uv, FfxUInt32 slice)
|
||||||
|
{
|
||||||
|
return rw_input_downsample_src_mid_mip[FfxUInt32x3(uv, slice)];
|
||||||
|
}
|
||||||
|
#endif // defined(FFX_SPD_BIND_UAV_INPUT_DOWNSAMPLE_SRC_MID_MIPMAP)
|
||||||
|
|
||||||
|
#if defined(FFX_SPD_BIND_UAV_INPUT_DOWNSAMPLE_SRC_MID_MIPMAP)
|
||||||
|
void StoreMidMip(FfxFloat32x4 value, FfxInt32x2 uv, FfxUInt32 slice)
|
||||||
|
{
|
||||||
|
rw_input_downsample_src_mid_mip[FfxUInt32x3(uv, slice)] = value;
|
||||||
|
}
|
||||||
|
#endif // defined(FFX_SPD_BIND_UAV_INPUT_DOWNSAMPLE_SRC_MID_MIPMAP)
|
||||||
|
|
||||||
|
#endif // FFX_HALF
|
||||||
|
|
||||||
|
#if defined(FFX_SPD_BIND_UAV_INTERNAL_GLOBAL_ATOMIC)
|
||||||
|
void IncreaseAtomicCounter(FFX_PARAMETER_IN FfxUInt32 slice, FFX_PARAMETER_INOUT FfxUInt32 counter)
|
||||||
|
{
|
||||||
|
InterlockedAdd(rw_internal_global_atomic[0].counter[slice], 1, counter);
|
||||||
|
}
|
||||||
|
#endif // defined(FFX_SPD_BIND_UAV_INTERNAL_GLOBAL_ATOMIC)
|
||||||
|
|
||||||
|
#if defined(FFX_SPD_BIND_UAV_INTERNAL_GLOBAL_ATOMIC)
|
||||||
|
void ResetAtomicCounter(FFX_PARAMETER_IN FfxUInt32 slice)
|
||||||
|
{
|
||||||
|
rw_internal_global_atomic[0].counter[slice] = 0;
|
||||||
|
}
|
||||||
|
#endif // defined(FFX_SPD_BIND_UAV_INTERNAL_GLOBAL_ATOMIC)
|
||||||
|
|
||||||
|
#endif // #if defined(FFX_GPU)
|
||||||
@ -0,0 +1,27 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: d906db2acd4127e49a5e5501da951810
|
||||||
|
PluginImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
iconMap: {}
|
||||||
|
executionOrder: {}
|
||||||
|
defineConstraints: []
|
||||||
|
isPreloaded: 0
|
||||||
|
isOverridable: 1
|
||||||
|
isExplicitlyReferenced: 0
|
||||||
|
validateReferences: 1
|
||||||
|
platformData:
|
||||||
|
- first:
|
||||||
|
Any:
|
||||||
|
second:
|
||||||
|
enabled: 1
|
||||||
|
settings: {}
|
||||||
|
- first:
|
||||||
|
Editor: Editor
|
||||||
|
second:
|
||||||
|
enabled: 0
|
||||||
|
settings:
|
||||||
|
DefaultValueInitialized: true
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
Loading…
x
Reference in New Issue
Block a user