From: bugzilla-daemon@freedesktop.org
Subject: [Bug 110229] glMemoryBarrier doesn't work.
Date: Thu, 11 Apr 2019 15:00:04 +0000
Message-ID:
Okey, I've found a temporary solution : putting instructions i=
n the second
fragment shader to slow down the shader execution code and it works...
const std::string fragmentShader2 =3D
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 =3D 0, r32ui) coherent uniform uimage2D
headPointers;
layout(binding =3D 0, std430) coherent buffer linkedLists {
NodeType nodes[];
};
void main() {
NodeType frags[MAX_FRAGMENTS];
NodeType frags2[MAX_FRAGMENTS];
int count =3D 0;
uint n =3D imageLoad(headPointers, ivec2(gl_FragCoord.xy)=
).r;
while( n !=3D 0u && count < MAX_FRAGMENTS) {
frags[count] =3D nodes[n];
frags2[count] =3D frags[count];
n =3D 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 =3D 1;
NodeType leftArray[MAX_FRAGMENTS/2]; //for merge sort
while (step <=3D count)
{
i =3D 0;
while (i < count - step)
{
=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20
////////////////////////////////////////////////////////////////////////
//merge(step, i, i + step, min(i + step + step,
count));
a =3D i;
b =3D i + step;
c =3D (i + step + step) >=3D count ? count : (=
i + step +
step);
for (k =3D 0; k < step; k++)
leftArray[k] =3D frags[a + k];
j1 =3D 0;
j2 =3D 0;
for (k =3D a; k < c; k++)
{
if (b + j1 >=3D c || (j2 < step &&a=
mp;
leftArray[j2].depth > frags[b + j1].depth))
frags[k] =3D leftArray[j2++];
else
frags[k] =3D frags[b + j1++];
}
=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20
////////////////////////////////////////////////////////////////////////
i +=3D 2 * step;
}
step *=3D 2;
}
vec4 color =3D vec4(0, 0, 0, 0);
for( int i =3D 0; i < count; i++ )
{
color =3D 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 =3D vec4(1, 1, 1, 1);
}
gl_FragColor =3D 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....