You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
27 lines
1.5 KiB
27 lines
1.5 KiB
#pragma kernel ClearDispatchIndirect
|
|
#pragma only_renderers d3d11 playstation xboxone xboxseries vulkan metal switch
|
|
|
|
RWBuffer<uint> g_DispatchIndirectBuffer : register( u0 ); // Indirect arguments have to be in a _buffer_, not a structured buffer
|
|
|
|
#include "Packages/com.unity.render-pipelines.core/ShaderLibrary/Common.hlsl"
|
|
#include "Packages/com.unity.render-pipelines.high-definition/Runtime/Lighting/LightLoop/LightLoop.cs.hlsl"
|
|
|
|
#ifdef PLATFORM_LANE_COUNT
|
|
#define NR_THREADS PLATFORM_LANE_COUNT
|
|
#else
|
|
#define NR_THREADS 64 // default to 64 threads per group on other platforms..
|
|
#endif
|
|
|
|
[numthreads(NR_THREADS, 1, 1)]
|
|
void ClearDispatchIndirect(uint dispatchThreadId : SV_DispatchThreadID)
|
|
{
|
|
// On iOS, we get a GPU hang/reset based upon the execution of the ClearDispatchIndirect kernel.
|
|
// The buffer is created using the 'NUM_FEATURE_VARIANTS' constant but we're dispatching a threadgroup of 64 threads, so we are presumably going out of bounds (Metal GPU errors are not terribly descriptive, but this is a common cause).
|
|
// In DirectX out-of-bounds reads are always zero and out-of-bounds writes are are a no op.
|
|
if (dispatchThreadId >= NUM_FEATURE_VARIANTS)
|
|
return;
|
|
|
|
g_DispatchIndirectBuffer[dispatchThreadId * 3 + 0] = 0; // ThreadGroupCountX
|
|
g_DispatchIndirectBuffer[dispatchThreadId * 3 + 1] = 1; // ThreadGroupCountY
|
|
g_DispatchIndirectBuffer[dispatchThreadId * 3 + 2] = 1; // ThreadGroupCountZ
|
|
}
|