diff --git a/Packages/com.unity.render-pipelines.universal@14.0.11/Runtime/OcclusionCulling/HierarchicalZOcclusionCullFeature.cs b/Packages/com.unity.render-pipelines.universal@14.0.11/Runtime/OcclusionCulling/HierarchicalZOcclusionCullFeature.cs index 71e930a..10106ce 100644 --- a/Packages/com.unity.render-pipelines.universal@14.0.11/Runtime/OcclusionCulling/HierarchicalZOcclusionCullFeature.cs +++ b/Packages/com.unity.render-pipelines.universal@14.0.11/Runtime/OcclusionCulling/HierarchicalZOcclusionCullFeature.cs @@ -208,10 +208,10 @@ namespace X.Rendering.Feature resizeX = Mathf.IsPowerOfTwo(viewportSize.x) ? viewportSize.x : Mathf.NextPowerOfTwo(viewportSize.x); resizeY = Mathf.IsPowerOfTwo(viewportSize.y) ? viewportSize.y : Mathf.NextPowerOfTwo(viewportSize.y); - if (resizeX > viewportSize.x) - resizeX /= 2; - if (resizeY > viewportSize.y) - resizeY /= 2; + //if (resizeX > viewportSize.x) + // resizeX /= 2; + //if (resizeY > viewportSize.y) + // resizeY /= 2; Vector2Int hardwareTextureSize = new Vector2Int(resizeX, resizeY); mipLevelOffsets[0] = Vector2Int.zero; @@ -443,11 +443,12 @@ namespace X.Rendering.Feature }, filterMode: FilterMode.Point, name: depthPyramidNames[hizIndex]); depthPyramidTexs[hizIndex] = hizBuffer; - var dispatchX = Mathf.CeilToInt(mip0SizeNOP.x / 64f); - var dispatchY = Mathf.CeilToInt(mip0SizeNOP.y / 64f); + var dispatchX = Mathf.CeilToInt(mipOffsetAndSizes[0].z / 64f); + var dispatchY = Mathf.CeilToInt(mipOffsetAndSizes[0].w / 64f); cmd.SetComputeIntParam(settings.Spd, "mips", mipLevelCount); cmd.SetComputeIntParam(settings.Spd, "numWorkGroups", dispatchX * dispatchY); - + cmd.SetComputeVectorParam(settings.Spd, "inputTextureSize", new Vector4(mip0SizeNOP.x, mip0SizeNOP.y, 0, 0)); + cmd.SetComputeVectorArrayParam(settings.Spd, "_MipOffsetAndSizeArray", mipOffsetAndSizes); diff --git a/Packages/com.unity.render-pipelines.universal@14.0.11/Runtime/OcclusionCulling/Shaders/SPD.compute b/Packages/com.unity.render-pipelines.universal@14.0.11/Runtime/OcclusionCulling/Shaders/SPD.compute index 66dfc43..b871e70 100644 --- a/Packages/com.unity.render-pipelines.universal@14.0.11/Runtime/OcclusionCulling/Shaders/SPD.compute +++ b/Packages/com.unity.render-pipelines.universal@14.0.11/Runtime/OcclusionCulling/Shaders/SPD.compute @@ -16,6 +16,15 @@ #include "ffx/ffx_common_types.h" #include "Packages/com.unity.render-pipelines.core/ShaderLibrary/Common.hlsl" +Texture2D _InputDepth; +RWTexture2D _OutDepth; +float4 _MipOffsetAndSizeArray[16]; + +FfxUInt32 mips; +FfxUInt32x2 inputTextureSize; +FfxUInt32 numWorkGroups; +FFX_GROUPSHARED FfxUInt32 spdCounter; +RWTexture2D rw_internal_global_atomic; FFX_GROUPSHARED FfxFloat32 spdIntermediate[16][16]; void SpdStoreIntermediate(FfxUInt32 x, FfxUInt32 y, FfxFloat32x4 value) { @@ -52,9 +61,6 @@ FfxFloat16x4 SpdReduce4H(FfxFloat16x4 v0, FfxFloat16x4 v1, FfxFloat16x4 v2, FfxF return max(max(v0, v1), max(v2, v3)); #endif } -Texture2D _InputDepth; -RWTexture2D _OutDepth; -float4 _MipOffsetAndSizeArray[16]; FfxFloat32x4 SpdLoad(FfxInt32x2 coordinate, FfxUInt32 slice) { @@ -87,14 +93,12 @@ FfxFloat32x4 SpdLoadSourceImage(FfxInt32x2 coordinate, FfxUInt32 slice) FfxFloat32x4 SpdLoadSourceImageH(FfxInt32x2 coordinate, FfxUInt32 slice) { - return _InputDepth[coordinate].xxxx; + uint4 cur = _MipOffsetAndSizeArray[0]; + float2 uv = coordinate / float2(cur.zw); + FfxInt32x2 uv2 = FfxInt32x2(uv * inputTextureSize); + return _InputDepth[uv2].xxxx; } -FfxUInt32 mips; -FfxUInt32 numWorkGroups; -FFX_GROUPSHARED FfxUInt32 spdCounter; -RWTexture2D rw_internal_global_atomic; - void IncreaseAtomicCounter(FFX_PARAMETER_IN FfxUInt32 slice, FFX_PARAMETER_INOUT FfxUInt32 counter) { InterlockedAdd(rw_internal_global_atomic[FfxInt32x2(0, 0)] , 1, counter);