Skip to content

Commit

Permalink
Merge pull request #8078 from Unity-Technologies/internal/2022.3/staging
Browse files Browse the repository at this point in the history
Internal/2022.3/staging
  • Loading branch information
UnityAljosha authored Jun 10, 2024
2 parents 99e2fb0 + c55bd46 commit 9ee1513
Show file tree
Hide file tree
Showing 876 changed files with 640,293 additions and 385 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -706,11 +706,7 @@ void OnEnable()
foreach (var graph in registeredGraph)
m_RegisteredGraphs.Add(graph, new HashSet<string>());

RenderGraph.requireDebugData = true;
RenderGraph.onGraphRegistered += OnGraphRegistered;
RenderGraph.onGraphUnregistered += OnGraphUnregistered;
RenderGraph.onExecutionRegistered += OnExecutionRegistered;
RenderGraph.onExecutionUnregistered += OnExecutionUnregistered;
SubscribeToRenderGraphEvents();
}

private void CreateGUI()
Expand All @@ -720,10 +716,36 @@ private void CreateGUI()

void OnDisable()
{
UnsubscribeToRenderGraphEvents();
}

void SubscribeToRenderGraphEvents()
{
if (RenderGraph.requireDebugData)
return;

RenderGraph.requireDebugData = true;
RenderGraph.onGraphRegistered += OnGraphRegistered;
RenderGraph.onGraphUnregistered += OnGraphUnregistered;
RenderGraph.onExecutionRegistered += OnExecutionRegistered;
RenderGraph.onExecutionUnregistered += OnExecutionUnregistered;
}

void UnsubscribeToRenderGraphEvents()
{
if (!RenderGraph.requireDebugData)
return;

RenderGraph.requireDebugData = false;
RenderGraph.onGraphRegistered -= OnGraphRegistered;
RenderGraph.onGraphUnregistered -= OnGraphUnregistered;
RenderGraph.onExecutionRegistered -= OnExecutionRegistered;
RenderGraph.onExecutionUnregistered -= OnExecutionUnregistered;
}

void Update()
{
// UUM-70378: In case the OnDisable Unsubscribes to Render Graph events when coming back from a Maximized state
SubscribeToRenderGraphEvents();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,218 @@
#define UNITY_FOVEATED_RENDERING_INCLUDED

#if (!defined(UNITY_COMPILER_DXC) && (defined(UNITY_PLATFORM_OSX) || defined(UNITY_PLATFORM_IOS) || defined(UNITY_PLATFORM_VISIONOS))) || defined(SHADER_API_PS5)

#if defined(SHADER_API_PS5) || defined(SHADER_API_METAL)

#define SUPPORTS_FOVEATED_RENDERING_NON_UNIFORM_RASTER 1
#endif
#endif

#if defined(SHADER_API_PS5)
#include "Packages/com.unity.render-pipelines.ps5/ShaderLibrary/API/FoveatedRendering_PSSL.hlsl"
#endif
#if SUPPORTS_FOVEATED_RENDERING_NON_UNIFORM_RASTER
#if defined(SHADER_API_PS5)
#include "Packages/com.unity.render-pipelines.ps5/ShaderLibrary/API/FoveatedRendering_PSSL.hlsl"
#endif

#if defined(SHADER_API_METAL)
#include "Packages/com.unity.render-pipelines.core/ShaderLibrary/API/FoveatedRendering_Metal.hlsl"
#endif
#if defined(SHADER_API_METAL)
#include "Packages/com.unity.render-pipelines.core/ShaderLibrary/API/FoveatedRendering_Metal.hlsl"
#endif

#endif
// coordinate remapping functions for foveated rendering
#define FOVEATED_FLIP_Y(uv) uv.y = 1.0f - uv.y
float2 FoveatedRemapLinearToNonUniform(float2 uv)
{
UNITY_BRANCH if(_FOVEATED_RENDERING_NON_UNIFORM_RASTER)
{
FOVEATED_FLIP_Y(uv);
uv = RemapFoveatedRenderingLinearToNonUniform(uv);
FOVEATED_FLIP_Y(uv);
}
return uv;
}

float2 FoveatedRemapPrevFrameLinearToNonUniform(float2 uv)
{
UNITY_BRANCH if(_FOVEATED_RENDERING_NON_UNIFORM_RASTER)
{
FOVEATED_FLIP_Y(uv);
uv = RemapFoveatedRenderingPrevFrameLinearToNonUniform(uv);
FOVEATED_FLIP_Y(uv);
}
return uv;
}

float2 FoveatedRemapDensity(float2 uv)
{
UNITY_BRANCH if(_FOVEATED_RENDERING_NON_UNIFORM_RASTER)
{
FOVEATED_FLIP_Y(uv);
uv = RemapFoveatedRenderingDensity(uv);
FOVEATED_FLIP_Y(uv);
}
return uv;
}

float2 FoveatedRemapPrevFrameDensity(float2 uv)
{
UNITY_BRANCH if(_FOVEATED_RENDERING_NON_UNIFORM_RASTER)
{
FOVEATED_FLIP_Y(uv);
uv = RemapFoveatedRenderingPrevFrameDensity(uv);
FOVEATED_FLIP_Y(uv);
}
return uv;
}

float2 FoveatedRemapNonUniformToLinear(float2 uv)
{
UNITY_BRANCH if(_FOVEATED_RENDERING_NON_UNIFORM_RASTER)
{
FOVEATED_FLIP_Y(uv);
uv = RemapFoveatedRenderingNonUniformToLinear(uv);
FOVEATED_FLIP_Y(uv);
}
return uv;
}

float2 FoveatedRemapPrevFrameNonUniformToLinear(float2 uv)
{
UNITY_BRANCH if(_FOVEATED_RENDERING_NON_UNIFORM_RASTER)
{
FOVEATED_FLIP_Y(uv);
uv = RemapFoveatedRenderingPrevFrameNonUniformToLinear(uv);
FOVEATED_FLIP_Y(uv);
}
return uv;
}
#undef FOVEATED_FLIP_Y

int2 FoveatedRemapLinearToNonUniformCS(int2 positionCS)
{
return FoveatedRemapLinearToNonUniform((positionCS + float2(0.5, 0.5)) * _ScreenSize.zw) * _ScreenSize.xy;
}

int2 FoveatedRemapNonUniformToLinearCS(int2 positionCS)
{
UNITY_BRANCH if(_FOVEATED_RENDERING_NON_UNIFORM_RASTER)
positionCS = RemapFoveatedRenderingNonUniformToLinearCS(positionCS, true);
return positionCS;
}

#else // SUPPORTS_FOVEATED_RENDERING_NON_UNIFORM_RASTER

// dummy coordinate remapping functions for non-foveated rendering
float2 FoveatedRemapLinearToNonUniform(float2 uv) {return uv;}
float2 FoveatedRemapPrevFrameLinearToNonUniform(float2 uv) {return uv;}
float2 FoveatedRemapDensity(float2 uv) {return uv;}
float2 FoveatedRemapPrevFrameDensity(float2 uv) {return uv;}
float2 FoveatedRemapNonUniformToLinear(float2 uv) {return uv;}
float2 FoveatedRemapPrevFrameNonUniformToLinear(float2 uv) {return uv;}
int2 FoveatedRemapLinearToNonUniformCS(int2 positionCS) {return positionCS;}
int2 FoveatedRemapNonUniformToLinearCS(int2 positionCS) {return positionCS;}

#endif

// foveated version of GetPositionInput() functions
PositionInputs FoveatedGetPositionInput(float2 positionSS, float2 invScreenSize, uint2 tileCoord)
{
PositionInputs posInput = GetPositionInput(positionSS, invScreenSize, tileCoord);
posInput.positionNDC = FoveatedRemapNonUniformToLinear(posInput.positionNDC);
return posInput;
}

PositionInputs FoveatedPrevFrameGetPositionInput(float2 positionSS, float2 invScreenSize, uint2 tileCoord)
{
PositionInputs posInput = GetPositionInput(positionSS, invScreenSize, tileCoord);
posInput.positionNDC = FoveatedRemapPrevFrameNonUniformToLinear(posInput.positionNDC);
return posInput;
}

PositionInputs FoveatedGetPositionInput(float2 positionSS, float2 invScreenSize)
{
return FoveatedGetPositionInput(positionSS, invScreenSize, uint2(0, 0));
}

PositionInputs FoveatedPrevFrameGetPositionInput(float2 positionSS, float2 invScreenSize)
{
return FoveatedPrevFrameGetPositionInput(positionSS, invScreenSize, uint2(0, 0));
}

PositionInputs FoveatedGetPositionInput(float2 positionSS, float2 invScreenSize, float3 positionWS)
{
PositionInputs posInput = FoveatedGetPositionInput(positionSS, invScreenSize, uint2(0, 0));
posInput.positionWS = positionWS;
return posInput;
}

PositionInputs FoveatedPrevFrameGetPositionInput(float2 positionSS, float2 invScreenSize, float3 positionWS)
{
PositionInputs posInput = FoveatedPrevFrameGetPositionInput(positionSS, invScreenSize, uint2(0, 0));
posInput.positionWS = positionWS;
return posInput;
}

PositionInputs FoveatedGetPositionInput(float2 positionSS, float2 invScreenSize, float deviceDepth, float linearDepth, float3 positionWS, uint2 tileCoord)
{
PositionInputs posInput = FoveatedGetPositionInput(positionSS, invScreenSize, tileCoord);
posInput.positionWS = positionWS;
posInput.deviceDepth = deviceDepth;
posInput.linearDepth = linearDepth;

return posInput;
}

PositionInputs FoveatedPrevFrameGetPositionInput(float2 positionSS, float2 invScreenSize, float deviceDepth, float linearDepth, float3 positionWS, uint2 tileCoord)
{
PositionInputs posInput = FoveatedPrevFrameGetPositionInput(positionSS, invScreenSize, tileCoord);
posInput.positionWS = positionWS;
posInput.deviceDepth = deviceDepth;
posInput.linearDepth = linearDepth;

return posInput;
}

PositionInputs FoveatedGetPositionInput(float2 positionSS, float2 invScreenSize, float deviceDepth, float linearDepth, float3 positionWS)
{
return FoveatedGetPositionInput(positionSS, invScreenSize, deviceDepth, linearDepth, positionWS, uint2(0, 0));
}

PositionInputs FoveatedPrevFrameGetPositionInput(float2 positionSS, float2 invScreenSize, float deviceDepth, float linearDepth, float3 positionWS)
{
return FoveatedPrevFrameGetPositionInput(positionSS, invScreenSize, deviceDepth, linearDepth, positionWS, uint2(0, 0));
}

PositionInputs FoveatedGetPositionInput(float2 positionSS, float2 invScreenSize, float deviceDepth,
float4x4 invViewProjMatrix, float4x4 viewMatrix,
uint2 tileCoord)
{
PositionInputs posInput = FoveatedGetPositionInput(positionSS, invScreenSize, tileCoord);
posInput.positionWS = ComputeWorldSpacePosition(posInput.positionNDC, deviceDepth, invViewProjMatrix);
posInput.deviceDepth = deviceDepth;
posInput.linearDepth = LinearEyeDepth(posInput.positionWS, viewMatrix);

return posInput;
}

PositionInputs FoveatedPrevFrameGetPositionInput(float2 positionSS, float2 invScreenSize, float deviceDepth,
float4x4 invViewProjMatrix, float4x4 viewMatrix,
uint2 tileCoord)
{
PositionInputs posInput = FoveatedPrevFrameGetPositionInput(positionSS, invScreenSize, tileCoord);
posInput.positionWS = ComputeWorldSpacePosition(posInput.positionNDC, deviceDepth, invViewProjMatrix);
posInput.deviceDepth = deviceDepth;
posInput.linearDepth = LinearEyeDepth(posInput.positionWS, viewMatrix);

return posInput;
}

PositionInputs FoveatedGetPositionInput(float2 positionSS, float2 invScreenSize, float deviceDepth,
float4x4 invViewProjMatrix, float4x4 viewMatrix)
{
return FoveatedGetPositionInput(positionSS, invScreenSize, deviceDepth, invViewProjMatrix, viewMatrix, uint2(0, 0));
}

PositionInputs FoveatedPrevFrameGetPositionInput(float2 positionSS, float2 invScreenSize, float deviceDepth,
float4x4 invViewProjMatrix, float4x4 viewMatrix)
{
return FoveatedPrevFrameGetPositionInput(positionSS, invScreenSize, deviceDepth, invViewProjMatrix, viewMatrix, uint2(0, 0));
}

#endif // UNITY_FOVEATED_RENDERING_INCLUDED
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#ifndef UNITY_FOVEATED_RENDERING_KEYWORDS_INCLUDED
#define UNITY_FOVEATED_RENDERING_KEYWORDS_INCLUDED

#if (!defined(UNITY_COMPILER_DXC) && (defined(UNITY_PLATFORM_OSX) || defined(UNITY_PLATFORM_IOS) || defined(UNITY_PLATFORM_VISIONOS)) || defined(SHADER_API_PS5))
#if (!defined(UNITY_COMPILER_DXC) && (defined(UNITY_PLATFORM_OSX) || defined(UNITY_PLATFORM_IOS) || defined(UNITY_PLATFORM_VISIONOS))) || defined(SHADER_API_PS5)

#if defined(SHADER_API_PS5) || defined(SHADER_API_METAL)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ ParallaxOcclusionMapping

delta = intersectionHeight - currHeight;

if (abs(delta) <= 0.01)
if ((delta >= -0.01) && (delta <= 0.01))
break;

// intersectionHeight < currHeight => new lower bounds
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,45 +15,49 @@ The **Rendering Debugger** is a specific window for the Scriptable Render Pipeli
![](Images/RenderPipelineDebug1.png)
The Rendering Debugger

## Using the Rendering Debugger
## How to access the Rendering Debugger

The Rendering Debugger window is available in the following modes:

* The Editor.
* The Play mode.
* At runtime in the standalone Unity Player, on any device. The window is only available in **Development Builds**.
| Mode | Platform | Availability | How to Open the Rendering Debugger |
|-----------|----------------|----------------------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| Editor | All | Yes (window in the Editor) | Select **Window > Analysis > Rendering Debugger** |
| Play mode | All | Yes (overlay in the Game view) | On a desktop or laptop computer, press **LeftCtrl+Backspace** (**LeftCtrl+Delete** on macOS)<br>On a console controller, press L3 and R3 (Left Stick and Right Stick) |
| Runtime | Desktop/Laptop | Yes (only in Development builds) | Press **LeftCtrl+Backspace** (**LeftCtrl+Delete** on macOS) |
| Runtime | Console | Yes (only in Development builds) | Press L3 and R3 (Left Stick and Right Stick) |
| Runtime | Mobile | Yes (only in Development builds) | Use a three-finger double tap |

To open the Rendering Debugger in the Editor:
To enable all the sections of the **Rendering Debugger** in your built application, disable **Strip Debug Variants** in **Project Settings > Graphics > HDRP Global Settings**. Otherwise, you can only use the [Display Stats](#display-stats) section.

* Enable **Runtime Debug Shaders** in **HDRP Global Settings** (in the menu: **Edit** > **Project Settings** > **Graphics** > **HDRP Settings**).

* Select **Window** > **Analysis** > **Rendering Debugger**.

To open the window in the Play mode, or at runtime in a Development Build, use the keyboard shortcut Ctrl+Backspace (Ctrl+Delete on macOS) or press L3 and R3 (Left Stick and Right Stick) on a controller.
To disable the runtime UI, use the [enableRuntimeUI](https://docs.unity3d.com/Packages/[email protected]/api/UnityEngine.Rendering.DebugManager.html#UnityEngine_Rendering_DebugManager_enableRuntimeUI) property.

You can display read-only items, such as the FPS counter, independently of the **Rendering Debugger** window. When you disable the **Rendering Debugger** window, they're still visible in the top right corner of the screen. Use this functionality to track particular values without cluttering the screen.

You can disable the runtime UI entirely by using the [`enableRuntimeUI`](https://docs.unity3d.com/Packages/com.unity.render-pipelines.core@latest/api/UnityEngine.Rendering.DebugManager.html#UnityEngine_Rendering_DebugManager_enableRuntimeUI) property.

### Navigation at runtime
## Navigation at runtime

To change the current active item:
### Keyboard

* **Keyboard**: Use the arrow keys.
* **Xbox controller**: Use the Directional pad (D-Pad).
* **PlayStation controller**: Use the Directional buttons.
| Action | Control |
|----------------------------------------------------|-------------------------------------------------------------------------------------------|
| **Change the current active item** | Use the arrow keys |
| **Change the current tab** | Use the Page up and Page down keys (Fn + Up and Fn + Down keys respectively for MacOS) |
| **Display the current active item independently of the debug window** | Press the right Shift key |

To change the current tab:
### Xbox Controller

* **Keyboard**: Use the Page up and Page down keys (Fn + Up and Fn + Down keys respectively for MacOS).
* **Xbox controller**: Use the Left Bumper and Right Bumper.
* **PlayStation controller**: Use the L1 button and R1 button.
| Action | Control |
|----------------------------------------------------|-------------------------------------------------------------------------------------------|
| **Change the current active item** | Use the Directional pad (D-Pad) |
| **Change the current tab** | Use the Left Bumper and Right Bumper |
| **Display the current active item independently of the debug window** | Press the X button |

To display the current active item independently of the debug window:
### PlayStation Controller

* **Keyboard**: Press the right Shift key.
* **Xbox controller**: Press the X button.
* **PlayStation controller**: Press the Square button.
| Action | Control |
|----------------------------------------------------|-------------------------------------------------------------------------------------------|
| **Change the current active item** | Use the Directional buttons |
| **Change the current tab** | Use the L1 button and R1 button |
| **Display the current active item independently of the debug window** | Press the Square button |

<a name="DecalsPanel"></a>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -182,15 +182,15 @@ class BlitCachedShadowPassData
public TextureHandle atlasTexture;
}

public void BlitCachedIntoAtlas(RenderGraph renderGraph, TextureHandle cachedAtlasTexture, int cachedAtlasSize, Material blitMaterial, string passName, HDProfileId profileID)
public void BlitCachedIntoAtlas(RenderGraph renderGraph, TextureHandle cachedAtlasTexture, Vector2Int cachedAtlasSize, Material blitMaterial, string passName, HDProfileId profileID)
{
if (m_MixedRequestsPendingBlits.Count > 0)
{
using (var builder = renderGraph.AddRenderPass<BlitCachedShadowPassData>(passName, out var passData, ProfilingSampler.Get(profileID)))
{
passData.requestsWaitingBlits = m_MixedRequestsPendingBlits;
passData.blitMaterial = blitMaterial;
passData.cachedShadowAtlasSize = new Vector2Int(cachedAtlasSize, cachedAtlasSize);
passData.cachedShadowAtlasSize = cachedAtlasSize;
passData.sourceCachedAtlas = builder.ReadTexture(cachedAtlasTexture);
passData.atlasTexture = builder.WriteTexture(GetShadowMapDepthTexture(renderGraph));

Expand Down
Loading

0 comments on commit 9ee1513

Please sign in to comment.