Skip to content

Conversation

peterjohnlong
Copy link
Contributor

Purpose of this PR

The purpose of this PR is to activate HDRP ray tracing functionality for PS5, by enabling compilation of associated shaders and code paths.

Testing status

Tested locally on HDRP_DXR_Tests on the console against reference images https://github.cds.internal.unity3d.com/unity/ScriptableRenderPipelinePrivate/tree/ps5-dxr/ReferenceImages/HDRP_DXR_Tests/PS5/PlayStation5/None
Tested locally on HDRP_DXR_Tests are remain green on DX12.
Currently yamato SRP PS5-DXR test is broken due to unrelated issue.

@github-actions
Copy link

Hi! This comment will help you figure out which jobs to run before merging your PR. The suggestions are dynamic based on what files you have changed.
Link to Yamato: https://yamato.cds.internal.unity3d.com/jobs/902-Graphics
Search for your PR branch using the sidebar on the left, then add the following segment(s) to the end of the URL (you may need multiple tabs depending on how many packages you change)

HDRP
/.yamato%252Fall-hdrp.yml%2523PR_HDRP_2021.2

Shader Graph
/.yamato%252Fall-shadergraph.yml%2523PR_ShaderGraph_2021.2
Depending on your PR, you may also want
/.yamato%252Fall-shadergraph_builtin_foundation.yml%2523PR_ShaderGraph_BuiltIn_Foundation_2021.2
/.yamato%252Fall-shadergraph_builtin_lighting.yml%2523PR_ShaderGraph_BuiltIn_Lighting_2021.2

Depending on the scope of your PR, you may need to run more jobs than what has been suggested. Please speak to your lead or a Graphics SDET (#devs-graphics-automation) if you are unsure.

Copy link
Contributor

@sebastienlagarde sebastienlagarde left a comment

Choose a reason for hiding this comment

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

outside of the quetion about SystemInfo.supportsRayTracing (which could be done in a next PR), all looks good.

Other question: With this PR, can we trigger test on scriptableRenderPipelinePrivate on PS5 for raytrace?

Also I expect it need to be backport up to 20.3 ?

@sebastienlagarde sebastienlagarde marked this pull request as ready for review July 29, 2021 15:41
@sebastienlagarde sebastienlagarde requested a review from a team as a code owner July 29, 2021 15:41
Copy link
Contributor

@anisunity anisunity left a comment

Choose a reason for hiding this comment

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

I think we need to rework a bit the wizard ps5 code as the wizard was centered around the dx12 problem. I'll take it from here @peterjohnlong if you're fine with that. The ps5 related changed are fine (except my question on the max recursion).

++EditorGUI.indentLevel;
EditorGUILayout.PropertyField(serialized.renderPipelineSettings.supportedRayTracingMode, Styles.supportedRayTracingMode);
if (serialized.renderPipelineSettings.supportRayTracing.boolValue && !UnityEngine.SystemInfo.supportsRayTracing)
if (serialized.renderPipelineSettings.supportRayTracing.boolValue && !UnityEngine.SystemInfo.supportsRayTracing
Copy link
Contributor

Choose a reason for hiding this comment

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

I would argue this is the best way of doing it, let's discuss

bool IsArchitecture64Bits()
=> EditorUserBuildSettings.activeBuildTarget == BuildTarget.StandaloneWindows64;
{
return (EditorUserBuildSettings.activeBuildTarget == BuildTarget.StandaloneWindows64) || (EditorUserBuildSettings.activeBuildTarget == BuildTarget.PS5);
Copy link
Contributor

Choose a reason for hiding this comment

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

same here, not the best way imo


// WARNING: This define must be kept in sync with the c# code
#if defined(SHADER_API_PSSL)
#define RAYTRACING_MAX_RECURSION 1
Copy link
Contributor

Choose a reason for hiding this comment

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

why this one only? RayTracingReflection.raytracing and RaytracingIndirectDiffuse need to have their max recursion force to 1 aswell

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@anisunity I am fine with you reworking the wizard code. Good point about RaytracingRenderer.raytrace - mainly it was done there as a reaction to some HDRP_DXR tests e.g. 902_Materials_SG_Variants_xxxxx where a third of the screen is testing recursive raytrace, in the case of PS5 I wanted to achieve a consistent result of just the background. I will rethink best way to do this.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@anisunity I have reverted this change to RayTracingRenderer.raytrace, and added a scripting define in ProjectSettings NO_RAY_RECURSION, and tests to set the max recursion in the shader setup .cs code for this and the other cases

@peterjohnlong
Copy link
Contributor Author

@sebastienlagarde
I am looking into running test on scriptableRenderPipelinePrivate on PS5 for raytrace again, which is broken ATM.
I will need to backport up to 20.3, but only once the C++ PR for the backports 2020.3 and 2021.1 are ready otherwise it will break PS5.

@anisunity
Copy link
Contributor

@peterjohnlong i'll do a quick pass on the pr later this week to change the wizard, etc.

@anisunity anisunity requested a review from RSlysz August 11, 2021 21:56
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.

Looks good. But please rename Bobby



[InitializeOnLoadMethod]
static void Bobby()
Copy link
Contributor

Choose a reason for hiding this comment

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

Please find a meaningful name :)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Renamed Bobby to InitializeEntryList


internal void ReBuildEntryList()
{
m_Entries = null;
Copy link
Contributor

Choose a reason for hiding this comment

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

Not needed. The line below already replace it. Former will be cleaned later by garbage collection.

Note that alternately if you only nullify it, the list will be rebuild by the lazy constructor anyway in entries. But in this case the name of this method is not accurate anymore.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Removed the unneeded code

}
}

Entry[] BuildEntryList()
Copy link
Contributor

@RSlysz RSlysz Aug 12, 2021

Choose a reason for hiding this comment

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

[Optional] I think that you can simplify things a little by removing BuildEntryList() and only keep ReBuildEntryList().

You should be able to make it work with only

internal void ReBuildEntryList() //current BuildEntryList() in your code
{
    //compute List<Entry> entryList as below this comment
    m_Entries = BuildEntryList();
}

and then entries would become

Entry[] entries
{
    get
    {
        // due to functor, cannot static link directly in an array and need lazy init
        if (m_Entries == null)
            ReBuildEntryList();
        return m_Entries;
    }
 }

Especially because when cleaning current ReBuildEntryList, it will become a one liner method.

@RSlysz
Copy link
Contributor

RSlysz commented Aug 12, 2021

Above is a fix for error logged in the console when user switch platform and Wizard window is open.

(@alex-vazquez for awareness. If this PR don't land, we would still need to do this fix. It seams unrelated to current Wizard change and could have been introduced 2 month ago in 31b7b5d)

@sebastienlagarde sebastienlagarde merged commit 8714705 into master Aug 25, 2021
@sebastienlagarde sebastienlagarde deleted the ps5/raytracing branch August 25, 2021 11:44
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.

4 participants