Hello there!
I have a shader that compiles and runs ok on Adreno 418 and Mali T880. When I try to compile it on PowerVR GE 8100 however, glGetShaderInfoLog() returns a cryptic ‘Compile failed’ . That’s it!
Vertex Shader:
#version 310 es
precision highp float;
precision highp int;
in vec2 a_Position; // quad [ (-0.5,-0.5), (-0.5,0.5) , (0.5,-0.5), (0.5,0.5) ]
out vec2 v_TexCoordinate;
out vec2 v_Pixel;
uniform uvec2 u_Size; // size of the screen, in pixels.
void main()
{
v_TexCoordinate = (a_Position + 0.5);
v_Pixel = (a_Position + 0.5) * vec2(u_Size);
gl_Position = vec4(2.0*a_Position,1.0,1.0);
}
Fragment shader:
#version 310 es
precision highp float;
precision highp int;
out vec4 fragColor;
in vec2 v_TexCoordinate;
in vec2 v_Pixel;
uniform sampler2D u_Texture;
uniform sampler2D u_DepthTexture;
//////////////////////////////////////////////////////////////////////////////////////////////
// per-pixel linked list. Order Independent Transparency.
uniform uvec2 u_Size;
uniform uint u_numRecords;
layout (binding=0, offset=0) uniform atomic_uint u_Counter;
layout (std430,binding=1) buffer linkedlist
{
uint u_Records[];
};
//////////////////////////////////////////////////////////////////////////////////////////////
// Concurrent insert to a linked list. Tim Harris, 'pragmatic implementation of non-blocking
// linked-lists', 2001.
// This arranges fragments by decreasing 'depth', so one would think - from back to front, but
// in main() below the depth is mapped with S*(1-depth)/2, so it is really front to back.
void insert( vec2 ij, uint depth, uint rgba )
{
uint ptr = atomicCounterIncrement(u_Counter);
if( ptr<u_numRecords )
{
ptr = 3u*ptr + u_Size.x*u_Size.y;
u_Records[ptr+1u] = depth;
u_Records[ptr+2u] = rgba;
memoryBarrier();
uint prev = uint(ij.x) + uint(ij.y) * u_Size.x;
uint curr = u_Records[prev];
while (true)
{
if ( curr==0u || depth > u_Records[curr+1u] ) // need to insert here
{
u_Records[ptr] = curr; // next of new record is curr
memoryBarrier();
uint res = atomicCompSwap( u_Records[prev], curr, ptr );
if (res==curr) break; // done!
else curr = res; // could not insert! retry from same place in list
}
else // advance in list
{
prev = curr;
curr = u_Records[prev];
}
}
}
}
//////////////////////////////////////////////////////////////////////////////////////////////
uint convert(vec4 c)
{
return ((uint(255.0*c.r))<<24u) + ((uint(255.0*c.g))<<16u) + ((uint(255.0*c.b))<<8u) + uint(255.0*c.a);
}
//////////////////////////////////////////////////////////////////////////////////////////////
// Pass2 of the OIT algorithm - build the LinkedList phase.
void main()
{
vec4 frag = texture(u_Texture , v_TexCoordinate);
float depth= texture(u_DepthTexture, v_TexCoordinate).r;
if( frag.a > 0.95 )
{
gl_FragDepth = depth;
fragColor = frag;
}
else
{
if( frag.a > 0.0 )
{
const float S= 2147483647.0; // max signed int. Could probably be max unsigned int but this is enough.
insert(v_Pixel, uint(S*(1.0-depth)/2.0), convert(frag) );
}
discard;
}
}
Could anyone offer some advice? If I comment out the ‘atomicCompSwap( u_Records[prev], curr, ptr );’ from the ‘insert()’ function, everything compiles.