@@ -17,6 +17,8 @@ layout(constant_id = 0) const uint thresholdsCountConst = 0u;
1717layout (local_size_x = 8 , local_size_y = 8 , local_size_z = 8 ) in ;
1818
1919#include "descriptor_sets.inc.glsl"
20+ #include "frame_set_common.inc.glsl"
21+ #include "morton_code.inc.glsl"
2022
2123layout (set = DESCRIPTOR_SET_FREQUENT, binding = 0 , std430) uniform EdgeTable {
2224 uint [256u] edges;
@@ -49,9 +51,6 @@ layout(set = DESCRIPTOR_SET_FREQUENT, binding = 5, scalar) buffer bufferatomics
4951 IndirectCommand[] commands;
5052};
5153
52- layout (set = DESCRIPTOR_SET_FREQUENT, binding = 6 ) uniform sampler linearSampler;
53- layout (set = DESCRIPTOR_SET_FREQUENT, binding = 7 ) uniform sampler nearestSampler;
54-
5554layout (set = DESCRIPTOR_SET_FREQUENT, binding = 8 ) uniform texture3D densityImageMin;
5655layout (set = DESCRIPTOR_SET_FREQUENT, binding = 9 ) uniform texture3D densityImageMax;
5756
@@ -73,15 +72,8 @@ uvec3 indexOffset(uint idx) {
7372
7473uint vertexKey(uvec3 pos1, uvec3 pos2) {
7574 uvec3 pos = pos1 + pos2;
76-
77- uvec3 sizes = uvec3 (512u * 2u + 1u);
78- pos = min (sizes - uvec3 (1u), pos);
79-
80- uint key = pos.z * sizes.x * sizes.y +
81- pos.y * sizes.x +
82- pos.x;
83-
84- return key;
75+ uvec3 size = uvec3 (512u * 2u + 1u);
76+ return mortonCode(pos, size);
8577}
8678
8779uint vertexKeyFromIndexOffsets(uint idx1, uint idx2) {
@@ -145,7 +137,7 @@ void main() {
145137 if (! any (greaterThanEqual (gl_LocalInvocationID, gl_WorkGroupSize - uvec3 (1u)))) {
146138 uvec3 lowResPos = workgroupBase / uvec3 (8u);
147139 // Workgroup 8x8x8 => +3 mip levels but min/max textures don't have the top mip level, so +2
148- float densityMax = texelFetch(sampler3D (densityImageMax, nearestSampler ), ivec3 (lowResPos), int (lod + 2u)).x;
140+ float densityMax = texelFetch(sampler3D (densityImageMax, samplerNearest ), ivec3 (lowResPos), int (lod + 2u)).x;
149141 bool empty = true;
150142 bool full = true;
151143 for (uint i = 0u; i < finalThresholdsCount; i++ ) {
@@ -169,7 +161,7 @@ void main() {
169161 uvec3 offset = uvec3 (x, y, z);
170162
171163 uvec3 pos = base + offset;
172- float density = texelFetch(sampler3D (densityImage, nearestSampler ), ivec3 (pos), int (lod)).x;
164+ float density = texelFetch(sampler3D (densityImage, samplerNearest ), ivec3 (pos), int (lod)).x;
173165
174166 uint index = ((x + z) & 1u) + z * 2u + y * 4u;
175167
0 commit comments