|
|
|
@ -36,7 +36,6 @@ namespace ArmASR |
|
|
|
private const int MaxQueuedFrames = 16; |
|
|
|
|
|
|
|
private Asr.ContextDescription _contextDescription; |
|
|
|
private CommandBuffer _commandBuffer; |
|
|
|
|
|
|
|
private AsrPass _computeLuminancePyramidPass; |
|
|
|
private AsrPass _reconstructPreviousDepthPass; |
|
|
|
@ -48,6 +47,7 @@ namespace ArmASR |
|
|
|
private AsrPass _tcrAutogeneratePass; |
|
|
|
|
|
|
|
private readonly AsrResources _resources = new AsrResources(); |
|
|
|
private readonly AsrKeywords _keywords = new AsrKeywords(); |
|
|
|
|
|
|
|
private ComputeBuffer _upscalerConstantsBuffer; |
|
|
|
private readonly Asr.UpscalerConstants[] _upscalerConstantsArray = { new Asr.UpscalerConstants() }; |
|
|
|
@ -65,8 +65,6 @@ namespace ArmASR |
|
|
|
private readonly Asr.GenerateReactiveConstants[] _generateReactiveConstantsArray = { new Asr.GenerateReactiveConstants() }; |
|
|
|
private ref Asr.GenerateReactiveConstants GenReactiveConsts => ref _generateReactiveConstantsArray[0]; |
|
|
|
|
|
|
|
private AsrKeywords _keywords = new(); |
|
|
|
|
|
|
|
private bool _firstExecution; |
|
|
|
private Vector2 _previousJitterOffset; |
|
|
|
private int _resourceFrameIndex; |
|
|
|
@ -74,7 +72,6 @@ namespace ArmASR |
|
|
|
public void Create(in Asr.ContextDescription contextDescription) |
|
|
|
{ |
|
|
|
_contextDescription = contextDescription; |
|
|
|
_commandBuffer = new CommandBuffer { name = "ASR" }; |
|
|
|
|
|
|
|
_upscalerConstantsBuffer = CreateConstantBuffer<Asr.UpscalerConstants>(); |
|
|
|
_spdConstantsBuffer = CreateConstantBuffer<Asr.SpdConstants>(); |
|
|
|
@ -119,19 +116,6 @@ namespace ArmASR |
|
|
|
DestroyConstantBuffer(ref _rcasConstantsBuffer); |
|
|
|
DestroyConstantBuffer(ref _spdConstantsBuffer); |
|
|
|
DestroyConstantBuffer(ref _upscalerConstantsBuffer); |
|
|
|
|
|
|
|
if (_commandBuffer != null) |
|
|
|
{ |
|
|
|
_commandBuffer.Dispose(); |
|
|
|
_commandBuffer = null; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
public void Dispatch(in Asr.DispatchDescription dispatchParams) |
|
|
|
{ |
|
|
|
_commandBuffer.Clear(); |
|
|
|
Dispatch(dispatchParams, _commandBuffer); |
|
|
|
Graphics.ExecuteCommandBuffer(_commandBuffer); |
|
|
|
} |
|
|
|
|
|
|
|
public void Dispatch(Asr.DispatchDescription dispatchParams, CommandBuffer commandBuffer) |
|
|
|
@ -174,8 +158,6 @@ namespace ArmASR |
|
|
|
const int threadGroupWorkRegionDim = 8; |
|
|
|
int dispatchSrcX = (UpscalerConsts.renderSize.x + (threadGroupWorkRegionDim - 1)) / threadGroupWorkRegionDim; |
|
|
|
int dispatchSrcY = (UpscalerConsts.renderSize.y + (threadGroupWorkRegionDim - 1)) / threadGroupWorkRegionDim; |
|
|
|
int dispatchDstX = (_contextDescription.DisplaySize.x + (threadGroupWorkRegionDim - 1)) / threadGroupWorkRegionDim; |
|
|
|
int dispatchDstY = (_contextDescription.DisplaySize.y + (threadGroupWorkRegionDim - 1)) / threadGroupWorkRegionDim; |
|
|
|
|
|
|
|
// Clear reconstructed depth for max depth store
|
|
|
|
if (resetAccumulation) |
|
|
|
@ -214,16 +196,16 @@ namespace ArmASR |
|
|
|
_computeLuminancePyramidPass.ScheduleDispatch(commandBuffer, dispatchParams, frameIndex, dispatchThreadGroupCount.x, dispatchThreadGroupCount.y); |
|
|
|
|
|
|
|
// Reconstruct previous depth
|
|
|
|
_reconstructPreviousDepthPass.ScheduleDispatch(commandBuffer, dispatchParams, frameIndex, dispatchSrcX, dispatchSrcY); |
|
|
|
_reconstructPreviousDepthPass.ScheduleDispatch(commandBuffer, dispatchParams, frameIndex); |
|
|
|
|
|
|
|
// Depth clip
|
|
|
|
_depthClipPass.ScheduleDispatch(commandBuffer, dispatchParams, frameIndex, dispatchSrcX, dispatchSrcY); |
|
|
|
_depthClipPass.ScheduleDispatch(commandBuffer, dispatchParams, frameIndex); |
|
|
|
|
|
|
|
// Create locks
|
|
|
|
_lockPass.ScheduleDispatch(commandBuffer, dispatchParams, frameIndex, dispatchSrcX, dispatchSrcY); |
|
|
|
|
|
|
|
// Accumulate
|
|
|
|
_accumulatePass.ScheduleDispatch(commandBuffer, dispatchParams, frameIndex, dispatchDstX, dispatchDstY); |
|
|
|
_accumulatePass.ScheduleDispatch(commandBuffer, dispatchParams, frameIndex); |
|
|
|
|
|
|
|
if (dispatchParams.EnableSharpening) |
|
|
|
{ |
|
|
|
@ -232,10 +214,7 @@ namespace ArmASR |
|
|
|
commandBuffer.SetBufferData(_rcasConstantsBuffer, _rcasConstantsArray); |
|
|
|
|
|
|
|
// Dispatch RCAS
|
|
|
|
const int threadGroupWorkRegionDimRcas = 16; |
|
|
|
int threadGroupsX = (_contextDescription.DisplaySize.x + threadGroupWorkRegionDimRcas - 1) / threadGroupWorkRegionDimRcas; |
|
|
|
int threadGroupsY = (_contextDescription.DisplaySize.y + threadGroupWorkRegionDimRcas - 1) / threadGroupWorkRegionDimRcas; |
|
|
|
_sharpenPass.ScheduleDispatch(commandBuffer, dispatchParams, frameIndex, threadGroupsX, threadGroupsY); |
|
|
|
_sharpenPass.ScheduleDispatch(commandBuffer, dispatchParams, frameIndex); |
|
|
|
} |
|
|
|
|
|
|
|
_resourceFrameIndex = (_resourceFrameIndex + 1) % MaxQueuedFrames; |
|
|
|
@ -245,13 +224,6 @@ namespace ArmASR |
|
|
|
commandBuffer.DisableShaderKeyword("UNITY_FFXM_TEXTURE2D_X_ARRAY"); |
|
|
|
} |
|
|
|
|
|
|
|
public void GenerateReactiveMask(in Asr.GenerateReactiveDescription dispatchParams) |
|
|
|
{ |
|
|
|
_commandBuffer.Clear(); |
|
|
|
GenerateReactiveMask(dispatchParams, _commandBuffer); |
|
|
|
Graphics.ExecuteCommandBuffer(_commandBuffer); |
|
|
|
} |
|
|
|
|
|
|
|
public void GenerateReactiveMask(in Asr.GenerateReactiveDescription dispatchParams, CommandBuffer commandBuffer) |
|
|
|
{ |
|
|
|
GenReactiveConsts.scale = dispatchParams.Scale; |
|
|
|
|