[PATCH 1/5] wined3d: Unify shader binding points.

Henri Verbeet hverbeet at codeweavers.com
Wed Oct 9 15:57:45 CDT 2013


---
 dlls/wined3d/arb_program_shader.c |   16 +++++-----
 dlls/wined3d/context.c            |   21 ++++++--------
 dlls/wined3d/cs.c                 |   58 ++++++-------------------------------
 dlls/wined3d/device.c             |   30 +++++++++----------
 dlls/wined3d/glsl_shader.c        |   16 +++++-----
 dlls/wined3d/shader.c             |    2 +-
 dlls/wined3d/state.c              |    6 ++--
 dlls/wined3d/stateblock.c         |   54 +++++++++++++++-------------------
 dlls/wined3d/wined3d_private.h    |   14 ++++-----
 9 files changed, 84 insertions(+), 133 deletions(-)

diff --git a/dlls/wined3d/arb_program_shader.c b/dlls/wined3d/arb_program_shader.c
index 64b7d90..5efb562 100644
--- a/dlls/wined3d/arb_program_shader.c
+++ b/dlls/wined3d/arb_program_shader.c
@@ -657,7 +657,9 @@ static void shader_arb_load_constants_internal(struct shader_arb_priv *priv,
 
     if (!from_shader_select)
     {
-        const struct wined3d_shader *vshader = state->vertex_shader, *pshader = state->pixel_shader;
+        const struct wined3d_shader *vshader = state->shader[WINED3D_SHADER_TYPE_VERTEX];
+        const struct wined3d_shader *pshader = state->shader[WINED3D_SHADER_TYPE_PIXEL];
+
         if (vshader
                 && (vshader->reg_maps.boolean_constants
                 || (!gl_info->supported[NV_VERTEX_PROGRAM2_OPTION]
@@ -691,7 +693,7 @@ static void shader_arb_load_constants_internal(struct shader_arb_priv *priv,
 
     if (useVertexShader)
     {
-        struct wined3d_shader *vshader = state->vertex_shader;
+        const struct wined3d_shader *vshader = state->shader[WINED3D_SHADER_TYPE_VERTEX];
         const struct arb_vs_compiled_shader *gl_shader = priv->compiled_vprog;
 
         /* Load DirectX 9 float constants for vertex shader */
@@ -702,7 +704,7 @@ static void shader_arb_load_constants_internal(struct shader_arb_priv *priv,
 
     if (usePixelShader)
     {
-        struct wined3d_shader *pshader = state->pixel_shader;
+        const struct wined3d_shader *pshader = state->shader[WINED3D_SHADER_TYPE_PIXEL];
         const struct arb_ps_compiled_shader *gl_shader = priv->compiled_fprog;
         UINT rt_height = state->fb->render_targets[0]->resource.height;
 
@@ -4586,7 +4588,7 @@ static void find_arb_vs_compile_args(const struct wined3d_state *state,
     args->clip.boolclip_compare = 0;
     if (use_ps(state))
     {
-        const struct wined3d_shader *ps = state->pixel_shader;
+        const struct wined3d_shader *ps = state->shader[WINED3D_SHADER_TYPE_PIXEL];
         const struct arb_pshader_private *shader_priv = ps->backend_data;
         args->ps_signature = shader_priv->input_signature_idx;
 
@@ -4658,7 +4660,7 @@ static void shader_arb_select(void *shader_priv, struct wined3d_context *context
     /* Deal with pixel shaders first so the vertex shader arg function has the input signature ready */
     if (use_ps(state))
     {
-        struct wined3d_shader *ps = state->pixel_shader;
+        struct wined3d_shader *ps = state->shader[WINED3D_SHADER_TYPE_PIXEL];
         struct arb_ps_compile_args compile_args;
         struct arb_ps_compiled_shader *compiled;
 
@@ -4725,7 +4727,7 @@ static void shader_arb_select(void *shader_priv, struct wined3d_context *context
 
     if (use_vs(state))
     {
-        struct wined3d_shader *vs = state->vertex_shader;
+        struct wined3d_shader *vs = state->shader[WINED3D_SHADER_TYPE_VERTEX];
         struct arb_vs_compile_args compile_args;
         struct arb_vs_compiled_shader *compiled;
         const struct wined3d_shader_signature_element *ps_input_sig;
@@ -4739,7 +4741,7 @@ static void shader_arb_select(void *shader_priv, struct wined3d_context *context
         if (compile_args.ps_signature == ~0U)
             ps_input_sig = NULL;
         else
-            ps_input_sig = state->pixel_shader->input_signature;
+            ps_input_sig = state->shader[WINED3D_SHADER_TYPE_PIXEL]->input_signature;
 
         compiled = find_arb_vshader(vs, context->gl_info, context->stream_info.use_map,
                 &compile_args, ps_input_sig);
diff --git a/dlls/wined3d/context.c b/dlls/wined3d/context.c
index b1f2f8a..f3566cf 100644
--- a/dlls/wined3d/context.c
+++ b/dlls/wined3d/context.c
@@ -2291,7 +2291,7 @@ static DWORD find_draw_buffers_mask(const struct wined3d_context *context, const
 {
     const struct wined3d_state *state = &device->state;
     struct wined3d_surface **rts = state->fb->render_targets;
-    struct wined3d_shader *ps = state->pixel_shader;
+    struct wined3d_shader *ps = state->shader[WINED3D_SHADER_TYPE_PIXEL];
     DWORD rt_mask, rt_mask_bits;
     unsigned int i;
 
@@ -2468,7 +2468,7 @@ static void context_map_fixed_function_samplers(struct wined3d_context *context,
 static void context_map_psamplers(struct wined3d_context *context, const struct wined3d_state *state)
 {
     const enum wined3d_sampler_texture_type *sampler_type =
-            state->pixel_shader->reg_maps.sampler_type;
+            state->shader[WINED3D_SHADER_TYPE_PIXEL]->reg_maps.sampler_type;
     unsigned int i;
     const struct wined3d_d3d_info *d3d_info = context->d3d_info;
 
@@ -2515,7 +2515,7 @@ static BOOL context_unit_free_for_vs(const struct wined3d_context *context,
 static void context_map_vsamplers(struct wined3d_context *context, BOOL ps, const struct wined3d_state *state)
 {
     const enum wined3d_sampler_texture_type *vshader_sampler_type =
-            state->vertex_shader->reg_maps.sampler_type;
+            state->shader[WINED3D_SHADER_TYPE_VERTEX]->reg_maps.sampler_type;
     const enum wined3d_sampler_texture_type *pshader_sampler_type = NULL;
     const struct wined3d_gl_info *gl_info = context->gl_info;
     int start = min(MAX_COMBINED_SAMPLERS, gl_info->limits.combined_samplers) - 1;
@@ -2525,7 +2525,7 @@ static void context_map_vsamplers(struct wined3d_context *context, BOOL ps, cons
     {
         /* Note that we only care if a sampler is sampled or not, not the sampler's specific type.
          * Otherwise we'd need to call shader_update_samplers() here for 1.x pixelshaders. */
-        pshader_sampler_type = state->pixel_shader->reg_maps.sampler_type;
+        pshader_sampler_type = state->shader[WINED3D_SHADER_TYPE_PIXEL]->reg_maps.sampler_type;
     }
 
     for (i = 0; i < MAX_VERTEX_SAMPLERS; ++i) {
@@ -2627,17 +2627,14 @@ void context_stream_info_from_declaration(struct wined3d_context *context,
 {
     /* We need to deal with frequency data! */
     struct wined3d_vertex_declaration *declaration = state->vertex_declaration;
-    BOOL use_vshader;
+    BOOL use_vshader = use_vs(state);
     unsigned int i;
     WORD map;
 
     stream_info->use_map = 0;
     stream_info->swizzle_map = 0;
     stream_info->all_vbo = 1;
-
-    /* Check for transformed vertices, disable vertex shader if present. */
     stream_info->position_transformed = declaration->position_transformed;
-    use_vshader = state->vertex_shader && !declaration->position_transformed;
 
     /* Translate the declaration into strided data. */
     for (i = 0; i < declaration->element_count; ++i)
@@ -2686,7 +2683,7 @@ void context_stream_info_from_declaration(struct wined3d_context *context,
                 /* TODO: Assuming vertexdeclarations are usually used with the
                  * same or a similar shader, it might be worth it to store the
                  * last used output slot and try that one first. */
-                stride_used = vshader_get_input(state->vertex_shader,
+                stride_used = vshader_get_input(state->shader[WINED3D_SHADER_TYPE_VERTEX],
                         element->usage, element->usage_idx, &idx);
             }
             else
@@ -2774,7 +2771,7 @@ static void context_update_stream_info(struct wined3d_context *context, const st
     TRACE("============================= Vertex Declaration =============================\n");
     context_stream_info_from_declaration(context, state, stream_info);
 
-    if (state->vertex_shader && !stream_info->position_transformed)
+    if (use_vs(state))
     {
         if (state->vertex_declaration->half_float_conv_needed && !stream_info->all_vbo)
         {
@@ -2826,7 +2823,7 @@ static void context_preload_textures(struct wined3d_context *context, const stru
     {
         for (i = 0; i < MAX_VERTEX_SAMPLERS; ++i)
         {
-            if (state->vertex_shader->reg_maps.sampler_type[i])
+            if (state->shader[WINED3D_SHADER_TYPE_VERTEX]->reg_maps.sampler_type[i])
                 context_preload_texture(context, state, MAX_FRAGMENT_SAMPLERS + i);
         }
     }
@@ -2835,7 +2832,7 @@ static void context_preload_textures(struct wined3d_context *context, const stru
     {
         for (i = 0; i < MAX_FRAGMENT_SAMPLERS; ++i)
         {
-            if (state->pixel_shader->reg_maps.sampler_type[i])
+            if (state->shader[WINED3D_SHADER_TYPE_PIXEL]->reg_maps.sampler_type[i])
                 context_preload_texture(context, state, i);
         }
     }
diff --git a/dlls/wined3d/cs.c b/dlls/wined3d/cs.c
index 0f440f7..12ab60e 100644
--- a/dlls/wined3d/cs.c
+++ b/dlls/wined3d/cs.c
@@ -38,9 +38,7 @@ enum wined3d_cs_op
     WINED3D_CS_OP_SET_STREAM_SOURCE_FREQ,
     WINED3D_CS_OP_SET_INDEX_BUFFER,
     WINED3D_CS_OP_SET_TEXTURE,
-    WINED3D_CS_OP_SET_VERTEX_SHADER,
-    WINED3D_CS_OP_SET_GEOMETRY_SHADER,
-    WINED3D_CS_OP_SET_PIXEL_SHADER,
+    WINED3D_CS_OP_SET_SHADER,
     WINED3D_CS_OP_SET_RENDER_STATE,
     WINED3D_CS_OP_SET_TEXTURE_STATE,
     WINED3D_CS_OP_SET_SAMPLER_STATE,
@@ -146,6 +144,7 @@ struct wined3d_cs_set_texture
 struct wined3d_cs_set_shader
 {
     enum wined3d_cs_op opcode;
+    enum wined3d_shader_type type;
     struct wined3d_shader *shader;
 };
 
@@ -563,58 +562,21 @@ void wined3d_cs_emit_set_texture(struct wined3d_cs *cs, UINT stage, struct wined
     cs->ops->submit(cs);
 }
 
-static void wined3d_cs_exec_set_vertex_shader(struct wined3d_cs *cs, const void *data)
+static void wined3d_cs_exec_set_shader(struct wined3d_cs *cs, const void *data)
 {
     const struct wined3d_cs_set_shader *op = data;
 
-    cs->state.vertex_shader = op->shader;
-    device_invalidate_state(cs->device, STATE_SHADER(WINED3D_SHADER_TYPE_VERTEX));
+    cs->state.shader[op->type] = op->shader;
+    device_invalidate_state(cs->device, STATE_SHADER(op->type));
 }
 
-void wined3d_cs_emit_set_vertex_shader(struct wined3d_cs *cs, struct wined3d_shader *shader)
+void wined3d_cs_emit_set_shader(struct wined3d_cs *cs, enum wined3d_shader_type type, struct wined3d_shader *shader)
 {
     struct wined3d_cs_set_shader *op;
 
     op = cs->ops->require_space(cs, sizeof(*op));
-    op->opcode = WINED3D_CS_OP_SET_VERTEX_SHADER;
-    op->shader = shader;
-
-    cs->ops->submit(cs);
-}
-
-static void wined3d_cs_exec_set_geometry_shader(struct wined3d_cs *cs, const void *data)
-{
-    const struct wined3d_cs_set_shader *op = data;
-
-    cs->state.geometry_shader = op->shader;
-    device_invalidate_state(cs->device, STATE_SHADER(WINED3D_SHADER_TYPE_GEOMETRY));
-}
-
-void wined3d_cs_emit_set_geometry_shader(struct wined3d_cs *cs, struct wined3d_shader *shader)
-{
-    struct wined3d_cs_set_shader *op;
-
-    op = cs->ops->require_space(cs, sizeof(*op));
-    op->opcode = WINED3D_CS_OP_SET_GEOMETRY_SHADER;
-    op->shader = shader;
-
-    cs->ops->submit(cs);
-}
-
-static void wined3d_cs_exec_set_pixel_shader(struct wined3d_cs *cs, const void *data)
-{
-    const struct wined3d_cs_set_shader *op = data;
-
-    cs->state.pixel_shader = op->shader;
-    device_invalidate_state(cs->device, STATE_SHADER(WINED3D_SHADER_TYPE_PIXEL));
-}
-
-void wined3d_cs_emit_set_pixel_shader(struct wined3d_cs *cs, struct wined3d_shader *shader)
-{
-    struct wined3d_cs_set_shader *op;
-
-    op = cs->ops->require_space(cs, sizeof(*op));
-    op->opcode = WINED3D_CS_OP_SET_PIXEL_SHADER;
+    op->opcode = WINED3D_CS_OP_SET_SHADER;
+    op->type = type;
     op->shader = shader;
 
     cs->ops->submit(cs);
@@ -759,9 +721,7 @@ static void (* const wined3d_cs_op_handlers[])(struct wined3d_cs *cs, const void
     /* WINED3D_CS_OP_SET_STREAM_SOURCE_FREQ */ wined3d_cs_exec_set_stream_source_freq,
     /* WINED3D_CS_OP_SET_INDEX_BUFFER       */ wined3d_cs_exec_set_index_buffer,
     /* WINED3D_CS_OP_SET_TEXTURE            */ wined3d_cs_exec_set_texture,
-    /* WINED3D_CS_OP_SET_VERTEX_SHADER      */ wined3d_cs_exec_set_vertex_shader,
-    /* WINED3D_CS_OP_SET_GEOMETRY_SHADER    */ wined3d_cs_exec_set_geometry_shader,
-    /* WINED3D_CS_OP_SET_PIXEL_SHADER       */ wined3d_cs_exec_set_pixel_shader,
+    /* WINED3D_CS_OP_SET_SHADER             */ wined3d_cs_exec_set_shader,
     /* WINED3D_CS_OP_SET_RENDER_STATE       */ wined3d_cs_exec_set_render_state,
     /* WINED3D_CS_OP_SET_TEXTURE_STATE      */ wined3d_cs_exec_set_texture_state,
     /* WINED3D_CS_OP_SET_SAMPLER_STATE      */ wined3d_cs_exec_set_sampler_state,
diff --git a/dlls/wined3d/device.c b/dlls/wined3d/device.c
index 20e7927..166c84b 100644
--- a/dlls/wined3d/device.c
+++ b/dlls/wined3d/device.c
@@ -2060,7 +2060,7 @@ struct wined3d_vertex_declaration * CDECL wined3d_device_get_vertex_declaration(
 
 void CDECL wined3d_device_set_vertex_shader(struct wined3d_device *device, struct wined3d_shader *shader)
 {
-    struct wined3d_shader *prev = device->update_state->vertex_shader;
+    struct wined3d_shader *prev = device->update_state->shader[WINED3D_SHADER_TYPE_VERTEX];
 
     TRACE("device %p, shader %p.\n", device, shader);
 
@@ -2072,9 +2072,9 @@ void CDECL wined3d_device_set_vertex_shader(struct wined3d_device *device, struc
 
     if (shader)
         wined3d_shader_incref(shader);
-    device->update_state->vertex_shader = shader;
+    device->update_state->shader[WINED3D_SHADER_TYPE_VERTEX] = shader;
     if (!device->recording)
-        wined3d_cs_emit_set_vertex_shader(device->cs, shader);
+        wined3d_cs_emit_set_shader(device->cs, WINED3D_SHADER_TYPE_VERTEX, shader);
     if (prev)
         wined3d_shader_decref(prev);
 }
@@ -2083,7 +2083,7 @@ struct wined3d_shader * CDECL wined3d_device_get_vertex_shader(const struct wine
 {
     TRACE("device %p.\n", device);
 
-    return device->state.vertex_shader;
+    return device->state.shader[WINED3D_SHADER_TYPE_VERTEX];
 }
 
 void CDECL wined3d_device_set_vs_cb(struct wined3d_device *device, UINT idx, struct wined3d_buffer *buffer)
@@ -2328,7 +2328,7 @@ HRESULT CDECL wined3d_device_get_vs_consts_f(const struct wined3d_device *device
 
 void CDECL wined3d_device_set_pixel_shader(struct wined3d_device *device, struct wined3d_shader *shader)
 {
-    struct wined3d_shader *prev = device->update_state->pixel_shader;
+    struct wined3d_shader *prev = device->update_state->shader[WINED3D_SHADER_TYPE_PIXEL];
 
     TRACE("device %p, shader %p.\n", device, shader);
 
@@ -2340,9 +2340,9 @@ void CDECL wined3d_device_set_pixel_shader(struct wined3d_device *device, struct
 
     if (shader)
         wined3d_shader_incref(shader);
-    device->update_state->pixel_shader = shader;
+    device->update_state->shader[WINED3D_SHADER_TYPE_PIXEL] = shader;
     if (!device->recording)
-        wined3d_cs_emit_set_pixel_shader(device->cs, shader);
+        wined3d_cs_emit_set_shader(device->cs, WINED3D_SHADER_TYPE_PIXEL, shader);
     if (prev)
         wined3d_shader_decref(prev);
 }
@@ -2351,7 +2351,7 @@ struct wined3d_shader * CDECL wined3d_device_get_pixel_shader(const struct wined
 {
     TRACE("device %p.\n", device);
 
-    return device->state.pixel_shader;
+    return device->state.shader[WINED3D_SHADER_TYPE_PIXEL];
 }
 
 void CDECL wined3d_device_set_ps_cb(struct wined3d_device *device, UINT idx, struct wined3d_buffer *buffer)
@@ -2586,7 +2586,7 @@ HRESULT CDECL wined3d_device_get_ps_consts_f(const struct wined3d_device *device
 
 void CDECL wined3d_device_set_geometry_shader(struct wined3d_device *device, struct wined3d_shader *shader)
 {
-    struct wined3d_shader *prev = device->update_state->geometry_shader;
+    struct wined3d_shader *prev = device->update_state->shader[WINED3D_SHADER_TYPE_GEOMETRY];
 
     TRACE("device %p, shader %p.\n", device, shader);
 
@@ -2594,8 +2594,8 @@ void CDECL wined3d_device_set_geometry_shader(struct wined3d_device *device, str
         return;
     if (shader)
         wined3d_shader_incref(shader);
-    device->update_state->geometry_shader = shader;
-    wined3d_cs_emit_set_geometry_shader(device->cs, shader);
+    device->update_state->shader[WINED3D_SHADER_TYPE_GEOMETRY] = shader;
+    wined3d_cs_emit_set_shader(device->cs, WINED3D_SHADER_TYPE_GEOMETRY, shader);
     if (prev)
         wined3d_shader_decref(prev);
 }
@@ -2604,7 +2604,7 @@ struct wined3d_shader * CDECL wined3d_device_get_geometry_shader(const struct wi
 {
     TRACE("device %p.\n", device);
 
-    return device->state.geometry_shader;
+    return device->state.shader[WINED3D_SHADER_TYPE_GEOMETRY];
 }
 
 void CDECL wined3d_device_set_gs_cb(struct wined3d_device *device, UINT idx, struct wined3d_buffer *buffer)
@@ -2984,10 +2984,10 @@ HRESULT CDECL wined3d_device_process_vertices(struct wined3d_device *device,
     context = context_acquire(device, NULL);
     gl_info = context->gl_info;
 
-    vs = state->vertex_shader;
-    state->vertex_shader = NULL;
+    vs = state->shader[WINED3D_SHADER_TYPE_VERTEX];
+    state->shader[WINED3D_SHADER_TYPE_VERTEX] = NULL;
     context_stream_info_from_declaration(context, state, &stream_info);
-    state->vertex_shader = vs;
+    state->shader[WINED3D_SHADER_TYPE_VERTEX] = vs;
 
     /* We can't convert FROM a VBO, and vertex buffers used to source into
      * process_vertices() are unlikely to ever be used for drawing. Release
diff --git a/dlls/wined3d/glsl_shader.c b/dlls/wined3d/glsl_shader.c
index 3e2a7a7..69f6dff 100644
--- a/dlls/wined3d/glsl_shader.c
+++ b/dlls/wined3d/glsl_shader.c
@@ -761,8 +761,8 @@ static void shader_glsl_load_constants(void *shader_priv, struct wined3d_context
         const struct wined3d_state *state)
 {
     const struct glsl_context_data *ctx_data = context->shader_backend_data;
-    const struct wined3d_shader *vshader = state->vertex_shader;
-    const struct wined3d_shader *pshader = state->pixel_shader;
+    const struct wined3d_shader *vshader = state->shader[WINED3D_SHADER_TYPE_VERTEX];
+    const struct wined3d_shader *pshader = state->shader[WINED3D_SHADER_TYPE_PIXEL];
     const struct wined3d_gl_info *gl_info = context->gl_info;
     struct shader_glsl_priv *priv = shader_priv;
     float position_fixup[4];
@@ -5791,8 +5791,8 @@ static void set_glsl_shader_program(const struct wined3d_context *context, const
 
         if (use_vs(state))
         {
-            vshader = state->vertex_shader;
-            gshader = state->geometry_shader;
+            vshader = state->shader[WINED3D_SHADER_TYPE_VERTEX];
+            gshader = state->shader[WINED3D_SHADER_TYPE_GEOMETRY];
 
             if (!(context->shader_update_mask & (1 << WINED3D_SHADER_TYPE_GEOMETRY))
                     && ctx_data->glsl_program->gs.id)
@@ -5804,13 +5804,13 @@ static void set_glsl_shader_program(const struct wined3d_context *context, const
     else if (use_vs(state))
     {
         struct vs_compile_args vs_compile_args;
-        vshader = state->vertex_shader;
+        vshader = state->shader[WINED3D_SHADER_TYPE_VERTEX];
 
         find_vs_compile_args(state, vshader, context->stream_info.swizzle_map, &vs_compile_args);
         vs_id = find_glsl_vshader(context, &priv->shader_buffer, vshader, &vs_compile_args);
         vs_list = &vshader->linked_programs;
 
-        if ((gshader = state->geometry_shader))
+        if ((gshader = state->shader[WINED3D_SHADER_TYPE_GEOMETRY]))
             gs_id = find_glsl_geometry_shader(context, &priv->shader_buffer, gshader);
     }
     else if (priv->vertex_pipe == &glsl_vertex_pipe)
@@ -5830,12 +5830,12 @@ static void set_glsl_shader_program(const struct wined3d_context *context, const
         ps_list = &ctx_data->glsl_program->ps.shader_entry;
 
         if (use_ps(state))
-            pshader = state->pixel_shader;
+            pshader = state->shader[WINED3D_SHADER_TYPE_PIXEL];
     }
     else if (use_ps(state))
     {
         struct ps_compile_args ps_compile_args;
-        pshader = state->pixel_shader;
+        pshader = state->shader[WINED3D_SHADER_TYPE_PIXEL];
         find_ps_compile_args(state, pshader, context->stream_info.position_transformed, &ps_compile_args, gl_info);
         ps_id = find_glsl_pshader(context, &priv->shader_buffer,
                 pshader, &ps_compile_args, &np2fixup_info);
diff --git a/dlls/wined3d/shader.c b/dlls/wined3d/shader.c
index fee9c77..3a1fc12 100644
--- a/dlls/wined3d/shader.c
+++ b/dlls/wined3d/shader.c
@@ -2057,7 +2057,7 @@ void find_ps_compile_args(const struct wined3d_state *state, const struct wined3
             {
                 DWORD tex_transform = flags & ~WINED3D_TTFF_PROJECTED;
 
-                if (!state->vertex_shader)
+                if (!state->shader[WINED3D_SHADER_TYPE_VERTEX])
                 {
                     unsigned int j;
                     unsigned int index = state->texture_states[i][WINED3D_TSS_TEXCOORD_INDEX];
diff --git a/dlls/wined3d/state.c b/dlls/wined3d/state.c
index 4011f11..3c03953 100644
--- a/dlls/wined3d/state.c
+++ b/dlls/wined3d/state.c
@@ -4075,7 +4075,7 @@ static void load_numbered_arrays(struct wined3d_context *context,
         {
             if (context->numbered_array_mask & (1 << i))
                 unload_numbered_array(context, i);
-            if (state->vertex_shader->reg_maps.input_registers & (1 << i))
+            if (state->shader[WINED3D_SHADER_TYPE_VERTEX]->reg_maps.input_registers & (1 << i))
                 GL_EXTCALL(glVertexAttrib4fARB(i, 0.0f, 0.0f, 0.0f, 0.0f));
             continue;
         }
@@ -4632,8 +4632,8 @@ void vertexdeclaration(struct wined3d_context *context, const struct wined3d_sta
                 transform_texture(context, state, STATE_TEXTURESTAGE(i, WINED3D_TSS_TEXTURE_TRANSFORM_FLAGS));
         }
 
-        if (use_ps(state) && state->pixel_shader->reg_maps.shader_version.major == 1
-                && state->pixel_shader->reg_maps.shader_version.minor <= 3)
+        if (use_ps(state) && state->shader[WINED3D_SHADER_TYPE_PIXEL]->reg_maps.shader_version.major == 1
+                && state->shader[WINED3D_SHADER_TYPE_PIXEL]->reg_maps.shader_version.minor <= 3)
             context->shader_update_mask |= 1 << WINED3D_SHADER_TYPE_PIXEL;
     }
 
diff --git a/dlls/wined3d/stateblock.c b/dlls/wined3d/stateblock.c
index b086d61..b2aacb3 100644
--- a/dlls/wined3d/stateblock.c
+++ b/dlls/wined3d/stateblock.c
@@ -504,10 +504,13 @@ void state_unbind_resources(struct wined3d_state *state)
         wined3d_buffer_decref(buffer);
     }
 
-    if ((shader = state->vertex_shader))
+    for (i = 0; i < WINED3D_SHADER_TYPE_COUNT; ++i)
     {
-        state->vertex_shader = NULL;
-        wined3d_shader_decref(shader);
+        if ((shader = state->shader[i]))
+        {
+            state->shader[i] = NULL;
+            wined3d_shader_decref(shader);
+        }
     }
 
     for (i = 0; i < MAX_CONSTANT_BUFFERS; ++i)
@@ -528,12 +531,6 @@ void state_unbind_resources(struct wined3d_state *state)
         }
     }
 
-    if ((shader = state->geometry_shader))
-    {
-        state->geometry_shader = NULL;
-        wined3d_shader_decref(shader);
-    }
-
     for (i = 0; i < MAX_CONSTANT_BUFFERS; ++i)
     {
         if ((buffer = state->gs_cb[i]))
@@ -552,12 +549,6 @@ void state_unbind_resources(struct wined3d_state *state)
         }
     }
 
-    if ((shader = state->pixel_shader))
-    {
-        state->pixel_shader = NULL;
-        wined3d_shader_decref(shader);
-    }
-
     for (i = 0; i < MAX_SAMPLER_OBJECTS; ++i)
     {
         if ((sampler = state->ps_sampler[i]))
@@ -686,16 +677,18 @@ void CDECL wined3d_stateblock_capture(struct wined3d_stateblock *stateblock)
 
     TRACE("Capturing state %p.\n", src_state);
 
-    if (stateblock->changed.vertexShader && stateblock->state.vertex_shader != src_state->vertex_shader)
+    if (stateblock->changed.vertexShader && stateblock->state.shader[WINED3D_SHADER_TYPE_VERTEX]
+            != src_state->shader[WINED3D_SHADER_TYPE_VERTEX])
     {
         TRACE("Updating vertex shader from %p to %p\n",
-                stateblock->state.vertex_shader, src_state->vertex_shader);
+                stateblock->state.shader[WINED3D_SHADER_TYPE_VERTEX],
+                src_state->shader[WINED3D_SHADER_TYPE_VERTEX]);
 
-        if (src_state->vertex_shader)
-            wined3d_shader_incref(src_state->vertex_shader);
-        if (stateblock->state.vertex_shader)
-            wined3d_shader_decref(stateblock->state.vertex_shader);
-        stateblock->state.vertex_shader = src_state->vertex_shader;
+        if (src_state->shader[WINED3D_SHADER_TYPE_VERTEX])
+            wined3d_shader_incref(src_state->shader[WINED3D_SHADER_TYPE_VERTEX]);
+        if (stateblock->state.shader[WINED3D_SHADER_TYPE_VERTEX])
+            wined3d_shader_decref(stateblock->state.shader[WINED3D_SHADER_TYPE_VERTEX]);
+        stateblock->state.shader[WINED3D_SHADER_TYPE_VERTEX] = src_state->shader[WINED3D_SHADER_TYPE_VERTEX];
     }
 
     /* Vertex shader float constants. */
@@ -950,13 +943,14 @@ void CDECL wined3d_stateblock_capture(struct wined3d_stateblock *stateblock)
         stateblock->state.sampler_states[stage][state] = src_state->sampler_states[stage][state];
     }
 
-    if (stateblock->changed.pixelShader && stateblock->state.pixel_shader != src_state->pixel_shader)
+    if (stateblock->changed.pixelShader && stateblock->state.shader[WINED3D_SHADER_TYPE_PIXEL]
+            != src_state->shader[WINED3D_SHADER_TYPE_PIXEL])
     {
-        if (src_state->pixel_shader)
-            wined3d_shader_incref(src_state->pixel_shader);
-        if (stateblock->state.pixel_shader)
-            wined3d_shader_decref(stateblock->state.pixel_shader);
-        stateblock->state.pixel_shader = src_state->pixel_shader;
+        if (src_state->shader[WINED3D_SHADER_TYPE_PIXEL])
+            wined3d_shader_incref(src_state->shader[WINED3D_SHADER_TYPE_PIXEL]);
+        if (stateblock->state.shader[WINED3D_SHADER_TYPE_PIXEL])
+            wined3d_shader_decref(stateblock->state.shader[WINED3D_SHADER_TYPE_PIXEL]);
+        stateblock->state.shader[WINED3D_SHADER_TYPE_PIXEL] = src_state->shader[WINED3D_SHADER_TYPE_PIXEL];
     }
 
     wined3d_state_record_lights(&stateblock->state, src_state);
@@ -991,7 +985,7 @@ void CDECL wined3d_stateblock_apply(const struct wined3d_stateblock *stateblock)
     TRACE("Applying stateblock %p to device %p.\n", stateblock, device);
 
     if (stateblock->changed.vertexShader)
-        wined3d_device_set_vertex_shader(device, stateblock->state.vertex_shader);
+        wined3d_device_set_vertex_shader(device, stateblock->state.shader[WINED3D_SHADER_TYPE_VERTEX]);
 
     /* Vertex Shader Constants. */
     for (i = 0; i < stateblock->num_contained_vs_consts_f; ++i)
@@ -1013,7 +1007,7 @@ void CDECL wined3d_stateblock_apply(const struct wined3d_stateblock *stateblock)
     apply_lights(device, &stateblock->state);
 
     if (stateblock->changed.pixelShader)
-        wined3d_device_set_pixel_shader(device, stateblock->state.pixel_shader);
+        wined3d_device_set_pixel_shader(device, stateblock->state.shader[WINED3D_SHADER_TYPE_PIXEL]);
 
     /* Pixel Shader Constants. */
     for (i = 0; i < stateblock->num_contained_ps_consts_f; ++i)
diff --git a/dlls/wined3d/wined3d_private.h b/dlls/wined3d/wined3d_private.h
index 14cc378..60dce76 100644
--- a/dlls/wined3d/wined3d_private.h
+++ b/dlls/wined3d/wined3d_private.h
@@ -1817,18 +1817,17 @@ struct wined3d_state
     INT load_base_vertex_index; /* Non-indexed drawing needs 0 here, indexed needs base_vertex_index. */
     GLenum gl_primitive_type;
 
-    struct wined3d_shader *vertex_shader;
+    struct wined3d_shader *shader[WINED3D_SHADER_TYPE_COUNT];
+
     struct wined3d_buffer *vs_cb[MAX_CONSTANT_BUFFERS];
     struct wined3d_sampler *vs_sampler[MAX_SAMPLER_OBJECTS];
     BOOL vs_consts_b[MAX_CONST_B];
     INT vs_consts_i[MAX_CONST_I * 4];
     float *vs_consts_f;
 
-    struct wined3d_shader *geometry_shader;
     struct wined3d_buffer *gs_cb[MAX_CONSTANT_BUFFERS];
     struct wined3d_sampler *gs_sampler[MAX_SAMPLER_OBJECTS];
 
-    struct wined3d_shader *pixel_shader;
     struct wined3d_buffer *ps_cb[MAX_CONSTANT_BUFFERS];
     struct wined3d_sampler *ps_sampler[MAX_SAMPLER_OBJECTS];
     BOOL ps_consts_b[MAX_CONST_B];
@@ -2482,11 +2481,9 @@ void wined3d_cs_emit_present(struct wined3d_cs *cs, struct wined3d_swapchain *sw
 void wined3d_cs_emit_set_clip_plane(struct wined3d_cs *cs, UINT plane_idx,
         const struct wined3d_vec4 *plane) DECLSPEC_HIDDEN;
 void wined3d_cs_emit_set_depth_stencil(struct wined3d_cs *cs, struct wined3d_surface *depth_stencil) DECLSPEC_HIDDEN;
-void wined3d_cs_emit_set_geometry_shader(struct wined3d_cs *cs, struct wined3d_shader *shader) DECLSPEC_HIDDEN;
 void wined3d_cs_emit_set_index_buffer(struct wined3d_cs *cs, struct wined3d_buffer *buffer,
         enum wined3d_format_id format_id) DECLSPEC_HIDDEN;
 void wined3d_cs_emit_set_material(struct wined3d_cs *cs, const struct wined3d_material *material) DECLSPEC_HIDDEN;
-void wined3d_cs_emit_set_pixel_shader(struct wined3d_cs *cs, struct wined3d_shader *shader) DECLSPEC_HIDDEN;
 void wined3d_cs_emit_set_render_state(struct wined3d_cs *cs,
         enum wined3d_render_state state, DWORD value) DECLSPEC_HIDDEN;
 void wined3d_cs_emit_set_render_target(struct wined3d_cs *cs, UINT render_target_idx,
@@ -2494,6 +2491,8 @@ void wined3d_cs_emit_set_render_target(struct wined3d_cs *cs, UINT render_target
 void wined3d_cs_emit_set_sampler_state(struct wined3d_cs *cs, UINT sampler_idx,
         enum wined3d_sampler_state state, DWORD value) DECLSPEC_HIDDEN;
 void wined3d_cs_emit_set_scissor_rect(struct wined3d_cs *cs, const RECT *rect) DECLSPEC_HIDDEN;
+void wined3d_cs_emit_set_shader(struct wined3d_cs *cs, enum wined3d_shader_type type,
+        struct wined3d_shader *shader) DECLSPEC_HIDDEN;
 void wined3d_cs_emit_set_stream_source(struct wined3d_cs *cs, UINT stream_idx,
         struct wined3d_buffer *buffer, UINT offset, UINT stride) DECLSPEC_HIDDEN;
 void wined3d_cs_emit_set_stream_source_freq(struct wined3d_cs *cs, UINT stream_idx,
@@ -2505,7 +2504,6 @@ void wined3d_cs_emit_set_transform(struct wined3d_cs *cs, enum wined3d_transform
         const struct wined3d_matrix *matrix) DECLSPEC_HIDDEN;
 void wined3d_cs_emit_set_vertex_declaration(struct wined3d_cs *cs,
         struct wined3d_vertex_declaration *declaration) DECLSPEC_HIDDEN;
-void wined3d_cs_emit_set_vertex_shader(struct wined3d_cs *cs, struct wined3d_shader *shader) DECLSPEC_HIDDEN;
 void wined3d_cs_emit_set_viewport(struct wined3d_cs *cs, const struct wined3d_viewport *viewport) DECLSPEC_HIDDEN;
 
 /* Direct3D terminology with little modifications. We do not have an issued state
@@ -3043,12 +3041,12 @@ static inline BOOL use_vs(const struct wined3d_state *state)
 {
     /* Check state->vertex_declaration to allow this to be used before the
      * stream info is validated, for example in device_update_tex_unit_map(). */
-    return state->vertex_shader && !state->vertex_declaration->position_transformed;
+    return state->shader[WINED3D_SHADER_TYPE_VERTEX] && !state->vertex_declaration->position_transformed;
 }
 
 static inline BOOL use_ps(const struct wined3d_state *state)
 {
-    return !!state->pixel_shader;
+    return !!state->shader[WINED3D_SHADER_TYPE_PIXEL];
 }
 
 static inline void context_apply_state(struct wined3d_context *context,
-- 
1.7.10.4




More information about the wine-patches mailing list