I notice that the depth buffer in HDRP is a texture atlas because depth-only RT does not support mipmap. This causes an issue where ctx.cmd.SetComputeIntParam(cullingShader, "_DepthPyramidMaxMip", ctx.cameraDepthBuffer.rt.mipmapCount - 1); does not work for the depth buffer. In the HDRP source code, I found use cb._SsrDepthPyramidMaxMip = hdCamera.depthBufferMipChainInfo.mipLevelCount - 1; to get the mipmap count, but hdCamera.depthBufferMipChainInfo is not accessible due to its protection level. Is there another way to get the level? Or at least a good number workaround?
I just find out this in HDUtils.cs: mipLevel++ while ((mipSize.x > 1) || (mipSize.y > 1)). Does that mean I can simply use log2(max(actualWidth, actualHeight)) to get the max mip level?
Yes, the depth mip chain always contains all the mips, their offset are stored in a compute buffer too:
hdCamera.depthBufferMipChainInfo.GetOffsetBufferData(m_DepthPyramidMipLevelOffsetsBuffer);
And they are used like this: Graphics/Packages/com.unity.render-pipelines.high-definition/Runtime/Lighting/ScreenSpaceLighting/ScreenSpaceReflections.compute at master · Unity-Technologies/Graphics · GitHub