Avoid atomic ops on vector members

* This doesn't translate well to metalsl and is in general not very useful - we
  were only doing it to avoid packing issues which in some cases are moot
  anyway. E.g. the histogram buffer doesn't have to be std140 and packed like an
  array of vectors, it can be std430 and packed like an array of uints.
This commit is contained in:
baldurk committed 2018-09-05 12:51:00 +01:00
1 parent bea1b87f59
commit 345208e0d9
5 files changed
+18 -22

No files matched your search

+4 -4
View File
@@ -24,9 +24,9 @@
//#include "texsample.h" // while includes aren't supported in glslang, this will be added in code
layout(binding=0, std140) buffer minmaxresultdest
layout(binding=0, std430) buffer minmaxresultdest
{
uvec4 result[HGRAM_NUM_BUCKETS];
uint result[HGRAM_NUM_BUCKETS];
} dest;
layout (local_size_x = HGRAM_TILES_PER_BLOCK, local_size_y = HGRAM_TILES_PER_BLOCK) in;
@@ -183,8 +183,8 @@ void main()
}
#endif
if(bucketIdx >= 0 && bucketIdx < HGRAM_NUM_BUCKETS)
atomicAdd(dest.result[bucketIdx].x, 1U);
if(bucketIdx < HGRAM_NUM_BUCKETS)
atomicAdd(dest.result[bucketIdx], 1U);
}
}
}
+8 -3
View File
@@ -34,7 +34,12 @@ layout(binding = 2, std430) readonly buffer index_data
layout(binding = 3, std140) buffer pickresult_buffer
{
uvec4 counter;
uint counter;
// individual padding to prevent uint/uint3 packing woes
uint pad0;
uint pad1;
uint pad2;
uvec4 results[];
} pickresult;
@@ -162,7 +167,7 @@ void trianglePath(uint threadID)
float dist1 = distance(pos1.xyz/pos1.w, hitPosition);
float dist2 = distance(pos2.xyz/pos2.w, hitPosition);
uint result_idx = atomicAdd(pickresult.counter.x, 1u);
uint result_idx = atomicAdd(pickresult.counter, 1u);
uint meshVert = vertid0;
if (dist1 < dist0 && dist1 < dist2)
@@ -208,7 +213,7 @@ void defaultPath(uint threadID)
float len = length(scr - meshpick.coords);
if(len < 35.0f)
{
uint result_idx = atomicAdd(pickresult.counter.x, 1u);
uint result_idx = atomicAdd(pickresult.counter, 1u);
pickresult.results[result_idx] = uvec4(vertid, idx, floatBitsToUint(len), floatBitsToUint(wpos.z));
}
}