Skip to content

Commit cc9c63a

Browse files
author
runes
committed
Minor refactoring in HDRenderLoop: Renamed light types are now referred to as volumes and light models are now referred to as light categories
1 parent ea64d4d commit cc9c63a

File tree

7 files changed

+139
-146
lines changed

7 files changed

+139
-146
lines changed

Assets/ScriptableRenderLoop/HDRenderLoop/Debug/Resources/DebugViewTiles.shader

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ Shader "Hidden/HDRenderLoop/DebugViewTiles"
101101
#endif
102102

103103
int n = 0;
104-
for(int category = 0; category < NR_LIGHT_MODELS; category++)
104+
for(int category = 0; category < NR_LIGHT_CATEGORIES; category++)
105105
{
106106
uint mask = 1u << category;
107107
uint start;

Assets/ScriptableRenderLoop/HDRenderLoop/Lighting/TilePass/Resources/lightlistbuild-bigtile.compute

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -212,7 +212,7 @@ void CullByExactEdgeTests(uint threadID, int iNrCoarseLights, uint2 viTilLL, uin
212212
for(int l=0; l<iNrCoarseLights; l++)
213213
{
214214
const uint idxCoarse = lightsListLDS[l];
215-
[branch]if (idxCoarse<(uint)g_iNrVisibLights && _LightShapeData[idxCoarse].lightType != SPHERE_LIGHT) // don't bother doing edge tests for sphere lights since these have camera aligned bboxes.
215+
[branch]if (idxCoarse<(uint)g_iNrVisibLights && _LightShapeData[idxCoarse].lightVolume != SPHERE_VOLUME) // don't bother doing edge tests for sphere lights since these have camera aligned bboxes.
216216
{
217217
SFiniteLightBound lgtDat = g_data[idxCoarse];
218218

Assets/ScriptableRenderLoop/HDRenderLoop/Lighting/TilePass/Resources/lightlistbuild-clustered.compute

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -331,7 +331,7 @@ void LIGHTLISTGEN(uint threadID : SV_GroupIndex, uint3 u3GroupID : SV_GroupID)
331331
InterlockedAdd(g_LayeredSingleIdxBuffer[0], (uint) iSpaceAvail, start); // alloc list memory
332332
}
333333

334-
int modelListCount[NR_LIGHT_MODELS]={0,0,0}; // direct light count and reflection lights
334+
int categoryListCount[NR_LIGHT_CATEGORIES]={0,0,0}; // direct light count and reflection lights
335335
uint offs = start;
336336
for(int ll=0; ll<iNrCoarseLights; ll+=4)
337337
{
@@ -347,7 +347,7 @@ void LIGHTLISTGEN(uint threadID : SV_GroupIndex, uint3 u3GroupID : SV_GroupID)
347347
if(offs<(start+iSpaceAvail) && i<nrClusters && CheckIntersection(l, i, viTilLL.xy, viTilUR.xy, suggestedBase) )
348348
{
349349
uint lightCategory = _LightShapeData[coarseList[l]].lightCategory;
350-
++modelListCount[lightCategory == REFLECTION_LIGHT ? 1 : 0];
350+
++categoryListCount[lightCategory];
351351
g_vLayeredLightList[offs++] = _LightShapeData[coarseList[l]].lightIndex; // reflection lights will be last since we sorted
352352
}
353353
}
@@ -359,14 +359,14 @@ void LIGHTLISTGEN(uint threadID : SV_GroupIndex, uint3 u3GroupID : SV_GroupID)
359359

360360
uint localOffs=0;
361361
offs = i*nrTilesX*nrTilesY + tileIDX.y*nrTilesX + tileIDX.x;
362-
for(int m=0; m<NR_LIGHT_MODELS; m++)
362+
for(int category=0; category<NR_LIGHT_CATEGORIES; category++)
363363
{
364-
int numLights = min(modelListCount[m],31); // only allow 5 bits
364+
int numLights = min(categoryListCount[category],31); // only allow 5 bits
365365
if(i<nrClusters)
366366
{
367367
g_LayeredOffset[offs] = (start+localOffs) | (((uint) numLights)<<27);
368368
offs += (nrClusters*nrTilesX*nrTilesY);
369-
localOffs += modelListCount[m]; // use unclamped count for localOffs
369+
localOffs += categoryListCount[category]; // use unclamped count for localOffs
370370
}
371371
}
372372

@@ -480,7 +480,7 @@ int CullByExactEdgeTests(uint threadID, int iNrCoarseLights, uint2 viTilLL, uint
480480
GroupMemoryBarrierWithGroupSync();
481481
#endif
482482
const int idxCoarse = coarseList[l];
483-
[branch]if (_LightShapeData[idxCoarse].lightType != SPHERE_LIGHT) // don't bother doing edge tests for sphere lights since these have camera aligned bboxes.
483+
[branch]if (_LightShapeData[idxCoarse].lightVolume != SPHERE_VOLUME) // don't bother doing edge tests for sphere lights since these have camera aligned bboxes.
484484
{
485485
SFiniteLightBound lgtDat = g_data[idxCoarse];
486486

Assets/ScriptableRenderLoop/HDRenderLoop/Lighting/TilePass/Resources/lightlistbuild.compute

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ groupshared uint ldsDoesLightIntersect[2];
5252
#endif
5353
groupshared int ldsNrLightsFinal;
5454

55-
groupshared int ldsModelListCount[NR_LIGHT_MODELS]; // since NR_LIGHT_MODELS is 3
55+
groupshared int ldsCategoryListCount[NR_LIGHT_CATEGORIES]; // since NR_LIGHT_CATEGORIES is 3
5656

5757
#ifdef PERFORM_SPHERICAL_INTERSECTION_TESTS
5858
groupshared uint lightOffsSph;
@@ -222,7 +222,7 @@ void LIGHTLISTGEN(uint threadID : SV_GroupIndex, uint3 u3GroupID : SV_GroupID)
222222
#endif
223223

224224
//
225-
if(t<NR_LIGHT_MODELS) ldsModelListCount[t]=0;
225+
if(t<NR_LIGHT_CATEGORIES) ldsCategoryListCount[t]=0;
226226

227227
#if !defined(SHADER_API_XBOXONE) && !defined(SHADER_API_PSSL)
228228
GroupMemoryBarrierWithGroupSync();
@@ -232,7 +232,7 @@ void LIGHTLISTGEN(uint threadID : SV_GroupIndex, uint3 u3GroupID : SV_GroupID)
232232
int nrLightsCombinedList = min(ldsNrLightsFinal,MAX_NR_COARSE_ENTRIES);
233233
for(int i=t; i<nrLightsCombinedList; i+=NR_THREADS)
234234
{
235-
InterlockedAdd(ldsModelListCount[_LightShapeData[prunedList[i]].lightCategory], 1);
235+
InterlockedAdd(ldsCategoryListCount[_LightShapeData[prunedList[i]].lightCategory], 1);
236236
}
237237

238238

@@ -246,9 +246,9 @@ void LIGHTLISTGEN(uint threadID : SV_GroupIndex, uint3 u3GroupID : SV_GroupID)
246246
int localOffs=0;
247247
int offs = tileIDX.y*nrTilesX + tileIDX.x;
248248

249-
for(int m=0; m<NR_LIGHT_MODELS; m++)
249+
for(int category=0; category<NR_LIGHT_CATEGORIES; category++)
250250
{
251-
int nrLightsFinal = ldsModelListCount[ m ];
251+
int nrLightsFinal = ldsCategoryListCount[category];
252252
int nrLightsFinalClamped = nrLightsFinal<MAX_NR_PRUNED_ENTRIES ? nrLightsFinal : MAX_NR_PRUNED_ENTRIES;
253253

254254

@@ -330,10 +330,10 @@ void FinePruneLights(uint threadID, int iNrCoarseLights, uint2 viTilLL, float4 v
330330
{
331331
// fetch light
332332
int idxCoarse = l<iNrCoarseLights ? coarseList[l] : 0;
333-
uint uLgtType = l<iNrCoarseLights ? _LightShapeData[idxCoarse].lightType : 0;
333+
uint uLightVolume = l<iNrCoarseLights ? _LightShapeData[idxCoarse].lightVolume : 0;
334334

335335
// spot
336-
while(l<iNrCoarseLights && uLgtType==SPOT_LIGHT)
336+
while(l<iNrCoarseLights && uLightVolume==SPOT_VOLUME)
337337
{
338338
LightShapeData lightData = _LightShapeData[idxCoarse];
339339
// TODO: Change by SebL
@@ -361,11 +361,11 @@ void FinePruneLights(uint threadID, int iNrCoarseLights, uint2 viTilLL, float4 v
361361

362362
uLightsFlags[l<32 ? 0 : 1] |= (uVal<<(l&31));
363363
++l; idxCoarse = l<iNrCoarseLights ? coarseList[l] : 0;
364-
uLgtType = l<iNrCoarseLights ? _LightShapeData[idxCoarse].lightType : 0;
364+
uLightVolume = l<iNrCoarseLights ? _LightShapeData[idxCoarse].lightVolume : 0;
365365
}
366366

367367
// sphere
368-
while(l<iNrCoarseLights && uLgtType==SPHERE_LIGHT)
368+
while(l<iNrCoarseLights && uLightVolume==SPHERE_VOLUME)
369369
{
370370
LightShapeData lightData = _LightShapeData[idxCoarse];
371371

@@ -388,11 +388,11 @@ void FinePruneLights(uint threadID, int iNrCoarseLights, uint2 viTilLL, float4 v
388388

389389
uLightsFlags[l<32 ? 0 : 1] |= (uVal<<(l&31));
390390
++l; idxCoarse = l<iNrCoarseLights ? coarseList[l] : 0;
391-
uLgtType = l<iNrCoarseLights ? _LightShapeData[idxCoarse].lightType : 0;
391+
uLightVolume = l<iNrCoarseLights ? _LightShapeData[idxCoarse].lightVolume : 0;
392392
}
393393

394394
// Box
395-
while(l<iNrCoarseLights && uLgtType==BOX_LIGHT)
395+
while(l<iNrCoarseLights && uLightVolume==BOX_VOLUME)
396396
{
397397
LightShapeData lightData = _LightShapeData[idxCoarse];
398398

@@ -415,11 +415,11 @@ void FinePruneLights(uint threadID, int iNrCoarseLights, uint2 viTilLL, float4 v
415415

416416
uLightsFlags[l<32 ? 0 : 1] |= (uVal<<(l&31));
417417
++l; idxCoarse = l<iNrCoarseLights ? coarseList[l] : 0;
418-
uLgtType = l<iNrCoarseLights ? _LightShapeData[idxCoarse].lightType : 0;
418+
uLightVolume = l<iNrCoarseLights ? _LightShapeData[idxCoarse].lightVolume : 0;
419419
}
420420

421421
// in case we have some corrupt data make sure we terminate
422-
if(uLgtType>=MAX_TYPES) ++l;
422+
if(uLightVolume >=MAX_VOLUME_TYPES) ++l;
423423
}
424424

425425
InterlockedOr(ldsDoesLightIntersect[0], uLightsFlags[0]);

0 commit comments

Comments
 (0)