Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions com.unity.render-pipelines.high-definition/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
- Fixed Custom Post Processes affecting preview cameras.
- Fixed serialization issue with matcap scale intensity.
- Fixed XR shadows culling
- Fixed error Maximum allowed thread group count is 65535 when resolution is very high.

### Changed
- Removed XRSystemTests. The GC verification is now done during playmode tests (case 1285012).
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
#pragma kernel ClearList

RWStructuredBuffer<uint> _LightListToClear;
int _LightListEntries;
int2 _LightListEntriesAndOffset;

#define _LightListEntries (uint)_LightListEntriesAndOffset.x
#define _LightListOffset (uint)_LightListEntriesAndOffset.y

[numthreads(64, 1, 1)]
void ClearList(uint3 id : SV_DispatchThreadID)
{
if (id.x < (uint)_LightListEntries)
_LightListToClear[id.x] = 0;
if ((id.x + _LightListOffset) < (uint)_LightListEntries)
_LightListToClear[id.x + _LightListOffset] = 0;
}
Original file line number Diff line number Diff line change
Expand Up @@ -3126,9 +3126,27 @@ void ClearLightList(HDCamera camera, CommandBuffer cmd, ComputeBuffer bufferToCl
var kernel = cs.FindKernel("ClearList");

cmd.SetComputeBufferParam(cs, kernel, HDShaderIDs._LightListToClear, bufferToClear);
cmd.SetComputeIntParam(cs, HDShaderIDs._LightListEntries, bufferToClear.count);
Vector2 countAndOffset = new Vector2Int(bufferToClear.count, 0);

int groupSize = 64;
int totalNumberOfGroupsNeeded = (bufferToClear.count + groupSize - 1) / groupSize;

const int maxAllowedGroups = 65535;
// On higher resolutions we might end up with more than 65535 group which is not allowed, so we need to to have multiple dispatches.
int i = 0;
while (totalNumberOfGroupsNeeded > 0)
{
countAndOffset.y = maxAllowedGroups * i;
cmd.SetComputeVectorParam(cs, HDShaderIDs._LightListEntriesAndOffset, countAndOffset);

int currGroupCount = Math.Min(maxAllowedGroups, totalNumberOfGroupsNeeded);

cmd.DispatchCompute(cs, kernel, currGroupCount, 1, 1);

totalNumberOfGroupsNeeded -= currGroupCount;
i++;
}

cmd.DispatchCompute(cs, kernel, (bufferToClear.count + groupSize - 1) / groupSize, 1, 1);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ static class HDShaderIDs
public static readonly int g_vLayeredOffsetsBuffer = Shader.PropertyToID("g_vLayeredOffsetsBuffer");

public static readonly int _LightListToClear = Shader.PropertyToID("_LightListToClear");
public static readonly int _LightListEntries = Shader.PropertyToID("_LightListEntries");
public static readonly int _LightListEntriesAndOffset = Shader.PropertyToID("_LightListEntriesAndOffset");

public static readonly int _ViewTilesFlags = Shader.PropertyToID("_ViewTilesFlags");
public static readonly int _MousePixelCoord = Shader.PropertyToID("_MousePixelCoord");
Expand Down