Skip to content

Porting most of post processing to Render graph #1038

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 13 commits into from
Jul 4, 2020

Conversation

FrancescoC-unity
Copy link
Contributor

Wowee that's a big one, ported most post processing stuff to render graph.

Still missing DoF (changed from when I started)
And custom PP.

Yamato: https://yamato.prd.cds.internal.unity3d.com/jobs/902-Graphics/tree/HDRP%252Fport-pp-to-rendergraph/.yamato%252Fall-hdrp_dxr.yml%2523All_HDRP_DXR_CUSTOM-REVISION/2638716/job

@FrancescoC-unity FrancescoC-unity self-assigned this Jun 29, 2020
@FrancescoC-unity FrancescoC-unity changed the base branch from master to HDRP/staging June 29, 2020 16:35
// Note: some platforms can't clear a partial render target so we directly draw black triangles
using (var builder = renderGraph.AddRenderPass<GuardBandPassData>("Guard Band Clear", out var passData, ProfilingSampler.Get(HDProfileId.GuardBandClear)))
{
passData.source = builder.ReadTexture(source);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't this be WriteTexture?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yup, my mistake (my brain saw source and put read :D )

if (m_PostProcessEnabled)
{
// // Temporal anti-aliasing goes first
// bool taaEnabled = false;
// Guard bands (also known as "horrible hack") to avoid bleeding previous RTHandle
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comment is duplicated in the static function

{
passData.source = builder.ReadTexture(source);
passData.parameters = PrepareExposureParameters(hdCamera);
passData.prevExposure = prevExposureHandle;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

An explicit Write/Read should still be done here.
The reason is that the pass needs to know that it writes to an imported texture so that it's considered as side effect and cannot be pruned.


if (m_Exposure.mode.value == ExposureMode.AutomaticHistogram)
{
passData.exposureDebugData = renderGraph.ImportTexture(m_DebugExposureData);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here.

passData.parameters = PrepareApplyExposureParameters(hdCamera);
RTHandle prevExp;
GrabExposureHistoryTextures(hdCamera, out prevExp, out _);
passData.prevExposure = renderGraph.ImportTexture(prevExp);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here: Read/Write required.

GrabExposureHistoryTextures(hdCamera, out prevExp, out _);
passData.prevExposure = renderGraph.ImportTexture(prevExp);

TextureHandle dest = renderGraph.CreateTexture(new TextureDesc(Vector2.one, true, true)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is repeated in several places. We could probably do a helper function to reduce code footprint

passData.depthBuffer = builder.ReadTexture(depthBuffer);
passData.motionVecTexture = builder.ReadTexture(motionVectors);
passData.depthMipChain = builder.ReadTexture(depthBufferMipChain);
passData.prevHistory = renderGraph.ImportTexture(prevHistory);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Read/Write

{
var cs = exposureParameters.exposureCS;
int kernel;

var sourceTex = colorBuffer;

// NOTE: Breakpoint here.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

stray comment?

@@ -60,7 +60,9 @@ class AfterPostProcessPassData
parameters.blueNoise,
inputColor,
afterPostProcessBuffer,
depthBuffer,
prepassOutput.depthBuffer,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Was this tested with MSAA?
I think we need prepassOutput.resolvedDepthBuffer here

@@ -217,7 +217,7 @@ class TempPassData { };

aovRequest.PushCameraTexture(m_RenderGraph, AOVBuffers.Color, hdCamera, colorBuffer, aovBuffers);

TextureHandle postProcessDest = RenderPostProcess(m_RenderGraph, colorBuffer, prepassOutput.resolvedDepthBuffer, backBuffer, cullingResults, hdCamera);
TextureHandle postProcessDest = RenderPostProcess(m_RenderGraph, prepassOutput, colorBuffer, backBuffer, cullingResults, hdCamera);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See comment above, this will cause a regression.

Copy link
Contributor

@JulienIgnace-Unity JulienIgnace-Unity left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Made a few comments on some reccuring patterns otherwise looks good.
Also discussed directly with Francesco the possibility of splitting the huge function into smaller one per pass to make it more readable.

@FrancescoC-unity
Copy link
Contributor Author

Addressed stuff from this review, will split into smaller functions when I am done with the dof conversion (another PR)

@sebastienlagarde sebastienlagarde merged commit bee2058 into HDRP/staging Jul 4, 2020
@sebastienlagarde sebastienlagarde deleted the HDRP/port-pp-to-rendergraph branch July 4, 2020 19:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants