wined3d: Pass the state and private data to shader_select.

This commit is contained in:
Stefan Dösinger 2013-05-14 17:38:19 +02:00 committed by Alexandre Julliard
parent 47f385adf0
commit 6fce4d4547
5 changed files with 31 additions and 47 deletions

View File

@ -640,8 +640,8 @@ static void shader_arb_vs_local_constants(const struct arb_vs_compiled_shader *g
checkGLcall("Load vs int consts"); checkGLcall("Load vs int consts");
} }
static void shader_arb_select(const struct wined3d_context *context, enum wined3d_shader_mode vertex_mode, static void shader_arb_select(void *shader_priv, const struct wined3d_context *context,
enum wined3d_shader_mode fragment_mode); const struct wined3d_state *state);
/** /**
* Loads the app-supplied constants into the currently set ARB_[vertex/fragment]_programs. * 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)))) && (vshader->reg_maps.integer_constants & ~vshader->reg_maps.local_int_consts))))
{ {
TRACE("bool/integer vertex shader constants potentially modified, forcing shader reselection.\n"); TRACE("bool/integer vertex shader constants potentially modified, forcing shader reselection.\n");
shader_arb_select(context, shader_arb_select(priv, context, state);
useVertexShader ? WINED3D_SHADER_MODE_SHADER : WINED3D_SHADER_MODE_FFP,
usePixelShader ? WINED3D_SHADER_MODE_SHADER : WINED3D_SHADER_MODE_FFP);
} }
else if (pshader else if (pshader
&& (pshader->reg_maps.boolean_constants && (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)))) && (pshader->reg_maps.integer_constants & ~pshader->reg_maps.local_int_consts))))
{ {
TRACE("bool/integer pixel shader constants potentially modified, forcing shader reselection.\n"); TRACE("bool/integer pixel shader constants potentially modified, forcing shader reselection.\n");
shader_arb_select(context, shader_arb_select(priv, context, state);
useVertexShader ? WINED3D_SHADER_MODE_SHADER : WINED3D_SHADER_MODE_FFP,
usePixelShader ? WINED3D_SHADER_MODE_SHADER : WINED3D_SHADER_MODE_FFP);
} }
} }
@ -4605,17 +4601,16 @@ static void find_arb_vs_compile_args(const struct wined3d_state *state,
} }
/* Context activation is done by the caller. */ /* Context activation is done by the caller. */
static void shader_arb_select(const struct wined3d_context *context, enum wined3d_shader_mode vertex_mode, static void shader_arb_select(void *shader_priv, const struct wined3d_context *context,
enum wined3d_shader_mode fragment_mode) const struct wined3d_state *state)
{ {
struct wined3d_device *device = context->swapchain->device; 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_gl_info *gl_info = context->gl_info;
const struct wined3d_state *state = &device->stateBlock->state;
int i; int i;
/* Deal with pixel shaders first so the vertex shader arg function has the input signature ready */ /* 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 wined3d_shader *ps = state->pixel_shader;
struct arb_ps_compile_args compile_args; 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; priv->pshader_const_dirty[i] = 1;
} }
/* Also takes care of loading local constants */ /* 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 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); 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 wined3d_shader *vs = state->vertex_shader;
struct arb_vs_compile_args compile_args; struct arb_vs_compile_args compile_args;

View File

@ -2403,9 +2403,7 @@ BOOL context_apply_draw_state(struct wined3d_context *context, struct wined3d_de
if (context->select_shader) if (context->select_shader)
{ {
device->shader_backend->shader_select(context, device->shader_backend->shader_select(device->shader_priv, context, state);
use_vs(state) ? WINED3D_SHADER_MODE_SHADER : WINED3D_SHADER_MODE_FFP,
use_ps(state) ? WINED3D_SHADER_MODE_SHADER : WINED3D_SHADER_MODE_FFP);
context->select_shader = 0; context->select_shader = 0;
} }

View File

@ -5480,13 +5480,11 @@ static void shader_glsl_init_ps_uniform_locations(const struct wined3d_gl_info *
} }
/* Context activation is done by the caller. */ /* Context activation is done by the caller. */
static void set_glsl_shader_program(const struct wined3d_context *context, struct wined3d_device *device, static void set_glsl_shader_program(const struct wined3d_context *context, const struct wined3d_state *state,
enum wined3d_shader_mode vertex_mode, enum wined3d_shader_mode fragment_mode) 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 wined3d_gl_info *gl_info = context->gl_info;
const struct ps_np2fixup_info *np2fixup_info = NULL; const struct ps_np2fixup_info *np2fixup_info = NULL;
struct shader_glsl_priv *priv = device->shader_priv;
struct glsl_shader_prog_link *entry = NULL; struct glsl_shader_prog_link *entry = NULL;
struct wined3d_shader *vshader = NULL; struct wined3d_shader *vshader = NULL;
struct wined3d_shader *gshader = 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; struct vs_compile_args vs_compile_args;
GLhandleARB vs_id, gs_id, ps_id; GLhandleARB vs_id, gs_id, ps_id;
struct list *ps_list; 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; vshader = state->vertex_shader;
find_vs_compile_args(state, vshader, &vs_compile_args); 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; gs_id = 0;
} }
if (fragment_mode == WINED3D_SHADER_MODE_SHADER) if (use_ps(state))
{ {
pshader = state->pixel_shader; pshader = state->pixel_shader;
find_ps_compile_args(state, pshader, &ps_compile_args); 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); pshader, &ps_compile_args, &np2fixup_info);
ps_list = &pshader->linked_programs; 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 glsl_ffp_fragment_shader *ffp_shader;
struct ffp_frag_settings settings; 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. */ /* Context activation is done by the caller. */
static void shader_glsl_select(const struct wined3d_context *context, enum wined3d_shader_mode vertex_mode, static void shader_glsl_select(void *shader_priv, const struct wined3d_context *context,
enum wined3d_shader_mode fragment_mode) const struct wined3d_state *state)
{ {
const struct wined3d_gl_info *gl_info = context->gl_info; const struct wined3d_gl_info *gl_info = context->gl_info;
struct wined3d_device *device = context->swapchain->device; struct shader_glsl_priv *priv = shader_priv;
struct shader_glsl_priv *priv = device->shader_priv;
GLhandleARB program_id = 0; GLhandleARB program_id = 0;
GLenum old_vertex_color_clamp, current_vertex_color_clamp; GLenum old_vertex_color_clamp, current_vertex_color_clamp;
priv->vertex_pipe->vp_enable(gl_info, vertex_mode == WINED3D_SHADER_MODE_FFP); priv->vertex_pipe->vp_enable(gl_info, !use_vs(state));
priv->fragment_pipe->enable_extension(gl_info, fragment_mode == WINED3D_SHADER_MODE_FFP); 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; 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; 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) 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. */ * 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) 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);
} }
} }

View File

@ -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) {} static void shader_none_context_destroyed(void *shader_priv, const struct wined3d_context *context) {}
/* Context activation is done by the caller. */ /* Context activation is done by the caller. */
static void shader_none_select(const struct wined3d_context *context, enum wined3d_shader_mode vertex_mode, static void shader_none_select(void *shader_priv, const struct wined3d_context *context,
enum wined3d_shader_mode fragment_mode) const struct wined3d_state *state)
{ {
const struct wined3d_gl_info *gl_info = context->gl_info; const struct wined3d_gl_info *gl_info = context->gl_info;
struct wined3d_device *device = context->swapchain->device; struct shader_none_priv *priv = shader_priv;
struct shader_none_priv *priv = device->shader_priv;
priv->vertex_pipe->vp_enable(gl_info, vertex_mode == WINED3D_SHADER_MODE_FFP); priv->vertex_pipe->vp_enable(gl_info, !use_vs(state));
priv->fragment_pipe->enable_extension(gl_info, fragment_mode == WINED3D_SHADER_MODE_FFP); priv->fragment_pipe->enable_extension(gl_info, !use_ps(state));
} }
/* Context activation is done by the caller. */ /* Context activation is done by the caller. */

View File

@ -785,12 +785,6 @@ struct vs_compile_args {
WORD swizzle_map; /* MAX_ATTRIBS, 16 */ WORD swizzle_map; /* MAX_ATTRIBS, 16 */
}; };
enum wined3d_shader_mode
{
WINED3D_SHADER_MODE_FFP,
WINED3D_SHADER_MODE_SHADER,
};
struct wined3d_context; struct wined3d_context;
struct wined3d_state; struct wined3d_state;
struct fragment_pipeline; struct fragment_pipeline;
@ -799,8 +793,8 @@ struct wined3d_vertex_pipe_ops;
struct wined3d_shader_backend_ops struct wined3d_shader_backend_ops
{ {
void (*shader_handle_instruction)(const struct wined3d_shader_instruction *); void (*shader_handle_instruction)(const struct wined3d_shader_instruction *);
void (*shader_select)(const struct wined3d_context *context, enum wined3d_shader_mode vertex_mode, void (*shader_select)(void *shader_priv, const struct wined3d_context *context,
enum wined3d_shader_mode fragment_mode); const struct wined3d_state *state);
void (*shader_disable)(void *shader_priv, const struct wined3d_context *context); 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, 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); enum tex_types tex_type, const SIZE *ds_mask_size);