Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
namespace UnityEditor.Rendering.HighDefinition.ShaderGraph
{
abstract class HDSubTarget : SubTarget<HDTarget>, IHasMetadata,
IRequiresData<SystemData>
IRequiresData<SystemData>, IVersionable<ShaderGraphVersion>
{
SystemData m_SystemData;
protected bool m_MigrateFromOldCrossPipelineSG; // Use only for the migration to shader stack architecture
Expand Down Expand Up @@ -60,12 +60,36 @@ public virtual ScriptableObject GetMetadataObject()
return hdMetadata;
}

ShaderGraphVersion IVersionable<ShaderGraphVersion>.version
{
get => systemData.version;
set => systemData.version = value;
}

// Generate migration description steps to migrate HD shader targets
internal static MigrationDescription<ShaderGraphVersion, HDSubTarget> migrationSteps => MigrationDescription.New(
Enum.GetValues(typeof(ShaderGraphVersion)).Cast<ShaderGraphVersion>().Select(
version => MigrationStep.New(version, (HDSubTarget t) => t.MigrateTo(version))
).ToArray()
);

/// <summary>
/// Override this method to handle migration in inherited subtargets
/// </summary>
/// <param name="version">The current version of the migration</param>
internal virtual void MigrateTo(ShaderGraphVersion version)
{
}

public override void Setup(ref TargetSetupContext context)
{
context.AddAssetDependencyPath(AssetDatabase.GUIDToAssetPath("c09e6e9062cbd5a48900c48a0c2ed1c2")); // HDSubTarget.cs
context.AddAssetDependencyPath(AssetDatabase.GUIDToAssetPath(subTargetAssetGuid));
context.SetDefaultShaderGUI(customInspector);

if (migrationSteps.Migrate(this))
OnBeforeSerialize();

foreach (var subShader in EnumerateSubShaders())
{
// patch render type and render queue from pass declaration:
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
using System;
using UnityEngine;
using UnityEngine.Rendering;
using UnityEngine.Rendering.HighDefinition;
using UnityEngine.Serialization;

namespace UnityEditor.Rendering.HighDefinition.ShaderGraph
{
public enum ShaderGraphVersion
{
Initial = 0,
}
}

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,14 @@ public bool dotsInstancing
set => m_DOTSInstancing = value;
}

[SerializeField]
ShaderGraphVersion m_Version = MigrationDescription.LastVersion<ShaderGraphVersion>();
public ShaderGraphVersion version
{
get => m_Version;
set => m_Version = value;
}

internal int inspectorFoldoutMask;
}

Expand Down