RobertC
06-29-2011, 09:34 AM
Hi,
I have difficulty declaring a read-only image variable for the use with the EXT_shader_image_load_store extension.
My data is not aliased and read-only, so I am trying to tell this to the compiler in order to help him optimize my code (uncoherently reorder, cache, and coalesce all read operations).
According to the spec, the following should be legal and specify an image whose content is constant and read-only.
layout(size4x32) const uniform image2D imageVariable;
I use the (almost) same definition in my shader:
#version 410
#extension GL_EXT_shader_image_load_store : require
#extension GL_ARB_gpu_shader5 : enable
layout(size4x32) const uniform image1D imageVariable;
However, I get the following compiler error (GeForce 460, driver version 275.33):
error C7522: OpenGL requires constants to be initialized
Is this a bug in the nVidia compiler or did I miss something? Does anyone have experience with such an declaration with the AMD compiler?
The compiler seems to understand the restrict keyword which was introduced with the extension, so it is strange it does not understand the extended meaning of the const keyword.
layout(size4x32) const uniform image1D restrict imageVar1; // error C7522
layout(size4x32) uniform image1D restrict imageVar2; // OK
As a workaround, I have just removed the const keyword and hope the compiler notices that I never use imageWrite() with the variable.
I have difficulty declaring a read-only image variable for the use with the EXT_shader_image_load_store extension.
My data is not aliased and read-only, so I am trying to tell this to the compiler in order to help him optimize my code (uncoherently reorder, cache, and coalesce all read operations).
According to the spec, the following should be legal and specify an image whose content is constant and read-only.
layout(size4x32) const uniform image2D imageVariable;
I use the (almost) same definition in my shader:
#version 410
#extension GL_EXT_shader_image_load_store : require
#extension GL_ARB_gpu_shader5 : enable
layout(size4x32) const uniform image1D imageVariable;
However, I get the following compiler error (GeForce 460, driver version 275.33):
error C7522: OpenGL requires constants to be initialized
Is this a bug in the nVidia compiler or did I miss something? Does anyone have experience with such an declaration with the AMD compiler?
The compiler seems to understand the restrict keyword which was introduced with the extension, so it is strange it does not understand the extended meaning of the const keyword.
layout(size4x32) const uniform image1D restrict imageVar1; // error C7522
layout(size4x32) uniform image1D restrict imageVar2; // OK
As a workaround, I have just removed the const keyword and hope the compiler notices that I never use imageWrite() with the variable.