diff --git a/com.unity.render-pipelines.core/Runtime/RenderGraph/RenderGraph.cs b/com.unity.render-pipelines.core/Runtime/RenderGraph/RenderGraph.cs
index 66b2f157838..0d05b85aff6 100644
--- a/com.unity.render-pipelines.core/Runtime/RenderGraph/RenderGraph.cs
+++ b/com.unity.render-pipelines.core/Runtime/RenderGraph/RenderGraph.cs
@@ -20,7 +20,7 @@ public enum DepthAccess
}
///
- /// This struct specifies the context given to every render pass.
+ /// This class specifies the context given to every render pass.
///
public class RenderGraphContext
{
@@ -30,8 +30,6 @@ public class RenderGraphContext
public CommandBuffer cmd;
///Render Graph pooll used for temporary data.
public RenderGraphObjectPool renderGraphPool;
- ///Render Graph Resource Registry used for accessing resources.
- public RenderGraphResourceRegistry resources;
///Render Graph default resources.
public RenderGraphDefaultResources defaultResources;
}
@@ -403,7 +401,7 @@ public void Execute(ScriptableRenderContext renderContext, CommandBuffer cmd, in
{
m_Logger.Initialize();
- m_Resources.BeginRender(parameters.renderingWidth, parameters.renderingHeight, parameters.msaaSamples, parameters.currentFrameIndex);
+ m_Resources.BeginRender(parameters.currentFrameIndex);
LogFrameInformation(parameters.renderingWidth, parameters.renderingHeight);
@@ -426,6 +424,8 @@ public void Execute(ScriptableRenderContext renderContext, CommandBuffer cmd, in
m_DebugParameters.logFrameInformation = false;
m_DebugParameters.logResources = false;
+
+ m_Resources.EndRender();
}
}
#endregion
@@ -814,7 +814,6 @@ void ExecuteRenderGraph(ScriptableRenderContext renderContext, CommandBuffer cmd
m_RenderGraphContext.cmd = cmd;
m_RenderGraphContext.renderContext = renderContext;
m_RenderGraphContext.renderGraphPool = m_RenderGraphPool;
- m_RenderGraphContext.resources = m_Resources;
m_RenderGraphContext.defaultResources = m_DefaultResources;
for (int passIndex = 0; passIndex < m_CompiledPassInfos.size; ++passIndex)
diff --git a/com.unity.render-pipelines.core/Runtime/RenderGraph/RenderGraphResourceRegistry.cs b/com.unity.render-pipelines.core/Runtime/RenderGraph/RenderGraphResourceRegistry.cs
index 521b97aa8e3..8847f3825d3 100644
--- a/com.unity.render-pipelines.core/Runtime/RenderGraph/RenderGraphResourceRegistry.cs
+++ b/com.unity.render-pipelines.core/Runtime/RenderGraph/RenderGraphResourceRegistry.cs
@@ -5,13 +5,30 @@
namespace UnityEngine.Experimental.Rendering.RenderGraphModule
{
- ///
- /// The RenderGraphResourceRegistry holds all resource allocated during Render Graph execution.
- ///
- public class RenderGraphResourceRegistry
+ class RenderGraphResourceRegistry
{
static readonly ShaderTagId s_EmptyName = new ShaderTagId("");
+ static RenderGraphResourceRegistry m_CurrentRegistry;
+ internal static RenderGraphResourceRegistry current
+ {
+ get
+ {
+ // We assume that it's enough to only check in editor because we don't want to pay the cost at runtime.
+#if UNITY_EDITOR
+ if (m_CurrentRegistry == null)
+ {
+ throw new InvalidOperationException("Current Render Graph Resource Registry is not set. You are probably trying to cast a Render Graph handle to a resource outside of a Render Graph Pass.");
+ }
+#endif
+ return m_CurrentRegistry;
+ }
+ set
+ {
+ m_CurrentRegistry = value;
+ }
+ }
+
class IRenderGraphResource
{
public bool imported;
@@ -100,13 +117,7 @@ internal RendererListResource(in RendererListDesc desc)
RTHandle m_CurrentBackbuffer;
- #region Public Interface
- ///
- /// Returns the RTHandle associated with the provided resource handle.
- ///
- /// Handle to a texture resource.
- /// The RTHandle associated with the provided resource handle or null if the handle is invalid.
- public RTHandle GetTexture(in TextureHandle handle)
+ internal RTHandle GetTexture(in TextureHandle handle)
{
if (!handle.IsValid())
return null;
@@ -114,12 +125,7 @@ public RTHandle GetTexture(in TextureHandle handle)
return GetTextureResource(handle.handle).resource;
}
- ///
- /// Returns the RendererList associated with the provided resource handle.
- ///
- /// Handle to a Renderer List resource.
- /// The Renderer List associated with the provided resource handle or an invalid renderer list if the handle is invalid.
- public RendererList GetRendererList(in RendererListHandle handle)
+ internal RendererList GetRendererList(in RendererListHandle handle)
{
if (!handle.IsValid() || handle >= m_RendererListResources.size)
return RendererList.nullRendererList;
@@ -127,19 +133,13 @@ public RendererList GetRendererList(in RendererListHandle handle)
return m_RendererListResources[handle].rendererList;
}
- ///
- /// Returns the Compute Buffer associated with the provided resource handle.
- ///
- /// Handle to a Compute Buffer resource.
- /// The Compute Buffer associated with the provided resource handle or a null reference if the handle is invalid.
- public ComputeBuffer GetComputeBuffer(in ComputeBufferHandle handle)
+ internal ComputeBuffer GetComputeBuffer(in ComputeBufferHandle handle)
{
if (!handle.IsValid())
return null;
return GetComputeBufferResource(handle.handle).resource;
}
- #endregion
#region Internal Interface
private RenderGraphResourceRegistry()
@@ -172,9 +172,15 @@ ResType GetResource(DynamicArray resour
return res.resource;
}
- internal void BeginRender(int width, int height, MSAASamples msaaSamples, int currentFrameIndex)
+ internal void BeginRender(int currentFrameIndex)
{
m_CurrentFrameIndex = currentFrameIndex;
+ current = this;
+ }
+
+ internal void EndRender()
+ {
+ current = null;
}
void CheckHandleValidity(in ResourceHandle res)
diff --git a/com.unity.render-pipelines.core/Runtime/RenderGraph/RenderGraphResources.cs b/com.unity.render-pipelines.core/Runtime/RenderGraph/RenderGraphResources.cs
index a7cb0d31c03..6c86aabcb11 100644
--- a/com.unity.render-pipelines.core/Runtime/RenderGraph/RenderGraphResources.cs
+++ b/com.unity.render-pipelines.core/Runtime/RenderGraph/RenderGraphResources.cs
@@ -14,7 +14,7 @@ internal enum RenderGraphResourceType
// Can't have a default constructor with handle = -1 hence the ugly IsValid implementation (where m_IsValid will be false by default).
internal struct ResourceHandle
{
- bool m_IsValid;
+ bool m_IsValid;
public int index { get; private set; }
public RenderGraphResourceType type { get; private set; }
@@ -53,6 +53,22 @@ public struct TextureHandle
internal TextureHandle(int handle) { this.handle = new ResourceHandle(handle, RenderGraphResourceType.Texture); }
+ ///
+ /// Cast to RTHandle
+ ///
+ /// Input TextureHandle.
+ public static implicit operator RTHandle(TextureHandle texture) => texture.IsValid() ? RenderGraphResourceRegistry.current.GetTexture(texture) : null;
+ ///
+ /// Cast to RenderTargetIdentifier
+ ///
+ /// Input TextureHandle.
+ public static implicit operator RenderTargetIdentifier(TextureHandle texture) => texture.IsValid() ? RenderGraphResourceRegistry.current.GetTexture(texture) : null;
+ ///
+ /// Cast to RenderTexture
+ ///
+ /// Input TextureHandle.
+ public static implicit operator RenderTexture(TextureHandle texture) => texture.IsValid() ? RenderGraphResourceRegistry.current.GetTexture(texture) : null;
+
///
/// Return true if the handle is valid.
///
@@ -70,6 +86,12 @@ public struct ComputeBufferHandle
internal ComputeBufferHandle(int handle) { this.handle = new ResourceHandle(handle, RenderGraphResourceType.ComputeBuffer); }
+ ///
+ /// Cast to ComputeBuffer
+ ///
+ /// Input ComputeBufferHandle
+ public static implicit operator ComputeBuffer(ComputeBufferHandle buffer) => buffer.IsValid() ? RenderGraphResourceRegistry.current.GetComputeBuffer(buffer) : null;
+
///
/// Return true if the handle is valid.
///
@@ -93,6 +115,8 @@ public struct RendererListHandle
/// The integer representation of the handle.
public static implicit operator int(RendererListHandle handle) { return handle.handle; }
+ public static implicit operator RendererList(RendererListHandle rendererList) => rendererList.IsValid() ? RenderGraphResourceRegistry.current.GetRendererList(rendererList) : RendererList.nullRendererList;
+
///
/// Return true if the handle is valid.
///
diff --git a/com.unity.render-pipelines.high-definition/Runtime/Lighting/ScreenSpaceLighting/AmbientOcclusion.RenderGraph.cs b/com.unity.render-pipelines.high-definition/Runtime/Lighting/ScreenSpaceLighting/AmbientOcclusion.RenderGraph.cs
index 065d388cba1..51dc68f4f0f 100644
--- a/com.unity.render-pipelines.high-definition/Runtime/Lighting/ScreenSpaceLighting/AmbientOcclusion.RenderGraph.cs
+++ b/com.unity.render-pipelines.high-definition/Runtime/Lighting/ScreenSpaceLighting/AmbientOcclusion.RenderGraph.cs
@@ -68,7 +68,7 @@ TextureHandle RenderAO(RenderGraph renderGraph, in RenderAOParameters parameters
builder.SetRenderFunc(
(RenderAOPassData data, RenderGraphContext ctx) =>
{
- RenderAO(data.parameters, ctx.resources.GetTexture(data.packedData), ctx.resources.GetTexture(data.depthPyramid), ctx.resources.GetTexture(data.normalBuffer), ctx.cmd);
+ RenderAO(data.parameters, data.packedData, data.depthPyramid, data.normalBuffer, ctx.cmd);
});
return passData.packedData;
@@ -124,13 +124,12 @@ TextureHandle DenoiseAO( RenderGraph renderGraph,
builder.SetRenderFunc(
(DenoiseAOPassData data, RenderGraphContext ctx) =>
{
- var res = ctx.resources;
DenoiseAO( data.parameters,
- res.GetTexture(data.packedData),
- res.GetTexture(data.packedDataBlurred),
- res.GetTexture(data.currentHistory),
- res.GetTexture(data.outputHistory),
- res.GetTexture(data.denoiseOutput),
+ data.packedData,
+ data.packedDataBlurred,
+ data.currentHistory,
+ data.outputHistory,
+ data.denoiseOutput,
ctx.cmd);
});
@@ -161,7 +160,7 @@ TextureHandle UpsampleAO(RenderGraph renderGraph, in RenderAOParameters paramete
builder.SetRenderFunc(
(UpsampleAOPassData data, RenderGraphContext ctx) =>
{
- UpsampleAO(data.parameters, ctx.resources.GetTexture(data.input), ctx.resources.GetTexture(data.output), ctx.cmd);
+ UpsampleAO(data.parameters, data.input, data.output, ctx.cmd);
});
return passData.output;
diff --git a/com.unity.render-pipelines.high-definition/Runtime/Lighting/Shadow/HDShadowManager.RenderGraph.cs b/com.unity.render-pipelines.high-definition/Runtime/Lighting/Shadow/HDShadowManager.RenderGraph.cs
index a07de453005..c0ae47a28b5 100644
--- a/com.unity.render-pipelines.high-definition/Runtime/Lighting/Shadow/HDShadowManager.RenderGraph.cs
+++ b/com.unity.render-pipelines.high-definition/Runtime/Lighting/Shadow/HDShadowManager.RenderGraph.cs
@@ -62,9 +62,9 @@ class BindShadowGlobalResourcesPassData
static void BindAtlasTexture(RenderGraphContext ctx, TextureHandle texture, int shaderId)
{
if (texture.IsValid())
- ctx.cmd.SetGlobalTexture(shaderId, ctx.resources.GetTexture(texture));
+ ctx.cmd.SetGlobalTexture(shaderId, texture);
else
- ctx.cmd.SetGlobalTexture(shaderId, ctx.resources.GetTexture(ctx.defaultResources.blackTexture));
+ ctx.cmd.SetGlobalTexture(shaderId, ctx.defaultResources.blackTexture);
}
void BindShadowGlobalResources(RenderGraph renderGraph, in ShadowResult shadowResult)
@@ -148,26 +148,22 @@ internal TextureHandle RenderShadows(RenderGraph renderGraph, CullingResults cul
builder.SetRenderFunc(
(RenderShadowsPassData data, RenderGraphContext context) =>
{
- RTHandle atlasTexture = context.resources.GetTexture(data.atlasTexture);
RenderShadows( data.parameters,
- atlasTexture,
+ data.atlasTexture,
data.shadowDrawSettings,
context.renderContext, context.cmd);
if (data.parameters.blurAlgorithm == BlurAlgorithm.EVSM)
{
RTHandle[] momentTextures = context.renderGraphPool.GetTempArray(2);
- momentTextures[0] = context.resources.GetTexture(data.momentAtlasTexture1);
- momentTextures[1] = context.resources.GetTexture(data.momentAtlasTexture2);
+ momentTextures[0] = data.momentAtlasTexture1;
+ momentTextures[1] = data.momentAtlasTexture2;
- EVSMBlurMoments(data.parameters, atlasTexture, momentTextures, context.cmd);
+ EVSMBlurMoments(data.parameters, data.atlasTexture, momentTextures, context.cmd);
}
else if (data.parameters.blurAlgorithm == BlurAlgorithm.IM)
{
- RTHandle momentAtlas = context.resources.GetTexture(data.momentAtlasTexture1);
- RTHandle intermediateSummedArea = context.resources.GetTexture(data.intermediateSummedAreaTexture);
- RTHandle summedArea = context.resources.GetTexture(data.summedAreaTexture);
- IMBlurMoment(data.parameters, atlasTexture, momentAtlas, intermediateSummedArea, summedArea, context.cmd);
+ IMBlurMoment(data.parameters, data.atlasTexture, data.momentAtlasTexture1, data.intermediateSummedAreaTexture, data.summedAreaTexture, context.cmd);
}
});
diff --git a/com.unity.render-pipelines.high-definition/Runtime/PostProcessing/PostProcessSystem.RenderGraph.cs b/com.unity.render-pipelines.high-definition/Runtime/PostProcessing/PostProcessSystem.RenderGraph.cs
index e1326b0d860..799116bf22b 100644
--- a/com.unity.render-pipelines.high-definition/Runtime/PostProcessing/PostProcessSystem.RenderGraph.cs
+++ b/com.unity.render-pipelines.high-definition/Runtime/PostProcessing/PostProcessSystem.RenderGraph.cs
@@ -196,10 +196,7 @@ public void Render(RenderGraph renderGraph,
builder.SetRenderFunc(
(AlphaCopyPassData data, RenderGraphContext ctx) =>
{
- DoCopyAlpha(data.parameters,
- ctx.resources.GetTexture(data.source),
- ctx.resources.GetTexture(data.outputAlpha),
- ctx.cmd);
+ DoCopyAlpha(data.parameters, data.source, data.outputAlpha, ctx.cmd);
});
alphaTexture = passData.outputAlpha;
@@ -216,7 +213,7 @@ public void Render(RenderGraph renderGraph,
builder.SetRenderFunc(
(GuardBandPassData data, RenderGraphContext ctx) =>
{
- ClearWithGuardBands(data.parameters, ctx.cmd, ctx.resources.GetTexture(data.source));
+ ClearWithGuardBands(data.parameters, ctx.cmd, data.source);
});
source = passData.source;
@@ -241,7 +238,7 @@ public void Render(RenderGraph renderGraph,
builder.SetRenderFunc(
(StopNaNPassData data, RenderGraphContext ctx) =>
{
- DoStopNaNs(data.parameters, ctx.cmd, ctx.resources.GetTexture(data.source), ctx.resources.GetTexture(data.destination));
+ DoStopNaNs(data.parameters, ctx.cmd, data.source, data.destination);
});
source = passData.destination;
@@ -274,10 +271,10 @@ public void Render(RenderGraph renderGraph,
builder.SetRenderFunc(
(DynamicExposureData data, RenderGraphContext ctx) =>
{
- DoHistogramBasedExposure(data.parameters, ctx.cmd, ctx.resources.GetTexture(data.source),
- ctx.resources.GetTexture(data.prevExposure),
- ctx.resources.GetTexture(data.nextExposure),
- ctx.resources.GetTexture(data.exposureDebugData));
+ DoHistogramBasedExposure(data.parameters, ctx.cmd, data.source,
+ data.prevExposure,
+ data.nextExposure,
+ data.exposureDebugData);
});
}
else
@@ -290,11 +287,11 @@ public void Render(RenderGraph renderGraph,
builder.SetRenderFunc(
(DynamicExposureData data, RenderGraphContext ctx) =>
{
- DoDynamicExposure(data.parameters, ctx.cmd, ctx.resources.GetTexture(data.source),
- ctx.resources.GetTexture(data.prevExposure),
- ctx.resources.GetTexture(data.nextExposure),
- ctx.resources.GetTexture(data.tmpTarget1024),
- ctx.resources.GetTexture(data.tmpTarget32));
+ DoDynamicExposure(data.parameters, ctx.cmd, data.source,
+ data.prevExposure,
+ data.nextExposure,
+ data.tmpTarget1024,
+ data.tmpTarget32);
});
}
}
@@ -315,7 +312,7 @@ public void Render(RenderGraph renderGraph,
builder.SetRenderFunc(
(ApplyExposureData data, RenderGraphContext ctx) =>
{
- ApplyExposure(data.parameters, ctx.cmd, ctx.resources.GetTexture(data.source), ctx.resources.GetTexture(data.destination), ctx.resources.GetTexture(data.prevExposure));
+ ApplyExposure(data.parameters, ctx.cmd, data.source, data.destination, data.prevExposure);
});
source = passData.destination;
@@ -367,15 +364,15 @@ public void Render(RenderGraph renderGraph,
builder.SetRenderFunc(
(TemporalAntiAliasingData data, RenderGraphContext ctx) =>
{
- DoTemporalAntialiasing(data.parameters, ctx.cmd, ctx.resources.GetTexture(data.source),
- ctx.resources.GetTexture(data.destination),
- ctx.resources.GetTexture(data.motionVecTexture),
- ctx.resources.GetTexture(data.depthBuffer),
- ctx.resources.GetTexture(data.depthMipChain),
- ctx.resources.GetTexture(data.prevHistory),
- ctx.resources.GetTexture(data.nextHistory),
- ctx.resources.GetTexture(data.prevMVLen),
- ctx.resources.GetTexture(data.nextMVLen));
+ DoTemporalAntialiasing(data.parameters, ctx.cmd, data.source,
+ data.destination,
+ data.motionVecTexture,
+ data.depthBuffer,
+ data.depthMipChain,
+ data.prevHistory,
+ data.nextHistory,
+ data.prevMVLen,
+ data.nextMVLen);
});
source = passData.destination;
@@ -400,11 +397,11 @@ public void Render(RenderGraph renderGraph,
builder.SetRenderFunc(
(SMAAData data, RenderGraphContext ctx) =>
{
- DoSMAA(data.parameters, ctx.cmd, ctx.resources.GetTexture(data.source),
- ctx.resources.GetTexture(data.smaaEdgeTex),
- ctx.resources.GetTexture(data.smaaBlendTex),
- ctx.resources.GetTexture(data.destination),
- ctx.resources.GetTexture(data.depthBuffer));
+ DoSMAA(data.parameters, ctx.cmd, data.source,
+ data.smaaEdgeTex,
+ data.smaaBlendTex,
+ data.destination,
+ data.depthBuffer);
});
source = passData.destination;
@@ -480,14 +477,14 @@ public void Render(RenderGraph renderGraph,
builder.SetRenderFunc(
(MotionBlurData data, RenderGraphContext ctx) =>
{
- DoMotionBlur(data.parameters, ctx.cmd, ctx.resources.GetTexture(data.source),
- ctx.resources.GetTexture(data.destination),
- ctx.resources.GetTexture(data.motionVecTexture),
- ctx.resources.GetTexture(data.preppedMotionVec),
- ctx.resources.GetTexture(data.minMaxTileVel),
- ctx.resources.GetTexture(data.maxTileNeigbourhood),
- ctx.resources.GetTexture(data.tileToScatterMax),
- ctx.resources.GetTexture(data.tileToScatterMin));
+ DoMotionBlur(data.parameters, ctx.cmd, data.source,
+ data.destination,
+ data.motionVecTexture,
+ data.preppedMotionVec,
+ data.minMaxTileVel,
+ data.maxTileNeigbourhood,
+ data.tileToScatterMax,
+ data.tileToScatterMin);
});
source = passData.destination;
@@ -511,7 +508,7 @@ public void Render(RenderGraph renderGraph,
builder.SetRenderFunc(
(PaniniProjectionData data, RenderGraphContext ctx) =>
{
- DoPaniniProjection(data.parameters, ctx.cmd, ctx.resources.GetTexture(data.source), ctx.resources.GetTexture(data.destination));
+ DoPaniniProjection(data.parameters, ctx.cmd, data.source, data.destination);
});
source = passData.destination;
@@ -539,11 +536,11 @@ public void Render(RenderGraph renderGraph,
for(int i=0; i
{
- DoColorGrading(data.parameters, ctx.resources.GetTexture(data.logLut), ctx.cmd);
+ DoColorGrading(data.parameters, data.logLut, ctx.cmd);
});
}
@@ -593,12 +590,12 @@ public void Render(RenderGraph renderGraph,
builder.SetRenderFunc(
(UberPostPassData data, RenderGraphContext ctx) =>
{
- DoUberPostProcess(data.parameters,
- ctx.resources.GetTexture(data.source),
- ctx.resources.GetTexture(data.destination),
- ctx.resources.GetTexture(data.logLut),
- ctx.resources.GetTexture(data.bloomTexture), // TODO: TMP VALUE, should be bloom texture and will be as soon as PP is ported to rendergraph.
- ctx.cmd);
+ DoUberPostProcess( data.parameters,
+ data.source,
+ data.destination,
+ data.logLut,
+ data.bloomTexture,
+ ctx.cmd);
});
source = passData.destination;
@@ -630,7 +627,7 @@ public void Render(RenderGraph renderGraph,
builder.SetRenderFunc(
(FXAAData data, RenderGraphContext ctx) =>
{
- DoFXAA(data.parameters, ctx.cmd, ctx.resources.GetTexture(data.source), ctx.resources.GetTexture(data.destination));
+ DoFXAA(data.parameters, ctx.cmd, data.source, data.destination);
});
source = passData.destination;
@@ -654,7 +651,7 @@ public void Render(RenderGraph renderGraph,
builder.SetRenderFunc(
(CASData data, RenderGraphContext ctx) =>
{
- DoContrastAdaptiveSharpening(data.parameters, ctx.cmd, ctx.resources.GetTexture(data.source), ctx.resources.GetTexture(data.destination));
+ DoContrastAdaptiveSharpening(data.parameters, ctx.cmd, data.source, data.destination);
});
source = passData.destination;
@@ -672,12 +669,7 @@ public void Render(RenderGraph renderGraph,
builder.SetRenderFunc(
(FinalPassData data, RenderGraphContext ctx) =>
{
- DoFinalPass(data.parameters,
- ctx.resources.GetTexture(data.source),
- ctx.resources.GetTexture(data.afterPostProcessTexture),
- ctx.resources.GetTexture(data.destination),
- ctx.resources.GetTexture(data.alphaTexture),
- ctx.cmd);
+ DoFinalPass(data.parameters, data.source, data.afterPostProcessTexture, data.destination, data.alphaTexture, ctx.cmd);
});
}
}
diff --git a/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/Camera/HDCamera.cs b/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/Camera/HDCamera.cs
index 2eb5e588c41..fc74d22ca21 100644
--- a/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/Camera/HDCamera.cs
+++ b/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/Camera/HDCamera.cs
@@ -768,16 +768,15 @@ internal void ExecuteCaptureActions(RenderGraph renderGraph, TextureHandle input
builder.SetRenderFunc(
(ExecuteCaptureActionsPassData data, RenderGraphContext ctx) =>
{
- var tempRT = ctx.resources.GetTexture(data.tempTexture);
var mpb = ctx.renderGraphPool.GetTempMaterialPropertyBlock();
- mpb.SetTexture(HDShaderIDs._BlitTexture, ctx.resources.GetTexture(data.input));
+ mpb.SetTexture(HDShaderIDs._BlitTexture, data.input);
mpb.SetVector(HDShaderIDs._BlitScaleBias, data.viewportScale);
mpb.SetFloat(HDShaderIDs._BlitMipLevel, 0);
- ctx.cmd.SetRenderTarget(tempRT);
+ ctx.cmd.SetRenderTarget(data.tempTexture);
ctx.cmd.DrawProcedural(Matrix4x4.identity, data.blitMaterial, 0, MeshTopology.Triangles, 3, 1, mpb);
for (data.recorderCaptureActions.Reset(); data.recorderCaptureActions.MoveNext();)
- data.recorderCaptureActions.Current(tempRT, ctx.cmd);
+ data.recorderCaptureActions.Current(data.tempTexture, ctx.cmd);
});
}
}
diff --git a/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/HDRenderPipeline.Debug.cs b/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/HDRenderPipeline.Debug.cs
index df68242484f..efbcddc6137 100644
--- a/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/HDRenderPipeline.Debug.cs
+++ b/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/HDRenderPipeline.Debug.cs
@@ -36,11 +36,11 @@ void RenderTransparencyOverdraw(RenderGraph renderGraph, TextureHandle depthBuff
(TransparencyOverdrawPassData data, RenderGraphContext ctx) =>
{
RenderTransparencyOverdraw( data.parameters,
- ctx.resources.GetTexture(data.output),
- ctx.resources.GetTexture(data.depthBuffer),
- ctx.resources.GetRendererList(data.transparencyRL),
- ctx.resources.GetRendererList(data.transparencyAfterPostRL),
- ctx.resources.GetRendererList(data.transparencyLowResRL),
+ data.output,
+ data.depthBuffer,
+ data.transparencyRL,
+ data.transparencyAfterPostRL,
+ data.transparencyLowResRL,
ctx.renderContext, ctx.cmd);
});
@@ -72,11 +72,7 @@ TextureHandle ResolveFullScreenDebug(RenderGraph renderGraph, in DebugParameters
builder.SetRenderFunc(
(ResolveFullScreenDebugPassData data, RenderGraphContext ctx) =>
{
- ResolveFullScreenDebug(data.debugParameters,
- ctx.renderGraphPool.GetTempMaterialPropertyBlock(),
- ctx.resources.GetTexture(data.input),
- ctx.resources.GetTexture(data.depthPyramid),
- ctx.resources.GetTexture(data.output), ctx.cmd);
+ ResolveFullScreenDebug(data.debugParameters, ctx.renderGraphPool.GetTempMaterialPropertyBlock(), data.input, data.depthPyramid, data.output, ctx.cmd);
});
return passData.output;
@@ -102,10 +98,7 @@ TextureHandle ResolveColorPickerDebug(RenderGraph renderGraph, in DebugParameter
builder.SetRenderFunc(
(ResolveColorPickerDebugPassData data, RenderGraphContext ctx) =>
{
- ResolveColorPickerDebug(data.debugParameters,
- ctx.resources.GetTexture(data.input),
- ctx.resources.GetTexture(data.output),
- ctx.cmd);
+ ResolveColorPickerDebug(data.debugParameters, data.input, data.output, ctx.cmd);
});
return passData.output;
@@ -157,20 +150,15 @@ void RenderDebugOverlays( RenderGraph renderGraph,
float y = debugParams.hdCamera.actualHeight - overlaySize;
var shadowAtlases = new HDShadowManager.ShadowDebugAtlasTextures();
- shadowAtlases.punctualShadowAtlas = data.shadowTextures.punctualShadowResult.IsValid() ? ctx.resources.GetTexture(data.shadowTextures.punctualShadowResult) : null;
- shadowAtlases.cascadeShadowAtlas = data.shadowTextures.directionalShadowResult.IsValid() ? ctx.resources.GetTexture(data.shadowTextures.directionalShadowResult) : null;
- shadowAtlases.areaShadowAtlas = data.shadowTextures.areaShadowResult.IsValid() ? ctx.resources.GetTexture(data.shadowTextures.areaShadowResult) : null;
- shadowAtlases.cachedPunctualShadowAtlas = data.shadowTextures.cachedPunctualShadowResult.IsValid() ? ctx.resources.GetTexture(data.shadowTextures.cachedPunctualShadowResult) : null;
- shadowAtlases.cachedAreaShadowAtlas = data.shadowTextures.cachedAreaShadowResult.IsValid() ? ctx.resources.GetTexture(data.shadowTextures.cachedAreaShadowResult) : null;
-
- ComputeBuffer tileBuffer = ctx.resources.GetComputeBuffer(data.tileList);
- ComputeBuffer lightListBuffer = ctx.resources.GetComputeBuffer(data.lightList);
- ComputeBuffer perVoxelLightListBuffer = ctx.resources.GetComputeBuffer(data.perVoxelLightList);
- ComputeBuffer dispatchIndirectBuffer = ctx.resources.GetComputeBuffer(data.dispatchIndirect);
+ shadowAtlases.punctualShadowAtlas = data.shadowTextures.punctualShadowResult;
+ shadowAtlases.cascadeShadowAtlas = data.shadowTextures.directionalShadowResult;
+ shadowAtlases.areaShadowAtlas = data.shadowTextures.areaShadowResult;
+ shadowAtlases.cachedPunctualShadowAtlas = data.shadowTextures.cachedPunctualShadowResult;
+ shadowAtlases.cachedAreaShadowAtlas = data.shadowTextures.cachedAreaShadowResult;
RenderSkyReflectionOverlay(debugParams, ctx.cmd, ctx.renderGraphPool.GetTempMaterialPropertyBlock(), ref x, ref y, overlaySize);
RenderRayCountOverlay(debugParams, ctx.cmd, ref x, ref y, overlaySize);
- RenderLightLoopDebugOverlay(debugParams, ctx.cmd, ref x, ref y, overlaySize, tileBuffer, lightListBuffer, perVoxelLightListBuffer, dispatchIndirectBuffer, ctx.resources.GetTexture(data.depthPyramidTexture));
+ RenderLightLoopDebugOverlay(debugParams, ctx.cmd, ref x, ref y, overlaySize, data.tileList, data.lightList, data.perVoxelLightList, data.dispatchIndirect, data.depthPyramidTexture);
RenderShadowsDebugOverlay(debugParams, shadowAtlases, ctx.cmd, ref x, ref y, overlaySize, ctx.renderGraphPool.GetTempMaterialPropertyBlock());
DecalSystem.instance.RenderDebugOverlay(debugParams.hdCamera, ctx.cmd, debugParams.debugDisplaySettings, ref x, ref y, overlaySize, debugParams.hdCamera.actualWidth);
});
@@ -209,18 +197,16 @@ static void RenderLightVolumes(RenderGraph renderGraph, in DebugParameters debug
(RenderLightVolumesPassData data, RenderGraphContext ctx) =>
{
RenderTargetIdentifier[] mrt = ctx.renderGraphPool.GetTempArray(2);
- var lightCountBuffer = ctx.resources.GetTexture(data.lightCountBuffer);
- var colorAccumulationBuffer = ctx.resources.GetTexture(data.colorAccumulationBuffer);
- mrt[0] = lightCountBuffer;
- mrt[1] = colorAccumulationBuffer;
+ mrt[0] = data.lightCountBuffer;
+ mrt[1] = data.colorAccumulationBuffer;
DebugLightVolumes.RenderLightVolumes( ctx.cmd,
data.parameters,
- mrt, lightCountBuffer,
- colorAccumulationBuffer,
- ctx.resources.GetTexture(data.debugLightVolumesTexture),
- ctx.resources.GetTexture(data.depthBuffer),
- ctx.resources.GetTexture(data.destination),
+ mrt, data.lightCountBuffer,
+ data.colorAccumulationBuffer,
+ data.debugLightVolumesTexture,
+ data.depthBuffer,
+ data.destination,
ctx.renderGraphPool.GetTempMaterialPropertyBlock());
});
}
@@ -310,8 +296,7 @@ TextureHandle RenderDebugViewMaterial(RenderGraph renderGraph, CullingResults cu
builder.SetRenderFunc(
(DebugViewMaterialData data, RenderGraphContext context) =>
{
- var res = context.resources;
- HDUtils.DrawFullScreen(context.cmd, data.debugGBufferMaterial, res.GetTexture(data.outputColor));
+ HDUtils.DrawFullScreen(context.cmd, data.debugGBufferMaterial, data.outputColor);
});
}
}
@@ -337,9 +322,8 @@ TextureHandle RenderDebugViewMaterial(RenderGraph renderGraph, CullingResults cu
builder.SetRenderFunc(
(DebugViewMaterialData data, RenderGraphContext context) =>
{
- var res = context.resources;
- DrawOpaqueRendererList(context, data.frameSettings, res.GetRendererList(data.opaqueRendererList));
- DrawTransparentRendererList(context, data.frameSettings, res.GetRendererList(data.transparentRendererList));
+ DrawOpaqueRendererList(context, data.frameSettings, data.opaqueRendererList);
+ DrawTransparentRendererList(context, data.frameSettings, data.transparentRendererList);
});
}
}
@@ -394,11 +378,10 @@ void PushFullScreenDebugTexture(RenderGraph renderGraph, TextureHandle input, in
builder.SetRenderFunc(
(PushFullScreenDebugPassData data, RenderGraphContext ctx) =>
{
- var texture = ctx.resources.GetTexture(data.input);
if (data.mipIndex != -1)
- HDUtils.BlitCameraTexture(ctx.cmd, texture, ctx.resources.GetTexture(data.output), data.mipIndex);
+ HDUtils.BlitCameraTexture(ctx.cmd, data.input, data.output, data.mipIndex);
else
- HDUtils.BlitCameraTexture(ctx.cmd, texture, ctx.resources.GetTexture(data.output));
+ HDUtils.BlitCameraTexture(ctx.cmd, data.input, data.output);
});
m_DebugFullScreenTexture = passData.output;
@@ -419,7 +402,7 @@ TextureHandle PushColorPickerDebugTexture(RenderGraph renderGraph, TextureHandle
builder.SetRenderFunc(
(PushFullScreenDebugPassData data, RenderGraphContext ctx) =>
{
- HDUtils.BlitCameraTexture(ctx.cmd, ctx.resources.GetTexture(data.input), ctx.resources.GetTexture(data.output));
+ HDUtils.BlitCameraTexture(ctx.cmd, data.input, data.output);
});
return passData.output;
diff --git a/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/HDRenderPipeline.LightLoop.cs b/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/HDRenderPipeline.LightLoop.cs
index cdf56cd61f0..82fa896ae5b 100644
--- a/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/HDRenderPipeline.LightLoop.cs
+++ b/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/HDRenderPipeline.LightLoop.cs
@@ -68,28 +68,28 @@ static BuildGPULightListResources PrepareBuildGPULightListResources(RenderGraphC
{
var buildLightListResources = new BuildGPULightListResources();
- buildLightListResources.depthBuffer = context.resources.GetTexture(data.depthBuffer);
- buildLightListResources.stencilTexture = context.resources.GetTexture(data.stencilTexture);
+ buildLightListResources.depthBuffer = data.depthBuffer;
+ buildLightListResources.stencilTexture = data.stencilTexture;
if (data.buildGPULightListParameters.computeMaterialVariants && data.buildGPULightListParameters.enableFeatureVariants)
{
buildLightListResources.gBuffer = context.renderGraphPool.GetTempArray(data.gBufferCount);
for (int i = 0; i < data.gBufferCount; ++i)
- buildLightListResources.gBuffer[i] = context.resources.GetTexture(data.gBuffer[i]);
+ buildLightListResources.gBuffer[i] = data.gBuffer[i];
}
- buildLightListResources.lightVolumeDataBuffer = context.resources.GetComputeBuffer(data.lightVolumeDataBuffer);
- buildLightListResources.convexBoundsBuffer = context.resources.GetComputeBuffer(data.convexBoundsBuffer);
- buildLightListResources.AABBBoundsBuffer = context.resources.GetComputeBuffer(data.AABBBoundsBuffer);
- buildLightListResources.globalLightListAtomic = context.resources.GetComputeBuffer(data.globalLightListAtomic);
+ buildLightListResources.lightVolumeDataBuffer = data.lightVolumeDataBuffer;
+ buildLightListResources.convexBoundsBuffer = data.convexBoundsBuffer;
+ buildLightListResources.AABBBoundsBuffer = data.AABBBoundsBuffer;
+ buildLightListResources.globalLightListAtomic = data.globalLightListAtomic;
- buildLightListResources.tileFeatureFlags = context.resources.GetComputeBuffer(data.output.tileFeatureFlags);
- buildLightListResources.dispatchIndirectBuffer = context.resources.GetComputeBuffer(data.output.dispatchIndirectBuffer);
- buildLightListResources.perVoxelOffset = context.resources.GetComputeBuffer(data.output.perVoxelOffset);
- buildLightListResources.perTileLogBaseTweak = context.resources.GetComputeBuffer(data.output.perTileLogBaseTweak);
- buildLightListResources.tileList = context.resources.GetComputeBuffer(data.output.tileList);
- buildLightListResources.bigTileLightList = context.resources.GetComputeBuffer(data.output.bigTileLightList);
- buildLightListResources.perVoxelLightLists = context.resources.GetComputeBuffer(data.output.perVoxelLightLists);
- buildLightListResources.lightList = context.resources.GetComputeBuffer(data.output.lightList);
+ buildLightListResources.tileFeatureFlags = data.output.tileFeatureFlags;
+ buildLightListResources.dispatchIndirectBuffer = data.output.dispatchIndirectBuffer;
+ buildLightListResources.perVoxelOffset = data.output.perVoxelOffset;
+ buildLightListResources.perTileLogBaseTweak = data.output.perTileLogBaseTweak;
+ buildLightListResources.tileList = data.output.tileList;
+ buildLightListResources.bigTileLightList = data.output.bigTileLightList;
+ buildLightListResources.perVoxelLightLists = data.output.perVoxelLightLists;
+ buildLightListResources.lightList = data.output.lightList;
return buildLightListResources;
}
@@ -321,33 +321,33 @@ LightingOutput RenderDeferredLighting( RenderGraph renderGraph,
var resources = new DeferredLightingResources();
resources.colorBuffers = context.renderGraphPool.GetTempArray(2);
- resources.colorBuffers[0] = context.resources.GetTexture(data.colorBuffer);
- resources.colorBuffers[1] = context.resources.GetTexture(data.sssDiffuseLightingBuffer);
- resources.depthStencilBuffer = context.resources.GetTexture(data.depthBuffer);
- resources.depthTexture = context.resources.GetTexture(data.depthTexture);
+ resources.colorBuffers[0] = data.colorBuffer;
+ resources.colorBuffers[1] = data.sssDiffuseLightingBuffer;
+ resources.depthStencilBuffer = data.depthBuffer;
+ resources.depthTexture = data.depthTexture;
- resources.lightListBuffer = context.resources.GetComputeBuffer(data.lightListBuffer);
- resources.tileFeatureFlagsBuffer = context.resources.GetComputeBuffer(data.tileFeatureFlagsBuffer);
- resources.tileListBuffer = context.resources.GetComputeBuffer(data.tileListBuffer);
- resources.dispatchIndirectBuffer = context.resources.GetComputeBuffer(data.dispatchIndirectBuffer);
+ resources.lightListBuffer = data.lightListBuffer;
+ resources.tileFeatureFlagsBuffer = data.tileFeatureFlagsBuffer;
+ resources.tileListBuffer = data.tileListBuffer;
+ resources.dispatchIndirectBuffer = data.dispatchIndirectBuffer;
// TODO RENDERGRAPH: try to find a better way to bind this.
// Issue is that some GBuffers have several names (for example normal buffer is both NormalBuffer and GBuffer1)
// So it's not possible to use auto binding via dependency to shaderTagID
// Should probably get rid of auto binding and go explicit all the way (might need to wait for us to remove non rendergraph code path).
for (int i = 0; i < data.gbufferCount; ++i)
- context.cmd.SetGlobalTexture(HDShaderIDs._GBufferTexture[i], context.resources.GetTexture(data.gbuffer[i]));
+ context.cmd.SetGlobalTexture(HDShaderIDs._GBufferTexture[i], data.gbuffer[i]);
if (data.lightLayersTextureIndex != -1)
- context.cmd.SetGlobalTexture(HDShaderIDs._LightLayersTexture, context.resources.GetTexture(data.gbuffer[data.lightLayersTextureIndex]));
+ context.cmd.SetGlobalTexture(HDShaderIDs._LightLayersTexture, data.gbuffer[data.lightLayersTextureIndex]);
else
context.cmd.SetGlobalTexture(HDShaderIDs._LightLayersTexture, TextureXR.GetWhiteTexture());
// TODO RENDERGRAPH: Remove these SetGlobal and properly send these textures to the deferred passes and bind them directly to compute shaders.
// This can wait that we remove the old code path.
- context.cmd.SetGlobalTexture(HDShaderIDs._AmbientOcclusionTexture, context.resources.GetTexture(data.lightingBuffers.ambientOcclusionBuffer));
- context.cmd.SetGlobalTexture(HDShaderIDs._SsrLightingTexture, context.resources.GetTexture(data.lightingBuffers.ssrLightingBuffer));
- context.cmd.SetGlobalTexture(HDShaderIDs._ContactShadowTexture, context.resources.GetTexture(data.lightingBuffers.contactShadowsBuffer));
+ context.cmd.SetGlobalTexture(HDShaderIDs._AmbientOcclusionTexture, data.lightingBuffers.ambientOcclusionBuffer);
+ context.cmd.SetGlobalTexture(HDShaderIDs._SsrLightingTexture, data.lightingBuffers.ssrLightingBuffer);
+ context.cmd.SetGlobalTexture(HDShaderIDs._ContactShadowTexture, data.lightingBuffers.contactShadowsBuffer);
if (data.parameters.enableTile)
{
@@ -439,18 +439,17 @@ TextureHandle RenderSSR( RenderGraph renderGraph,
builder.SetRenderFunc(
(RenderSSRPassData data, RenderGraphContext context) =>
{
- var res = context.resources;
RenderSSR(data.parameters,
- res.GetTexture(data.depthBuffer),
- res.GetTexture(data.depthPyramid),
- res.GetTexture(data.normalBuffer),
- res.GetTexture(data.motionVectorsBuffer),
- res.GetTexture(data.hitPointsTexture),
- res.GetTexture(data.stencilBuffer),
- res.GetTexture(data.clearCoatMask),
- res.GetTexture(data.colorPyramid),
- res.GetTexture(data.lightingTexture),
- res.GetComputeBuffer(data.coarseStencilBuffer),
+ data.depthBuffer,
+ data.depthPyramid,
+ data.normalBuffer,
+ data.motionVectorsBuffer,
+ data.hitPointsTexture,
+ data.stencilBuffer,
+ data.clearCoatMask,
+ data.colorPyramid,
+ data.lightingTexture,
+ data.coarseStencilBuffer,
context.cmd, context.renderContext);
});
@@ -502,8 +501,7 @@ TextureHandle RenderContactShadows(RenderGraph renderGraph, HDCamera hdCamera, T
builder.SetRenderFunc(
(RenderContactShadowPassData data, RenderGraphContext context) =>
{
- var res = context.resources;
- RenderContactShadows(data.parameters, res.GetTexture(data.contactShadowsTexture), res.GetTexture(data.depthTexture), data.lightLoopLightData, res.GetComputeBuffer(data.lightList), context.cmd);
+ RenderContactShadows(data.parameters, data.contactShadowsTexture, data.depthTexture, data.lightLoopLightData, data.lightList, context.cmd);
});
}
@@ -547,10 +545,10 @@ TextureHandle VolumeVoxelizationPass( RenderGraph renderGraph,
(VolumeVoxelizationPassData data, RenderGraphContext ctx) =>
{
VolumeVoxelizationPass( data.parameters,
- ctx.resources.GetTexture(data.densityBuffer),
+ data.densityBuffer,
data.visibleVolumeBoundsBuffer,
data.visibleVolumeDataBuffer,
- ctx.resources.GetComputeBuffer(data.bigTileLightListBuffer),
+ data.bigTileLightListBuffer,
ctx.cmd);
});
@@ -607,21 +605,17 @@ TextureHandle VolumetricLightingPass(RenderGraph renderGraph, HDCamera hdCamera,
builder.SetRenderFunc(
(VolumetricLightingPassData data, RenderGraphContext ctx) =>
{
- RTHandle densityBufferRT = ctx.resources.GetTexture(data.densityBuffer);
- RTHandle lightinBufferRT = ctx.resources.GetTexture(data.lightingBuffer);
- RTHandle depthTextureRT = ctx.resources.GetTexture(data.depthTexture);
-
VolumetricLightingPass( data.parameters,
- depthTextureRT,
- densityBufferRT,
- lightinBufferRT,
- data.parameters.enableReprojection ? ctx.resources.GetTexture(data.historyBuffer) : null,
- data.parameters.enableReprojection ? ctx.resources.GetTexture(data.feedbackBuffer) : null,
- ctx.resources.GetComputeBuffer(data.bigTileLightListBuffer),
+ data.depthTexture,
+ data.densityBuffer,
+ data.lightingBuffer,
+ data.parameters.enableReprojection ? data.historyBuffer : (RTHandle)null,
+ data.parameters.enableReprojection ? data.feedbackBuffer : (RTHandle)null,
+ data.bigTileLightListBuffer,
ctx.cmd);
if (data.parameters.filterVolume)
- FilterVolumetricLighting(data.parameters, densityBufferRT, lightinBufferRT, ctx.cmd);
+ FilterVolumetricLighting(data.parameters, data.densityBuffer, data.lightingBuffer, ctx.cmd);
});
if (parameters.enableReprojection)
diff --git a/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/HDRenderPipeline.PostProcess.cs b/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/HDRenderPipeline.PostProcess.cs
index 040fec11e4d..9a21b633110 100644
--- a/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/HDRenderPipeline.PostProcess.cs
+++ b/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/HDRenderPipeline.PostProcess.cs
@@ -43,11 +43,7 @@ TextureHandle RenderPostProcess( RenderGraph renderGraph,
builder.SetRenderFunc(
(AfterPostProcessPassData data, RenderGraphContext ctx) =>
{
- RenderAfterPostProcess(data.parameters
- , ctx.resources.GetRendererList(data.opaqueAfterPostprocessRL)
- , ctx.resources.GetRendererList(data.transparentAfterPostprocessRL)
- , ctx.renderContext, ctx.cmd);
-
+ RenderAfterPostProcess(data.parameters, data.opaqueAfterPostprocessRL, data.transparentAfterPostprocessRL, ctx.renderContext, ctx.cmd);
});
afterPostProcessBuffer = passData.afterPostProcessBuffer;
diff --git a/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/HDRenderPipeline.Prepass.cs b/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/HDRenderPipeline.Prepass.cs
index c149751da52..5a6d58332b7 100644
--- a/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/HDRenderPipeline.Prepass.cs
+++ b/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/HDRenderPipeline.Prepass.cs
@@ -313,22 +313,22 @@ bool RenderDepthPrepass(RenderGraph renderGraph, CullingResults cull, HDCamera h
if (data.hasDepthDeferredPass && data.decalLayersEnabled)
{
deferredMrt = context.renderGraphPool.GetTempArray(1);
- deferredMrt[0] = context.resources.GetTexture(data.decalBuffer);
+ deferredMrt[0] = data.decalBuffer;
}
var forwardMrt = context.renderGraphPool.GetTempArray((data.msaaEnabled ? 2 : 1) + (data.decalLayersEnabled ? 1 : 0));
if (data.msaaEnabled)
{
- forwardMrt[0] = context.resources.GetTexture(data.depthAsColorBuffer);
- forwardMrt[1] = context.resources.GetTexture(data.normalBuffer);
+ forwardMrt[0] = data.depthAsColorBuffer;
+ forwardMrt[1] = data.normalBuffer;
if (data.decalLayersEnabled)
- forwardMrt[2] = context.resources.GetTexture(data.decalBuffer);
+ forwardMrt[2] = data.decalBuffer;
}
else
{
- forwardMrt[0] = context.resources.GetTexture(data.normalBuffer);
+ forwardMrt[0] = data.normalBuffer;
if (data.decalLayersEnabled)
- forwardMrt[1] = context.resources.GetTexture(data.decalBuffer);
+ forwardMrt[1] = data.decalBuffer;
}
bool useRayTracing = data.frameSettings.IsEnabled(FrameSettingsField.RayTracing);
@@ -336,9 +336,9 @@ bool RenderDepthPrepass(RenderGraph renderGraph, CullingResults cull, HDCamera h
RenderDepthPrepass(context.renderContext, context.cmd, data.frameSettings
, deferredMrt
, forwardMrt
- , context.resources.GetTexture(data.depthBuffer)
- , context.resources.GetRendererList(data.rendererListDepthDeferred)
- , context.resources.GetRendererList(data.rendererListDepthForward)
+ , data.depthBuffer
+ , data.rendererListDepthDeferred
+ , data.rendererListDepthForward
, data.hasDepthDeferredPass
);
});
@@ -381,7 +381,7 @@ void RenderObjectsMotionVectors(RenderGraph renderGraph, CullingResults cull, HD
// Disable write to normal buffer for unlit shader (the normal buffer binding change when using MSAA)
context.cmd.SetGlobalInt(HDShaderIDs._ColorMaskNormal, data.frameSettings.IsEnabled(FrameSettingsField.MSAA) ? (int)ColorWriteMask.All : 0);
- DrawOpaqueRendererList(context, data.frameSettings, context.resources.GetRendererList(data.rendererList));
+ DrawOpaqueRendererList(context, data.frameSettings, data.rendererList);
});
}
}
@@ -465,8 +465,8 @@ void SetupGBufferTargets(RenderGraph renderGraph, HDCamera hdCamera, GBufferPass
static void BindDBufferGlobalData(in DBufferOutput dBufferOutput, in RenderGraphContext ctx)
{
for (int i = 0; i < dBufferOutput.dBufferCount; ++i)
- ctx.cmd.SetGlobalTexture(HDShaderIDs._DBufferTexture[i], ctx.resources.GetTexture(dBufferOutput.mrt[i]));
- ctx.cmd.SetGlobalBuffer(HDShaderIDs._DecalPropertyMaskBufferSRV, ctx.resources.GetComputeBuffer(dBufferOutput.decalPropertyMaskBuffer));
+ ctx.cmd.SetGlobalTexture(HDShaderIDs._DBufferTexture[i], dBufferOutput.mrt[i]);
+ ctx.cmd.SetGlobalBuffer(HDShaderIDs._DecalPropertyMaskBufferSRV, dBufferOutput.decalPropertyMaskBuffer);
}
static void BindProbeVolumeGlobalData(in FrameSettings frameSettings, GBufferPassData data, in RenderGraphContext ctx)
@@ -475,9 +475,9 @@ static void BindProbeVolumeGlobalData(in FrameSettings frameSettings, GBufferPas
return;
if (frameSettings.IsEnabled(FrameSettingsField.BigTilePrepass))
- ctx.cmd.SetGlobalBuffer(HDShaderIDs.g_vBigTileLightList, ctx.resources.GetComputeBuffer(data.probeVolumeBigTile));
- ctx.cmd.SetGlobalBuffer(HDShaderIDs.g_vProbeVolumesLayeredOffsetsBuffer, ctx.resources.GetComputeBuffer(data.probeVolumePerVoxelOffset));
- ctx.cmd.SetGlobalBuffer(HDShaderIDs.g_vProbeVolumesLightListGlobal, ctx.resources.GetComputeBuffer(data.probeVolumePerVoxelLightList));
+ ctx.cmd.SetGlobalBuffer(HDShaderIDs.g_vBigTileLightList, data.probeVolumeBigTile);
+ ctx.cmd.SetGlobalBuffer(HDShaderIDs.g_vProbeVolumesLayeredOffsetsBuffer, data.probeVolumePerVoxelOffset);
+ ctx.cmd.SetGlobalBuffer(HDShaderIDs.g_vProbeVolumesLightListGlobal, data.probeVolumePerVoxelLightList);
// int useDepthBuffer = 0;
// cmd.SetGlobalInt(HDShaderIDs.g_isLogBaseBufferEnabled, useDepthBuffer);
}
@@ -517,7 +517,7 @@ void RenderGBuffer(RenderGraph renderGraph, TextureHandle sssBuffer, ref Prepass
{
BindProbeVolumeGlobalData(data.frameSettings, data, context);
BindDBufferGlobalData(data.dBuffer, context);
- DrawOpaqueRendererList(context, data.frameSettings, context.resources.GetRendererList(data.rendererList));
+ DrawOpaqueRendererList(context, data.frameSettings, data.rendererList);
});
}
}
@@ -577,10 +577,10 @@ void ResolvePrepassBuffers(RenderGraph renderGraph, HDCamera hdCamera, ref Prepa
builder.SetRenderFunc(
(ResolvePrepassData data, RenderGraphContext context) =>
{
- data.depthResolveMaterial.SetTexture(HDShaderIDs._NormalTextureMS, context.resources.GetTexture(data.normalBufferMSAA));
- data.depthResolveMaterial.SetTexture(HDShaderIDs._DepthTextureMS, context.resources.GetTexture(data.depthAsColorBufferMSAA));
+ data.depthResolveMaterial.SetTexture(HDShaderIDs._NormalTextureMS, data.normalBufferMSAA);
+ data.depthResolveMaterial.SetTexture(HDShaderIDs._DepthTextureMS, data.depthAsColorBufferMSAA);
if (data.needMotionVectors)
- data.depthResolveMaterial.SetTexture(HDShaderIDs._MotionVectorTextureMS, context.resources.GetTexture(data.motionVectorBufferMSAA));
+ data.depthResolveMaterial.SetTexture(HDShaderIDs._MotionVectorTextureMS, data.motionVectorBufferMSAA);
context.cmd.DrawProcedural(Matrix4x4.identity, data.depthResolveMaterial, data.depthResolvePassIndex, MeshTopology.Triangles, 3, 1);
});
@@ -613,7 +613,6 @@ void CopyDepthBufferIfNeeded(RenderGraph renderGraph, HDCamera hdCamera, ref Pre
builder.SetRenderFunc(
(CopyDepthPassData data, RenderGraphContext context) =>
{
- RenderGraphResourceRegistry resources = context.resources;
// TODO: maybe we don't actually need the top MIP level?
// That way we could avoid making the copy, and build the MIP hierarchy directly.
// The downside is that our SSR tracing accuracy would decrease a little bit.
@@ -622,7 +621,7 @@ void CopyDepthBufferIfNeeded(RenderGraph renderGraph, HDCamera hdCamera, ref Pre
// TODO: reading the depth buffer with a compute shader will cause it to decompress in place.
// On console, to preserve the depth test performance, we must NOT decompress the 'm_CameraDepthStencilBuffer' in place.
// We should call decompressDepthSurfaceToCopy() and decompress it to 'm_CameraDepthBufferMipChain'.
- data.GPUCopy.SampleCopyChannel_xyzw2x(context.cmd, resources.GetTexture(data.inputDepth), resources.GetTexture(data.outputDepth), new RectInt(0, 0, data.width, data.height));
+ data.GPUCopy.SampleCopyChannel_xyzw2x(context.cmd, data.inputDepth, data.outputDepth, new RectInt(0, 0, data.width, data.height));
});
}
@@ -651,14 +650,9 @@ void BuildCoarseStencilAndResolveIfNeeded(RenderGraph renderGraph, HDCamera hdCa
builder.SetRenderFunc(
(ResolveStencilPassData data, RenderGraphContext context) =>
{
- var res = context.resources;
- BuildCoarseStencilAndResolveIfNeeded(data.parameters,
- res.GetTexture(data.inputDepth),
- res.GetTexture(data.resolvedStencil),
- res.GetComputeBuffer(data.coarseStencilBuffer),
- context.cmd);
- }
- );
+ BuildCoarseStencilAndResolveIfNeeded(data.parameters, data.inputDepth, data.resolvedStencil, data.coarseStencilBuffer, context.cmd);
+ });
+
bool isMSAAEnabled = hdCamera.frameSettings.IsEnabled(FrameSettingsField.MSAA);
if (isMSAAEnabled)
{
@@ -771,8 +765,6 @@ void RenderDBuffer(RenderGraph renderGraph, HDCamera hdCamera, TextureHandle dec
builder.SetRenderFunc(
(RenderDBufferPassData data, RenderGraphContext context) =>
{
- RenderGraphResourceRegistry resources = context.resources;
-
RenderTargetIdentifier[] rti = context.renderGraphPool.GetTempArray(data.dBufferCount);
RTHandle[] rt = context.renderGraphPool.GetTempArray(data.dBufferCount);
@@ -780,18 +772,18 @@ void RenderDBuffer(RenderGraph renderGraph, HDCamera hdCamera, TextureHandle dec
// This way we can directly use the UseColorBuffer API and set clear color directly at resource creation and not in the RenderDBuffer shared function.
for (int i = 0; i < data.dBufferCount; ++i)
{
- rt[i] = resources.GetTexture(data.mrt[i]);
+ rt[i] = data.mrt[i];
rti[i] = rt[i];
}
RenderDBuffer( data.parameters,
rti,
rt,
- resources.GetTexture(data.depthStencilBuffer),
- resources.GetTexture(data.depthTexture),
- resources.GetRendererList(data.meshDecalsRendererList),
- resources.GetComputeBuffer(data.propertyMaskBuffer),
- resources.GetTexture(data.decalBuffer),
+ data.depthStencilBuffer,
+ data.depthTexture,
+ data.meshDecalsRendererList,
+ data.propertyMaskBuffer,
+ data.decalBuffer,
context.renderContext,
context.cmd);
});
@@ -816,13 +808,9 @@ void DecalNormalPatch(RenderGraph renderGraph, HDCamera hdCamera, ref PrepassOut
{
RTHandle[] mrt = ctx.renderGraphPool.GetTempArray(data.dBuffer.dBufferCount);
for (int i = 0; i < data.dBuffer.dBufferCount; ++i)
- mrt[i] = ctx.resources.GetTexture(data.dBuffer.mrt[i]);
+ mrt[i] = data.dBuffer.mrt[i];
- DecalNormalPatch( data.parameters,
- mrt,
- ctx.resources.GetTexture(data.depthStencilBuffer),
- ctx.resources.GetTexture(data.normalBuffer),
- ctx.cmd);
+ DecalNormalPatch(data.parameters, mrt, data.depthStencilBuffer, data.normalBuffer, ctx.cmd);
});
}
}
@@ -849,7 +837,7 @@ void GenerateDepthPyramid(RenderGraph renderGraph, HDCamera hdCamera, ref Prepas
builder.SetRenderFunc(
(GenerateDepthPyramidPassData data, RenderGraphContext context) =>
{
- data.mipGenerator.RenderMinDepthPyramid(context.cmd, context.resources.GetTexture(data.depthTexture), data.mipInfo);
+ data.mipGenerator.RenderMinDepthPyramid(context.cmd, data.depthTexture, data.mipInfo);
});
output.depthPyramidTexture = passData.depthTexture;
@@ -888,8 +876,7 @@ void RenderCameraMotionVectors(RenderGraph renderGraph, HDCamera hdCamera, Textu
builder.SetRenderFunc(
(CameraMotionVectorsPassData data, RenderGraphContext context) =>
{
- var res = context.resources;
- HDUtils.DrawFullScreen(context.cmd, data.cameraMotionVectorsMaterial, res.GetTexture(data.motionVectorsBuffer), res.GetTexture(data.depthBuffer), null, 0);
+ HDUtils.DrawFullScreen(context.cmd, data.cameraMotionVectorsMaterial,data.motionVectorsBuffer, data.depthBuffer, null, 0);
});
}
}
diff --git a/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/HDRenderPipeline.RenderGraph.cs b/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/HDRenderPipeline.RenderGraph.cs
index 44477a2df50..4cff68277ba 100644
--- a/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/HDRenderPipeline.RenderGraph.cs
+++ b/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/HDRenderPipeline.RenderGraph.cs
@@ -332,9 +332,7 @@ void BlitFinalCameraTexture(RenderGraph renderGraph, HDCamera hdCamera, TextureH
builder.SetRenderFunc(
(FinalBlitPassData data, RenderGraphContext context) =>
{
- var sourceTexture = context.resources.GetTexture(data.source);
- var destinationTexture = context.resources.GetTexture(data.destination);
- BlitFinalCameraTexture(data.parameters, context.renderGraphPool.GetTempMaterialPropertyBlock(), sourceTexture, destinationTexture, context.cmd);
+ BlitFinalCameraTexture(data.parameters, context.renderGraphPool.GetTempMaterialPropertyBlock(), data.source, data.destination, context.cmd);
});
}
}
@@ -374,7 +372,7 @@ void SetFinalTarget(RenderGraph renderGraph, HDCamera hdCamera, TextureHandle de
(SetFinalTargetPassData data, RenderGraphContext ctx) =>
{
// We need to make sure the viewport is correctly set for the editor rendering. It might have been changed by debug overlay rendering just before.
- ctx.cmd.SetRenderTarget(ctx.resources.GetTexture(data.finalTarget));
+ ctx.cmd.SetRenderTarget(data.finalTarget);
ctx.cmd.SetViewport(data.finalViewport);
if (data.copyDepth)
@@ -382,7 +380,7 @@ void SetFinalTarget(RenderGraph renderGraph, HDCamera hdCamera, TextureHandle de
using (new ProfilingScope(ctx.cmd, ProfilingSampler.Get(HDProfileId.CopyDepthInTargetTexture)))
{
var mpb = ctx.renderGraphPool.GetTempMaterialPropertyBlock();
- mpb.SetTexture(HDShaderIDs._InputDepth, ctx.resources.GetTexture(data.depthBuffer));
+ mpb.SetTexture(HDShaderIDs._InputDepth, data.depthBuffer);
// When we are Main Game View we need to flip the depth buffer ourselves as we are after postprocess / blit that have already flipped the screen
mpb.SetInt("_FlipY", data.flipY ? 1 : 0);
mpb.SetVector(HDShaderIDs._BlitScaleBias, new Vector4(1.0f, 1.0f, 0.0f, 0.0f));
@@ -488,17 +486,12 @@ void RenderForwardOpaque( RenderGraph renderGraph,
// TODO RENDERGRAPH: replace with UseColorBuffer when removing old rendering (SetRenderTarget is called inside RenderForwardRendererList because of that).
var mrt = context.renderGraphPool.GetTempArray(data.renderTargetCount);
for (int i = 0; i < data.renderTargetCount; ++i)
- mrt[i] = context.resources.GetTexture(data.renderTarget[i]);
+ mrt[i] = data.renderTarget[i];
if (data.dbuffer != null)
BindDBufferGlobalData(data.dbuffer.Value, context);
- RenderForwardRendererList(data.frameSettings,
- context.resources.GetRendererList(data.rendererList),
- mrt,
- context.resources.GetTexture(data.depthBuffer),
- context.resources.GetComputeBuffer(data.lightListBuffer),
- true, context.renderContext, context.cmd);
+ RenderForwardRendererList(data.frameSettings, data.rendererList, mrt, data.depthBuffer, data.lightListBuffer, true, context.renderContext, context.cmd);
});
}
}
@@ -567,23 +560,18 @@ void RenderForwardTransparent( RenderGraph renderGraph,
// TODO: replace with UseColorBuffer when removing old rendering.
var mrt = context.renderGraphPool.GetTempArray(data.renderTargetCount);
for (int i = 0; i < data.renderTargetCount; ++i)
- mrt[i] = context.resources.GetTexture(data.renderTarget[i]);
+ mrt[i] = data.renderTarget[i];
// Bind all global data/parameters for transparent forward pass
context.cmd.SetGlobalInt(HDShaderIDs._ColorMaskTransparentVel, data.renderMotionVecForTransparent ? (int)ColorWriteMask.All : 0);
if (data.decalsEnabled)
DecalSystem.instance.SetAtlas(context.cmd); // for clustered decals
- context.cmd.SetGlobalBuffer(HDShaderIDs.g_vLayeredOffsetsBuffer, context.resources.GetComputeBuffer(data.perVoxelOffset));
- context.cmd.SetGlobalBuffer(HDShaderIDs.g_logBaseBuffer, context.resources.GetComputeBuffer(data.perTileLogBaseTweak));
- context.cmd.SetGlobalTexture(HDShaderIDs._SsrLightingTexture, context.resources.GetTexture(data.ssrLlightingBuffer));
+ context.cmd.SetGlobalBuffer(HDShaderIDs.g_vLayeredOffsetsBuffer, data.perVoxelOffset);
+ context.cmd.SetGlobalBuffer(HDShaderIDs.g_logBaseBuffer, data.perTileLogBaseTweak);
+ context.cmd.SetGlobalTexture(HDShaderIDs._SsrLightingTexture, data.ssrLlightingBuffer);
- RenderForwardRendererList( data.frameSettings,
- context.resources.GetRendererList(data.rendererList),
- mrt,
- context.resources.GetTexture(data.depthBuffer),
- context.resources.GetComputeBuffer(data.lightListBuffer),
- false, context.renderContext, context.cmd);
+ RenderForwardRendererList( data.frameSettings, data.rendererList, mrt, data.depthBuffer, data.lightListBuffer, false, context.renderContext, context.cmd);
});
}
}
@@ -608,7 +596,7 @@ void RenderTransparentDepthPrepass(RenderGraph renderGraph, HDCamera hdCamera, i
builder.SetRenderFunc(
(ForwardPassData data, RenderGraphContext context) =>
{
- DrawTransparentRendererList(context.renderContext, context.cmd, data.frameSettings, context.resources.GetRendererList(data.rendererList));
+ DrawTransparentRendererList(context.renderContext, context.cmd, data.frameSettings, data.rendererList);
});
}
}
@@ -629,7 +617,7 @@ void RenderTransparentDepthPostpass(RenderGraph renderGraph, HDCamera hdCamera,
builder.SetRenderFunc(
(ForwardPassData data, RenderGraphContext context) =>
{
- DrawTransparentRendererList(context.renderContext, context.cmd, data.frameSettings, context.resources.GetRendererList(data.rendererList));
+ DrawTransparentRendererList(context.renderContext, context.cmd, data.frameSettings, data.rendererList);
});
}
}
@@ -699,7 +687,7 @@ TextureHandle RenderLowResTransparent(RenderGraph renderGraph, HDCamera hdCamera
UpdateOffscreenRenderingConstants(ref data.globalCB, true, 2u);
ConstantBuffer.PushGlobal(context.cmd, data.globalCB, HDShaderIDs._ShaderVariablesGlobal);
- DrawTransparentRendererList(context.renderContext, context.cmd, data.frameSettings, context.resources.GetRendererList(data.rendererList));
+ DrawTransparentRendererList(context.renderContext, context.cmd, data.frameSettings, data.rendererList);
UpdateOffscreenRenderingConstants(ref data.globalCB, false, 1u);
ConstantBuffer.PushGlobal(context.cmd, data.globalCB, HDShaderIDs._ShaderVariablesGlobal);
@@ -739,9 +727,8 @@ void UpsampleTransparent(RenderGraph renderGraph, HDCamera hdCamera, TextureHand
builder.SetRenderFunc(
(UpsampleTransparentPassData data, RenderGraphContext context) =>
{
- var res = context.resources;
- data.upsampleMaterial.SetTexture(HDShaderIDs._LowResTransparent, res.GetTexture(data.lowResTransparentBuffer));
- data.upsampleMaterial.SetTexture(HDShaderIDs._LowResDepthTexture, res.GetTexture(data.downsampledDepthBuffer));
+ data.upsampleMaterial.SetTexture(HDShaderIDs._LowResTransparent, data.lowResTransparentBuffer);
+ data.upsampleMaterial.SetTexture(HDShaderIDs._LowResDepthTexture, data.downsampledDepthBuffer);
context.cmd.DrawProcedural(Matrix4x4.identity, data.upsampleMaterial, 0, MeshTopology.Triangles, 3, 1, null);
});
}
@@ -828,7 +815,7 @@ void RenderForwardEmissive( RenderGraph renderGraph,
builder.SetRenderFunc(
(RenderForwardEmissivePassData data, RenderGraphContext context) =>
{
- HDUtils.DrawRendererList(context.renderContext, context.cmd, context.resources.GetRendererList(data.rendererList));
+ HDUtils.DrawRendererList(context.renderContext, context.cmd, data.rendererList);
if (data.enableDecals)
DecalSystem.instance.RenderForwardEmissive(context.cmd);
});
@@ -854,7 +841,7 @@ void RenderForwardError(RenderGraph renderGraph,
builder.SetRenderFunc(
(ForwardPassData data, RenderGraphContext context) =>
{
- HDUtils.DrawRendererList(context.renderContext, context.cmd, context.resources.GetRendererList(data.rendererList));
+ HDUtils.DrawRendererList(context.renderContext, context.cmd, data.rendererList);
});
}
}
@@ -884,7 +871,7 @@ void SendGeometryGraphicsBuffers(RenderGraph renderGraph, TextureHandle normalBu
builder.SetRenderFunc(
(SendGeometryBuffersPassData data, RenderGraphContext ctx) =>
{
- SendGeometryGraphicsBuffers(data.parameters, ctx.resources.GetTexture(data.normalBuffer), ctx.resources.GetTexture(data.depthBuffer), ctx.cmd);
+ SendGeometryGraphicsBuffers(data.parameters, data.normalBuffer, data.depthBuffer, ctx.cmd);
});
}
}
@@ -929,7 +916,7 @@ void ClearStencilBuffer(RenderGraph renderGraph, TextureHandle colorBuffer, Text
(ClearStencilPassData data, RenderGraphContext ctx) =>
{
data.clearStencilMaterial.SetInt(HDShaderIDs._StencilMask, (int)StencilUsage.HDRPReservedBits);
- HDUtils.DrawFullScreen(ctx.cmd, data.clearStencilMaterial, ctx.resources.GetTexture(data.colorBuffer), ctx.resources.GetTexture(data.depthBuffer));
+ HDUtils.DrawFullScreen(ctx.cmd, data.clearStencilMaterial, data.colorBuffer, data.depthBuffer);
});
}
}
@@ -967,11 +954,7 @@ void PreRenderSky(RenderGraph renderGraph, HDCamera hdCamera, TextureHandle colo
builder.SetRenderFunc(
(PreRenderSkyPassData data, RenderGraphContext context) =>
{
- var depthBuffer = context.resources.GetTexture(data.depthStencilBuffer);
- var destination = context.resources.GetTexture(data.colorBuffer);
- var normalBuffer= context.resources.GetTexture(data.normalBuffer);
-
- data.skyManager.PreRenderSky(data.hdCamera, data.sunLight, destination, normalBuffer, depthBuffer, data.debugDisplaySettings, data.frameCount, context.cmd);
+ data.skyManager.PreRenderSky(data.hdCamera, data.sunLight, data.colorBuffer, data.normalBuffer, data.depthStencilBuffer, data.debugDisplaySettings, data.frameCount, context.cmd);
});
}
}
@@ -1018,17 +1001,12 @@ void RenderSky(RenderGraph renderGraph, HDCamera hdCamera, TextureHandle colorBu
// Necessary to perform dual-source (polychromatic alpha) blending which is not supported by Unity.
// We load from the color buffer, perform blending manually, and store to the atmospheric scattering buffer.
// Then we perform a copy from the atmospheric scattering buffer back to the color buffer.
- var depthBuffer = context.resources.GetTexture(data.depthStencilBuffer);
- var destination = context.resources.GetTexture(data.colorBuffer);
- var intermediateBuffer = context.resources.GetTexture(data.intermediateBuffer);
- var inputVolumetric = context.resources.GetTexture(data.volumetricLighting);
-
- data.skyManager.RenderSky(data.hdCamera, data.sunLight, destination, depthBuffer, data.debugDisplaySettings, data.frameCount, context.cmd);
+ data.skyManager.RenderSky(data.hdCamera, data.sunLight, data.colorBuffer, data.depthStencilBuffer, data.debugDisplaySettings, data.frameCount, context.cmd);
if (Fog.IsFogEnabled(data.hdCamera) || Fog.IsPBRFogEnabled(data.hdCamera))
{
var pixelCoordToViewDirWS = data.hdCamera.mainViewConstants.pixelCoordToViewDirWS;
- data.skyManager.RenderOpaqueAtmosphericScattering(context.cmd, data.hdCamera, destination, inputVolumetric, intermediateBuffer, depthBuffer, pixelCoordToViewDirWS, data.hdCamera.frameSettings.IsEnabled(FrameSettingsField.MSAA));
+ data.skyManager.RenderOpaqueAtmosphericScattering(context.cmd, data.hdCamera, data.colorBuffer, data.volumetricLighting, data.intermediateBuffer, data.depthStencilBuffer, pixelCoordToViewDirWS, data.hdCamera.frameSettings.IsEnabled(FrameSettingsField.MSAA));
}
});
}
@@ -1069,13 +1047,10 @@ void GenerateColorPyramid(RenderGraph renderGraph, HDCamera hdCamera, TextureHan
(GenerateColorPyramidData data, RenderGraphContext context) =>
{
Vector2Int pyramidSize = new Vector2Int(data.hdCamera.actualWidth, data.hdCamera.actualHeight);
- var colorPyramid = context.resources.GetTexture(data.colorPyramid);
- var inputTexture = context.resources.GetTexture(data.inputColor);
- data.hdCamera.colorPyramidHistoryMipCount = data.mipGenerator.RenderColorGaussianPyramid(context.cmd, pyramidSize, inputTexture, colorPyramid);
-
+ data.hdCamera.colorPyramidHistoryMipCount = data.mipGenerator.RenderColorGaussianPyramid(context.cmd, pyramidSize, data.inputColor, data.colorPyramid);
// TODO RENDERGRAPH: We'd like to avoid SetGlobals like this but it's required by custom passes currently.
// We will probably be able to remove those once we push custom passes fully to render graph.
- context.cmd.SetGlobalTexture(HDShaderIDs._ColorPyramidTexture, colorPyramid);
+ context.cmd.SetGlobalTexture(HDShaderIDs._ColorPyramidTexture, data.colorPyramid);
});
}
@@ -1110,7 +1085,7 @@ TextureHandle AccumulateDistortion( RenderGraph renderGraph,
builder.SetRenderFunc(
(AccumulateDistortionPassData data, RenderGraphContext context) =>
{
- DrawTransparentRendererList(context.renderContext, context.cmd, data.frameSettings, context.resources.GetRendererList(data.distortionRendererList));
+ DrawTransparentRendererList(context.renderContext, context.cmd, data.frameSettings, data.distortionRendererList);
});
return passData.distortionBuffer;
@@ -1149,15 +1124,14 @@ void RenderDistortion( RenderGraph renderGraph,
builder.SetRenderFunc(
(RenderDistortionPassData data, RenderGraphContext context) =>
{
- var res = context.resources;
// TODO: Set stencil stuff via parameters rather than hard-coding it in shader.
- data.applyDistortionMaterial.SetTexture(HDShaderIDs._DistortionTexture, res.GetTexture(data.distortionBuffer));
- data.applyDistortionMaterial.SetTexture(HDShaderIDs._ColorPyramidTexture, res.GetTexture(data.colorPyramidBuffer));
+ data.applyDistortionMaterial.SetTexture(HDShaderIDs._DistortionTexture, data.distortionBuffer);
+ data.applyDistortionMaterial.SetTexture(HDShaderIDs._ColorPyramidTexture, data.colorPyramidBuffer);
data.applyDistortionMaterial.SetVector(HDShaderIDs._Size, data.size);
data.applyDistortionMaterial.SetInt(HDShaderIDs._StencilMask, (int)StencilUsage.DistortionVectors);
data.applyDistortionMaterial.SetInt(HDShaderIDs._StencilRef, (int)StencilUsage.DistortionVectors);
- HDUtils.DrawFullScreen(context.cmd, data.applyDistortionMaterial, res.GetTexture(data.colorBuffer), res.GetTexture(data.depthStencilBuffer), null, 0);
+ HDUtils.DrawFullScreen(context.cmd, data.applyDistortionMaterial, data.colorBuffer, data.depthStencilBuffer, null, 0);
});
}
}
@@ -1232,9 +1206,8 @@ TextureHandle ResolveMSAAColor(RenderGraph renderGraph, HDCamera hdCamera, Textu
builder.SetRenderFunc(
(ResolveColorData data, RenderGraphContext context) =>
{
- var res = context.resources;
var mpb = context.renderGraphPool.GetTempMaterialPropertyBlock();
- mpb.SetTexture(HDShaderIDs._ColorTextureMS, res.GetTexture(data.input));
+ mpb.SetTexture(HDShaderIDs._ColorTextureMS, data.input);
context.cmd.DrawProcedural(Matrix4x4.identity, data.resolveMaterial, data.passIndex, MeshTopology.Triangles, 3, 1, mpb);
});
@@ -1269,9 +1242,8 @@ TextureHandle ResolveMotionVector(RenderGraph renderGraph, HDCamera hdCamera, Te
builder.SetRenderFunc(
(ResolveMotionVectorData data, RenderGraphContext context) =>
{
- var res = context.resources;
var mpb = context.renderGraphPool.GetTempMaterialPropertyBlock();
- mpb.SetTexture(HDShaderIDs._MotionVectorTextureMS, res.GetTexture(data.input));
+ mpb.SetTexture(HDShaderIDs._MotionVectorTextureMS, data.input);
context.cmd.DrawProcedural(Matrix4x4.identity, data.resolveMaterial, data.passIndex, MeshTopology.Triangles, 3, 1, mpb);
});
@@ -1309,7 +1281,7 @@ void RenderAccumulation(RenderGraph renderGraph, HDCamera hdCamera, TextureHandl
builder.SetRenderFunc(
(RenderAccumulationPassData data, RenderGraphContext ctx) =>
{
- RenderAccumulation(data.parameters, ctx.resources.GetTexture(data.input), ctx.resources.GetTexture(data.output), ctx.resources.GetTexture(data.history), ctx.cmd);
+ RenderAccumulation(data.parameters, data.input, data.output, data.history, ctx.cmd);
});
}
diff --git a/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/HDRenderPipeline.RenderGraphUtils.cs b/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/HDRenderPipeline.RenderGraphUtils.cs
index 8c41d4e0f24..52d3f67d800 100644
--- a/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/HDRenderPipeline.RenderGraphUtils.cs
+++ b/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/HDRenderPipeline.RenderGraphUtils.cs
@@ -147,7 +147,7 @@ void RenderXROcclusionMeshes(RenderGraph renderGraph, HDCamera hdCamera, Texture
builder.SetRenderFunc(
(RenderOcclusionMeshesPassData data, RenderGraphContext ctx) =>
{
- data.hdCamera.xr.RenderOcclusionMeshes(ctx.cmd, data.clearColor, ctx.resources.GetTexture(data.colorBuffer), ctx.resources.GetTexture(data.depthBuffer));
+ data.hdCamera.xr.RenderOcclusionMeshes(ctx.cmd, data.clearColor, data.colorBuffer, data.depthBuffer);
});
}
}
diff --git a/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/HDRenderPipeline.SubsurfaceScattering.cs b/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/HDRenderPipeline.SubsurfaceScattering.cs
index 9815274982a..23e9b85a1b6 100644
--- a/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/HDRenderPipeline.SubsurfaceScattering.cs
+++ b/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/HDRenderPipeline.SubsurfaceScattering.cs
@@ -64,13 +64,13 @@ void RenderSubsurfaceScattering(RenderGraph renderGraph, HDCamera hdCamera, Text
(SubsurfaceScaterringPassData data, RenderGraphContext context) =>
{
var resources = new SubsurfaceScatteringResources();
- resources.colorBuffer = context.resources.GetTexture(data.colorBuffer);
- resources.diffuseBuffer = context.resources.GetTexture(data.diffuseBuffer);
- resources.depthStencilBuffer = context.resources.GetTexture(data.depthStencilBuffer);
- resources.depthTexture = context.resources.GetTexture(data.depthTexture);
- resources.cameraFilteringBuffer = context.resources.GetTexture(data.cameraFilteringBuffer);
- resources.sssBuffer = context.resources.GetTexture(data.sssBuffer);
- resources.coarseStencilBuffer = context.resources.GetComputeBuffer(data.coarseStencilBuffer);
+ resources.colorBuffer = data.colorBuffer;
+ resources.diffuseBuffer = data.diffuseBuffer;
+ resources.depthStencilBuffer = data.depthStencilBuffer;
+ resources.depthTexture = data.depthTexture;
+ resources.cameraFilteringBuffer = data.cameraFilteringBuffer;
+ resources.sssBuffer = data.sssBuffer;
+ resources.coarseStencilBuffer = data.coarseStencilBuffer;
RenderSubsurfaceScattering(data.parameters, resources, context.cmd);
});
diff --git a/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/RenderPass/AOV/AOVRequestData.cs b/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/RenderPass/AOV/AOVRequestData.cs
index ddb949175bd..5e36d58fc06 100644
--- a/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/RenderPass/AOV/AOVRequestData.cs
+++ b/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/RenderPass/AOV/AOVRequestData.cs
@@ -215,7 +215,7 @@ List targets
builder.SetRenderFunc(
(PushCameraTexturePassData data, RenderGraphContext ctx) =>
{
- HDUtils.BlitCameraTexture(ctx.cmd, ctx.resources.GetTexture(data.source), data.target);
+ HDUtils.BlitCameraTexture(ctx.cmd, data.source, data.target);
});
}
}
@@ -312,7 +312,7 @@ List targets
if (data.customPassSource != null)
HDUtils.BlitCameraTexture(ctx.cmd, data.customPassSource, data.target);
else
- HDUtils.BlitCameraTexture(ctx.cmd, ctx.resources.GetTexture(data.source), data.target);
+ HDUtils.BlitCameraTexture(ctx.cmd, data.source, data.target);
});
}
}
diff --git a/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/RenderPass/CustomPass/CustomPass.cs b/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/RenderPass/CustomPass/CustomPass.cs
index ee7019aa0df..7efc28f2a9b 100644
--- a/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/RenderPass/CustomPass/CustomPass.cs
+++ b/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/RenderPass/CustomPass/CustomPass.cs
@@ -66,8 +66,6 @@ internal ProfilingSampler profilingSampler
CustomPassVolume owner;
SharedRTManager currentRTManager;
HDCamera currentHDCamera;
- // This is a bit dirty but necessary as users may call function that need it but they don't have the instance to pass on.
- RenderGraphContext currentRenderGraphContext;
MaterialPropertyBlock userMaterialPropertyBlock;
@@ -259,7 +257,6 @@ internal void ExecuteInternal(RenderGraph renderGraph, HDCamera hdCamera, Cullin
(ExecutePassData data, RenderGraphContext ctx) =>
{
var customPass = data.customPass;
- customPass.currentRenderGraphContext = ctx;
if (!customPass.isSetup)
{
@@ -272,15 +269,15 @@ internal void ExecuteInternal(RenderGraph renderGraph, HDCamera hdCamera, Cullin
customPass.SetCustomPassTarget(ctx.cmd);
- var outputColorBuffer = ctx.resources.GetTexture(customPass.currentRenderTarget.colorBufferRG);
+ var outputColorBuffer = customPass.currentRenderTarget.colorBufferRG;
// Create the custom pass context:
CustomPassContext customPassCtx = new CustomPassContext(
ctx.renderContext, ctx.cmd, data.hdCamera,
data.cullingResult,
outputColorBuffer,
- ctx.resources.GetTexture(customPass.currentRenderTarget.depthBufferRG),
- ctx.resources.GetTexture(customPass.currentRenderTarget.normalBufferRG),
+ customPass.currentRenderTarget.depthBufferRG,
+ customPass.currentRenderTarget.normalBufferRG,
customPass.currentRenderTarget.customColorBuffer,
customPass.currentRenderTarget.customDepthBuffer,
ctx.renderGraphPool.GetTempMaterialPropertyBlock()
@@ -345,8 +342,8 @@ void SetCustomPassTarget(CommandBuffer cmd)
}
else
{
- colorBuffer = (targetColorBuffer == TargetBuffer.Custom) ? currentRenderTarget.customColorBuffer.Value : currentRenderGraphContext.resources.GetTexture(currentRenderTarget.colorBufferRG);
- depthBuffer = (targetDepthBuffer == TargetBuffer.Custom) ? currentRenderTarget.customDepthBuffer.Value : currentRenderGraphContext.resources.GetTexture(currentRenderTarget.depthBufferRG);
+ colorBuffer = (targetColorBuffer == TargetBuffer.Custom) ? currentRenderTarget.customColorBuffer.Value : currentRenderTarget.colorBufferRG;
+ depthBuffer = (targetDepthBuffer == TargetBuffer.Custom) ? currentRenderTarget.customDepthBuffer.Value : currentRenderTarget.depthBufferRG;
}
if (targetColorBuffer == TargetBuffer.None && targetDepthBuffer != TargetBuffer.None)
@@ -416,8 +413,8 @@ protected void SetCameraRenderTarget(CommandBuffer cmd, bool bindDepth = true, C
RTHandle colorBuffer, depthBuffer;
if (currentRenderTarget.useRenderGraph)
{
- colorBuffer = currentRenderGraphContext.resources.GetTexture(currentRenderTarget.colorBufferRG);
- depthBuffer = currentRenderGraphContext.resources.GetTexture(currentRenderTarget.depthBufferRG);
+ colorBuffer = currentRenderTarget.colorBufferRG;
+ depthBuffer = currentRenderTarget.depthBufferRG;
}
else
{
@@ -474,8 +471,8 @@ protected void ResolveMSAAColorBuffer(CommandBuffer cmd, HDCamera hdCamera)
RTHandle input, output;
if (currentRenderTarget.useRenderGraph)
{
- input = currentRenderGraphContext.resources.GetTexture(currentRenderTarget.colorBufferRG);
- output = currentRenderGraphContext.resources.GetTexture(currentRenderTarget.nonMSAAColorBufferRG);
+ input = currentRenderTarget.colorBufferRG;
+ output = currentRenderTarget.nonMSAAColorBufferRG;
}
else
{
@@ -507,8 +504,8 @@ protected void GetCameraBuffers(out RTHandle colorBuffer, out RTHandle depthBuff
bool msaa = IsMSAAEnabled(currentHDCamera);
if (currentRenderTarget.useRenderGraph)
{
- colorBuffer = currentRenderGraphContext.resources.GetTexture(currentRenderTarget.colorBufferRG);
- depthBuffer = currentRenderGraphContext.resources.GetTexture(currentRenderTarget.depthBufferRG);
+ colorBuffer = currentRenderTarget.colorBufferRG;
+ depthBuffer = currentRenderTarget.depthBufferRG;
}
else
{
@@ -543,7 +540,7 @@ protected RTHandle GetNormalBuffer()
throw new Exception("GetNormalBuffer can only be called inside the CustomPass.Execute function");
if (currentRenderTarget.useRenderGraph)
- return currentRenderGraphContext.resources.GetTexture(currentRenderTarget.normalBufferRG);
+ return currentRenderTarget.normalBufferRG;
else
return currentRTManager.GetNormalBuffer(IsMSAAEnabled(currentHDCamera));
}