|
|
|
@ -71,10 +71,10 @@ namespace ArmASR |
|
|
|
private Vector2 _previousJitterOffset; |
|
|
|
private int _resourceFrameIndex; |
|
|
|
|
|
|
|
public void Create(Asr.ContextDescription contextDescription) |
|
|
|
public void Create(in Asr.ContextDescription contextDescription) |
|
|
|
{ |
|
|
|
_contextDescription = contextDescription; |
|
|
|
_commandBuffer = new CommandBuffer { name = "Arm ASR" }; |
|
|
|
_commandBuffer = new CommandBuffer { name = "ASR" }; |
|
|
|
|
|
|
|
_upscalerConstantsBuffer = CreateConstantBuffer<Asr.UpscalerConstants>(); |
|
|
|
_spdConstantsBuffer = CreateConstantBuffer<Asr.SpdConstants>(); |
|
|
|
@ -127,7 +127,7 @@ namespace ArmASR |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
public void Dispatch(Asr.DispatchDescription dispatchParams) |
|
|
|
public void Dispatch(in Asr.DispatchDescription dispatchParams) |
|
|
|
{ |
|
|
|
_commandBuffer.Clear(); |
|
|
|
Dispatch(dispatchParams, _commandBuffer); |
|
|
|
@ -198,7 +198,7 @@ namespace ArmASR |
|
|
|
commandBuffer.ClearRenderTarget(false, true, Color.clear); |
|
|
|
} |
|
|
|
|
|
|
|
// FSR3: need to clear here since we need the content of this surface for frame interpolation, so clearing in the lock pass is not an option
|
|
|
|
// Need to clear here since we need the content of this surface for frame interpolation, so clearing in the lock pass is not an option
|
|
|
|
bool depthInverted = (_contextDescription.Flags & Asr.InitializationFlags.EnableDepthInverted) == Asr.InitializationFlags.EnableDepthInverted; |
|
|
|
commandBuffer.SetRenderTarget(AsrShaderIDs.UavReconstructedPrevNearestDepth); |
|
|
|
commandBuffer.ClearRenderTarget(false, true, depthInverted ? Color.clear : Color.white); |
|
|
|
@ -245,29 +245,25 @@ namespace ArmASR |
|
|
|
commandBuffer.DisableShaderKeyword("UNITY_FFXM_TEXTURE2D_X_ARRAY"); |
|
|
|
} |
|
|
|
|
|
|
|
public void GenerateReactiveMask(Asr.GenerateReactiveDescription dispatchParams) |
|
|
|
public void GenerateReactiveMask(in Asr.GenerateReactiveDescription dispatchParams) |
|
|
|
{ |
|
|
|
_commandBuffer.Clear(); |
|
|
|
GenerateReactiveMask(dispatchParams, _commandBuffer); |
|
|
|
Graphics.ExecuteCommandBuffer(_commandBuffer); |
|
|
|
} |
|
|
|
|
|
|
|
public void GenerateReactiveMask(Asr.GenerateReactiveDescription dispatchParams, CommandBuffer commandBuffer) |
|
|
|
public void GenerateReactiveMask(in Asr.GenerateReactiveDescription dispatchParams, CommandBuffer commandBuffer) |
|
|
|
{ |
|
|
|
const int threadGroupWorkRegionDim = 8; |
|
|
|
int dispatchSrcX = (dispatchParams.RenderSize.x + (threadGroupWorkRegionDim - 1)) / threadGroupWorkRegionDim; |
|
|
|
int dispatchSrcY = (dispatchParams.RenderSize.y + (threadGroupWorkRegionDim - 1)) / threadGroupWorkRegionDim; |
|
|
|
|
|
|
|
GenReactiveConsts.scale = dispatchParams.Scale; |
|
|
|
GenReactiveConsts.threshold = dispatchParams.CutoffThreshold; |
|
|
|
GenReactiveConsts.binaryValue = dispatchParams.BinaryValue; |
|
|
|
GenReactiveConsts.flags = (uint)dispatchParams.Flags; |
|
|
|
commandBuffer.SetBufferData(_generateReactiveConstantsBuffer, _generateReactiveConstantsArray); |
|
|
|
|
|
|
|
((AsrGenerateReactivePass)_generateReactivePass).ScheduleDispatch(commandBuffer, dispatchParams, dispatchSrcX, dispatchSrcY); |
|
|
|
((AsrGenerateReactivePass)_generateReactivePass).ScheduleDispatch(commandBuffer, dispatchParams); |
|
|
|
} |
|
|
|
|
|
|
|
private void SetupConstants(Asr.DispatchDescription dispatchParams, bool resetAccumulation) |
|
|
|
private void SetupConstants(in Asr.DispatchDescription dispatchParams, bool resetAccumulation) |
|
|
|
{ |
|
|
|
ref Asr.UpscalerConstants constants = ref UpscalerConsts; |
|
|
|
|
|
|
|
@ -331,7 +327,7 @@ namespace ArmASR |
|
|
|
constants.lumaMipDimensions.y = (int)(constants.maxRenderSize.y / mipDiv); |
|
|
|
} |
|
|
|
|
|
|
|
private Vector4 SetupDeviceDepthToViewSpaceDepthParams(Asr.DispatchDescription dispatchParams) |
|
|
|
private Vector4 SetupDeviceDepthToViewSpaceDepthParams(in Asr.DispatchDescription dispatchParams) |
|
|
|
{ |
|
|
|
bool inverted = (_contextDescription.Flags & Asr.InitializationFlags.EnableDepthInverted) != 0; |
|
|
|
bool infinite = (_contextDescription.Flags & Asr.InitializationFlags.EnableDepthInfinite) != 0; |
|
|
|
@ -364,13 +360,13 @@ namespace ArmASR |
|
|
|
1.0f / cotHalfFovY); |
|
|
|
} |
|
|
|
|
|
|
|
private void SetupRcasConstants(Asr.DispatchDescription dispatchParams) |
|
|
|
private void SetupRcasConstants(in Asr.DispatchDescription dispatchParams) |
|
|
|
{ |
|
|
|
int sharpnessIndex = Mathf.RoundToInt(Mathf.Clamp01(dispatchParams.Sharpness) * (RcasConfigs.Length - 1)); |
|
|
|
RcasConsts = RcasConfigs[sharpnessIndex]; |
|
|
|
} |
|
|
|
|
|
|
|
private void SetupSpdConstants(Asr.DispatchDescription dispatchParams, out Vector2Int dispatchThreadGroupCount) |
|
|
|
private void SetupSpdConstants(in Asr.DispatchDescription dispatchParams, out Vector2Int dispatchThreadGroupCount) |
|
|
|
{ |
|
|
|
RectInt rectInfo = new RectInt(0, 0, dispatchParams.RenderSize.x, dispatchParams.RenderSize.y); |
|
|
|
SpdSetup(rectInfo, out dispatchThreadGroupCount, out var workGroupOffset, out var numWorkGroupsAndMips); |
|
|
|
@ -402,7 +398,7 @@ namespace ArmASR |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
private void DebugCheckDispatch(Asr.DispatchDescription dispatchParams) |
|
|
|
private void DebugCheckDispatch(in Asr.DispatchDescription dispatchParams) |
|
|
|
{ |
|
|
|
if (!dispatchParams.Color.IsValid) |
|
|
|
{ |
|
|
|
|