diff --git a/com.unity.render-pipelines.high-definition/CHANGELOG.md b/com.unity.render-pipelines.high-definition/CHANGELOG.md index 1f02bb53088..ff75bcae460 100644 --- a/com.unity.render-pipelines.high-definition/CHANGELOG.md +++ b/com.unity.render-pipelines.high-definition/CHANGELOG.md @@ -9,6 +9,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0. ### Fixed - Fixed GC allocations from XR occlusion mesh when using multipass. - Fixed XR depth copy when using MSAA. +- Fixed register spilling on FXC in light list shaders. ## [11.0.0] - 2020-10-21 diff --git a/com.unity.render-pipelines.high-definition/Runtime/Lighting/LightLoop/lightlistbuild-clustered.compute b/com.unity.render-pipelines.high-definition/Runtime/Lighting/LightLoop/lightlistbuild-clustered.compute index 2bd81fec1d2..04569707a71 100644 --- a/com.unity.render-pipelines.high-definition/Runtime/Lighting/LightLoop/lightlistbuild-clustered.compute +++ b/com.unity.render-pipelines.high-definition/Runtime/Lighting/LightLoop/lightlistbuild-clustered.compute @@ -69,6 +69,38 @@ groupshared float4 lightPlanes[4*6]; // Each plane is defined by a float4. 6 pla groupshared uint lightOffs; +groupshared int categoryListCountScratch[NR_THREADS * LIGHTCATEGORY_COUNT]; +groupshared int shiftIndexScratch[NR_THREADS * LIGHTCATEGORY_COUNT]; + +void ZeroCategoryListCountAndShiftIndex(uint threadIdx) +{ + for (int i = 0; i < LIGHTCATEGORY_COUNT; ++i) + { + categoryListCountScratch[threadIdx * LIGHTCATEGORY_COUNT + i] = 0; + shiftIndexScratch[threadIdx * LIGHTCATEGORY_COUNT + i] = 0; + } +} + +void WriteShiftIndex(uint threadIdx, uint index, int value) +{ + shiftIndexScratch[threadIdx * LIGHTCATEGORY_COUNT + index] = value; +} + +int ReadShiftIndex(uint threadIdx, uint index) +{ + return shiftIndexScratch[threadIdx * LIGHTCATEGORY_COUNT + index]; +} + +void IncrementCategoryListCount(uint threadIdx, uint index) +{ + categoryListCountScratch[threadIdx * LIGHTCATEGORY_COUNT + index]++; +} + +int ReadCategoryListCount(uint threadIdx, uint index) +{ + return categoryListCountScratch[threadIdx * LIGHTCATEGORY_COUNT + index]; +} + #ifdef ENABLE_DEPTH_TEXTURE_BACKPLANE groupshared uint ldsZMax; #endif @@ -375,14 +407,11 @@ void LIGHTLISTGEN(uint threadID : SV_GroupIndex, uint3 u3GroupID : SV_GroupID) // All our cull data are in the same list, but at render time envLights are separated so we need to shift the index // to make it work correctly - int shiftIndex[LIGHTCATEGORY_COUNT]; - ZERO_INITIALIZE_ARRAY(int, shiftIndex, LIGHTCATEGORY_COUNT); - shiftIndex[LIGHTCATEGORY_ENV] = _EnvLightIndexShift; - shiftIndex[LIGHTCATEGORY_DECAL] = _DecalIndexShift; - shiftIndex[LIGHTCATEGORY_DENSITY_VOLUME] = _DensityVolumeIndexShift; + ZeroCategoryListCountAndShiftIndex(t); - int categoryListCount[LIGHTCATEGORY_COUNT]; // number of direct lights, reflection probes, decals, density volumes, and probe volumes - ZERO_INITIALIZE_ARRAY(int, categoryListCount, LIGHTCATEGORY_COUNT); + WriteShiftIndex(t, LIGHTCATEGORY_ENV, _EnvLightIndexShift); + WriteShiftIndex(t, LIGHTCATEGORY_DECAL, _DecalIndexShift); + WriteShiftIndex(t, LIGHTCATEGORY_DENSITY_VOLUME, _DensityVolumeIndexShift); uint offs = start; for(int ll=0; ll