|
@@ -13,7 +13,11 @@
|
|
|
layout(set = 0, binding = 0) uniform texture2D u_inputTex;
|
|
layout(set = 0, binding = 0) uniform texture2D u_inputTex;
|
|
|
layout(set = 0, binding = 1) uniform sampler u_nearestClampSampler;
|
|
layout(set = 0, binding = 1) uniform sampler u_nearestClampSampler;
|
|
|
|
|
|
|
|
|
|
+#if SRI_TEXEL_DIMENSION == 8
|
|
|
|
|
+const UVec2 REGION_SIZE = UVec2(2u, 2u);
|
|
|
|
|
+#else
|
|
|
const UVec2 REGION_SIZE = UVec2(2u, 4u);
|
|
const UVec2 REGION_SIZE = UVec2(2u, 4u);
|
|
|
|
|
+#endif
|
|
|
|
|
|
|
|
const UVec2 WORKGROUP_SIZE = UVec2(SRI_TEXEL_DIMENSION) / REGION_SIZE;
|
|
const UVec2 WORKGROUP_SIZE = UVec2(SRI_TEXEL_DIMENSION) / REGION_SIZE;
|
|
|
layout(local_size_x = WORKGROUP_SIZE.x, local_size_y = WORKGROUP_SIZE.y, local_size_z = 1) in;
|
|
layout(local_size_x = WORKGROUP_SIZE.x, local_size_y = WORKGROUP_SIZE.y, local_size_z = 1) in;
|
|
@@ -51,6 +55,28 @@ void main()
|
|
|
const Vec2 uv = (Vec2(gl_GlobalInvocationID.xy) * Vec2(REGION_SIZE) + 0.5) * u_oneOverViewportSize;
|
|
const Vec2 uv = (Vec2(gl_GlobalInvocationID.xy) * Vec2(REGION_SIZE) + 0.5) * u_oneOverViewportSize;
|
|
|
const Vec2 ndc = UV_TO_NDC(uv);
|
|
const Vec2 ndc = UV_TO_NDC(uv);
|
|
|
|
|
|
|
|
|
|
+#if SRI_TEXEL_DIMENSION == 8
|
|
|
|
|
+ // Get positions
|
|
|
|
|
+ // l0.z l0.w
|
|
|
|
|
+ // l0.x l0.y
|
|
|
|
|
+ Vec4 l0;
|
|
|
|
|
+ l0.x = sampleViewPositionZ(uv, 0, 0);
|
|
|
|
|
+ l0.y = sampleViewPositionZ(uv, 1, 0);
|
|
|
|
|
+ l0.z = sampleViewPositionZ(uv, 0, 1);
|
|
|
|
|
+ l0.w = sampleViewPositionZ(uv, 1, 1);
|
|
|
|
|
+
|
|
|
|
|
+ // Calculate derivatives.
|
|
|
|
|
+ Vec2 a = Vec2(l0.y, l0.z);
|
|
|
|
|
+ Vec2 b = Vec2(l0.x, l0.w);
|
|
|
|
|
+ const Vec2 dx = abs(a - b);
|
|
|
|
|
+
|
|
|
|
|
+ a = Vec2(l0.z, l0.w);
|
|
|
|
|
+ b = Vec2(l0.x, l0.y);
|
|
|
|
|
+ const Vec2 dy = abs(a - b);
|
|
|
|
|
+
|
|
|
|
|
+ F32 maxDerivativeX = max(dx.x, dx.y);
|
|
|
|
|
+ F32 maxDerivativeY = max(dy.x, dy.y);
|
|
|
|
|
+#else
|
|
|
// Get positions
|
|
// Get positions
|
|
|
// l1.z l1.w
|
|
// l1.z l1.w
|
|
|
// l1.x l1.y
|
|
// l1.x l1.y
|
|
@@ -79,6 +105,8 @@ void main()
|
|
|
|
|
|
|
|
F32 maxDerivativeX = max(max(dx.x, dx.y), max(dx.z, dx.w));
|
|
F32 maxDerivativeX = max(max(dx.x, dx.y), max(dx.z, dx.w));
|
|
|
F32 maxDerivativeY = max(max(dy.x, dy.y), max(dy.z, dy.w));
|
|
F32 maxDerivativeY = max(max(dy.x, dy.y), max(dy.z, dy.w));
|
|
|
|
|
+#endif
|
|
|
|
|
+
|
|
|
maxDerivativeX = subgroupMax(maxDerivativeX);
|
|
maxDerivativeX = subgroupMax(maxDerivativeX);
|
|
|
maxDerivativeY = subgroupMax(maxDerivativeY);
|
|
maxDerivativeY = subgroupMax(maxDerivativeY);
|
|
|
|
|
|