Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
41 commits
Select commit Hold shift + click to select a range
2c148e3
[Port] [6000.0] Minor shader graph docs fixes
svc-reach-platform-support Aug 21, 2025
0184a2f
[Port] [6000.0] DOCG-7283 Improve Replace Color node docs
svc-reach-platform-support Aug 21, 2025
3927997
[Port] [6000.0] DOCG-7073 Custom interpolator node docs improvements
svc-reach-platform-support Aug 21, 2025
645f32e
[Port] [6000.0] DOCG-7309 Branch node docs improvements
svc-reach-platform-support Aug 21, 2025
ee92de0
[UUM-100651] Disable unstable HDRP test
AngelaDematte Aug 22, 2025
f1aefe3
[Port] [6000.0] DOCG-7257: Fix typo
svc-reach-platform-support Aug 22, 2025
5627b6c
[Port] [6000.0] RenderGraph imported texture clear fixes
svc-reach-platform-support Aug 22, 2025
76bdc30
[Port] [6000.0] DOCG-7342 Improvements to Dither node docs
svc-reach-platform-support Aug 22, 2025
3bc7cdc
[Port] [6000.0] DOCG-7438 Improve Emission node docs
svc-reach-platform-support Aug 22, 2025
0124da5
[Port] [6000.0] DOCG-7115 Improve Scene Depth Difference node docs
svc-reach-platform-support Aug 22, 2025
80a3e05
[Port] [6000.0] DOCG-7358 Scene Color Node docs improvements
markg-unity Aug 22, 2025
2ff8c53
[Port] [6000.0] DOCG-7262: Link to latest version of Manual docs
svc-reach-platform-support Aug 22, 2025
c43087a
Shader Graph documentation build log cleanup
sebastienduverne Aug 26, 2025
888c76e
[Port] [6000.0] DOCG-7288 port descript fix
svc-reach-platform-support Aug 26, 2025
8fe7b5d
[Port] [6000.0] DOCG-7247 ShaderGraph graph settings tab update
svc-reach-platform-support Aug 26, 2025
e3a8c23
[Port] [6000.0] DOCG-7195 Update volumetric fog with light layers note
svc-reach-platform-support Aug 26, 2025
f77e231
[6000.0][UUM-111385] Fix WebGL 2D with shadowed lighting
kennytann Aug 28, 2025
ddcf25d
[Port] [6000.0] DOCG-7369 Improve Object node docs
svc-reach-platform-support Aug 28, 2025
e0972fe
[Port] [6000.0] docg-7338: Fix Parallax Mapping image
svc-reach-platform-support Aug 29, 2025
26a947f
[Port] [6000.0] docs/graphics/docg-7326: Improve explanation of Unpac…
svc-reach-platform-support Aug 29, 2025
92c78d2
[Port] [6000.0] docg-7320: Unexposed properties revert to default values
svc-reach-platform-support Aug 29, 2025
1c7fcf0
[Port] [6000.0] DOCG-6643: Improve quality of Blackboard page in VFX …
ocarrere Aug 30, 2025
1f286e5
[Port] [6000.0] docg-7367: add Lerp formula and additional info
svc-reach-platform-support Aug 30, 2025
ecc4c19
[Port] [6000.0] docg-7339: Clarify Reoriented option for Normal Blend…
svc-reach-platform-support Aug 30, 2025
f8298bb
[Port] [6000.0] docs/graphics/docg-7270: add comment to basic test code
svc-reach-platform-support Aug 30, 2025
86070a8
[Port] [6000.0] ANT-2394: Update QV coverage for PlaymodeTests on mac
gabriel-unity Sep 1, 2025
93a66df
[Port] [6000.0] [UUM-99709] Material Converter should enable AlphaCli…
svc-reach-platform-support Sep 1, 2025
ca4432e
[Port] [6000.0] docg-7769: Add Additional resources section
svc-reach-platform-support Sep 2, 2025
75a35d7
[Port] [6000.0] docg-7723: Change link
svc-reach-platform-support Sep 2, 2025
ada67f1
[Port] [6000.0] [UUM-101919][6000.3][2D] Fix Light Batching Debugger …
svc-reach-platform-support Sep 3, 2025
f19fef9
Use published version of the Graphics Test Framework (v8)
theo-at-unity Sep 3, 2025
d27f31e
[Port] [6000.0] DOCG-7365 Shader Graph feedback improvements
svc-reach-platform-support Sep 3, 2025
adf63c3
[Port] [6000.0] [UUM-115779] Fix artifacts caused by tiled deferred l…
svc-reach-platform-support Sep 3, 2025
847ffa2
[Port] [6000.0] UUM-115123 - Disallow GPU Driven for MeshRenderers wh…
svc-reach-platform-support Sep 3, 2025
6b5ed0f
[content automatically redacted] touching PlatformDependent folder
sebastian-termen Sep 5, 2025
fbd0f6f
[Port] [6000.0] DOCG-7264: Remove screenshots from node landing page
ocarrere Sep 5, 2025
89543bc
[switch2] Landing of Switch2 test changes into 6000.0
timcannellunity3d Sep 7, 2025
449fa0c
[Port] [6000.0] [UUM-70734] Fix for Size of ShadowCaster2D with Casti…
svc-reach-platform-support Sep 8, 2025
cf00918
[Port] [6000.0] docg-7781: Fix typo
ocarrere Sep 8, 2025
c8c68f9
[6000.0]Fix Multiple errors occur when setting the Render Object Even…
Sep 8, 2025
bec6c82
[6000.0] Fix excessive memory usage in APV
pema99 Sep 9, 2025
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
11 changes: 11 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,11 @@ Repositories.ini eol=lf
*.[mM][sS][iI] filter=lfs diff=lfs merge=lfs -text
*.[aA][rR][cC] filter=lfs diff=lfs merge=lfs -text

# media files
*.[mM][pP]4 filter=lfs diff=lfs merge=lfs -text
*.[mM][oO][vV] filter=lfs diff=lfs merge=lfs -text
*.[wW][eE][bB][mM] filter=lfs diff=lfs merge=lfs -text

# executables and libraries
*.[aA] filter=lfs diff=lfs merge=lfs -text
*.[oO] filter=lfs diff=lfs merge=lfs -text
Expand Down Expand Up @@ -361,6 +366,12 @@ Editor/Resources/unity[[:space:]]editor[[:space:]]resources filter=lfs diff=lfs
**/GfxTestProjectFolder/**/*.[pP][rR][xX] filter=lfs diff=lfs merge=lfs -text
**/GfxTestProjectFolder/**/*.[dD][fF][oO][nN][tT] filter=lfs diff=lfs merge=lfs -text

# Video tests
# ---
# `.ts` is used for MPEG Transport Stream files. This rule is very specific to a certain video
# package because the `.ts` extension clashes with the TypeScript file extension.
**/EditModeAndPlayModeTests/Video/**/HLS/**/*.[tT][sS] filter=lfs diff=lfs merge=lfs -text

# memoryprofiler test snapshots
**/com.unity.memoryprofiler.tests/**/*.[sS][nN][aA][pP] filter=lfs diff=lfs merge=lfs -text

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -641,7 +641,12 @@ public void Dispose()

static bool m_IsInit = false;
static BakingBatch m_BakingBatch;
static ProbeVolumeBakingSet m_BakingSet = null;
static ProbeVolumeBakingSetWeakReference m_BakingSetReference = new();
static ProbeVolumeBakingSet m_BakingSet
{
get => m_BakingSetReference.Get();
set => m_BakingSetReference.Set(value);
}
static TouchupVolumeWithBoundsList s_AdjustmentVolumes;

static Bounds globalBounds = new Bounds();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,18 +112,18 @@ static ProbeVolumeBakingSet defaultSet
bool m_TempBakingSet = false;
bool m_Initialized = false;

ProbeVolumeBakingSet m_ActiveSet;
ProbeVolumeBakingSetWeakReference m_ActiveSet = new();
ProbeVolumeBakingSet activeSet
{
get => m_ActiveSet;
get => m_ActiveSet.Get();
set
{
if (ReferenceEquals(m_ActiveSet, value)) return;
if (m_TempBakingSet) Object.DestroyImmediate(m_ActiveSet);
m_ActiveSet = value;
if (ReferenceEquals(m_ActiveSet.Get(), value)) return;
if (m_TempBakingSet) Object.DestroyImmediate(m_ActiveSet.Get());
m_ActiveSet.Set(value);
m_TempBakingSet = false;
if (m_ActiveSet == null) return;
m_SingleSceneMode = m_ActiveSet.singleSceneMode;
if (m_ActiveSet.Get() == null) return;
m_SingleSceneMode = m_ActiveSet.Get().singleSceneMode;
InitializeSceneList();
}
}
Expand Down Expand Up @@ -169,14 +169,14 @@ public override void OnEnable()

bool FindActiveSet()
{
if (m_ActiveSet == null)
if (m_ActiveSet.Get() == null)
{
activeSet = ProbeVolumeBakingSet.GetBakingSetForScene(SceneManager.GetActiveScene());
for (int i = 0; activeSet == null && i < SceneManager.sceneCount; i++)
activeSet = ProbeVolumeBakingSet.GetBakingSetForScene(SceneManager.GetSceneAt(i));
}

return m_ActiveSet != null;
return m_ActiveSet.Get() != null;
}

void Initialize()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ class KeywordFloatRename
public float setVal, unsetVal;
}
List<KeywordFloatRename> m_KeywordFloatRename = new List<KeywordFloatRename>();
Dictionary<string, (string, System.Func<float, bool>)> m_ConditionalFloatRename;

/// <summary>
/// Type of property to rename.
Expand Down Expand Up @@ -220,6 +221,20 @@ public virtual void Convert(Material srcMaterial, Material dstMaterial)

dstMaterial.SetFloat(t.property, srcMaterial.IsKeywordEnabled(t.keyword) ? t.setVal : t.unsetVal);
}

// Handle conditional float renaming
if (m_ConditionalFloatRename != null)
{
foreach (var (oldName, (newName, condition)) in m_ConditionalFloatRename)
{
if (srcMaterial.HasProperty(oldName) &&
condition(srcMaterial.GetFloat(oldName)) &&
dstMaterial.HasProperty(newName))
{
dstMaterial.SetFloat(newName, 1.0f);
}
}
}
}

/// <summary>
Expand Down Expand Up @@ -316,6 +331,17 @@ public void RenameKeywordToFloat(string oldName, string newName, float setVal, f
m_KeywordFloatRename.Add(new KeywordFloatRename { keyword = oldName, property = newName, setVal = setVal, unsetVal = unsetVal });
}

/// <summary>
/// Rename a float property conditionally based on its value
/// </summary>
/// <param name="oldName">Old property name</param>
/// <param name="newName">New property name</param>
/// <param name="condition">Condition function that takes the float value and returns true if renaming should occur</param>
protected void RenameFloat(string oldName, string newName, System.Func<float, bool> condition)
{
(m_ConditionalFloatRename ??= new Dictionary<string, (string, System.Func<float, bool>)>())[oldName] = (newName, condition);
}

static MaterialUpgrader GetUpgrader(List<MaterialUpgrader> upgraders, Material material)
{
if (material == null || material.shader == null)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,8 @@ private static void AllowGPUDrivenRenderingRecursively(Transform transform, bool
private void OnValidate()
{
OnDisable();
OnEnable();
if (enabled)
OnEnable();
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -726,8 +726,19 @@ public struct ExtraDataActionInput
// Information of the probe volume scenes that is being loaded (if one is pending)
List<string> m_ActiveScenes = new List<string>();

ProbeVolumeBakingSet m_CurrentBakingSet = null;
ProbeVolumeBakingSet m_LazyBakingSet = null;
ProbeVolumeBakingSetWeakReference m_CurrentBakingSetReference = new();
ProbeVolumeBakingSet m_CurrentBakingSet
{
get => m_CurrentBakingSetReference.Get();
set => m_CurrentBakingSetReference.Set(value);
}

ProbeVolumeBakingSetWeakReference m_LazyBakingSetReference = new();
ProbeVolumeBakingSet m_LazyBakingSet
{
get => m_LazyBakingSetReference.Get();
set => m_LazyBakingSetReference.Set(value);
}

bool m_NeedLoadAsset = false;
bool m_ProbeReferenceVolumeInit = false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ internal class SceneBakeData

[SerializeField]
SerializedDictionary<string, SceneBakeData> m_SceneBakeData = new();
internal static Dictionary<string, ProbeVolumeBakingSet> sceneToBakingSet = new Dictionary<string, ProbeVolumeBakingSet>();
internal static Dictionary<string, ProbeVolumeBakingSetWeakReference> sceneToBakingSet = new Dictionary<string, ProbeVolumeBakingSetWeakReference>();

/// <summary>
/// Tries to add a scene to the baking set.
Expand All @@ -42,7 +42,7 @@ internal void AddScene(string guid, SceneBakeData bakeData = null)
{
m_SceneGUIDs.Add(guid);
m_SceneBakeData.Add(guid, bakeData != null ? bakeData : new SceneBakeData());
sceneToBakingSet[guid] = this;
sceneToBakingSet[guid] = new ProbeVolumeBakingSetWeakReference(this);

EditorUtility.SetDirty(this);
}
Expand All @@ -65,7 +65,7 @@ internal void SetScene(string guid, int index, SceneBakeData bakeData = null)
var previousSceneGUID = m_SceneGUIDs[index];
m_SceneGUIDs[index] = guid;
sceneToBakingSet.Remove(previousSceneGUID);
sceneToBakingSet[guid] = this;
sceneToBakingSet[guid] = new ProbeVolumeBakingSetWeakReference(this);
m_SceneBakeData.Add(guid, bakeData != null ? bakeData : new SceneBakeData());

EditorUtility.SetDirty(this);
Expand Down Expand Up @@ -291,26 +291,34 @@ public string RenameScenario(string scenario, string newName)

internal static void SyncBakingSets()
{
sceneToBakingSet = new Dictionary<string, ProbeVolumeBakingSet>();
sceneToBakingSet = new Dictionary<string, ProbeVolumeBakingSetWeakReference>();

var setGUIDs = AssetDatabase.FindAssets("t:" + typeof(ProbeVolumeBakingSet).Name);
var setGUIDs = AssetDatabase.FindAssets("t:" + nameof(ProbeVolumeBakingSet));

foreach (var setGUID in setGUIDs)
{
var set = AssetDatabase.LoadAssetAtPath<ProbeVolumeBakingSet>(AssetDatabase.GUIDToAssetPath(setGUID));
string bakingSetPath = AssetDatabase.GUIDToAssetPath(setGUID);
bool alreadyLoaded = AssetDatabase.IsMainAssetAtPathLoaded(bakingSetPath);

var set = AssetDatabase.LoadAssetAtPath<ProbeVolumeBakingSet>(bakingSetPath);
if (set != null)
{
// We need to call Migrate here because of Version.RemoveProbeVolumeSceneData step.
// This step needs the obsolete ProbeVolumeSceneData to be initialized first which can happen out of order. Here we now it's ok.
set.Migrate();

var reference = new ProbeVolumeBakingSetWeakReference(set);
foreach (var guid in set.sceneGUIDs)
sceneToBakingSet[guid] = set;
sceneToBakingSet[guid] = reference;

// If the asset wasn't already in-memory, and we just loaded it into memory, free it, so we don't waste memory.
if (!alreadyLoaded)
reference.Unload();
}
}
}

internal static ProbeVolumeBakingSet GetBakingSetForScene(string sceneGUID) => sceneToBakingSet.GetValueOrDefault(sceneGUID, null);
internal static ProbeVolumeBakingSet GetBakingSetForScene(string sceneGUID) => sceneToBakingSet.GetValueOrDefault(sceneGUID, null)?.Get();
internal static ProbeVolumeBakingSet GetBakingSetForScene(Scene scene) => GetBakingSetForScene(scene.GetGUID());

internal void SetDefaults()
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
namespace UnityEngine.Rendering
{
// Q: What is this?
// A: A utility class for storing a reference to a ProbeVolumeBakingSet, without forcing the object to be loaded in-memory.

// Q: Why do we need this?
// A: APV uses a lot of global state, and we aren't always good with cleaning it up. Unity's serialization layer will automatically
// load referenced assets into memory, recursively. Some of the assets referenced by ProbeVolumeBakingSet can get very large, on
// the order of several gigabytes. A lingering global reference to a ProbeVolumeBakingSet can keep these assets in memory indefinitely,
// preventing them from being garbage collected. By using a weak reference, we prevent this - ProbeVolumeBakingSet can be freely
// garbage collected. Whenever we actually need to access it, we load it on-demand, if it isn't already in memory.

internal class ProbeVolumeBakingSetWeakReference
{
public int m_InstanceID;

public ProbeVolumeBakingSetWeakReference(ProbeVolumeBakingSet bakingSet)
{
Set(bakingSet);
}

public ProbeVolumeBakingSetWeakReference()
{
m_InstanceID = 0;
}

// Change which baking set the references points to.
public void Set(ProbeVolumeBakingSet bakingSet)
{
if (bakingSet == null)
m_InstanceID = 0;
else
m_InstanceID = bakingSet.GetInstanceID();
}

// Get the referenced baking set, loading it into memory if necessary.
public ProbeVolumeBakingSet Get()
{
return Resources.InstanceIDToObject(m_InstanceID) as ProbeVolumeBakingSet;
}

// Is the referenced baking set in memory?
public bool IsLoaded()
{
return Resources.InstanceIDIsValid(m_InstanceID);
}

// Force the referenced baking set to be unloaded from memory.
// Calling Get() after Unload() will re-load the baking set into memory.
public void Unload()
{
if (!IsLoaded())
return;

var bakingSet = Get();

// These assets would get garbage collected, but we clean them up immediately to free memory earlier.
// Only do this in editor, where the assets are never needed, so we don't unload assets that may still be in use.
#if UNITY_EDITOR
Resources.UnloadAsset(bakingSet.cellBricksDataAsset?.asset);
Resources.UnloadAsset(bakingSet.cellSharedDataAsset?.asset);
Resources.UnloadAsset(bakingSet.cellSupportDataAsset?.asset);
foreach (var scenario in bakingSet.scenarios)
{
Resources.UnloadAsset(scenario.Value.cellDataAsset?.asset);
Resources.UnloadAsset(scenario.Value.cellOptionalDataAsset?.asset);
Resources.UnloadAsset(scenario.Value.cellProbeOcclusionDataAsset?.asset);
}
#endif

// Unload the baking set itself.
Resources.UnloadAsset(bakingSet);
}
}
}

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 @@ -115,7 +115,7 @@ internal enum NativeCompilerProfileId
NRPRGComp_TryMergeNativePasses,
NRPRGComp_FindResourceUsageRanges,
NRPRGComp_DetectMemorylessResources,
NRPRGComp_ExecuteCreateResources,
NRPRGComp_ExecuteInitializeResources,
NRPRGComp_ExecuteBeginRenderpassCommand,
NRPRGComp_ExecuteDestroyResources,
}
Expand Down Expand Up @@ -730,10 +730,9 @@ internal static bool IsSameNativeSubPass(ref SubPassDescriptor a, ref SubPassDes
return true;
}


private void ExecuteCreateRessource(InternalRenderGraphContext rgContext, RenderGraphResourceRegistry resources, in PassData pass)
private void ExecuteInitializeResource(InternalRenderGraphContext rgContext, RenderGraphResourceRegistry resources, in PassData pass)
{
using (new ProfilingScope(ProfilingSampler.Get(NativeCompilerProfileId.NRPRGComp_ExecuteCreateResources)))
using (new ProfilingScope(ProfilingSampler.Get(NativeCompilerProfileId.NRPRGComp_ExecuteInitializeResources)))
{
resources.forceManualClearOfResource = true;

Expand All @@ -748,15 +747,26 @@ private void ExecuteCreateRessource(InternalRenderGraphContext rgContext, Render
foreach (ref readonly var res in subPass.FirstUsedResources(contextData))
{
ref readonly var resInfo = ref contextData.UnversionedResourceData(res);
if (resInfo.isImported == false && resInfo.memoryLess == false)
{
bool usedAsFragmentThisPass = subPass.IsUsedAsFragment(res, contextData);
bool usedAsFragmentThisPass = subPass.IsUsedAsFragment(res, contextData);

// This resource is read for the first time as a regular texture and not as a framebuffer attachment
// so we need to explicitly clear it, as loadAction.clear only works on framebuffer attachments
// TODO: Should this be a performance warning?? Maybe rare enough in practice?
resources.forceManualClearOfResource = !usedAsFragmentThisPass;
resources.CreatePooledResource(rgContext, res.iType, res.index);
// This resource is read for the first time as a regular texture and not as a framebuffer attachment
// so if requested we need to explicitly clear it, as loadAction.clear only works on framebuffer attachments
resources.forceManualClearOfResource = !usedAsFragmentThisPass;

if (!resInfo.memoryLess)
{
if (!resInfo.isImported)
{
// This resource is read for the first time as a regular texture and not as a framebuffer attachment
// so we need to explicitly clear it, as loadAction.clear only works on framebuffer attachments
// TODO: Should this be a performance warning?? Maybe rare enough in practice?
resources.CreatePooledResource(rgContext, res.iType, res.index);
}
else // Imported resource
{
if (resInfo.clear && resources.forceManualClearOfResource)
resources.ClearResource(rgContext, res.iType, res.index);
}
}
}
}
Expand All @@ -768,10 +778,15 @@ private void ExecuteCreateRessource(InternalRenderGraphContext rgContext, Render
foreach (ref readonly var create in pass.FirstUsedResources(contextData))
{
ref readonly var pointTo = ref contextData.UnversionedResourceData(create);
if (pointTo.isImported == false)
if (!pointTo.isImported)
{
resources.CreatePooledResource(rgContext, create.iType, create.index);
}
else // Imported resource
{
if (pointTo.clear)
resources.ClearResource(rgContext, create.iType, create.index);
}
}
}

Expand Down Expand Up @@ -1387,7 +1402,7 @@ public void ExecuteGraph(InternalRenderGraphContext rgContext, RenderGraphResour

var isRaster = pass.type == RenderGraphPassType.Raster;

ExecuteCreateRessource(rgContext, resources, pass);
ExecuteInitializeResource(rgContext, resources, pass);

var isAsyncCompute = pass.type == RenderGraphPassType.Compute && pass.asyncCompute == true;
if (isAsyncCompute)
Expand Down
Loading