Skip to content

Commit 63181d8

Browse files
Partner/crazyhunter 10.6.0 custom.1 rendergraph (#25)
* Some code was accessing the rendergraph through a global var instead of their local argument * Split ExecuteWithRenderGraph * ProbeVolume upload code will now execute in the RenderGraph if available * Import shared ProbeVolumesRenderGraphResources only once per frame * Fixed debug mode Co-authored-by: Guillermo Gijon <[email protected]>
1 parent b779872 commit 63181d8

File tree

9 files changed

+1023
-749
lines changed

9 files changed

+1023
-749
lines changed

com.unity.render-pipelines.high-definition/Runtime/Lighting/ProbeVolume/ProbeVolumeLighting.cs

Lines changed: 384 additions & 120 deletions
Large diffs are not rendered by default.

com.unity.render-pipelines.high-definition/Runtime/Lighting/Shadow/ScreenSpaceShadowManager.RenderGraph.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ TextureHandle EvaluateShadowDebugView(RenderGraph renderGraph, HDCamera hdCamera
3434
{
3535
// If this is the right debug mode and the index we are asking for is in the range
3636
if (!rayTracingSupported || (m_ScreenSpaceShadowChannelSlot <= m_CurrentDebugDisplaySettings.data.screenSpaceShadowIndex))
37-
return m_RenderGraph.defaultResources.blackTextureXR;
37+
return renderGraph.defaultResources.blackTextureXR;
3838

3939
using (var builder = renderGraph.AddRenderPass<ScreenSpaceShadowDebugPassData>("Screen Space Shadows Debug", out var passData, ProfilingSampler.Get(HDProfileId.ScreenSpaceShadowsDebug)))
4040
{
@@ -140,7 +140,7 @@ TextureHandle RenderScreenSpaceShadows(RenderGraph renderGraph, HDCamera hdCamer
140140
{
141141
// If screen space shadows are not supported for this camera, we are done
142142
if (!hdCamera.frameSettings.IsEnabled(FrameSettingsField.ScreenSpaceShadows) || !RequestedScreenSpaceShadows())
143-
return m_RenderGraph.defaultResources.blackTextureArrayXR;
143+
return renderGraph.defaultResources.blackTextureArrayXR;
144144

145145
using (new RenderGraphProfilingScope(renderGraph, ProfilingSampler.Get(HDProfileId.ScreenSpaceShadows)))
146146
{
@@ -158,7 +158,7 @@ TextureHandle RenderScreenSpaceShadows(RenderGraph renderGraph, HDCamera hdCamer
158158

159159
// We render the debug view, if the texture is not used, it is not evaluated anyway
160160
TextureHandle screenSpaceShadowDebug = EvaluateShadowDebugView(renderGraph, hdCamera, screenSpaceShadowTexture);
161-
PushFullScreenDebugTexture(m_RenderGraph, screenSpaceShadowDebug, FullScreenDebugMode.ScreenSpaceShadows);
161+
PushFullScreenDebugTexture(renderGraph, screenSpaceShadowDebug, FullScreenDebugMode.ScreenSpaceShadows);
162162

163163
return screenSpaceShadowTexture;
164164
}

com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/HDRenderPipeline.Debug.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -254,7 +254,7 @@ void RenderProbeVolumeDebugOverlay(RenderGraph renderGraph, in DebugParameters d
254254
passData.depthBuffer = builder.UseDepthBuffer(depthBuffer, DepthAccess.ReadWrite);
255255

256256
builder.SetRenderFunc(
257-
(DebugLightLoopOverlayPassData data, RenderGraphContext ctx) =>
257+
(DebugOverlayPassData data, RenderGraphContext ctx) =>
258258
{
259259
RenderProbeVolumeDebugOverlay(data.debugParameters, ctx.cmd);
260260
});

com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/HDRenderPipeline.LightLoop.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -253,7 +253,7 @@ void PushGlobalCameraParams(RenderGraph renderGraph, HDCamera hdCamera)
253253

254254
internal ShadowResult RenderShadows(RenderGraph renderGraph, HDCamera hdCamera, CullingResults cullResults, ref ShadowResult result)
255255
{
256-
m_ShadowManager.RenderShadows(m_RenderGraph, m_ShaderVariablesGlobalCB, hdCamera, cullResults, ref result);
256+
m_ShadowManager.RenderShadows(renderGraph, m_ShaderVariablesGlobalCB, hdCamera, cullResults, ref result);
257257
// Need to restore global camera parameters.
258258
PushGlobalCameraParams(renderGraph, hdCamera);
259259
return result;

com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/HDRenderPipeline.Prepass.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -218,7 +218,7 @@ PrepassOutput RenderPrepass(RenderGraph renderGraph,
218218
BuildGPULightListOutput probeVolumeListOutput = new BuildGPULightListOutput();
219219
if (hdCamera.frameSettings.IsEnabled(FrameSettingsField.ProbeVolume) && ShaderConfig.s_ProbeVolumesEvaluationMode == ProbeVolumesEvaluationModes.MaterialPass)
220220
{
221-
probeVolumeListOutput = BuildGPULightList(m_RenderGraph, hdCamera, m_ProbeVolumeClusterData, m_ProbeVolumeCount, ref m_ShaderVariablesProbeVolumeLightListCB, result.depthBuffer, result.stencilBuffer, result.gbuffer);
221+
probeVolumeListOutput = BuildGPULightList(renderGraph, hdCamera, m_ProbeVolumeClusterData, m_ProbeVolumeCount, ref m_ShaderVariablesProbeVolumeLightListCB, result.depthBuffer, result.stencilBuffer, result.gbuffer);
222222
}
223223

224224
bool shouldRenderMotionVectorAfterGBuffer = RenderDepthPrepass(renderGraph, cullingResults, hdCamera, ref result, out var decalBuffer);

com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/HDRenderPipeline.RenderGraph.cs

Lines changed: 17 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,22 @@ class TempPassData { };
1313
// Needed only because of custom pass. See comment at ResolveMSAAColor.
1414
TextureHandle m_NonMSAAColorBuffer;
1515

16+
private void BeginRenderGraph(ScriptableRenderContext renderContext, CommandBuffer commandBuffer)
17+
{
18+
var renderGraphParams = new RenderGraphParameters()
19+
{
20+
scriptableRenderContext = renderContext,
21+
commandBuffer = commandBuffer,
22+
currentFrameIndex = m_FrameCount
23+
};
24+
25+
m_RenderGraph.Begin(renderGraphParams);
26+
}
27+
1628
void ExecuteWithRenderGraph(RenderRequest renderRequest,
1729
AOVRequestData aovRequest,
1830
List<RTHandle> aovBuffers,
19-
List<RTHandle> aovCustomPassBuffers,
20-
ScriptableRenderContext renderContext,
21-
CommandBuffer commandBuffer)
31+
List<RTHandle> aovCustomPassBuffers)
2232
{
2333
var hdCamera = renderRequest.hdCamera;
2434
var camera = hdCamera.camera;
@@ -27,15 +37,6 @@ void ExecuteWithRenderGraph(RenderRequest renderRequest,
2737
bool msaa = hdCamera.frameSettings.IsEnabled(FrameSettingsField.MSAA);
2838
var target = renderRequest.target;
2939

30-
var renderGraphParams = new RenderGraphParameters()
31-
{
32-
scriptableRenderContext = renderContext,
33-
commandBuffer = commandBuffer,
34-
currentFrameIndex = m_FrameCount
35-
};
36-
37-
m_RenderGraph.Begin(renderGraphParams);
38-
3940
// We need to initalize the MipChainInfo here, so it will be available to any render graph pass that wants to use it during setup
4041
// Be careful, ComputePackedMipChainInfo needs the render texture size and not the viewport size. Otherwise it would compute the wrong size.
4142
m_DepthBufferMipChainInfo.ComputePackedMipChainInfo(RTHandles.rtHandleProperties.currentRenderTargetSize);
@@ -283,7 +284,7 @@ void ExecuteWithRenderGraph(RenderRequest renderRequest,
283284
}
284285
PushFullScreenExposureDebugTexture(m_RenderGraph, postProcessDest);
285286

286-
ResetCameraSizeForAfterPostProcess(m_RenderGraph, hdCamera, commandBuffer);
287+
ResetCameraSizeForAfterPostProcess(m_RenderGraph, hdCamera);
287288

288289
RenderCustomPass(m_RenderGraph, hdCamera, postProcessDest, prepassOutput, customPassCullingResults, CustomPassInjectionPoint.AfterPostProcess, aovRequest, aovCustomPassBuffers);
289290

@@ -338,15 +339,6 @@ void ExecuteWithRenderGraph(RenderRequest renderRequest,
338339
RenderGizmos(m_RenderGraph, hdCamera, colorBuffer, GizmoSubset.PostImageEffects);
339340

340341
m_RenderGraph.Execute();
341-
342-
if (aovRequest.isValid)
343-
{
344-
// aovRequest.Execute don't go through render graph for now
345-
using (new ProfilingScope(commandBuffer, ProfilingSampler.Get(HDProfileId.AOVExecute)))
346-
{
347-
aovRequest.Execute(commandBuffer, aovBuffers, aovCustomPassBuffers, RenderOutputProperties.From(hdCamera));
348-
}
349-
}
350342
}
351343

352344
class FinalBlitPassData
@@ -947,7 +939,7 @@ TextureHandle RenderTransparency(RenderGraph renderGraph,
947939
// TODO RENDERGRAPH: Remove this when we properly convert custom passes to full render graph with explicit color buffer reads.
948940
// To allow users to fetch the current color buffer, we temporarily bind the camera color buffer
949941
SetGlobalColorForCustomPass(renderGraph, colorBuffer);
950-
RenderCustomPass(m_RenderGraph, hdCamera, colorBuffer, prepassOutput, customPassCullingResults, CustomPassInjectionPoint.BeforePreRefraction, aovRequest, aovCustomPassBuffers);
942+
RenderCustomPass(renderGraph, hdCamera, colorBuffer, prepassOutput, customPassCullingResults, CustomPassInjectionPoint.BeforePreRefraction, aovRequest, aovCustomPassBuffers);
951943
SetGlobalColorForCustomPass(renderGraph, currentColorPyramid);
952944

953945
// Render pre-refraction objects
@@ -960,7 +952,7 @@ TextureHandle RenderTransparency(RenderGraph renderGraph,
960952
}
961953

962954
// We don't have access to the color pyramid with transparent if rough refraction is disabled
963-
RenderCustomPass(m_RenderGraph, hdCamera, colorBuffer, prepassOutput, customPassCullingResults, CustomPassInjectionPoint.BeforeTransparent, aovRequest, aovCustomPassBuffers);
955+
RenderCustomPass(renderGraph, hdCamera, colorBuffer, prepassOutput, customPassCullingResults, CustomPassInjectionPoint.BeforeTransparent, aovRequest, aovCustomPassBuffers);
964956

965957
// Render all type of transparent forward (unlit, lit, complex (hair...)) to keep the sorting between transparent objects.
966958
RenderForwardTransparent(renderGraph, hdCamera, colorBuffer, normalBuffer, prepassOutput, vtFeedbackBuffer, volumetricLighting, ssrLightingBuffer, currentColorPyramid, lightLists, shadowResult, cullingResults, false);
@@ -1581,7 +1573,7 @@ class ResetCameraSizeForAfterPostProcessPassData
15811573
public ShaderVariablesGlobal shaderVariablesGlobal;
15821574
}
15831575

1584-
void ResetCameraSizeForAfterPostProcess(RenderGraph renderGraph, HDCamera hdCamera, CommandBuffer commandBuffer)
1576+
void ResetCameraSizeForAfterPostProcess(RenderGraph renderGraph, HDCamera hdCamera)
15851577
{
15861578
if (DynamicResolutionHandler.instance.DynamicResolutionEnabled())
15871579
{

0 commit comments

Comments
 (0)