wined3d: Avoid a couple of useless glGetUniformLocationARB() calls.

This commit is contained in:
Henri Verbeet 2013-09-04 08:56:44 +02:00 committed by Alexandre Julliard
parent ff6ce4c669
commit 99092c2700
1 changed files with 12 additions and 6 deletions

View File

@ -5754,18 +5754,20 @@ static struct glsl_ffp_fragment_shader *shader_glsl_find_ffp_fragment_shader(str
static void shader_glsl_init_vs_uniform_locations(const struct wined3d_gl_info *gl_info,
GLhandleARB program_id, struct glsl_vs_program *vs)
GLhandleARB program_id, struct glsl_vs_program *vs, unsigned int vs_c_count)
{
unsigned int i;
char name[32];
vs->uniform_f_locations = HeapAlloc(GetProcessHeap(), 0,
sizeof(GLhandleARB) * gl_info->limits.glsl_vs_float_constants);
for (i = 0; i < gl_info->limits.glsl_vs_float_constants; ++i)
for (i = 0; i < vs_c_count; ++i)
{
snprintf(name, sizeof(name), "vs_c[%u]", i);
vs->uniform_f_locations[i] = GL_EXTCALL(glGetUniformLocationARB(program_id, name));
}
memset(&vs->uniform_f_locations[vs_c_count], 0xff,
(gl_info->limits.glsl_vs_float_constants - vs_c_count) * sizeof(GLhandleARB));
for (i = 0; i < MAX_CONST_I; ++i)
{
@ -5777,18 +5779,20 @@ static void shader_glsl_init_vs_uniform_locations(const struct wined3d_gl_info *
}
static void shader_glsl_init_ps_uniform_locations(const struct wined3d_gl_info *gl_info,
GLhandleARB program_id, struct glsl_ps_program *ps)
GLhandleARB program_id, struct glsl_ps_program *ps, unsigned int ps_c_count)
{
unsigned int i;
char name[32];
ps->uniform_f_locations = HeapAlloc(GetProcessHeap(), 0,
sizeof(GLhandleARB) * gl_info->limits.glsl_ps_float_constants);
for (i = 0; i < gl_info->limits.glsl_ps_float_constants; ++i)
for (i = 0; i < ps_c_count; ++i)
{
snprintf(name, sizeof(name), "ps_c[%u]", i);
ps->uniform_f_locations[i] = GL_EXTCALL(glGetUniformLocationARB(program_id, name));
}
memset(&ps->uniform_f_locations[ps_c_count], 0xff,
(gl_info->limits.glsl_ps_float_constants - ps_c_count) * sizeof(GLhandleARB));
for (i = 0; i < MAX_CONST_I; ++i)
{
@ -6002,8 +6006,10 @@ static void set_glsl_shader_program(const struct wined3d_context *context, const
GL_EXTCALL(glLinkProgramARB(programId));
shader_glsl_validate_link(gl_info, programId);
shader_glsl_init_vs_uniform_locations(gl_info, programId, &entry->vs);
shader_glsl_init_ps_uniform_locations(gl_info, programId, &entry->ps);
shader_glsl_init_vs_uniform_locations(gl_info, programId, &entry->vs,
vshader ? vshader->limits.constant_float : 0);
shader_glsl_init_ps_uniform_locations(gl_info, programId, &entry->ps,
pshader ? pshader->limits.constant_float : 0);
checkGLcall("Find glsl program uniform locations");
if (pshader && pshader->reg_maps.shader_version.major >= 3