Skip to content

Commit d87dba6

Browse files
authored
Merge pull request #8152 from Unity-Technologies/internal/master
Internal/master
2 parents ddab622 + 6805ee9 commit d87dba6

File tree

98 files changed

+14591
-70
lines changed

Some content is hidden

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

98 files changed

+14591
-70
lines changed

Packages/com.unity.render-pipelines.core/CHANGELOG.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,16 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
1010
Version Updated
1111
The version number for this package has increased due to a version update of a related graphics package.
1212

13+
## [17.2.0] - 2025-05-14
14+
15+
This version is compatible with Unity 6000.2.0b2.
16+
17+
### Fixed
18+
- Fixed an editor crash that could sometimes occur when throwing an exception from `Dispose()` in a custom SRP renderer feature.
19+
- Fixed a memory leak that occurred when entering and exiting Play mode in the Editor.
20+
- Fixed an issue where the *Add Override* button in the Global Volume's Inspector panel did not work correctly on Linux.
21+
- Fix out of bounds read in CoreUnsafeUtils.FixedBufferStringQueue.TryPop when the remaining bytes in the buffer is less than 4
22+
1323
## [17.0.3] - 2025-02-13
1424

1525
This version is compatible with Unity 6000.2.0a17.
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
---
2+
uid: srp-core-api-index
3+
---
4+
5+
# Scriptable Render Pipeline Core scripting API
6+
7+
This is the documentation for the scripting APIs of the Scriptable Render Pipeline (SRP) Core package.
8+
9+
**Note**: URP and HDRP are built on the Scriptable Render Pipeline (SRP) Core package, but have their own class types. For more information, refer to the following:
10+
11+
- [Universal Render Pipeline (URP) Scripting API](https://docs.unity3d.com/Packages/com.unity.render-pipelines.universal@17.3/api/index.html)
12+
- [High Definition Render Pipeline (HDRP) Scripting API](https://docs.unity3d.com/Packages/com.unity.render-pipelines.high-definition@17.3/api/index.html)

Packages/com.unity.render-pipelines.core/Editor/CoreEditorStyles.cs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,8 @@ public static GUIStyle miniLabelButton
118118

119119
/// <summary> Warning icon </summary>
120120
public static readonly Texture2D iconWarn;
121+
/// <summary> Info icon </summary>
122+
public static readonly Texture2D iconInfo;
121123
/// <summary> Help icon </summary>
122124
public static readonly Texture2D iconHelp;
123125
/// <summary> Fail icon </summary>
@@ -144,7 +146,7 @@ internal static Texture2D GetMessageTypeIcon(MessageType messageType)
144146
case MessageType.None:
145147
return null;
146148
case MessageType.Info:
147-
return iconHelp;
149+
return iconInfo;
148150
case MessageType.Warning:
149151
return iconWarn;
150152
case MessageType.Error:
@@ -215,7 +217,8 @@ static CoreEditorStyles()
215217
greenTexture = CoreEditorUtils.CreateColoredTexture2D(Color.green, "Green 1x1");
216218
blueTexture = CoreEditorUtils.CreateColoredTexture2D(Color.blue, "Blue 1x1");
217219

218-
iconHelp = CoreEditorUtils.LoadIcon("icons", "console.infoicon", ".png");
220+
iconHelp = CoreEditorUtils.LoadIcon("icons", "_Help", ".png");
221+
iconInfo = CoreEditorUtils.LoadIcon("icons", "console.infoicon", ".png");
219222
iconWarn = CoreEditorUtils.LoadIcon("icons", "console.warnicon", ".png");
220223
iconFail = CoreEditorUtils.LoadIcon("icons", "console.erroricon", ".png");
221224
iconSuccess = EditorGUIUtility.FindTexture("TestPassed");

Packages/com.unity.render-pipelines.core/Editor/Debugging/DebugState.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,7 @@ public sealed class DebugStateInt : DebugState<int> { }
179179
/// <summary>
180180
/// Object Debug State.
181181
/// </summary>
182-
[Serializable, DebugState(typeof(DebugUI.ObjectPopupField), typeof(DebugUI.CameraSelector))]
182+
[Serializable, DebugState(typeof(DebugUI.ObjectPopupField), typeof(DebugUI.CameraSelector), typeof(DebugUI.ObjectField))]
183183
public sealed class DebugStateObject : DebugState<UnityEngine.Object>
184184
{
185185
/// <summary>

Packages/com.unity.render-pipelines.core/Runtime/RenderGraph/RenderGraph.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -717,7 +717,7 @@ public TextureHandle ImportShadingRateImageTexture(RTHandle rt)
717717
/// <param name="rt">External RTHandle that needs to be imported.</param>
718718
/// <param name="importParams">Info describing the clear behavior of imported textures. Clearing textures using importParams may be more efficient than manually clearing the texture using `cmd.Clear` on some hardware.</param>
719719
/// <returns>A new TextureHandle that represents the imported texture in the context of this rendergraph.</returns>
720-
public TextureHandle ImportTexture(RTHandle rt, ImportResourceParams importParams )
720+
public TextureHandle ImportTexture(RTHandle rt, ImportResourceParams importParams)
721721
{
722722
CheckNotUsedWhenExecuting();
723723

@@ -740,7 +740,7 @@ public TextureHandle ImportTexture(RTHandle rt, ImportResourceParams importParam
740740
/// <param name="info">The properties of the passed in RTHandle.</param>
741741
/// <param name="importParams">Info describing the clear behavior of imported textures. Clearing textures using importParams may be more efficient than manually clearing the texture using `cmd.Clear` on some hardware.</param>
742742
/// <returns>A new TextureHandle that represents the imported texture in the context of this rendergraph.</returns>
743-
public TextureHandle ImportTexture(RTHandle rt, RenderTargetInfo info, ImportResourceParams importParams = new ImportResourceParams() )
743+
public TextureHandle ImportTexture(RTHandle rt, RenderTargetInfo info, ImportResourceParams importParams = new ImportResourceParams())
744744
{
745745
CheckNotUsedWhenExecuting();
746746

Packages/com.unity.render-pipelines.core/Runtime/RenderGraph/RenderGraphResourceTexture.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@ public struct TextureDesc
170170
public int width;
171171
///<summary>Texture height.</summary>
172172
public int height;
173-
///<summary>Number of texture slices..</summary>
173+
///<summary>Number of texture slices.</summary>
174174
public int slices;
175175
///<summary>Texture scale.</summary>
176176
public Vector2 scale;

Packages/com.unity.render-pipelines.core/Runtime/RenderGraph/RenderGraphUtilsBlit.cs

Lines changed: 38 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -236,9 +236,11 @@ class BlitPassData
236236
/// <param name="numMips"> The number of mipmaps to copy. -1 to copy all mipmaps. Arguments that copy invalid mips to be copied will lead to an error.</param>
237237
/// <param name="filterMode">The filtering used when blitting from source to destination.</param>
238238
/// <param name="passName">A name to use for debugging and error logging. This name will be shown in the rendergraph debugger. </param>
239+
/// <param name="returnBuilder">A boolean indicating whether to return the builder instance for the blit pass.</param>
239240
/// <param name="file">File line of the source file this function is called from. Used for debugging. This parameter is automatically generated by the compiler. Users do not need to pass it.</param>
240241
/// <param name="line">File line of the source file this function is called from. Used for debugging. This parameter is automatically generated by the compiler. Users do not need to pass it.</param>
241-
public static void AddBlitPass(this RenderGraph graph,
242+
/// <returns>A new instance of IBaseRenderGraphBuilder used to setup the new Render Pass, returned only if <paramref name="returnBuilder"/> is set to <c>true</c>or <c>null</c> if <paramref name="returnBuilder"/> is <c>false</c>.</returns>
243+
public static IBaseRenderGraphBuilder AddBlitPass(this RenderGraph graph,
242244
TextureHandle source,
243245
TextureHandle destination,
244246
Vector2 scale,
@@ -250,7 +252,8 @@ public static void AddBlitPass(this RenderGraph graph,
250252
int destinationMip = 0,
251253
int numMips = 1,
252254
BlitFilterMode filterMode = BlitFilterMode.ClampBilinear,
253-
string passName = "Blit Pass Utility"
255+
string passName = "Blit Pass Utility",
256+
bool returnBuilder = false
254257
#if !CORE_PACKAGE_DOCTOOLS
255258
, [CallerFilePath] string file = "",
256259
[CallerLineNumber] int line = 0)
@@ -278,8 +281,10 @@ public static void AddBlitPass(this RenderGraph graph,
278281
throw new ArgumentException($"BlitPass: {passName} attempts to blit too many mips. The pass will be skipped.");
279282
}
280283

281-
using (var builder = graph.AddUnsafePass<BlitPassData>(passName, out var passData, file, line))
284+
var builder = graph.AddUnsafePass<BlitPassData>(passName, out var passData, file, line);
285+
try
282286
{
287+
passData.isXR = IsTextureXR(ref destinationDesc, sourceSlice, destinationSlice, numSlices, numMips);
283288
passData.source = source;
284289
passData.destination = destination;
285290
passData.scale = scale;
@@ -291,12 +296,23 @@ public static void AddBlitPass(this RenderGraph graph,
291296
passData.destinationMip = destinationMip;
292297
passData.numMips = numMips;
293298
passData.filterMode = filterMode;
294-
passData.isXR = IsTextureXR(ref destinationDesc, sourceSlice, destinationSlice, numSlices, numMips);
295299
builder.UseTexture(source, AccessFlags.Read);
296300
builder.UseTexture(destination, AccessFlags.Write);
297301
builder.SetRenderFunc((BlitPassData data, UnsafeGraphContext context) => BlitRenderFunc(data, context));
298302
}
303+
catch
304+
{
305+
builder.Dispose();
306+
throw;
307+
}
308+
309+
if (returnBuilder)
310+
return builder;
311+
312+
builder.Dispose();
313+
return null;
299314
}
315+
300316
static Vector4 s_BlitScaleBias = new Vector4();
301317
static void BlitRenderFunc(BlitPassData data, UnsafeGraphContext context)
302318
{
@@ -754,12 +770,15 @@ class BlitMaterialPassData
754770
/// </summary>
755771
/// <param name="graph">The RenderGraph adding this pass to.</param>
756772
/// <param name="blitParameters">Parameters used for rendering.</param>
773+
/// <param name="returnBuilder">A boolean indicating whether to return the builder instance for the blit pass.</param>
757774
/// <param name="passName">A name to use for debugging and error logging. This name will be shown in the rendergraph debugger. </param>
758775
/// <param name="file">File line of the source file this function is called from. Used for debugging. This parameter is automatically generated by the compiler. Users do not need to pass it.</param>
759776
/// <param name="line">File line of the source file this function is called from. Used for debugging. This parameter is automatically generated by the compiler. Users do not need to pass it.</param>
760-
public static void AddBlitPass(this RenderGraph graph,
777+
/// <returns>A new instance of IBaseRenderGraphBuilder used to setup the new Render Pass, returned only if <paramref name="returnBuilder"/> is set to <c>true</c>or <c>null</c> if <paramref name="returnBuilder"/> is <c>false</c>.</returns>
778+
public static IBaseRenderGraphBuilder AddBlitPass(this RenderGraph graph,
761779
BlitMaterialParameters blitParameters,
762-
string passName = "Blit Pass Utility w. Material"
780+
string passName = "Blit Pass Utility w. Material",
781+
bool returnBuilder = false
763782
#if !CORE_PACKAGE_DOCTOOLS
764783
, [CallerFilePath] string file = "",
765784
[CallerLineNumber] int line = 0)
@@ -814,7 +833,8 @@ public static void AddBlitPass(this RenderGraph graph,
814833
throw new ArgumentException($"BlitPass: {passName} attempts to blit too many mips. There are not enough mips in the destination texture. The pass will be skipped.");
815834
}
816835

817-
using (var builder = graph.AddUnsafePass<BlitMaterialPassData>(passName, out var passData, file, line))
836+
var builder = graph.AddUnsafePass<BlitMaterialPassData>(passName, out var passData, file, line);
837+
try
818838
{
819839
passData.sourceTexturePropertyID = blitParameters.sourceTexturePropertyID;
820840
passData.source = blitParameters.source;
@@ -835,15 +855,24 @@ public static void AddBlitPass(this RenderGraph graph,
835855
passData.sourceMipPropertyID = blitParameters.sourceMipPropertyID;
836856
passData.scaleBiasPropertyID = blitParameters.scaleBiasPropertyID;
837857
passData.isXR = IsTextureXR(ref destinationDesc, (passData.sourceSlice == -1) ? 0 : passData.sourceSlice, passData.destinationSlice, passData.numSlices, passData.numMips);
838-
839858
if (blitParameters.source.IsValid())
840859
{
841860
builder.UseTexture(blitParameters.source);
842861
}
843-
844862
builder.UseTexture(blitParameters.destination, AccessFlags.Write);
845863
builder.SetRenderFunc((BlitMaterialPassData data, UnsafeGraphContext context) => BlitMaterialRenderFunc(data, context));
846864
}
865+
catch
866+
{
867+
builder.Dispose();
868+
throw;
869+
}
870+
871+
if (returnBuilder)
872+
return builder;
873+
874+
builder.Dispose();
875+
return null;
847876
}
848877

849878
static void BlitMaterialRenderFunc(BlitMaterialPassData data, UnsafeGraphContext context)

Packages/com.unity.render-pipelines.core/Runtime/Textures/TextureXR.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ public static bool useTexArray
4343
case GraphicsDeviceType.PlayStation5NGGC:
4444
case GraphicsDeviceType.Vulkan:
4545
case GraphicsDeviceType.Metal:
46+
case GraphicsDeviceType.OpenGLES3:
4647
return true;
4748

4849
default:

Packages/com.unity.render-pipelines.core/ShaderLibrary/HDROutput.hlsl

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,17 @@ float3 RotateRec2020ToP3D65(float3 Rec2020Input)
151151
return mul(Rec2020ToP3D65Mat, Rec2020Input);
152152
}
153153

154+
float3 RotateP3D65ToRec709(float3 P3D65Input)
155+
{
156+
static const float3x3 P3D65ToRec709Mat = float3x3(
157+
1.224940, -0.224940, 0.000000,
158+
-0.042057, 1.042057, 0.000000,
159+
-0.019638, -0.078635, 1.098274
160+
);
161+
162+
return mul(P3D65ToRec709Mat, P3D65Input);
163+
}
164+
154165
float3 RotateP3D65ToRec2020(float3 P3D65Input)
155166
{
156167
static const float3x3 P3D65ToRec2020Mat = float3x3(
@@ -195,6 +206,22 @@ float3 RotateRec2020ToOutputSpace(float3 Rec2020Input)
195206
}
196207
}
197208

209+
float3 RotateOutputSpaceToRec709(float3 ODTInput)
210+
{
211+
if (_HDRColorspace == HDRCOLORSPACE_REC2020)
212+
{
213+
return RotateRec2020ToRec709(ODTInput);
214+
}
215+
else if (_HDRColorspace == HDRCOLORSPACE_P3D65)
216+
{
217+
return RotateP3D65ToRec709(ODTInput);
218+
}
219+
else // HDRCOLORSPACE_REC709
220+
{
221+
return ODTInput;
222+
}
223+
}
224+
198225

199226
float3 RotateRec2020ToLMS(float3 Rec2020Input)
200227
{
Lines changed: 115 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,115 @@
1+
using NUnit.Framework;
2+
using UnityEngine.Experimental.Rendering;
3+
using UnityEngine.Rendering.RenderGraphModule;
4+
using UnityEngine.Rendering.RenderGraphModule.Util;
5+
6+
#if UNITY_EDITOR
7+
using UnityEditor;
8+
using UnityEditor.Rendering;
9+
#endif
10+
11+
namespace UnityEngine.Rendering.Tests
12+
{
13+
partial class RenderGraphTests
14+
{
15+
class TestBlitResources
16+
{
17+
public TextureHandle[] textures = new TextureHandle[2];
18+
public Material material;
19+
public RenderGraphUtils.BlitMaterialParameters blitParameters;
20+
};
21+
22+
TestBlitResources CreateBlitResources(RenderGraph g)
23+
{
24+
TestBlitResources result = new TestBlitResources();
25+
26+
result.material = new Material(Shader.Find("Hidden/BlitCopy"));
27+
28+
for (int i = 0; i < result.textures.Length; i++)
29+
{
30+
result.textures[i] = g.CreateTexture(new TextureDesc(Vector2.one) { colorFormat = GraphicsFormat.R8G8B8A8_UNorm });
31+
}
32+
33+
result.blitParameters = new(result.textures[0], result.textures[1], result.material, 0);
34+
35+
return result;
36+
}
37+
38+
[Test]
39+
public void RenderPassAddBlitReturnBuilder()
40+
{
41+
var resources = CreateBlitResources(m_RenderGraph);
42+
43+
var builderNull = m_RenderGraph.AddBlitPass(resources.blitParameters, "Test Pass", false);
44+
Assert.IsNull(builderNull);
45+
46+
var builder = m_RenderGraph.AddBlitPass(resources.blitParameters, "Test Pass", true);
47+
Assert.IsNotNull(builder);
48+
builder.Dispose();
49+
50+
builderNull = m_RenderGraph.AddBlitPass(resources.textures[0], resources.textures[1], Vector2.one, Vector2.zero, passName:"Test Pass", returnBuilder:false);
51+
Assert.IsNull(builderNull);
52+
53+
builder = m_RenderGraph.AddBlitPass(resources.textures[0], resources.textures[1], Vector2.one, Vector2.zero, passName:"Test Pass", returnBuilder:true);
54+
Assert.IsNotNull(builder);
55+
builder.Dispose();
56+
}
57+
58+
[Test]
59+
public void RenderPassAddBlitSetGlobal()
60+
{
61+
int texture0ID = 0;
62+
int texture1ID = 1;
63+
var resources = CreateBlitResources(m_RenderGraph);
64+
65+
using(var builder = m_RenderGraph.AddBlitPass(resources.blitParameters, "Test Pass", true ))
66+
{
67+
builder.SetGlobalTextureAfterPass(resources.textures[0], texture0ID);
68+
}
69+
Assert.IsTrue(m_RenderGraph.IsGlobal(texture0ID));
70+
71+
using(var builder = m_RenderGraph.AddBlitPass(resources.textures[0], resources.textures[1], Vector2.one, Vector2.zero, passName: "Test Pass", returnBuilder: true ))
72+
{
73+
builder.SetGlobalTextureAfterPass(resources.textures[1], texture1ID);
74+
}
75+
Assert.IsTrue(m_RenderGraph.IsGlobal(texture1ID));
76+
}
77+
78+
79+
[Test]
80+
public void RenderPassAddBlitUseTexture()
81+
{
82+
var resources = CreateBlitResources(m_RenderGraph);
83+
84+
// Writing to the texture blitting is the same as writing the same texture twice, is not allowed.
85+
using (var builder = m_RenderGraph.AddBlitPass(resources.blitParameters, "BlitPass", true ))
86+
{
87+
Assert.Throws<System.InvalidOperationException>(() =>
88+
{
89+
builder.UseTexture(resources.textures[1], AccessFlags.Write);
90+
});
91+
}
92+
93+
// Writing to the texture blitting is the same as writing the same texture twice, is not allowed.
94+
using (var builder = m_RenderGraph.AddBlitPass(resources.textures[0], resources.textures[1], Vector2.one, Vector2.zero, passName: "Test Pass", returnBuilder: true))
95+
{
96+
Assert.Throws<System.InvalidOperationException>(() =>
97+
{
98+
builder.UseTexture(resources.textures[1], AccessFlags.Write);
99+
});
100+
}
101+
102+
// Reading the same texture twice is allowed
103+
using (var builder = m_RenderGraph.AddBlitPass(resources.blitParameters, "BlitPass", true ))
104+
{
105+
builder.UseTexture(resources.textures[0], AccessFlags.Read);
106+
}
107+
108+
// Reading the same texture twice is allowed
109+
using (var builder = m_RenderGraph.AddBlitPass(resources.textures[0], resources.textures[1], Vector2.one, Vector2.zero, passName: "Test Pass", returnBuilder: true))
110+
{
111+
builder.UseTexture(resources.textures[0], AccessFlags.Read);
112+
}
113+
}
114+
}
115+
}

0 commit comments

Comments
 (0)