Reputation: 314
This shader seems to compile fine on my Vega 8 iGPU on my ryzen 3 2200g but the same fragment shader does not compile on intel hd 4000 graphics. Is there really a shader error or something I am doing wrong? I also took steps to not refer to a uniform using an int
. Please help.
#version 330 core
in vec2 TexCoord;
// I am using a batch rendering method. The "TexElement" is the slot to which the texture is bound to
in flat int TexElement;
// Color to multiply with the texture color also called tint
in flat vec4 MultiplyColor;
// Outputted color
out vec4 color;
uniform sampler2D u_Textures[32];
void main()
{
switch (TexElement)
{
case 0 : color = texture(u_Textures[0], TexCoord) * MultiplyColor; break;
case 1 : color = texture(u_Textures[1], TexCoord) * MultiplyColor; break;
case 2 : color = texture(u_Textures[2], TexCoord) * MultiplyColor; break;
case 3 : color = texture(u_Textures[3], TexCoord) * MultiplyColor; break;
case 4 : color = texture(u_Textures[4], TexCoord) * MultiplyColor; break;
case 5 : color = texture(u_Textures[5], TexCoord) * MultiplyColor; break;
case 6 : color = texture(u_Textures[6], TexCoord) * MultiplyColor; break;
case 7 : color = texture(u_Textures[7], TexCoord) * MultiplyColor; break;
case 8 : color = texture(u_Textures[8], TexCoord) * MultiplyColor; break;
case 9 : color = texture(u_Textures[9], TexCoord) * MultiplyColor; break;
case 10 : color = texture(u_Textures[10], TexCoord) * MultiplyColor; break;
case 11 : color = texture(u_Textures[11], TexCoord) * MultiplyColor; break;
case 12 : color = texture(u_Textures[12], TexCoord) * MultiplyColor; break;
case 13 : color = texture(u_Textures[13], TexCoord) * MultiplyColor; break;
case 14 : color = texture(u_Textures[14], TexCoord) * MultiplyColor; break;
case 15 : color = texture(u_Textures[15], TexCoord) * MultiplyColor; break;
case 16 : color = texture(u_Textures[16], TexCoord) * MultiplyColor; break;
case 17 : color = texture(u_Textures[17], TexCoord) * MultiplyColor; break;
case 18 : color = texture(u_Textures[18], TexCoord) * MultiplyColor; break;
case 19 : color = texture(u_Textures[19], TexCoord) * MultiplyColor; break;
case 20 : color = texture(u_Textures[20], TexCoord) * MultiplyColor; break;
case 21 : color = texture(u_Textures[21], TexCoord) * MultiplyColor; break;
case 22 : color = texture(u_Textures[22], TexCoord) * MultiplyColor; break;
case 23 : color = texture(u_Textures[23], TexCoord) * MultiplyColor; break;
case 24 : color = texture(u_Textures[24], TexCoord) * MultiplyColor; break;
case 25 : color = texture(u_Textures[25], TexCoord) * MultiplyColor; break;
case 26 : color = texture(u_Textures[26], TexCoord) * MultiplyColor; break;
case 27 : color = texture(u_Textures[27], TexCoord) * MultiplyColor; break;
case 28 : color = texture(u_Textures[28], TexCoord) * MultiplyColor; break;
case 29 : color = texture(u_Textures[29], TexCoord) * MultiplyColor; break;
case 30 : color = texture(u_Textures[30], TexCoord) * MultiplyColor; break;
case 31 : color = texture(u_Textures[31], TexCoord) * MultiplyColor; break;
default : color = MultiplyColor; break;
}
}
Here is the glInfoLog :
ERROR: 0:19: 'u_Textures' : undeclared identifier
ERROR: 0:19: 'u_Textures' : left of '[' is not of type array, matrix, or vector
ERROR: 0:19: 'texture' : no matching overloaded function found (using implicit conversion)
ERROR: 0:20: 'u_Textures' : left of '[' is not of type array, matrix, or vector
ERROR: 0:20: 'texture' : no matching overloaded function found (using implicit conversion)
ERROR: 0:21: 'u_Textures' : left of '[' is not of type array, matrix, o
I also verified the actual string that is passed to the GLSL compiler but there is no difference.
I am really not sure what the issue is.
Upvotes: 1
Views: 508
Reputation: 314
Intel HD 4000 graphics only supports upto 16 texture slots or units. You are taking in a sampler2D array of size 32. Which is more than 16. It will work if you change the array size to 16 and comment out the extra cases. Here is the updated shader code :
#version 330 core
in vec2 TexCoord;
// I am using a batch rendering method. The "TexElement" is the slot to which the texture is bound to
in flat int TexElement;
// Color to multiply with the texture color also called tint
in flat vec4 MultiplyColor;
// Outputted color
out vec4 color;
uniform sampler2D u_Textures[16];
void main()
{
switch (TexElement)
{
case 0 : color = texture(u_Textures[0], TexCoord) * MultiplyColor; break;
case 1 : color = texture(u_Textures[1], TexCoord) * MultiplyColor; break;
case 2 : color = texture(u_Textures[2], TexCoord) * MultiplyColor; break;
case 3 : color = texture(u_Textures[3], TexCoord) * MultiplyColor; break;
case 4 : color = texture(u_Textures[4], TexCoord) * MultiplyColor; break;
case 5 : color = texture(u_Textures[5], TexCoord) * MultiplyColor; break;
case 6 : color = texture(u_Textures[6], TexCoord) * MultiplyColor; break;
case 7 : color = texture(u_Textures[7], TexCoord) * MultiplyColor; break;
case 8 : color = texture(u_Textures[8], TexCoord) * MultiplyColor; break;
case 9 : color = texture(u_Textures[9], TexCoord) * MultiplyColor; break;
case 10 : color = texture(u_Textures[10], TexCoord) * MultiplyColor; break;
case 11 : color = texture(u_Textures[11], TexCoord) * MultiplyColor; break;
case 12 : color = texture(u_Textures[12], TexCoord) * MultiplyColor; break;
case 13 : color = texture(u_Textures[13], TexCoord) * MultiplyColor; break;
case 14 : color = texture(u_Textures[14], TexCoord) * MultiplyColor; break;
case 15 : color = texture(u_Textures[15], TexCoord) * MultiplyColor; break;
default : color = MultiplyColor; break;
}
}
Thanks!
Upvotes: 1