-
Notifications
You must be signed in to change notification settings - Fork 855
Fixed some Shader Graph shaders fail to compile for Android XR #4806
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
…on system generated semantics.
… into universal/xr/fix-sg-packedvaryings
// | ||
if (subscript.HasPreprocessor() && (subscript.preprocessor.Contains("SHADER_STAGE_FRAGMENT"))) | ||
postUnpackedSubscripts.Add(subscript); | ||
// special case, "UNITY_STEREO_INSTANCING_ENABLED" fields must be packed at the end of the struct because they are system generated semantics |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This will not conflict with the previous one (SHADER_STAGE_FRAGMENT) which also needs to be at the end ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
SHADER_STAGE_FRAGMENT field is also a system generated semantic(FRONT_FACE_SEMANTIC) so it won't conflict in our XR use case. However the comment mentioned semantic ordering in fragment shader I am not sure about that use case. Will dig in more.
public static FieldDescriptor cullFace = new FieldDescriptor(Varyings.name, "cullFace", "VARYINGS_NEED_CULLFACE", "FRONT_FACE_TYPE", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The SHADER_STAGE_FRAGMENT
case is there for situations where frag only SVs coming in wouldn't've been part of the vertex output but still needs to be in the interpolator structure. Since the custom interpolator feature allows arbitrarily adding more interpolators, we had to make sure frag only fields were pushed to the bottom.
A similar issue shows up with instancing, but the instance ids are optionally established in the vertex stage. So-- I think what we want here is for the UNITY_STEREO_INSTANCING_ENABLED
case to come before the SHADER_STAGE_FRAGMENT
case. They both need to be pushed to the end, but fragment should come after instancing.
I think it's safe (and preferred) to generalize this for any type of instancing, not just stereo.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @esmelusina , thanks for the feedback!
I have moved the UNITY_STEREO_INSTANCING_ENABLED case before the SHADER_STAGE_FRAGMENT case in 3774019. I also checked the usage of SV_InstanceID in shader graph. It is only used as vertex shader input and not being used in Varyings. So I think we don't need to handle it in the PackedVaryings logic here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It can be optionally pulled in if the "Instance ID" node is used in the fragment stage. I'd prefer if you went ahead and generalized it.
Thanks!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @esmelusina ,
I have made another commit that generalize the instance case here: 2a2afbe
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changes requested in the comment thread there (and mentioned on slack).
Let me know if that's unclear.
Dev branch (universal/xr/fix-sg-packedvaryings bb08c6a) is green on Yamato for Android XR OpenGL URP Foundation, Lighting, PostProc, and Terrain per links below. For Vulkan these builders fail, but per discussion with XR Graphics devs this is a separate bug(s). I see that PR 4806 is still under dev review, so there will probably be further commits before it can be reviewed by QA. |
…ce semantic handling.
- Generalized the case for all preprocessor cases that contains INSTANCING as keyword.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the changes. I'm approving for shadergraph, I'm going to @tian-unity to see if they want to check that this interacts correctly with speed tree.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This PR’s dev branch last inherited from master around 7/4/2021 so I am comparing Nightly from back then on master against today’s Nightly on the dev branch
-
Graphics (master 45a5ae2)
https://yamato.cds.internal.unity3d.com/jobs/902-Graphics/tree/master/.yamato%252Fall-vfx.yml%2523Nightly_VFX_trunk/7130646/job/pipeline -
Graphics (universal/xr/fix-sg-packedvaryings 2a2afbe)
https://yamato.cds.internal.unity3d.com/jobs/902-Graphics/tree/universal%252Fxr%252Ffix-sg-packedvaryings/.yamato%252F_abv.yml%2523all_project_ci_nightly_trunk/7365566/job
The dev branch is green wherever master was green except for several jobs. These became green upon re-run except for these two:
-
URP_Performance_BoatAttack on Win_DX12_performance_build_editmode_mono_Linear
-
URP_Performance_BoatAttack on Win_Vulkan_performance_build_editmode_mono_Linear
Both of these jobs had the following error and crashed. I do not believe this is due to this PR because I see the same error and crash in recent jobs on Graphics master for these two pipelines.
Error retrieving packages from source 'https://artifactory-slo.bf.unity3d.com/artifactory/api/nuget/slough-nuget':
Could not connect to the feed specified at 'https://artifactory-slo.bf.unity3d.com/artifactory/api/nuget/slough-nuget'. Please verify that
[12:17:30.831 Information] the package source (located in the Package Manager Settings) is valid and ensure your network connectivity.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Re-Approving to clear lock.
Purpose of this PR
Testing status
Comments to reviewers
UNITY_STEREO_INSTANCING_ENABLED
define so that they could be placed at the end of PackedVaryings struct. This is required for SV_RenderTargetArrayIndex to avoid error:Non system-generated input signature parameter () cannot appear after a system generated value