[PATCH 2/5] wined3d: Avoid a couple of useless glGetUniformLocationARB() calls.
Henri Verbeet
hverbeet at codeweavers.com
Wed Sep 4 01:56:44 CDT 2013
Ideally we wouldn't need to allocate more space than needed for
uniform_f_locations either, but that's a bit harder because e.g.
walk_constant_heap() makes assumptions about the size of the array.
---
dlls/wined3d/glsl_shader.c | 18 ++++++++++++------
1 file changed, 12 insertions(+), 6 deletions(-)
diff --git a/dlls/wined3d/glsl_shader.c b/dlls/wined3d/glsl_shader.c
index 280ec20..93ec2a8 100644
--- a/dlls/wined3d/glsl_shader.c
+++ b/dlls/wined3d/glsl_shader.c
@@ -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
--
1.8.1.5
More information about the wine-patches
mailing list