Graphics
Intel® graphics drivers and software, compatibility, troubleshooting, performance, and optimization
20621 Discussions

GLSL driver bug: mat4x3 * vec4 = vec4?!

idata
Employee
3,985 Views

Hello. I'm developing a game using OpenGL, but my GLSL skinning vertex shader isn't compiling. I'm doing a mat4x3 * vec4 multiplication, but the GLSL compiler is insisting that this yields a vec4, while it actually should return a vec3. This was tested on an Intel® HD Graphics 3000 Sandy Bridge CPU-integrated GPU. The following vertex shader does not compile properly:

# version 120

uniform mat4x3 matrix;

void main(){

gl_Position = vec4(matrix * gl_Vertex, 1.0);

}

It generates this error:

ERROR: 0:4: 'constructor' : too many arguments

meaning that the multiplication results is a vec4. Forcing the result to a vec3 by writing

gl_Position = vec4(vec3(matrix * gl_Vertex).xyz, 1.0);

compiles but does not produce the correct results.

Edit: Forcing the result to a vec3 DOES produce the correct result. This proved to be a very non-intrusive workaround.

Note that the exact same shader compiles and works fine on an Intel® HD Graphics 2500 (Ivy Bridge) GPU.

Please fix this ASAP! This bug is keeping my engine from working on Sandy Bridge integrated GPUs! If it's possible to work around the issue, that'd help a lot too!

0 Kudos
6 Replies
Fred_D_Intel
Employee
1,634 Views

Hi Daniel,

Thanks for sharing this information with us. I will forward it to the appropriate support group so they can take it in consideration.

0 Kudos
idata
Employee
1,634 Views
0 Kudos
HVu6
Beginner
1,634 Views

Hi,

I have a similar problem with Intel HD Graphics 3000, driver version: 9.17.10.3347

mat3x4 M;

vec3 x;

then the multiplication : M*x is valid and the result should be of type vec4, however if I write: vec4 y = M*x then I have the message:

" '=' : cannot convert from '3-component vector of float' to '4-component vector of float'".

It means "mat3x4 * vec3" is considered having the vec3 type : mat3x4*vec3 = vec3 ?!

I do not have this error with Nvidia cards.

Thanks to fix this issue.

0 Kudos
Kevin_M_Intel
Employee
1,634 Views
0 Kudos
SThom18
Beginner
1,634 Views

In GLSL, the type mat4x3 represents a matrix that is 4 columns wide (row-lengths of 4) and 3 rows tall (column-lengths of 3) http://www.opengl.org/wiki/Data_Type_(GLSL)# Matrices [source]. The products of a matrix and a vector in GLSL requires the vector's length be the same as the matrix's column-length/row-count https://en.wikibooks.org/wiki/GLSL_Programming/Vector_and_Matrix_Operations# Operators [source].

What you're seeing — that a matrix with column-lengths of 3 requires the vector to be a vec3 — is the correct behavior for GLSL on every platform. It's much more common to use matrices of size mat4x4 (AKA mat4) when transforming the gl_Vertex to a gl_Position. Correct solutions to your problem would be to:

  1. Strip off the .w component off of gl_Vertex as you've done, or
  2. To initialize a 4th row of the matrix (as a mat4) to 0,0,0,1 (from bottom-left to bottom-right).

Much more information about how GL/GLSL perform standard matrix transformation can be found in this useful post: http://www.songho.ca/opengl/gl_transform.html# modelview http://www.songho.ca/opengl/gl_transform.html# modelview

The best part about this is the two official Intel reps didn't bother to point out your mistake, they both blindly handed you apologies and courtesies claiming that they're sending the problem off to be fixed. TL;DR: Intel has some pretty shitty support reps.

0 Kudos
Kevin_M_Intel
Employee
1,634 Views

CapnSlipp,

Thank you for the information. This will be helpful for other users.

Kevin M

0 Kudos
Reply