Skip to content
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

Internal/2021.3/staging #8098

Merged
merged 30 commits into from
Sep 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
bc010b0
[Backport][2021.3][SRPF] Hide RenderMode field and remove documentation
kirill-titov-u Jun 28, 2024
2f01e03
[Port 2021.3][BuiltTarget Extensions]API was accessing the target pla…
alex-vazquez-unity3d Jul 1, 2024
a17c2a7
Backport wireframe fixes (including Vulkan)
YohannVaastUnity Jul 3, 2024
48d37c5
[Backport][2021.3][VFX] Blackboard not visible when docked in small area
julienamsellem Jul 3, 2024
bf4900d
[2021.3][HDRP] Simplify Screen Space Reflection and add missing fence…
NdBree Jul 8, 2024
47a8a44
[Backport 2021.3] Fix Tonemap artifacts in Scene View
YohannVaastUnity Jul 8, 2024
f65c21d
[Port] [2021.3] Fix Linear01DepthFromNear
svc-reach-platform-support Jul 9, 2024
531ff28
[Port] [2021.3] Minor docs fixes
markg-unity Jul 10, 2024
8c0896e
[Port] [2021.3] DOCG-5438 Updated broken links to xref links
svc-reach-platform-support Jul 15, 2024
b563761
[Port] [2021.3] DOCG-5041 Fix for RThandle broken link
svc-reach-platform-support Jul 16, 2024
9ecf44e
[Tests][iOS] Disabled three testscenes that were causing trouble
NdBree Jul 22, 2024
eae0377
[Port] [2021.3] Avoid that the same volume can be registered more tha…
svc-reach-platform-support Jul 22, 2024
6ea5067
[Port] [2021.3] Fixed graphical issue when modifying Reflection Probe…
svc-reach-platform-support Jul 23, 2024
ac44505
[Port] [2021.3] Fixed compiler error when using half precision caused…
jrs-unity Jul 23, 2024
244b4f3
2021.3 Backport PR #49299 (Reduce Banding on FSR Upscaled Render Target)
gmitrano-unity Jul 25, 2024
84d146f
2021.3 Backport #49172 (Add Missing Fallback Setting for FSR EASU Sha…
gmitrano-unity Jul 25, 2024
5db5c9d
[UUM-70478] [2021.3] Backport fixes for HDRP mipmap debug views
Olof-AV Aug 5, 2024
b7ef1c4
[2021.3][ShaderGraph] Variant Limit bug fix
Aug 8, 2024
4c8ad67
[Port] [2021.3] [UUM-76270] Fix resize and scrolling behavior of Cust…
svc-reach-platform-support Aug 19, 2024
7631afa
2021.3: Fixed an issue where glClientWaitSync: Expected application t…
skannan-rythmos Aug 19, 2024
ed5f7c4
[Backport][2021.3][SRPF] Use FNV-1a 32 for caching and resource hashc…
kirill-titov-u Aug 23, 2024
b3d4bcf
[Port] [2021.3] Sg/uum 76198 remove context block delete option
svc-reach-platform-support Aug 23, 2024
852baa2
[content automatically redacted] touching PlatformDependent folder
Adrian1066 Aug 23, 2024
43cc2c1
[Port] [2021.3] fix camera offset in the UI editor for the RenderObje…
svc-reach-platform-support Aug 23, 2024
9c247e1
[SpeedTree] backport-2021.3: Fix camera facing leaf effect
volkan-unity Aug 26, 2024
6c1be11
[Port] [2021.3] Set no-op matrix for empty shadow-rendering.
amsXYZ Aug 28, 2024
5edb84b
[Port] [2021.3] SG integration: Read unexposed global properties from…
svc-reach-platform-support Aug 28, 2024
d0c571c
[Port] [2021.3] Only call MakeEditable on SG reimports triggered by a…
amsXYZ Sep 6, 2024
d18c90e
[Port] [2021.3] Fix a bug that Normal From Height node generates inco…
svc-reach-platform-support Sep 9, 2024
b08c5f3
[Port] [2021.3] Fixed the BlockNode to display the name using Display…
svc-reach-platform-support Sep 10, 2024
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
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ This document describes the main principles of a render graph and an overview of

Before you can write render passes with the [RenderGraph](../api/UnityEngine.Experimental.Rendering.RenderGraphModule.RenderGraph.html) API, you need to know the following foundational principles:

- You no longer handle resources directly and instead use render graph system-specific handles. All RenderGraph APIs use these handles to manipulate resources. The resource types a render graph manages are [RTHandles](rthandle-system.md), [ComputeBuffers](https://docs.unity3d.com/ScriptReference/ComputeBuffer.html), and [RendererLists](../api/UnityEngine.Experimental.Rendering.RendererList.html).
- You no longer handle resources directly and instead use render graph system-specific handles. All RenderGraph APIs use these handles to manipulate resources. The resource types a render graph manages are [RTHandles](rthandle-system.md), [ComputeBuffers](xref:UnityEngine.ComputeBuffer), and [RendererLists](xref:UnityEngine.Rendering.RendererList).
- Actual resource references are only accessible within the execution code of a render pass.
- The framework requires an explicit declaration of render passes. Each render pass must state which resources it reads from and/or writes to.
- There is no persistence between each execution of a render graph. This means that the resources you create inside one execution of the render graph cannot carry over to the next execution.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ This document describes the main principles of the RTHandle (RTHandle) system.
The RTHandle system is an abstraction on top of Unity's [RenderTexture](https://docs.unity3d.com/ScriptReference/RenderTexture.html) API. It makes it trivial to reuse render textures across Cameras that use various resolutions. The following principles are the foundation of how the RTHandle system works:

- You no longer allocate render textures yourself with a fixed resolution. Instead, you declare a render texture using a scale related to the full screen at a given resolution. The RTHandle system allocates the texture only once for the whole render pipeline so that it can reuse it for different Cameras.
- There is now the concept of reference size. This is the resolution the application uses for rendering. It is your responsibility to declare it before the render pipeline renders every Camera at a particular resolution. For information on how to do this, see the [Updating the RTHandle system](#updating-the-rthandle-system) section.
- There is now the concept of reference size. This is the resolution the application uses for rendering. It is your responsibility to declare it before the render pipeline renders every Camera at a particular resolution. For information on how to do this, see the [Updating the RTHandle system](rthandle-system-using.md#updating-the-rthandle-system) section.
- Internally, the RTHandle system tracks the largest reference size you declare. It uses this as the actual size of render textures. The largest reference size is the maximum size.
- Every time you declare a new reference size for rendering, the RTHandle system checks if it is larger than the current recorded largest reference size. If it is, the RTHandle system reallocates all render textures internally to fit the new size and replaces the largest reference size with the new size.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ public HierarchicalBox(Color baseColor, Color[] polychromeHandleColors = null, H
public void DrawHull(bool filled)
{
Color previousColor = Handles.color;
if (filled)
if (filled && Event.current.type == EventType.Repaint)
{
// Draw the hull
var xSize = new Vector3(size.z, size.y, 1f);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -796,7 +796,7 @@ internal void OnPassAdded(RenderGraphPass pass)
{
if (m_DebugParameters.immediateMode)
{
ExecutePassImmediatly(pass);
ExecutePassImmediately(pass);
}
}

Expand Down Expand Up @@ -1323,7 +1323,7 @@ ref CompiledPassInfo CompilePassImmediatly(RenderGraphPass pass)
return ref passInfo;
}

void ExecutePassImmediatly(RenderGraphPass pass)
void ExecutePassImmediately(RenderGraphPass pass)
{
ExecuteCompiledPass(ref CompilePassImmediatly(pass), m_CurrentImmediatePassIndex - 1);
}
Expand Down Expand Up @@ -1422,25 +1422,37 @@ void PreRenderPassExecute(in CompiledPassInfo passInfo, RenderGraphContext rgCon
// Need to save the command buffer to restore it later as the one in the context can changed if running a pass async.
m_PreviousCommandBuffer = rgContext.cmd;

bool executedWorkDuringResourceCreation = false;
for (int type = 0; type < (int)RenderGraphResourceType.Count; ++type)
{
foreach (int resource in passInfo.resourceCreateList[type])
{
m_Resources.CreatePooledResource(rgContext, type, resource);
executedWorkDuringResourceCreation |= m_Resources.CreatePooledResource(rgContext, type, resource);
}
}

PreRenderPassSetRenderTargets(passInfo, rgContext);

if (passInfo.enableAsyncCompute)
{
GraphicsFence previousFence = new GraphicsFence();
if (executedWorkDuringResourceCreation)
{
previousFence = rgContext.cmd.CreateGraphicsFence(GraphicsFenceType.AsyncQueueSynchronisation, SynchronisationStageFlags.AllGPUOperations);
}

// Flush current command buffer on the render context before enqueuing async commands.
rgContext.renderContext.ExecuteCommandBuffer(rgContext.cmd);
rgContext.cmd.Clear();

CommandBuffer asyncCmd = CommandBufferPool.Get(pass.name);
asyncCmd.SetExecutionFlags(CommandBufferExecutionFlags.AsyncCompute);
rgContext.cmd = asyncCmd;

if (executedWorkDuringResourceCreation)
{
rgContext.cmd.WaitOnAsyncGraphicsFence(previousFence);
}
}

// Synchronize with graphics or compute pipe if needed.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using System;
using System.Diagnostics;
using UnityEngine.Rendering;

namespace UnityEngine.Experimental.Rendering.RenderGraphModule
{
Expand Down Expand Up @@ -82,13 +83,11 @@ public ComputeBufferDesc(int count, int stride, ComputeBufferType type)
/// <returns>The texture descriptor hash.</returns>
public override int GetHashCode()
{
int hashCode = 17;

hashCode = hashCode * 23 + count;
hashCode = hashCode * 23 + stride;
hashCode = hashCode * 23 + (int)type;

return hashCode;
var hashCode = HashFNV1A32.Create();
hashCode.Append(count);
hashCode.Append(stride);
hashCode.Append((int)type);
return hashCode.value;
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,15 +33,16 @@ internal static RenderGraphResourceRegistry current
m_CurrentRegistry = value;
}
}


delegate bool ResourceCreateCallback(RenderGraphContext rgContext, IRenderGraphResource res);
delegate void ResourceCallback(RenderGraphContext rgContext, IRenderGraphResource res);

class RenderGraphResourcesData
{
public DynamicArray<IRenderGraphResource> resourceArray = new DynamicArray<IRenderGraphResource>();
public int sharedResourcesCount;
public IRenderGraphResourcePool pool;
public ResourceCallback createResourceCallback;
public ResourceCreateCallback createResourceCallback;
public ResourceCallback releaseResourceCallback;

public void Clear(bool onException, int frameIndex)
Expand Down Expand Up @@ -435,8 +436,9 @@ void ManageSharedRenderGraphResources()
}
}

internal void CreatePooledResource(RenderGraphContext rgContext, int type, int index)
internal bool CreatePooledResource(RenderGraphContext rgContext, int type, int index)
{
bool? executedWork = false;
var resource = m_RenderGraphResources[type].resourceArray[index];
if (!resource.imported)
{
Expand All @@ -445,11 +447,13 @@ internal void CreatePooledResource(RenderGraphContext rgContext, int type, int i
if (m_RenderGraphDebug.enableLogging)
resource.LogCreation(m_FrameInformationLogger);

m_RenderGraphResources[type].createResourceCallback?.Invoke(rgContext, resource);
executedWork = m_RenderGraphResources[type].createResourceCallback?.Invoke(rgContext, resource);
}

return executedWork ?? false;
}

void CreateTextureCallback(RenderGraphContext rgContext, IRenderGraphResource res)
bool CreateTextureCallback(RenderGraphContext rgContext, IRenderGraphResource res)
{
var resource = res as TextureResource;

Expand All @@ -461,6 +465,7 @@ void CreateTextureCallback(RenderGraphContext rgContext, IRenderGraphResource re
}
#endif

bool executedWork = false;
if (resource.desc.clearBuffer || m_RenderGraphDebug.clearRenderTargetsAtCreation)
{
bool debugClear = m_RenderGraphDebug.clearRenderTargetsAtCreation && !resource.desc.clearBuffer;
Expand All @@ -470,7 +475,9 @@ void CreateTextureCallback(RenderGraphContext rgContext, IRenderGraphResource re
var clearColor = debugClear ? Color.magenta : resource.desc.clearColor;
CoreUtils.SetRenderTarget(rgContext.cmd, resource.graphicsResource, clearFlag, clearColor);
}
executedWork = true;
}
return executedWork;
}

internal void ReleasePooledResource(RenderGraphContext rgContext, int type, int index)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -241,48 +241,42 @@ public TextureDesc(TextureDesc input)
/// <returns>The texture descriptor hash.</returns>
public override int GetHashCode()
{
int hashCode = 17;

unchecked
var hashCode = HashFNV1A32.Create();
switch (sizeMode)
{
switch (sizeMode)
{
case TextureSizeMode.Explicit:
hashCode = hashCode * 23 + width;
hashCode = hashCode * 23 + height;
break;
case TextureSizeMode.Functor:
if (func != null)
hashCode = hashCode * 23 + func.GetHashCode();
break;
case TextureSizeMode.Scale:
hashCode = hashCode * 23 + scale.x.GetHashCode();
hashCode = hashCode * 23 + scale.y.GetHashCode();
break;
}
case TextureSizeMode.Explicit:
hashCode.Append(width);
hashCode.Append(height);
break;
case TextureSizeMode.Functor:
if (func != null)
hashCode.Append(func);
break;
case TextureSizeMode.Scale:
hashCode.Append(scale);
break;
}

hashCode = hashCode * 23 + mipMapBias.GetHashCode();
hashCode = hashCode * 23 + slices;
hashCode = hashCode * 23 + (int)depthBufferBits;
hashCode = hashCode * 23 + (int)colorFormat;
hashCode = hashCode * 23 + (int)filterMode;
hashCode = hashCode * 23 + (int)wrapMode;
hashCode = hashCode * 23 + (int)dimension;
hashCode = hashCode * 23 + (int)memoryless;
hashCode = hashCode * 23 + anisoLevel;
hashCode = hashCode * 23 + (enableRandomWrite ? 1 : 0);
hashCode = hashCode * 23 + (useMipMap ? 1 : 0);
hashCode = hashCode * 23 + (autoGenerateMips ? 1 : 0);
hashCode = hashCode * 23 + (isShadowMap ? 1 : 0);
hashCode = hashCode * 23 + (bindTextureMS ? 1 : 0);
hashCode = hashCode * 23 + (useDynamicScale ? 1 : 0);
hashCode = hashCode * 23 + (int)msaaSamples;
hashCode.Append(mipMapBias);
hashCode.Append(slices);
hashCode.Append((int) depthBufferBits);
hashCode.Append((int) colorFormat);
hashCode.Append((int) filterMode);
hashCode.Append((int) wrapMode);
hashCode.Append((int) dimension);
hashCode.Append((int) memoryless);
hashCode.Append(anisoLevel);
hashCode.Append(enableRandomWrite);
hashCode.Append(useMipMap);
hashCode.Append(autoGenerateMips);
hashCode.Append(isShadowMap);
hashCode.Append(bindTextureMS);
hashCode.Append(useDynamicScale);
hashCode.Append((int) msaaSamples);
#if UNITY_2020_2_OR_NEWER
hashCode = hashCode * 23 + (fastMemoryDesc.inFastMemory ? 1 : 0);
hashCode.Append(fastMemoryDesc.inFastMemory);
#endif
}

return hashCode;
return hashCode.value;
}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,125 @@
using System;
using System.Runtime.CompilerServices;

namespace UnityEngine.Rendering
{
internal ref struct HashFNV1A32
{
/// <summary>
/// FNV prime.
/// </summary>
const uint k_Prime = 16777619;

/// <summary>
/// FNV offset basis.
/// </summary>
const uint k_OffsetBasis = 2166136261;

uint m_Hash;

public static HashFNV1A32 Create()
{
return new HashFNV1A32 { m_Hash = k_OffsetBasis };
}

[MethodImpl(MethodImplOptions.AggressiveInlining)]
public void Append(in int input)
{
unchecked
{
m_Hash = (m_Hash ^ (uint)input) * k_Prime;
}
}

[MethodImpl(MethodImplOptions.AggressiveInlining)]
public void Append(in uint input)
{
unchecked
{
m_Hash = (m_Hash ^ input) * k_Prime;
}
}

[MethodImpl(MethodImplOptions.AggressiveInlining)]
public void Append(in bool input)
{
m_Hash = (m_Hash ^ (input ? 1u : 0u)) * k_Prime;
}

[MethodImpl(MethodImplOptions.AggressiveInlining)]
public void Append(in float input)
{
unchecked
{
m_Hash = (m_Hash ^ (uint)input.GetHashCode()) * k_Prime;
}
}

[MethodImpl(MethodImplOptions.AggressiveInlining)]
public void Append(in double input)
{
unchecked
{
m_Hash = (m_Hash ^ (uint)input.GetHashCode()) * k_Prime;
}
}

[MethodImpl(MethodImplOptions.AggressiveInlining)]
public void Append(in Vector2 input)
{
unchecked
{
m_Hash = (m_Hash ^ (uint)input.GetHashCode()) * k_Prime;
}
}

[MethodImpl(MethodImplOptions.AggressiveInlining)]
public void Append(in Vector3 input)
{
unchecked
{
m_Hash = (m_Hash ^ (uint)input.GetHashCode()) * k_Prime;
}
}

[MethodImpl(MethodImplOptions.AggressiveInlining)]
public void Append(in Vector4 input)
{
unchecked
{
m_Hash = (m_Hash ^ (uint)input.GetHashCode()) * k_Prime;
}
}

[MethodImpl(MethodImplOptions.AggressiveInlining)]
public void Append<T>(T input) where T : struct
{
unchecked
{
m_Hash = (m_Hash ^ (uint)input.GetHashCode()) * k_Prime;
}
}

[MethodImpl(MethodImplOptions.AggressiveInlining)]
public void Append(Delegate del)
{
unchecked
{
m_Hash = (m_Hash ^ (uint)GetFuncHashCode(del)) * k_Prime;
}
}

[MethodImpl(MethodImplOptions.AggressiveInlining)]
internal static int GetFuncHashCode(Delegate del)
{
return del.Method.GetHashCode() ^ RuntimeHelpers.GetHashCode(del.Target);
}

public int value => (int)m_Hash;

public override int GetHashCode()
{
return value;
}
}
}

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

Loading
Loading