From: bugzilla-daemon@freedesktop.org Subject: [Bug 110229] glMemoryBarrier doesn't work. Date: Thu, 11 Apr 2019 15:00:04 +0000 Message-ID: References: Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="===============1384601868==" Return-path: Received: from culpepper.freedesktop.org (culpepper.freedesktop.org [IPv6:2610:10:20:722:a800:ff:fe98:4b55]) by gabe.freedesktop.org (Postfix) with ESMTP id 2681C893BC for ; Thu, 11 Apr 2019 15:00:04 +0000 (UTC) In-Reply-To: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" To: dri-devel@lists.freedesktop.org List-Id: dri-devel@lists.freedesktop.org --===============1384601868== Content-Type: multipart/alternative; boundary="15549948040.fF15c148.25409" Content-Transfer-Encoding: 7bit --15549948040.fF15c148.25409 Date: Thu, 11 Apr 2019 15:00:04 +0000 MIME-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: http://bugs.freedesktop.org/ Auto-Submitted: auto-generated https://bugs.freedesktop.org/show_bug.cgi?id=3D110229 --- Comment #31 from Laurent --- 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 =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 && 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.... --=20 You are receiving this mail because: You are the assignee for the bug.= --15549948040.fF15c148.25409 Date: Thu, 11 Apr 2019 15:00:04 +0000 MIME-Version: 1.0 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: http://bugs.freedesktop.org/ Auto-Submitted: auto-generated

Comme= nt # 31 on bug 11022= 9 from Laurent
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....


You are receiving this mail because:
  • You are the assignee for the bug.
= --15549948040.fF15c148.25409-- --===============1384601868== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: base64 Content-Disposition: inline X19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX18KZHJpLWRldmVs IG1haWxpbmcgbGlzdApkcmktZGV2ZWxAbGlzdHMuZnJlZWRlc2t0b3Aub3JnCmh0dHBzOi8vbGlz dHMuZnJlZWRlc2t0b3Aub3JnL21haWxtYW4vbGlzdGluZm8vZHJpLWRldmVs --===============1384601868==--