Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
eb5b39d
[content automatically redacted] touching PlatformDependent folder
timcannellunity3d Aug 14, 2025
aacc413
Update max motion vector eye count to 4
qgu-unity Aug 14, 2025
ec101de
Graphics docs feedback fixes August
markg-unity Aug 14, 2025
20c9fe7
[UUM-112932][2D][CI] Add Mac x64 and arm64 to 2D QV
kennytann Aug 14, 2025
303087c
DOCG-7659 Correct updating keywords in a script
markg-unity Aug 14, 2025
0534597
Fix UUM-113881 by calculating capacity with a guard for long->int wrap
pigselated Aug 14, 2025
3d89f2d
[Backport] Fix: TDR on an empty scene with Compute backend
belgaard Aug 15, 2025
4de9784
Fix bloom and lens flare on tiny resolutions.
eh-unity Aug 15, 2025
257e440
Fix invisible grid lines in Render Graph Viewer with light theme
arttu-peltonen Aug 15, 2025
ec93c5a
Shader Graph Terrain Sample
bencloward Aug 16, 2025
4ab0b02
[XR] SRP MSAA software resolve
thomas-zeng Aug 18, 2025
28c409e
Use 2D.Common for Shape Editing.
venkify Aug 18, 2025
336e1b3
DOCG-7358 Fixes and improvements to Scene Depth Node docs
markg-unity Aug 19, 2025
35ce6a6
DOCG-7278 Improve Position node docs
markg-unity Aug 19, 2025
0de733b
DOCG-7299 Improvements to Simple Noise node docs
markg-unity Aug 19, 2025
f88e870
DOCG-7329 Improve UV Node docs
markg-unity Aug 19, 2025
08c5fb0
DOCG-7355 Remap node docs improvements
markg-unity Aug 19, 2025
a5e3992
OutOfMemory exception in the console and unreleased memory when bakin…
belgaard Aug 20, 2025
79f8ba3
DOCG-7309 Branch node docs improvements
markg-unity Aug 20, 2025
7a6d13f
Fix sample dependencies importer
RemyUnity Aug 20, 2025
8f0396a
DOCG-7073 Custom interpolator node docs improvements
markg-unity Aug 20, 2025
256a422
Fix ShaderGraph UITK MasterNode preview not showing after loading Ren…
ncerone-unity Aug 20, 2025
77e07c3
[ShaderGraph] Collection of various fixes (08/25)
Aug 20, 2025
efa97e8
DOCG-7283 Improve Replace Color node docs
markg-unity Aug 20, 2025
0a75f0f
Minor shader graph docs fixes
markg-unity Aug 20, 2025
c44aa40
Fix Surface Cache RenderPipelineResourceSets not showing up in URP GI…
laylaarab Aug 20, 2025
8d139ba
[Render Pipeline converter]Settings Converter - Fix URP asset generat…
alex-vazquez-unity3d Aug 20, 2025
bab57ad
Changed _REFLECTION_PROBE_ keywords to use dynamic branch
Nzollner Aug 20, 2025
3d914a0
[Port] [Forward] Ensure userLutTexture has an updated texture, null w…
svc-reach-platform-support Aug 20, 2025
a79ae44
[Particles] Change default particle material for HDRP to be consisten…
gabrieldelacruz Aug 20, 2025
41aa8ed
DOCG-7342 Improvements to Dither node docs
markg-unity Aug 20, 2025
ec06159
Fix errors & black screen when resetting active URP Asset from UI
arttu-peltonen Aug 20, 2025
ec66f18
DOCG-7438 Improve Emission node docs
markg-unity Aug 20, 2025
5749b28
DOCG-7115 Improve Scene Depth Difference node docs
markg-unity Aug 20, 2025
a596ef0
[VFX] Improve editing prewarm values for visual effect asset
gabrieldelacruz Aug 20, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,6 @@
[assembly: InternalsVisibleTo("Unity.RenderPipelines.Core.Editor.Tests")]
[assembly: InternalsVisibleTo("Unity.RenderPipelines.HighDefinition.Editor.Tests")]
[assembly: InternalsVisibleTo("Unity.RenderPipelines.Universal.Editor.Tests")]
[assembly: InternalsVisibleTo("Unity.Testing.VisualEffectGraph.EditorTests")]
[assembly: InternalsVisibleTo("Assembly-CSharp-Editor-testable")]

Original file line number Diff line number Diff line change
Expand Up @@ -1005,27 +1005,36 @@ internal static void BakeAdjustmentVolume(ProbeVolumeBakingSet bakingSet, ProbeA

if (!failed)
{
for (int c = 0; c < bakingCells.Length; c++)
// Validate baking cells size before any global state modifications
var chunkSizeInProbes = ProbeBrickPool.GetChunkSizeInProbeCount();
var hasVirtualOffsets = m_BakingSet.settings.virtualOffsetSettings.useVirtualOffset;
var hasRenderingLayers = m_BakingSet.useRenderingLayers;

if (ValidateBakingCellsSize(bakingCells, chunkSizeInProbes, hasVirtualOffsets, hasRenderingLayers))
{
ref var cell = ref bakingCells[c];
ComputeValidityMasks(cell);
}

// Write result to disk
WriteBakingCells(bakingCells);
for (int c = 0; c < bakingCells.Length; c++)
{
ref var cell = ref bakingCells[c];
ComputeValidityMasks(cell);
}

// Reload everything
AssetDatabase.SaveAssets();
AssetDatabase.Refresh();
// Attempt to write the result to disk
if (WriteBakingCells(bakingCells))
{
// Reload everything
AssetDatabase.SaveAssets();
AssetDatabase.Refresh();

if (m_BakingSet.hasDilation)
{
// Force reloading of data
foreach (var data in prv.perSceneDataList)
data.Initialize();
if (m_BakingSet.hasDilation)
{
// Force reloading of data
foreach (var data in prv.perSceneDataList)
data.Initialize();

InitDilationShaders();
PerformDilation();
InitDilationShaders();
PerformDilation();
}
}
}
}
}
Expand All @@ -1045,6 +1054,7 @@ internal static void BakeAdjustmentVolume(ProbeVolumeBakingSet bakingSet, ProbeA
bakingSet.settings.virtualOffsetSettings.useVirtualOffset = savedVirtualOffset;
bakingSet.useRenderingLayers = savedRenderingLayers;

m_BakingBatch?.Dispose();
m_BakingBatch = null;
m_BakingSet = null;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
using Unity.Collections;
using UnityEngine.SceneManagement;
using UnityEditor;

using System.Runtime.InteropServices;
using Brick = UnityEngine.Rendering.ProbeBrickIndex.Brick;

namespace UnityEngine.Rendering
Expand Down Expand Up @@ -191,7 +191,8 @@ static NativeList<Vector3> ApplySubdivisionResults(ProbeSubdivisionResult result
int positionStart = positions.Length;

ConvertBricksToPositions(bricks, out var probePositions, out var brickSubdivLevels);
DeduplicateProbePositions(in probePositions, in brickSubdivLevels, m_BakingBatch, positions, out var probeIndices);
if (!DeduplicateProbePositions(in probePositions, in brickSubdivLevels, m_BakingBatch, positions, out var probeIndices))
return new NativeList<Vector3>(Allocator.Persistent);

BakingCell cell = new BakingCell()
{
Expand All @@ -210,9 +211,22 @@ static NativeList<Vector3> ApplySubdivisionResults(ProbeSubdivisionResult result
return positions;
}

private static void DeduplicateProbePositions(in Vector3[] probePositions, in int[] brickSubdivLevel, BakingBatch batch,
// We know that the current limitation on native containers is this. When an integer overflow bug (https://jira.unity3d.com/browse/UUM-113721) has been fixed, we can raise the limit
// This and related work is tracked by https://jira.unity3d.com/browse/GFXLIGHT-1738
static readonly long k_MaxNumberOfPositions = 67180350;

static bool DeduplicateProbePositions(in Vector3[] probePositions, in int[] brickSubdivLevel, BakingBatch batch,
NativeList<Vector3> uniquePositions, out int[] indices)
{
long numberOfPositions = (long)probePositions.Length + batch.positionToIndex.Count;
if (numberOfPositions > k_MaxNumberOfPositions)
{
Debug.LogError($"The number of Adaptive Probe Volume (APV) probes Unity generated exceeds the current system limit of {k_MaxNumberOfPositions} probes per Baking Set. Reduce density either by adjusting the general Probe Spacing in the Lighting window, or by modifying the Adaptive Probe Volumes in the scene to limit where the denser subdivision levels are used.");
indices = null;

return false;
}

indices = new int[probePositions.Length];
int uniqueIndex = batch.positionToIndex.Count;

Expand All @@ -238,6 +252,8 @@ private static void DeduplicateProbePositions(in Vector3[] probePositions, in in
uniqueIndex++;
}
}

return true;
}

static ProbeSubdivisionResult GetBricksFromLoaded(List<ProbeVolumePerSceneData> dataList)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -726,6 +726,63 @@ static void ExtractBakingCells()

static long AlignRemainder16(long count) => count % 16L;

/// <summary>
/// Calculates support data chunk size based on provided configuration.
/// </summary>
/// <param name="chunkSizeInProbes">Number of probes per chunk</param>
/// <param name="hasVirtualOffsets">Whether virtual offsets are enabled</param>
/// <param name="hasRenderingLayers">Whether rendering layers are enabled</param>
/// <returns>The size in bytes of a single support data chunk</returns>
static int CalculateSupportDataChunkSize(int chunkSizeInProbes, bool hasVirtualOffsets, bool hasRenderingLayers)
{
int supportPositionChunkSize = UnsafeUtility.SizeOf<Vector3>() * chunkSizeInProbes;
int supportValidityChunkSize = UnsafeUtility.SizeOf<float>() * chunkSizeInProbes;
int supportTouchupChunkSize = UnsafeUtility.SizeOf<float>() * chunkSizeInProbes;
int supportLayerMaskChunkSize = hasRenderingLayers ? UnsafeUtility.SizeOf<byte>() * chunkSizeInProbes : 0;
int supportOffsetsChunkSize = hasVirtualOffsets ? UnsafeUtility.SizeOf<Vector3>() * chunkSizeInProbes : 0;

return supportPositionChunkSize + supportValidityChunkSize +
supportOffsetsChunkSize + supportLayerMaskChunkSize + supportTouchupChunkSize;
}

/// <summary>
/// Validates that the baking cells can be written without exceeding system limits.
/// This method performs size calculations without accessing any global state.
/// </summary>
/// <param name="bakingCells">Array of baking cells to validate</param>
/// <param name="chunkSizeInProbes">Number of probes per chunk</param>
/// <param name="hasVirtualOffsets">Whether virtual offsets are enabled</param>
/// <param name="hasRenderingLayers">Whether rendering layers are enabled</param>
/// <returns>True if cells can be written safely, false if they exceed limits</returns>
static bool ValidateBakingCellsSize(BakingCell[] bakingCells, int chunkSizeInProbes, bool hasVirtualOffsets, bool hasRenderingLayers)
{
if (bakingCells == null || bakingCells.Length == 0)
return true;

int supportDataChunkSize = CalculateSupportDataChunkSize(chunkSizeInProbes, hasVirtualOffsets, hasRenderingLayers);

// Calculate total chunks count - need to call AnalyzeBrickForIndirectionEntries to get shChunkCount
// Create a copy to avoid modifying the original cells during validation
var tempCells = new BakingCell[bakingCells.Length];
int totalChunksCount = 0;
for (var i = 0; i < bakingCells.Length; ++i)
{
tempCells[i] = bakingCells[i]; // Shallow copy is sufficient for this validation
AnalyzeBrickForIndirectionEntries(ref tempCells[i]);
totalChunksCount += tempCells[i].shChunkCount;
}

// Perform the critical size check
long supportDataTotalSize = (long)totalChunksCount * supportDataChunkSize;
if (supportDataTotalSize > int.MaxValue)
{
Debug.LogError($"The size of the Adaptive Probe Volume (APV) baking set chunks exceed the current system limit of {int.MaxValue}, unable to save the baked cell assets. Reduce density either by adjusting the general Probe Spacing in the Lighting window, or by modifying the Adaptive Probe Volumes in the scene to limit where the denser subdivision levels are used.");
return false;
}

return true;
}

static void WriteNativeArray<T>(System.IO.FileStream fs, NativeArray<T> array) where T : struct
{
unsafe
Expand All @@ -736,7 +793,7 @@ static void WriteNativeArray<T>(System.IO.FileStream fs, NativeArray<T> array) w
}

/// <summary>
/// This method converts a list of baking cells into 5 separate assets:
/// This method attempts to convert a list of baking cells into 5 separate assets:
/// 2 assets per baking state:
/// CellData: a binary flat file containing L0L1 probes data
/// CellOptionalData: a binary flat file containing L2 probe data (when present)
Expand All @@ -745,7 +802,7 @@ static void WriteNativeArray<T>(System.IO.FileStream fs, NativeArray<T> array) w
/// CellSharedData: a binary flat file containing bricks data
/// CellSupportData: a binary flat file containing debug data (stripped from player builds if building without debug shaders)
/// </summary>
unsafe static void WriteBakingCells(BakingCell[] bakingCells)
static unsafe bool WriteBakingCells(BakingCell[] bakingCells)
{
m_BakingSet.GetBlobFileNames(m_BakingSet.lightingScenario, out var cellDataFilename, out var cellBricksDataFilename, out var cellOptionalDataFilename, out var cellProbeOcclusionDataFilename, out var cellSharedDataFilename, out var cellSupportDataFilename);

Expand Down Expand Up @@ -846,16 +903,16 @@ unsafe static void WriteBakingCells(BakingCell[] bakingCells)
// Brick data
using var bricks = new NativeArray<Brick>(m_TotalCellCounts.bricksCount, Allocator.Persistent, NativeArrayOptions.UninitializedMemory);

// CellSupportData
m_BakingSet.supportPositionChunkSize = sizeof(Vector3) * chunkSizeInProbes;
m_BakingSet.supportValidityChunkSize = sizeof(float) * chunkSizeInProbes;
m_BakingSet.supportOffsetsChunkSize = hasVirtualOffsets ? sizeof(Vector3) * chunkSizeInProbes : 0;
m_BakingSet.supportTouchupChunkSize = sizeof(float) * chunkSizeInProbes;
m_BakingSet.supportLayerMaskChunkSize = hasRenderingLayers ? sizeof(byte) * chunkSizeInProbes : 0;
// CellSupportData - use pure helper function for calculation
m_BakingSet.supportPositionChunkSize = UnsafeUtility.SizeOf<Vector3>() * chunkSizeInProbes;
m_BakingSet.supportValidityChunkSize = UnsafeUtility.SizeOf<float>() * chunkSizeInProbes;
m_BakingSet.supportOffsetsChunkSize = hasVirtualOffsets ? UnsafeUtility.SizeOf<Vector3>() * chunkSizeInProbes : 0;
m_BakingSet.supportTouchupChunkSize = UnsafeUtility.SizeOf<float>() * chunkSizeInProbes;
m_BakingSet.supportLayerMaskChunkSize = hasRenderingLayers ? UnsafeUtility.SizeOf<byte>() * chunkSizeInProbes : 0;

m_BakingSet.supportDataChunkSize = m_BakingSet.supportPositionChunkSize + m_BakingSet.supportValidityChunkSize + m_BakingSet.supportOffsetsChunkSize + m_BakingSet.supportLayerMaskChunkSize + m_BakingSet.supportTouchupChunkSize;
var supportDataTotalSize = m_TotalCellCounts.chunksCount * m_BakingSet.supportDataChunkSize;
using var supportData = new NativeArray<byte>(supportDataTotalSize, Allocator.Persistent, NativeArrayOptions.UninitializedMemory);
m_BakingSet.supportDataChunkSize = CalculateSupportDataChunkSize(chunkSizeInProbes, hasVirtualOffsets, hasRenderingLayers);
long supportDataTotalSize = (long)m_TotalCellCounts.chunksCount * m_BakingSet.supportDataChunkSize;
using var supportData = new NativeArray<byte>((int)supportDataTotalSize, Allocator.Persistent, NativeArrayOptions.UninitializedMemory);

var sceneStateHash = m_BakingSet.GetBakingHashCode();
var startCounts = new CellCounts();
Expand Down Expand Up @@ -1093,6 +1150,8 @@ unsafe static void WriteBakingCells(BakingCell[] bakingCells)
m_BakingSet.cellSupportDataAsset = new ProbeVolumeStreamableAsset(kAPVStreamingAssetsPath, cellSupportDescs, m_BakingSet.supportDataChunkSize, bakingSetGUID, AssetDatabase.AssetPathToGUID(cellSupportDataFilename));

EditorUtility.SetDirty(m_BakingSet);

return true;
}

unsafe static void WriteDilatedCells(List<Cell> cells)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -342,8 +342,19 @@ static internal void RecomputeVOForDebugOnly()
// Make sure unloading happens.
prv.PerformPendingOperations();

// Write back the assets.
WriteBakingCells(m_BakingBatch.cells.ToArray());
// Validate baking cells size before writing
var bakingCellsArray = m_BakingBatch.cells.ToArray();
var chunkSizeInProbes = ProbeBrickPool.GetChunkSizeInProbeCount();
var hasVirtualOffsets = m_BakingSet.settings.virtualOffsetSettings.useVirtualOffset;
var hasRenderingLayers = m_BakingSet.useRenderingLayers;

if (ValidateBakingCellsSize(bakingCellsArray, chunkSizeInProbes, hasVirtualOffsets, hasRenderingLayers))
{
// Write back the assets.
WriteBakingCells(bakingCellsArray);
}

m_BakingBatch?.Dispose();
m_BakingBatch = null;

foreach (var data in prv.perSceneDataList)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -268,15 +268,15 @@ internal int GetBakingHashCode()
}
}

class BakingBatch
class BakingBatch : IDisposable
{
public Dictionary<int, HashSet<string>> cellIndex2SceneReferences = new ();
public List<BakingCell> cells = new ();
// Used to retrieve probe data from it's position in order to fix seams
public Dictionary<int, int> positionToIndex = new ();
public NativeHashMap<int, int> positionToIndex;
// Allow to get a mapping to subdiv level with the unique positions. It stores the minimum subdiv level found for a given position.
// Can be probably done cleaner.
public Dictionary<int, int> uniqueBrickSubdiv = new ();
public NativeHashMap<int, int> uniqueBrickSubdiv;
// Mapping for explicit invalidation, whether it comes from the auto finding of occluders or from the touch up volumes
// TODO: This is not used yet. Will soon.
public Dictionary<Vector3, bool> invalidatedPositions = new ();
Expand Down Expand Up @@ -306,6 +306,19 @@ public BakingBatch(Vector3Int cellCount, ProbeReferenceVolume refVolume)
maxBrickCount = cellCount * ProbeReferenceVolume.CellSize(refVolume.GetMaxSubdivision());
inverseScale = ProbeBrickPool.kBrickCellCount / refVolume.MinBrickSize();
offset = refVolume.ProbeOffset();

// Initialize NativeHashMaps with reasonable initial capacity
// Using a larger capacity to reduce allocations during baking
positionToIndex = new NativeHashMap<int, int>(100000, Allocator.Persistent);
uniqueBrickSubdiv = new NativeHashMap<int, int>(100000, Allocator.Persistent);
}

public void Dispose()
{
if (positionToIndex.IsCreated)
positionToIndex.Dispose();
if (uniqueBrickSubdiv.IsCreated)
uniqueBrickSubdiv.Dispose();
}

public int GetProbePositionHash(Vector3 position)
Expand Down Expand Up @@ -1202,6 +1215,7 @@ static void OnBakeCancelled()
static void CleanBakeData()
{
s_BakeData.Dispose();
m_BakingBatch?.Dispose();
m_BakingBatch = null;
s_AdjustmentVolumes = null;

Expand Down Expand Up @@ -1478,6 +1492,15 @@ static void ApplyPostBakeOperations()
// Use the globalBounds we just computed, as the one in probeRefVolume doesn't include scenes that have never been baked
probeRefVolume.globalBounds = globalBounds;

// Validate baking cells size before any state modifications
var bakingCellsArray = m_BakedCells.Values.ToArray();
var chunkSizeInProbes = ProbeBrickPool.GetChunkSizeInProbeCount();
var hasVirtualOffsets = m_BakingSet.settings.virtualOffsetSettings.useVirtualOffset;
var hasRenderingLayers = m_BakingSet.useRenderingLayers;

if (!ValidateBakingCellsSize(bakingCellsArray, chunkSizeInProbes, hasVirtualOffsets, hasRenderingLayers))
return; // Early exit if validation fails

PrepareCellsForWriting(isBakingSceneSubset);

m_BakingSet.chunkSizeInBricks = ProbeBrickPool.GetChunkSizeInBrickCount();
Expand All @@ -1488,9 +1511,13 @@ static void ApplyPostBakeOperations()

m_BakingSet.scenarios.TryAdd(m_BakingSet.lightingScenario, new ProbeVolumeBakingSet.PerScenarioDataInfo());

// Convert baking cells to runtime cells
// Attempt to convert baking cells to runtime cells
bool succeededWritingBakingCells;
using (new BakingCompleteProfiling(BakingCompleteProfiling.Stages.WriteBakedData))
WriteBakingCells(m_BakedCells.Values.ToArray());
succeededWritingBakingCells = WriteBakingCells(m_BakedCells.Values.ToArray());

if (!succeededWritingBakingCells)
return;

// Reset internal structures depending on current bake.
Debug.Assert(probeRefVolume.EnsureCurrentBakingSet(m_BakingSet));
Expand Down Expand Up @@ -1534,6 +1561,7 @@ static void ApplyPostBakeOperations()
}

// Mark stuff as up to date
m_BakingBatch?.Dispose();
m_BakingBatch = null;
foreach (var probeVolume in GetProbeVolumeList())
probeVolume.OnBakeCompleted();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,11 @@ class Styles

public void PreferenceGUI()
{
EditorGUI.indentLevel++;
AdvancedProperties.enabled = EditorGUILayout.IntPopup(Styles.additionalPropertiesLabel,
AdvancedProperties.enabled ? 1 : 0, Styles.additionalPropertiesNames,
Styles.additionalPropertiesValues) == 1;
EditorGUI.indentLevel--;
}
}
}
Loading