Skip to content

Internal/master #8152

New issue

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

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

Already on GitHub? Sign in to your account

Merged
merged 17 commits into from
May 19, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
17 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions Packages/com.unity.render-pipelines.core/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,16 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
Version Updated
The version number for this package has increased due to a version update of a related graphics package.

## [17.2.0] - 2025-05-14

This version is compatible with Unity 6000.2.0b2.

### Fixed
- Fixed an editor crash that could sometimes occur when throwing an exception from `Dispose()` in a custom SRP renderer feature.
- Fixed a memory leak that occurred when entering and exiting Play mode in the Editor.
- Fixed an issue where the *Add Override* button in the Global Volume's Inspector panel did not work correctly on Linux.
- Fix out of bounds read in CoreUnsafeUtils.FixedBufferStringQueue.TryPop when the remaining bytes in the buffer is less than 4

## [17.0.3] - 2025-02-13

This version is compatible with Unity 6000.2.0a17.
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
---
uid: srp-core-api-index
---

# Scriptable Render Pipeline Core scripting API

This is the documentation for the scripting APIs of the Scriptable Render Pipeline (SRP) Core package.

**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:

- [Universal Render Pipeline (URP) Scripting API](https://docs.unity3d.com/Packages/[email protected]/api/index.html)
- [High Definition Render Pipeline (HDRP) Scripting API](https://docs.unity3d.com/Packages/[email protected]/api/index.html)
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,8 @@ public static GUIStyle miniLabelButton

/// <summary> Warning icon </summary>
public static readonly Texture2D iconWarn;
/// <summary> Info icon </summary>
public static readonly Texture2D iconInfo;
/// <summary> Help icon </summary>
public static readonly Texture2D iconHelp;
/// <summary> Fail icon </summary>
Expand All @@ -144,7 +146,7 @@ internal static Texture2D GetMessageTypeIcon(MessageType messageType)
case MessageType.None:
return null;
case MessageType.Info:
return iconHelp;
return iconInfo;
case MessageType.Warning:
return iconWarn;
case MessageType.Error:
Expand Down Expand Up @@ -215,7 +217,8 @@ static CoreEditorStyles()
greenTexture = CoreEditorUtils.CreateColoredTexture2D(Color.green, "Green 1x1");
blueTexture = CoreEditorUtils.CreateColoredTexture2D(Color.blue, "Blue 1x1");

iconHelp = CoreEditorUtils.LoadIcon("icons", "console.infoicon", ".png");
iconHelp = CoreEditorUtils.LoadIcon("icons", "_Help", ".png");
iconInfo = CoreEditorUtils.LoadIcon("icons", "console.infoicon", ".png");
iconWarn = CoreEditorUtils.LoadIcon("icons", "console.warnicon", ".png");
iconFail = CoreEditorUtils.LoadIcon("icons", "console.erroricon", ".png");
iconSuccess = EditorGUIUtility.FindTexture("TestPassed");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ public sealed class DebugStateInt : DebugState<int> { }
/// <summary>
/// Object Debug State.
/// </summary>
[Serializable, DebugState(typeof(DebugUI.ObjectPopupField), typeof(DebugUI.CameraSelector))]
[Serializable, DebugState(typeof(DebugUI.ObjectPopupField), typeof(DebugUI.CameraSelector), typeof(DebugUI.ObjectField))]
public sealed class DebugStateObject : DebugState<UnityEngine.Object>
{
/// <summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -717,7 +717,7 @@ public TextureHandle ImportShadingRateImageTexture(RTHandle rt)
/// <param name="rt">External RTHandle that needs to be imported.</param>
/// <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>
/// <returns>A new TextureHandle that represents the imported texture in the context of this rendergraph.</returns>
public TextureHandle ImportTexture(RTHandle rt, ImportResourceParams importParams )
public TextureHandle ImportTexture(RTHandle rt, ImportResourceParams importParams)
{
CheckNotUsedWhenExecuting();

Expand All @@ -740,7 +740,7 @@ public TextureHandle ImportTexture(RTHandle rt, ImportResourceParams importParam
/// <param name="info">The properties of the passed in RTHandle.</param>
/// <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>
/// <returns>A new TextureHandle that represents the imported texture in the context of this rendergraph.</returns>
public TextureHandle ImportTexture(RTHandle rt, RenderTargetInfo info, ImportResourceParams importParams = new ImportResourceParams() )
public TextureHandle ImportTexture(RTHandle rt, RenderTargetInfo info, ImportResourceParams importParams = new ImportResourceParams())
{
CheckNotUsedWhenExecuting();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ public struct TextureDesc
public int width;
///<summary>Texture height.</summary>
public int height;
///<summary>Number of texture slices..</summary>
///<summary>Number of texture slices.</summary>
public int slices;
///<summary>Texture scale.</summary>
public Vector2 scale;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -236,9 +236,11 @@ class BlitPassData
/// <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>
/// <param name="filterMode">The filtering used when blitting from source to destination.</param>
/// <param name="passName">A name to use for debugging and error logging. This name will be shown in the rendergraph debugger. </param>
/// <param name="returnBuilder">A boolean indicating whether to return the builder instance for the blit pass.</param>
/// <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>
/// <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>
public static void AddBlitPass(this RenderGraph graph,
/// <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>
public static IBaseRenderGraphBuilder AddBlitPass(this RenderGraph graph,
TextureHandle source,
TextureHandle destination,
Vector2 scale,
Expand All @@ -250,7 +252,8 @@ public static void AddBlitPass(this RenderGraph graph,
int destinationMip = 0,
int numMips = 1,
BlitFilterMode filterMode = BlitFilterMode.ClampBilinear,
string passName = "Blit Pass Utility"
string passName = "Blit Pass Utility",
bool returnBuilder = false
#if !CORE_PACKAGE_DOCTOOLS
, [CallerFilePath] string file = "",
[CallerLineNumber] int line = 0)
Expand Down Expand Up @@ -278,8 +281,10 @@ public static void AddBlitPass(this RenderGraph graph,
throw new ArgumentException($"BlitPass: {passName} attempts to blit too many mips. The pass will be skipped.");
}

using (var builder = graph.AddUnsafePass<BlitPassData>(passName, out var passData, file, line))
var builder = graph.AddUnsafePass<BlitPassData>(passName, out var passData, file, line);
try
{
passData.isXR = IsTextureXR(ref destinationDesc, sourceSlice, destinationSlice, numSlices, numMips);
passData.source = source;
passData.destination = destination;
passData.scale = scale;
Expand All @@ -291,12 +296,23 @@ public static void AddBlitPass(this RenderGraph graph,
passData.destinationMip = destinationMip;
passData.numMips = numMips;
passData.filterMode = filterMode;
passData.isXR = IsTextureXR(ref destinationDesc, sourceSlice, destinationSlice, numSlices, numMips);
builder.UseTexture(source, AccessFlags.Read);
builder.UseTexture(destination, AccessFlags.Write);
builder.SetRenderFunc((BlitPassData data, UnsafeGraphContext context) => BlitRenderFunc(data, context));
}
catch
{
builder.Dispose();
throw;
}

if (returnBuilder)
return builder;

builder.Dispose();
return null;
}

static Vector4 s_BlitScaleBias = new Vector4();
static void BlitRenderFunc(BlitPassData data, UnsafeGraphContext context)
{
Expand Down Expand Up @@ -754,12 +770,15 @@ class BlitMaterialPassData
/// </summary>
/// <param name="graph">The RenderGraph adding this pass to.</param>
/// <param name="blitParameters">Parameters used for rendering.</param>
/// <param name="returnBuilder">A boolean indicating whether to return the builder instance for the blit pass.</param>
/// <param name="passName">A name to use for debugging and error logging. This name will be shown in the rendergraph debugger. </param>
/// <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>
/// <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>
public static void AddBlitPass(this RenderGraph graph,
/// <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>
public static IBaseRenderGraphBuilder AddBlitPass(this RenderGraph graph,
BlitMaterialParameters blitParameters,
string passName = "Blit Pass Utility w. Material"
string passName = "Blit Pass Utility w. Material",
bool returnBuilder = false
#if !CORE_PACKAGE_DOCTOOLS
, [CallerFilePath] string file = "",
[CallerLineNumber] int line = 0)
Expand Down Expand Up @@ -814,7 +833,8 @@ public static void AddBlitPass(this RenderGraph graph,
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.");
}

using (var builder = graph.AddUnsafePass<BlitMaterialPassData>(passName, out var passData, file, line))
var builder = graph.AddUnsafePass<BlitMaterialPassData>(passName, out var passData, file, line);
try
{
passData.sourceTexturePropertyID = blitParameters.sourceTexturePropertyID;
passData.source = blitParameters.source;
Expand All @@ -835,15 +855,24 @@ public static void AddBlitPass(this RenderGraph graph,
passData.sourceMipPropertyID = blitParameters.sourceMipPropertyID;
passData.scaleBiasPropertyID = blitParameters.scaleBiasPropertyID;
passData.isXR = IsTextureXR(ref destinationDesc, (passData.sourceSlice == -1) ? 0 : passData.sourceSlice, passData.destinationSlice, passData.numSlices, passData.numMips);

if (blitParameters.source.IsValid())
{
builder.UseTexture(blitParameters.source);
}

builder.UseTexture(blitParameters.destination, AccessFlags.Write);
builder.SetRenderFunc((BlitMaterialPassData data, UnsafeGraphContext context) => BlitMaterialRenderFunc(data, context));
}
catch
{
builder.Dispose();
throw;
}

if (returnBuilder)
return builder;

builder.Dispose();
return null;
}

static void BlitMaterialRenderFunc(BlitMaterialPassData data, UnsafeGraphContext context)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ public static bool useTexArray
case GraphicsDeviceType.PlayStation5NGGC:
case GraphicsDeviceType.Vulkan:
case GraphicsDeviceType.Metal:
case GraphicsDeviceType.OpenGLES3:
return true;

default:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,17 @@ float3 RotateRec2020ToP3D65(float3 Rec2020Input)
return mul(Rec2020ToP3D65Mat, Rec2020Input);
}

float3 RotateP3D65ToRec709(float3 P3D65Input)
{
static const float3x3 P3D65ToRec709Mat = float3x3(
1.224940, -0.224940, 0.000000,
-0.042057, 1.042057, 0.000000,
-0.019638, -0.078635, 1.098274
);

return mul(P3D65ToRec709Mat, P3D65Input);
}

float3 RotateP3D65ToRec2020(float3 P3D65Input)
{
static const float3x3 P3D65ToRec2020Mat = float3x3(
Expand Down Expand Up @@ -195,6 +206,22 @@ float3 RotateRec2020ToOutputSpace(float3 Rec2020Input)
}
}

float3 RotateOutputSpaceToRec709(float3 ODTInput)
{
if (_HDRColorspace == HDRCOLORSPACE_REC2020)
{
return RotateRec2020ToRec709(ODTInput);
}
else if (_HDRColorspace == HDRCOLORSPACE_P3D65)
{
return RotateP3D65ToRec709(ODTInput);
}
else // HDRCOLORSPACE_REC709
{
return ODTInput;
}
}


float3 RotateRec2020ToLMS(float3 Rec2020Input)
{
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,115 @@
using NUnit.Framework;
using UnityEngine.Experimental.Rendering;
using UnityEngine.Rendering.RenderGraphModule;
using UnityEngine.Rendering.RenderGraphModule.Util;

#if UNITY_EDITOR
using UnityEditor;
using UnityEditor.Rendering;
#endif

namespace UnityEngine.Rendering.Tests
{
partial class RenderGraphTests
{
class TestBlitResources
{
public TextureHandle[] textures = new TextureHandle[2];
public Material material;
public RenderGraphUtils.BlitMaterialParameters blitParameters;
};

TestBlitResources CreateBlitResources(RenderGraph g)
{
TestBlitResources result = new TestBlitResources();

result.material = new Material(Shader.Find("Hidden/BlitCopy"));

for (int i = 0; i < result.textures.Length; i++)
{
result.textures[i] = g.CreateTexture(new TextureDesc(Vector2.one) { colorFormat = GraphicsFormat.R8G8B8A8_UNorm });
}

result.blitParameters = new(result.textures[0], result.textures[1], result.material, 0);

return result;
}

[Test]
public void RenderPassAddBlitReturnBuilder()
{
var resources = CreateBlitResources(m_RenderGraph);

var builderNull = m_RenderGraph.AddBlitPass(resources.blitParameters, "Test Pass", false);
Assert.IsNull(builderNull);

var builder = m_RenderGraph.AddBlitPass(resources.blitParameters, "Test Pass", true);
Assert.IsNotNull(builder);
builder.Dispose();

builderNull = m_RenderGraph.AddBlitPass(resources.textures[0], resources.textures[1], Vector2.one, Vector2.zero, passName:"Test Pass", returnBuilder:false);
Assert.IsNull(builderNull);

builder = m_RenderGraph.AddBlitPass(resources.textures[0], resources.textures[1], Vector2.one, Vector2.zero, passName:"Test Pass", returnBuilder:true);
Assert.IsNotNull(builder);
builder.Dispose();
}

[Test]
public void RenderPassAddBlitSetGlobal()
{
int texture0ID = 0;
int texture1ID = 1;
var resources = CreateBlitResources(m_RenderGraph);

using(var builder = m_RenderGraph.AddBlitPass(resources.blitParameters, "Test Pass", true ))
{
builder.SetGlobalTextureAfterPass(resources.textures[0], texture0ID);
}
Assert.IsTrue(m_RenderGraph.IsGlobal(texture0ID));

using(var builder = m_RenderGraph.AddBlitPass(resources.textures[0], resources.textures[1], Vector2.one, Vector2.zero, passName: "Test Pass", returnBuilder: true ))
{
builder.SetGlobalTextureAfterPass(resources.textures[1], texture1ID);
}
Assert.IsTrue(m_RenderGraph.IsGlobal(texture1ID));
}


[Test]
public void RenderPassAddBlitUseTexture()
{
var resources = CreateBlitResources(m_RenderGraph);

// Writing to the texture blitting is the same as writing the same texture twice, is not allowed.
using (var builder = m_RenderGraph.AddBlitPass(resources.blitParameters, "BlitPass", true ))
{
Assert.Throws<System.InvalidOperationException>(() =>
{
builder.UseTexture(resources.textures[1], AccessFlags.Write);
});
}

// Writing to the texture blitting is the same as writing the same texture twice, is not allowed.
using (var builder = m_RenderGraph.AddBlitPass(resources.textures[0], resources.textures[1], Vector2.one, Vector2.zero, passName: "Test Pass", returnBuilder: true))
{
Assert.Throws<System.InvalidOperationException>(() =>
{
builder.UseTexture(resources.textures[1], AccessFlags.Write);
});
}

// Reading the same texture twice is allowed
using (var builder = m_RenderGraph.AddBlitPass(resources.blitParameters, "BlitPass", true ))
{
builder.UseTexture(resources.textures[0], AccessFlags.Read);
}

// Reading the same texture twice is allowed
using (var builder = m_RenderGraph.AddBlitPass(resources.textures[0], resources.textures[1], Vector2.one, Vector2.zero, passName: "Test Pass", returnBuilder: true))
{
builder.UseTexture(resources.textures[0], AccessFlags.Read);
}
}
}
}

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

4 changes: 2 additions & 2 deletions Packages/com.unity.render-pipelines.core/package.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
{
"name": "com.unity.render-pipelines.core",
"description": "SRP Core makes it easier to create or customize a Scriptable Render Pipeline (SRP). SRP Core contains reusable code, including boilerplate code for working with platform-specific graphics APIs, utility functions for common rendering operations, and shader libraries. The code in SRP Core is use by the High Definition Render Pipeline (HDRP) and Universal Render Pipeline (URP). If you are creating a custom SRP from scratch or customizing a prebuilt SRP, using SRP Core will save you time.",
"version": "17.2.0",
"unity": "6000.2",
"version": "17.3.0",
"unity": "6000.3",
"displayName": "Scriptable Render Pipeline Core",
"dependencies": {
"com.unity.burst": "1.8.14",
Expand Down
Loading