From 43b03244e2e732dc482f8ea6ea4e27da9fdce2cf Mon Sep 17 00:00:00 2001 From: thomas-zeng Date: Fri, 4 Jun 2021 13:20:28 -0700 Subject: [PATCH 1/4] * Fixed an issue where system generated semantics are placed before non system generated semantics. --- .../Editor/Generation/Processors/GenerationUtils.cs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/com.unity.shadergraph/Editor/Generation/Processors/GenerationUtils.cs b/com.unity.shadergraph/Editor/Generation/Processors/GenerationUtils.cs index 83c7bb39017..66edd8df23f 100644 --- a/com.unity.shadergraph/Editor/Generation/Processors/GenerationUtils.cs +++ b/com.unity.shadergraph/Editor/Generation/Processors/GenerationUtils.cs @@ -154,6 +154,10 @@ internal static void GeneratePackedStruct(StructDescriptor shaderStruct, ActiveF // 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 + // + else if(subscript.HasPreprocessor() && (subscript.preprocessor.Contains("UNITY_STEREO_INSTANCING_ENABLED"))) + postUnpackedSubscripts.Add(subscript); else if (subscript.HasSemantic() || subscript.vectorCount == 0) packedSubscripts.Add(subscript); else From bb08c6a64226e0e7e8294aea87534b4b2e697119 Mon Sep 17 00:00:00 2001 From: thomas-zeng Date: Fri, 4 Jun 2021 16:23:56 -0700 Subject: [PATCH 2/4] * Formatted the file. --- .../Editor/Generation/Processors/GenerationUtils.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/com.unity.shadergraph/Editor/Generation/Processors/GenerationUtils.cs b/com.unity.shadergraph/Editor/Generation/Processors/GenerationUtils.cs index 66edd8df23f..85e360bda9f 100644 --- a/com.unity.shadergraph/Editor/Generation/Processors/GenerationUtils.cs +++ b/com.unity.shadergraph/Editor/Generation/Processors/GenerationUtils.cs @@ -156,7 +156,7 @@ internal static void GeneratePackedStruct(StructDescriptor shaderStruct, ActiveF 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 // - else if(subscript.HasPreprocessor() && (subscript.preprocessor.Contains("UNITY_STEREO_INSTANCING_ENABLED"))) + else if (subscript.HasPreprocessor() && (subscript.preprocessor.Contains("UNITY_STEREO_INSTANCING_ENABLED"))) postUnpackedSubscripts.Add(subscript); else if (subscript.HasSemantic() || subscript.vectorCount == 0) packedSubscripts.Add(subscript); From 37740195699d8cfb509eb17b87c8d25c6471b065 Mon Sep 17 00:00:00 2001 From: thomas-zeng Date: Wed, 9 Jun 2021 13:41:16 -0700 Subject: [PATCH 3/4] * Addressed some feedback - moving stereo output logic before cull face semantic handling. --- .../Editor/Generation/Processors/GenerationUtils.cs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/com.unity.shadergraph/Editor/Generation/Processors/GenerationUtils.cs b/com.unity.shadergraph/Editor/Generation/Processors/GenerationUtils.cs index 85e360bda9f..80d372a04b1 100644 --- a/com.unity.shadergraph/Editor/Generation/Processors/GenerationUtils.cs +++ b/com.unity.shadergraph/Editor/Generation/Processors/GenerationUtils.cs @@ -149,14 +149,14 @@ internal static void GeneratePackedStruct(StructDescriptor shaderStruct, ActiveF if (fieldIsActive) { - // special case, "SHADER_STAGE_FRAGMENT" fields must be packed at the end of the struct, - // otherwise the vertex output struct will have different semantic ordering than the fragment input struct. + // special case, "UNITY_STEREO_INSTANCING_ENABLED" fields must be packed at the end of the struct because they are system generated semantics // - if (subscript.HasPreprocessor() && (subscript.preprocessor.Contains("SHADER_STAGE_FRAGMENT"))) + if (subscript.HasPreprocessor() && (subscript.preprocessor.Contains("UNITY_STEREO_INSTANCING_ENABLED"))) 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 + // special case, "SHADER_STAGE_FRAGMENT" fields must be packed at the end of the struct, + // otherwise the vertex output struct will have different semantic ordering than the fragment input struct. // - else if (subscript.HasPreprocessor() && (subscript.preprocessor.Contains("UNITY_STEREO_INSTANCING_ENABLED"))) + else if (subscript.HasPreprocessor() && (subscript.preprocessor.Contains("SHADER_STAGE_FRAGMENT"))) postUnpackedSubscripts.Add(subscript); else if (subscript.HasSemantic() || subscript.vectorCount == 0) packedSubscripts.Add(subscript); From 2a2afbeb1b62d798a6ab0c17c0d804fb70b37dc4 Mon Sep 17 00:00:00 2001 From: thomas-zeng Date: Mon, 14 Jun 2021 13:59:29 -0700 Subject: [PATCH 4/4] * Addressed second round feedback. - Generalized the case for all preprocessor cases that contains INSTANCING as keyword. --- .../Editor/Generation/Processors/GenerationUtils.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/com.unity.shadergraph/Editor/Generation/Processors/GenerationUtils.cs b/com.unity.shadergraph/Editor/Generation/Processors/GenerationUtils.cs index 80d372a04b1..f88aff5aee8 100644 --- a/com.unity.shadergraph/Editor/Generation/Processors/GenerationUtils.cs +++ b/com.unity.shadergraph/Editor/Generation/Processors/GenerationUtils.cs @@ -151,7 +151,7 @@ internal static void GeneratePackedStruct(StructDescriptor shaderStruct, ActiveF { // special case, "UNITY_STEREO_INSTANCING_ENABLED" fields must be packed at the end of the struct because they are system generated semantics // - if (subscript.HasPreprocessor() && (subscript.preprocessor.Contains("UNITY_STEREO_INSTANCING_ENABLED"))) + if (subscript.HasPreprocessor() && (subscript.preprocessor.Contains("INSTANCING"))) postUnpackedSubscripts.Add(subscript); // special case, "SHADER_STAGE_FRAGMENT" fields must be packed at the end of the struct, // otherwise the vertex output struct will have different semantic ordering than the fragment input struct.