Skip to content

Conversation

@cdxntchou
Copy link

@cdxntchou cdxntchou commented Jan 29, 2021

Purpose of this PR

Fix for https://fogbugz.unity3d.com/f/cases/1301915/

Include files are now tracked by GUID (so they can find a file even after it moves), the includes are propagated out of subgraphs, and merged uniquely by the generator.

Some care was taken to keep the HDRP "replace placeholder" functionality working properly.


Testing status

  • Verified that moving or renaming CFN-include files from a subgraph now works correctly -- the subgraph does NOT reimport, but the graphs that use it DO reimport, and the correct path is used
  • Verified that serialized subgraph assets contains include information from custom function nodes
  • Verified that serialized subgraph assets contains include information from parallax mapping nodes
  • Verified that subgraph nodes pull in includes from subgraph assets
  • Verified that multiple-includes of the same file get de-duplicated
  • Verified that custom function nodes using includes still work correctly
  • Verified that parallax mapping nodes still work correctly
    image
  • verified that HDRP "replace placeholder" include continues to work properly
  • tested VFX integration path, when using CFN-include files
  • also tested moving directories of those files used by VFX
    image

Added new Editor test for moving directories of ShaderGraph/SubGraphs containing CFN nodes using include files, similar to the repro case.

  • verified that the test failed before this PR
  • verified that it now works, after this PR

ShaderGraph PR job: 🟢
https://yamato.cds.internal.unity3d.com/jobs/902-Graphics/tree/sg%252Ffix%252F1301915/.yamato%252Fall-shadergraph.yml%2523PR_ShaderGraph_trunk/5141106/job/pipeline

ShaderGraph Stereo PR job: 🟢
https://yamato.cds.internal.unity3d.com/jobs/902-Graphics/tree/sg%252Ffix%252F1301915/.yamato%252Fall-shadergraph_stereo.yml%2523PR_ShaderGraph_Stereo_trunk/5141105/job/pipeline

HDRP PR job: failures match master failures
https://yamato.cds.internal.unity3d.com/jobs/902-Graphics/tree/sg%252Ffix%252F1301915/.yamato%252Fall-hdrp.yml%2523PR_HDRP_trunk/5141136/job/pipeline

Master equivalent job:
https://yamato.cds.internal.unity3d.com/jobs/902-Graphics/tree/master/.yamato%252Fall-hdrp.yml%2523PR_HDRP_trunk/5068229/job/pipeline

Failures:
HDRP on Linux_Vulkan_playmode_cache_mono_Linear on version trunk -- same 4 tests failed same way
HDRP on OSX_Metal_playmode_cache_mono_Linear on version trunk -- master failed 8 tests, this branch failed 6, all matching master failures
master additionally failed: HDRP_GraphicTestRunner.2106_GI_EmissionSG, HDRP_GraphicTestRunner.2108_GI_IESCookie_B
seems unrelated to my changes, I assume non-determinism
HDRP on Win_Vulkan_playmode_cache_mono_Linear on version trunk -- same 4 tests failed same way
HDRP on Win_DX12_playmode_cache_mono_Linear on version trunk -- same 5 tests failed same way
slight difference on error amount for one of the same tests that failed in master OSX_Metal above -- assume non-determinism
HDRP on Win_DX11_playmode_XR_cache_mono_Linear on version trunk -- both had script compile failures
HDRP on Win_DX11_playmode_cache_mono_Linear on version trunk -- same 4 tests failed same way

HDRP_DXR PR Job: 🟢
https://yamato.cds.internal.unity3d.com/jobs/902-Graphics/tree/sg%252Ffix%252F1301915/.yamato%252Fall-hdrp_dxr.yml%2523PR_HDRP_DXR_trunk/5141127/job/pipeline

HDRP_Hybrid PR Job: 🟢
https://yamato.cds.internal.unity3d.com/jobs/902-Graphics/tree/sg%252Ffix%252F1301915/.yamato%252Fall-hdrp_hybrid.yml%2523PR_HDRP_Hybrid_trunk/5141129/job/pipeline

HDRP VFX PR job: 🟢
https://yamato.cds.internal.unity3d.com/jobs/902-Graphics/tree/sg%252Ffix%252F1301915/.yamato%252Fall-vfx_hdrp.yml%2523PR_VFX_HDRP_trunk/5141135/job/pipeline

Universal PR job: failures match master failures
https://yamato.cds.internal.unity3d.com/jobs/902-Graphics/tree/sg%252Ffix%252F1301915/.yamato%252Fall-universal.yml%2523PR_Universal_trunk/5174976/job/pipeline

Master equivalent job:
https://yamato.cds.internal.unity3d.com/jobs/902-Graphics/tree/master/.yamato%252Fall-universal.yml%2523PR_Universal_trunk/5068179/job/pipeline

failures:
Universal on iPhone_Metal_Standalone_cache_il2cpp_Linear on version trunk -- same 1 test failed same way
Universal on Android_Vulkan_Standalone_cache_il2cpp_Linear on version trunk -- did not complete, re-running
Universal on Android_OpenGLES3_Standalone_cache_il2cpp_Linear on version trunk -- same 3 tests failed same way
Universal on Win_DX11_playmode_XR_cache_mono_Linear on version trunk -- both had script compile errors


Comments to reviewers

Notes for the reviewers you have assigned.

… of subgraphs, and uniquely merged

Some care was taken to keep the HDRP "replace placeholder" functionality working properly..
@cdxntchou cdxntchou marked this pull request as ready for review January 30, 2021 00:07
@cdxntchou cdxntchou requested a review from a team as a code owner January 30, 2021 00:07
@cdxntchou cdxntchou requested a review from a user February 1, 2021 18:48

if (!String.IsNullOrEmpty(include.descriptor.value))
finalIncludes.Add(include.descriptor.value, include.descriptor.location, include.fieldConditions);
var path = include.path;
Copy link
Author

@cdxntchou cdxntchou Feb 1, 2021

Choose a reason for hiding this comment

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

This seems like an error in that it used to be modifying the values stored in the passDescriptor (which may be static global).. with this PR it no longer modifies the existing structure...

}

public bool Reload(HashSet<string> changedFileDependencies)
public bool Reload(HashSet<string> changedFileDependencyGUIDs)
Copy link
Author

Choose a reason for hiding this comment

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

this is just changing the name of the variable to make it clear these are GUIDs not paths

if (asset == null || hasError)
return;

registry.RequiresIncludes(asset.includes);
Copy link
Author

Choose a reason for hiding this comment

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

This forwards the includes from the subgraph asset to any graph using them..

Dictionary<string, FunctionSource> m_Sources = new Dictionary<string, FunctionSource>();
bool m_Validate = false;
ShaderStringBuilder m_Builder;
IncludeCollection m_Includes;
Copy link
Author

Choose a reason for hiding this comment

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

Easiest was to make the FunctionRegistry effectively a "FunctionAndNodeInclude" registry...

[GenerationAPI]
internal class DefineCollection : IEnumerable<DefineCollection.Item>
{
public class Item : IConditional, IShaderString
Copy link
Author

Choose a reason for hiding this comment

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

IShaderString interface is not used anywhere... I removed it.

{
[GenerationAPI]
internal class IncludeCollection : IEnumerable<IncludeCollection.Item>
[Serializable]
Copy link
Author

@cdxntchou cdxntchou Feb 1, 2021

Choose a reason for hiding this comment

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

The changes here are to make the IncludeCollection serializable, so we can serialize it as part of the subgraph asset. We also switch it to being GUID-based instead of path-based. We still record the path, but the GUID is treated as the authoritative link to the file.

Copy link
Author

@cdxntchou cdxntchou Feb 1, 2021

Choose a reason for hiding this comment

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

Note that I removed "Item" and just combined it with the IncludeDescriptor. No one else was using either of them, so there didn't seem to be any reason to have separate classes for the two.

namespace UnityEditor.ShaderGraph
{
[GenerationAPI]
[Serializable]
Copy link
Author

Choose a reason for hiding this comment

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

Not strictly necessary, enums are serializable by default, but serves as a good reminder that this is a serialized enumeration, if anyone is looking to change it in the future...

string command = GenerationUtils.GetSpliceCommand(passPragmaBuilder.ToCodeBlock(), "PassPragmas");
spliceCommands.Add("PassPragmas", command);
}

Copy link
Author

Choose a reason for hiding this comment

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

These move further down, so we can combine the Target/pass includes with the node includes before generating them.

@cdxntchou cdxntchou changed the title [master] [ShaderGraph] [bugfix 1301915] Node Include files are now tracked explicitly BY GUID [2021.2] [ShaderGraph] [bugfix 1301915] Node Include files are now tracked explicitly BY GUID Feb 2, 2021
Copy link

@ghost ghost left a comment

Choose a reason for hiding this comment

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

Did just a bit of extra testing (setting up a use case scenario and making sure the bug is fixed). Other than that, developer testing is sufficient.

@cdxntchou cdxntchou merged commit 88058ae into master Feb 4, 2021
@cdxntchou cdxntchou deleted the sg/fix/1301915 branch February 4, 2021 20:36
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.

3 participants