@ -19,6 +19,7 @@
// THE SOFTWARE.
using System ;
using System.Collections.Generic ;
using System.Diagnostics ;
using UnityEngine ;
using UnityEngine.Profiling ;
@ -41,6 +42,11 @@ namespace ArmASR
protected ComputeShader ComputeShader ;
protected int KernelIndex ;
protected Material FragmentMaterial ;
protected int FragmentPass ;
protected MaterialPropertyBlock FragmentProperties ;
protected readonly List < LocalKeyword > FragmentKeywords = new ( ) ;
private CustomSampler _sampler ;
@ -53,6 +59,13 @@ namespace ArmASR
public virtual void Dispose ( )
{
if ( FragmentMaterial ! = null )
{
Asr . DestroyObject ( FragmentMaterial ) ;
FragmentMaterial = null ;
}
FragmentKeywords . Clear ( ) ;
}
public void ScheduleDispatch ( CommandBuffer commandBuffer , Asr . DispatchDescription dispatchParams , int frameIndex , int dispatchX , int dispatchY )
@ -80,6 +93,45 @@ namespace ArmASR
KernelIndex = ComputeShader . FindKernel ( "main" ) ;
_sampler = CustomSampler . Create ( passName ) ;
foreach ( string keyword in GetKeywords ( flags ) )
{
ComputeShader . EnableKeyword ( keyword ) ;
}
}
protected void InitFragmentShader ( string passName , Shader shader , int passNumber )
{
InitFragmentShader ( passName , shader , passNumber , ContextDescription . Flags ) ;
}
private void InitFragmentShader ( string passName , Shader shader , int passNumber , Asr . InitializationFlags flags )
{
if ( shader = = null )
{
throw new MissingReferenceException ( $"Shader for ASR pass '{passName}' could not be loaded! Please ensure it is included in the project correctly." ) ;
}
FragmentMaterial = new Material ( shader ) ;
FragmentPass = passNumber ;
_sampler = CustomSampler . Create ( passName ) ;
FragmentProperties = new MaterialPropertyBlock ( ) ;
foreach ( string keyword in GetKeywords ( flags ) )
{
// TODO: also want to include keywords that should be disabled (false)
// TODO: might be better to just determine all the keywords once up front and set them globally, probably don't even need to manage them here but in the AsrContext instead
// NOTE: be mindful of UNITY_2021_2_OR_NEWER (Local & GlobalKeyword were introduced there)
FragmentKeywords . Add ( new LocalKeyword ( shader , keyword ) ) ;
}
}
protected void BlitFragment ( CommandBuffer commandBuffer )
{
commandBuffer . DrawProcedural ( Matrix4x4 . identity , FragmentMaterial , FragmentPass , MeshTopology . Triangles , 3 , 1 , FragmentProperties ) ;
}
private static IEnumerable < string > GetKeywords ( Asr . InitializationFlags flags )
{
bool useLut = false ;
#if UNITY_2022_1_OR_NEWER // This will also work in 2020.3.43+ and 2021.3.14+
if ( SystemInfo . computeSubGroupSize = = 6 4 )
@ -89,12 +141,12 @@ namespace ArmASR
#endif
// This matches the permutation rules from the CreatePipeline* functions
if ( ( flags & Asr . InitializationFlags . EnableHighDynamicRange ) ! = 0 ) ComputeShader . EnableKeyword ( "FFXM_FSR2_OPTION_HDR_COLOR_INPUT" ) ;
if ( ( flags & Asr . InitializationFlags . EnableDisplayResolutionMotionVectors ) = = 0 ) ComputeShader . EnableKeyword ( "FFXM_FSR2_OPTION_LOW_RESOLUTION_MOTION_VECTORS" ) ;
if ( ( flags & Asr . InitializationFlags . EnableMotionVectorsJitterCancellation ) ! = 0 ) ComputeShader . EnableKeyword ( "FFXM_FSR2_OPTION_JITTERED_MOTION_VECTORS" ) ;
if ( ( flags & Asr . InitializationFlags . EnableDepthInverted ) ! = 0 ) ComputeShader . EnableKeyword ( "FFXM_FSR2_OPTION_INVERTED_DEPTH" ) ;
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 . EnableHighDynamicRange ) ! = 0 ) yield return "FFXM_FSR2_OPTION_HDR_COLOR_INPUT" ;
if ( ( flags & Asr . InitializationFlags . EnableDisplayResolutionMotionVectors ) = = 0 ) yield return "FFXM_FSR2_OPTION_LOW_RESOLUTION_MOTION_VECTORS" ;
if ( ( flags & Asr . InitializationFlags . EnableMotionVectorsJitterCancellation ) ! = 0 ) yield return "FFXM_FSR2_OPTION_JITTERED_MOTION_VECTORS" ;
if ( ( flags & Asr . InitializationFlags . EnableDepthInverted ) ! = 0 ) yield return "FFXM_FSR2_OPTION_INVERTED_DEPTH" ;
if ( useLut ) yield return "FFXM_FSR2_OPTION_REPROJECT_USE_LANCZOS_TYPE" ;
if ( ( flags & Asr . InitializationFlags . EnableFP16Usage ) ! = 0 ) yield return "FFXM_HALF" ;
}
[Conditional("ENABLE_PROFILER")]
@ -124,8 +176,7 @@ namespace ArmASR
protected override void DoScheduleDispatch ( CommandBuffer commandBuffer , Asr . DispatchDescription dispatchParams , int frameIndex , int dispatchX , int dispatchY )
{
ref var color = ref dispatchParams . Color ;
commandBuffer . SetComputeTextureParam ( ComputeShader , KernelIndex , AsrShaderIDs . SrvInputColor , color . RenderTarget , color . MipLevel , color . SubElement ) ;
commandBuffer . SetComputeResourceParam ( ComputeShader , KernelIndex , AsrShaderIDs . SrvInputColor , dispatchParams . Color ) ;
commandBuffer . SetComputeTextureParam ( ComputeShader , KernelIndex , AsrShaderIDs . UavSpdAtomicCount , Resources . SpdAtomicCounter ) ;
commandBuffer . SetComputeTextureParam ( ComputeShader , KernelIndex , AsrShaderIDs . UavExposureMipLumaChange , Resources . SceneLuminance , ShadingChangeMipLevel ) ;
@ -144,26 +195,21 @@ namespace ArmASR
public AsrReconstructPreviousDepthPass ( Asr . ContextDescription contextDescription , AsrResources resources , ComputeBuffer constants )
: base ( contextDescription , resources , constants )
{
InitCompute Shader ( "Reconstruct & Dilate" , contextDescription . Shaders . reconstructPreviousDepthPass ) ;
InitFragment Shader ( "Reconstruct & Dilate" , contextDescription . Shaders . fragmentShader , 1 ) ;
}
protected override void DoScheduleDispatch ( CommandBuffer commandBuffer , Asr . DispatchDescription dispatchParams , int frameIndex , int dispatchX , int dispatchY )
{
ref var color = ref dispatchParams . Color ;
ref var depth = ref dispatchParams . Depth ;
ref var motionVectors = ref dispatchParams . MotionVectors ;
ref var exposure = ref dispatchParams . Exposure ;
commandBuffer . SetGlobalResource ( AsrShaderIDs . SrvInputColor , dispatchParams . Color ) ;
commandBuffer . SetGlobalResource ( AsrShaderIDs . SrvInputDepth , dispatchParams . Depth ) ;
commandBuffer . SetGlobalResource ( AsrShaderIDs . SrvInputMotionVectors , dispatchParams . MotionVectors ) ;
commandBuffer . SetGlobalResource ( AsrShaderIDs . SrvInputExposure , dispatchParams . Exposure ) ;
commandBuffer . SetComputeTextureParam ( ComputeShader , KernelIndex , AsrShaderIDs . SrvInputColor , color . RenderTarget , color . MipLevel , color . SubElement ) ;
commandBuffer . SetComputeTextureParam ( ComputeShader , KernelIndex , AsrShaderIDs . SrvInputDepth , depth . RenderTarget , depth . MipLevel , depth . SubElement ) ;
commandBuffer . SetComputeTextureParam ( ComputeShader , KernelIndex , AsrShaderIDs . SrvInputMotionVectors , motionVectors . RenderTarget , motionVectors . MipLevel , motionVectors . SubElement ) ;
commandBuffer . SetComputeTextureParam ( ComputeShader , KernelIndex , AsrShaderIDs . SrvInputExposure , exposure . RenderTarget , exposure . MipLevel , exposure . SubElement ) ;
commandBuffer . SetComputeTextureParam ( ComputeShader , KernelIndex , AsrShaderIDs . UavDilatedMotionVectors , Resources . DilatedMotionVectors [ frameIndex ] ) ;
// TODO: this actually needs to be the render target
commandBuffer . SetGlobalTexture ( AsrShaderIDs . UavDilatedMotionVectors , Resources . DilatedMotionVectors [ frameIndex ] ) ;
commandBuffer . SetComputeConstantBufferParam ( ComputeShader , AsrShaderIDs . CbFsr2 , Constants , 0 , Constants . stride ) ;
commandBuffer . DispatchCompute ( ComputeShader , KernelIndex , dispatchX , dispatchY , 1 ) ;
FragmentProperties . SetConstantBuffer ( AsrShaderIDs . CbFsr2 , Constants , 0 , Constants . stride ) ;
BlitFragment ( commandBuffer ) ;
}
}
@ -172,33 +218,25 @@ namespace ArmASR
public AsrDepthClipPass ( Asr . ContextDescription contextDescription , AsrResources resources , ComputeBuffer constants )
: base ( contextDescription , resources , constants )
{
InitCompute Shader ( "Depth Clip" , contextDescription . Shaders . depthClipPass ) ;
InitFragment Shader ( "Depth Clip" , contextDescription . Shaders . fragmentShader , 2 ) ;
}
protected override void DoScheduleDispatch ( CommandBuffer commandBuffer , Asr . DispatchDescription dispatchParams , int frameIndex , int dispatchX , int dispatchY )
{
ref var color = ref dispatchParams . Color ;
ref var depth = ref dispatchParams . Depth ;
ref var motionVectors = ref dispatchParams . MotionVectors ;
ref var exposure = ref dispatchParams . Exposure ;
ref var reactive = ref dispatchParams . Reactive ;
ref var tac = ref dispatchParams . TransparencyAndComposition ;
commandBuffer . SetComputeTextureParam ( ComputeShader , KernelIndex , AsrShaderIDs . SrvInputColor , color . RenderTarget , color . MipLevel , color . SubElement ) ;
commandBuffer . SetComputeTextureParam ( ComputeShader , KernelIndex , AsrShaderIDs . SrvInputDepth , depth . RenderTarget , depth . MipLevel , depth . SubElement ) ;
commandBuffer . SetComputeTextureParam ( ComputeShader , KernelIndex , AsrShaderIDs . SrvInputMotionVectors , motionVectors . RenderTarget , motionVectors . MipLevel , motionVectors . SubElement ) ;
commandBuffer . SetComputeTextureParam ( ComputeShader , KernelIndex , AsrShaderIDs . SrvInputExposure , exposure . RenderTarget , exposure . MipLevel , exposure . SubElement ) ;
commandBuffer . SetComputeTextureParam ( ComputeShader , KernelIndex , AsrShaderIDs . SrvReactiveMask , reactive . RenderTarget , reactive . MipLevel , reactive . SubElement ) ;
commandBuffer . SetComputeTextureParam ( ComputeShader , KernelIndex , AsrShaderIDs . SrvTransparencyAndCompositionMask , tac . RenderTarget , tac . MipLevel , tac . SubElement ) ;
commandBuffer . SetComputeTextureParam ( ComputeShader , KernelIndex , AsrShaderIDs . SrvReconstructedPrevNearestDepth , AsrShaderIDs . UavReconstructedPrevNearestDepth ) ;
commandBuffer . SetComputeTextureParam ( ComputeShader , KernelIndex , AsrShaderIDs . SrvDilatedMotionVectors , Resources . DilatedMotionVectors [ frameIndex ] ) ;
commandBuffer . SetComputeTextureParam ( ComputeShader , KernelIndex , AsrShaderIDs . SrvDilatedDepth , AsrShaderIDs . UavDilatedDepth ) ;
commandBuffer . SetComputeTextureParam ( ComputeShader , KernelIndex , AsrShaderIDs . SrvPrevDilatedMotionVectors , Resources . DilatedMotionVectors [ frameIndex ^ 1 ] ) ;
commandBuffer . SetComputeConstantBufferParam ( ComputeShader , AsrShaderIDs . CbFsr2 , Constants , 0 , Constants . stride ) ;
commandBuffer . DispatchCompute ( ComputeShader , KernelIndex , dispatchX , dispatchY , 1 ) ;
commandBuffer . SetGlobalResource ( AsrShaderIDs . SrvInputColor , dispatchParams . Color ) ;
commandBuffer . SetGlobalResource ( AsrShaderIDs . SrvInputDepth , dispatchParams . Depth ) ;
commandBuffer . SetGlobalResource ( AsrShaderIDs . SrvInputMotionVectors , dispatchParams . MotionVectors ) ;
commandBuffer . SetGlobalResource ( AsrShaderIDs . SrvInputExposure , dispatchParams . Exposure ) ;
commandBuffer . SetGlobalResource ( AsrShaderIDs . SrvReactiveMask , dispatchParams . Reactive ) ;
commandBuffer . SetGlobalResource ( AsrShaderIDs . SrvTransparencyAndCompositionMask , dispatchParams . TransparencyAndComposition ) ;
commandBuffer . SetGlobalTexture ( AsrShaderIDs . SrvReconstructedPrevNearestDepth , AsrShaderIDs . UavReconstructedPrevNearestDepth ) ;
commandBuffer . SetGlobalTexture ( AsrShaderIDs . SrvDilatedMotionVectors , Resources . DilatedMotionVectors [ frameIndex ] ) ;
commandBuffer . SetGlobalTexture ( AsrShaderIDs . SrvDilatedDepth , AsrShaderIDs . UavDilatedDepth ) ;
commandBuffer . SetGlobalTexture ( AsrShaderIDs . SrvPrevDilatedMotionVectors , Resources . DilatedMotionVectors [ frameIndex ^ 1 ] ) ;
FragmentProperties . SetConstantBuffer ( AsrShaderIDs . CbFsr2 , Constants , 0 , Constants . stride ) ;
BlitFragment ( commandBuffer ) ;
}
}
@ -230,9 +268,9 @@ namespace ArmASR
public AsrAccumulatePass ( Asr . ContextDescription contextDescription , AsrResources resources , ComputeBuffer constants )
: base ( contextDescription , resources , constants )
{
InitCompute Shader ( "Reproject & Accumulate" , contextDescription . Shaders . accumulatePass ) ;
InitFragment Shader ( "Reproject & Accumulate" , contextDescription . Shaders . fr agmentShader , 3 ) ;
#if UNITY_2021_2_OR_NEWER
_sharpeningKeyword = new LocalKeyword ( ComputeShader , SharpeningKeyword ) ;
_sharpeningKeyword = new LocalKeyword ( ComputeShader , SharpeningKeyword ) ; // TODO: dynamically enable this on MaterialPropertyBlock
#endif
}
@ -252,37 +290,35 @@ namespace ArmASR
if ( ( ContextDescription . Flags & Asr . InitializationFlags . EnableDisplayResolutionMotionVectors ) = = 0 )
{
commandBuffer . SetComputeTextureParam ( ComputeShader , KernelIndex , AsrShaderIDs . SrvDilatedMotionVectors , Resources . DilatedMotionVectors [ frameIndex ] ) ;
commandBuffer . SetGlobalTexture ( AsrShaderIDs . SrvDilatedMotionVectors , Resources . DilatedMotionVectors [ frameIndex ] ) ;
}
else
{
ref var motionVectors = ref dispatchParams . MotionVectors ;
commandBuffer . SetComputeTextureParam ( ComputeShader , KernelIndex , AsrShaderIDs . SrvInputMotionVectors , motionVectors . RenderTarget , motionVectors . MipLevel , motionVectors . SubElement ) ;
commandBuffer . SetGlobalResource ( AsrShaderIDs . SrvInputMotionVectors , dispatchParams . MotionVectors ) ;
}
ref var exposure = ref dispatchParams . Exposure ;
commandBuffer . SetComputeTextureParam ( ComputeShader , KernelIndex , AsrShaderIDs . SrvInputExposure , exposure . RenderTarget , exposure . MipLevel , exposure . SubElement ) ;
commandBuffer . SetComputeTextureParam ( ComputeShader , KernelIndex , AsrShaderIDs . SrvDilatedReactiveMasks , AsrShaderIDs . UavDilatedReactiveMasks ) ;
commandBuffer . SetComputeTextureParam ( ComputeShader , KernelIndex , AsrShaderIDs . SrvInternalUpscaled , Resources . InternalUpscaled [ frameIndex ^ 1 ] ) ;
commandBuffer . SetComputeTextureParam ( ComputeShader , KernelIndex , AsrShaderIDs . SrvLockStatus , Resources . LockStatus [ frameIndex ^ 1 ] ) ;
commandBuffer . SetComputeTextureParam ( ComputeShader , KernelIndex , AsrShaderIDs . SrvPreparedInputColor , AsrShaderIDs . UavPreparedInputColor ) ;
commandBuffer . SetComputeTextureParam ( ComputeShader , KernelIndex , AsrShaderIDs . SrvLanczo sLut , Resources . Lanczo sLut) ;
commandBuffer . SetComputeTextureParam ( ComputeShader , KernelIndex , AsrShaderIDs . SrvUpscaleMaximumBiasLut , Resources . MaximumBiasLut ) ;
commandBuffer . SetComputeTextureParam ( ComputeShader , KernelIndex , AsrShaderIDs . SrvSceneLuminanceMips , Resources . SceneLuminanc e) ;
commandBuffer . SetComputeTextureParam ( ComputeShader , KernelIndex , AsrShaderIDs . SrvAutoExposure , Resources . AutoExposure ) ;
commandBuffer . SetComputeTextureParam ( ComputeShader , KernelIndex , AsrShaderIDs . SrvLumaHistory , Resources . LumaHistory [ frameIndex ^ 1 ] ) ;
commandBuffer . SetComputeTextureParam ( ComputeShader , KernelIndex , AsrShaderIDs . UavInternalUpscaled , Resources . InternalUpscaled [ frameIndex ] ) ;
commandBuffer . SetComputeTextureParam ( ComputeShader , KernelIndex , AsrShaderIDs . UavLockStatus , Resources . LockStatus [ frameIndex ] ) ;
commandBuffer . SetComputeTextureParam ( ComputeShader , KernelIndex , AsrShaderIDs . UavLumaHistory , Resources . LumaHistory [ frameIndex ] ) ;
commandBuffer . SetGlobalResource ( AsrShaderIDs . SrvInputExposure , dispatchParams . Exposure ) ;
commandBuffer . SetGlobalTexture ( AsrShaderIDs . SrvDilatedReactiveMasks , AsrShaderIDs . UavDilatedReactiveMasks ) ;
commandBuffer . SetGlobalTexture ( AsrShaderIDs . SrvInternalUpscaled , Resources . InternalUpscaled [ frameIndex ^ 1 ] ) ;
commandBuffer . SetGlobalTexture ( AsrShaderIDs . SrvLockStatus , Resources . LockStatus [ frameIndex ^ 1 ] ) ;
commandBuffer . SetGlobalTexture ( AsrShaderIDs . SrvPreparedInputColor , AsrShaderIDs . UavPreparedInputColor ) ;
commandBuffer . SetGlobalTexture ( AsrShaderIDs . SrvLanczosLut , Resources . LanczosLut ) ;
commandBuffer . SetGlobalTexture ( AsrShaderIDs . SrvUpscaleMaximumBia sLut , Resources . MaximumBia sLut) ;
commandBuffer . SetGlobalTexture ( AsrShaderIDs . SrvSceneLuminanceMips , Resources . SceneLuminance ) ;
commandBuffer . SetGlobalTexture ( AsrShaderIDs . SrvAutoExposure , Resources . AutoExposur e) ;
commandBuffer . SetGlobalTexture ( AsrShaderIDs . SrvLumaHistory , Resources . LumaHistory [ frameIndex ^ 1 ] ) ;
// TODO: these need to be multi-render targets (and also vary depending on the ASR preset used)
commandBuffer . SetGlobalTexture ( AsrShaderIDs . UavInternalUpscaled , Resources . InternalUpscaled [ frameIndex ] ) ;
commandBuffer . SetGlobalTexture ( AsrShaderIDs . UavLockStatus , Resources . LockStatus [ frameIndex ] ) ;
commandBuffer . SetGlobalTexture ( AsrShaderIDs . UavLumaHistory , Resources . LumaHistory [ frameIndex ] ) ;
ref var output = ref dispatchParams . Output ;
commandBuffer . SetComputeTextureParam ( ComputeShader , KernelIndex , AsrShaderIDs . UavUpscaledOutput , output . RenderTarget , output . MipLevel , output . SubElemen t) ;
// TODO: this actually needs to be the render target
commandBuffer . SetGlobalResource ( AsrShaderIDs . UavUpscaledOutput , dispatchParams . Outpu t) ;
commandBuffer . SetComputeConstantBufferParam ( ComputeShader , AsrShaderIDs . CbFsr2 , Constants , 0 , Constants . stride ) ;
commandBuffer . DispatchCompute ( ComputeShader , KernelIndex , dispatchX , dispatchY , 1 ) ;
FragmentProperties . SetConstantBuffer ( AsrShaderIDs . CbFsr2 , Constants , 0 , Constants . stride ) ;
BlitFragment ( commandBuffer ) ;
}
}
@ -295,22 +331,20 @@ namespace ArmASR
{
_rcasConstants = rcasConstants ;
InitCompute Shader ( "RCAS Sharpening" , contextDescription . Shaders . sharpenPass ) ;
InitFragment Shader ( "RCAS Sharpening" , contextDescription . Shaders . fragmentShader , 4 ) ;
}
protected override void DoScheduleDispatch ( CommandBuffer commandBuffer , Asr . DispatchDescription dispatchParams , int frameIndex , int dispatchX , int dispatchY )
{
ref var exposure = ref dispatchParams . Exposure ;
commandBuffer . SetComputeTextureParam ( ComputeShader , KernelIndex , AsrShaderIDs . SrvInputExposure , exposure . RenderTarget , exposure . MipLevel , exposure . SubElement ) ;
commandBuffer . SetComputeTextureParam ( ComputeShader , KernelIndex , AsrShaderIDs . SrvRcasInput , Resources . InternalUpscaled [ frameIndex ] ) ;
commandBuffer . SetGlobalResource ( AsrShaderIDs . SrvInputExposure , dispatchParams . Exposure ) ;
commandBuffer . SetGlobalTexture ( AsrShaderIDs . SrvRcasInput , Resources . InternalUpscaled [ frameIndex ] ) ;
ref var output = ref dispatchParams . Output ;
commandBuffer . SetComputeTextureParam ( ComputeShader , KernelIndex , AsrShaderIDs . UavUpscaledOutput , output . RenderTarget , output . MipLevel , output . SubElemen t) ;
// TODO: this actually needs to be the render target
commandBuffer . SetGlobalResource ( AsrShaderIDs . UavUpscaledOutput , dispatchParams . Outpu t) ;
commandBuffer . SetComputeConstantBufferParam ( ComputeShader , AsrShaderIDs . CbFsr2 , Constants , 0 , Constants . stride ) ;
commandBuffer . SetComputeConstantBufferParam ( ComputeShader , AsrShaderIDs . CbRcas , _rcasConstants , 0 , _rcasConstants . stride ) ;
commandBuffer . DispatchCompute ( ComputeShader , KernelIndex , dispatchX , dispatchY , 1 ) ;
FragmentProperties . SetConstantBuffer ( AsrShaderIDs . CbFsr2 , Constants , 0 , Constants . stride ) ;
FragmentProperties . SetConstantBuffer ( AsrShaderIDs . CbRcas , _rcasConstants , 0 , _rcasConstants . stride ) ;
BlitFragment ( commandBuffer ) ;
}
}
@ -323,7 +357,7 @@ namespace ArmASR
{
_generateReactiveConstants = generateReactiveConstants ;
InitCompute Shader ( "Auto-Generate Reactive Mask" , contextDescription . Shaders . autoGenReactivePass ) ;
InitFragment Shader ( "Auto-Generate Reactive Mask" , contextDescription . Shaders . fragmentShader , 0 ) ;
}
protected override void DoScheduleDispatch ( CommandBuffer commandBuffer , Asr . DispatchDescription dispatchParams , int frameIndex , int dispatchX , int dispatchY )
@ -334,17 +368,14 @@ namespace ArmASR
{
BeginSample ( commandBuffer ) ;
ref var opaqueOnly = ref dispatchParams . ColorOpaqueOnly ;
ref var color = ref dispatchParams . ColorPreUpscale ;
ref var reactive = ref dispatchParams . OutReactive ;
commandBuffer . SetComputeResourceParam ( ComputeShader , KernelIndex , AsrShaderIDs . SrvOpaqueOnly , dispatchParams . ColorOpaqueOnly ) ;
commandBuffer . SetComputeResourceParam ( ComputeShader , KernelIndex , AsrShaderIDs . SrvInputColor , dispatchParams . ColorPreUpscale ) ;
commandBuffer . SetComputeTextureParam ( ComputeShader , KernelIndex , AsrShaderIDs . SrvOpaqueOnly , opaqueOnly . RenderTarget , opaqueOnly . MipLevel , opaqueOnly . SubElement ) ;
commandBuffer . SetComputeTextureParam ( ComputeShader , KernelIndex , AsrShaderIDs . SrvInputColor , color . RenderTarget , color . MipLevel , color . SubElement ) ;
commandBuffer . SetComputeTextureParam ( ComputeShader , KernelIndex , AsrShaderIDs . UavAutoReactive , reactive . RenderTarget , reactive . MipLevel , reactive . SubElement ) ;
// TODO: this actually needs to be the render target
commandBuffer . SetComputeResourceParam ( ComputeShader , KernelIndex , AsrShaderIDs . UavAutoReactive , dispatchParams . OutReactive ) ;
commandBuffer . SetComputeConstantBufferParam ( ComputeShader , AsrShaderIDs . CbGenReactive , _generateReactiveConstants , 0 , _generateReactiveConstants . stride ) ;
commandBuffer . DispatchCompute ( ComputeShader , KernelIndex , dispatchX , dispatchY , 1 ) ;
FragmentProperties . SetConstantBuffer ( AsrShaderIDs . CbGenReactive , _generateReactiveConstants , 0 , _generateReactiveConstants . stride ) ;
BlitFragment ( commandBuffer ) ;
EndSample ( commandBuffer ) ;
}