static public void ExecuteLightClusterDebug(CommandBuffer cmd, LightClusterDebugParameters parameters, LightClusterDebugResources resources)
        {
            // Bind the output texture
            CoreUtils.SetRenderTarget(cmd, resources.debugLightClusterTexture, resources.depthStencilBuffer, clearFlag: ClearFlag.Color, clearColor: Color.black);

            // Inject all the parameters to the debug compute
            cmd.SetComputeBufferParam(parameters.lightClusterDebugCS, parameters.lightClusterDebugKernel, HDShaderIDs._RaytracingLightCluster, parameters.lightCluster);
            cmd.SetComputeVectorParam(parameters.lightClusterDebugCS, _ClusterCellSize, parameters.clusterCellSize);
            cmd.SetComputeTextureParam(parameters.lightClusterDebugCS, parameters.lightClusterDebugKernel, HDShaderIDs._CameraDepthTexture, resources.depthStencilBuffer);

            // Target output texture
            cmd.SetComputeTextureParam(parameters.lightClusterDebugCS, parameters.lightClusterDebugKernel, _DebutLightClusterTexture, resources.debugLightClusterTexture);

            // Dispatch the compute
            int lightVolumesTileSize = 8;
            int numTilesX            = (parameters.texWidth + (lightVolumesTileSize - 1)) / lightVolumesTileSize;
            int numTilesY            = (parameters.texHeight + (lightVolumesTileSize - 1)) / lightVolumesTileSize;

            cmd.DispatchCompute(parameters.lightClusterDebugCS, parameters.lightClusterDebugKernel, numTilesX, numTilesY, 1);

            // Bind the parameters
            parameters.debugMaterialProperties.SetBuffer(HDShaderIDs._RaytracingLightCluster, parameters.lightCluster);
            parameters.debugMaterialProperties.SetVector(_ClusterCellSize, parameters.clusterCellSize);
            parameters.debugMaterialProperties.SetTexture(HDShaderIDs._CameraDepthTexture, resources.depthTexture);

            // Draw the faces
            cmd.DrawProcedural(Matrix4x4.identity, parameters.debugMaterial, 1, MeshTopology.Lines, 48, 64 * 64 * 32, parameters.debugMaterialProperties);
            cmd.DrawProcedural(Matrix4x4.identity, parameters.debugMaterial, 0, MeshTopology.Triangles, 36, 64 * 64 * 32, parameters.debugMaterialProperties);
        }
        public void EvaluateClusterDebugView(CommandBuffer cmd, HDCamera hdCamera)
        {
            LightClusterDebugParameters parameters = PrepareLightClusterDebugParameters(hdCamera);
            LightClusterDebugResources  resources  = PrepareLightClusterDebugResources(m_DebugLightClusterTexture);

            ExecuteLightClusterDebug(cmd, parameters, resources);

            // Bind the result
            m_RenderPipeline.PushFullScreenDebugTexture(hdCamera, cmd, m_DebugLightClusterTexture, FullScreenDebugMode.LightCluster);
        }
        LightClusterDebugParameters PrepareLightClusterDebugParameters(HDCamera hdCamera)
        {
            LightClusterDebugParameters parameters = new LightClusterDebugParameters();

            parameters.texWidth                = hdCamera.actualWidth;
            parameters.texHeight               = hdCamera.actualHeight;
            parameters.clusterCellSize         = clusterCellSize;
            parameters.lightCluster            = m_LightCluster;
            parameters.lightClusterDebugCS     = m_RenderPipelineRayTracingResources.lightClusterDebugCS;
            parameters.lightClusterDebugKernel = parameters.lightClusterDebugCS.FindKernel("DebugLightCluster");
            parameters.debugMaterial           = m_DebugMaterial;
            return(parameters);
        }