From f6bd191385431929f5a8847a8a3556e6309850df Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B3zef=20Kucia?= Date: Wed, 22 Jun 2016 11:37:32 +0200 Subject: [PATCH] wined3d: Introduce wined3d_gl_limits_get_uniform_block_range(). MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Józef Kucia Signed-off-by: Henri Verbeet Signed-off-by: Alexandre Julliard --- dlls/wined3d/glsl_shader.c | 19 ++++++++----------- dlls/wined3d/state.c | 14 +++++++++----- dlls/wined3d/utils.c | 27 +++++++++++++++++++++++++++ dlls/wined3d/wined3d_private.h | 9 ++++++--- 4 files changed, 50 insertions(+), 19 deletions(-) diff --git a/dlls/wined3d/glsl_shader.c b/dlls/wined3d/glsl_shader.c index b4ddf894647..3aa96267572 100644 --- a/dlls/wined3d/glsl_shader.c +++ b/dlls/wined3d/glsl_shader.c @@ -7518,13 +7518,14 @@ static void shader_glsl_init_ps_uniform_locations(const struct wined3d_gl_info * static void shader_glsl_init_uniform_block_bindings(const struct wined3d_gl_info *gl_info, struct shader_glsl_priv *priv, GLuint program_id, - const struct wined3d_shader_reg_maps *reg_maps, unsigned int base, unsigned int count) + const struct wined3d_shader_reg_maps *reg_maps) { - const char *prefix = shader_glsl_get_prefix(reg_maps->shader_version.type); - GLuint block_idx; - unsigned int i; struct wined3d_string_buffer *name = string_buffer_get(&priv->string_buffers); + const char *prefix = shader_glsl_get_prefix(reg_maps->shader_version.type); + unsigned int i, base, count; + GLuint block_idx; + wined3d_gl_limits_get_uniform_block_range(&gl_info->limits, reg_maps->shader_version.type, &base, &count); for (i = 0; i < count; ++i) { if (!reg_maps->cb_sizes[i]) @@ -7819,8 +7820,7 @@ static void set_glsl_shader_program(const struct wined3d_context *context, const if (entry->vs.pos_fixup_location != -1) entry->constant_update_mask |= WINED3D_SHADER_CONST_POS_FIXUP; - shader_glsl_init_uniform_block_bindings(gl_info, priv, program_id, &vshader->reg_maps, - 0, gl_info->limits.vertex_uniform_blocks); + shader_glsl_init_uniform_block_bindings(gl_info, priv, program_id, &vshader->reg_maps); } else { @@ -7860,8 +7860,7 @@ static void set_glsl_shader_program(const struct wined3d_context *context, const if (gshader) { entry->constant_update_mask |= WINED3D_SHADER_CONST_POS_FIXUP; - shader_glsl_init_uniform_block_bindings(gl_info, priv, program_id, &gshader->reg_maps, - gl_info->limits.vertex_uniform_blocks, gl_info->limits.geometry_uniform_blocks); + shader_glsl_init_uniform_block_bindings(gl_info, priv, program_id, &gshader->reg_maps); } if (ps_id) @@ -7876,9 +7875,7 @@ static void set_glsl_shader_program(const struct wined3d_context *context, const if (entry->ps.ycorrection_location != -1) entry->constant_update_mask |= WINED3D_SHADER_CONST_PS_Y_CORR; - shader_glsl_init_uniform_block_bindings(gl_info, priv, program_id, &pshader->reg_maps, - gl_info->limits.vertex_uniform_blocks + gl_info->limits.geometry_uniform_blocks, - gl_info->limits.fragment_uniform_blocks); + shader_glsl_init_uniform_block_bindings(gl_info, priv, program_id, &pshader->reg_maps); } else { diff --git a/dlls/wined3d/state.c b/dlls/wined3d/state.c index bc55263cf61..6b9cd3d0656 100644 --- a/dlls/wined3d/state.c +++ b/dlls/wined3d/state.c @@ -4849,30 +4849,34 @@ static void state_cb(const struct wined3d_gl_info *gl_info, const struct wined3d static void state_cb_vs(struct wined3d_context *context, const struct wined3d_state *state, DWORD state_id) { const struct wined3d_gl_limits *limits = &context->gl_info->limits; + unsigned int base, count; TRACE("context %p, state %p, state_id %#x.\n", context, state, state_id); - state_cb(context->gl_info, state, WINED3D_SHADER_TYPE_VERTEX, 0, limits->vertex_uniform_blocks); + wined3d_gl_limits_get_uniform_block_range(limits, WINED3D_SHADER_TYPE_VERTEX, &base, &count); + state_cb(context->gl_info, state, WINED3D_SHADER_TYPE_VERTEX, base, count); } static void state_cb_gs(struct wined3d_context *context, const struct wined3d_state *state, DWORD state_id) { const struct wined3d_gl_limits *limits = &context->gl_info->limits; + unsigned int base, count; TRACE("context %p, state %p, state_id %#x.\n", context, state, state_id); - state_cb(context->gl_info, state, WINED3D_SHADER_TYPE_GEOMETRY, - limits->vertex_uniform_blocks, limits->geometry_uniform_blocks); + wined3d_gl_limits_get_uniform_block_range(limits, WINED3D_SHADER_TYPE_GEOMETRY, &base, &count); + state_cb(context->gl_info, state, WINED3D_SHADER_TYPE_GEOMETRY, base, count); } static void state_cb_ps(struct wined3d_context *context, const struct wined3d_state *state, DWORD state_id) { const struct wined3d_gl_limits *limits = &context->gl_info->limits; + unsigned int base, count; TRACE("context %p, state %p, state_id %#x.\n", context, state, state_id); - state_cb(context->gl_info, state, WINED3D_SHADER_TYPE_PIXEL, - limits->vertex_uniform_blocks + limits->geometry_uniform_blocks, limits->fragment_uniform_blocks); + wined3d_gl_limits_get_uniform_block_range(limits, WINED3D_SHADER_TYPE_PIXEL, &base, &count); + state_cb(context->gl_info, state, WINED3D_SHADER_TYPE_PIXEL, base, count); } static void state_cb_warn(struct wined3d_context *context, const struct wined3d_state *state, DWORD state_id) diff --git a/dlls/wined3d/utils.c b/dlls/wined3d/utils.c index 9575b3955cd..01e56eb7441 100644 --- a/dlls/wined3d/utils.c +++ b/dlls/wined3d/utils.c @@ -5748,3 +5748,30 @@ BOOL wined3d_clip_blit(const RECT *clip_rect, RECT *clipped, RECT *other) return TRUE; } + +void wined3d_gl_limits_get_uniform_block_range(const struct wined3d_gl_limits *gl_limits, + enum wined3d_shader_type shader_type, unsigned int *base, unsigned int *count) +{ + *base = 0; + *count = gl_limits->vertex_uniform_blocks; + + if (shader_type == WINED3D_SHADER_TYPE_VERTEX) + return; + + *base += *count; + *count = gl_limits->geometry_uniform_blocks; + + if (shader_type == WINED3D_SHADER_TYPE_GEOMETRY) + return; + + *base += *count; + *count = gl_limits->fragment_uniform_blocks; + + if (shader_type == WINED3D_SHADER_TYPE_PIXEL) + return; + + *base += *count; + *count = 0; + + ERR("Unhandled shader type %#x.\n", shader_type); +} diff --git a/dlls/wined3d/wined3d_private.h b/dlls/wined3d/wined3d_private.h index 701e93e0880..ce094ca8a74 100644 --- a/dlls/wined3d/wined3d_private.h +++ b/dlls/wined3d/wined3d_private.h @@ -1971,9 +1971,9 @@ struct wined3d_gl_limits UINT lights; UINT textures; UINT texture_coords; - UINT vertex_uniform_blocks; - UINT geometry_uniform_blocks; - UINT fragment_uniform_blocks; + unsigned int vertex_uniform_blocks; + unsigned int geometry_uniform_blocks; + unsigned int fragment_uniform_blocks; UINT fragment_samplers; UINT vertex_samplers; UINT combined_samplers; @@ -2004,6 +2004,9 @@ struct wined3d_gl_limits UINT arb_ps_temps; }; +void wined3d_gl_limits_get_uniform_block_range(const struct wined3d_gl_limits *gl_limits, + enum wined3d_shader_type shader_type, unsigned int *base, unsigned int *count) DECLSPEC_HIDDEN; + struct wined3d_gl_info { DWORD selected_gl_version;