|
@@ -100,6 +100,10 @@ layout(set = 0, binding = 3, std430) buffer restrict ClusterRender {
|
|
}
|
|
}
|
|
cluster_render;
|
|
cluster_render;
|
|
|
|
|
|
|
|
+#ifdef USE_ATTACHMENT
|
|
|
|
+layout(location = 0) out vec4 frag_color;
|
|
|
|
+#endif
|
|
|
|
+
|
|
void main() {
|
|
void main() {
|
|
//convert from screen to cluster
|
|
//convert from screen to cluster
|
|
uvec2 cluster = uvec2(gl_FragCoord.xy) >> state.screen_to_clusters_shift;
|
|
uvec2 cluster = uvec2(gl_FragCoord.xy) >> state.screen_to_clusters_shift;
|
|
@@ -113,6 +117,8 @@ void main() {
|
|
uint usage_write_offset = cluster_offset + (element_index >> 5);
|
|
uint usage_write_offset = cluster_offset + (element_index >> 5);
|
|
uint usage_write_bit = 1 << (element_index & 0x1F);
|
|
uint usage_write_bit = 1 << (element_index & 0x1F);
|
|
|
|
|
|
|
|
+ uint aux = 0;
|
|
|
|
+
|
|
#ifdef USE_SUBGROUPS
|
|
#ifdef USE_SUBGROUPS
|
|
|
|
|
|
uint cluster_thread_group_index;
|
|
uint cluster_thread_group_index;
|
|
@@ -138,7 +144,7 @@ void main() {
|
|
cluster_thread_group_index = subgroupBallotExclusiveBitCount(mask);
|
|
cluster_thread_group_index = subgroupBallotExclusiveBitCount(mask);
|
|
|
|
|
|
if (cluster_thread_group_index == 0) {
|
|
if (cluster_thread_group_index == 0) {
|
|
- atomicOr(cluster_render.data[usage_write_offset], usage_write_bit);
|
|
|
|
|
|
+ aux = atomicOr(cluster_render.data[usage_write_offset], usage_write_bit);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
#else
|
|
#else
|
|
@@ -147,7 +153,7 @@ void main() {
|
|
if (!gl_HelperInvocation)
|
|
if (!gl_HelperInvocation)
|
|
#endif
|
|
#endif
|
|
{
|
|
{
|
|
- atomicOr(cluster_render.data[usage_write_offset], usage_write_bit);
|
|
|
|
|
|
+ aux = atomicOr(cluster_render.data[usage_write_offset], usage_write_bit);
|
|
}
|
|
}
|
|
#endif
|
|
#endif
|
|
//find the current element in the depth usage list and mark the current depth as used
|
|
//find the current element in the depth usage list and mark the current depth as used
|
|
@@ -162,7 +168,7 @@ void main() {
|
|
if (!gl_HelperInvocation) {
|
|
if (!gl_HelperInvocation) {
|
|
z_write_bit = subgroupOr(z_write_bit); //merge all Zs
|
|
z_write_bit = subgroupOr(z_write_bit); //merge all Zs
|
|
if (cluster_thread_group_index == 0) {
|
|
if (cluster_thread_group_index == 0) {
|
|
- atomicOr(cluster_render.data[z_write_offset], z_write_bit);
|
|
|
|
|
|
+ aux = atomicOr(cluster_render.data[z_write_offset], z_write_bit);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
#else
|
|
#else
|
|
@@ -171,7 +177,11 @@ void main() {
|
|
if (!gl_HelperInvocation)
|
|
if (!gl_HelperInvocation)
|
|
#endif
|
|
#endif
|
|
{
|
|
{
|
|
- atomicOr(cluster_render.data[z_write_offset], z_write_bit);
|
|
|
|
|
|
+ aux = atomicOr(cluster_render.data[z_write_offset], z_write_bit);
|
|
}
|
|
}
|
|
#endif
|
|
#endif
|
|
|
|
+
|
|
|
|
+#ifdef USE_ATTACHMENT
|
|
|
|
+ frag_color = vec4(float(aux));
|
|
|
|
+#endif
|
|
}
|
|
}
|