Skip to content

Commit f79e45f

Browse files
svc-reach-platform-supportEvergreen
authored andcommitted
[Port] [6000.4] [UUM-131625] Fix subgraphs with only non-numeric outputs generating errors
1 parent fcb3571 commit f79e45f

File tree

2 files changed

+9
-3
lines changed

2 files changed

+9
-3
lines changed

Packages/com.unity.shadergraph/Editor/Data/SubGraph/SubGraphOutputNode.cs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,12 @@ class SubGraphOutputNode : AbstractMaterialNode
2727
};
2828
public bool IsFirstSlotValid = true;
2929

30+
// Returns true if the given slot is non-null and the slot's data may be used to render a preview
31+
public static bool IsPreviewableType(MaterialSlot slot)
32+
{
33+
return slot == null ? false : s_ValidSlotTypes.Contains(slot.concreteValueType);
34+
}
35+
3036
public SubGraphOutputNode()
3137
{
3238
name = "Output";
@@ -75,7 +81,7 @@ void ValidateSlotType()
7581
{
7682
owner.AddValidationError(objectId, s_MissingOutputSlot, ShaderCompilerMessageSeverity.Error);
7783
}
78-
else if (!s_ValidSlotTypes.Contains(slots.FirstOrDefault().concreteValueType))
84+
else if (!IsPreviewableType(slots.FirstOrDefault()))
7985
{
8086
IsFirstSlotValid = false;
8187
owner.AddValidationError(objectId, "Preview can only compile if the first output slot is a Vector, Matrix, or Boolean type. Please adjust slot types.", ShaderCompilerMessageSeverity.Error);

Packages/com.unity.shadergraph/Editor/Generation/Processors/GenerationUtils.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1040,7 +1040,7 @@ internal static void GenerateSurfaceDescriptionStruct(ShaderStringBuilder surfac
10401040
if (isSubgraphOutput)
10411041
{
10421042
var firstSlot = slots.FirstOrDefault();
1043-
if (firstSlot != null)
1043+
if (SubGraphOutputNode.IsPreviewableType(firstSlot))
10441044
{
10451045
var hlslName = $"{NodeUtils.GetHLSLSafeName(firstSlot.shaderOutputName)}_{firstSlot.id}";
10461046
surfaceDescriptionStruct.AppendLine("{0} {1};", firstSlot.concreteValueType.ToShaderString(firstSlot.owner.concretePrecision), hlslName);
@@ -1206,7 +1206,7 @@ static void GenerateSurfaceDescriptionRemap(
12061206
else if (rootNode is SubGraphOutputNode)
12071207
{
12081208
var slot = slots.FirstOrDefault();
1209-
if (slot != null)
1209+
if (SubGraphOutputNode.IsPreviewableType(slot))
12101210
{
12111211
var foundEdges = graph.GetEdges(slot.slotReference).ToArray();
12121212
var hlslName = $"{NodeUtils.GetHLSLSafeName(slot.shaderOutputName)}_{slot.id}";

0 commit comments

Comments
 (0)