Skip to content

Commit 8d3c2e2

Browse files
authored
Merge pull request #8282 from Unity-Technologies/internal/6000.5/staging
Mirror Internal/6000.5/staging
2 parents f098e5d + 66725cd commit 8d3c2e2

54 files changed

Lines changed: 1135 additions & 629 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

Packages/com.unity.render-pipelines.core/Editor-PrivateShared/Tools/Converter/RenderPipelineConverterAssetItem.cs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,13 @@ public string guid
3030

3131
public string GlobalObjectId => m_GlobalObjectId;
3232

33-
public string name => System.IO.Path.GetFileNameWithoutExtension(assetPath);
33+
[SerializeField]
34+
private string m_Name;
35+
public string name
36+
{
37+
get => string.IsNullOrEmpty(m_Name) ? System.IO.Path.GetFileNameWithoutExtension(assetPath) : m_Name;
38+
set => m_Name = value;
39+
}
3440

3541
[SerializeField]
3642
private string m_Info;

Packages/com.unity.render-pipelines.core/Editor/Lighting/ProbeVolume/ProbeGIBaking.LightTransport.cs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -670,7 +670,7 @@ internal static void BakeAdjustmentVolume(ProbeVolumeBakingSet bakingSet, ProbeA
670670
failed |= !layerMaskJob.Step();
671671

672672
// Bake probe SH
673-
s_BakeData.InitLightingJob(m_BakingSet, uniquePositions, BakeType.ApvOnly);
673+
s_BakeData.InitLightingJob(bakingSet, touchup, uniquePositions, BakeType.ApvOnly);
674674
LightingBaker lightingJob = s_BakeData.lightingJob;
675675
while (!failed && lightingJob.currentStep < lightingJob.stepCount)
676676
failed |= !lightingJob.Step();
@@ -680,7 +680,7 @@ internal static void BakeAdjustmentVolume(ProbeVolumeBakingSet bakingSet, ProbeA
680680
foreach ((int uniqueProbeIndex, int cellIndex, int i) in bakedProbes)
681681
{
682682
ref var cell = ref bakingCells[cellIndex];
683-
cell.SetBakedData(m_BakingSet, m_BakingBatch, cellVolumes[cellIndex], i, uniqueProbeIndex,
683+
cell.SetBakedData(bakingSet, m_BakingBatch, cellVolumes[cellIndex], i, uniqueProbeIndex,
684684
lightingJob.irradiance[uniqueProbeIndex], lightingJob.validity[uniqueProbeIndex],
685685
layerMaskJob.renderingLayerMasks, virtualOffsetJob.offsets,
686686
skyOcclusionJob.occlusion, skyOcclusionJob.encodedDirections, lightingJob.occlusion);
@@ -696,8 +696,8 @@ internal static void BakeAdjustmentVolume(ProbeVolumeBakingSet bakingSet, ProbeA
696696
{
697697
// Validate baking cells size before any global state modifications
698698
var chunkSizeInProbes = ProbeBrickPool.GetChunkSizeInProbeCount();
699-
var hasVirtualOffsets = m_BakingSet.settings.virtualOffsetSettings.useVirtualOffset;
700-
var hasRenderingLayers = m_BakingSet.useRenderingLayers;
699+
var hasVirtualOffsets = bakingSet.settings.virtualOffsetSettings.useVirtualOffset;
700+
var hasRenderingLayers = bakingSet.useRenderingLayers;
701701

702702
if (ValidateBakingCellsSize(bakingCells, chunkSizeInProbes, hasVirtualOffsets, hasRenderingLayers))
703703
{
@@ -707,8 +707,8 @@ internal static void BakeAdjustmentVolume(ProbeVolumeBakingSet bakingSet, ProbeA
707707
ComputeValidityMasks(cell);
708708
}
709709

710-
// Attempt to write the result to disk
711-
if (WriteBakingCells(bakingCells))
710+
// Attempt to write the result to disk.
711+
if (WriteBakingCells(bakingSet, bakingCells))
712712
{
713713
// Reload everything
714714
AssetDatabase.SaveAssets();

Packages/com.unity.render-pipelines.core/Editor/Lighting/ProbeVolume/ProbeGIBaking.Placement.cs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,15 @@ static NativeList<Vector3> RunPlacement(ProbeVolumeProfileInfo profileInfo, Prob
133133
{
134134
Debug.Assert(profileInfo != null);
135135

136+
// APV baking requires compute shader support that is not always available on OpenGL devices
137+
if (SystemInfo.graphicsDeviceType == GraphicsDeviceType.OpenGLCore ||
138+
SystemInfo.graphicsDeviceType == GraphicsDeviceType.OpenGLES3)
139+
{
140+
Debug.LogError("Adaptive Probe Volume baking is not supported on OpenGL. Please switch to Direct3D, Vulkan, or Metal in Project Settings > Player > Other Settings > Graphics API.");
141+
canceledByUser = true;
142+
return new NativeList<Vector3>(Allocator.Temp);
143+
}
144+
136145
// Overwrite loaded settings with data from profile. Note that the m_BakingSet.profile is already patched up if isFreezingPlacement
137146
float prevBrickSize = refVolume.MinBrickSize();
138147
int prevMaxSubdiv = refVolume.GetMaxSubdivision();

Packages/com.unity.render-pipelines.core/Editor/Lighting/ProbeVolume/ProbeGIBaking.Serialization.cs

Lines changed: 79 additions & 78 deletions
Large diffs are not rendered by default.

Packages/com.unity.render-pipelines.core/Editor/Lighting/ProbeVolume/ProbeGIBaking.VirtualOffset.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -356,7 +356,7 @@ static internal void RecomputeVOForDebugOnly()
356356
if (ValidateBakingCellsSize(bakingCellsArray, chunkSizeInProbes, hasVirtualOffsets, hasRenderingLayers))
357357
{
358358
// Write back the assets.
359-
WriteBakingCells(bakingCellsArray);
359+
WriteBakingCells(m_BakingSet, bakingCellsArray);
360360
}
361361

362362
m_BakingBatch?.Dispose();

Packages/com.unity.render-pipelines.core/Editor/Lighting/ProbeVolume/ProbeGIBaking.cs

Lines changed: 52 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -479,6 +479,14 @@ struct BakeData
479479
// Cancellation
480480
public bool failed;
481481

482+
[Flags]
483+
enum BakeJobRequests
484+
{
485+
MAIN_REQUEST = 1,
486+
TOUCHUP_REQUESTS = 2,
487+
ADDITIONAL_REQUEST = 4
488+
}
489+
482490
internal static void InitVirtualOffsetJob(IntPtr pVirtualOffsetsBuffer, ref bool bakeVirtualOffsets)
483491
{
484492
bool usingVirtualOffset = m_BakingSet.settings.virtualOffsetSettings.useVirtualOffset;
@@ -541,7 +549,11 @@ public void Init(ProbeVolumeBakingSet bakingSet, NativeList<Vector3> probePositi
541549
probeCount = probePositions.Length;
542550
reflectionProbeCount = requests.Count;
543551

544-
jobs = CreateBakingJobs(bakingSet, requests.Count != 0);
552+
var probeJobRequests = BakeJobRequests.MAIN_REQUEST | BakeJobRequests.TOUCHUP_REQUESTS;
553+
if (requests.Count > 0)
554+
probeJobRequests |= BakeJobRequests.ADDITIONAL_REQUEST;
555+
556+
jobs = CreateBakingJobs(bakingSet, probeJobRequests);
545557
originalPositions = probePositions.ToArray(Allocator.Persistent);
546558
SortPositions(probePositions, requests);
547559

@@ -587,13 +599,22 @@ public void InitAdditionalRequests(NativeList<Vector3> probePositions, List<Vect
587599
stepCount = lightingJob.stepCount;
588600
}
589601

590-
public void InitLightingJob(ProbeVolumeBakingSet bakingSet, NativeList<Vector3> probePositions, BakeType bakeType)
602+
public void InitLightingJob(ProbeVolumeBakingSet bakingSet, ProbeAdjustmentVolume touchup, NativeList<Vector3> probePositions, BakeType bakeType)
591603
{
592604
probeCount = probePositions.Length;
593605

594606
s_AdjustmentVolumes = new TouchupVolumeWithBoundsList();
607+
touchup.GetOBBandAABB(out var obb, out var aabb);
608+
s_AdjustmentVolumes.Add((obb, aabb, touchup));
609+
touchup.skyDirection.Normalize();
595610

596-
jobs = CreateBakingJobs(bakingSet, false);
611+
var probeJobRequests = BakeJobRequests.TOUCHUP_REQUESTS;
612+
if (touchup.mode != ProbeAdjustmentVolume.Mode.OverrideSampleCount)
613+
{
614+
// Other touchup volumes don't need a job of their own but they do need a main request job
615+
probeJobRequests |= BakeJobRequests.MAIN_REQUEST;
616+
}
617+
jobs = CreateBakingJobs(bakingSet, probeJobRequests);
597618
SortPositions(probePositions, new List<Vector3>());
598619

599620
lightingJob = lightingOverride ?? new DefaultLightTransport();
@@ -622,16 +643,19 @@ public void ExecuteLightingAsync()
622643
bakingThread.Start();
623644
}
624645

625-
static BakeJob[] CreateBakingJobs(ProbeVolumeBakingSet bakingSet, bool hasAdditionalRequests)
646+
static BakeJob[] CreateBakingJobs(ProbeVolumeBakingSet bakingSet, BakeJobRequests bakeJobRequests)
626647
{
627648
// Build the list of adjustment volumes affecting sample count
628649
var touchupVolumesAndBounds = new TouchupVolumeWithBoundsList();
650+
if (bakeJobRequests.HasFlag(BakeJobRequests.TOUCHUP_REQUESTS))
629651
{
630652
// This is slow, but we should have very little amount of touchup volumes.
631653
foreach (var adjustment in s_AdjustmentVolumes)
632654
{
633655
if (adjustment.volume.mode == ProbeAdjustmentVolume.Mode.OverrideSampleCount)
656+
{
634657
touchupVolumesAndBounds.Add(adjustment);
658+
}
635659
}
636660

637661
// Sort by volume to give priority to smaller volumes
@@ -640,18 +664,33 @@ static BakeJob[] CreateBakingJobs(ProbeVolumeBakingSet bakingSet, bool hasAdditi
640664

641665
var lightingSettings = ProbeVolumeLightingTab.GetLightingSettings();
642666
bool skyOcclusion = bakingSet.skyOcclusion;
667+
var jobs = new List<BakeJob>();
643668

644-
int additionalJobs = hasAdditionalRequests ? 2 : 1;
645-
var jobs = new BakeJob[touchupVolumesAndBounds.Count + additionalJobs];
669+
if (bakeJobRequests.HasFlag(BakeJobRequests.TOUCHUP_REQUESTS))
670+
{
671+
foreach (var touchupVolume in touchupVolumesAndBounds)
672+
{
673+
BakeJob job = new BakeJob();
674+
job.Create(lightingSettings, skyOcclusion, touchupVolume);
675+
jobs.Add(job);
676+
}
677+
}
646678

647-
for (int i = 0; i < touchupVolumesAndBounds.Count; i++)
648-
jobs[i].Create(lightingSettings, skyOcclusion, touchupVolumesAndBounds[i]);
679+
if (bakeJobRequests.HasFlag(BakeJobRequests.MAIN_REQUEST))
680+
{
681+
BakeJob job = new BakeJob();
682+
job.Create(bakingSet, lightingSettings, skyOcclusion);
683+
jobs.Add(job);
684+
}
649685

650-
jobs[touchupVolumesAndBounds.Count + 0].Create(bakingSet, lightingSettings, skyOcclusion);
651-
if (hasAdditionalRequests)
652-
jobs[touchupVolumesAndBounds.Count + 1].Create(bakingSet, lightingSettings, false);
686+
if (bakeJobRequests.HasFlag(BakeJobRequests.ADDITIONAL_REQUEST))
687+
{
688+
BakeJob job = new BakeJob();
689+
job.Create(bakingSet, lightingSettings, false);
690+
jobs.Add(job);
691+
}
653692

654-
return jobs;
693+
return jobs.ToArray();
655694
}
656695

657696
static BakeJob[] CreateAdditionalBakingJobs()
@@ -1802,7 +1841,7 @@ static void ApplyPostBakeOperations()
18021841
// Attempt to convert baking cells to runtime cells
18031842
bool succeededWritingBakingCells;
18041843
using (new BakingCompleteProfiling(BakingCompleteProfiling.Stages.WriteBakedData))
1805-
succeededWritingBakingCells = WriteBakingCells(m_BakedCells.Values.ToArray());
1844+
succeededWritingBakingCells = WriteBakingCells(m_BakingSet, m_BakedCells.Values.ToArray());
18061845

18071846
if (!succeededWritingBakingCells)
18081847
return;

Packages/com.unity.render-pipelines.core/Editor/Lighting/ProbeVolume/ProbePlacement.cs

Lines changed: 24 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -170,13 +170,30 @@ static ComputeShader subdivideSceneCS
170170
{
171171
_subdivideSceneCS = GraphicsSettings.GetRenderPipelineSettings<ProbeVolumeBakingResources>().subdivideSceneCS;
172172

173-
s_ClearBufferKernel = subdivideSceneCS.FindKernel("ClearBuffer");
174-
s_ClearKernel = subdivideSceneCS.FindKernel("Clear");
175-
s_JumpFloodingKernel = subdivideSceneCS.FindKernel("JumpFlooding");
176-
s_FillUVKernel = subdivideSceneCS.FindKernel("FillUVMap");
177-
s_FinalPassKernel = subdivideSceneCS.FindKernel("FinalPass");
178-
s_VoxelizeProbeVolumesKernel = subdivideSceneCS.FindKernel("VoxelizeProbeVolumeData");
179-
s_SubdivideKernel = subdivideSceneCS.FindKernel("Subdivide");
173+
// The compute shader is not supported on OpenGL (see #pragma only_renderers in ProbeVolumeSubdivide.compute)
174+
// The kernels won't exist, so we skip initialization. This is caught earlier in RunPlacement with a proper error message.
175+
try
176+
{
177+
s_ClearBufferKernel = subdivideSceneCS.FindKernel("ClearBuffer");
178+
s_ClearKernel = subdivideSceneCS.FindKernel("Clear");
179+
s_JumpFloodingKernel = subdivideSceneCS.FindKernel("JumpFlooding");
180+
s_FillUVKernel = subdivideSceneCS.FindKernel("FillUVMap");
181+
s_FinalPassKernel = subdivideSceneCS.FindKernel("FinalPass");
182+
s_VoxelizeProbeVolumesKernel = subdivideSceneCS.FindKernel("VoxelizeProbeVolumeData");
183+
s_SubdivideKernel = subdivideSceneCS.FindKernel("Subdivide");
184+
}
185+
catch (System.ArgumentException)
186+
{
187+
// Kernels not found - likely running on unsupported graphics API
188+
string message = "ProbeVolumeSubdivide compute shader kernels not found.";
189+
if (SystemInfo.graphicsDeviceType == GraphicsDeviceType.OpenGLCore ||
190+
SystemInfo.graphicsDeviceType == GraphicsDeviceType.OpenGLES3)
191+
{
192+
message += " This is expected on OpenGL which is not supported for APV baking.";
193+
}
194+
Debug.LogWarning(message);
195+
_subdivideSceneCS = null;
196+
}
180197
}
181198
return _subdivideSceneCS;
182199
}

Packages/com.unity.render-pipelines.core/Runtime/GPUDriven/Batching/InstanceCullingBatcherBurst.cs

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -141,15 +141,24 @@ private static void ProcessRenderer(InstanceHandle instance,
141141
// Scan all materials once to retrieve whether this renderer is indirect-compatible or not (and store it in the RangeKey).
142142
// Also cache hash map lookups since we need them right after.
143143
bool supportsIndirect = true;
144-
NativeArray<GPUDrivenMaterial> subMaterials = new NativeArray<GPUDrivenMaterial>(subMaterialIDs.Length, Allocator.Temp);
144+
bool isMetal = SystemInfo.graphicsDeviceType == GraphicsDeviceType.Metal;
145+
var subMaterials = new NativeArray<GPUDrivenMaterial>(subMaterialIDs.Length, Allocator.Temp);
145146
for (int i = 0; i < subMaterialIDs.Length; i++)
146147
{
147148
EntityId subMaterialID = subMaterialIDs[i];
148149
if (!materialMap.TryGetValue(subMaterialID, out GPUDrivenMaterial subMaterial))
149150
continue;
150151

151-
supportsIndirect &= subMaterial.isIndirectSupported;
152152
subMaterials[i] = subMaterial;
153+
154+
int subMeshIndex = subMeshStartIndex + i;
155+
int lodLoopCount = math.max(mesh.meshLodCount, 1);
156+
var subMesh = mesh.subMeshes[subMeshIndex * lodLoopCount];
157+
158+
// The indirect path does not support topology adjustment; use the direct path when this is required.
159+
// Concretely, for quads, only use the indirect path if we allow quads natively (e.g. tessellation shaders).
160+
supportsIndirect &= subMesh.topology != MeshTopology.Quads || subMaterial.hasTessellation;
161+
supportsIndirect &= !isMetal || !subMaterial.hasTessellation;
153162
}
154163

155164
var rangeKey = new RangeKey

Packages/com.unity.render-pipelines.core/Runtime/Settings/RenderingDebuggerRuntimeResources.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -30,12 +30,12 @@ enum Version
3030

3131
#if ENABLE_RENDERING_DEBUGGER_UI
3232
[SerializeField, ResourcePath("Runtime/Debugging/Runtime UI Resources/RuntimeDebugWindow_PanelSettings.asset")]
33-
private LazyLoadReference<PanelSettings> m_PanelSettings;
33+
private PanelSettings m_PanelSettings;
3434

35-
/// <summary>StyleSheet for the Rendering Debugger Runtime UI</summary>
35+
/// <summary>Panel Settings Asset for the Rendering Debugger Runtime UI</summary>
3636
public PanelSettings panelSettings
3737
{
38-
get => m_PanelSettings.asset;
38+
get => m_PanelSettings;
3939
set => this.SetValueAndNotify(ref m_PanelSettings, value, nameof(m_PanelSettings));
4040
}
4141

@@ -54,12 +54,12 @@ public StyleSheet[] styleSheets
5454
}
5555

5656
[SerializeField, ResourcePath("Runtime/Debugging/Runtime UI Resources/RuntimeDebugWindow.uxml")]
57-
private LazyLoadReference<VisualTreeAsset> m_VisualTreeAsset;
57+
private VisualTreeAsset m_VisualTreeAsset;
5858

5959
/// <summary>Visual Tree Asset for the Rendering Debugger Runtime UI</summary>
6060
public VisualTreeAsset visualTreeAsset
6161
{
62-
get => m_VisualTreeAsset.asset;
62+
get => m_VisualTreeAsset;
6363
set => this.SetValueAndNotify(ref m_VisualTreeAsset, value, nameof(m_VisualTreeAsset));
6464
}
6565
#endif

0 commit comments

Comments
 (0)