From 8fc225ab1f723bafa84ca10d62e2221378a547b1 Mon Sep 17 00:00:00 2001 From: FrancescoC-Unity Date: Wed, 13 Oct 2021 15:52:47 +0200 Subject: [PATCH] Force scalarization of shadow index data off --- .../Runtime/Lighting/LightLoop/HDShadow.hlsl | 10 +++++++--- .../VolumetricLighting/VolumetricLighting.compute | 3 +++ 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/com.unity.render-pipelines.high-definition/Runtime/Lighting/LightLoop/HDShadow.hlsl b/com.unity.render-pipelines.high-definition/Runtime/Lighting/LightLoop/HDShadow.hlsl index 1c399940211..b6788b26dc2 100644 --- a/com.unity.render-pipelines.high-definition/Runtime/Lighting/LightLoop/HDShadow.hlsl +++ b/com.unity.render-pipelines.high-definition/Runtime/Lighting/LightLoop/HDShadow.hlsl @@ -17,6 +17,10 @@ # include "Packages/com.unity.render-pipelines.high-definition/Runtime/Lighting/Shadow/HDShadowContext.hlsl" +// Normal light loop is guaranteed to be scalar, but not always we sample shadows with said guarantee. In those cases we define SHADOW_DATA_NOT_GUARANTEED_SCALAR to skip the forcing into scalar. +#define FORCE_SHADOW_SCALAR_READ !defined(SHADOW_DATA_NOT_GUARANTEED_SCALAR) && !defined(SHADER_API_XBOXONE) && !defined(SHADER_API_GAMECORE) && (defined(PLATFORM_SUPPORTS_WAVE_INTRINSICS) && !defined(LIGHTLOOP_DISABLE_TILE_AND_CLUSTER)) + + // normalWS is the vertex normal if available or shading normal use to bias the shadow position float GetDirectionalShadowAttenuation(HDShadowContext shadowContext, float2 positionSS, float3 positionWS, float3 normalWS, int shadowDataIndex, float3 L) { @@ -32,7 +36,7 @@ float GetDirectionalShadowAttenuation(HDShadowContext shadowContext, float2 posi float GetPunctualShadowAttenuation(HDShadowContext shadowContext, float2 positionSS, float3 positionWS, float3 normalWS, int shadowDataIndex, float3 L, float L_dist, bool pointLight, bool perspecive) { -#if !defined(SHADER_API_XBOXONE) && !defined(SHADER_API_GAMECORE) && (defined(PLATFORM_SUPPORTS_WAVE_INTRINSICS) && !defined(LIGHTLOOP_DISABLE_TILE_AND_CLUSTER)) +#if FORCE_SHADOW_SCALAR_READ shadowDataIndex = WaveReadLaneFirst(shadowDataIndex); #endif @@ -63,7 +67,7 @@ float GetPunctualShadowAttenuation(HDShadowContext shadowContext, float2 positio float GetPunctualShadowClosestDistance(HDShadowContext shadowContext, SamplerState sampl, real3 positionWS, int shadowDataIndex, float3 L, float3 lightPositionWS, bool pointLight) { -#if !defined(SHADER_API_XBOXONE) && !defined(SHADER_API_GAMECORE) && (defined(PLATFORM_SUPPORTS_WAVE_INTRINSICS) && !defined(LIGHTLOOP_DISABLE_TILE_AND_CLUSTER)) +#if FORCE_SHADOW_SCALAR_READ shadowDataIndex = WaveReadLaneFirst(shadowDataIndex); #endif @@ -94,7 +98,7 @@ float GetRectAreaShadowAttenuation(HDShadowContext shadowContext, float2 positio { // We need to disable the scalarization here on xbox due to bad code generated by FXC for the eye shader. // This shouldn't have an enormous impact since with Area lights we are already exploded in VGPR by this point. -#if !defined(SHADER_API_XBOXONE) && !defined(SHADER_API_GAMECORE) && (defined(PLATFORM_SUPPORTS_WAVE_INTRINSICS) && !defined(LIGHTLOOP_DISABLE_TILE_AND_CLUSTER)) +#if FORCE_SHADOW_SCALAR_READ shadowDataIndex = WaveReadLaneFirst(shadowDataIndex); #endif HDShadowData sd = shadowContext.shadowDatas[shadowDataIndex]; diff --git a/com.unity.render-pipelines.high-definition/Runtime/Lighting/VolumetricLighting/VolumetricLighting.compute b/com.unity.render-pipelines.high-definition/Runtime/Lighting/VolumetricLighting/VolumetricLighting.compute index 942ac278753..bd5c8f33a87 100644 --- a/com.unity.render-pipelines.high-definition/Runtime/Lighting/VolumetricLighting/VolumetricLighting.compute +++ b/com.unity.render-pipelines.high-definition/Runtime/Lighting/VolumetricLighting/VolumetricLighting.compute @@ -40,6 +40,9 @@ // which might be lower than the max number of lights that might be in the big tile. #define PRE_FILTER_LIGHT_LIST 1 && defined(USE_BIG_TILE_LIGHTLIST) + +#define SHADOW_DATA_NOT_GUARANTEED_SCALAR // We are not looping over shadows in a scalarized fashion. If we will at some point, remove this define. + //-------------------------------------------------------------------------------------------------- // Included headers //--------------------------------------------------------------------------------------------------