Skip to content

Commit 53e44f1

Browse files
Fix state packing and shouldRenderCachedComponent setting (#110)
1 parent 871b79d commit 53e44f1

File tree

5 files changed

+8
-22
lines changed

5 files changed

+8
-22
lines changed

com.unity.render-pipelines.high-definition/Runtime/Lighting/Light/HDGpuLightsBuilder.LightLoop.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -683,7 +683,7 @@ internal unsafe void CalculateShadowIndices(
683683
ref HDAdditionalLightDataUpdateInfo updateInfo = ref UnsafeUtility.AsRef<HDAdditionalLightDataUpdateInfo>(updateInfosUnsafePtr + additionalLightDataIndex);
684684

685685
shadowRequest.shouldUseCachedShadowData = false;
686-
686+
shadowRequest.shouldRenderCachedComponent = false;
687687
shadowRequest.cachedShadowData.cacheTranslationDelta = new Vector3(0.0f, 0.0f, 0.0f);
688688

689689
// Write per light type matrices, splitDatas and culling parameters

com.unity.render-pipelines.high-definition/Runtime/Lighting/Light/HDLightRenderDatabase.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ public void SetTypeData(byte typeIndex, byte value)
102102
[MethodImpl(MethodImplOptions.AggressiveInlining)]
103103
public byte GetTypeData(byte typeIndex)
104104
{
105-
return (byte)(typeData & (0b11 << (typeIndex * 2)));
105+
return (byte)((typeData >> (typeIndex * 2)) & 0b11);
106106
}
107107

108108
public SpotLightShape spotLightShape
@@ -125,8 +125,8 @@ public ShadowUpdateMode shadowUpdateMode
125125

126126
public HDAdditionalLightData.PointLightHDType pointLightHDType
127127
{
128-
get => (HDAdditionalLightData.PointLightHDType)((typeData >> 6) & 0b11);
129-
set => typeData = (byte)((typeData & 0b00111111) | (((int)value) << 6));
128+
[MethodImpl(MethodImplOptions.AggressiveInlining)] get => (HDAdditionalLightData.PointLightHDType)GetTypeData(3);
129+
[MethodImpl(MethodImplOptions.AggressiveInlining)] set => SetTypeData(3, (byte)value);
130130
}
131131

132132
public bool useCustomSpotLightShadowCone

com.unity.render-pipelines.high-definition/Runtime/Lighting/Light/UpdateShadowRequestsAndCalculateIndicesJob.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -602,7 +602,7 @@ public void UpdateDynamicPointShadowRequestsAndResolutionRequests()
602602
HDAdditionalLightDataUpdateInfo updateInfo = additionalLightDataUpdateInfos[additionalLightDataIndex];
603603

604604
shadowRequest.shouldUseCachedShadowData = false;
605-
605+
shadowRequest.shouldRenderCachedComponent = false;
606606
shadowRequest.cachedShadowData.cacheTranslationDelta = new Vector3(0.0f, 0.0f, 0.0f);
607607

608608
// Write per light type matrices, splitDatas and culling parameters
@@ -712,7 +712,7 @@ public void UpdateDynamicSpotShadowRequestsAndResolutionRequests()
712712
HDAdditionalLightDataUpdateInfo updateInfo = additionalLightDataUpdateInfos[additionalLightDataIndex];
713713

714714
shadowRequest.shouldUseCachedShadowData = false;
715-
715+
shadowRequest.shouldRenderCachedComponent = false;
716716
shadowRequest.cachedShadowData.cacheTranslationDelta = new Vector3(0.0f, 0.0f, 0.0f);
717717

718718
// Write per light type matrices, splitDatas and culling parameters
@@ -849,7 +849,7 @@ public void UpdateDynamicAreaShadowRequestsAndResolutionRequests(NativeList<Shad
849849
HDAdditionalLightDataUpdateInfo updateInfo = additionalLightDataUpdateInfos[additionalLightDataIndex];
850850

851851
shadowRequest.shouldUseCachedShadowData = false;
852-
852+
shadowRequest.shouldRenderCachedComponent = false;
853853
shadowRequest.cachedShadowData.cacheTranslationDelta = new Vector3(0.0f, 0.0f, 0.0f);
854854

855855
/// Write per light type matrices, splitDatas and culling parameters

com.unity.render-pipelines.high-definition/Runtime/Lighting/Shadow/HDCachedShadowAtlas.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,7 @@ public HDCachedShadowAtlas(ShadowMapType type)
8282
m_RecordsPendingPlacement = new NativeHashMap<int, CachedShadowRecord>(s_InitialCapacity, Allocator.Persistent);
8383

8484
m_TransformCaches = new NativeHashMap<int, CachedTransform>(s_InitialCapacity / 2, Allocator.Persistent);
85+
m_IsACacheForShadows = true;
8586
}
8687

8788
public override void InitAtlas(HDShadowAtlasInitParameters atlasInitParams)

com.unity.render-pipelines.high-definition/Runtime/Lighting/Shadow/HDShadowAtlas.cs

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -178,21 +178,6 @@ public void UpdateSize(Vector2Int size)
178178
}
179179
}
180180

181-
internal void AddShadowRequest(HDShadowRequestHandle shadowRequest)
182-
{
183-
m_ShadowRequests.Add(shadowRequest);
184-
}
185-
186-
internal static void AddShadowRequest(ref HDDynamicShadowAtlasUnmanaged shadowAtlas, HDShadowRequestHandle shadowRequest)
187-
{
188-
shadowAtlas.shadowRequests.Add(shadowRequest);
189-
}
190-
191-
internal static void AddShadowRequest(ref HDCachedShadowAtlasUnmanaged shadowAtlas, HDShadowRequestHandle shadowRequest)
192-
{
193-
shadowAtlas.shadowRequests.Add(shadowRequest);
194-
}
195-
196181
public void UpdateDebugSettings(LightingDebugSettings lightingDebugSettings)
197182
{
198183
m_LightingDebugSettings = lightingDebugSettings;

0 commit comments

Comments
 (0)