From 6fce4d45474d1d933d04264b12869bd9a6a485b6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stefan=20D=C3=B6singer?= Date: Tue, 14 May 2013 17:38:19 +0200 Subject: [PATCH] wined3d: Pass the state and private data to shader_select. --- dlls/wined3d/arb_program_shader.c | 25 ++++++++++--------------- dlls/wined3d/context.c | 4 +--- dlls/wined3d/glsl_shader.c | 28 +++++++++++++--------------- dlls/wined3d/shader.c | 11 +++++------ dlls/wined3d/wined3d_private.h | 10 ++-------- 5 files changed, 31 insertions(+), 47 deletions(-) diff --git a/dlls/wined3d/arb_program_shader.c b/dlls/wined3d/arb_program_shader.c index e65bc5b8f76..bfade7383e6 100644 --- a/dlls/wined3d/arb_program_shader.c +++ b/dlls/wined3d/arb_program_shader.c @@ -640,8 +640,8 @@ static void shader_arb_vs_local_constants(const struct arb_vs_compiled_shader *g checkGLcall("Load vs int consts"); } -static void shader_arb_select(const struct wined3d_context *context, enum wined3d_shader_mode vertex_mode, - enum wined3d_shader_mode fragment_mode); +static void shader_arb_select(void *shader_priv, const struct wined3d_context *context, + const struct wined3d_state *state); /** * Loads the app-supplied constants into the currently set ARB_[vertex/fragment]_programs. @@ -666,9 +666,7 @@ static void shader_arb_load_constants_internal(struct shader_arb_priv *priv, && (vshader->reg_maps.integer_constants & ~vshader->reg_maps.local_int_consts)))) { TRACE("bool/integer vertex shader constants potentially modified, forcing shader reselection.\n"); - shader_arb_select(context, - useVertexShader ? WINED3D_SHADER_MODE_SHADER : WINED3D_SHADER_MODE_FFP, - usePixelShader ? WINED3D_SHADER_MODE_SHADER : WINED3D_SHADER_MODE_FFP); + shader_arb_select(priv, context, state); } else if (pshader && (pshader->reg_maps.boolean_constants @@ -676,9 +674,7 @@ static void shader_arb_load_constants_internal(struct shader_arb_priv *priv, && (pshader->reg_maps.integer_constants & ~pshader->reg_maps.local_int_consts)))) { TRACE("bool/integer pixel shader constants potentially modified, forcing shader reselection.\n"); - shader_arb_select(context, - useVertexShader ? WINED3D_SHADER_MODE_SHADER : WINED3D_SHADER_MODE_FFP, - usePixelShader ? WINED3D_SHADER_MODE_SHADER : WINED3D_SHADER_MODE_FFP); + shader_arb_select(priv, context, state); } } @@ -4605,17 +4601,16 @@ static void find_arb_vs_compile_args(const struct wined3d_state *state, } /* Context activation is done by the caller. */ -static void shader_arb_select(const struct wined3d_context *context, enum wined3d_shader_mode vertex_mode, - enum wined3d_shader_mode fragment_mode) +static void shader_arb_select(void *shader_priv, const struct wined3d_context *context, + const struct wined3d_state *state) { struct wined3d_device *device = context->swapchain->device; - struct shader_arb_priv *priv = device->shader_priv; + struct shader_arb_priv *priv = shader_priv; const struct wined3d_gl_info *gl_info = context->gl_info; - const struct wined3d_state *state = &device->stateBlock->state; int i; /* Deal with pixel shaders first so the vertex shader arg function has the input signature ready */ - if (fragment_mode == WINED3D_SHADER_MODE_SHADER) + if (use_ps(state)) { struct wined3d_shader *ps = state->pixel_shader; struct arb_ps_compile_args compile_args; @@ -4653,7 +4648,7 @@ static void shader_arb_select(const struct wined3d_context *context, enum wined3 priv->pshader_const_dirty[i] = 1; } /* Also takes care of loading local constants */ - shader_arb_load_constants_internal(device->shader_priv, context, state, TRUE, FALSE, TRUE); + shader_arb_load_constants_internal(shader_priv, context, state, TRUE, FALSE, TRUE); } else { @@ -4680,7 +4675,7 @@ static void shader_arb_select(const struct wined3d_context *context, enum wined3 priv->fragment_pipe->enable_extension(gl_info, TRUE); } - if (vertex_mode == WINED3D_SHADER_MODE_SHADER) + if (use_vs(state)) { struct wined3d_shader *vs = state->vertex_shader; struct arb_vs_compile_args compile_args; diff --git a/dlls/wined3d/context.c b/dlls/wined3d/context.c index 98bcbc86165..5b3fd6212b8 100644 --- a/dlls/wined3d/context.c +++ b/dlls/wined3d/context.c @@ -2403,9 +2403,7 @@ BOOL context_apply_draw_state(struct wined3d_context *context, struct wined3d_de if (context->select_shader) { - device->shader_backend->shader_select(context, - use_vs(state) ? WINED3D_SHADER_MODE_SHADER : WINED3D_SHADER_MODE_FFP, - use_ps(state) ? WINED3D_SHADER_MODE_SHADER : WINED3D_SHADER_MODE_FFP); + device->shader_backend->shader_select(device->shader_priv, context, state); context->select_shader = 0; } diff --git a/dlls/wined3d/glsl_shader.c b/dlls/wined3d/glsl_shader.c index bf530cba2a7..88162295893 100644 --- a/dlls/wined3d/glsl_shader.c +++ b/dlls/wined3d/glsl_shader.c @@ -5480,13 +5480,11 @@ static void shader_glsl_init_ps_uniform_locations(const struct wined3d_gl_info * } /* Context activation is done by the caller. */ -static void set_glsl_shader_program(const struct wined3d_context *context, struct wined3d_device *device, - enum wined3d_shader_mode vertex_mode, enum wined3d_shader_mode fragment_mode) +static void set_glsl_shader_program(const struct wined3d_context *context, const struct wined3d_state *state, + struct shader_glsl_priv *priv) { - const struct wined3d_state *state = &device->stateBlock->state; const struct wined3d_gl_info *gl_info = context->gl_info; const struct ps_np2fixup_info *np2fixup_info = NULL; - struct shader_glsl_priv *priv = device->shader_priv; struct glsl_shader_prog_link *entry = NULL; struct wined3d_shader *vshader = NULL; struct wined3d_shader *gshader = NULL; @@ -5498,8 +5496,9 @@ static void set_glsl_shader_program(const struct wined3d_context *context, struc struct vs_compile_args vs_compile_args; GLhandleARB vs_id, gs_id, ps_id; struct list *ps_list; + struct wined3d_device *device = context->swapchain->device; - if (vertex_mode == WINED3D_SHADER_MODE_SHADER) + if (use_vs(state)) { vshader = state->vertex_shader; find_vs_compile_args(state, vshader, &vs_compile_args); @@ -5516,7 +5515,7 @@ static void set_glsl_shader_program(const struct wined3d_context *context, struc gs_id = 0; } - if (fragment_mode == WINED3D_SHADER_MODE_SHADER) + if (use_ps(state)) { pshader = state->pixel_shader; find_ps_compile_args(state, pshader, &ps_compile_args); @@ -5524,7 +5523,7 @@ static void set_glsl_shader_program(const struct wined3d_context *context, struc pshader, &ps_compile_args, &np2fixup_info); ps_list = &pshader->linked_programs; } - else if (fragment_mode == WINED3D_SHADER_MODE_FFP && priv->fragment_pipe == &glsl_fragment_pipe) + else if (priv->fragment_pipe == &glsl_fragment_pipe) { struct glsl_ffp_fragment_shader *ffp_shader; struct ffp_frag_settings settings; @@ -5781,20 +5780,19 @@ static GLhandleARB create_glsl_blt_shader(const struct wined3d_gl_info *gl_info, } /* Context activation is done by the caller. */ -static void shader_glsl_select(const struct wined3d_context *context, enum wined3d_shader_mode vertex_mode, - enum wined3d_shader_mode fragment_mode) +static void shader_glsl_select(void *shader_priv, const struct wined3d_context *context, + const struct wined3d_state *state) { const struct wined3d_gl_info *gl_info = context->gl_info; - struct wined3d_device *device = context->swapchain->device; - struct shader_glsl_priv *priv = device->shader_priv; + struct shader_glsl_priv *priv = shader_priv; GLhandleARB program_id = 0; GLenum old_vertex_color_clamp, current_vertex_color_clamp; - priv->vertex_pipe->vp_enable(gl_info, vertex_mode == WINED3D_SHADER_MODE_FFP); - priv->fragment_pipe->enable_extension(gl_info, fragment_mode == WINED3D_SHADER_MODE_FFP); + priv->vertex_pipe->vp_enable(gl_info, !use_vs(state)); + priv->fragment_pipe->enable_extension(gl_info, !use_ps(state)); old_vertex_color_clamp = priv->glsl_program ? priv->glsl_program->vs.vertex_color_clamp : GL_FIXED_ONLY_ARB; - set_glsl_shader_program(context, device, vertex_mode, fragment_mode); + set_glsl_shader_program(context, state, priv); current_vertex_color_clamp = priv->glsl_program ? priv->glsl_program->vs.vertex_color_clamp : GL_FIXED_ONLY_ARB; if (old_vertex_color_clamp != current_vertex_color_clamp) { @@ -5819,7 +5817,7 @@ static void shader_glsl_select(const struct wined3d_context *context, enum wined * called between selecting the shader and using it, which results in wrong fixup for some frames. */ if (priv->glsl_program && priv->glsl_program->ps.np2_fixup_info) { - shader_glsl_load_np2fixup_constants(priv, gl_info, &device->stateBlock->state); + shader_glsl_load_np2fixup_constants(priv, gl_info, state); } } diff --git a/dlls/wined3d/shader.c b/dlls/wined3d/shader.c index b4802d2dbd1..26fd65b53c4 100644 --- a/dlls/wined3d/shader.c +++ b/dlls/wined3d/shader.c @@ -1517,15 +1517,14 @@ static void shader_none_destroy(struct wined3d_shader *shader) {} static void shader_none_context_destroyed(void *shader_priv, const struct wined3d_context *context) {} /* Context activation is done by the caller. */ -static void shader_none_select(const struct wined3d_context *context, enum wined3d_shader_mode vertex_mode, - enum wined3d_shader_mode fragment_mode) +static void shader_none_select(void *shader_priv, const struct wined3d_context *context, + const struct wined3d_state *state) { const struct wined3d_gl_info *gl_info = context->gl_info; - struct wined3d_device *device = context->swapchain->device; - struct shader_none_priv *priv = device->shader_priv; + struct shader_none_priv *priv = shader_priv; - priv->vertex_pipe->vp_enable(gl_info, vertex_mode == WINED3D_SHADER_MODE_FFP); - priv->fragment_pipe->enable_extension(gl_info, fragment_mode == WINED3D_SHADER_MODE_FFP); + priv->vertex_pipe->vp_enable(gl_info, !use_vs(state)); + priv->fragment_pipe->enable_extension(gl_info, !use_ps(state)); } /* Context activation is done by the caller. */ diff --git a/dlls/wined3d/wined3d_private.h b/dlls/wined3d/wined3d_private.h index 6d8e5560aa1..e5ea47ebf43 100644 --- a/dlls/wined3d/wined3d_private.h +++ b/dlls/wined3d/wined3d_private.h @@ -785,12 +785,6 @@ struct vs_compile_args { WORD swizzle_map; /* MAX_ATTRIBS, 16 */ }; -enum wined3d_shader_mode -{ - WINED3D_SHADER_MODE_FFP, - WINED3D_SHADER_MODE_SHADER, -}; - struct wined3d_context; struct wined3d_state; struct fragment_pipeline; @@ -799,8 +793,8 @@ struct wined3d_vertex_pipe_ops; struct wined3d_shader_backend_ops { void (*shader_handle_instruction)(const struct wined3d_shader_instruction *); - void (*shader_select)(const struct wined3d_context *context, enum wined3d_shader_mode vertex_mode, - enum wined3d_shader_mode fragment_mode); + void (*shader_select)(void *shader_priv, const struct wined3d_context *context, + const struct wined3d_state *state); void (*shader_disable)(void *shader_priv, const struct wined3d_context *context); void (*shader_select_depth_blt)(void *shader_priv, const struct wined3d_gl_info *gl_info, enum tex_types tex_type, const SIZE *ds_mask_size);