Skip to content

Commit

Permalink
com.unity.render-pipelines.core@10.9.0
Browse files Browse the repository at this point in the history
## [10.9.0] - 2021-12-06

Version Updated
The version number for this package has increased due to a version update of a related graphics package.
  • Loading branch information
Unity Technologies committed Dec 6, 2021
1 parent 3d44e64 commit 0d93fcb
Show file tree
Hide file tree
Showing 9 changed files with 77 additions and 21 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ All notable changes to this package will be documented in this file.
The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).

## [10.8.1] - 2021-12-16
## [10.9.0] - 2021-12-06

Version Updated
The version number for this package has increased due to a version update of a related graphics package.
Expand Down
15 changes: 12 additions & 3 deletions Runtime/Common/DynamicResolutionHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -382,7 +382,7 @@ public void ForceSoftwareFallback()

/// <summary>
/// Applies to the passed size the scale imposed by the dynamic resolution system.
/// Note: this function has the side effect of caching the last scale size.
/// Note: this function has the side effect of caching the last scale size, and the output is always smaller or equal then the input.
/// </summary>
/// <param name="size">The starting size of the render target that will be scaled by dynamic resolution.</param>
/// <returns>The parameter size scaled by the dynamic resolution system.</returns>
Expand All @@ -396,26 +396,35 @@ public Vector2Int GetScaledSize(Vector2Int size)
}

Vector2Int scaledSize = ApplyScalesOnSize(size);

m_LastScaledSize = scaledSize;
return scaledSize;
}

/// <summary>
/// Applies to the passed size the scale imposed by the dynamic resolution system.
/// This function uses the internal resolved scale from the dynamic resolution system.
/// Note: this function is pure (has no side effects), this function does not cache the pre-scale size
/// </summary>
/// <param name="size">The size to apply the scaling</param>
/// <returns>The parameter size scaled by the dynamic resolution system.</returns>
public Vector2Int ApplyScalesOnSize(Vector2Int size)
{
Vector2 resolvedScales = GetResolvedScale();
Vector2Int scaledSize = new Vector2Int(Mathf.CeilToInt(size.x * resolvedScales.x), Mathf.CeilToInt(size.y * resolvedScales.y));
return ApplyScalesOnSize(size, GetResolvedScale());
}

internal Vector2Int ApplyScalesOnSize(Vector2Int size, Vector2 scales)
{
Vector2Int scaledSize = new Vector2Int(Mathf.CeilToInt(size.x * scales.x), Mathf.CeilToInt(size.y * scales.y));
if (m_ForceSoftwareFallback || type != DynamicResolutionType.Hardware)
{
scaledSize.x += (1 & scaledSize.x);
scaledSize.y += (1 & scaledSize.y);
}

scaledSize.x = Math.Min(scaledSize.x, size.x);
scaledSize.y = Math.Min(scaledSize.y, size.y);

return scaledSize;
}

Expand Down
2 changes: 1 addition & 1 deletion Runtime/Documentation.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ public class DocumentationInfo
/// <summary>
/// Current version of the documentation.
/// </summary>
public const string version = "10.8";
public const string version = "10.9";
}

//Need to live in Runtime as Attribute of documentation is on Runtime classes \o/
Expand Down
1 change: 1 addition & 0 deletions Runtime/RenderGraph/RenderGraph.cs
Original file line number Diff line number Diff line change
Expand Up @@ -316,6 +316,7 @@ public void Cleanup()
m_DebugParameters.UnRegisterDebug(this.name);
m_Resources.Cleanup();
m_DefaultResources.Cleanup();
m_RenderGraphPool.Cleanup();

s_RegisteredGraphs.Remove(this);
onGraphUnregistered?.Invoke(this);
Expand Down
37 changes: 35 additions & 2 deletions Runtime/RenderGraph/RenderGraphObjectPool.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,20 @@ namespace UnityEngine.Experimental.Rendering.RenderGraphModule
/// </summary>
public sealed class RenderGraphObjectPool
{
class SharedObjectPool<T> where T : new()
abstract class SharedObjectPoolBase
{
protected static List<SharedObjectPoolBase> s_AllocatedPools = new List<SharedObjectPoolBase>();

protected abstract void Clear();

public static void ClearAll()
{
foreach (var pool in s_AllocatedPools)
pool.Clear();
}
}

class SharedObjectPool<T> : SharedObjectPoolBase where T : new()
{
Stack<T> m_Pool = new Stack<T>();

Expand All @@ -24,7 +37,19 @@ public void Release(T value)
m_Pool.Push(value);
}

static readonly Lazy<SharedObjectPool<T>> s_Instance = new Lazy<SharedObjectPool<T>>();
static SharedObjectPool<T> AllocatePool()
{
var pool = new SharedObjectPool<T>();
s_AllocatedPools.Add(pool);
return pool;
}

override protected void Clear()
{
m_Pool.Clear();
}

static readonly Lazy<SharedObjectPool<T>> s_Instance = new Lazy<SharedObjectPool<T>>(AllocatePool);
public static SharedObjectPool<T> sharedPool => s_Instance.Value;
}

Expand Down Expand Up @@ -97,5 +122,13 @@ internal void ReleaseAllTempAlloc()
var pool = SharedObjectPool<T>.sharedPool;
pool.Release(value);
}

internal void Cleanup()
{
m_AllocatedArrays.Clear();
m_AllocatedMaterialPropertyBlocks.Clear();
m_ArrayPool.Clear();
SharedObjectPoolBase.ClearAll();
}
}
}
28 changes: 19 additions & 9 deletions Runtime/Textures/RTHandleSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -217,25 +217,35 @@ public void SetReferenceSize(int width, int height, MSAASamples msaaSamples, boo
lastFrameMaxSize = new Vector2(GetMaxWidth(), GetMaxHeight());
}

var scales = CalculateRatioAgainstMaxSize(m_RTHandleProperties.currentViewportSize);
if (DynamicResolutionHandler.instance.HardwareDynamicResIsEnabled() && m_HardwareDynamicResRequested)
{
Vector2Int maxSize = new Vector2Int(GetMaxWidth(), GetMaxHeight());
// Making the final scale in 'drs' space, since the final scale must account for rounding pixel values.
var scaledFinalViewport = DynamicResolutionHandler.instance.ApplyScalesOnSize(DynamicResolutionHandler.instance.finalViewport);
var scaledMaxSize = DynamicResolutionHandler.instance.ApplyScalesOnSize(maxSize);
float xScale = (float)scaledFinalViewport.x / (float)scaledMaxSize.x;
float yScale = (float)scaledFinalViewport.y / (float)scaledMaxSize.y;
m_RTHandleProperties.rtHandleScale = new Vector4(xScale, yScale, m_RTHandleProperties.rtHandleScale.x, m_RTHandleProperties.rtHandleScale.y);
m_RTHandleProperties.rtHandleScale = new Vector4(scales.x, scales.y, m_RTHandleProperties.rtHandleScale.x, m_RTHandleProperties.rtHandleScale.y);
}
else
{
Vector2 maxSize = new Vector2(GetMaxWidth(), GetMaxHeight());
Vector2 scaleCurrent = m_RTHandleProperties.currentViewportSize / maxSize;
Vector2 scalePrevious = m_RTHandleProperties.previousViewportSize / lastFrameMaxSize;
m_RTHandleProperties.rtHandleScale = new Vector4(scaleCurrent.x, scaleCurrent.y, scalePrevious.x, scalePrevious.y);
m_RTHandleProperties.rtHandleScale = new Vector4(scales.x, scales.y, scalePrevious.x, scalePrevious.y);
}
}

internal Vector2 CalculateRatioAgainstMaxSize(in Vector2Int viewportSize)
{
Vector2 maxSize = new Vector2(GetMaxWidth(), GetMaxHeight());

if (DynamicResolutionHandler.instance.HardwareDynamicResIsEnabled() && m_HardwareDynamicResRequested && viewportSize != DynamicResolutionHandler.instance.finalViewport)
{
//for hardware resolution, the final goal is to figure out a scale from finalViewport into maxViewport.
//This is however wrong! because the actualViewport might not fit the finalViewport perfectly, due to rounding.
//A correct way is to instead downscale the maxViewport, and keep the final scale in terms of downsampled buffers.
Vector2 currentScale = (Vector2)viewportSize / (Vector2)DynamicResolutionHandler.instance.finalViewport;
maxSize = DynamicResolutionHandler.instance.ApplyScalesOnSize(new Vector2Int(GetMaxWidth(), GetMaxHeight()), currentScale);
}

return new Vector2((float)viewportSize.x / maxSize.x, (float)viewportSize.y / maxSize.y);
}

/// <summary>
/// Enable or disable hardware dynamic resolution for the RTHandle System
/// </summary>
Expand Down
2 changes: 1 addition & 1 deletion ShaderLibrary/Version.hlsl
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#define SHADER_LIBRARY_VERSION_MAJOR 10
#define SHADER_LIBRARY_VERSION_MINOR 8
#define SHADER_LIBRARY_VERSION_MINOR 9

#define VERSION_GREATER_EQUAL(major, minor) ((SHADER_LIBRARY_VERSION_MAJOR > major) || ((SHADER_LIBRARY_VERSION_MAJOR == major) && (SHADER_LIBRARY_VERSION_MINOR >= minor)))
#define VERSION_LOWER(major, minor) ((SHADER_LIBRARY_VERSION_MAJOR < major) || ((SHADER_LIBRARY_VERSION_MAJOR == major) && (SHADER_LIBRARY_VERSION_MINOR < minor)))
Expand Down
2 changes: 1 addition & 1 deletion ValidationExceptions.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
{
"ValidationTest": "API Validation",
"ExceptionError": "Breaking changes require a new major version.",
"PackageVersion": "10.8.1"
"PackageVersion": "10.9.0"
}
]
}
9 changes: 6 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"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": "10.8.1",
"version": "10.9.0",
"unity": "2020.3",
"unityRelease": "18f1",
"displayName": "Core RP Library",
Expand All @@ -10,12 +10,15 @@
"com.unity.modules.physics": "1.0.0",
"com.unity.modules.jsonserialize": "1.0.0"
},
"upm": {
"changelog": "Version Updated\nThe version number for this package has increased due to a version update of a related graphics package."
},
"upmCi": {
"footprint": "dd6c6fa696b2b4a419dcfa4ef0835ee6bfbe7e80"
"footprint": "0fb1deba82c08376692d7ed7cc5132a067e0a9a7"
},
"repository": {
"url": "https://github.com/Unity-Technologies/Graphics.git",
"type": "git",
"revision": "31a193989d1e4e18ec3dced0f45168f8d2552a9a"
"revision": "5a193e907cafca7b2fa290618e18c3f28a3b451b"
}
}

0 comments on commit 0d93fcb

Please sign in to comment.