glsl: textureGatherOffset param broken
The following compute shader from KHR-GL46.sparse_texture2_tests.SparseTexture2Lookup
is broken in Mesa:
#version 450 core
#extension GL_ARB_sparse_texture2 : enable
#extension GL_ARB_sparse_texture_clamp : enable
layout (local_size_x = 1, local_size_y = 1, local_size_z = 1) in;
layout (location = 1, r8ui) writeonly uniform uimage2D uni_out;
layout (location = 2) uniform sampler2D uni_in;
layout (location = 3) uniform int widthCommitted;
void main()
{
ivec2 point = ivec2(gl_WorkGroupID.x, gl_WorkGroupID.y);
ivec2 texSize = ivec2(512, 512);
ivec2 icoord = ivec2(gl_WorkGroupID.x, gl_WorkGroupID.y);
vec2 coord = vec2(gl_WorkGroupID.x, gl_WorkGroupID.y) / vec2(texSize);
vec4 retValue,
expValue,
epsilon;
retValue = vec4(0);
expValue = vec4(1, 1, 1, 1);
epsilon = vec4(0.008);
ivec2 offsetsArray[4];
offsetsArray[0] = ivec2(0);
offsetsArray[1] = ivec2(0);
offsetsArray[2] = ivec2(0);
offsetsArray[3] = ivec2(0);
ivec2 corner1 = ivec2(1, 1);
ivec2 corner2 = ivec2(texSize.x - 1, texSize.y - 1);
int code = sparseTextureGatherOffsetsARB(uni_in,
coord, offsetsArray,
retValue, 0);
memoryBarrier();
imageStore(uni_out, point, uvec4(255));
if (point.x > corner1.x && point.y > corner1.y &&
point.x < corner2.x && point.y < corner2.y &&
point.x < widthCommitted - 1)
{
if (!sparseTexelsResidentARB(code) ||
any(greaterThan(retValue, expValue + epsilon)) ||
any(lessThan(retValue, expValue - epsilon)))
{
imageStore(uni_out, point, uvec4(0));
}
}
if (point.x > corner1.x && point.y > corner1.y &&
point.x < corner2.x && point.y < corner2.y &&
point.x >= widthCommitted + 1)
{
if (sparseTexelsResidentARB(code))
{
imageStore(uni_out, point, uvec4(0));
}
}
}
Log:
0:37(9): error: parameter `in offsets' must be a constant expression
0:47(31): warning: `code' used uninitialized
0:59(30): warning: `code' used uninitialized
-
code
is not uninitialized -
in offsets
is the offsets param (offsetsArray
) forsparseTextureGatherOffsetsARB
, and the GLSL compiler is failing to detect that it's constant because it is an array variable with constant values assigned to it rather than a constant value. According to GLSL 4.6 (page 300):The specified values in offsets must be constant.