Skip to content

Conversation

@cdxntchou
Copy link

@cdxntchou cdxntchou commented Mar 18, 2021

Purpose of this PR

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

This fixes a regression introduced by this PR: #3290
By registering the node include files at generation time, instead of splicing them into the generated code, we can now properly track the include dependencies; but it also moved the location where the includes were spliced. In particular, the node includes now show up before the property declarations in many templates. In order for the CustomFunctionNode included files to be able to access shader properties, the includes must come after the property declarations. This PR adds a new include splice location "Graph", which come after the property declaration, and then moves all node-declared includes to this new location.


Testing status

Added a ShaderGraph test for include file usage of graph properties:

  • Verified the new test breaks on master, but passes in this PR
  • Tested against CFN-include-file-using graph that worked in 2020.2, but fails in 2021.2a7, verified that it now works.
  • Verified the generated shader has the correct includes in the new and old locations
  • Tested the graph above in URP (using URP template)
  • Tested previews using the above CFN (using shadergraph/preview template)
  • Tested the graph in HDRP (using HDRP template)
  • Tested the graph with the HDRP Decal sub-target (different template)

Yamato tests:
(running against trunk f4de2e18f4148a678759ff44540c9d25ffd9d99f, because of trunk breakages)

ShaderGraph PR Job: 🟢
https://yamato.cds.internal.unity3d.com/jobs/902-Graphics/tree/sg%252Ffix%252F1322467/.yamato%252Fall-shadergraph.yml%2523PR_ShaderGraph_CUSTOM-REVISION/5939294/job/pipeline

Failures:
Build ShaderGraph on iPhone_Metal_il2cpp_Linear_Standalone_cache_build_Player on version CUSTOM-REVISION -- success on re-run

Universal PR Job: 🟢
https://yamato.cds.internal.unity3d.com/jobs/902-Graphics/tree/sg%252Ffix%252F1322467/.yamato%252Fall-universal_split.yml%2523PR_Universal_Split_CUSTOM-REVISION/5939301/job/pipeline

Failures:
URP_Foundation on iPhone_Metal_Standalone_cache_il2cpp_Linear on version CUSTOM-REVISION -- success on re-run

HDRP PR Job: 🟢
https://yamato.cds.internal.unity3d.com/jobs/902-Graphics/tree/sg%252Ffix%252F1322467/.yamato%252Fall-hdrp.yml%2523PR_HDRP_CUSTOM-REVISION/5946563/job/pipeline

Failures:
Build VFX_HDRP on Win_DX11_mono_Linear_Standalone_cache_build_Player on version CUSTOM-REVISION -- also fails on master
Build VFX_HDRP on Win_DX12_mono_Linear_Standalone_cache_build_Player on version CUSTOM-REVISION -- also fails on master
VFX_HDRP on Win_DX11_Standalone_cache_mono_Linear on version CUSTOM-REVISION -- also fails on master
VFX_HDRP on Win_DX12_Standalone_cache_mono_Linear on version CUSTOM-REVISION -- also fails on master

Pack and Test Job: 🟢
https://yamato.cds.internal.unity3d.com/jobs/902-Graphics/tree/sg%252Ffix%252F1322467/.yamato%252F_projectcontext.yml%2523test_all_project_Win_trunk/5946535/job


Comments to reviewers

Notes for the reviewers you have assigned.

bool isOSX =
(Application.platform == RuntimePlatform.OSXEditor) ||
(Application.platform == RuntimePlatform.OSXPlayer);

Copy link
Contributor

Choose a reason for hiding this comment

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

Vulkan doesn't guarantee more than 16 either. I suspect most desktop implementations actually provide more than 16, but the hardware requirements for the spec are derived from OpenGL ES 3.1, so it's not guaranteed without checking.

Copy link
Author

Choose a reason for hiding this comment

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

Yeah, it at least passes on Windows Editor / Vulkan on my box.

Copy link
Contributor

@jessebarker jessebarker left a comment

Choose a reason for hiding this comment

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

LGTM

@cdxntchou cdxntchou marked this pull request as ready for review March 23, 2021 21:22
@cdxntchou cdxntchou requested review from a team as code owners March 23, 2021 21:22
@cdxntchou cdxntchou requested a review from a user March 23, 2021 21:22
Copy link
Contributor

@jessebarker jessebarker left a comment

Choose a reason for hiding this comment

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

Updated changes look good

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.

Developer testing is sufficient

@marctem marctem merged commit 331d995 into master Mar 26, 2021
@marctem marctem deleted the sg/fix/1322467 branch March 26, 2021 17:02
sebastienlagarde pushed a commit that referenced this pull request Mar 30, 2021
* Fix include ordering by moving graph/node based includes below the property declarations

* Adding tests for include file / custom function node issue (and also 12.x version tests)

* Handling compile faillures on OSX GLCore tests (sampler limit count hit on some test shaders)

* Fix compile

* Disabling failing test for now

* Think this will fix the tests -- variable name was too long

* Testing super short variable names

* think this fixes it -- force asset database to update before we run the multi-import tests (we rely on being able to lookup files by GUID)
sebastienlagarde added a commit that referenced this pull request Mar 31, 2021
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.

6 participants