diff options
author | Ian Romanick <[email protected]> | 2014-11-05 17:48:40 -0800 |
---|---|---|
committer | Ian Romanick <[email protected]> | 2017-01-26 09:46:09 -0800 |
commit | 9f7ac45ce46f18b53777fc5c040e38049c1cbb47 (patch) | |
tree | 3f16ee82678361f710d1fc3355708d28131e5595 /src/mesa/main/uniforms.c | |
parent | 874393186b43f80ebd5921e3eb909aeec415e7c5 (diff) |
mesa: Arrange _mesa_uniform_matrix parameters to match the call sites
By putting the parameters first that match the parameters to the call
site, 4 (of 16) instructions are saved at _mesa_UniformMatrix4fv on
x64. On IA32, the details of the instructions change, but it is the
same count and mix of instructions.
Before:
0000000000001380 <_mesa_UniformMatrix4fv>:
1380: 48 83 ec 10 sub $0x10,%rsp
1384: 48 8b 05 00 00 00 00 mov 0x0(%rip),%rax # 138b <_mesa_UniformMatrix4fv+0xb>
138b: 41 89 f8 mov %edi,%r8d
138e: 41 89 f1 mov %esi,%r9d
1391: 0f b6 d2 movzbl %dl,%edx
1394: 64 48 8b 38 mov %fs:(%rax),%rdi
1398: 48 8b b7 c8 01 02 00 mov 0x201c8(%rdi),%rsi
139f: 48 8b 76 70 mov 0x70(%rsi),%rsi
13a3: 68 06 14 00 00 pushq $0x1406
13a8: 51 push %rcx
13a9: 52 push %rdx
13aa: b9 04 00 00 00 mov $0x4,%ecx
13af: ba 04 00 00 00 mov $0x4,%edx
13b4: e8 00 00 00 00 callq 13b9 <_mesa_UniformMatrix4fv+0x39>
13b9: 48 83 c4 28 add $0x28,%rsp
13bd: c3 retq
After:
0000000000001360 <_mesa_UniformMatrix4fv>:
1360: 48 83 ec 10 sub $0x10,%rsp
1364: 48 8b 05 00 00 00 00 mov 0x0(%rip),%rax # 136b <_mesa_UniformMatrix4fv+0xb>
136b: 0f b6 d2 movzbl %dl,%edx
136e: 64 4c 8b 00 mov %fs:(%rax),%r8
1372: 49 8b 80 c8 01 02 00 mov 0x201c8(%r8),%rax
1379: 68 06 14 00 00 pushq $0x1406
137e: 6a 04 pushq $0x4
1380: 6a 04 pushq $0x4
1382: 4c 8b 48 70 mov 0x70(%rax),%r9
1386: e8 00 00 00 00 callq 138b <_mesa_UniformMatrix4fv+0x2b>
138b: 48 83 c4 28 add $0x28,%rsp
138f: c3 retq
Saves a measly 576 bytes of text on x64.
text data bss dec hex filename
6670131 228340 22552 6921023 699b3f lib/i965_dri.so before
6670131 228340 22552 6921023 699b3f lib/i965_dri.so after
6343924 293872 29880 6667676 65bd9c lib64/i965_dri.so before
6343348 293872 29880 6667100 65bb5c lib64/i965_dri.so after
v2: Rebase on GL_ARB_gpu_shader_fp64.
Signed-off-by: Ian Romanick <[email protected]>
Reviewed-by: Jordan Justen <[email protected]>
Diffstat (limited to 'src/mesa/main/uniforms.c')
-rw-r--r-- | src/mesa/main/uniforms.c | 117 |
1 files changed, 63 insertions, 54 deletions
diff --git a/src/mesa/main/uniforms.c b/src/mesa/main/uniforms.c index 3b645cb5172..c1d951ad605 100644 --- a/src/mesa/main/uniforms.c +++ b/src/mesa/main/uniforms.c @@ -551,8 +551,8 @@ _mesa_UniformMatrix2fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat * value) { GET_CURRENT_CONTEXT(ctx); - _mesa_uniform_matrix(ctx, ctx->_Shader->ActiveProgram, - 2, 2, location, count, transpose, value, GLSL_TYPE_FLOAT); + _mesa_uniform_matrix(location, count, transpose, value, + ctx, ctx->_Shader->ActiveProgram, 2, 2, GLSL_TYPE_FLOAT); } void GLAPIENTRY @@ -560,8 +560,8 @@ _mesa_UniformMatrix3fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat * value) { GET_CURRENT_CONTEXT(ctx); - _mesa_uniform_matrix(ctx, ctx->_Shader->ActiveProgram, - 3, 3, location, count, transpose, value, GLSL_TYPE_FLOAT); + _mesa_uniform_matrix(location, count, transpose, value, + ctx, ctx->_Shader->ActiveProgram, 3, 3, GLSL_TYPE_FLOAT); } void GLAPIENTRY @@ -569,8 +569,8 @@ _mesa_UniformMatrix4fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat * value) { GET_CURRENT_CONTEXT(ctx); - _mesa_uniform_matrix(ctx, ctx->_Shader->ActiveProgram, - 4, 4, location, count, transpose, value, GLSL_TYPE_FLOAT); + _mesa_uniform_matrix(location, count, transpose, value, + ctx, ctx->_Shader->ActiveProgram, 4, 4, GLSL_TYPE_FLOAT); } /** Same as above with direct state access **/ @@ -682,7 +682,7 @@ _mesa_ProgramUniformMatrix2fv(GLuint program, GLint location, GLsizei count, struct gl_shader_program *shProg = _mesa_lookup_shader_program_err(ctx, program, "glProgramUniformMatrix2fv"); - _mesa_uniform_matrix(ctx, shProg, 2, 2, location, count, transpose, value, GLSL_TYPE_FLOAT); + _mesa_uniform_matrix(location, count, transpose, value, ctx, shProg, 2, 2, GLSL_TYPE_FLOAT); } void GLAPIENTRY @@ -693,7 +693,7 @@ _mesa_ProgramUniformMatrix3fv(GLuint program, GLint location, GLsizei count, struct gl_shader_program *shProg = _mesa_lookup_shader_program_err(ctx, program, "glProgramUniformMatrix3fv"); - _mesa_uniform_matrix(ctx, shProg, 3, 3, location, count, transpose, value, GLSL_TYPE_FLOAT); + _mesa_uniform_matrix(location, count, transpose, value, ctx, shProg, 3, 3, GLSL_TYPE_FLOAT); } void GLAPIENTRY @@ -704,7 +704,7 @@ _mesa_ProgramUniformMatrix4fv(GLuint program, GLint location, GLsizei count, struct gl_shader_program *shProg = _mesa_lookup_shader_program_err(ctx, program, "glProgramUniformMatrix4fv"); - _mesa_uniform_matrix(ctx, shProg, 4, 4, location, count, transpose, value, GLSL_TYPE_FLOAT); + _mesa_uniform_matrix(location, count, transpose, value, ctx, shProg, 4, 4, GLSL_TYPE_FLOAT); } @@ -716,8 +716,8 @@ _mesa_UniformMatrix2x3fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat *value) { GET_CURRENT_CONTEXT(ctx); - _mesa_uniform_matrix(ctx, ctx->_Shader->ActiveProgram, - 2, 3, location, count, transpose, value, GLSL_TYPE_FLOAT); + _mesa_uniform_matrix(location, count, transpose, value, + ctx, ctx->_Shader->ActiveProgram, 2, 3, GLSL_TYPE_FLOAT); } void GLAPIENTRY @@ -725,8 +725,8 @@ _mesa_UniformMatrix3x2fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat *value) { GET_CURRENT_CONTEXT(ctx); - _mesa_uniform_matrix(ctx, ctx->_Shader->ActiveProgram, - 3, 2, location, count, transpose, value, GLSL_TYPE_FLOAT); + _mesa_uniform_matrix(location, count, transpose, value, + ctx, ctx->_Shader->ActiveProgram, 3, 2, GLSL_TYPE_FLOAT); } void GLAPIENTRY @@ -734,8 +734,8 @@ _mesa_UniformMatrix2x4fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat *value) { GET_CURRENT_CONTEXT(ctx); - _mesa_uniform_matrix(ctx, ctx->_Shader->ActiveProgram, - 2, 4, location, count, transpose, value, GLSL_TYPE_FLOAT); + _mesa_uniform_matrix(location, count, transpose, value, + ctx, ctx->_Shader->ActiveProgram, 2, 4, GLSL_TYPE_FLOAT); } void GLAPIENTRY @@ -743,8 +743,8 @@ _mesa_UniformMatrix4x2fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat *value) { GET_CURRENT_CONTEXT(ctx); - _mesa_uniform_matrix(ctx, ctx->_Shader->ActiveProgram, - 4, 2, location, count, transpose, value, GLSL_TYPE_FLOAT); + _mesa_uniform_matrix(location, count, transpose, value, + ctx, ctx->_Shader->ActiveProgram, 4, 2, GLSL_TYPE_FLOAT); } void GLAPIENTRY @@ -752,8 +752,8 @@ _mesa_UniformMatrix3x4fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat *value) { GET_CURRENT_CONTEXT(ctx); - _mesa_uniform_matrix(ctx, ctx->_Shader->ActiveProgram, - 3, 4, location, count, transpose, value, GLSL_TYPE_FLOAT); + _mesa_uniform_matrix(location, count, transpose, value, + ctx, ctx->_Shader->ActiveProgram, 3, 4, GLSL_TYPE_FLOAT); } void GLAPIENTRY @@ -761,8 +761,8 @@ _mesa_UniformMatrix4x3fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat *value) { GET_CURRENT_CONTEXT(ctx); - _mesa_uniform_matrix(ctx, ctx->_Shader->ActiveProgram, - 4, 3, location, count, transpose, value, GLSL_TYPE_FLOAT); + _mesa_uniform_matrix(location, count, transpose, value, + ctx, ctx->_Shader->ActiveProgram, 4, 3, GLSL_TYPE_FLOAT); } /** Same as above with direct state access **/ @@ -775,7 +775,7 @@ _mesa_ProgramUniformMatrix2x3fv(GLuint program, GLint location, GLsizei count, struct gl_shader_program *shProg = _mesa_lookup_shader_program_err(ctx, program, "glProgramUniformMatrix2x3fv"); - _mesa_uniform_matrix(ctx, shProg, 2, 3, location, count, transpose, value, GLSL_TYPE_FLOAT); + _mesa_uniform_matrix(location, count, transpose, value, ctx, shProg, 2, 3, GLSL_TYPE_FLOAT); } void GLAPIENTRY @@ -786,7 +786,7 @@ _mesa_ProgramUniformMatrix3x2fv(GLuint program, GLint location, GLsizei count, struct gl_shader_program *shProg = _mesa_lookup_shader_program_err(ctx, program, "glProgramUniformMatrix3x2fv"); - _mesa_uniform_matrix(ctx, shProg, 3, 2, location, count, transpose, value, GLSL_TYPE_FLOAT); + _mesa_uniform_matrix(location, count, transpose, value, ctx, shProg, 3, 2, GLSL_TYPE_FLOAT); } void GLAPIENTRY @@ -797,7 +797,7 @@ _mesa_ProgramUniformMatrix2x4fv(GLuint program, GLint location, GLsizei count, struct gl_shader_program *shProg = _mesa_lookup_shader_program_err(ctx, program, "glProgramUniformMatrix2x4fv"); - _mesa_uniform_matrix(ctx, shProg, 2, 4, location, count, transpose, value, GLSL_TYPE_FLOAT); + _mesa_uniform_matrix(location, count, transpose, value, ctx, shProg, 2, 4, GLSL_TYPE_FLOAT); } void GLAPIENTRY @@ -808,7 +808,7 @@ _mesa_ProgramUniformMatrix4x2fv(GLuint program, GLint location, GLsizei count, struct gl_shader_program *shProg = _mesa_lookup_shader_program_err(ctx, program, "glProgramUniformMatrix4x2fv"); - _mesa_uniform_matrix(ctx, shProg, 4, 2, location, count, transpose, value, GLSL_TYPE_FLOAT); + _mesa_uniform_matrix(location, count, transpose, value, ctx, shProg, 4, 2, GLSL_TYPE_FLOAT); } void GLAPIENTRY @@ -819,7 +819,7 @@ _mesa_ProgramUniformMatrix3x4fv(GLuint program, GLint location, GLsizei count, struct gl_shader_program *shProg = _mesa_lookup_shader_program_err(ctx, program, "glProgramUniformMatrix3x4fv"); - _mesa_uniform_matrix(ctx, shProg, 3, 4, location, count, transpose, value, GLSL_TYPE_FLOAT); + _mesa_uniform_matrix(location, count, transpose, value, ctx, shProg, 3, 4, GLSL_TYPE_FLOAT); } void GLAPIENTRY @@ -830,7 +830,7 @@ _mesa_ProgramUniformMatrix4x3fv(GLuint program, GLint location, GLsizei count, struct gl_shader_program *shProg = _mesa_lookup_shader_program_err(ctx, program, "glProgramUniformMatrix4x3fv"); - _mesa_uniform_matrix(ctx, shProg, 4, 3, location, count, transpose, value, GLSL_TYPE_FLOAT); + _mesa_uniform_matrix(location, count, transpose, value, ctx, shProg, 4, 3, GLSL_TYPE_FLOAT); } @@ -1369,8 +1369,8 @@ _mesa_UniformMatrix2dv(GLint location, GLsizei count, GLboolean transpose, const GLdouble * value) { GET_CURRENT_CONTEXT(ctx); - _mesa_uniform_matrix(ctx, ctx->_Shader->ActiveProgram, - 2, 2, location, count, transpose, value, GLSL_TYPE_DOUBLE); + _mesa_uniform_matrix(location, count, transpose, value, + ctx, ctx->_Shader->ActiveProgram, 2, 2, GLSL_TYPE_DOUBLE); } void GLAPIENTRY @@ -1378,8 +1378,8 @@ _mesa_UniformMatrix3dv(GLint location, GLsizei count, GLboolean transpose, const GLdouble * value) { GET_CURRENT_CONTEXT(ctx); - _mesa_uniform_matrix(ctx, ctx->_Shader->ActiveProgram, - 3, 3, location, count, transpose, value, GLSL_TYPE_DOUBLE); + _mesa_uniform_matrix(location, count, transpose, value, + ctx, ctx->_Shader->ActiveProgram, 3, 3, GLSL_TYPE_DOUBLE); } void GLAPIENTRY @@ -1387,8 +1387,8 @@ _mesa_UniformMatrix4dv(GLint location, GLsizei count, GLboolean transpose, const GLdouble * value) { GET_CURRENT_CONTEXT(ctx); - _mesa_uniform_matrix(ctx, ctx->_Shader->ActiveProgram, - 4, 4, location, count, transpose, value, GLSL_TYPE_DOUBLE); + _mesa_uniform_matrix(location, count, transpose, value, + ctx, ctx->_Shader->ActiveProgram, 4, 4, GLSL_TYPE_DOUBLE); } void GLAPIENTRY @@ -1396,8 +1396,8 @@ _mesa_UniformMatrix2x3dv(GLint location, GLsizei count, GLboolean transpose, const GLdouble *value) { GET_CURRENT_CONTEXT(ctx); - _mesa_uniform_matrix(ctx, ctx->_Shader->ActiveProgram, - 2, 3, location, count, transpose, value, GLSL_TYPE_DOUBLE); + _mesa_uniform_matrix(location, count, transpose, value, + ctx, ctx->_Shader->ActiveProgram, 2, 3, GLSL_TYPE_DOUBLE); } void GLAPIENTRY @@ -1405,8 +1405,8 @@ _mesa_UniformMatrix3x2dv(GLint location, GLsizei count, GLboolean transpose, const GLdouble *value) { GET_CURRENT_CONTEXT(ctx); - _mesa_uniform_matrix(ctx, ctx->_Shader->ActiveProgram, - 3, 2, location, count, transpose, value, GLSL_TYPE_DOUBLE); + _mesa_uniform_matrix(location, count, transpose, value, + ctx, ctx->_Shader->ActiveProgram, 3, 2, GLSL_TYPE_DOUBLE); } void GLAPIENTRY @@ -1414,8 +1414,8 @@ _mesa_UniformMatrix2x4dv(GLint location, GLsizei count, GLboolean transpose, const GLdouble *value) { GET_CURRENT_CONTEXT(ctx); - _mesa_uniform_matrix(ctx, ctx->_Shader->ActiveProgram, - 2, 4, location, count, transpose, value, GLSL_TYPE_DOUBLE); + _mesa_uniform_matrix(location, count, transpose, value, + ctx, ctx->_Shader->ActiveProgram, 2, 4, GLSL_TYPE_DOUBLE); } void GLAPIENTRY @@ -1423,8 +1423,8 @@ _mesa_UniformMatrix4x2dv(GLint location, GLsizei count, GLboolean transpose, const GLdouble *value) { GET_CURRENT_CONTEXT(ctx); - _mesa_uniform_matrix(ctx, ctx->_Shader->ActiveProgram, - 4, 2, location, count, transpose, value, GLSL_TYPE_DOUBLE); + _mesa_uniform_matrix(location, count, transpose, value, + ctx, ctx->_Shader->ActiveProgram, 4, 2, GLSL_TYPE_DOUBLE); } void GLAPIENTRY @@ -1432,8 +1432,8 @@ _mesa_UniformMatrix3x4dv(GLint location, GLsizei count, GLboolean transpose, const GLdouble *value) { GET_CURRENT_CONTEXT(ctx); - _mesa_uniform_matrix(ctx, ctx->_Shader->ActiveProgram, - 3, 4, location, count, transpose, value, GLSL_TYPE_DOUBLE); + _mesa_uniform_matrix(location, count, transpose, value, + ctx, ctx->_Shader->ActiveProgram, 3, 4, GLSL_TYPE_DOUBLE); } void GLAPIENTRY @@ -1441,8 +1441,8 @@ _mesa_UniformMatrix4x3dv(GLint location, GLsizei count, GLboolean transpose, const GLdouble *value) { GET_CURRENT_CONTEXT(ctx); - _mesa_uniform_matrix(ctx, ctx->_Shader->ActiveProgram, - 4, 3, location, count, transpose, value, GLSL_TYPE_DOUBLE); + _mesa_uniform_matrix(location, count, transpose, value, + ctx, ctx->_Shader->ActiveProgram, 4, 3, GLSL_TYPE_DOUBLE); } void GLAPIENTRY @@ -1548,7 +1548,8 @@ _mesa_ProgramUniformMatrix2dv(GLuint program, GLint location, GLsizei count, struct gl_shader_program *shProg = _mesa_lookup_shader_program_err(ctx, program, "glProgramUniformMatrix2dv"); - _mesa_uniform_matrix(ctx, shProg, 2, 2, location, count, transpose, value, GLSL_TYPE_DOUBLE); + _mesa_uniform_matrix(location, count, transpose, value, + ctx, shProg, 2, 2, GLSL_TYPE_DOUBLE); } void GLAPIENTRY @@ -1559,7 +1560,8 @@ _mesa_ProgramUniformMatrix3dv(GLuint program, GLint location, GLsizei count, struct gl_shader_program *shProg = _mesa_lookup_shader_program_err(ctx, program, "glProgramUniformMatrix3dv"); - _mesa_uniform_matrix(ctx, shProg, 3, 3, location, count, transpose, value, GLSL_TYPE_DOUBLE); + _mesa_uniform_matrix(location, count, transpose, value, + ctx, shProg, 3, 3, GLSL_TYPE_DOUBLE); } void GLAPIENTRY @@ -1570,7 +1572,8 @@ _mesa_ProgramUniformMatrix4dv(GLuint program, GLint location, GLsizei count, struct gl_shader_program *shProg = _mesa_lookup_shader_program_err(ctx, program, "glProgramUniformMatrix4dv"); - _mesa_uniform_matrix(ctx, shProg, 4, 4, location, count, transpose, value, GLSL_TYPE_DOUBLE); + _mesa_uniform_matrix(location, count, transpose, value, + ctx, shProg, 4, 4, GLSL_TYPE_DOUBLE); } void GLAPIENTRY @@ -1581,7 +1584,8 @@ _mesa_ProgramUniformMatrix2x3dv(GLuint program, GLint location, GLsizei count, struct gl_shader_program *shProg = _mesa_lookup_shader_program_err(ctx, program, "glProgramUniformMatrix2x3dv"); - _mesa_uniform_matrix(ctx, shProg, 2, 3, location, count, transpose, value, GLSL_TYPE_DOUBLE); + _mesa_uniform_matrix(location, count, transpose, value, + ctx, shProg, 2, 3, GLSL_TYPE_DOUBLE); } void GLAPIENTRY @@ -1592,7 +1596,8 @@ _mesa_ProgramUniformMatrix3x2dv(GLuint program, GLint location, GLsizei count, struct gl_shader_program *shProg = _mesa_lookup_shader_program_err(ctx, program, "glProgramUniformMatrix3x2dv"); - _mesa_uniform_matrix(ctx, shProg, 3, 2, location, count, transpose, value, GLSL_TYPE_DOUBLE); + _mesa_uniform_matrix(location, count, transpose, value, + ctx, shProg, 3, 2, GLSL_TYPE_DOUBLE); } void GLAPIENTRY @@ -1603,7 +1608,8 @@ _mesa_ProgramUniformMatrix2x4dv(GLuint program, GLint location, GLsizei count, struct gl_shader_program *shProg = _mesa_lookup_shader_program_err(ctx, program, "glProgramUniformMatrix2x4dv"); - _mesa_uniform_matrix(ctx, shProg, 2, 4, location, count, transpose, value, GLSL_TYPE_DOUBLE); + _mesa_uniform_matrix(location, count, transpose, value, + ctx, shProg, 2, 4, GLSL_TYPE_DOUBLE); } void GLAPIENTRY @@ -1614,7 +1620,8 @@ _mesa_ProgramUniformMatrix4x2dv(GLuint program, GLint location, GLsizei count, struct gl_shader_program *shProg = _mesa_lookup_shader_program_err(ctx, program, "glProgramUniformMatrix4x2dv"); - _mesa_uniform_matrix(ctx, shProg, 4, 2, location, count, transpose, value, GLSL_TYPE_DOUBLE); + _mesa_uniform_matrix(location, count, transpose, value, + ctx, shProg, 4, 2, GLSL_TYPE_DOUBLE); } void GLAPIENTRY @@ -1625,7 +1632,8 @@ _mesa_ProgramUniformMatrix3x4dv(GLuint program, GLint location, GLsizei count, struct gl_shader_program *shProg = _mesa_lookup_shader_program_err(ctx, program, "glProgramUniformMatrix3x4dv"); - _mesa_uniform_matrix(ctx, shProg, 3, 4, location, count, transpose, value, GLSL_TYPE_DOUBLE); + _mesa_uniform_matrix(location, count, transpose, value, + ctx, shProg, 3, 4, GLSL_TYPE_DOUBLE); } void GLAPIENTRY @@ -1636,7 +1644,8 @@ _mesa_ProgramUniformMatrix4x3dv(GLuint program, GLint location, GLsizei count, struct gl_shader_program *shProg = _mesa_lookup_shader_program_err(ctx, program, "glProgramUniformMatrix4x3dv"); - _mesa_uniform_matrix(ctx, shProg, 4, 3, location, count, transpose, value, GLSL_TYPE_DOUBLE); + _mesa_uniform_matrix(location, count, transpose, value, + ctx, shProg, 4, 3, GLSL_TYPE_DOUBLE); } void GLAPIENTRY |