lion0406 / angleproject

Automatically exported from code.google.com/p/angleproject
Other
0 stars 0 forks source link

Seemingly senseless double transpose #431

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Try a GLSL vertex shader with the following code
   uniform mat4 erp_matrix[5];
   attribute vec4 erp_position;
   main() {
   gl_position = erp_matrix_[0] * erp_position;
   }

   and a GL program which loads the matrix via glUniformMatrix4fv.

2. Observe that:
     The corresponding line in the translated HLSL code is
        gl_Position = mul(transpose(_erp_matrix[0]), _erp_position);

3. Observe that:
     ProgramBinary::setUniformMatrix4fv (and all other
     setUniformMatrix variants) calls transposeMatrix on the matrix
     array passed from the application.

What is the expected output? What do you see instead?

It would seem that the transposes could be eliminated completely in this simple 
example. It may be that the matrix is being transposed on loading to facilitate 
the GLSL shader indexing the matrix, e.g vec4 foo = vec4(erp_matrix[0][0]). In 
that case the transpose in the shader could still be eliminated by using 
another variant of mul: mul(_erp_position, _erp_matrix[0]); It would certainly 
be nice to avoid a matrix transpose on every vertex.

What version of the product are you using? On what operating system?
dx11 branch; Windows 7.

Original issue reported on code.google.com by callow.m...@artspark.co.jp on 5 Jun 2013 at 8:01