Skip to content

Conversation

@jonuuukas
Copy link
Contributor

@jonuuukas jonuuukas commented Apr 7, 2021

Purpose of this PR

This is a follow up PR for the initial RenderPass PR: #3380.
This PR introduces the RenderPass merging mechanism, that should allow for eligible passes to be merged.

This also includes:

  • moving most of the native RenderPass logic to a separate partial class in NativeRenderPass.cs.
  • disabling RendererFeatures to use NativeRenderPass unless specific override is called to enable
  • all the technical intricacies of merging passes and subpasses (please read through the TDD linked below for the implementation details)

TDD and more in-depth explanation: https://docs.google.com/document/d/1ddJS70UnbyUT21FxvSgeVy6XFoZXScrMWn5u7J4l790

Entry point for the whole RenderPass Conversion:
https://docs.google.com/document/d/174wpA7AvycbY65wg_Nd3FHt2zJK7sAnOx3qiDUynSro


Testing status

Manually ran the URP editor tests, will run them on iOS and compare non-RenderPass and RenderPass rendering paths.

Comments to reviewers

NOTE: This PR won't enable RenderPasses. The setting will still be disabled, and the selector hidden to users. This is an incremental step to enable further work and optimizations.

manuele-bonanno and others added 30 commits February 26, 2021 11:10
…he RenderPass attachment list. Merging subpasses and attachments which are the same or compatible
…nity-Technologies/Graphics into universal/render-pass-conversion
…nity-Technologies/Graphics into universal/render-pass-conversion
…preparation step to move into different files (potentially)
…nity-Technologies/Graphics into universal/render-pass-conversion
…enderPass data to the NativeRenderPass class
… moved RenderPass data to the NativeRenderPass class"

This reverts commit ef3e215.
// 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.

@fabien-unity fabien-unity removed their request for review April 14, 2021 14:22
@ernestasKupciunas ernestasKupciunas requested a review from a team April 20, 2021 06:19
Copy link
Contributor

@nigeljw-unity nigeljw-unity left a comment

Choose a reason for hiding this comment

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

Just added the comments from our call. I'll do a deeper dive tomorrow.

Copy link
Contributor

@lukaschod lukaschod left a comment

Choose a reason for hiding this comment

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

Looks good

@ernestasKupciunas ernestasKupciunas requested review from ernestasKupciunas and removed request for a team April 22, 2021 16:14
Copy link

@ernestasKupciunas ernestasKupciunas left a comment

Choose a reason for hiding this comment

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

PR looks good. I was running projects using Deferred and Forward renderers. Tested Metal, Vulkan and Gles3 Graphics APIs. Visual correctness looks good. No suspicious activity in the logs. No bugs related to this PR. Good job!
Winter:
Screen Shot 2021-04-26 at 13 06 58

BoatAttack:
Screen Shot 2021-04-26 at 17 13 38-min
PolyFarm:
Screen Shot 2021-04-26 at 14 59 34
Projects used for testing:

Devices under testing:
VLNQA00217, Razer Phone 2, 9.0.0, Snapdragon 845 SDM845, Adreno 630
VLNQA00268, Samsung Galaxy S10+, 10.0.0, Exynos 9 9820, Mali-G76
OnePlus Nord, 10, Snapdragon 765G SM7250-AB, Adreno 620
Samsung Galaxy Z Fold2 5G, 10, Snapdragon 865 SM8250, Adreno 650
iPad Air4, SoC: A14, iOS: 14.0
iPhone 12Pro, SoC: A14, iOS: 14.1

Unity used for testing:
Version: 2021.2.0a16.2217
Revision: trunk b5c81da9dae0
Built: Sun, 25 Apr 2021 10:56:38 GMT

Copy link
Contributor

@nigeljw-unity nigeljw-unity left a comment

Choose a reason for hiding this comment

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

Still got some other things I want to go over, but just posting these comments in advance of the meeting.

w = width;
h = height;
samples = sampleCount;
depthID = rtID;
Copy link
Contributor

Choose a reason for hiding this comment

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

Do we support stencil only formats for descriptors and/or separate stencil usage flags? Did we resolve this discussion in our last meeting? So VK_FORMAT_S8_UINT format, and also https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/VkImageStencilUsageCreateInfo.html

Copy link
Contributor

Choose a reason for hiding this comment

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

as discussed in the call: this will require Vulkan work to be added to the backlog. Currently Unity doesn't support this

// keep track if this is the current camera's last pass and the RT is the backbuffer (BuiltinRenderTextureType.CameraTarget)
// knowing isLastPassToBB can help decide the optimal store action as it gives us additional information about the current frame
bool isLastPassToBB = pass.isLastPass && (colorAttachmentTarget == BuiltinRenderTextureType.CameraTarget);
currentAttachmentDescriptor.ConfigureTarget(colorAttachmentTarget, ((uint)finalClearFlag & (uint)ClearFlag.Color) == 0, !(samples > 1 && isLastPassToBB));
Copy link
Contributor

Choose a reason for hiding this comment

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

I know this proceeded this change, but is this actually the right logic? !(samples > 1 && isLastPassToBB)
Can you clarify it for me, so we want to store when no msaa or when this is not the last pass for the back buffer?

Copy link
Contributor

@manuele-bonanno manuele-bonanno Apr 28, 2021

Choose a reason for hiding this comment

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

this is old logic from before the merge PR. For now we always store but the next PR should optimize that

Copy link
Contributor

@manuele-bonanno manuele-bonanno Apr 28, 2021

Choose a reason for hiding this comment

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

in general though yes, if the pass wouldn't be merged (which was the case before this PR) this would try to discard if MSAA > 1 and is the last pass.
Now with the merging all the store/discard logic will have to take into account the mergeable pass list, so that logic is outdated and harmless, but will need to be reworked in the next bandwidth optimization PR I mentioned in the call

Copy link
Contributor

@manuele-bonanno manuele-bonanno Apr 29, 2021

Choose a reason for hiding this comment

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

just to clarify: "why when MSAA > 1 we requested to store?"

this require an explanation of how Unity implicitly converts to resolve actions in the device implementations:

when MSAA is on, internally the device code converts DontCare actions in Resolve, and Store actions in StoreAndResolve. If the pass is the last pass to BB then we want to NOT store, so the action will become Resolve. Resolve still stores the resolved surface but discards the MSAA'd surface, while StoreAndResolve would also store the MSAA'd surface which wastes a lot of bandwidth.

If MSAA is OFF: then you want to store the non-AA RT, otherwise the final result of the pass wouldn't make it to the BB memory as it would be discarded

Hope it makes sense now

Copy link
Contributor

@hdb-unity hdb-unity left a comment

Choose a reason for hiding this comment

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

No PR issues found - checked for regressions in 2x Universal RP projects.

@phi-lira phi-lira merged commit 6bcd723 into master Apr 29, 2021
@phi-lira phi-lira deleted the universal/render-pass-conversion branch April 29, 2021 09:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.