<html>
<head>
<base href="https://bugs.freedesktop.org/">
</head>
<body>
<p>
<div>
<b><a class="bz_bug_link
bz_status_NEEDINFO "
title="NEEDINFO - glMemoryBarrier doesn't work."
href="https://bugs.freedesktop.org/show_bug.cgi?id=110229#c31">Comment # 31</a>
on <a class="bz_bug_link
bz_status_NEEDINFO "
title="NEEDINFO - glMemoryBarrier doesn't work."
href="https://bugs.freedesktop.org/show_bug.cgi?id=110229">bug 110229</a>
from <span class="vcard"><a class="email" href="mailto:laurentduroisin@gmail.com" title="Laurent <laurentduroisin@gmail.com>"> <span class="fn">Laurent</span></a>
</span></b>
<pre>Okey, I've found a temporary solution : putting instructions in the second
fragment shader to slow down the shader execution code and it works...
const std::string fragmentShader2 =
R"(
#version 140
#extension GL_ARB_shader_atomic_counters : require
#extension GL_ARB_shading_language_420pack : require
#extension GL_ARB_shader_image_load_store : require
#extension GL_ARB_shader_storage_buffer_object : require
#define MAX_FRAGMENTS 75
struct NodeType {
vec4 color;
float depth;
uint next;
};
layout(binding = 0, r32ui) coherent uniform uimage2D
headPointers;
layout(binding = 0, std430) coherent buffer linkedLists {
NodeType nodes[];
};
void main() {
NodeType frags[MAX_FRAGMENTS];
NodeType frags2[MAX_FRAGMENTS];
int count = 0;
uint n = imageLoad(headPointers, ivec2(gl_FragCoord.xy)).r;
while( n != 0u && count < MAX_FRAGMENTS) {
frags[count] = nodes[n];
frags2[count] = frags[count];
n = nodes[n].next;
imageStore(headPointers, ivec2(gl_FragCoord.xy),
uvec4(n, 0, 0, 0));
count++;
}
//merge sort
int i, j1, j2, k;
int a, b, c;
int step = 1;
NodeType leftArray[MAX_FRAGMENTS/2]; //for merge sort
while (step <= count)
{
i = 0;
while (i < count - step)
{
////////////////////////////////////////////////////////////////////////
//merge(step, i, i + step, min(i + step + step,
count));
a = i;
b = i + step;
c = (i + step + step) >= count ? count : (i + step +
step);
for (k = 0; k < step; k++)
leftArray[k] = frags[a + k];
j1 = 0;
j2 = 0;
for (k = a; k < c; k++)
{
if (b + j1 >= c || (j2 < step &&
leftArray[j2].depth > frags[b + j1].depth))
frags[k] = leftArray[j2++];
else
frags[k] = frags[b + j1++];
}
////////////////////////////////////////////////////////////////////////
i += 2 * step;
}
step *= 2;
}
vec4 color = vec4(0, 0, 0, 0);
for( int i = 0; i < count; i++ )
{
color = mix( color, frags[i].color, frags[i].color.a);
if (frags2[i].color.r > 1 || frags2[i].color.g > 1 ||
frags2[i].color.b > 1)
color = vec4(1, 1, 1, 1);
}
gl_FragColor = color;
})";
First I had to affect n whith nodes[n] instead of frags[count], I don't
understand why.
Secondly I have to make another array and adding a if in the last loop (for)
when I mix colors, otherwise, I have a black screen....</pre>
</div>
</p>
<hr>
<span>You are receiving this mail because:</span>
<ul>
<li>You are the assignee for the bug.</li>
</ul>
</body>
</html>