0

So, I recently found an interesting shader and tried to compile it.

But, the GLSL compiler threw the following error:

ERROR: 0:50: error(#132) Syntax error: "layout" parse error

@ (Fragment shader)

#version 420

...

uint ImageAtomic_Average_RGBA8(layout (r32ui) volatile uimage3D Img, ivec3 Coords, vec4 NewVal)
{ ... }

Details:

  • Card: AMD Radeon HD 7870 (It supports OpenGL 4.20)
  • I tried both the 4.2 driver and the 4.3 beta driver.
Andreas Goulas
  • 163
  • 1
  • 1
  • 11
  • Could you post your entire vertex and fragment shader code? – bwroga Sep 29 '13 at 17:08
  • @bwroga The original code can be found [here](https://github.com/domme/VoxelConeTracing/blob/master/bin/assets/shader/VoxelConeTracing/voxelizeFrag.shader). I slightly modified the style though (It shouldn't affect anything) – Andreas Goulas Sep 29 '13 at 17:19

1 Answers1

1

A layout qualifier cannot be part of the function's signature. Section 6.1.1 of the GLSL 4.40 Specification defines the following grammar for a function prototype:

function-prototype :
precision-qualifier type function-name(*parameter-qualifiers* precision-qualifier type name array-specifier, ... )

Now, a parameter-qualifier can be one of

const
in
out
inout
precise
memory qualifier (volatile, ...)
precision qualifier(lowp, ...)


Consistently, section 4.10 explicitly states:

Layout qualifiers cannot be used on formal function parameters [..]

If you drop the layout qualifier, you should be fine. If not, it's a driver bug.

thokra
  • 2,874
  • 18
  • 25
  • Oh wow, that fixed the error. However, when I try to pass an image variable to that function (e.g. `ImageAtomic_Average_RGBA8(VoxelFragTex_Normal, ivec3(BaseVoxel), Normal);` - Declaration: `layout (r32ui) uniform volatile uimage3D VoxelFragTex_Normal;`) the compiler throws this error: `error(#373) Invalid usage of image qualifier`. Is that related? – Andreas Goulas Sep 30 '13 at 12:49
  • Does it generate the error at the line where the function is called? Or at the image declaration? Or somewhere else? – thokra Sep 30 '13 at 12:56
  • @structinf: Also, is the GitHub version your current version? – thokra Sep 30 '13 at 13:08
  • With the exception of some style modifications, yes. – Andreas Goulas Sep 30 '13 at 13:13