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.
2
  • Could you post your entire vertex and fragment shader code? Commented Sep 29, 2013 at 17:08
  • @bwroga The original code can be found here. I slightly modified the style though (It shouldn't affect anything) Commented Sep 29, 2013 at 17:19

1 Answer 1

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.

Sign up to request clarification or add additional context in comments.

4 Comments

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?
Does it generate the error at the line where the function is called? Or at the image declaration? Or somewhere else?
@structinf: Also, is the GitHub version your current version?
With the exception of some style modifications, yes.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.