Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Internal/6000.0/staging #8135

Open
wants to merge 29 commits into
base: 6000.0/staging
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
1f5e8c2
[Port] [6000.0] [XRVOSB-64] Fix post process passes when HDR and XR r…
mtschoen-unity Feb 20, 2025
f6f6c14
[Backport 6000.0] UUM-95334 NativePassData.GraphPasses() has GC Alloc…
RoseHirigoyen Feb 20, 2025
4ead064
[Port] [6000.0] Fix APV assets missing from .unitypackage exports
svc-reach-platform-support Feb 21, 2025
36936c8
Port 6000.0 for UUM-97863
venkify Feb 21, 2025
720eac2
[Port] [6000.0] Check if transparent objects receive shadows when set…
laylaarab Feb 21, 2025
fd902f3
[Port] [6000.0] DOCG-6671 Add missing render graph Rendering Debugger…
svc-reach-platform-support Feb 21, 2025
5b22a61
[Port] [6000.0] Fix Jump To Source functionality in Render Graph View…
svc-reach-platform-support Feb 21, 2025
db4de48
[Port] [6000.0] Graphics docs feedback fixes February 2025 pt2
markg-unity Feb 21, 2025
b4e7f0c
[Port] [6000.0] [SpeedTree][URP] Fix compressed & downsampled normal …
svc-reach-platform-support Feb 25, 2025
9e193e7
[Backport 6000.0] DOCG-6679 - What's New 17 to TOC
Sam-Unity Feb 25, 2025
fe8cf54
[Port] [6000.0] Moving Volume Tests components to SRP smoke tests.
svc-reach-platform-support Feb 26, 2025
44ee8ef
[Port] [6000.0] Fix editor debug views not rendering when GPUResident…
svc-reach-platform-support Feb 26, 2025
d244f4d
[Port] [6000.0] [URP] Fix missing namespace and upgrade from old GUID…
svc-reach-platform-support Feb 27, 2025
f1d0374
6000.0: Fixed the generation of new artifact ID of ShaderGraph on eve…
Saiprasad945 Feb 27, 2025
164f21d
[Backport][UUM-82524][6000.0] Fix global light textures not set corre…
kennytann Feb 27, 2025
e08e840
[Port] [6000.0] DOCG-4872 Review Full Screen Renderer Feature code te…
svc-reach-platform-support Feb 27, 2025
5d0abac
[Port] [6000.0] [VFX] Fix Shader Warnings
svc-reach-platform-support Mar 1, 2025
7d8cae3
[Port] [6000.0][UUM-95754] Add layer mask in renderer 2d data
svc-reach-platform-support Mar 1, 2025
f6fceb0
[Port] [6000.0] [VFX] Fix missing invalidation in case of SetTexture
svc-reach-platform-support Mar 1, 2025
efbccfd
[Port] [6000.0] Fix for UUM 83095
svc-reach-platform-support Mar 3, 2025
260a986
[Port] [6000.0] [VFX] Fix Capitalization
svc-reach-platform-support Mar 3, 2025
20d584e
[Port] [6000.0] [VFX/SG] Fix Unexpected Visible Dead Particles
svc-reach-platform-support Mar 3, 2025
3efada4
[Port] [6000.0] DOCG-5799 Clarify Sample Graphics Buffer and custom t…
svc-reach-platform-support Mar 3, 2025
8df97e6
[Port] [6000.0] [UUM-97588] Fix Fullscreen Render Pass on visionOS
svc-reach-platform-support Mar 4, 2025
cbd93b2
[Port] [6000.0] [VFX] Fixed cut labels when editor font is set to "Sy…
svc-reach-platform-support Mar 4, 2025
a496844
[Port] [6000.0] [VFX] Fixed invalid cast exception happens when click…
svc-reach-platform-support Mar 4, 2025
d4844e2
[Port] [6000.0] [VFX] Context title label was slightly offset when be…
svc-reach-platform-support Mar 4, 2025
c830882
[Port] [6000.0] [VFX] Undoing slider value change not updating float…
svc-reach-platform-support Mar 4, 2025
aeca46e
[Backport][Regression][UUM-98261] Fix shader compilation warning
zeroyao Mar 4, 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
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
* [What's new](whats-new.md)
* [12](whats-new-12.md)
* [13](whats-new-13.md)
* [17](whats-new-17.md)
* [Creating a custom render pipeline](srp-custom.md)
* [Create a custom Scriptable Render Pipeline](srp-custom-getting-started.md)
* [Create a Render Pipeline Asset and Render Pipeline Instance in a custom render pipeline](srp-creating-render-pipeline-asset-and-render-pipeline-instance.md)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,10 @@
using UnityEditor.Build.Reporting;
using UnityEngine;
using UnityEngine.Rendering;
using UnityEngine.SceneManagement;

namespace UnityEditor.Rendering
{
class ProbeVolumeBuildProcessor : BuildPlayerProcessor, IProcessSceneWithReport
class ProbeVolumeBuildProcessor : BuildPlayerProcessor, IPostprocessBuildWithReport
{
const string kTempAPVStreamingAssetsPath = "TempAPVStreamingAssets";

Expand All @@ -18,15 +17,27 @@ string GetTempAPVStreamingAssetsPath()
return Path.Combine(libraryPath, kTempAPVStreamingAssetsPath);
}

void PrepareStreamableAsset(ProbeVolumeStreamableAsset asset, string basePath, bool useStreamingAsset)
// Include an asset in the build. The mechanism for doing so depends on whether we are using StreamingAssets path.
static void IncludeStreamableAsset(ProbeVolumeStreamableAsset asset, string basePath, bool useStreamingAsset)
{
asset.UpdateAssetReference(useStreamingAsset);

if (useStreamingAsset)
{
asset.ClearAssetReferenceForBuild();
CopyStreamableAsset(asset, basePath);
}
else
{
asset.EnsureAssetLoaded();
}
}

// Ensure that an asset is not included in the build.
static void StripStreambleAsset(ProbeVolumeStreamableAsset asset)
{
asset.ClearAssetReferenceForBuild();
}

void CopyStreamableAsset(ProbeVolumeStreamableAsset asset, string basePath)
static void CopyStreamableAsset(ProbeVolumeStreamableAsset asset, string basePath)
{
var assetPath = asset.GetAssetPath();
if (!File.Exists(assetPath))
Expand Down Expand Up @@ -60,6 +71,9 @@ void GetProbeVolumeProjectSettings(BuildTarget target, out bool supportProbeVolu
}
}

// Keep track of which assets we touched during the build, so we can restore them after the build.
private static HashSet<ProbeVolumeBakingSet> s_BakingSetsProcessedLastBuild = new();

public override void PrepareForBuild(BuildPlayerContext buildPlayerContext)
{
GetProbeVolumeProjectSettings(buildPlayerContext.BuildPlayerOptions.target, out bool supportProbeVolume, out var maxSHBands);
Expand Down Expand Up @@ -89,16 +103,15 @@ public override void PrepareForBuild(BuildPlayerContext buildPlayerContext)

Directory.CreateDirectory(tempStreamingAssetsPath);

HashSet<ProbeVolumeBakingSet> processedBakingSets = new HashSet<ProbeVolumeBakingSet>();

s_BakingSetsProcessedLastBuild.Clear();
foreach (var scene in buildPlayerContext.BuildPlayerOptions.scenes)
{
var sceneGUID = AssetDatabase.AssetPathToGUID(scene);
var bakingSet = ProbeVolumeBakingSet.GetBakingSetForScene(sceneGUID);
if (bakingSet != null)
{
// Already processed (different scenes can belong to the same baking set).
if (processedBakingSets.Contains(bakingSet))
if (s_BakingSetsProcessedLastBuild.Contains(bakingSet))
continue;

if (!bakingSet.cellSharedDataAsset.IsValid()) // Not baked
Expand All @@ -111,89 +124,53 @@ public override void PrepareForBuild(BuildPlayerContext buildPlayerContext)

bool useStreamingAsset = !GraphicsSettings.GetRenderPipelineSettings<ProbeVolumeGlobalSettings>().probeVolumeDisableStreamingAssets;

PrepareStreamableAsset(bakingSet.cellSharedDataAsset, basePath, useStreamingAsset);
PrepareStreamableAsset(bakingSet.cellBricksDataAsset, basePath, useStreamingAsset);
IncludeStreamableAsset(bakingSet.cellSharedDataAsset, basePath, useStreamingAsset);
IncludeStreamableAsset(bakingSet.cellBricksDataAsset, basePath, useStreamingAsset);
// For now we always strip support data in build as it's mostly unsupported.
// Later we'll need a proper option to strip it or not.
bool stripSupportData = true;
if (!stripSupportData)
PrepareStreamableAsset(bakingSet.cellSupportDataAsset, basePath, useStreamingAsset);
if (stripSupportData)
StripStreambleAsset(bakingSet.cellSupportDataAsset);
else
IncludeStreamableAsset(bakingSet.cellSupportDataAsset, basePath, useStreamingAsset);

foreach (var scenario in bakingSet.scenarios)
{
PrepareStreamableAsset(scenario.Value.cellDataAsset, basePath, useStreamingAsset);
IncludeStreamableAsset(scenario.Value.cellDataAsset, basePath, useStreamingAsset);
if (maxSHBands == ProbeVolumeSHBands.SphericalHarmonicsL2)
PrepareStreamableAsset(scenario.Value.cellOptionalDataAsset, basePath, useStreamingAsset);
PrepareStreamableAsset(scenario.Value.cellProbeOcclusionDataAsset, basePath, useStreamingAsset);
IncludeStreamableAsset(scenario.Value.cellOptionalDataAsset, basePath, useStreamingAsset);
else
StripStreambleAsset(scenario.Value.cellOptionalDataAsset);
IncludeStreamableAsset(scenario.Value.cellProbeOcclusionDataAsset, basePath, useStreamingAsset);
}

processedBakingSets.Add(bakingSet);
s_BakingSetsProcessedLastBuild.Add(bakingSet);
}
}

buildPlayerContext.AddAdditionalPathToStreamingAssets(tempStreamingAssetsPath, AdaptiveProbeVolumes.kAPVStreamingAssetsPath);
}

private static bool IsBundleBuild(BuildReport report, bool isPlaying)
{
// We are entering playmode, so not building a bundle.
if (isPlaying)
return false;

// Addressable builds do not provide a BuildReport. Because the Addressables package
// only supports AssetBundle builds, we infer that this is not a player build.
if (report == null)
return true;

return report.summary.buildType == BuildType.AssetBundle;
}

// This codepath handles the case of building asset bundles, i.e. not a full player build. It updates the references
// to individual data assets in the baking sets for each scene, such that the assets are included in the bundle.
public override int callbackOrder => 1;
public void OnProcessScene(Scene scene, BuildReport report)
public void OnPostprocessBuild(BuildReport report)
{
// Only run for bundle builds.
if (!IsBundleBuild(report, Application.isPlaying))
return;

// Only run when APV is enabled.
GetProbeVolumeProjectSettings(EditorUserBuildSettings.activeBuildTarget, out bool supportProbeVolume, out var maxSHBands);
if (!supportProbeVolume)
return;

// Reload the map from scene to baking set if we couldn't find the specific baking set.
if (ProbeVolumeBakingSet.sceneToBakingSet == null || ProbeVolumeBakingSet.sceneToBakingSet.Count == 0)
ProbeVolumeBakingSet.SyncBakingSets();

// Get the baking set for the scene.
var bakingSet = ProbeVolumeBakingSet.GetBakingSetForScene(scene.GetGUID());
if (bakingSet == null || !bakingSet.cellSharedDataAsset.IsValid())
if (s_BakingSetsProcessedLastBuild == null || s_BakingSetsProcessedLastBuild.Count == 0)
return;

bool useStreamingAsset = !GraphicsSettings.GetRenderPipelineSettings<ProbeVolumeGlobalSettings>().probeVolumeDisableStreamingAssets;
if (useStreamingAsset)
// Go over each asset reference we touched during the last build, make sure asset references are intact.
foreach (var bakingSet in s_BakingSetsProcessedLastBuild)
{
Debug.LogWarning(
"Attempted to build an Asset Bundle containing Adaptive Probe Volume data, but streaming assets are enabled. This is unsupported. " +
"To use Adaptive Probe Volumes with Asset Bundles, please check 'Probe Volume Disable Streaming Assets' under Graphics Settings.");
bakingSet.cellBricksDataAsset.EnsureAssetLoaded();
bakingSet.cellSharedDataAsset.EnsureAssetLoaded();
bakingSet.cellSupportDataAsset.EnsureAssetLoaded();
foreach (var scenario in bakingSet.scenarios)
{
scenario.Value.cellDataAsset.EnsureAssetLoaded();
scenario.Value.cellOptionalDataAsset.EnsureAssetLoaded();
scenario.Value.cellProbeOcclusionDataAsset.EnsureAssetLoaded();
}
}

// Update all the asset references.
bakingSet.cellSharedDataAsset.UpdateAssetReference(useStreamingAsset);
bakingSet.cellBricksDataAsset.UpdateAssetReference(useStreamingAsset);

bool stripSupportData = true;
if (!stripSupportData)
bakingSet.cellSupportDataAsset.UpdateAssetReference(false);

foreach (var scenario in bakingSet.scenarios)
{
scenario.Value.cellDataAsset.UpdateAssetReference(useStreamingAsset);
if (maxSHBands == ProbeVolumeSHBands.SphericalHarmonicsL2)
scenario.Value.cellOptionalDataAsset.UpdateAssetReference(useStreamingAsset);
scenario.Value.cellProbeOcclusionDataAsset.UpdateAssetReference(useStreamingAsset);
}
s_BakingSetsProcessedLastBuild.Clear();
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,7 @@
[assembly: InternalsVisibleTo("Unity.RenderPipelines.Core.Runtime.Tests")]
[assembly: InternalsVisibleTo("Unity.GraphicTests.Performance.RPCore.Runtime")]
[assembly: InternalsVisibleTo("Unity.GraphicTests.Performance.Universal.Runtime")] // access to internal ProfileIds

// Smoke test project visibility
[assembly: InternalsVisibleTo("SRPSmoke.Runtime.Tests")]
[assembly: InternalsVisibleTo("SRPSmoke.Editor.Tests")]
Original file line number Diff line number Diff line change
Expand Up @@ -334,7 +334,7 @@ private static void Recreate(GPUResidentDrawerSettings settings)
private NativeList<int> m_FrameCameraIDs;
private bool m_FrameUpdateNeeded = false;

private bool m_SelectionChanged;
private bool m_IsSelectionDirty;

static GPUResidentDrawer()
{
Expand Down Expand Up @@ -399,6 +399,7 @@ private GPUResidentDrawer(GPUResidentDrawerSettings settings, int maxInstanceCou
#if UNITY_EDITOR
AssemblyReloadEvents.beforeAssemblyReload += OnAssemblyReload;
m_FrameCameraIDs = new NativeList<int>(1, Allocator.Persistent);
m_IsSelectionDirty = true; // Force at least one selection update
#endif
SceneManager.sceneLoaded += OnSceneLoaded;

Expand Down Expand Up @@ -429,6 +430,7 @@ private void Dispose()
#endif
SceneManager.sceneLoaded -= OnSceneLoaded;

// Note: Those RenderPipelineManager callbacks do not run when using built-in editor debug views such as lightmap, shadowmask etc
RenderPipelineManager.beginContextRendering -= OnBeginContextRendering;
RenderPipelineManager.endContextRendering -= OnEndContextRendering;
RenderPipelineManager.beginCameraRendering -= OnBeginCameraRendering;
Expand Down Expand Up @@ -487,6 +489,7 @@ private void OnBeginContextRendering(ScriptableRenderContext context, List<Camer
// If running in the editor the player loop might not run
// In order to still have a single frame update we keep track of the camera ids
// A frame update happens in case the first camera is rendered again
// Note: This doesn't run when using built-in debug views such as lightmaps, shadowmask and etc
private void EditorFrameUpdate(List<Camera> cameras)
{
bool newFrame = false;
Expand All @@ -508,21 +511,16 @@ private void EditorFrameUpdate(List<Camera> cameras)
else
m_FrameUpdateNeeded = true;
}

ProcessSelection();
}

private void OnSelectionChanged()
{
m_SelectionChanged = true;
m_IsSelectionDirty = true;
}

private void ProcessSelection()
private void UpdateSelection()
{
if(!m_SelectionChanged)
return;

m_SelectionChanged = false;
Profiler.BeginSample("GPUResidentDrawer.UpdateSelection");

Object[] renderers = Selection.GetFiltered(typeof(MeshRenderer), SelectionMode.Deep);

Expand All @@ -532,8 +530,10 @@ private void ProcessSelection()
rendererIDs[i] = renderers[i] ? renderers[i].GetInstanceID() : 0;

m_Batcher.UpdateSelectedRenderers(rendererIDs);

rendererIDs.Dispose();

Profiler.EndSample();
}
#endif

Expand Down Expand Up @@ -612,10 +612,15 @@ private void PostPostLateUpdate()
supportedChangedPackedMaterialDatas.Dispose();

m_BatchersContext.UpdateInstanceMotions();

m_Batcher.UpdateFrame();

#if UNITY_EDITOR
if (m_IsSelectionDirty)
{
UpdateSelection();
m_IsSelectionDirty = false;
}

m_FrameUpdateNeeded = false;
#endif
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,8 @@ public sealed partial class ProbeVolumeBakingSet : ScriptableObject, ISerializat
internal enum Version
{
Initial,
RemoveProbeVolumeSceneData
RemoveProbeVolumeSceneData,
AssetsAlwaysReferenced,
}

[Serializable]
Expand Down Expand Up @@ -345,6 +346,28 @@ internal void Migrate()
#endif
}

// Upgrade baking sets from before we always stored asset references.
if (version < Version.AssetsAlwaysReferenced && ProbeReferenceVolume.instance.isInitialized)
{
#if UNITY_EDITOR
cellBricksDataAsset.EnsureAssetLoaded();
cellSharedDataAsset.EnsureAssetLoaded();
cellSupportDataAsset.EnsureAssetLoaded();
foreach (var scenario in scenarios)
{
scenario.Value.cellDataAsset.EnsureAssetLoaded();
scenario.Value.cellOptionalDataAsset.EnsureAssetLoaded();
scenario.Value.cellProbeOcclusionDataAsset.EnsureAssetLoaded();
}

version = Version.AssetsAlwaysReferenced;

// Save immediately since these references must be written to disk for certain functionality
// to work, such as exporting a .unitypackage. Changing in memory is not enough.
UnityEditor.EditorUtility.SetDirty(this);
UnityEditor.AssetDatabase.SaveAssetIfDirty(this);
#endif
}
#pragma warning restore 618
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,9 @@ public ProbeVolumeStreamableAsset(string apvStreamingAssetsPath, SerializedDicti
m_StreamableCellDescs = cellDescs;
m_ElementSize = elementSize;
m_StreamableAssetPath = Path.Combine(Path.Combine(apvStreamingAssetsPath, bakingSetGUID), m_AssetGUID + ".bytes");
#if UNITY_EDITOR
EnsureAssetLoaded();
#endif
}

internal void RefreshAssetPath()
Expand Down Expand Up @@ -89,9 +92,16 @@ public void RenameAsset(string newName)
m_FinalAssetPath = "";
}

public void UpdateAssetReference(bool useStreamingAsset)
// Ensures that the asset is referenced via Unity's serialization layer.
public void EnsureAssetLoaded()
{
m_Asset = AssetDatabase.LoadAssetAtPath<TextAsset>(GetAssetPath());
}

// Temporarily clear the asset reference. Used to prevent serialization of the asset when we are using the StreamingAssets codepath.
public void ClearAssetReferenceForBuild()
{
m_Asset = useStreamingAsset ? null : AssetDatabase.LoadAssetAtPath<TextAsset>(GetAssetPath());
m_Asset = null;
}
#endif

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
using Unity.Collections.LowLevel.Unsafe;
using UnityEngine.Rendering;
using System.Collections.Generic;
using Unity.Collections;

namespace UnityEngine.Rendering.RenderGraphModule.NativeRenderPassCompiler
{
Expand Down Expand Up @@ -594,7 +595,9 @@ public readonly ReadOnlySpan<PassData> GraphPasses(CompilerContextData ctx)
return ctx.passData.MakeReadOnlySpan(firstGraphPass, numGraphPasses);
}

var actualPasses = new PassData[numGraphPasses];
var actualPasses =
new NativeArray<PassData>(numGraphPasses, Allocator.Temp,
NativeArrayOptions.UninitializedMemory);

for (int i = firstGraphPass, index = 0; i < lastGraphPass + 1; ++i)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2519,7 +2519,7 @@ void GenerateCompilerDebugData(ref DebugData debugData)
newPass.syncFromPassIndex = passInfo.syncFromPassIndex;
newPass.syncToPassIndex = passInfo.syncToPassIndex;

DebugData.s_PassScriptMetadata.TryGetValue(pass.name, out newPass.scriptInfo);
DebugData.s_PassScriptMetadata.TryGetValue(pass, out newPass.scriptInfo);

for (int type = 0; type < (int)RenderGraphResourceType.Count; ++type)
{
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
using System.Runtime.CompilerServices;

[assembly: InternalsVisibleTo("SRPSmoke.Editor.Tests")]

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

Loading