|
|
|
@ -19,16 +19,12 @@ namespace UnityEngine.Rendering.PostProcessing |
|
|
|
|
|
|
|
public abstract void Render(PostProcessRenderContext context, Upscaling config); |
|
|
|
|
|
|
|
private ConstantsBuffer<PrepareInputsConstants> _prepareInputsConstants; |
|
|
|
|
|
|
|
protected bool PrepareInputs(CommandBuffer cmd, PostProcessRenderContext context, Upscaling config, RenderTexture rwColor = null, RenderTexture rwDepth = null, RenderTexture rwMotionVectors = null) |
|
|
|
{ |
|
|
|
ComputeShader shader = context.resources.computeShaders.prepareInputs; |
|
|
|
if (shader == null) |
|
|
|
return false; |
|
|
|
|
|
|
|
_prepareInputsConstants ??= ConstantsBuffer<PrepareInputsConstants>.Create(); |
|
|
|
|
|
|
|
Vector2Int scaledRenderSize = config.GetScaledRenderSize(context.camera); |
|
|
|
|
|
|
|
const int threadGroupWorkRegionDim = 8; |
|
|
|
@ -37,11 +33,6 @@ namespace UnityEngine.Rendering.PostProcessing |
|
|
|
|
|
|
|
cmd.BeginSample("Prepare Inputs"); |
|
|
|
|
|
|
|
_prepareInputsConstants.Value.prepareColor = rwColor != null ? 1 : 0; |
|
|
|
_prepareInputsConstants.Value.prepareDepth = rwDepth != null ? 1 : 0; |
|
|
|
_prepareInputsConstants.Value.prepareMotionVectors = rwMotionVectors != null ? 1 : 0; |
|
|
|
_prepareInputsConstants.UpdateBufferData(cmd); |
|
|
|
|
|
|
|
int kernelIndex = shader.FindKernel("CS"); |
|
|
|
cmd.SetComputeTextureParam(shader, kernelIndex, "InColor", context.source, 0, RenderTextureSubElement.Color); |
|
|
|
cmd.SetComputeTextureParam(shader, kernelIndex, "InDepth", Upscaling.GetDepthTexture(context.camera), 0, RenderTextureSubElement.Depth); |
|
|
|
@ -51,22 +42,11 @@ namespace UnityEngine.Rendering.PostProcessing |
|
|
|
cmd.SetComputeTextureParam(shader, kernelIndex, "OutDepth", rwDepth != null ? rwDepth : BuiltinRenderTextureType.None); |
|
|
|
cmd.SetComputeTextureParam(shader, kernelIndex, "OutMotionVectors", rwMotionVectors != null ? rwMotionVectors : BuiltinRenderTextureType.None); |
|
|
|
|
|
|
|
cmd.SetComputeConstantBufferParam(shader, "Params", _prepareInputsConstants, 0, Marshal.SizeOf<PrepareInputsConstants>()); |
|
|
|
|
|
|
|
cmd.DispatchCompute(shader, kernelIndex, dispatchSrcX, dispatchSrcY, 1); |
|
|
|
|
|
|
|
cmd.EndSample("Prepare Inputs"); |
|
|
|
return true; |
|
|
|
} |
|
|
|
|
|
|
|
[Serializable, StructLayout(LayoutKind.Sequential)] |
|
|
|
internal struct PrepareInputsConstants |
|
|
|
{ |
|
|
|
public int prepareColor; |
|
|
|
public int prepareDepth; |
|
|
|
public int prepareMotionVectors; |
|
|
|
public int pad; |
|
|
|
} |
|
|
|
|
|
|
|
private ConstantsBuffer<GenerateReactiveConstants> _reactiveMaskConstants; |
|
|
|
private RenderTexture _reactiveMask; |
|
|
|
|