In HDRP's compute shader how to correctly translate a World Position to ScreenSpace position?

Hi. I have a compute shader that takes GameObject’s world position ,and I want to get the screen space position of it for further operations. (Suppose there’s only 1 camera in the scene)

However I find it frustrating to do it.

some includes
...

RWStructuredBuffer<float4> _TestData;
float4 _WorldPos;

void CalculateScreenSpacePosition()
{
    float4 clipPos = ComputeClipSpacePosition(_WorldPos, UNITY_MATRIX_VP);
    _TestData[0] = clipPos;
 
    float3 ndcPos = ComputeNormalizedDeviceCoordinatesWithZ(_WorldPos, UNITY_MATRIX_VP);
    _TestData[1] = float4(ndcPos, 1);
 
    float4 screenPos = ComputeScreenPos(clipPos, _ProjectionParams.x);
    _TestData[2] = screenPos;
}

[numthreads(1,1,1)]
void CSMain (uint3 id : SV_DispatchThreadID)
{
     CalculateScreenSpacePosition();
}

I did some tests and use a vector buffer to retrieve the results .
However the positions don’t look correct.

8940540--1226268--upload_2023-4-11_19-39-18.png
the elements in the array of the pic: clip pos, ndc pos, screen pos

And I try to get the native matrices it doesn’t feel very correct.

8940540--1226271--upload_2023-4-11_19-41-6.png

 _MatrixData[0] = UNITY_MATRIX_V;

Above is the UNITY_MATRIX_V matrix I got from compute shader. It sort of lacks of position infomrations.

However I manually log the Camera’s worldToCameraMatrix in c# code, it gives correct result with positions informations.

I can’t find any related resources or guide in google/GPT/source code in HDRP to go further.
So I need help with how to translate a world pos into screen space pos correctly in compute shader.

OK, I’ve found that you need to translate the world pos to a relative WS as HDRP use camera as center for rendering.

    float3 worldPosRelative = GetCameraRelativePositionWS(_WorldPos);
    float4 clipPos = ComputeClipSpacePosition(worldPosRelative, UNITY_MATRIX_VP);
    float3 ndcPos = ComputeNormalizedDeviceCoordinatesWithZ(worldPosRelative, UNITY_MATRIX_VP);

    float4 positionSS = 0;
    positionSS.xy = ndcPos.xy / _ScreenSize.zw;