Browse Source

Merge branch 'master' into ww1dev/hdrp17/staging

ww1dev/hdrp17/staging
Nico de Poel 8 months ago
parent
commit
126b8bc3bb
  1. 22
      Packages/com.unity.render-pipelines.core/Editor/Deprecated.cs
  2. 8
      Packages/com.unity.render-pipelines.core/Editor/Lighting/ProbeVolume/ProbeGIBaking.cs
  3. 11
      Packages/com.unity.render-pipelines.core/Editor/RenderGraph/RenderGraphViewer.SidePanel.cs
  4. 6
      Packages/com.unity.render-pipelines.core/Editor/Settings/PropertyDrawers/DefaultVolumeProfileSettingsPropertyDrawer.cs
  5. 12
      Packages/com.unity.render-pipelines.core/Runtime/Common/CoreUnsafeUtils.cs
  6. 3
      Packages/com.unity.render-pipelines.core/Runtime/Common/DynamicArray.cs
  7. 15
      Packages/com.unity.render-pipelines.core/Runtime/GPUDriven/GPUResidentBatcher.cs
  8. 91
      Packages/com.unity.render-pipelines.core/Runtime/GPUDriven/GPUResidentDrawer.cs
  9. 123
      Packages/com.unity.render-pipelines.core/Runtime/GPUDriven/InstanceCullingBatcher.cs
  10. 1
      Packages/com.unity.render-pipelines.core/Runtime/Lighting/ProbeVolume/ProbeBrickPool.cs
  11. 5
      Packages/com.unity.render-pipelines.core/Runtime/Lighting/ProbeVolume/ProbeReferenceVolume.cs
  12. 3
      Packages/com.unity.render-pipelines.core/Runtime/RenderGraph/Compiler/NativePassCompiler.Debug.cs
  13. 36
      Packages/com.unity.render-pipelines.core/Runtime/Utilities/Blitter.cs
  14. 26
      Packages/com.unity.render-pipelines.core/Tests/Editor/FixedBufferStringQueueTests.cs
  15. 42
      Packages/com.unity.render-pipelines.core/Tests/Editor/GPUDriven/GPUDrivenRenderingTests.cs
  16. 2
      Packages/com.unity.render-pipelines.core/package.json
  17. 2
      Packages/com.unity.render-pipelines.high-definition-config/package.json
  18. 2
      Packages/com.unity.render-pipelines.high-definition/Editor/PropertyDrawers/HDRPDefaultVolumeProfileSettingsPropertyDrawer.cs
  19. 4
      Packages/com.unity.render-pipelines.high-definition/Editor/RenderPipeline/Camera/HDCameraUI.Rendering.Drawers.cs
  20. 17
      Packages/com.unity.render-pipelines.high-definition/Editor/RenderPipeline/CustomPass/CustomPassDrawer.cs
  21. 3
      Packages/com.unity.render-pipelines.high-definition/Editor/RenderPipeline/HDRenderPipelineUI.Skin.cs
  22. 4
      Packages/com.unity.render-pipelines.high-definition/Editor/RenderPipeline/HDRenderPipelineUI.cs
  23. 6
      Packages/com.unity.render-pipelines.high-definition/Runtime/Lighting/Shadow/HDShadowAlgorithms.hlsl
  24. 2
      Packages/com.unity.render-pipelines.high-definition/Runtime/Material/Lit/Lit.shader
  25. 7
      Packages/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/HDRenderPipeline.PostProcess.cs
  26. 4
      Packages/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/HDRenderPipeline.Prepass.cs
  27. 2
      Packages/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/HDRenderPipeline.cs
  28. 29
      Packages/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/RenderPass/CustomPass/CustomPass.cs
  29. 4
      Packages/com.unity.render-pipelines.high-definition/Runtime/Settings/HDRPDefaultVolumeProfileSetting.cs
  30. 4
      Packages/com.unity.render-pipelines.high-definition/Runtime/Water/Shaders/SampleWaterSurface.hlsl
  31. 2
      Packages/com.unity.render-pipelines.high-definition/Runtime/Water/Shaders/UnderWaterUtilities.hlsl
  32. 2
      Packages/com.unity.render-pipelines.high-definition/package.json
  33. 9
      Packages/com.unity.shadergraph/Editor/Drawing/MaterialGraphEditWindow.cs
  34. 2
      Packages/com.unity.shadergraph/package.json
  35. 2
      Packages/com.unity.ugui/Editor/TMP/TMP_BaseShaderGUI.cs
  36. 15
      Packages/com.unity.ugui/Editor/TMP/TMP_FontAssetEditor.cs
  37. 7
      Packages/com.unity.ugui/Editor/TMP/TMPro_FontAssetCreatorWindow.cs
  38. 10
      Packages/com.unity.ugui/Runtime/TMP/TMP_InputField.cs
  39. 2
      Packages/com.unity.ugui/Runtime/TMP/TMP_SpriteAsset.cs
  40. 4
      Packages/com.unity.ugui/Runtime/UGUI/UI/Core/InputField.cs
  41. 2
      Packages/com.unity.ugui/package.json
  42. 6
      Packages/com.unity.visualeffectgraph/Editor/GraphView/Views/VFXConvertSubgraph.cs
  43. 82
      Packages/com.unity.visualeffectgraph/Editor/GraphView/Views/VFXView.cs
  44. 3
      Packages/com.unity.visualeffectgraph/Editor/Models/VFXErrorManager.cs
  45. 45
      Packages/com.unity.visualeffectgraph/Editor/Models/VFXGraph.cs
  46. 8
      Packages/com.unity.visualeffectgraph/Editor/UIResources/uss/PropertyRM.uss
  47. 4
      Packages/com.unity.visualeffectgraph/Editor/UIResources/uss/VFXDataAnchor.uss
  48. 4
      Packages/com.unity.visualeffectgraph/Shaders/VFXVolumetricFogUpdate.template
  49. 2
      Packages/com.unity.visualeffectgraph/package.json

22
Packages/com.unity.render-pipelines.core/Editor/Deprecated.cs

@ -2,6 +2,7 @@ using System;
using System.Collections.Generic; using System.Collections.Generic;
using UnityEngine; using UnityEngine;
using UnityEngine.Rendering; using UnityEngine.Rendering;
using UnityEngine.UIElements;
namespace UnityEditor.Rendering namespace UnityEditor.Rendering
{ {
@ -182,7 +183,28 @@ namespace UnityEditor.Rendering
} }
} }
public abstract partial class DefaultVolumeProfileSettingsPropertyDrawer
{
/// <summary>
/// Context menu implementation for Default Volume Profile.
/// </summary>
/// <typeparam name="TSetting">Default Volume Profile Settings type</typeparam>
/// <typeparam name="TRenderPipeline">Render Pipeline type</typeparam>
[Obsolete("Use DefaultVolumeProfileSettingsPropertyDrawer<T>.DefaultVolumeProfileSettingsContextMenu2<TSetting, TRenderPipeline> instead #from(6000.0)")]
public abstract class DefaultVolumeProfileSettingsContextMenu<TSetting, TRenderPipeline> : IRenderPipelineGraphicsSettingsContextMenu<TSetting>
where TSetting : class, IDefaultVolumeProfileSettings
where TRenderPipeline : RenderPipeline
{
/// <summary>
/// Path where new Default Volume Profile will be created.
/// </summary>
[Obsolete("Not used anymore. #from(6000.0)")]
protected abstract string defaultVolumeProfilePath { get; }
[Obsolete("Not used anymore. #from(6000.0)")]
void IRenderPipelineGraphicsSettingsContextMenu<TSetting>.PopulateContextMenu(TSetting setting, PropertyDrawer property, ref GenericMenu menu){ }
}
}
/// <summary> /// <summary>
/// Builtin Drawer for Maskfield Debug Items. /// Builtin Drawer for Maskfield Debug Items.

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

@ -1419,11 +1419,14 @@ namespace UnityEngine.Rendering
if (m_BakingSet.hasDilation) if (m_BakingSet.hasDilation)
{ {
// This subsequent block needs to happen AFTER we call WriteBakingCells. // This subsequent block needs to happen AFTER we call WriteBakingCells.
// Otherwise in cases where we change the spacing between probes, we end up loading cells with a certain layout in ForceSHBand
// Otherwise, in cases where we change the spacing between probes, we end up loading cells with a certain layout in ForceSHBand
// And then we unload cells using the wrong layout in PerformDilation (after WriteBakingCells updates the baking set object) which leads to a broken internal state. // And then we unload cells using the wrong layout in PerformDilation (after WriteBakingCells updates the baking set object) which leads to a broken internal state.
// Don't use Disk streaming to avoid having to wait for it when doing dilation. // Don't use Disk streaming to avoid having to wait for it when doing dilation.
probeRefVolume.ForceNoDiskStreaming(true); probeRefVolume.ForceNoDiskStreaming(true);
// Increase the memory budget to make sure we can fit the current cell and all its neighbors when doing dilation.
var prevMemoryBudget = probeRefVolume.memoryBudget;
probeRefVolume.ForceMemoryBudget(ProbeVolumeTextureMemoryBudget.MemoryBudgetHigh);
// Force maximum sh bands to perform baking, we need to store what sh bands was selected from the settings as we need to restore it after. // Force maximum sh bands to perform baking, we need to store what sh bands was selected from the settings as we need to restore it after.
var prevSHBands = probeRefVolume.shBands; var prevSHBands = probeRefVolume.shBands;
probeRefVolume.ForceSHBand(ProbeVolumeSHBands.SphericalHarmonicsL2); probeRefVolume.ForceSHBand(ProbeVolumeSHBands.SphericalHarmonicsL2);
@ -1434,8 +1437,9 @@ namespace UnityEngine.Rendering
using (new BakingCompleteProfiling(BakingCompleteProfiling.Stages.PerformDilation)) using (new BakingCompleteProfiling(BakingCompleteProfiling.Stages.PerformDilation))
PerformDilation(); PerformDilation();
// Need to restore the original state
// Restore the original state.
probeRefVolume.ForceNoDiskStreaming(false); probeRefVolume.ForceNoDiskStreaming(false);
probeRefVolume.ForceMemoryBudget(prevMemoryBudget);
probeRefVolume.ForceSHBand(prevSHBands); probeRefVolume.ForceSHBand(prevSHBands);
} }
else else

11
Packages/com.unity.render-pipelines.core/Editor/RenderGraph/RenderGraphViewer.SidePanel.cs

@ -18,6 +18,14 @@ namespace UnityEditor.Rendering
"Compute Pass" "Compute Pass"
}; };
static readonly string[] k_PassTypeNamesNotMergedMessage =
{
"This is a Legacy Render Pass. Only Raster Render Passes can be merged.",
"This is an Unsafe Render Pass. Only Raster Render Passes can be merged.",
"Pass merging was disabled.",
"This is a Compute Pass. Only Raster Render Passes can be merged."
};
static partial class Names static partial class Names
{ {
public const string kPanelContainer = "panel-container"; public const string kPanelContainer = "panel-container";
@ -370,8 +378,7 @@ namespace UnityEditor.Rendering
else else
{ {
CreateTextElement(passItem, "Pass break reasoning", Classes.kSubHeaderText); CreateTextElement(passItem, "Pass break reasoning", Classes.kSubHeaderText);
var msg = $"This is a {k_PassTypeNames[(int) firstPassData.type]}. Only Raster Render Passes can be merged.";
msg = msg.Replace("a Unsafe", "an Unsafe");
string msg = k_PassTypeNamesNotMergedMessage[(int)firstPassData.type];
CreateTextElement(passItem, msg); CreateTextElement(passItem, msg);
} }

6
Packages/com.unity.render-pipelines.core/Editor/Settings/PropertyDrawers/DefaultVolumeProfileSettingsPropertyDrawer.cs

@ -8,7 +8,7 @@ namespace UnityEditor.Rendering
/// <summary> /// <summary>
/// Base implementation for drawing Default Volume Profile UI in Graphics Settings. /// Base implementation for drawing Default Volume Profile UI in Graphics Settings.
/// </summary> /// </summary>
public abstract class DefaultVolumeProfileSettingsPropertyDrawer : PropertyDrawer
public abstract partial class DefaultVolumeProfileSettingsPropertyDrawer : PropertyDrawer
{ {
// UUM-77758: Due to how PropertyDrawers are created and cached, there is no way to retrieve them reliably // UUM-77758: Due to how PropertyDrawers are created and cached, there is no way to retrieve them reliably
// later. We know that only one DefaultVolumeProfile exists at any given time, so we can access it through // later. We know that only one DefaultVolumeProfile exists at any given time, so we can access it through
@ -118,7 +118,7 @@ namespace UnityEditor.Rendering
/// </summary> /// </summary>
/// <typeparam name="TSetting">Default Volume Profile Settings type</typeparam> /// <typeparam name="TSetting">Default Volume Profile Settings type</typeparam>
/// <typeparam name="TRenderPipeline">Render Pipeline type</typeparam> /// <typeparam name="TRenderPipeline">Render Pipeline type</typeparam>
public abstract class DefaultVolumeProfileSettingsContextMenu<TSetting, TRenderPipeline> : IRenderPipelineGraphicsSettingsContextMenu<TSetting>
public abstract class DefaultVolumeProfileSettingsContextMenu2<TSetting, TRenderPipeline> : IRenderPipelineGraphicsSettingsContextMenu2<TSetting>
where TSetting : class, IDefaultVolumeProfileSettings where TSetting : class, IDefaultVolumeProfileSettings
where TRenderPipeline : RenderPipeline where TRenderPipeline : RenderPipeline
{ {
@ -127,7 +127,7 @@ namespace UnityEditor.Rendering
/// </summary> /// </summary>
protected abstract string defaultVolumeProfilePath { get; } protected abstract string defaultVolumeProfilePath { get; }
void IRenderPipelineGraphicsSettingsContextMenu<TSetting>.PopulateContextMenu(TSetting setting, PropertyDrawer _, ref GenericMenu menu)
void IRenderPipelineGraphicsSettingsContextMenu2<TSetting>.PopulateContextMenu(TSetting setting, SerializedProperty _, ref GenericMenu menu)
{ {
bool canCreateNewAsset = RenderPipelineManager.currentPipeline is TRenderPipeline; bool canCreateNewAsset = RenderPipelineManager.currentPipeline is TRenderPipeline;
VolumeProfileUtils.AddVolumeProfileContextMenuItems(ref menu, VolumeProfileUtils.AddVolumeProfileContextMenuItems(ref menu,

12
Packages/com.unity.render-pipelines.core/Runtime/Common/CoreUnsafeUtils.cs

@ -69,12 +69,18 @@ namespace UnityEngine.Rendering
} }
/// <summary> /// <summary>
/// Pop an element of the queue.
/// Try to pop an element of the queue.
/// </summary> /// </summary>
/// <param name="v">Output result string.</param> /// <param name="v">Output result string.</param>
/// <returns>True if an element was succesfuly poped.</returns>
/// <returns>True if an element was successfully popped.</returns>
public bool TryPop(out string v) public bool TryPop(out string v)
{ {
if (m_ReadCursor + sizeof(int) >= m_BufferEnd)
{
v = null;
return false;
}
var size = *(int*)m_ReadCursor; var size = *(int*)m_ReadCursor;
if (size != 0) if (size != 0)
{ {
@ -84,7 +90,7 @@ namespace UnityEngine.Rendering
return true; return true;
} }
v = default;
v = null;
return false; return false;
} }

3
Packages/com.unity.render-pipelines.core/Runtime/Common/DynamicArray.cs

@ -685,8 +685,7 @@ namespace UnityEngine.Rendering
} }
} }
// C# SUCKS
// Had to copy paste because it's apparently impossible to pass a sort delegate where T is Comparable<T>, otherwise some boxing happens and allocates...
// A copy/paste because it's apparently impossible to pass a sort delegate where T is Comparable<T>, otherwise some boxing happens and allocates...
// So two identical versions of the function, one with delegate but no Comparable and the other with just the comparable. // So two identical versions of the function, one with delegate but no Comparable and the other with just the comparable.
static int Partition<T>(Span<T> data, int left, int right, DynamicArray<T>.SortComparer comparer) where T : new() static int Partition<T>(Span<T> data, int left, int right, DynamicArray<T>.SortComparer comparer) where T : new()
{ {

15
Packages/com.unity.render-pipelines.core/Runtime/GPUDriven/GPUResidentBatcher.cs

@ -196,12 +196,7 @@ namespace UnityEngine.Rendering
Profiler.BeginSample("InstanceCullingBatcher.BuildBatch"); Profiler.BeginSample("InstanceCullingBatcher.BuildBatch");
{ {
m_InstanceCullingBatcher.BuildBatch(
instances,
rendererData.materialID,
rendererData.meshID,
rendererData, true);
m_InstanceCullingBatcher.BuildBatch(instances, rendererData, true);
} }
Profiler.EndSample(); Profiler.EndSample();
@ -234,15 +229,11 @@ namespace UnityEngine.Rendering
Profiler.BeginSample("InstanceCullingBatcher.BuildBatch"); Profiler.BeginSample("InstanceCullingBatcher.BuildBatch");
{ {
m_InstanceCullingBatcher.BuildBatch(
instances.AsArray(),
rendererData.materialID,
rendererData.meshID,
rendererData, false);
instances.Dispose();
m_InstanceCullingBatcher.BuildBatch(instances.AsArray(), rendererData, false);
} }
Profiler.EndSample(); Profiler.EndSample();
instances.Dispose();
} }
Profiler.EndSample(); Profiler.EndSample();
} }

91
Packages/com.unity.render-pipelines.core/Runtime/GPUDriven/GPUResidentDrawer.cs

@ -567,7 +567,7 @@ namespace UnityEngine.Rendering
var lodGroupTransformData = m_Dispatcher.GetTransformChangesAndClear<LODGroup>(TransformTrackingType.GlobalTRS, Allocator.TempJob); var lodGroupTransformData = m_Dispatcher.GetTransformChangesAndClear<LODGroup>(TransformTrackingType.GlobalTRS, Allocator.TempJob);
var lodGroupData = m_Dispatcher.GetTypeChangesAndClear<LODGroup>(Allocator.TempJob, noScriptingArray: true); var lodGroupData = m_Dispatcher.GetTypeChangesAndClear<LODGroup>(Allocator.TempJob, noScriptingArray: true);
var meshDataSorted = m_Dispatcher.GetTypeChangesAndClear<Mesh>(Allocator.TempJob, sortByInstanceID: true, noScriptingArray: true); var meshDataSorted = m_Dispatcher.GetTypeChangesAndClear<Mesh>(Allocator.TempJob, sortByInstanceID: true, noScriptingArray: true);
var materialData = m_Dispatcher.GetTypeChangesAndClear<Material>(Allocator.TempJob);
var materialData = m_Dispatcher.GetTypeChangesAndClear<Material>(Allocator.TempJob, noScriptingArray: true);
var rendererData = m_Dispatcher.GetTypeChangesAndClear<MeshRenderer>(Allocator.TempJob, noScriptingArray: true); var rendererData = m_Dispatcher.GetTypeChangesAndClear<MeshRenderer>(Allocator.TempJob, noScriptingArray: true);
Profiler.EndSample(); Profiler.EndSample();
@ -597,8 +597,8 @@ namespace UnityEngine.Rendering
ProcessRenderers(rendererData, unsupportedRenderers.AsArray()); ProcessRenderers(rendererData, unsupportedRenderers.AsArray());
Profiler.EndSample(); Profiler.EndSample();
Profiler.BeginSample("GPUResidentDrawer.ProcessRendererMaterialChanges");
ProcessRendererMaterialChanges(rendererData.changedID, supportedChangedMaterials.AsArray(), supportedChangedPackedMaterialDatas.AsArray());
Profiler.BeginSample("GPUResidentDrawer.ProcessRendererMaterialAndMeshChanges");
ProcessRendererMaterialAndMeshChanges(rendererData.changedID, supportedChangedMaterials.AsArray(), supportedChangedPackedMaterialDatas.AsArray(), meshDataSorted.changedID);
Profiler.EndSample(); Profiler.EndSample();
lodGroupTransformData.Dispose(); lodGroupTransformData.Dispose();
@ -655,9 +655,9 @@ namespace UnityEngine.Rendering
m_BatchersContext.TransformLODGroups(transformedID); m_BatchersContext.TransformLODGroups(transformedID);
} }
private void ProcessRendererMaterialChanges(NativeArray<int> excludedRenderers, NativeArray<int> changedMaterials, NativeArray<GPUDrivenPackedMaterialData> changedPackedMaterialDatas)
private void ProcessRendererMaterialAndMeshChanges(NativeArray<int> excludedRenderers, NativeArray<int> changedMaterials, NativeArray<GPUDrivenPackedMaterialData> changedPackedMaterialDatas, NativeArray<int> changedMeshes)
{ {
if (changedMaterials.Length == 0)
if (changedMaterials.Length == 0 && changedMeshes.Length == 0)
return; return;
Profiler.BeginSample("GPUResidentDrawer.GetMaterialsWithChangedPackedMaterial"); Profiler.BeginSample("GPUResidentDrawer.GetMaterialsWithChangedPackedMaterial");
@ -669,7 +669,7 @@ namespace UnityEngine.Rendering
Profiler.EndSample(); Profiler.EndSample();
if (filteredMaterials.Count == 0)
if (filteredMaterials.Count == 0 && changedMeshes.Length == 0)
{ {
filteredMaterials.Dispose(); filteredMaterials.Dispose();
updatePackedMaterialCacheJob.Complete(); updatePackedMaterialCacheJob.Complete();
@ -679,14 +679,14 @@ namespace UnityEngine.Rendering
var sortedExcludedRenderers = new NativeArray<int>(excludedRenderers, Allocator.TempJob); var sortedExcludedRenderers = new NativeArray<int>(excludedRenderers, Allocator.TempJob);
if (sortedExcludedRenderers.Length > 0) if (sortedExcludedRenderers.Length > 0)
{ {
Profiler.BeginSample("ProcessRendererMaterialChanges.Sort");
Profiler.BeginSample("ProcessRendererMaterialAndMeshChanges.Sort");
sortedExcludedRenderers.ParallelSort().Complete(); sortedExcludedRenderers.ParallelSort().Complete();
Profiler.EndSample(); Profiler.EndSample();
} }
Profiler.BeginSample("GPUResidentDrawer.FindRenderersFromMaterials");
Profiler.BeginSample("GPUResidentDrawer.FindRenderersFromMaterialsOrMeshes");
NativeList<int> renderersWithChangedMaterials = FindRenderersFromMaterials(sortedExcludedRenderers, filteredMaterials, Allocator.TempJob);
var (renderersWithChangedMaterials, renderersWithChangedMeshes) = FindRenderersFromMaterialsOrMeshes(sortedExcludedRenderers, filteredMaterials, changedMeshes, Allocator.TempJob);
filteredMaterials.Dispose(); filteredMaterials.Dispose();
Profiler.EndSample(); Profiler.EndSample();
@ -694,22 +694,35 @@ namespace UnityEngine.Rendering
sortedExcludedRenderers.Dispose(); sortedExcludedRenderers.Dispose();
updatePackedMaterialCacheJob.Complete(); updatePackedMaterialCacheJob.Complete();
if (renderersWithChangedMaterials.Length == 0)
if (renderersWithChangedMaterials.Length == 0 && renderersWithChangedMeshes.Length == 0)
{ {
renderersWithChangedMaterials.Dispose(); renderersWithChangedMaterials.Dispose();
renderersWithChangedMeshes.Dispose();
return; return;
} }
Profiler.BeginSample("GPUResidentDrawer.UpdateRenderers"); Profiler.BeginSample("GPUResidentDrawer.UpdateRenderers");
{ {
var materialChangedInstances = new NativeArray<InstanceHandle>(renderersWithChangedMaterials.Length, Allocator.TempJob, NativeArrayOptions.UninitializedMemory);
ScheduleQueryRendererGroupInstancesJob(renderersWithChangedMaterials.AsArray(), materialChangedInstances).Complete();
var changedMaterialsCount = renderersWithChangedMaterials.Length;
var changedMeshesCount = renderersWithChangedMeshes.Length;
var totalCount = changedMaterialsCount + changedMeshesCount;
m_Batcher.DestroyDrawInstances(materialChangedInstances);
materialChangedInstances.Dispose();
var changedInstances = new NativeArray<InstanceHandle>(totalCount, Allocator.TempJob, NativeArrayOptions.UninitializedMemory);
var changedRenderers = new NativeArray<int>(totalCount, Allocator.TempJob, NativeArrayOptions.UninitializedMemory);
NativeArray<int>.Copy(renderersWithChangedMaterials.AsArray(), changedRenderers, changedMaterialsCount);
NativeArray<int>.Copy(renderersWithChangedMeshes.AsArray(), changedRenderers.GetSubArray(changedMaterialsCount, changedMeshesCount), changedMeshesCount);
ScheduleQueryRendererGroupInstancesJob(changedRenderers, changedInstances).Complete();
m_Batcher.DestroyDrawInstances(changedInstances);
m_Batcher.UpdateRenderers(renderersWithChangedMaterials.AsArray(), true); m_Batcher.UpdateRenderers(renderersWithChangedMaterials.AsArray(), true);
m_Batcher.UpdateRenderers(renderersWithChangedMeshes.AsArray(), false);
changedInstances.Dispose();
changedRenderers.Dispose();
renderersWithChangedMaterials.Dispose(); renderersWithChangedMaterials.Dispose();
renderersWithChangedMeshes.Dispose();
} }
Profiler.EndSample(); Profiler.EndSample();
} }
@ -858,22 +871,26 @@ namespace UnityEngine.Rendering
return filteredMaterials; return filteredMaterials;
} }
private NativeList<int> FindRenderersFromMaterials(NativeArray<int> sortedExcludeRenderers, NativeHashSet<int> materials, Allocator rendererListAllocator)
private (NativeList<int> renderersWithMaterials, NativeList<int> renderersWithMeshes) FindRenderersFromMaterialsOrMeshes(NativeArray<int> sortedExcludeRenderers, NativeHashSet<int> materials, NativeArray<int> meshes, Allocator rendererListAllocator)
{ {
var sharedInstanceData = m_BatchersContext.sharedInstanceData; var sharedInstanceData = m_BatchersContext.sharedInstanceData;
NativeList<int> renderers = new NativeList<int>(sharedInstanceData.rendererGroupIDs.Length, rendererListAllocator);
NativeList<int> renderersWithMaterials = new NativeList<int>(sharedInstanceData.rendererGroupIDs.Length, rendererListAllocator);
NativeList<int> renderersWithMeshes = new NativeList<int>(sharedInstanceData.rendererGroupIDs.Length, rendererListAllocator);
var jobHandle = new FindRenderersFromMaterialJob
var jobHandle = new FindRenderersFromMaterialOrMeshJob
{ {
materialIDs = materials.AsReadOnly(), materialIDs = materials.AsReadOnly(),
materialIDArrays = sharedInstanceData.materialIDArrays, materialIDArrays = sharedInstanceData.materialIDArrays,
meshIDs = meshes.AsReadOnly(),
meshIDArray = sharedInstanceData.meshIDs,
rendererGroupIDs = sharedInstanceData.rendererGroupIDs, rendererGroupIDs = sharedInstanceData.rendererGroupIDs,
sortedExcludeRendererIDs = sortedExcludeRenderers.AsReadOnly(), sortedExcludeRendererIDs = sortedExcludeRenderers.AsReadOnly(),
selectedRenderGroups = renderers.AsParallelWriter(),
}.ScheduleBatch(sharedInstanceData.rendererGroupIDs.Length, FindRenderersFromMaterialJob.k_BatchSize);
selectedRenderGroupsForMaterials = renderersWithMaterials.AsParallelWriter(),
selectedRenderGroupsForMeshes = renderersWithMeshes.AsParallelWriter()
}.ScheduleBatch(sharedInstanceData.rendererGroupIDs.Length, FindRenderersFromMaterialOrMeshJob.k_BatchSize);
jobHandle.Complete(); jobHandle.Complete();
return renderers;
return (renderersWithMaterials, renderersWithMeshes);
} }
[BurstCompile(DisableSafetyChecks = true, OptimizeFor = OptimizeFor.Performance)] [BurstCompile(DisableSafetyChecks = true, OptimizeFor = OptimizeFor.Performance)]
@ -950,22 +967,29 @@ namespace UnityEngine.Rendering
} }
[BurstCompile(DisableSafetyChecks = true, OptimizeFor = OptimizeFor.Performance)] [BurstCompile(DisableSafetyChecks = true, OptimizeFor = OptimizeFor.Performance)]
private unsafe struct FindRenderersFromMaterialJob : IJobParallelForBatch
private unsafe struct FindRenderersFromMaterialOrMeshJob : IJobParallelForBatch
{ {
public const int k_BatchSize = 128; public const int k_BatchSize = 128;
[ReadOnly] public NativeHashSet<int>.ReadOnly materialIDs; [ReadOnly] public NativeHashSet<int>.ReadOnly materialIDs;
[ReadOnly] public NativeArray<SmallIntegerArray>.ReadOnly materialIDArrays; [ReadOnly] public NativeArray<SmallIntegerArray>.ReadOnly materialIDArrays;
[ReadOnly] public NativeArray<int>.ReadOnly meshIDs;
[ReadOnly] public NativeArray<int>.ReadOnly meshIDArray;
[ReadOnly] public NativeArray<int>.ReadOnly rendererGroupIDs; [ReadOnly] public NativeArray<int>.ReadOnly rendererGroupIDs;
[ReadOnly] public NativeArray<int>.ReadOnly sortedExcludeRendererIDs; [ReadOnly] public NativeArray<int>.ReadOnly sortedExcludeRendererIDs;
[WriteOnly] public NativeList<int>.ParallelWriter selectedRenderGroups;
[WriteOnly] public NativeList<int>.ParallelWriter selectedRenderGroupsForMaterials;
[WriteOnly] public NativeList<int>.ParallelWriter selectedRenderGroupsForMeshes;
public void Execute(int startIndex, int count) public void Execute(int startIndex, int count)
{ {
int* renderersToAddPtr = stackalloc int[k_BatchSize];
var renderersToAdd = new UnsafeList<int>(renderersToAddPtr, k_BatchSize);
renderersToAdd.Length = 0;
int* renderersToAddForMaterialsPtr = stackalloc int[k_BatchSize];
var renderersToAddForMaterials = new UnsafeList<int>(renderersToAddForMaterialsPtr, k_BatchSize);
renderersToAddForMaterials.Length = 0;
int* renderersToAddForMeshesPtr = stackalloc int[k_BatchSize];
var renderersToAddForMeshes = new UnsafeList<int>(renderersToAddForMeshesPtr, k_BatchSize);
renderersToAddForMeshes.Length = 0;
for (int index = 0; index < count; index++) for (int index = 0; index < count; index++)
{ {
@ -976,6 +1000,17 @@ namespace UnityEngine.Rendering
if (sortedExcludeRendererIDs.BinarySearch(rendererID) >= 0) if (sortedExcludeRendererIDs.BinarySearch(rendererID) >= 0)
continue; continue;
{
var meshID = meshIDArray[rendererIndex];
if (meshIDs.Contains(meshID))
{
renderersToAddForMeshes.AddNoResize(rendererID);
// We can skip the material check if we found a mesh match since at this point
// the renderer is already added and will be processed by the mesh branch
continue;
}
}
{
var rendererMaterials = materialIDArrays[rendererIndex]; var rendererMaterials = materialIDArrays[rendererIndex];
for (int materialIndex = 0; materialIndex < rendererMaterials.Length; materialIndex++) for (int materialIndex = 0; materialIndex < rendererMaterials.Length; materialIndex++)
@ -983,13 +1018,15 @@ namespace UnityEngine.Rendering
var materialID = rendererMaterials[materialIndex]; var materialID = rendererMaterials[materialIndex];
if (materialIDs.Contains(materialID)) if (materialIDs.Contains(materialID))
{ {
renderersToAdd.AddNoResize(rendererID);
renderersToAddForMaterials.AddNoResize(rendererID);
break; break;
} }
} }
} }
}
selectedRenderGroups.AddRangeNoResize(renderersToAddPtr, renderersToAdd.Length);
selectedRenderGroupsForMaterials.AddRangeNoResize(renderersToAddForMaterialsPtr, renderersToAddForMaterials.Length);
selectedRenderGroupsForMeshes.AddRangeNoResize(renderersToAddForMeshesPtr, renderersToAddForMeshes.Length);
} }
} }

123
Packages/com.unity.render-pipelines.core/Runtime/GPUDriven/InstanceCullingBatcher.cs

@ -8,11 +8,6 @@ using Unity.Collections.LowLevel.Unsafe;
using Unity.Burst; using Unity.Burst;
using UnityEngine.Profiling; using UnityEngine.Profiling;
[assembly: RegisterGenericJobType(typeof(UnityEngine.Rendering.RegisterNewInstancesJob<UnityEngine.Rendering.BatchMeshID>))]
[assembly: RegisterGenericJobType(typeof(UnityEngine.Rendering.RegisterNewInstancesJob<UnityEngine.Rendering.BatchMaterialID>))]
[assembly: RegisterGenericJobType(typeof(UnityEngine.Rendering.FindNonRegisteredInstancesJob<UnityEngine.Rendering.BatchMeshID>))]
[assembly: RegisterGenericJobType(typeof(UnityEngine.Rendering.FindNonRegisteredInstancesJob<UnityEngine.Rendering.BatchMaterialID>))]
namespace UnityEngine.Rendering namespace UnityEngine.Rendering
{ {
internal delegate void OnCullingCompleteCallback(JobHandle jobHandle, in BatchCullingContext cullingContext, in BatchCullingOutput cullingOutput); internal delegate void OnCullingCompleteCallback(JobHandle jobHandle, in BatchCullingContext cullingContext, in BatchCullingOutput cullingOutput);
@ -191,48 +186,109 @@ namespace UnityEngine.Rendering
} }
[BurstCompile(DisableSafetyChecks = true, OptimizeFor = OptimizeFor.Performance)] [BurstCompile(DisableSafetyChecks = true, OptimizeFor = OptimizeFor.Performance)]
internal struct FindNonRegisteredInstancesJob<T> : IJobParallelForBatch where T : unmanaged
internal struct FindNonRegisteredMeshesJob : IJobParallelForBatch
{ {
public const int k_BatchSize = 128; public const int k_BatchSize = 128;
[ReadOnly] public NativeArray<int> instanceIDs; [ReadOnly] public NativeArray<int> instanceIDs;
[ReadOnly] public NativeParallelHashMap<int, T> hashMap;
[ReadOnly] public NativeParallelHashMap<int, BatchMeshID> hashMap;
[WriteOnly] public NativeList<int>.ParallelWriter outInstancesWriter; [WriteOnly] public NativeList<int>.ParallelWriter outInstancesWriter;
public unsafe void Execute(int startIndex, int count) public unsafe void Execute(int startIndex, int count)
{ {
int* notFoundinstanceIDs = stackalloc int[k_BatchSize];
int length = 0;
int* notFoundinstanceIDsPtr = stackalloc int[k_BatchSize];
var notFoundinstanceIDs = new UnsafeList<int>(notFoundinstanceIDsPtr, k_BatchSize);
notFoundinstanceIDs.Length = 0;
for (int i = startIndex; i < startIndex + count; ++i) for (int i = startIndex; i < startIndex + count; ++i)
{ {
int instanceID = instanceIDs[i]; int instanceID = instanceIDs[i];
if (!hashMap.ContainsKey(instanceID)) if (!hashMap.ContainsKey(instanceID))
notFoundinstanceIDs[length++] = instanceID;
notFoundinstanceIDs.AddNoResize(instanceID);
} }
outInstancesWriter.AddRangeNoResize(notFoundinstanceIDs, length);
outInstancesWriter.AddRangeNoResize(notFoundinstanceIDsPtr, notFoundinstanceIDs.Length);
} }
} }
[BurstCompile(DisableSafetyChecks = true, OptimizeFor = OptimizeFor.Performance)] [BurstCompile(DisableSafetyChecks = true, OptimizeFor = OptimizeFor.Performance)]
internal struct RegisterNewInstancesJob<T> : IJobParallelFor where T : unmanaged
internal struct FindNonRegisteredMaterialsJob : IJobParallelForBatch
{ {
public const int k_BatchSize = 128; public const int k_BatchSize = 128;
[ReadOnly] public NativeArray<int> instanceIDs; [ReadOnly] public NativeArray<int> instanceIDs;
[ReadOnly] public NativeArray<T> batchIDs;
[ReadOnly] public NativeArray<GPUDrivenPackedMaterialData> packedMaterialDatas;
[ReadOnly] public NativeParallelHashMap<int, BatchMaterialID> hashMap;
[WriteOnly] public NativeParallelHashMap<int, T>.ParallelWriter hashMap;
[WriteOnly] public NativeList<int>.ParallelWriter outInstancesWriter;
[WriteOnly] public NativeList<GPUDrivenPackedMaterialData>.ParallelWriter outPackedMaterialDatasWriter;
public unsafe void Execute(int index)
public unsafe void Execute(int startIndex, int count)
{
int* notFoundinstanceIDsPtr = stackalloc int[k_BatchSize];
var notFoundinstanceIDs = new UnsafeList<int>(notFoundinstanceIDsPtr, k_BatchSize);
GPUDrivenPackedMaterialData* notFoundPackedMaterialDatasPtr = stackalloc GPUDrivenPackedMaterialData[k_BatchSize];
var notFoundPackedMaterialDatas = new UnsafeList<GPUDrivenPackedMaterialData>(notFoundPackedMaterialDatasPtr, k_BatchSize);
notFoundinstanceIDs.Length = 0;
notFoundPackedMaterialDatas.Length = 0;
for (int i = startIndex; i < startIndex + count; ++i)
{
int instanceID = instanceIDs[i];
if (!hashMap.ContainsKey(instanceID))
{
notFoundinstanceIDs.AddNoResize(instanceID);
notFoundPackedMaterialDatas.AddNoResize(packedMaterialDatas[i]);
}
}
outInstancesWriter.AddRangeNoResize(notFoundinstanceIDsPtr, notFoundinstanceIDs.Length);
outPackedMaterialDatasWriter.AddRangeNoResize(notFoundPackedMaterialDatasPtr, notFoundPackedMaterialDatas.Length);
}
}
[BurstCompile(DisableSafetyChecks = true, OptimizeFor = OptimizeFor.Performance)]
internal struct RegisterNewMeshesJob : IJobParallelFor
{
public const int k_BatchSize = 128;
[ReadOnly] public NativeArray<int> instanceIDs;
[ReadOnly] public NativeArray<BatchMeshID> batchIDs;
[WriteOnly] public NativeParallelHashMap<int, BatchMeshID>.ParallelWriter hashMap;
public void Execute(int index)
{ {
hashMap.TryAdd(instanceIDs[index], batchIDs[index]); hashMap.TryAdd(instanceIDs[index], batchIDs[index]);
} }
} }
[BurstCompile(DisableSafetyChecks = true, OptimizeFor = OptimizeFor.Performance)]
internal struct RegisterNewMaterialsJob : IJobParallelFor
{
public const int k_BatchSize = 128;
[ReadOnly] public NativeArray<int> instanceIDs;
[ReadOnly] public NativeArray<GPUDrivenPackedMaterialData> packedMaterialDatas;
[ReadOnly] public NativeArray<BatchMaterialID> batchIDs;
[WriteOnly] public NativeParallelHashMap<int, BatchMaterialID>.ParallelWriter batchMaterialHashMap;
[WriteOnly] public NativeParallelHashMap<int, GPUDrivenPackedMaterialData>.ParallelWriter packedMaterialHashMap;
public void Execute(int index)
{
var instanceID = instanceIDs[index];
batchMaterialHashMap.TryAdd(instanceID, batchIDs[index]);
packedMaterialHashMap.TryAdd(instanceID, packedMaterialDatas[index]);
}
}
[BurstCompile(DisableSafetyChecks = true, OptimizeFor = OptimizeFor.Performance)] [BurstCompile(DisableSafetyChecks = true, OptimizeFor = OptimizeFor.Performance)]
internal struct RemoveDrawInstanceIndicesJob : IJob internal struct RemoveDrawInstanceIndicesJob : IJob
{ {
@ -468,7 +524,7 @@ namespace UnityEngine.Rendering
{ {
var materialID = rendererData.materialID[materialIndex]; var materialID = rendererData.materialID[materialIndex];
bool isFound = packedMaterialDataHash.TryGetValue(materialID, out packedMaterialData); bool isFound = packedMaterialDataHash.TryGetValue(materialID, out packedMaterialData);
Assert.IsTrue(isFound);
Assert.IsTrue(isFound, "Packed material data not found.");
} }
supportsIndirect &= packedMaterialData.isIndirectSupported; supportsIndirect &= packedMaterialData.isIndirectSupported;
@ -1011,41 +1067,45 @@ namespace UnityEngine.Rendering
private void RegisterBatchMeshes(NativeArray<int> meshIDs) private void RegisterBatchMeshes(NativeArray<int> meshIDs)
{ {
var newMeshIDs = new NativeList<int>(meshIDs.Length, Allocator.TempJob); var newMeshIDs = new NativeList<int>(meshIDs.Length, Allocator.TempJob);
new FindNonRegisteredInstancesJob<BatchMeshID>
new FindNonRegisteredMeshesJob
{ {
instanceIDs = meshIDs, instanceIDs = meshIDs,
hashMap = m_BatchMeshHash, hashMap = m_BatchMeshHash,
outInstancesWriter = newMeshIDs.AsParallelWriter() outInstancesWriter = newMeshIDs.AsParallelWriter()
} }
.ScheduleBatch(meshIDs.Length, FindNonRegisteredInstancesJob<BatchMeshID>.k_BatchSize).Complete();
.ScheduleBatch(meshIDs.Length, FindNonRegisteredMeshesJob.k_BatchSize).Complete();
var newBatchMeshIDs = new NativeArray<BatchMeshID>(newMeshIDs.Length, Allocator.TempJob, NativeArrayOptions.UninitializedMemory); var newBatchMeshIDs = new NativeArray<BatchMeshID>(newMeshIDs.Length, Allocator.TempJob, NativeArrayOptions.UninitializedMemory);
m_BRG.RegisterMeshes(newMeshIDs.AsArray(), newBatchMeshIDs); m_BRG.RegisterMeshes(newMeshIDs.AsArray(), newBatchMeshIDs);
int totalMeshesNum = m_BatchMeshHash.Count() + newBatchMeshIDs.Length; int totalMeshesNum = m_BatchMeshHash.Count() + newBatchMeshIDs.Length;
m_BatchMeshHash.Capacity = Math.Max(m_BatchMeshHash.Capacity, Mathf.CeilToInt(totalMeshesNum / 1023.0f) * 1024); m_BatchMeshHash.Capacity = Math.Max(m_BatchMeshHash.Capacity, Mathf.CeilToInt(totalMeshesNum / 1023.0f) * 1024);
new RegisterNewInstancesJob<BatchMeshID>
new RegisterNewMeshesJob
{ {
instanceIDs = newMeshIDs.AsArray(), instanceIDs = newMeshIDs.AsArray(),
batchIDs = newBatchMeshIDs, batchIDs = newBatchMeshIDs,
hashMap = m_BatchMeshHash.AsParallelWriter() hashMap = m_BatchMeshHash.AsParallelWriter()
} }
.Schedule(newMeshIDs.Length, RegisterNewInstancesJob<BatchMeshID>.k_BatchSize).Complete();
.Schedule(newMeshIDs.Length, RegisterNewMeshesJob.k_BatchSize).Complete();
newMeshIDs.Dispose(); newMeshIDs.Dispose();
newBatchMeshIDs.Dispose(); newBatchMeshIDs.Dispose();
} }
private void RegisterBatchMaterials(in NativeArray<int> usedMaterialIDs)
private void RegisterBatchMaterials(in NativeArray<int> usedMaterialIDs, in NativeArray<GPUDrivenPackedMaterialData> usedPackedMaterialDatas)
{ {
Debug.Assert(usedMaterialIDs.Length == usedPackedMaterialDatas.Length, "Each material ID should correspond to one packed material data.");
var newMaterialIDs = new NativeList<int>(usedMaterialIDs.Length, Allocator.TempJob); var newMaterialIDs = new NativeList<int>(usedMaterialIDs.Length, Allocator.TempJob);
new FindNonRegisteredInstancesJob<BatchMaterialID>
var newPackedMaterialDatas = new NativeList<GPUDrivenPackedMaterialData>(usedMaterialIDs.Length, Allocator.TempJob);
new FindNonRegisteredMaterialsJob
{ {
instanceIDs = usedMaterialIDs, instanceIDs = usedMaterialIDs,
packedMaterialDatas = usedPackedMaterialDatas,
hashMap = m_BatchMaterialHash, hashMap = m_BatchMaterialHash,
outInstancesWriter = newMaterialIDs.AsParallelWriter()
outInstancesWriter = newMaterialIDs.AsParallelWriter(),
outPackedMaterialDatasWriter = newPackedMaterialDatas.AsParallelWriter()
} }
.ScheduleBatch(usedMaterialIDs.Length, FindNonRegisteredInstancesJob<BatchMaterialID>.k_BatchSize).Complete();
.ScheduleBatch(usedMaterialIDs.Length, FindNonRegisteredMaterialsJob.k_BatchSize).Complete();
var newBatchMaterialIDs = new NativeArray<BatchMaterialID>(newMaterialIDs.Length, Allocator.TempJob, NativeArrayOptions.UninitializedMemory); var newBatchMaterialIDs = new NativeArray<BatchMaterialID>(newMaterialIDs.Length, Allocator.TempJob, NativeArrayOptions.UninitializedMemory);
m_BRG.RegisterMaterials(newMaterialIDs.AsArray(), newBatchMaterialIDs); m_BRG.RegisterMaterials(newMaterialIDs.AsArray(), newBatchMaterialIDs);
@ -1054,15 +1114,18 @@ namespace UnityEngine.Rendering
m_BatchMaterialHash.Capacity = Math.Max(m_BatchMaterialHash.Capacity, Mathf.CeilToInt(totalMaterialsNum / 1023.0f) * 1024); m_BatchMaterialHash.Capacity = Math.Max(m_BatchMaterialHash.Capacity, Mathf.CeilToInt(totalMaterialsNum / 1023.0f) * 1024);
m_PackedMaterialHash.Capacity = m_BatchMaterialHash.Capacity; m_PackedMaterialHash.Capacity = m_BatchMaterialHash.Capacity;
new RegisterNewInstancesJob<BatchMaterialID>
new RegisterNewMaterialsJob
{ {
instanceIDs = newMaterialIDs.AsArray(), instanceIDs = newMaterialIDs.AsArray(),
packedMaterialDatas = newPackedMaterialDatas.AsArray(),
batchIDs = newBatchMaterialIDs, batchIDs = newBatchMaterialIDs,
hashMap = m_BatchMaterialHash.AsParallelWriter()
batchMaterialHashMap = m_BatchMaterialHash.AsParallelWriter(),
packedMaterialHashMap = m_PackedMaterialHash.AsParallelWriter()
} }
.Schedule(newMaterialIDs.Length, RegisterNewInstancesJob<BatchMaterialID>.k_BatchSize).Complete();
.Schedule(newMaterialIDs.Length, RegisterNewMaterialsJob.k_BatchSize).Complete();
newMaterialIDs.Dispose(); newMaterialIDs.Dispose();
newPackedMaterialDatas.Dispose();
newBatchMaterialIDs.Dispose(); newBatchMaterialIDs.Dispose();
} }
@ -1078,15 +1141,13 @@ namespace UnityEngine.Rendering
public void BuildBatch( public void BuildBatch(
NativeArray<InstanceHandle> instances, NativeArray<InstanceHandle> instances,
NativeArray<int> usedMaterialIDs,
NativeArray<int> usedMeshIDs,
in GPUDrivenRendererGroupData rendererData, in GPUDrivenRendererGroupData rendererData,
bool registerMaterialsAndMeshes) bool registerMaterialsAndMeshes)
{ {
if (registerMaterialsAndMeshes) if (registerMaterialsAndMeshes)
{ {
RegisterBatchMaterials(usedMaterialIDs);
RegisterBatchMeshes(usedMeshIDs);
RegisterBatchMaterials(rendererData.materialID, rendererData.packedMaterialData);
RegisterBatchMeshes(rendererData.meshID);
} }
new CreateDrawBatchesJob new CreateDrawBatchesJob

1
Packages/com.unity.render-pipelines.core/Runtime/Lighting/ProbeVolume/ProbeBrickPool.cs

@ -281,6 +281,7 @@ namespace UnityEngine.Rendering
if (!ignoreErrorLog) if (!ignoreErrorLog)
Debug.LogError("Cannot allocate more brick chunks, probe volume brick pool is full."); Debug.LogError("Cannot allocate more brick chunks, probe volume brick pool is full.");
Deallocate(outAllocations);
outAllocations.Clear(); outAllocations.Clear();
return false; // failure case, pool is full return false; // failure case, pool is full
} }

5
Packages/com.unity.render-pipelines.core/Runtime/Lighting/ProbeVolume/ProbeReferenceVolume.cs

@ -1078,6 +1078,11 @@ namespace UnityEngine.Rendering
m_VertexSampling = value; m_VertexSampling = value;
} }
internal void ForceMemoryBudget(ProbeVolumeTextureMemoryBudget budget)
{
m_MemoryBudget = budget;
}
// This is used for steps such as dilation that require the maximum order allowed to be loaded at all times. Should really never be used as a general purpose function. // This is used for steps such as dilation that require the maximum order allowed to be loaded at all times. Should really never be used as a general purpose function.
internal void ForceSHBand(ProbeVolumeSHBands shBands) internal void ForceSHBand(ProbeVolumeSHBands shBands)
{ {

3
Packages/com.unity.render-pipelines.core/Runtime/RenderGraph/Compiler/NativePassCompiler.Debug.cs

@ -99,6 +99,9 @@ namespace UnityEngine.Rendering.RenderGraphModule.NativeRenderPassCompiler
case PassBreakReason.DifferentShadingRateStates: case PassBreakReason.DifferentShadingRateStates:
message += $"{prevPassName} uses different shading rate states than {passName}."; message += $"{prevPassName} uses different shading rate states than {passName}.";
break; break;
case PassBreakReason.PassMergingDisabled:
message += "The pass merging is disabled.";
break;
default: default:
throw new ArgumentOutOfRangeException(); throw new ArgumentOutOfRangeException();
} }

36
Packages/com.unity.render-pipelines.core/Runtime/Utilities/Blitter.cs

@ -712,6 +712,42 @@ namespace UnityEngine.Rendering
BlitTexture(cmd.m_WrappedCommandBuffer, source, scaleBias, material, pass); BlitTexture(cmd.m_WrappedCommandBuffer, source, scaleBias, material, pass);
} }
/// <summary>
/// Adds in a <see cref="UnsafeCommandBuffer"/> a command to copy a texture identified by its <see cref="RTHandle"/> into
/// the currently bound render target's color buffer, using a user material and specific shader pass.
/// </summary>
/// <remarks>
/// The <c>source</c> texture will be bound to the "_BlitTexture" shader property.
/// The <c>scaleBias</c> parameter controls the rectangle of pixels in the source texture to copy by manipulating
/// the source texture coordinates. The X and Y coordinates store the scaling factor to apply to these texture
/// coordinates, while the Z and W coordinates store the texture coordinate offsets. The operation will always
/// write to the full destination render target rectangle.
/// </remarks>
/// <param name="cmd">Command Buffer used for recording the action.</param>
/// <param name="source">RTHandle of the source texture to copy from.</param>
/// <param name="scaleBias">Scale and bias for sampling the source texture.</param>
/// <param name="material">The material to use for writing to the destination target.</param>
/// <param name="pass">The index of the pass to use in the material's shader.</param>
/// <example>
/// <code lang="cs"><![CDATA[
/// // Copy the bottom left quadrant of the source texture to the render target using the first
/// // pass of a custom material, scaling to the destination render target's full rectangle.
/// // Configure the scale value to 0.5 because a quadrant has half the width and half the
/// // height of the texture, and the bias to 0 because the texture coordinate origin is at
/// // the bottom left.
/// Blitter.BlitTexture(cmd, source, new Vector4(0.5, 0.5, 0, 0), blitMaterial, 0);
///
/// // Copy the top half of the source texture mip level 4 to the render target using the
/// // second pass of a custom material, scaling to the destination render target's full
/// // rectangle.
/// Blitter.BlitTexture(cmd, source, new Vector4(1, 0.5, 0, 0.5), blitMaterial, 1);
/// ]]></code>
/// </example>
public static void BlitTexture(UnsafeCommandBuffer cmd, RTHandle source, Vector4 scaleBias, Material material, int pass)
{
BlitTexture(cmd.m_WrappedCommandBuffer, source, scaleBias, material, pass);
}
/// <summary> /// <summary>
/// Adds in a <see cref="CommandBuffer"/> a command to copy a texture identified by its <see cref="RTHandle"/> into /// Adds in a <see cref="CommandBuffer"/> a command to copy a texture identified by its <see cref="RTHandle"/> into
/// the currently bound render target's color buffer, using a user material and specific shader pass. /// the currently bound render target's color buffer, using a user material and specific shader pass.

26
Packages/com.unity.render-pipelines.core/Tests/Editor/FixedBufferStringQueueTests.cs

@ -36,6 +36,31 @@ namespace UnityEngine.Rendering.Tests
Assert.False(buffer.TryPush("amet, consectetur adipiscing")); Assert.False(buffer.TryPush("amet, consectetur adipiscing"));
Assert.AreEqual(1, buffer.Count); Assert.AreEqual(1, buffer.Count);
Assert.True(buffer.TryPop(out string v) && v == "Lorem ipsum dolor sit");
Assert.False(buffer.TryPop(out v) && v == null);
}
[Test]
public void PushAndPopOutOfBufferRange_StringSizeNotDivisibleBy4()
{
// UUM-104687: Buffer is created with size of 32 bytes. The test fills the first 30 bytes with a string,
// so 2 bytes are left over in the buffer. After we pop the string out, we check that the next TryPop
// doesn't try to read out of bounds when trying to read the string length.
const int bufferLength = 32;
const int bytesToFill = bufferLength - 2;
const int bytesForString = bytesToFill - sizeof(int);
const int numCharacters = bytesForString / sizeof(char);
string testValue = new string('a', numCharacters);
byte* bufferStart = stackalloc byte[bufferLength];
CoreUnsafeUtils.FixedBufferStringQueue buffer = new CoreUnsafeUtils.FixedBufferStringQueue(bufferStart, bufferLength);
Assume.That(buffer.TryPush(testValue));
Assume.That(buffer.TryPop(out string v));
Assert.False(buffer.TryPop(out v));
} }
[Test] [Test]
@ -58,5 +83,6 @@ namespace UnityEngine.Rendering.Tests
Assert.True(buffer.TryPop(out string v) && v == "elit, sed do eiusmod"); Assert.True(buffer.TryPop(out string v) && v == "elit, sed do eiusmod");
Assert.True(buffer.TryPop(out v) && v == "tempor incididunt ut labore"); Assert.True(buffer.TryPop(out v) && v == "tempor incididunt ut labore");
} }
} }
} }

42
Packages/com.unity.render-pipelines.core/Tests/Editor/GPUDriven/GPUDrivenRenderingTests.cs

@ -189,10 +189,11 @@ namespace UnityEngine.Rendering.Tests
var callbackCounter = new BoxedCounter(); var callbackCounter = new BoxedCounter();
cpuDrivenDesc.onCompleteCallback = (JobHandle jobHandle, in BatchCullingContext cc, in BatchCullingOutput cullingOutput) => cpuDrivenDesc.onCompleteCallback = (JobHandle jobHandle, in BatchCullingContext cc, in BatchCullingOutput cullingOutput) =>
{ {
jobHandle.Complete();
if (cc.viewType != BatchCullingViewType.Camera) if (cc.viewType != BatchCullingViewType.Camera)
return; return;
jobHandle.Complete();
BatchCullingOutputDrawCommands drawCommands = cullingOutput.drawCommands[0]; BatchCullingOutputDrawCommands drawCommands = cullingOutput.drawCommands[0];
var materials = new NativeParallelHashSet<BatchMaterialID>(10, Allocator.Temp); var materials = new NativeParallelHashSet<BatchMaterialID>(10, Allocator.Temp);
@ -221,6 +222,8 @@ namespace UnityEngine.Rendering.Tests
using (var brg = new GPUResidentBatcher(brgContext, cpuDrivenDesc, gpuDrivenProcessor)) using (var brg = new GPUResidentBatcher(brgContext, cpuDrivenDesc, gpuDrivenProcessor))
{ {
brg.OnBeginContextRendering();
brg.UpdateRenderers(objIDs.AsArray()); brg.UpdateRenderers(objIDs.AsArray());
var cameraObject = new GameObject("myCamera"); var cameraObject = new GameObject("myCamera");
@ -228,6 +231,8 @@ namespace UnityEngine.Rendering.Tests
SubmitCameraRenderRequest(mainCamera); SubmitCameraRenderRequest(mainCamera);
brg.OnEndContextRendering();
Assert.AreEqual(1, callbackCounter.Value); Assert.AreEqual(1, callbackCounter.Value);
mainCamera = null; mainCamera = null;
@ -268,16 +273,19 @@ namespace UnityEngine.Rendering.Tests
cpuDrivenDesc.onCompleteCallback = (JobHandle jobHandle, in BatchCullingContext cc, in BatchCullingOutput cullingOutput) => cpuDrivenDesc.onCompleteCallback = (JobHandle jobHandle, in BatchCullingContext cc, in BatchCullingOutput cullingOutput) =>
{ {
jobHandle.Complete();
if (cc.viewType != BatchCullingViewType.Camera) if (cc.viewType != BatchCullingViewType.Camera)
return; return;
jobHandle.Complete();
BatchCullingOutputDrawCommands drawCommands = cullingOutput.drawCommands[0]; BatchCullingOutputDrawCommands drawCommands = cullingOutput.drawCommands[0];
callbackCounter.Value = drawCommands.visibleInstanceCount; callbackCounter.Value = drawCommands.visibleInstanceCount;
}; };
using (var brg = new GPUResidentBatcher(brgContext, cpuDrivenDesc, gpuDrivenProcessor)) using (var brg = new GPUResidentBatcher(brgContext, cpuDrivenDesc, gpuDrivenProcessor))
{ {
brg.OnBeginContextRendering();
brg.UpdateRenderers(objIDs); brg.UpdateRenderers(objIDs);
var cameraObject = new GameObject("SceneViewCamera"); var cameraObject = new GameObject("SceneViewCamera");
@ -298,6 +306,8 @@ namespace UnityEngine.Rendering.Tests
brg.OnEndCameraRendering(mainCamera); brg.OnEndCameraRendering(mainCamera);
Assert.AreEqual(callbackCounter.Value, 1); Assert.AreEqual(callbackCounter.Value, 1);
brg.OnEndContextRendering();
GameObject.DestroyImmediate(cameraObject); GameObject.DestroyImmediate(cameraObject);
brgContext.ScheduleQueryRendererGroupInstancesJob(objIDs, instances).Complete(); brgContext.ScheduleQueryRendererGroupInstancesJob(objIDs, instances).Complete();
brg.DestroyDrawInstances(instances); brg.DestroyDrawInstances(instances);
@ -346,10 +356,11 @@ namespace UnityEngine.Rendering.Tests
var cpuDrivenDesc = InstanceCullingBatcherDesc.NewDefault(); var cpuDrivenDesc = InstanceCullingBatcherDesc.NewDefault();
cpuDrivenDesc.onCompleteCallback = (JobHandle jobHandle, in BatchCullingContext cc, in BatchCullingOutput cullingOutput) => cpuDrivenDesc.onCompleteCallback = (JobHandle jobHandle, in BatchCullingContext cc, in BatchCullingOutput cullingOutput) =>
{ {
jobHandle.Complete();
if (cc.viewType != BatchCullingViewType.Camera) if (cc.viewType != BatchCullingViewType.Camera)
return; return;
jobHandle.Complete();
BatchCullingOutputDrawCommands drawCommands = cullingOutput.drawCommands[0]; BatchCullingOutputDrawCommands drawCommands = cullingOutput.drawCommands[0];
var drawCommandCount = 0U; var drawCommandCount = 0U;
@ -370,6 +381,8 @@ namespace UnityEngine.Rendering.Tests
using (var brg = new GPUResidentBatcher(brgContext, cpuDrivenDesc, gpuDrivenProcessor)) using (var brg = new GPUResidentBatcher(brgContext, cpuDrivenDesc, gpuDrivenProcessor))
{ {
brg.OnBeginContextRendering();
brg.UpdateRenderers(objIDs.AsArray()); brg.UpdateRenderers(objIDs.AsArray());
var cameraObject = new GameObject("myCamera"); var cameraObject = new GameObject("myCamera");
@ -377,6 +390,8 @@ namespace UnityEngine.Rendering.Tests
SubmitCameraRenderRequest(mainCamera); SubmitCameraRenderRequest(mainCamera);
brg.OnEndContextRendering();
mainCamera = null; mainCamera = null;
GameObject.DestroyImmediate(cameraObject); GameObject.DestroyImmediate(cameraObject);
@ -458,10 +473,11 @@ namespace UnityEngine.Rendering.Tests
var expectedDrawCommandCount = 2; var expectedDrawCommandCount = 2;
cpuDrivenDesc.onCompleteCallback = (JobHandle jobHandle, in BatchCullingContext cc, in BatchCullingOutput cullingOutput) => cpuDrivenDesc.onCompleteCallback = (JobHandle jobHandle, in BatchCullingContext cc, in BatchCullingOutput cullingOutput) =>
{ {
jobHandle.Complete();
if (cc.viewType != BatchCullingViewType.Camera) if (cc.viewType != BatchCullingViewType.Camera)
return; return;
jobHandle.Complete();
BatchCullingOutputDrawCommands drawCommands = cullingOutput.drawCommands[0]; BatchCullingOutputDrawCommands drawCommands = cullingOutput.drawCommands[0];
var drawCommandCount = 0U; var drawCommandCount = 0U;
@ -482,6 +498,8 @@ namespace UnityEngine.Rendering.Tests
using (var brg = new GPUResidentBatcher(brgContext, cpuDrivenDesc, gpuDrivenProcessor)) using (var brg = new GPUResidentBatcher(brgContext, cpuDrivenDesc, gpuDrivenProcessor))
{ {
brg.OnBeginContextRendering();
brgContext.UpdateLODGroups(lodGroupInstancesID.AsArray()); brgContext.UpdateLODGroups(lodGroupInstancesID.AsArray());
brg.UpdateRenderers(objIDs.AsArray()); brg.UpdateRenderers(objIDs.AsArray());
@ -526,6 +544,8 @@ namespace UnityEngine.Rendering.Tests
expectedDrawCommandCount = 1; expectedDrawCommandCount = 1;
SubmitCameraRenderRequest(mainCamera); SubmitCameraRenderRequest(mainCamera);
brg.OnEndContextRendering();
Assert.AreEqual(7, callbackCounter.Value); Assert.AreEqual(7, callbackCounter.Value);
mainCamera = null; mainCamera = null;
@ -611,10 +631,11 @@ namespace UnityEngine.Rendering.Tests
var expectedDrawCommandCount = 0; var expectedDrawCommandCount = 0;
cpuDrivenDesc.onCompleteCallback = (JobHandle jobHandle, in BatchCullingContext cc, in BatchCullingOutput cullingOutput) => cpuDrivenDesc.onCompleteCallback = (JobHandle jobHandle, in BatchCullingContext cc, in BatchCullingOutput cullingOutput) =>
{ {
jobHandle.Complete();
if (cc.viewType != BatchCullingViewType.Camera) if (cc.viewType != BatchCullingViewType.Camera)
return; return;
jobHandle.Complete();
BatchCullingOutputDrawCommands drawCommands = cullingOutput.drawCommands[0]; BatchCullingOutputDrawCommands drawCommands = cullingOutput.drawCommands[0];
unsafe unsafe
@ -633,6 +654,8 @@ namespace UnityEngine.Rendering.Tests
using (var brg = new GPUResidentBatcher(brgContext, cpuDrivenDesc, gpuDrivenProcessor)) using (var brg = new GPUResidentBatcher(brgContext, cpuDrivenDesc, gpuDrivenProcessor))
{ {
brg.OnBeginContextRendering();
brgContext.UpdateLODGroups(lodGroupInstancesID.AsArray()); brgContext.UpdateLODGroups(lodGroupInstancesID.AsArray());
brg.UpdateRenderers(objIDs.AsArray()); brg.UpdateRenderers(objIDs.AsArray());
@ -684,6 +707,8 @@ namespace UnityEngine.Rendering.Tests
cameraObject.transform.position = new Vector3(0.0f, 0.0f, -4.0f); cameraObject.transform.position = new Vector3(0.0f, 0.0f, -4.0f);
SubmitCameraRenderRequest(mainCamera); SubmitCameraRenderRequest(mainCamera);
brg.OnEndContextRendering();
mainCamera = null; mainCamera = null;
GameObject.DestroyImmediate(cameraObject); GameObject.DestroyImmediate(cameraObject);
@ -744,10 +769,11 @@ namespace UnityEngine.Rendering.Tests
var expectedDrawCommandCount = 0; var expectedDrawCommandCount = 0;
cpuDrivenDesc.onCompleteCallback = (JobHandle jobHandle, in BatchCullingContext cc, in BatchCullingOutput cullingOutput) => cpuDrivenDesc.onCompleteCallback = (JobHandle jobHandle, in BatchCullingContext cc, in BatchCullingOutput cullingOutput) =>
{ {
jobHandle.Complete();
if (cc.viewType != BatchCullingViewType.Camera) if (cc.viewType != BatchCullingViewType.Camera)
return; return;
jobHandle.Complete();
BatchCullingOutputDrawCommands drawCommands = cullingOutput.drawCommands[0]; BatchCullingOutputDrawCommands drawCommands = cullingOutput.drawCommands[0];
unsafe unsafe
@ -766,6 +792,8 @@ namespace UnityEngine.Rendering.Tests
using (var brg = new GPUResidentBatcher(brgContext, cpuDrivenDesc, gpuDrivenProcessor)) using (var brg = new GPUResidentBatcher(brgContext, cpuDrivenDesc, gpuDrivenProcessor))
{ {
brg.OnBeginContextRendering();
brg.UpdateRenderers(objIDs.AsArray()); brg.UpdateRenderers(objIDs.AsArray());
var cameraObject = new GameObject("myCamera"); var cameraObject = new GameObject("myCamera");
@ -801,6 +829,8 @@ namespace UnityEngine.Rendering.Tests
cameraObject.transform.position = new Vector3(0.0f, 0.0f, -10.0f); cameraObject.transform.position = new Vector3(0.0f, 0.0f, -10.0f);
SubmitCameraRenderRequest(mainCamera); SubmitCameraRenderRequest(mainCamera);
brg.OnEndContextRendering();
mainCamera = null; mainCamera = null;
GameObject.DestroyImmediate(cameraObject); GameObject.DestroyImmediate(cameraObject);

2
Packages/com.unity.render-pipelines.core/package.json

@ -14,5 +14,5 @@
"com.unity.modules.jsonserialize": "1.0.0", "com.unity.modules.jsonserialize": "1.0.0",
"com.unity.rendering.light-transport": "1.0.1" "com.unity.rendering.light-transport": "1.0.1"
}, },
"_fingerprint": "79d3abb9adf1668400072f165c52ac7c03b1bca9"
"_fingerprint": "71b4bdac1964f74b866160605ee9150cf79ab359"
} }

2
Packages/com.unity.render-pipelines.high-definition-config/package.json

@ -7,5 +7,5 @@
"dependencies": { "dependencies": {
"com.unity.render-pipelines.core": "17.1.0" "com.unity.render-pipelines.core": "17.1.0"
}, },
"_fingerprint": "df264f43ceeeb27fd645ba51a52555c620dd9154"
"_fingerprint": "8c699487ee0c5bb938902fb2e91075c921a1fb5f"
} }

2
Packages/com.unity.render-pipelines.high-definition/Editor/PropertyDrawers/HDRPDefaultVolumeProfileSettingsPropertyDrawer.cs

@ -92,7 +92,7 @@ namespace UnityEditor.Rendering.HighDefinition
return profileLine; return profileLine;
} }
public class HDRPDefaultVolumeProfileSettingsContextMenu : DefaultVolumeProfileSettingsContextMenu<HDRPDefaultVolumeProfileSettings, HDRenderPipeline>
public class HDRPDefaultVolumeProfileSettingsContextMenu : DefaultVolumeProfileSettingsContextMenu2<HDRPDefaultVolumeProfileSettings, HDRenderPipeline>
{ {
protected override string defaultVolumeProfilePath protected override string defaultVolumeProfilePath
{ {

4
Packages/com.unity.render-pipelines.high-definition/Editor/RenderPipeline/Camera/HDCameraUI.Rendering.Drawers.cs

@ -148,10 +148,6 @@ namespace UnityEditor.Rendering.HighDefinition
{ {
EditorGUI.indentLevel++; EditorGUI.indentLevel++;
EditorGUILayout.PropertyField(p.deepLearningSuperSamplingUseOptimalSettings, HDRenderPipelineUI.Styles.DLSSUseOptimalSettingsContent); EditorGUILayout.PropertyField(p.deepLearningSuperSamplingUseOptimalSettings, HDRenderPipelineUI.Styles.DLSSUseOptimalSettingsContent);
using (new EditorGUI.DisabledScope(p.deepLearningSuperSamplingUseOptimalSettings.boolValue))
{
EditorGUILayout.PropertyField(p.deepLearningSuperSamplingSharpening, HDRenderPipelineUI.Styles.DLSSSharpnessContent);
}
EditorGUI.indentLevel--; EditorGUI.indentLevel--;
} }
} }

17
Packages/com.unity.render-pipelines.high-definition/Editor/RenderPipeline/CustomPass/CustomPassDrawer.cs

@ -172,6 +172,16 @@ namespace UnityEditor.Rendering.HighDefinition
{ {
EditorGUI.PropertyField(rect, m_TargetDepthBuffer, Styles.targetDepthBuffer); EditorGUI.PropertyField(rect, m_TargetDepthBuffer, Styles.targetDepthBuffer);
rect.y += Styles.defaultLineSpace; rect.y += Styles.defaultLineSpace;
CustomPass.TargetBuffer requestedDepth = m_TargetDepthBuffer.GetEnumValue<CustomPass.TargetBuffer>();
if (m_CustomPass.getConstrainedDepthBuffer() != requestedDepth)
{
Rect helpBoxRect = rect;
float helpBoxHeight = EditorGUIUtility.singleLineHeight * 2;
helpBoxRect.height = helpBoxHeight;
EditorGUI.HelpBox(helpBoxRect, "Camera depth isn't supported when dynamic scaling is on. We will automatically fall back to not doing depth-testing for this pass.", MessageType.Warning);
rect.y += helpBoxHeight;
}
} }
if ((commonPassUIFlags & PassUIFlag.ClearFlags) != 0) if ((commonPassUIFlags & PassUIFlag.ClearFlags) != 0)
@ -264,6 +274,13 @@ namespace UnityEditor.Rendering.HighDefinition
} }
height += Styles.defaultLineSpace * lines; height += Styles.defaultLineSpace * lines;
// Add height for the help box if it will be shown
if ((commonPassUIFlags & PassUIFlag.TargetDepthBuffer) != 0 &&
m_CustomPass.getConstrainedDepthBuffer() != m_TargetDepthBuffer.GetEnumValue<CustomPass.TargetBuffer>())
{
height += EditorGUIUtility.singleLineHeight * 2; // Help box height
}
} }
return height + GetPassHeight(property); return height + GetPassHeight(property);

3
Packages/com.unity.render-pipelines.high-definition/Editor/RenderPipeline/HDRenderPipelineUI.Skin.cs

@ -277,7 +277,6 @@ namespace UnityEditor.Rendering.HighDefinition
public static readonly GUIContent TAAUInjectionPoint = EditorGUIUtility.TrTextContent("TAA Upscale Injection Point", "The injection point at which to apply the upscaling."); public static readonly GUIContent TAAUInjectionPoint = EditorGUIUtility.TrTextContent("TAA Upscale Injection Point", "The injection point at which to apply the upscaling.");
public static readonly GUIContent STPInjectionPoint = EditorGUIUtility.TrTextContent("STP Injection Point", "The injection point at which to apply the upscaling."); public static readonly GUIContent STPInjectionPoint = EditorGUIUtility.TrTextContent("STP Injection Point", "The injection point at which to apply the upscaling.");
public static readonly GUIContent DLSSUseOptimalSettingsContent = EditorGUIUtility.TrTextContent("DLSS Use Optimal Settings", "Sets the sharpness and scale automatically for NVIDIA Deep Learning Super Sampling, depending on the values of quality settings. When DLSS Optimal Settings is on, the percentage settings for Dynamic Resolution Scaling are ignored."); public static readonly GUIContent DLSSUseOptimalSettingsContent = EditorGUIUtility.TrTextContent("DLSS Use Optimal Settings", "Sets the sharpness and scale automatically for NVIDIA Deep Learning Super Sampling, depending on the values of quality settings. When DLSS Optimal Settings is on, the percentage settings for Dynamic Resolution Scaling are ignored.");
public static readonly GUIContent DLSSSharpnessContent = EditorGUIUtility.TrTextContent("DLSS Sharpness", "NVIDIA Deep Learning Super Sampling pixel sharpness of upsampler. Controls how the DLSS upsampler will render edges on the image. More sharpness usually means more contrast and clearer image but can increase flickering and fireflies. This setting is ignored if optimal settings are used.");
public static readonly GUIContent FSR2Title = EditorGUIUtility.TrTextContent("AMD FidelityFX Super Resolution 2.0 (FSR2)"); public static readonly GUIContent FSR2Title = EditorGUIUtility.TrTextContent("AMD FidelityFX Super Resolution 2.0 (FSR2)");
public static readonly GUIContent enableFSR2 = EditorGUIUtility.TrTextContent("Enable Fidelity FX 2.2", "Enables FidelityFX 2.0 Super Resolution (FSR2)."); public static readonly GUIContent enableFSR2 = EditorGUIUtility.TrTextContent("Enable Fidelity FX 2.2", "Enables FidelityFX 2.0 Super Resolution (FSR2).");
@ -314,7 +313,7 @@ namespace UnityEditor.Rendering.HighDefinition
public const string FSR2WinTargetWarning = "HDRP does not support AMD Fidelity FX2 for the current build target and graphics device API. To enable FSR2, set your build target to Windows x86_64 and DirectX12."; public const string FSR2WinTargetWarning = "HDRP does not support AMD Fidelity FX2 for the current build target and graphics device API. To enable FSR2, set your build target to Windows x86_64 and DirectX12.";
public const string FSR2SwitchTarget64Button = "Fix"; public const string FSR2SwitchTarget64Button = "Fix";
public const string FSR2FeatureDetectedMsg = "Unity detected AMD Fidelity FX 2 Super Resolution and will ignore the Fallback Upscale Filter."; public const string FSR2FeatureDetectedMsg = "Unity detected AMD Fidelity FX 2 Super Resolution and will ignore the Fallback Upscale Filter.";
public const string FSR2FeatureNotDetectedMsg = "Unity cannot detect Unity detected AMD Fidelity FX 2 Super Resolution and will use the Fallback Upscale Filter instead.";
public const string FSR2FeatureNotDetectedMsg = "Unity cannot detect AMD Fidelity FX 2 Super Resolution and will use the Fallback Upscale Filter instead.";
public const string STPSwDrsWarningMsg = "STP cannot support dynamic resolution without hardware dynamic resolution mode. You can use the forced screen percentage feature to guarantee a fixed resoution for STP or HDRP will fall back to the next best supported upscaling filter instead."; public const string STPSwDrsWarningMsg = "STP cannot support dynamic resolution without hardware dynamic resolution mode. You can use the forced screen percentage feature to guarantee a fixed resoution for STP or HDRP will fall back to the next best supported upscaling filter instead.";

4
Packages/com.unity.render-pipelines.high-definition/Editor/RenderPipeline/HDRenderPipelineUI.cs

@ -686,10 +686,6 @@ namespace UnityEditor.Rendering.HighDefinition
serialized.renderPipelineSettings.dynamicResolutionSettings.DLSSInjectionPoint.intValue = injectionPointVal; serialized.renderPipelineSettings.dynamicResolutionSettings.DLSSInjectionPoint.intValue = injectionPointVal;
EditorGUILayout.PropertyField(serialized.renderPipelineSettings.dynamicResolutionSettings.DLSSUseOptimalSettings, Styles.DLSSUseOptimalSettingsContent); EditorGUILayout.PropertyField(serialized.renderPipelineSettings.dynamicResolutionSettings.DLSSUseOptimalSettings, Styles.DLSSUseOptimalSettingsContent);
using (new EditorGUI.DisabledScope(serialized.renderPipelineSettings.dynamicResolutionSettings.DLSSUseOptimalSettings.boolValue))
{
EditorGUILayout.PropertyField(serialized.renderPipelineSettings.dynamicResolutionSettings.DLSSSharpness, Styles.DLSSSharpnessContent);
}
--EditorGUI.indentLevel; --EditorGUI.indentLevel;
} }

6
Packages/com.unity.render-pipelines.high-definition/Runtime/Lighting/Shadow/HDShadowAlgorithms.hlsl

@ -7,9 +7,15 @@
// For backward compatibility // For backward compatibility
#ifdef SHADOW_LOW #ifdef SHADOW_LOW
#ifndef PUNCTUAL_SHADOW_LOW
#define PUNCTUAL_SHADOW_LOW #define PUNCTUAL_SHADOW_LOW
#endif
#ifndef DIRECTIONAL_SHADOW_LOW
#define DIRECTIONAL_SHADOW_LOW #define DIRECTIONAL_SHADOW_LOW
#endif #endif
#endif
// For non-fragment shaders we might skip the variant with the quality as shadows might not be used, if that's the case define something just to make the compiler happy in case the quality is not defined. // For non-fragment shaders we might skip the variant with the quality as shadows might not be used, if that's the case define something just to make the compiler happy in case the quality is not defined.
#ifndef SHADER_STAGE_FRAGMENT #ifndef SHADER_STAGE_FRAGMENT

2
Packages/com.unity.render-pipelines.high-definition/Runtime/Material/Lit/Lit.shader

@ -1045,8 +1045,10 @@ Shader "HDRP/Lit"
#ifndef SHADER_STAGE_FRAGMENT #ifndef SHADER_STAGE_FRAGMENT
#define SHADOW_LOW #define SHADOW_LOW
#ifndef USE_FPTL_LIGHTLIST
#define USE_FPTL_LIGHTLIST #define USE_FPTL_LIGHTLIST
#endif #endif
#endif
#define SHADERPASS SHADERPASS_FORWARD #define SHADERPASS SHADERPASS_FORWARD
// In case of opaque we don't want to perform the alpha test, it is done in depth prepass and we use depth equal for ztest (setup from UI) // In case of opaque we don't want to perform the alpha test, it is done in depth prepass and we use depth equal for ztest (setup from UI)

7
Packages/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/HDRenderPipeline.PostProcess.cs

@ -922,13 +922,18 @@ namespace UnityEngine.Rendering.HighDefinition
passData.parameters.drsSettings = currentAsset.currentPlatformRenderPipelineSettings.dynamicResolutionSettings; passData.parameters.drsSettings = currentAsset.currentPlatformRenderPipelineSettings.dynamicResolutionSettings;
// Must check this with nvidia. After trying many things this gives the least amount of ghosting. // Must check this with nvidia. After trying many things this gives the least amount of ghosting.
// For now we clamp the exposure to a reasonable value. // For now we clamp the exposure to a reasonable value.
passData.parameters.preExposure = Mathf.Clamp(hdCamera.GpuExposureValue(), 0.35f, 2.0f);
passData.parameters.preExposure = Mathf.Clamp(hdCamera.GpuExposureValue(), 0.20f, 2.0f);
var viewHandles = new UpscalerResources.ViewResourceHandles(); var viewHandles = new UpscalerResources.ViewResourceHandles();
viewHandles.source = builder.ReadTexture(source); viewHandles.source = builder.ReadTexture(source);
viewHandles.output = builder.WriteTexture(GetPostprocessUpsampledOutputHandle(hdCamera, renderGraph, "DLSS destination")); viewHandles.output = builder.WriteTexture(GetPostprocessUpsampledOutputHandle(hdCamera, renderGraph, "DLSS destination"));
viewHandles.depth = builder.ReadTexture(depthBuffer); viewHandles.depth = builder.ReadTexture(depthBuffer);
viewHandles.motionVectors = builder.ReadTexture(motionVectors); viewHandles.motionVectors = builder.ReadTexture(motionVectors);
// Note: exposure texture input
// We skip providing exposureTexture since HDRP pre-applies exposure in GBuffer pass / light accumulation buffer,
// and doesn't use it later on in tonemapping. DLSS docs mention this texture is needed if used in tonemapping later on.
// Given we also provide an option to inject DLSS post-tonemapping, we can safely skip providing this input as
// it usually exacerbates ghosting within the HDRP use context.
if (biasColorMask.IsValid()) if (biasColorMask.IsValid())
viewHandles.biasColorMask = builder.ReadTexture(biasColorMask); viewHandles.biasColorMask = builder.ReadTexture(biasColorMask);

4
Packages/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/HDRenderPipeline.Prepass.cs

@ -28,6 +28,8 @@ namespace UnityEngine.Rendering.HighDefinition
const int m_MaxXRViewsCount = 4; const int m_MaxXRViewsCount = 4;
const int kIntelVendorId = 0x8086;
void InitializePrepass(HDRenderPipelineAsset hdAsset) void InitializePrepass(HDRenderPipelineAsset hdAsset)
{ {
m_MSAAResolveMaterial = CoreUtils.CreateEngineMaterial(runtimeShaders.depthValuesPS); m_MSAAResolveMaterial = CoreUtils.CreateEngineMaterial(runtimeShaders.depthValuesPS);
@ -1407,7 +1409,7 @@ namespace UnityEngine.Rendering.HighDefinition
{ {
// Integrated Intel GPU on Mac don't support the texture format use for normal (RGBA_8UNORM) for SetRandomWriteTarget // Integrated Intel GPU on Mac don't support the texture format use for normal (RGBA_8UNORM) for SetRandomWriteTarget
// So on Metal for now we don't patch normal buffer if we detect an intel GPU // So on Metal for now we don't patch normal buffer if we detect an intel GPU
if (SystemInfo.graphicsDeviceType == GraphicsDeviceType.Metal && SystemInfo.graphicsDeviceName.Contains("Intel"))
if (SystemInfo.graphicsDeviceType == GraphicsDeviceType.Metal && SystemInfo.graphicsDeviceVendorID == kIntelVendorId)
{ {
return; return;
} }

2
Packages/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/HDRenderPipeline.cs

@ -2817,7 +2817,7 @@ namespace UnityEngine.Rendering.HighDefinition
cameraXRSettings.viewCount = (uint)hdCamera.viewCount; cameraXRSettings.viewCount = (uint)hdCamera.viewCount;
cameraXRSettings.viewOffset = (uint)hdCamera.xr.multipassId; cameraXRSettings.viewOffset = (uint)hdCamera.xr.multipassId;
VFXManager.ProcessCameraCommand(camera, cmd, cameraXRSettings, cullingResults);
VFXManager.ProcessCameraCommand(camera, cmd, cameraXRSettings, cullingResults, customPassCullingResults);
if (GL.wireframe) if (GL.wireframe)
{ {

29
Packages/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/RenderPass/CustomPass/CustomPass.cs

@ -52,6 +52,24 @@ namespace UnityEngine.Rendering.HighDefinition
/// </summary> /// </summary>
public TargetBuffer targetDepthBuffer; public TargetBuffer targetDepthBuffer;
// The actual depth buffer has to follow some constraints, and thus may not be the same result as the target
// depth buffer that the user has requested. Apply these constraints and return a result.
internal TargetBuffer getConstrainedDepthBuffer()
{
TargetBuffer depth = targetDepthBuffer;
if (depth == TargetBuffer.Camera &&
HDRenderPipeline.currentAsset.currentPlatformRenderPipelineSettings.dynamicResolutionSettings.enabled &&
currentHDCamera.allowDynamicResolution &&
injectionPoint == CustomPassInjectionPoint.AfterPostProcess)
{
// This custom pass is injected after postprocessing, and Dynamic Resolution Scaling is enabled, which
// means an upscaler is active. In this case, the camera color buffer is the full display resolution,
// but the camera depth buffer is a lower, pre-upscale resolution. So we cannot do depth testing here.
depth = TargetBuffer.None;
}
return depth;
}
/// <summary> /// <summary>
/// What clear to apply when the color and depth buffer are bound /// What clear to apply when the color and depth buffer are bound
/// </summary> /// </summary>
@ -314,7 +332,7 @@ namespace UnityEngine.Rendering.HighDefinition
} }
// Set back the camera color buffer if we were using a custom buffer as target // Set back the camera color buffer if we were using a custom buffer as target
if (customPass.targetDepthBuffer != TargetBuffer.Camera)
if (customPass.getConstrainedDepthBuffer() != TargetBuffer.Camera)
CoreUtils.SetRenderTarget(ctx.cmd, outputColorBuffer); CoreUtils.SetRenderTarget(ctx.cmd, outputColorBuffer);
}); });
} }
@ -351,16 +369,17 @@ namespace UnityEngine.Rendering.HighDefinition
// This function must be only called from the ExecuteInternal method (requires current render target and current RT manager) // This function must be only called from the ExecuteInternal method (requires current render target and current RT manager)
void SetCustomPassTarget(CommandBuffer cmd) void SetCustomPassTarget(CommandBuffer cmd)
{ {
TargetBuffer depth = getConstrainedDepthBuffer();
// In case all the buffer are set to none, we can't bind anything // In case all the buffer are set to none, we can't bind anything
if (targetColorBuffer == TargetBuffer.None && targetDepthBuffer == TargetBuffer.None)
if (targetColorBuffer == TargetBuffer.None && depth == TargetBuffer.None)
return; return;
RTHandle colorBuffer = (targetColorBuffer == TargetBuffer.Custom) ? currentRenderTarget.customColorBuffer.Value : currentRenderTarget.colorBufferRG; RTHandle colorBuffer = (targetColorBuffer == TargetBuffer.Custom) ? currentRenderTarget.customColorBuffer.Value : currentRenderTarget.colorBufferRG;
RTHandle depthBuffer = (targetDepthBuffer == TargetBuffer.Custom) ? currentRenderTarget.customDepthBuffer.Value : currentRenderTarget.depthBufferRG;
RTHandle depthBuffer = (depth == TargetBuffer.Custom) ? currentRenderTarget.customDepthBuffer.Value : currentRenderTarget.depthBufferRG;
if (targetColorBuffer == TargetBuffer.None && targetDepthBuffer != TargetBuffer.None)
if (targetColorBuffer == TargetBuffer.None && depth != TargetBuffer.None)
CoreUtils.SetRenderTarget(cmd, depthBuffer, clearFlags); CoreUtils.SetRenderTarget(cmd, depthBuffer, clearFlags);
else if (targetColorBuffer != TargetBuffer.None && targetDepthBuffer == TargetBuffer.None)
else if (targetColorBuffer != TargetBuffer.None && depth == TargetBuffer.None)
CoreUtils.SetRenderTarget(cmd, colorBuffer, clearFlags); CoreUtils.SetRenderTarget(cmd, colorBuffer, clearFlags);
else else
{ {

4
Packages/com.unity.render-pipelines.high-definition/Runtime/Settings/HDRPDefaultVolumeProfileSetting.cs

@ -69,9 +69,9 @@ namespace UnityEngine.Rendering.HighDefinition
#if UNITY_EDITOR #if UNITY_EDITOR
//Overriding "Reset" in menu that is not called at HDRPDefaultVolumeProfileSettings creation such Reset() //Overriding "Reset" in menu that is not called at HDRPDefaultVolumeProfileSettings creation such Reset()
struct ResetImplementation : IRenderPipelineGraphicsSettingsContextMenu<HDRPDefaultVolumeProfileSettings>
struct ResetImplementation : IRenderPipelineGraphicsSettingsContextMenu2<HDRPDefaultVolumeProfileSettings>
{ {
public void PopulateContextMenu(HDRPDefaultVolumeProfileSettings setting, PropertyDrawer drawer, ref GenericMenu menu)
public void PopulateContextMenu(HDRPDefaultVolumeProfileSettings setting, SerializedProperty _, ref GenericMenu menu)
{ {
void Reset() void Reset()
{ {

4
Packages/com.unity.render-pipelines.high-definition/Runtime/Water/Shaders/SampleWaterSurface.hlsl

@ -442,7 +442,11 @@ void EvaluateWaterAdditionalData(float3 positionOS, float3 transformedPosition,
return; return;
// Evaluate the pre-displaced absolute position // Evaluate the pre-displaced absolute position
#if defined(WATER_DISPLACEMENT)
float3 positionRWS = positionOS;
#else
float3 positionRWS = TransformObjectToWorld_Water(positionOS); float3 positionRWS = TransformObjectToWorld_Water(positionOS);
#endif
// Evaluate the distance to the camera // Evaluate the distance to the camera
float distanceToCamera = length(positionRWS); float distanceToCamera = length(positionRWS);
// Get the world space transformed postion // Get the world space transformed postion

2
Packages/com.unity.render-pipelines.high-definition/Runtime/Water/Shaders/UnderWaterUtilities.hlsl

@ -40,7 +40,7 @@ float GetUnderWaterDistance(uint2 coord)
uint xr = unity_StereoEyeIndex * _BufferStride; uint xr = unity_StereoEyeIndex * _BufferStride;
uint2 boundsX = uint2(0xFFFFFFFF - _WaterLine[0 + xr], _WaterLine[1 + xr]); uint2 boundsX = uint2(0xFFFFFFFF - _WaterLine[0 + xr], _WaterLine[1 + xr]);
uint posX = round(dot((float2)coord.xy, rightVector) - _BoundsSS.x); uint posX = round(dot((float2)coord.xy, rightVector) - _BoundsSS.x);
posX = clamp(posX, boundsX.x, boundsX.y);
posX = clamp(posX, min(boundsX.y, boundsX.x), max(boundsX.x, boundsX.y));
// Decompress water line height // Decompress water line height
float posY = dot((float2)coord.xy, upVector) - _BoundsSS.z; float posY = dot((float2)coord.xy, upVector) - _BoundsSS.z;

2
Packages/com.unity.render-pipelines.high-definition/package.json

@ -100,5 +100,5 @@
] ]
} }
], ],
"_fingerprint": "4de1dfa20daa1dde4106c2c4990e5356c4cbf1e7"
"_fingerprint": "840db4b587bbd894c751a83052cd5c5a11fba2f2"
} }

9
Packages/com.unity.shadergraph/Editor/Drawing/MaterialGraphEditWindow.cs

@ -486,7 +486,7 @@ namespace UnityEditor.ShaderGraph.Drawing
UpdateTitle(); UpdateTitle();
} }
public void UpdateTitle()
public void UpdateTitle(bool ignoreUnsavedChanges = false)
{ {
string assetPath = AssetDatabase.GUIDToAssetPath(selectedGuid); string assetPath = AssetDatabase.GUIDToAssetPath(selectedGuid);
string shaderName = Path.GetFileNameWithoutExtension(assetPath); string shaderName = Path.GetFileNameWithoutExtension(assetPath);
@ -501,7 +501,7 @@ namespace UnityEditor.ShaderGraph.Drawing
title = title + " (nothing loaded)"; title = title + " (nothing loaded)";
else else
{ {
if (GraphHasChangedSinceLastSerialization())
if (!ignoreUnsavedChanges && GraphHasChangedSinceLastSerialization())
{ {
hasUnsavedChanges = true; hasUnsavedChanges = true;
// This is the message EditorWindow will show when prompting to close while dirty // This is the message EditorWindow will show when prompting to close while dirty
@ -1260,6 +1260,7 @@ namespace UnityEditor.ShaderGraph.Drawing
using (GraphLoadMarker.Auto()) using (GraphLoadMarker.Auto())
{ {
m_LastSerializedFileContents = File.ReadAllText(path, Encoding.UTF8); m_LastSerializedFileContents = File.ReadAllText(path, Encoding.UTF8);
graphObject = CreateInstance<GraphObject>(); graphObject = CreateInstance<GraphObject>();
graphObject.hideFlags = HideFlags.HideAndDontSave; graphObject.hideFlags = HideFlags.HideAndDontSave;
graphObject.graph = new GraphData graphObject.graph = new GraphData
@ -1268,6 +1269,7 @@ namespace UnityEditor.ShaderGraph.Drawing
isSubGraph = isSubGraph, isSubGraph = isSubGraph,
messageManager = messageManager messageManager = messageManager
}; };
MultiJson.Deserialize(graphObject.graph, m_LastSerializedFileContents); MultiJson.Deserialize(graphObject.graph, m_LastSerializedFileContents);
graphObject.graph.OnEnable(); graphObject.graph.OnEnable();
graphObject.graph.ValidateGraph(); graphObject.graph.ValidateGraph();
@ -1281,8 +1283,7 @@ namespace UnityEditor.ShaderGraph.Drawing
}; };
} }
UpdateTitle();
UpdateTitle(ignoreUnsavedChanges: true);
Repaint(); Repaint();
} }
catch (Exception) catch (Exception)

2
Packages/com.unity.shadergraph/package.json

@ -43,5 +43,5 @@
"path": "Samples~/UGUIShaders" "path": "Samples~/UGUIShaders"
} }
], ],
"_fingerprint": "26dc5ae27e7d8949b4e95045bf189b8733da88ee"
"_fingerprint": "e5d3455aa13376f767ad6bf5f3faab2073877176"
} }

2
Packages/com.unity.ugui/Editor/TMP/TMP_BaseShaderGUI.cs

@ -438,7 +438,7 @@ namespace TMPro.EditorUtilities
{ {
MaterialProperty property = BeginProperty(name); MaterialProperty property = BeginProperty(name);
s_TempLabel.text = label; s_TempLabel.text = label;
Color value = EditorGUI.ColorField(EditorGUILayout.GetControlRect(), s_TempLabel, property.colorValue, false, true, false);
Color value = EditorGUI.ColorField(EditorGUILayout.GetControlRect(), s_TempLabel, property.colorValue, false, true, true);
if (EndProperty()) if (EndProperty())
{ {
property.colorValue = value; property.colorValue = value;

15
Packages/com.unity.ugui/Editor/TMP/TMP_FontAssetEditor.cs

@ -6,6 +6,7 @@ using JetBrains.Annotations;
using UnityEngine.TextCore; using UnityEngine.TextCore;
using UnityEngine.TextCore.LowLevel; using UnityEngine.TextCore.LowLevel;
using UnityEditor.TextCore.LowLevel; using UnityEditor.TextCore.LowLevel;
using System;
namespace TMPro.EditorUtilities namespace TMPro.EditorUtilities
@ -255,7 +256,6 @@ namespace TMPro.EditorUtilities
private System.DateTime timeStamp; private System.DateTime timeStamp;
public void OnEnable() public void OnEnable()
{ {
m_FaceInfo_prop = serializedObject.FindProperty("m_FaceInfo"); m_FaceInfo_prop = serializedObject.FindProperty("m_FaceInfo");
@ -533,7 +533,18 @@ namespace TMPro.EditorUtilities
{ {
EditorGUI.BeginChangeCheck(); EditorGUI.BeginChangeCheck();
// TODO: Switch shaders depending on GlyphRenderMode. // TODO: Switch shaders depending on GlyphRenderMode.
EditorGUILayout.PropertyField(m_AtlasRenderMode_prop);
var glyphRenderValues = (GlyphRenderMode[])Enum.GetValues(typeof(GlyphRenderMode));
GlyphRenderMode currentValue = glyphRenderValues[m_AtlasRenderMode_prop.enumValueIndex];
GlyphRenderModeUI selectedUI = (GlyphRenderModeUI)currentValue;
selectedUI = (GlyphRenderModeUI)EditorGUILayout.EnumPopup("Render Mode", selectedUI);
GlyphRenderMode updatedValue = (GlyphRenderMode)selectedUI;
if (updatedValue != currentValue)
{
int updatedIndex = Array.IndexOf(glyphRenderValues, updatedValue);
m_AtlasRenderMode_prop.enumValueIndex = updatedIndex;
m_DisplayDestructiveChangeWarning = true;
}
EditorGUILayout.PropertyField(m_SamplingPointSize_prop, new GUIContent("Sampling Point Size")); EditorGUILayout.PropertyField(m_SamplingPointSize_prop, new GUIContent("Sampling Point Size"));
if (EditorGUI.EndChangeCheck()) if (EditorGUI.EndChangeCheck())
{ {

7
Packages/com.unity.ugui/Editor/TMP/TMPro_FontAssetCreatorWindow.cs

@ -675,13 +675,13 @@ namespace TMPro.EditorUtilities
//GUILayout.EndHorizontal(); //GUILayout.EndHorizontal();
// Render Mode Selection // Render Mode Selection
CheckForLegacyGlyphRenderMode();
GlyphRenderModeUI selectedUIMode = (GlyphRenderModeUI)m_GlyphRenderMode;
EditorGUI.BeginChangeCheck(); EditorGUI.BeginChangeCheck();
m_GlyphRenderMode = (GlyphRenderMode)EditorGUILayout.EnumPopup("Render Mode", m_GlyphRenderMode);
selectedUIMode = (GlyphRenderModeUI)EditorGUILayout.EnumPopup("Render Mode", selectedUIMode);
if (EditorGUI.EndChangeCheck()) if (EditorGUI.EndChangeCheck())
{ {
m_IsFontAtlasInvalid = true; m_IsFontAtlasInvalid = true;
m_GlyphRenderMode = (GlyphRenderMode)selectedUIMode;
} }
m_IncludeFontFeatures = EditorGUILayout.Toggle("Get Font Features", m_IncludeFontFeatures); m_IncludeFontFeatures = EditorGUILayout.Toggle("Get Font Features", m_IncludeFontFeatures);
@ -1184,7 +1184,6 @@ namespace TMPro.EditorUtilities
ClearGeneratedData(); ClearGeneratedData();
} }
/// <summary> /// <summary>
/// Clear the previously generated data. /// Clear the previously generated data.
/// </summary> /// </summary>

10
Packages/com.unity.ugui/Runtime/TMP/TMP_InputField.cs

@ -2395,17 +2395,16 @@ namespace TMPro
} }
break; break;
} }
} }
if (consumedEvent)
// We must also consume events when IME is active to prevent them from being passed to the text field. // UUM-100552
if (consumedEvent || (m_IsCompositionActive && compositionLength > 0))
{ {
UpdateLabel(); UpdateLabel();
eventData.Use(); eventData.Use();
} }
} }
/// <summary> /// <summary>
/// ///
/// </summary> /// </summary>
@ -4188,14 +4187,15 @@ namespace TMPro
if (!cursorBeforeDash) if (!cursorBeforeDash)
{ {
if (ch >= '0' && ch <= '9') return ch; if (ch >= '0' && ch <= '9') return ch;
if (ch == '-' && (pos == 0 || selectionAtStart)) return ch;
if (ch == '-' && (pos == 0 || selectionAtStart) && !text.Contains('-')) return ch;
var separator = Thread.CurrentThread.CurrentCulture.NumberFormat.NumberDecimalSeparator; var separator = Thread.CurrentThread.CurrentCulture.NumberFormat.NumberDecimalSeparator;
if (ch == Convert.ToChar(separator) && characterValidation == CharacterValidation.Decimal && !text.Contains(separator)) return ch; if (ch == Convert.ToChar(separator) && characterValidation == CharacterValidation.Decimal && !text.Contains(separator)) return ch;
//Some keyboards including Samsung require double tapping a . to get a - this allows these keyboards to input negative integers //Some keyboards including Samsung require double tapping a . to get a - this allows these keyboards to input negative integers
if (characterValidation == CharacterValidation.Integer && ch == '.' && (pos == 0 || selectionAtStart)) return '-';
if (characterValidation == CharacterValidation.Integer && ch == '.' && (pos == 0 || selectionAtStart) && !text.Contains('-')) return '-';
} }
} }
else if (characterValidation == CharacterValidation.Digit) else if (characterValidation == CharacterValidation.Digit)
{ {

2
Packages/com.unity.ugui/Runtime/TMP/TMP_SpriteAsset.cs

@ -237,7 +237,7 @@ namespace TMPro
if (m_NameLookup == null) if (m_NameLookup == null)
UpdateLookupTables(); UpdateLookupTables();
int hashCode = TMP_TextUtilities.GetSimpleHashCode(name);
int hashCode = TMP_TextUtilities.GetHashCode(name);
return GetSpriteIndexFromHashcode(hashCode); return GetSpriteIndexFromHashcode(hashCode);
} }

4
Packages/com.unity.ugui/Runtime/UGUI/UI/Core/InputField.cs

@ -3009,10 +3009,10 @@ namespace UnityEngine.UI
if (!cursorBeforeDash || dashInSelection) if (!cursorBeforeDash || dashInSelection)
{ {
if (ch >= '0' && ch <= '9') return ch; if (ch >= '0' && ch <= '9') return ch;
if (ch == '-' && (pos == 0 || selectionAtStart)) return ch;
if (ch == '-' && (pos == 0 || selectionAtStart) && !text.Contains('-')) return ch;
if ((ch == '.' || ch == ',') && characterValidation == CharacterValidation.Decimal && text.IndexOfAny(new[] { '.', ',' }) == -1) return ch; if ((ch == '.' || ch == ',') && characterValidation == CharacterValidation.Decimal && text.IndexOfAny(new[] { '.', ',' }) == -1) return ch;
//Some keyboards including Samsung require double tapping a . to get a - this allows these keyboards to input negative integers //Some keyboards including Samsung require double tapping a . to get a - this allows these keyboards to input negative integers
if (characterValidation == CharacterValidation.Integer && ch == '.' && (pos == 0 || selectionAtStart)) return '-';
if (characterValidation == CharacterValidation.Integer && ch == '.' && (pos == 0 || selectionAtStart) && !text.Contains('-')) return '-';
} }
} }
else if (characterValidation == CharacterValidation.Alphanumeric) else if (characterValidation == CharacterValidation.Alphanumeric)

2
Packages/com.unity.ugui/package.json

@ -19,5 +19,5 @@
"com.unity.modules.ui": "1.0.0", "com.unity.modules.ui": "1.0.0",
"com.unity.modules.imgui": "1.0.0" "com.unity.modules.imgui": "1.0.0"
}, },
"_fingerprint": "5c9fd4989cdd8e57279d95edb174435a77f5c853"
"_fingerprint": "57cef44123c7486b2e2f08dc6535aecf6c34b8ef"
} }

6
Packages/com.unity.visualeffectgraph/Editor/GraphView/Views/VFXConvertSubgraph.cs

@ -248,6 +248,8 @@ namespace UnityEditor.VFX.UI
TransferEdges(); TransferEdges();
//TransferContextsFlowEdges(); //TransferContextsFlowEdges();
UninitSmart(); UninitSmart();
m_TargetSubgraph.GetResource()?.WriteAssetWithSubAssets();
} }
public void ConvertToSubgraphOperator(VFXView sourceView, IEnumerable<Controller> controllers, Rect rect, string path) public void ConvertToSubgraphOperator(VFXView sourceView, IEnumerable<Controller> controllers, Rect rect, string path)
@ -282,6 +284,8 @@ namespace UnityEditor.VFX.UI
var subGraphOperator = m_SourceNode as VFXSubgraphOperator; var subGraphOperator = m_SourceNode as VFXSubgraphOperator;
subGraphOperator.RecreateCopy(); subGraphOperator.RecreateCopy();
subGraphOperator.ResyncSlots(true); subGraphOperator.ResyncSlots(true);
m_TargetSubgraph.GetResource()?.WriteAssetWithSubAssets();
} }
List<VFXBlockController> m_SourceBlockControllers; List<VFXBlockController> m_SourceBlockControllers;
@ -374,6 +378,8 @@ namespace UnityEditor.VFX.UI
TransferEdges(); TransferEdges();
m_SourceControllers = m_SourceControllersWithBlocks.ToList(); m_SourceControllers = m_SourceControllersWithBlocks.ToList();
UninitSmart(); UninitSmart();
m_TargetSubgraph.GetResource()?.WriteAssetWithSubAssets();
} }
bool CreateUniqueSubgraph(string typeName, string extension, Func<string, VisualEffectObject> createFunc) bool CreateUniqueSubgraph(string typeName, string extension, Func<string, VisualEffectObject> createFunc)

82
Packages/com.unity.visualeffectgraph/Editor/GraphView/Views/VFXView.cs

@ -1056,7 +1056,20 @@ namespace UnityEditor.VFX.UI
m_ComponentBoard.RefreshInitializeErrors(); m_ComponentBoard.RefreshInitializeErrors();
} }
public void ToggleDebugPanels()
{
if (m_ProfilingBoard.parent != null && attachedComponent != null)
{
m_ProfilingBoard.TogglePanelsVisibility();
}
}
public void ToggleProfilingBoard() public void ToggleProfilingBoard()
{
m_ToggleProfilingBoard.value = !m_ToggleProfilingBoard.value;
}
void OnToggleProfilingBoard()
{ {
if (m_ProfilingBoard.parent == null) if (m_ProfilingBoard.parent == null)
{ {
@ -1116,7 +1129,7 @@ namespace UnityEditor.VFX.UI
Toggle m_ToggleProfilingBoard; Toggle m_ToggleProfilingBoard;
void ToggleProfilingBoard(ChangeEvent<bool> e) void ToggleProfilingBoard(ChangeEvent<bool> e)
{ {
ToggleProfilingBoard();
OnToggleProfilingBoard();
} }
public void OnVisualEffectComponentChanged(IEnumerable<VisualEffect> visualEffects) public void OnVisualEffectComponentChanged(IEnumerable<VisualEffect> visualEffects)
@ -1812,27 +1825,7 @@ namespace UnityEditor.VFX.UI
{ {
m_ComponentBoard?.DeactivateBoundsRecordingIfNeeded(); //Avoids saving the graph with unnecessary bounds computations m_ComponentBoard?.DeactivateBoundsRecordingIfNeeded(); //Avoids saving the graph with unnecessary bounds computations
var graphToSave = new HashSet<VFXGraph>();
GetGraphsRecursively(controller.graph, graphToSave);
foreach (var graph in graphToSave)
{
if (EditorUtility.IsDirty(graph) || UnityEngine.Object.ReferenceEquals(graph, controller.graph))
{
graph.UpdateSubAssets();
try
{
VFXGraph.compilingInEditMode = !m_IsRuntimeMode;
graph.visualEffectResource.WriteAsset();
}
finally
{
VFXGraph.compilingInEditMode = false;
}
}
}
// Only for testing purpose
//VFXAnalytics.GetInstance().OnSaveVFXAsset(this);
controller.graph.visualEffectResource.WriteAssetWithSubAssets();
} }
internal void SaveAs(string newPath) internal void SaveAs(string newPath)
@ -1848,46 +1841,6 @@ namespace UnityEditor.VFX.UI
} }
} }
void GetGraphsRecursively(VFXGraph start, HashSet<VFXGraph> graphs)
{
if (graphs.Contains(start))
return;
graphs.Add(start);
foreach (var child in start.children)
{
if (child is VFXSubgraphOperator ope)
{
if (ope.subgraph != null)
{
var graph = ope.subgraph.GetResource().GetOrCreateGraph();
GetGraphsRecursively(graph, graphs);
}
}
else if (child is VFXSubgraphContext subCtx)
{
if (subCtx.subgraph != null)
{
var graph = subCtx.subgraph.GetResource().GetOrCreateGraph();
GetGraphsRecursively(graph, graphs);
}
}
else if (child is VFXContext ctx)
{
foreach (var block in ctx.children.Cast<VFXBlock>())
{
if (block is VFXSubgraphBlock subBlock)
{
if (subBlock.subgraph != null)
{
var graph = subBlock.subgraph.GetResource().GetOrCreateGraph();
GetGraphsRecursively(graph, graphs);
}
}
}
}
}
}
public EventPropagation OnCompile() public EventPropagation OnCompile()
{ {
Compile(); Compile();
@ -1967,11 +1920,6 @@ namespace UnityEditor.VFX.UI
} }
} }
public void ToggleDebugPanels()
{
m_ProfilingBoard.TogglePanelsVisibility();
}
public IEnumerable<VFXContextUI> GetAllContexts() public IEnumerable<VFXContextUI> GetAllContexts()
{ {
foreach (var layer in contentViewContainer.Children()) foreach (var layer in contentViewContainer.Children())

3
Packages/com.unity.visualeffectgraph/Editor/Models/VFXErrorManager.cs

@ -158,7 +158,10 @@ namespace UnityEditor.VFX
} }
finally finally
{ {
// swap dirty and scheduled models
var tmp = m_DirtyModels;
m_DirtyModels = m_ScheduledModels; m_DirtyModels = m_ScheduledModels;
m_ScheduledModels = tmp;
m_ScheduledModels.Clear(); m_ScheduledModels.Clear();
m_IsGeneratingErrors = false; m_IsGeneratingErrors = false;
} }

45
Packages/com.unity.visualeffectgraph/Editor/Models/VFXGraph.cs

@ -374,19 +374,7 @@ namespace UnityEditor.VFX
AssetDatabase.StartAssetEditing(); AssetDatabase.StartAssetEditing();
} }
var vfxResource = VisualEffectResource.GetResourceAtPath(path); var vfxResource = VisualEffectResource.GetResourceAtPath(path);
if (vfxResource != null)
{
vfxResource.GetOrCreateGraph().UpdateSubAssets();
try
{
VFXGraph.compilingInEditMode = vfxResource.GetOrCreateGraph().GetCompilationMode() == VFXCompilationMode.Edition;
vfxResource.WriteAsset(); // write asset as the AssetDatabase won't do it.
}
finally
{
VFXGraph.compilingInEditMode = false;
}
}
vfxResource?.WriteAssetWithSubAssets();
} }
} }
finally finally
@ -432,6 +420,13 @@ namespace UnityEditor.VFX
resource.GetOrCreateGraph().UpdateSubAssets(); resource.GetOrCreateGraph().UpdateSubAssets();
} }
public static void WriteAssetWithSubAssets(this VisualEffectResource resource)
{
var graph = resource.GetOrCreateGraph();
graph.UpdateSubAssets();
resource.WriteAsset();
}
public static bool IsAssetEditable(this VisualEffectResource resource) public static bool IsAssetEditable(this VisualEffectResource resource)
{ {
return AssetDatabase.IsOpenForEdit((UnityEngine.Object)resource.asset ?? resource.subgraph, StatusQueryOptions.UseCachedIfPossible); return AssetDatabase.IsOpenForEdit((UnityEngine.Object)resource.asset ?? resource.subgraph, StatusQueryOptions.UseCachedIfPossible);
@ -488,15 +483,6 @@ namespace UnityEditor.VFX
// 18: Change ProbabilitySampling m_IntegratedRandomDeprecated changed to m_Mode // 18: Change ProbabilitySampling m_IntegratedRandomDeprecated changed to m_Mode
public static readonly int CurrentVersion = 18; public static readonly int CurrentVersion = 18;
[NonSerialized]
internal static bool compilingInEditMode = false;
public override void OnEnable()
{
base.OnEnable();
m_ExpressionGraphDirty = true;
}
public override void OnSRPChanged() public override void OnSRPChanged()
{ {
m_GraphSanitized = false; m_GraphSanitized = false;
@ -1139,7 +1125,7 @@ namespace UnityEditor.VFX
public void SetCompilationMode(VFXCompilationMode mode, bool reimport = true) public void SetCompilationMode(VFXCompilationMode mode, bool reimport = true)
{ {
if (m_CompilationMode != mode)
if (m_CompilationMode != mode && !GetResource().isSubgraph)
{ {
m_CompilationMode = mode; m_CompilationMode = mode;
SetExpressionGraphDirty(); SetExpressionGraphDirty();
@ -1400,11 +1386,10 @@ namespace UnityEditor.VFX
public void CompileForImport() public void CompileForImport()
{ {
if (compilingInEditMode)
m_CompilationMode = VFXCompilationMode.Edition;
bool isSubgraph = GetResource().isSubgraph;
SyncCustomAttributes(); SyncCustomAttributes();
if (!GetResource().isSubgraph)
if (!isSubgraph)
{ {
// Check Graph Before Import can be needed to synchronize modified shaderGraph // Check Graph Before Import can be needed to synchronize modified shaderGraph
foreach (var child in children) foreach (var child in children)
@ -1492,21 +1477,15 @@ namespace UnityEditor.VFX
[SerializeField] [SerializeField]
private int m_ResourceVersion; private int m_ResourceVersion;
[NonSerialized]
private bool m_GraphSanitized = false; private bool m_GraphSanitized = false;
[NonSerialized]
private bool m_ExpressionGraphDirty = true; private bool m_ExpressionGraphDirty = true;
[NonSerialized]
private bool m_ExpressionValuesDirty = true; private bool m_ExpressionValuesDirty = true;
[NonSerialized]
private bool m_DependentDirty = true; private bool m_DependentDirty = true;
[NonSerialized]
private bool m_MaterialsDirty = false; private bool m_MaterialsDirty = false;
[NonSerialized]
private bool m_CustomAttributesDirty = false; private bool m_CustomAttributesDirty = false;
[NonSerialized]
private VFXGraphCompiledData m_CompiledData; private VFXGraphCompiledData m_CompiledData;
private VFXCompilationMode m_CompilationMode = VFXCompilationMode.Runtime; private VFXCompilationMode m_CompilationMode = VFXCompilationMode.Runtime;
private bool m_ForceShaderDebugSymbols = false; private bool m_ForceShaderDebugSymbols = false;
private bool m_ForceShaderValidation = false; private bool m_ForceShaderValidation = false;

8
Packages/com.unity.visualeffectgraph/Editor/UIResources/uss/PropertyRM.uss

@ -107,9 +107,11 @@
.propertyrm #spacebutton.None { .propertyrm #spacebutton.None {
background-image : url("project:///Packages/com.unity.visualeffectgraph/Editor/UIResources/VFX/d_NoneSpace@2x.png"); background-image : url("project:///Packages/com.unity.visualeffectgraph/Editor/UIResources/VFX/d_NoneSpace@2x.png");
} }
.propertyrm VFXMatrix4x4Field Label {
width: 18px;
margin-left: 4px;
.propertyrm #matrixContainer Label {
width: 20px;
margin-right: 2px;
-unity-text-align: middle-right;
} }
.propertyrm #spacebutton:hover { .propertyrm #spacebutton:hover {

4
Packages/com.unity.visualeffectgraph/Editor/UIResources/uss/VFXDataAnchor.uss

@ -175,6 +175,10 @@ VFXDataAnchor.Output #type
-unity-text-align: middle-center; -unity-text-align: middle-center;
} }
.VFXDataAnchor .propertyrm #matrixContainer FloatInput {
width: 30px;
}
.VFXOutputDataAnchor #icon .VFXOutputDataAnchor #icon
{ {
width: 13px; width: 13px;

4
Packages/com.unity.visualeffectgraph/Shaders/VFXVolumetricFogUpdate.template

@ -10,6 +10,10 @@ ${VFXInclude("Shaders/VFXParticleCommon.template")}
// Indirect draw is always enabled for volumetric fog output // Indirect draw is always enabled for volumetric fog output
RWStructuredBuffer<uint> indirectBuffer; RWStructuredBuffer<uint> indirectBuffer;
#if HAS_STRIPS_DATA
StructuredBuffer<uint> stripDataBuffer;
#endif
#include "Packages/com.unity.render-pipelines.core/ShaderLibrary/Common.hlsl" #include "Packages/com.unity.render-pipelines.core/ShaderLibrary/Common.hlsl"
#include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/Builtin/BuiltinData.hlsl" #include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/Builtin/BuiltinData.hlsl"
#include "Packages/com.unity.render-pipelines.high-definition/Runtime/ShaderLibrary/ShaderVariables.hlsl" #include "Packages/com.unity.render-pipelines.high-definition/Runtime/ShaderLibrary/ShaderVariables.hlsl"

2
Packages/com.unity.visualeffectgraph/package.json

@ -36,5 +36,5 @@
] ]
} }
], ],
"_fingerprint": "a6f52bdb90a859536ffa7087989628316309dacc"
"_fingerprint": "aecde9dec67d1cb56e53e3135229de90e9d94fb6"
} }
Loading…
Cancel
Save