Restrict keyword crashes GLSL compiler

Since driver version 310, the GLSL driver crashes when using the “restrict” keyword. I can reproduce this on different machines running windows or linux. Latest driver version I have tried is 320.18.

The following code for a fragment shader crashes the compiler. Remove the “restrict” keyword and it works.

#version 420

layout(rgba32f) uniform image2D restrict x;

void main(){}


  • Windows: shader compiler outputs "fatal error C9999: *** exception during compilation ***"
  • Linux: application crashes with a segfault

In addition to “restrict”, the keywords “coherent” and “volatile” also crash the driver.
Keywords “readonly” and “writeonly” work on the other hand.

Anyone experiencing the same issue? I have posted this 4 months ago to the nvidia bug submission system, without a single response.

Quote from the ARB_shader_image_load_store specification:

The position of the qualifier is meaningful.  Qualifiers
before the type name apply to the data referenced by the variable.
Qualifiers after the type name apply to the variable itself.
For "coherent", "volatile", and "const", the qualifier should typically
go before the image type.  For "restrict", the qualifier must go after
the image type, since "restrict" applies to the pointer, not the data
being pointed to.

And here’s how the nvidia driver behaves.

layout(rgba32f) uniform image2D const x; // Crash
layout(rgba32f) const uniform image2D x; // Crash
layout(rgba32f) restrict uniform image2D x; // Compiles, but not legal
layout(rgba32f) uniform image2D restrict x; // Crash
layout(rgba32f) uniform image2D volatile x; // Crash
layout(rgba32f) volatile uniform image2D x; // Compiles
layout(rgba32f) uniform image2D coherent x; // Crash
layout(rgba32f) coherent uniform image2D x; // Compiles

Yep. It’s been around for a while:*-crashes-when-compiling-GLSL-using-restrict-keyword-on-image-unit

It’d be nice if the compiler could automatically optimize the memory layout, especially for use in the fragment shader. Seems like a pretty daunting task to implement though.