Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
59 commits
Select commit Hold shift + click to select a range
ddbee5f
enabled MSAA when the RenderPass API is used. Resolving implicitly to…
manuele-bonanno Feb 26, 2021
8f7db74
Initial lazy merging prototype
manuele-bonanno Mar 4, 2021
fe5cadb
Lazy merging prototype: all the needed attachments are now added to t…
manuele-bonanno Mar 5, 2021
e50c046
initial work to add lazy merging to the deferred renderer (doesn't ha…
manuele-bonanno Mar 8, 2021
3ba7c7b
MRT attachments merging improvements
manuele-bonanno Mar 10, 2021
b66f183
fix for a crash because of incomplete Targets setup for merged render…
manuele-bonanno Mar 10, 2021
422ed1b
change m_ShadowmapWidth/Height variables to use renderTargetWidth
jonuuukas Mar 10, 2021
9bdd3ef
Merge branch 'universal/render-pass-conversion' of ssh://github.com/U…
jonuuukas Mar 10, 2021
7d3c5ba
m_ActiveRenderPassQueue[i] to var renderPass
jonuuukas Mar 16, 2021
6f5d3f0
changing hash ctor logic to merge width/height and include depth rtID
jonuuukas Mar 16, 2021
7dc34fa
fix setlastpass flag loop
jonuuukas Mar 23, 2021
72d51d2
NativeArray memory leak fix
manuele-bonanno Mar 23, 2021
73d666d
refactoring to remove duplicated code
manuele-bonanno Mar 23, 2021
d86b828
fix non-renderpass passes getting hashes and etc.
jonuuukas Mar 23, 2021
ac46e52
more cleaning up, moving RenderPass code in separate functions for cl…
manuele-bonanno Mar 23, 2021
bc45166
lists to arrays and other gc.alloc related stuff
jonuuukas Mar 24, 2021
7b828d8
Merge branch 'universal/render-pass-conversion' of ssh://github.com/U…
jonuuukas Mar 24, 2021
44d350e
Merge branch 'master' into universal/render-pass-conversion
jonuuukas Mar 24, 2021
e57a3ed
merge leftovers
jonuuukas Mar 24, 2021
432dc6b
moving all the RenderPass API specific code in separate methods as a …
manuele-bonanno Mar 24, 2021
bf030cb
remove Configure in SetLastPassFlag
jonuuukas Mar 24, 2021
f7d061a
refatoring (in progress): moving all the RenderPass API specific code…
manuele-bonanno Mar 25, 2021
1b0b6bf
fixing depth-only offscreen camera and exposing usesNativeRenderPass
jonuuukas Mar 25, 2021
6a6dd1f
Merge branch 'universal/render-pass-conversion' of ssh://github.com/U…
jonuuukas Mar 25, 2021
f8a8e62
merge leftovers
jonuuukas Mar 25, 2021
d84f779
more cleaning up and refactoring
manuele-bonanno Mar 26, 2021
ef3e215
splitting initial scene index setup from RenderPass data, and moved R…
manuele-bonanno Mar 26, 2021
eb3514d
Revert "splitting initial scene index setup from RenderPass data, and…
manuele-bonanno Mar 26, 2021
b89f1e8
fix for RenderPass MRT attachments being setup when the RenderPass AP…
manuele-bonanno Mar 26, 2021
ebd2d04
adding profiler samples to NativeRenderPass code
jonuuukas Mar 26, 2021
82d7d6b
moving more RenderPass related code in NativeRenderPass.cs
manuele-bonanno Mar 29, 2021
304a9ab
removed any direct references to RenderPass frame data outside of Nat…
manuele-bonanno Mar 29, 2021
391784c
fixing targetTexture != null and depthOnly pass cornercase with wrong…
jonuuukas Mar 29, 2021
617322d
NativeRenderPass from static to partial class conversion
jonuuukas Mar 30, 2021
8a00998
add RenderPassDescriptor to contain dimensions and etc.
jonuuukas Mar 30, 2021
a62901e
add GetDefaultGraphicsFormat for RenderPass attachment descriptors
jonuuukas Mar 30, 2021
bc7a4b8
remove isFirstMergeable and isLastMergeable and add comments
jonuuukas Mar 30, 2021
2ee17b8
moving some stuff and removing some parameters for methods due to par…
jonuuukas Mar 30, 2021
073e77e
some more cleanup
jonuuukas Mar 30, 2021
279d157
more cleanup: making methods non static and reducing the input parame…
manuele-bonanno Mar 30, 2021
c5d86db
renamed attachmentIndices in m_InputAttachmentIndices
manuele-bonanno Mar 30, 2021
f1c6990
more cleanup: removing unnecessary statics
manuele-bonanno Mar 30, 2021
e2c0ebe
improved subpass merging
manuele-bonanno Mar 30, 2021
bcc0638
more renaming of methods
manuele-bonanno Mar 31, 2021
276e7d8
renaming more stuff for consistency with previous renamings
manuele-bonanno Mar 31, 2021
eb5be47
renderPass MRT clear logic fixed
jonuuukas Mar 31, 2021
49506d5
useDepth always if depthOnly is true
jonuuukas Apr 6, 2021
6412f03
fixing useDepth not picking up default depth attachment
jonuuukas Apr 6, 2021
43fc427
adding SupportsNativeRenderPass to rendererFeatures and adding mechan…
jonuuukas Apr 7, 2021
a3c0d85
formatting check fix
manuele-bonanno Apr 7, 2021
8357b72
more formatting check fixes...
manuele-bonanno Apr 7, 2021
8a17123
include cleanup
jonuuukas Apr 13, 2021
a4ada9d
Merge branch 'master' into universal/render-pass-conversion
jonuuukas Apr 13, 2021
c5c3bc0
add validation check and fallback
jonuuukas Apr 13, 2021
00a359a
reviewer feedback changes
jonuuukas Apr 23, 2021
7350695
Merge branch 'master' into universal/render-pass-conversion
jonuuukas Apr 28, 2021
0e287cb
merge cleanup
jonuuukas Apr 28, 2021
c606713
minor changes to address reviewers feedback
manuele-bonanno Apr 29, 2021
05a5fa0
minor refactoring addressing reviewer feedback
manuele-bonanno Apr 29, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
531 changes: 531 additions & 0 deletions com.unity.render-pipelines.universal/Runtime/NativeRenderPass.cs

Large diffs are not rendered by default.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,6 @@ public ShadowResolutionRequest(int _visibleLightIndex, int _perLightShadowSliceI
private RenderTargetHandle m_AdditionalLightsShadowmap;
internal RenderTexture m_AdditionalLightsShadowmapTexture;

int m_ShadowmapWidth;
int m_ShadowmapHeight;

float m_MaxShadowDistanceSq;
float m_CascadeBorder;
Expand Down Expand Up @@ -479,8 +477,8 @@ public bool Setup(ref RenderingData renderingData)

Clear();

m_ShadowmapWidth = renderingData.shadowData.additionalLightsShadowmapWidth;
m_ShadowmapHeight = renderingData.shadowData.additionalLightsShadowmapHeight;
renderTargetWidth = renderingData.shadowData.additionalLightsShadowmapWidth;
renderTargetHeight = renderingData.shadowData.additionalLightsShadowmapHeight;

var visibleLights = renderingData.lightData.visibleLights;
int additionalLightsCount = renderingData.lightData.additionalLightsCount;
Expand Down Expand Up @@ -747,11 +745,12 @@ public bool Setup(ref RenderingData renderingData)
atlasMaxY = Mathf.Max(atlasMaxY, shadowResolutionRequest.offsetY + shadowResolutionRequest.allocatedResolution);
}
// ...but make sure we still use power-of-two dimensions (might perform better on some hardware)
m_ShadowmapWidth = Mathf.NextPowerOfTwo(atlasMaxX);
m_ShadowmapHeight = Mathf.NextPowerOfTwo(atlasMaxY);

float oneOverAtlasWidth = 1.0f / m_ShadowmapWidth;
float oneOverAtlasHeight = 1.0f / m_ShadowmapHeight;
renderTargetWidth = Mathf.NextPowerOfTwo(atlasMaxX);
renderTargetHeight = Mathf.NextPowerOfTwo(atlasMaxY);

float oneOverAtlasWidth = 1.0f / renderTargetWidth;
float oneOverAtlasHeight = 1.0f / renderTargetHeight;

Matrix4x4 sliceTransform;
for (int globalShadowSliceIndex = 0; globalShadowSliceIndex < shadowCastingLightsBufferCount; ++globalShadowSliceIndex)
Expand Down Expand Up @@ -784,7 +783,7 @@ public bool Setup(ref RenderingData renderingData)
m_AdditionalLightShadowSliceIndexTo_WorldShadowMatrix[globalShadowSliceIndex] = sliceTransform * m_AdditionalLightShadowSliceIndexTo_WorldShadowMatrix[globalShadowSliceIndex];
}

m_AdditionalLightsShadowmapTexture = ShadowUtils.GetTemporaryShadowTexture(m_ShadowmapWidth, m_ShadowmapHeight, k_ShadowmapBufferBits);
m_AdditionalLightsShadowmapTexture = ShadowUtils.GetTemporaryShadowTexture(renderTargetWidth, renderTargetHeight, k_ShadowmapBufferBits);
m_MaxShadowDistanceSq = renderingData.cameraData.maxShadowDistance * renderingData.cameraData.maxShadowDistance;
m_CascadeBorder = renderingData.shadowData.mainLightShadowCascadeBorder;

Expand All @@ -793,7 +792,7 @@ public bool Setup(ref RenderingData renderingData)

public override void Configure(CommandBuffer cmd, RenderTextureDescriptor cameraTextureDescriptor)
{
ConfigureTarget(new RenderTargetIdentifier(m_AdditionalLightsShadowmapTexture), GraphicsFormat.ShadowAuto, m_ShadowmapWidth, m_ShadowmapHeight, 1, true);
ConfigureTarget(new RenderTargetIdentifier(m_AdditionalLightsShadowmapTexture), GraphicsFormat.ShadowAuto, renderTargetWidth, renderTargetHeight, 1, true);
ConfigureClear(ClearFlag.All, Color.black);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,6 @@ private static class MainLightShadowConstantBuffer
const int k_ShadowmapBufferBits = 16;
float m_CascadeBorder;
float m_MaxShadowDistanceSq;
int m_ShadowmapWidth;
int m_ShadowmapHeight;
int m_ShadowCasterCascadesCount;
bool m_SupportsBoxFilterForShadows;

Expand Down Expand Up @@ -98,22 +96,22 @@ public bool Setup(ref RenderingData renderingData)

int shadowResolution = ShadowUtils.GetMaxTileResolutionInAtlas(renderingData.shadowData.mainLightShadowmapWidth,
renderingData.shadowData.mainLightShadowmapHeight, m_ShadowCasterCascadesCount);
m_ShadowmapWidth = renderingData.shadowData.mainLightShadowmapWidth;
m_ShadowmapHeight = (m_ShadowCasterCascadesCount == 2) ?
renderTargetWidth = renderingData.shadowData.mainLightShadowmapWidth;
renderTargetHeight = (m_ShadowCasterCascadesCount == 2) ?
renderingData.shadowData.mainLightShadowmapHeight >> 1 :
renderingData.shadowData.mainLightShadowmapHeight;

for (int cascadeIndex = 0; cascadeIndex < m_ShadowCasterCascadesCount; ++cascadeIndex)
{
bool success = ShadowUtils.ExtractDirectionalLightMatrix(ref renderingData.cullResults, ref renderingData.shadowData,
shadowLightIndex, cascadeIndex, m_ShadowmapWidth, m_ShadowmapHeight, shadowResolution, light.shadowNearPlane,
shadowLightIndex, cascadeIndex, renderTargetWidth, renderTargetHeight, shadowResolution, light.shadowNearPlane,
out m_CascadeSplitDistances[cascadeIndex], out m_CascadeSlices[cascadeIndex]);

if (!success)
return false;
}

m_MainLightShadowmapTexture = ShadowUtils.GetTemporaryShadowTexture(m_ShadowmapWidth, m_ShadowmapHeight, k_ShadowmapBufferBits);
m_MainLightShadowmapTexture = ShadowUtils.GetTemporaryShadowTexture(renderTargetWidth, renderTargetHeight, k_ShadowmapBufferBits);
m_MaxShadowDistanceSq = renderingData.cameraData.maxShadowDistance * renderingData.cameraData.maxShadowDistance;
m_CascadeBorder = renderingData.shadowData.mainLightShadowCascadeBorder;

Expand All @@ -122,7 +120,7 @@ public bool Setup(ref RenderingData renderingData)

public override void Configure(CommandBuffer cmd, RenderTextureDescriptor cameraTextureDescriptor)
{
ConfigureTarget(new RenderTargetIdentifier(m_MainLightShadowmapTexture), GraphicsFormat.ShadowAuto, m_ShadowmapWidth, m_ShadowmapHeight, 1, true);
ConfigureTarget(new RenderTargetIdentifier(m_MainLightShadowmapTexture), GraphicsFormat.ShadowAuto, renderTargetWidth, renderTargetHeight, 1, true);
ConfigureClear(ClearFlag.All, Color.black);
}

Expand Down Expand Up @@ -215,8 +213,8 @@ void SetupMainLightShadowReceiverConstants(CommandBuffer cmd, VisibleLight shado
for (int i = cascadeCount; i <= k_MaxCascades; ++i)
m_MainLightShadowMatrices[i] = noOpShadowMatrix;

float invShadowAtlasWidth = 1.0f / m_ShadowmapWidth;
float invShadowAtlasHeight = 1.0f / m_ShadowmapHeight;
float invShadowAtlasWidth = 1.0f / renderTargetWidth;
float invShadowAtlasHeight = 1.0f / renderTargetHeight;
float invHalfShadowAtlasWidth = 0.5f * invShadowAtlasWidth;
float invHalfShadowAtlasHeight = 0.5f * invShadowAtlasHeight;
float softShadowsProp = softShadows ? 1.0f : 0.0f;
Expand Down Expand Up @@ -267,7 +265,7 @@ void SetupMainLightShadowReceiverConstants(CommandBuffer cmd, VisibleLight shado
// enough so custom shaders might use it.
cmd.SetGlobalVector(MainLightShadowConstantBuffer._ShadowmapSize, new Vector4(invShadowAtlasWidth,
invShadowAtlasHeight,
m_ShadowmapWidth, m_ShadowmapHeight));
renderTargetWidth, renderTargetHeight));
}
}
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
using System.Collections;
using System.Collections.Generic;
using System.ComponentModel;
using Unity.Collections;
using UnityEngine.Scripting.APIUpdating;
using UnityEngine.Experimental.Rendering;

Expand Down Expand Up @@ -201,7 +202,10 @@ public Color clearColor
internal bool depthOnly { get; set; }
// this flag is updated each frame to keep track of which pass is the last for the current camera
internal bool isLastPass { get; set; }
// index to track the position in the current frame
internal int renderPassQueueIndex { get; set; }

internal NativeArray<int> m_InputAttachmentIndices;
Copy link
Contributor

Choose a reason for hiding this comment

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

I dont see where it is used

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@lukaschod - yeah, it's not used yet. we can remove it for now, but it will still be added in next PR that will introduce input attachments/fb fetch and etc.


internal GraphicsFormat[] renderTargetFormat { get; set; }
RenderTargetIdentifier[] m_ColorAttachments = new RenderTargetIdentifier[] {BuiltinRenderTextureType.CameraTarget};
Expand All @@ -228,6 +232,7 @@ public ScriptableRenderPass()
renderTargetWidth = -1;
renderTargetHeight = -1;
renderTargetSampleCount = -1;
renderPassQueueIndex = -1;
renderTargetFormat = new GraphicsFormat[]
{
GraphicsFormat.None, GraphicsFormat.None, GraphicsFormat.None,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,5 +92,10 @@ public override void AddRenderPasses(ScriptableRenderer renderer, ref RenderingD
{
renderer.EnqueuePass(renderObjectsPass);
}

internal override bool SupportsNativeRenderPass()
{
return true;
}
}
}
14 changes: 0 additions & 14 deletions com.unity.render-pipelines.universal/Runtime/RenderingUtils.cs
Original file line number Diff line number Diff line change
Expand Up @@ -349,20 +349,6 @@ internal static uint GetValidColorBufferCount(RenderTargetIdentifier[] colorBuff
return nonNullColorBuffers;
}

internal static uint GetValidColorAttachmentCount(AttachmentDescriptor[] colorAttachments)
{
uint nonNullColorBuffers = 0;
if (colorAttachments != null)
{
foreach (var attachment in colorAttachments)
{
if (attachment != RenderingUtils.emptyAttachment)
++nonNullColorBuffers;
}
}
return nonNullColorBuffers;
}

/// <summary>
/// Return true if colorBuffers is an actual MRT setup
/// </summary>
Expand Down
Loading