Skip to content

Conversation

sebastienlagarde
Copy link
Contributor

@sebastienlagarde sebastienlagarde commented Apr 21, 2021

Purpose of this PR

This PR correctly fix the issue attempted to be fixed in this PR:
#3894
and this fogbugzz:
https://fogbugz.unity3d.com/f/cases/1320304/

We are changing the behavior.

Previously, the raytracing resources was re-loaded and init only if the option Real-time raytracing was enabled on the current use asset and reset to null otherwise. This is causing issue in case of multiple configuration with mismatch on this property (i.e some true, some false).
The PR #3894 is an attempt to fix this problem but wasn't the correct solution and the issue was remaining.

The correct solution is to always initialize the raytracing resources, as they are located in the Default settings and must be embed in the build if any of the configuration required it. So the users could switch at runtime between raytracing and non raytracing.

This is what this PR is doing. It now always init and reload the raytracing resources like the regular one if any of the quality level of graphicssettings RP have raytracing - this is what is done on master - BUT it use the stripper to remove the unused compute shader from it. However there is not stripper yet for raytrace shader so they can't be removed. Fortunately, on platform which don't support raytrace shader (so all of them except DX12), those shader will not be compile anyway.

The downside is that for platform which support DX12 the raytrace resources will always been embed even if raytracing is not used. As of today the usage of DX12 is related to raytracing as otherwise it is less performant it is not really a problem.


Testing status

I have tested the template on windows with a RTX card. I was able to build a player with and without raytracing and checked in the compute shader compilation list with verbose mode that compute shader used for raytracing were correctly used.


Comments to reviewers

For QA, can you please test this PR on metal and console to see if the player build works correctly? I want to check that a non null raytrace resource have no impact on those platform. Thanks

Note : I don't add a changelog as I am reusing the one in #3894 as it have been backported "Fixed HDRPAsset loosing its reference to the ray tracing resources when clicking on a different quality level that doesn't have ray tracing (case 1320304)."

@github-actions
Copy link

It appears that you made a non-draft PR!
Please convert your PR to draft (button on the right side of the page)
and cancel any jobs that started on Yamato.
See the PR template for more information.
Thank you!

@sebastienlagarde sebastienlagarde changed the title Hdrp/fix resource raytracing [10.x.x HDRP] Fix issue with raytracing resources not properly initialize Apr 21, 2021
@remi-chapelain remi-chapelain requested a review from a team April 22, 2021 07:44
Copy link
Contributor

@RSlysz RSlysz left a comment

Choose a reason for hiding this comment

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

Still, check if we also need to verify hardware compatibility or if supportRayTracing can only be true if this is the case.

if (HDRenderPipeline.defaultAsset.renderPipelineRayTracingResources == null)
return;

foreach (var fieldInfo in HDRenderPipeline.defaultAsset.renderPipelineRayTracingResources.GetType().GetFields(BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.Instance | BindingFlags.Static))
Copy link
Contributor

Choose a reason for hiding this comment

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

You should not need BindingFlags.Static. There will never have static field in resources as they are not serialized.

Comment on lines +615 to +618
bool requiresRayTracingResources = false;
// Make sure to include ray-tracing resources if at least one of the defaultAsset or quality levels needs it
if (defaultAsset.currentPlatformRenderPipelineSettings.supportRayTracing)
requiresRayTracingResources = true;
Copy link
Contributor

Choose a reason for hiding this comment

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

Can be simplified as
bool requiresRayTracingResources = defaultAsset.currentPlatformRenderPipelineSettings.supportRayTracing;

Does former GatherRayTracingSupport also check if hardware is compatible? Should we check it here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

indeed, will make the change on master. We must not check hardware support as you can build with a GPU not supporting it

@sebastienlagarde
Copy link
Contributor Author

After quick check with Remi we will merge the PR so it can be tested in 10.5.0

@sebastienlagarde sebastienlagarde merged commit 08be9e0 into 10.x.x/release Apr 22, 2021
@sebastienlagarde sebastienlagarde deleted the HDRP/fix-resource-raytracing branch April 22, 2021 08:22
@remi-chapelain
Copy link
Contributor

remi-chapelain commented Apr 22, 2021

already tested on the branch with 2020.3.6f1.

  • Render is fine again in editor if there's mismatch for realtime raytracing flags between default HDRP and current HDRP assets. ✔️
  • Built a player with low quality (no raytracing) by default and tried to change quality setting at runtime to be sure that raytracing was still working. ✔️
  • Built a player with dx11, then open the palyer with -force-d3d12 and checked that raytracing was still working✔️

Will make another quick pass on new 10.5.0 package version tomorow.

sebastienlagarde added a commit that referenced this pull request Apr 30, 2021
…lize (#4268)

* draft

* Fix build DXR

* Match behavior with the one in master
sebastienlagarde added a commit that referenced this pull request May 1, 2021
* [10.x.x HDRP] Fix issue with raytracing resources not properly initialize (#4268)

* draft

* Fix build DXR

* Match behavior with the one in master

* Updated ray tracing settings and added it to the table of contents  (#4279)

* Updated ray tracing settings and added it to the toc

* Removed hyphens from rtss toc entry

* Fix shader warning when using Lanczos upsampling (#4280)

* Added DOTS_INSTANCING_ON variants to the "HDRP/Decal" shader #4284

* [HDRP] Fp16_PPAlpha Panini projection, Motion Blur test and moved other Fp16Alpha scenes to one #4290

* [HDRP] Fix undo of some properties on light editor #4293

* Opt-out of builtin auto baking of ambient/reflection probe. #4324

* Revert "Opt-out of builtin auto baking of ambient/reflection probe. #4324"

This reverts commit 719e835.

* Hd/redo fix inputregistering domainreload (#4358)

* Update InputRegistering.cs

* Remove asset modification if InputSystem package is in use

* Prevent missuse of InputRegistering while InputSystem package is in use

* cleaning

* more cleaning

* Update code to use Next instead of GetArrayElementAtIndex

* Fix strange out of range error

Co-authored-by: Lewis Jordan <lewis.jordan@hotmail.co.uk>
Co-authored-by: Pavlos Mavridis <pavlos.mavridis@unity3d.com>
Co-authored-by: Andrew Saraev <67020478+AndrewSaraevUnity@users.noreply.github.com>
Co-authored-by: TomasKiniulis <50582134+TomasKiniulis@users.noreply.github.com>
Co-authored-by: Adrien de Tocqueville <adrien.tocqueville@unity3d.com>
Co-authored-by: JulienIgnace-Unity <julien@unity3d.com>
Co-authored-by: Remi Slysz <40034005+RSlysz@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants