|
|
@ -19,6 +19,7 @@ |
|
|
// THE SOFTWARE.
|
|
|
// THE SOFTWARE.
|
|
|
|
|
|
|
|
|
using System; |
|
|
using System; |
|
|
|
|
|
using System.Diagnostics; |
|
|
using UnityEngine; |
|
|
using UnityEngine; |
|
|
using UnityEngine.Profiling; |
|
|
using UnityEngine.Profiling; |
|
|
using UnityEngine.Rendering; |
|
|
using UnityEngine.Rendering; |
|
|
@ -41,7 +42,7 @@ namespace ArmASR |
|
|
protected ComputeShader ComputeShader; |
|
|
protected ComputeShader ComputeShader; |
|
|
protected int KernelIndex; |
|
|
protected int KernelIndex; |
|
|
|
|
|
|
|
|
protected CustomSampler Sampler; |
|
|
|
|
|
|
|
|
private CustomSampler _sampler; |
|
|
|
|
|
|
|
|
protected AsrPass(Asr.ContextDescription contextDescription, AsrResources resources, ComputeBuffer constants) |
|
|
protected AsrPass(Asr.ContextDescription contextDescription, AsrResources resources, ComputeBuffer constants) |
|
|
{ |
|
|
{ |
|
|
@ -56,9 +57,9 @@ namespace ArmASR |
|
|
|
|
|
|
|
|
public void ScheduleDispatch(CommandBuffer commandBuffer, Asr.DispatchDescription dispatchParams, int frameIndex, int dispatchX, int dispatchY) |
|
|
public void ScheduleDispatch(CommandBuffer commandBuffer, Asr.DispatchDescription dispatchParams, int frameIndex, int dispatchX, int dispatchY) |
|
|
{ |
|
|
{ |
|
|
commandBuffer.BeginSample(Sampler); |
|
|
|
|
|
|
|
|
BeginSample(commandBuffer); |
|
|
DoScheduleDispatch(commandBuffer, dispatchParams, frameIndex, dispatchX, dispatchY); |
|
|
DoScheduleDispatch(commandBuffer, dispatchParams, frameIndex, dispatchX, dispatchY); |
|
|
commandBuffer.EndSample(Sampler); |
|
|
|
|
|
|
|
|
EndSample(commandBuffer); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
protected abstract void DoScheduleDispatch(CommandBuffer commandBuffer, Asr.DispatchDescription dispatchParams, int frameIndex, int dispatchX, int dispatchY); |
|
|
protected abstract void DoScheduleDispatch(CommandBuffer commandBuffer, Asr.DispatchDescription dispatchParams, int frameIndex, int dispatchX, int dispatchY); |
|
|
@ -77,7 +78,7 @@ namespace ArmASR |
|
|
|
|
|
|
|
|
ComputeShader = shader; |
|
|
ComputeShader = shader; |
|
|
KernelIndex = ComputeShader.FindKernel("main"); |
|
|
KernelIndex = ComputeShader.FindKernel("main"); |
|
|
Sampler = CustomSampler.Create(passName); |
|
|
|
|
|
|
|
|
_sampler = CustomSampler.Create(passName); |
|
|
|
|
|
|
|
|
bool useLut = false; |
|
|
bool useLut = false; |
|
|
#if UNITY_2022_1_OR_NEWER // This will also work in 2020.3.43+ and 2021.3.14+
|
|
|
#if UNITY_2022_1_OR_NEWER // This will also work in 2020.3.43+ and 2021.3.14+
|
|
|
@ -95,6 +96,18 @@ namespace ArmASR |
|
|
if (useLut) ComputeShader.EnableKeyword("FFXM_FSR2_OPTION_REPROJECT_USE_LANCZOS_TYPE"); |
|
|
if (useLut) ComputeShader.EnableKeyword("FFXM_FSR2_OPTION_REPROJECT_USE_LANCZOS_TYPE"); |
|
|
if ((flags & Asr.InitializationFlags.EnableFP16Usage) != 0) ComputeShader.EnableKeyword("FFXM_HALF"); |
|
|
if ((flags & Asr.InitializationFlags.EnableFP16Usage) != 0) ComputeShader.EnableKeyword("FFXM_HALF"); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
[Conditional("ENABLE_PROFILER")] |
|
|
|
|
|
protected void BeginSample(CommandBuffer cmd) |
|
|
|
|
|
{ |
|
|
|
|
|
cmd.BeginSample(_sampler); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
[Conditional("ENABLE_PROFILER")] |
|
|
|
|
|
protected void EndSample(CommandBuffer cmd) |
|
|
|
|
|
{ |
|
|
|
|
|
cmd.EndSample(_sampler); |
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
internal class AsrComputeLuminancePyramidPass : AsrPass |
|
|
internal class AsrComputeLuminancePyramidPass : AsrPass |
|
|
@ -319,7 +332,7 @@ namespace ArmASR |
|
|
|
|
|
|
|
|
public void ScheduleDispatch(CommandBuffer commandBuffer, Asr.GenerateReactiveDescription dispatchParams, int dispatchX, int dispatchY) |
|
|
public void ScheduleDispatch(CommandBuffer commandBuffer, Asr.GenerateReactiveDescription dispatchParams, int dispatchX, int dispatchY) |
|
|
{ |
|
|
{ |
|
|
commandBuffer.BeginSample(Sampler); |
|
|
|
|
|
|
|
|
BeginSample(commandBuffer); |
|
|
|
|
|
|
|
|
ref var opaqueOnly = ref dispatchParams.ColorOpaqueOnly; |
|
|
ref var opaqueOnly = ref dispatchParams.ColorOpaqueOnly; |
|
|
ref var color = ref dispatchParams.ColorPreUpscale; |
|
|
ref var color = ref dispatchParams.ColorPreUpscale; |
|
|
@ -333,7 +346,7 @@ namespace ArmASR |
|
|
|
|
|
|
|
|
commandBuffer.DispatchCompute(ComputeShader, KernelIndex, dispatchX, dispatchY, 1); |
|
|
commandBuffer.DispatchCompute(ComputeShader, KernelIndex, dispatchX, dispatchY, 1); |
|
|
|
|
|
|
|
|
commandBuffer.EndSample(Sampler); |
|
|
|
|
|
|
|
|
EndSample(commandBuffer); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |