Switch fragment/vertex shaders to the new caching semantics.
authorZack Rusin <zack@tungstengraphics.com>
Thu, 20 Sep 2007 11:50:33 +0000 (07:50 -0400)
committerZack Rusin <zack@tungstengraphics.com>
Thu, 20 Sep 2007 11:50:33 +0000 (07:50 -0400)
Allow driver custom allocation within cached objects. The shaders
are currently twiced (by cso layer and by the program itself).

18 files changed:
src/mesa/pipe/cso_cache/cso_cache.h
src/mesa/pipe/failover/fo_context.h
src/mesa/pipe/failover/fo_state.c
src/mesa/pipe/failover/fo_state_emit.c
src/mesa/pipe/i915simple/i915_state.c
src/mesa/pipe/p_context.h
src/mesa/pipe/softpipe/sp_state.h
src/mesa/pipe/softpipe/sp_state_fs.c
src/mesa/state_tracker/st_atom_fs.c
src/mesa/state_tracker/st_atom_vs.c
src/mesa/state_tracker/st_cache.c
src/mesa/state_tracker/st_cache.h
src/mesa/state_tracker/st_cb_clear.c
src/mesa/state_tracker/st_cb_drawpixels.c
src/mesa/state_tracker/st_cb_rasterpos.c
src/mesa/state_tracker/st_context.h
src/mesa/state_tracker/st_draw.c
src/mesa/state_tracker/st_program.h

index cd4b64eec4fa4e8c6f1d37e2cb2d7a598b18815f..57d162b2acc0a303091922fe0a951005e30bc359 100644 (file)
@@ -58,6 +58,16 @@ struct cso_rasterizer {
    void *data;
 };
 
+struct cso_fragment_shader {
+   struct pipe_shader_state state;
+   void *data;
+};
+
+struct cso_vertex_shader {
+   struct pipe_shader_state state;
+   void *data;
+};
+
 enum cso_cache_type {
    CSO_BLEND,
    CSO_SAMPLER,
index a649899010f821a7f9ba3a99106c76c7bf1f1b1c..a81bfe82ddba67fd6c3b41b22af175bf626dccbc 100644 (file)
@@ -74,8 +74,8 @@ struct failover_context {
    const struct pipe_sampler_state       *sampler[PIPE_MAX_SAMPLERS];
    const struct pipe_depth_stencil_state *depth_stencil;
    const struct fo_state                 *rasterizer;
-   const struct pipe_shader_state        *fragment_shader;
-   const struct pipe_shader_state        *vertex_shader;
+   const struct fo_state                 *fragment_shader;
+   const struct fo_state                 *vertex_shader;
 
    struct pipe_alpha_test_state alpha_test;
    struct pipe_blend_color blend_color;
index 25725625e009798493b682bd031f599067c2fe40..db3aea775655ca5d1e6fc6f83bc4703e525500b7 100644 (file)
@@ -150,26 +150,81 @@ failover_set_framebuffer_state(struct pipe_context *pipe,
    failover->hw->set_framebuffer_state( failover->hw, framebuffer );
 }
 
+
+static void *
+failover_create_fs_state(struct pipe_context *pipe,
+                         const struct pipe_shader_state *templ)
+{
+   struct fo_state *state = malloc(sizeof(struct fo_state));
+   struct failover_context *failover = failover_context(pipe);
+
+   state->sw_state = failover->sw->create_fs_state(pipe, templ);
+   state->hw_state = failover->hw->create_fs_state(pipe, templ);
+
+   return state;
+}
+
 static void
 failover_bind_fs_state(struct pipe_context *pipe,
-                       const struct pipe_shader_state *fs)
+                       void *fs)
 {
    struct failover_context *failover = failover_context(pipe);
 
-   failover->fragment_shader = fs;
+   failover->fragment_shader = (struct fo_state *)fs;
    failover->dirty |= FO_NEW_FRAGMENT_SHADER;
-   failover->hw->bind_fs_state( failover->hw, fs );
+   failover->hw->bind_fs_state(failover->hw, (struct pipe_shader_state *)fs);
+}
+
+static void
+failover_delete_fs_state(struct pipe_context *pipe,
+                         void *fs)
+{
+   struct fo_state *state = (struct fo_state*)fs;
+   struct failover_context *failover = failover_context(pipe);
+
+   failover->sw->delete_fs_state(pipe, state->sw_state);
+   failover->hw->delete_fs_state(pipe, state->hw_state);
+   state->sw_state = 0;
+   state->hw_state = 0;
+   free(state);
+}
+
+static void *
+failover_create_vs_state(struct pipe_context *pipe,
+                         const struct pipe_shader_state *templ)
+{
+   struct fo_state *state = malloc(sizeof(struct fo_state));
+   struct failover_context *failover = failover_context(pipe);
+
+   state->sw_state = failover->sw->create_vs_state(pipe, templ);
+   state->hw_state = failover->hw->create_vs_state(pipe, templ);
+
+   return state;
 }
 
 static void
 failover_bind_vs_state(struct pipe_context *pipe,
-                     const struct pipe_shader_state *vs)
+                       void *vs)
 {
    struct failover_context *failover = failover_context(pipe);
 
-   failover->vertex_shader = vs;
+   failover->vertex_shader = (struct fo_state*)vs;
    failover->dirty |= FO_NEW_VERTEX_SHADER;
-   failover->hw->bind_vs_state( failover->hw, vs );
+   failover->hw->bind_vs_state(failover->hw, vs);
+}
+
+static void
+failover_delete_vs_state(struct pipe_context *pipe,
+                         void *vs)
+{
+   struct fo_state *state = (struct fo_state*)vs;
+   struct failover_context *failover = failover_context(pipe);
+
+   failover->sw->delete_vs_state(pipe, state->sw_state);
+   failover->hw->delete_vs_state(pipe, state->hw_state);
+   state->sw_state = 0;
+   state->hw_state = 0;
+   free(state);
 }
 
 static void 
@@ -312,8 +367,12 @@ failover_init_state_functions( struct failover_context *failover )
    failover->pipe.create_rasterizer_state = failover_create_rasterizer_state;
    failover->pipe.bind_rasterizer_state = failover_bind_rasterizer_state;
    failover->pipe.delete_rasterizer_state = failover_delete_rasterizer_state;
-   failover->pipe.bind_fs_state = failover_bind_fs_state;
-   failover->pipe.bind_vs_state = failover_bind_vs_state;
+   failover->pipe.create_fs_state = failover_create_fs_state;
+   failover->pipe.bind_fs_state   = failover_bind_fs_state;
+   failover->pipe.delete_fs_state = failover_delete_fs_state;
+   failover->pipe.create_vs_state = failover_create_vs_state;
+   failover->pipe.bind_vs_state   = failover_bind_vs_state;
+   failover->pipe.delete_vs_state = failover_delete_vs_state;
 
    failover->pipe.set_alpha_test_state = failover_set_alpha_test_state;
    failover->pipe.set_blend_color = failover_set_blend_color;
index f2b0b1edc0ed0e457846be469815e825a955d881..ec896fd02046bd09fa0a718e218ca9def2e3ef72 100644 (file)
@@ -78,10 +78,12 @@ failover_state_emit( struct failover_context *failover )
       failover->sw->set_framebuffer_state( failover->sw, &failover->framebuffer );
 
    if (failover->dirty & FO_NEW_FRAGMENT_SHADER)
-      failover->sw->bind_fs_state( failover->sw, failover->fragment_shader );
+      failover->sw->bind_fs_state( failover->sw,
+                                   failover->fragment_shader->sw_state );
 
    if (failover->dirty & FO_NEW_VERTEX_SHADER)
-      failover->sw->bind_vs_state( failover->sw, failover->vertex_shader );
+      failover->sw->bind_vs_state( failover->sw,
+                                   failover->vertex_shader->sw_state );
 
    if (failover->dirty & FO_NEW_STIPPLE)
       failover->sw->set_polygon_stipple( failover->sw, &failover->poly_stipple );
index 66aa9a0274b8b0d88b859855ff9fb15dbd481fda..1104c9519db9acec5be66fd57b6b356511fe4ac9 100644 (file)
@@ -228,41 +228,37 @@ static void i915_set_polygon_stipple( struct pipe_context *pipe,
 }
 
 
-static const struct pipe_shader_state *
-i915_create_shader_state( struct pipe_context *pipe,
-                          const struct pipe_shader_state *templ )
+static void *
+i915_create_shader_state(struct pipe_context *pipe,
+                         const struct pipe_shader_state *templ)
 {
-
-   struct pipe_shader_state *shader = malloc(sizeof(struct pipe_shader_state));
-   memcpy(shader, templ, sizeof(struct pipe_shader_state));
-
-   return shader;
+   return 0;
 }
 
 static void i915_bind_fs_state( struct pipe_context *pipe,
-                               const struct pipe_shader_state *fs )
+                               void *fs )
 {
    struct i915_context *i915 = i915_context(pipe);
 
-   i915->fs = fs;
+   i915->fs = (struct pipe_shader_state *)fs;
 
    i915->dirty |= I915_NEW_FS;
 }
 
 
-static void i915_bind_vs_state( struct pipe_context *pipe,
-                               const struct pipe_shader_state *vs )
+static void i915_bind_vs_state(struct pipe_context *pipe,
+                               void *vs)
 {
    struct i915_context *i915 = i915_context(pipe);
 
    /* just pass-through to draw module */
-   draw_set_vertex_shader(i915->draw, vs);
+   draw_set_vertex_shader(i915->draw, (const struct pipe_shader_state *)vs);
 }
 
-static void i915_delete_shader_state( struct pipe_context *pipe,
-                                      const struct pipe_shader_state *shader )
+static void i915_delete_shader_state(struct pipe_context *pipe,
+                                     void *shader)
 {
-   free((struct pipe_shader_state*)shader);
+   /*do nothing*/
 }
 
 static void i915_set_constant_buffer(struct pipe_context *pipe,
index 65001dfdf95f15b1789988f627397e2762044334..e17faad2c73ac2b14ebdc1685b3e4f72ef52840a 100644 (file)
@@ -113,20 +113,15 @@ struct pipe_context {
    void (*delete_depth_stencil_state)(struct pipe_context *,
                                       const struct pipe_depth_stencil_state *);
 
-   const struct pipe_shader_state * (*create_fs_state)(
-      struct pipe_context *,
-      const struct pipe_shader_state *);
-   void (*bind_fs_state)(struct pipe_context *,
-                         const struct pipe_shader_state *);
-   void (*delete_fs_state)(struct pipe_context *,
-                           const struct pipe_shader_state *);
-   const struct pipe_shader_state * (*create_vs_state)(
-      struct pipe_context *,
-      const struct pipe_shader_state *);
-   void (*bind_vs_state)(struct pipe_context *,
-                         const struct pipe_shader_state *);
-   void (*delete_vs_state)(struct pipe_context *,
-                           const struct pipe_shader_state *);
+   void * (*create_fs_state)(struct pipe_context *,
+                             const struct pipe_shader_state *);
+   void   (*bind_fs_state)(struct pipe_context *, void *);
+   void   (*delete_fs_state)(struct pipe_context *, void *);
+
+   void * (*create_vs_state)(struct pipe_context *,
+                             const struct pipe_shader_state *);
+   void   (*bind_vs_state)(struct pipe_context *, void *);
+   void   (*delete_vs_state)(struct pipe_context *, void *);
 
    void (*set_alpha_test_state)( struct pipe_context *,
                                  const struct pipe_alpha_test_state * );
index a20ae1d4a229851afcb5454fc4348c6772a32a89..5ed963c21dea74821eb83987a82dfa8594f0197d 100644 (file)
@@ -88,15 +88,12 @@ void softpipe_set_constant_buffer(struct pipe_context *,
 void softpipe_set_feedback_state( struct pipe_context *,
                                   const struct pipe_feedback_state * );
 
-const struct pipe_shader_state *
+void *
 softpipe_create_shader_state( struct pipe_context *,
                               const struct pipe_shader_state * );
-void softpipe_bind_fs_state( struct pipe_context *,
-                             const struct pipe_shader_state * );
-void softpipe_bind_vs_state( struct pipe_context *,
-                             const struct pipe_shader_state * );
-void softpipe_delete_shader_state( struct pipe_context *,
-                                   const struct pipe_shader_state * );
+void softpipe_bind_fs_state( struct pipe_context *, void * );
+void softpipe_bind_vs_state( struct pipe_context *, void * );
+void softpipe_delete_shader_state( struct pipe_context *, void * );
 
 void softpipe_set_polygon_stipple( struct pipe_context *,
                                  const struct pipe_poly_stipple * );
index fbbde2f52014de5848e9145af7c17d8e4ce046d3..8306a95f449560397b994a7dd6e9e8b476e99c7b 100644 (file)
 #include "pipe/draw/draw_context.h"
 
 
-const struct pipe_shader_state *
-softpipe_create_shader_state( struct pipe_context *pipe,
-                              const struct pipe_shader_state *templ )
+void * softpipe_create_shader_state(struct pipe_context *pipe,
+                                    const struct pipe_shader_state *templ)
 {
-   struct pipe_shader_state *shader = malloc(sizeof(struct pipe_shader_state));
-   memcpy(shader, templ, sizeof(struct pipe_shader_state));
-
-   return shader;
+   /* we just want the pipe_shader_state template in the bind calls */
+   return 0;
 }
 
-void softpipe_bind_fs_state( struct pipe_context *pipe,
-                            const struct pipe_shader_state *fs )
+void softpipe_bind_fs_state(struct pipe_context *pipe, void *fs)
 {
    struct softpipe_context *softpipe = softpipe_context(pipe);
 
-   softpipe->fs = fs;
+   softpipe->fs = (struct pipe_shader_state *)fs;
 
    softpipe->dirty |= SP_NEW_FS;
 }
 
 
-void softpipe_bind_vs_state( struct pipe_context *pipe,
-                            const struct pipe_shader_state *vs )
+void softpipe_bind_vs_state(struct pipe_context *pipe, void *vs)
 {
    struct softpipe_context *softpipe = softpipe_context(pipe);
 
-   softpipe->vs = vs;
+   softpipe->vs = (struct pipe_shader_state *)vs;
 
    softpipe->dirty |= SP_NEW_VS;
 
-   draw_set_vertex_shader(softpipe->draw, vs);
+   draw_set_vertex_shader(softpipe->draw, (struct pipe_shader_state *)vs);
 }
 
 
 void softpipe_delete_shader_state( struct pipe_context *pipe,
-                                   const struct pipe_shader_state *shader )
+                                   void *shader )
 {
-   free((struct pipe_shader_state*)shader);
+   /* do nothing */
 }
 
 void softpipe_set_constant_buffer(struct pipe_context *pipe,
index 94b69c8df7d37ee91b98242afd2db8ee790cdbbb..91e58f58316ad2d737ae7f5bb8816de268df4b66 100644 (file)
  * Translate a Mesa fragment shader into a TGSI shader.
  * \return  pointer to cached pipe_shader object.
  */
-struct pipe_shader_state *
+const struct cso_fragment_shader *
 st_translate_fragment_shader(struct st_context *st,
                            struct st_fragment_program *stfp)
 {
    GLuint outputMapping[FRAG_RESULT_MAX];
    GLuint inputMapping[PIPE_MAX_SHADER_INPUTS];
    struct pipe_shader_state fs;
-   struct pipe_shader_state *cached;
+   const struct cso_fragment_shader *cso;
    GLuint interpMode[16];  /* XXX size? */
    GLuint i;
    GLbitfield inputsRead = stfp->Base.Base.InputsRead;
@@ -142,15 +142,15 @@ st_translate_fragment_shader(struct st_context *st,
 
    fs.tokens = &stfp->tokens[0];
 
-   cached = st_cached_fs_state(st, &fs);
-   stfp->fs = cached;
+   cso = st_cached_fs_state(st, &fs);
+   stfp->fs = cso;
 
    if (TGSI_DEBUG)
       tgsi_dump( stfp->tokens, 0/*TGSI_DUMP_VERBOSE*/ );
 
    stfp->dirty = 0;
 
-   return cached;
+   return cso;
 }
 
 
@@ -183,7 +183,7 @@ static void update_fs( struct st_context *st )
       if (stfp->dirty)
         st->state.fs = st_translate_fragment_shader( st, st->fp );
 
-      st->pipe->bind_fs_state(st->pipe, st->state.fs);
+      st->pipe->bind_fs_state(st->pipe, st->state.fs->data);
    }
 }
 
index cf9dd810e91dfbdb639cbc414bb0725260b9a46c..078c052ae29f30f789a02a7eca55b3a2a77ff7db 100644 (file)
  * Translate a Mesa vertex shader into a TGSI shader.
  * \return  pointer to cached pipe_shader object.
  */
-struct pipe_shader_state *
+const struct cso_vertex_shader *
 st_translate_vertex_shader(struct st_context *st,
                            struct st_vertex_program *stvp)
 {
    GLuint outputMapping[PIPE_MAX_SHADER_INPUTS];
    struct pipe_shader_state vs;
-   struct pipe_shader_state *cached;
+   const struct cso_vertex_shader *cso;
    GLuint i;
 
    memset(&vs, 0, sizeof(vs));
@@ -147,8 +147,8 @@ st_translate_vertex_shader(struct st_context *st,
 
    vs.tokens = &stvp->tokens[0];
 
-   cached = st_cached_vs_state(st, &vs);
-   stvp->vs = cached;
+   cso = st_cached_vs_state(st, &vs);
+   stvp->vs = cso;
 
    if (TGSI_DEBUG)
       tgsi_dump( stvp->tokens, 0 );
@@ -157,13 +157,13 @@ st_translate_vertex_shader(struct st_context *st,
    if (stvp->sse2_program.csr == stvp->sse2_program.store)
       tgsi_emit_sse2( stvp->tokens, &stvp->sse2_program );
 
-   if (!cached->executable)
-      cached->executable = (void *) x86_get_func( &stvp->sse2_program );
+   if (!cso->state.executable)
+      cso->state.executable = (void *) x86_get_func( &stvp->sse2_program );
 #endif
 
    stvp->dirty = 0;
 
-   return cached;
+   return cso;
 }
 
 
@@ -191,10 +191,10 @@ static void update_vs( struct st_context *st )
       /* Bind the vertex program */
       st->vp = stvp;
 
-      if (stvp->dirty) 
+      if (stvp->dirty)
         st->state.vs = st_translate_vertex_shader( st, st->vp );
 
-      st->pipe->bind_vs_state(st->pipe, st->state.vs);
+      st->pipe->bind_vs_state(st->pipe, st->state.vs->data);
    }
 }
 
index 0f233cea588a271d2d59a968f458d238ea06da21..e5ba0592cfbeaa6a5afecdb4b14c0269a8cbe5ea 100644 (file)
@@ -115,9 +115,9 @@ const struct cso_rasterizer* st_cached_rasterizer_state(
    return (struct cso_rasterizer*)(cso_hash_iter_data(iter));
 }
 
-struct pipe_shader_state * st_cached_fs_state(
-   struct st_context *st,
-   const struct pipe_shader_state *templ)
+const struct cso_fragment_shader *
+st_cached_fs_state(struct st_context *st,
+                   const struct pipe_shader_state *templ)
 {
    unsigned hash_key = cso_construct_key((void*)templ,
                                          sizeof(struct pipe_shader_state));
@@ -125,17 +125,19 @@ struct pipe_shader_state * st_cached_fs_state(
                                                        hash_key, CSO_FRAGMENT_SHADER,
                                                        (void*)templ);
    if (cso_hash_iter_is_null(iter)) {
-      const struct pipe_shader_state *created_state =
-         st->pipe->create_fs_state(st->pipe, templ);
-      iter = cso_insert_state(st->cache, hash_key, CSO_FRAGMENT_SHADER,
-                              (void*)created_state);
+      struct cso_fragment_shader *cso = malloc(sizeof(struct cso_fragment_shader));
+      memcpy(&cso->state, templ, sizeof(struct pipe_shader_state));
+      cso->data = st->pipe->create_fs_state(st->pipe, templ);
+      if (!cso->data)
+         cso->data = &cso->state;
+      iter = cso_insert_state(st->cache, hash_key, CSO_FRAGMENT_SHADER, cso);
    }
-   return (struct pipe_shader_state*)(cso_hash_iter_data(iter));
+   return (struct cso_fragment_shader*)(cso_hash_iter_data(iter));
 }
 
-struct pipe_shader_state * st_cached_vs_state(
-   struct st_context *st,
-   const struct pipe_shader_state *templ)
+const struct cso_vertex_shader *
+st_cached_vs_state(struct st_context *st,
+                   const struct pipe_shader_state *templ)
 {
    unsigned hash_key = cso_construct_key((void*)templ,
                                          sizeof(struct pipe_shader_state));
@@ -143,10 +145,12 @@ struct pipe_shader_state * st_cached_vs_state(
                                                        hash_key, CSO_VERTEX_SHADER,
                                                        (void*)templ);
    if (cso_hash_iter_is_null(iter)) {
-      const struct pipe_shader_state *created_state =
-         st->pipe->create_vs_state(st->pipe, templ);
-      iter = cso_insert_state(st->cache, hash_key, CSO_VERTEX_SHADER,
-                              (void*)created_state);
+      struct cso_vertex_shader *cso = malloc(sizeof(struct cso_vertex_shader));
+      memcpy(&cso->state, templ, sizeof(struct pipe_shader_state));
+      cso->data = st->pipe->create_vs_state(st->pipe, templ);
+      if (!cso->data)
+         cso->data = &cso->state;
+      iter = cso_insert_state(st->cache, hash_key, CSO_VERTEX_SHADER, cso);
    }
-   return (struct pipe_shader_state*)(cso_hash_iter_data(iter));
+   return (struct cso_vertex_shader*)(cso_hash_iter_data(iter));
 }
index 5b8c6168a8f2f46d301f1602f9c3ed8e4a29716c..356dd981833ff20e9f2e36c71bec1d2c14e3af78 100644 (file)
@@ -55,13 +55,13 @@ const struct cso_rasterizer *
 st_cached_rasterizer_state(struct st_context *st,
                            const struct pipe_rasterizer_state *raster);
 
-struct pipe_shader_state *st_cached_fs_state(
-   struct st_context *st,
-   const struct pipe_shader_state *templ);
+const struct cso_fragment_shader *
+st_cached_fs_state(struct st_context *st,
+                   const struct pipe_shader_state *templ);
 
 
-struct pipe_shader_state *st_cached_vs_state(
-   struct st_context *st,
-   const struct pipe_shader_state *templ);
+const struct cso_vertex_shader *
+st_cached_vs_state(struct st_context *st,
+                   const struct pipe_shader_state *templ);
 
 #endif
index ee70ce3320482ce298b2bff47c8c56db49dd7c65..03a81652cb44997bf3853eb175018337e49e8d6d 100644 (file)
@@ -348,7 +348,7 @@ clear_with_quad(GLcontext *ctx,
       if (!stfp) {
          stfp = make_frag_shader(st);
       }
-      pipe->bind_fs_state(pipe, stfp->fs);
+      pipe->bind_fs_state(pipe, stfp->fs->data);
    }
 
    /* vertex shader state: color/position pass-through */
@@ -357,7 +357,7 @@ clear_with_quad(GLcontext *ctx,
       if (!stvp) {
          stvp = make_vertex_shader(st);
       }
-      pipe->bind_vs_state(pipe, stvp->vs);
+      pipe->bind_vs_state(pipe, stvp->vs->data);
    }
 
    /* viewport state: viewport matching window dims */
@@ -383,8 +383,8 @@ clear_with_quad(GLcontext *ctx,
    pipe->set_alpha_test_state(pipe, &st->state.alpha_test);
    pipe->bind_blend_state(pipe, st->state.blend->data);
    pipe->bind_depth_stencil_state(pipe, st->state.depth_stencil);
-   pipe->bind_fs_state(pipe, st->state.fs);
-   pipe->bind_vs_state(pipe, st->state.vs);
+   pipe->bind_fs_state(pipe, st->state.fs->data);
+   pipe->bind_vs_state(pipe, st->state.vs->data);
    pipe->bind_rasterizer_state(pipe, st->state.rasterizer->data);
    pipe->set_viewport_state(pipe, &ctx->st->state.viewport);
    /* OR:
index d4f260ee5474ce09f9584865f63b89902d8bd3d2..4e3c24353e8956f2224c890f4b59db0f9f1bc7d2 100644 (file)
@@ -330,7 +330,7 @@ draw_textured_quad(GLcontext *ctx, GLint x, GLint y, GLfloat z,
       if (!stfp) {
          stfp = make_fragment_shader(ctx->st);
       }
-      pipe->bind_fs_state(pipe, stfp->fs);
+      pipe->bind_fs_state(pipe, stfp->fs->data);
    }
 
    /* vertex shader state: position + texcoord pass-through */
@@ -339,7 +339,7 @@ draw_textured_quad(GLcontext *ctx, GLint x, GLint y, GLfloat z,
       if (!stvp) {
          stvp = make_vertex_shader(ctx->st);
       }
-      pipe->bind_vs_state(pipe, stvp->vs);
+      pipe->bind_vs_state(pipe, stvp->vs->data);
    }
 
    /* texture sampling state: */
@@ -393,8 +393,8 @@ draw_textured_quad(GLcontext *ctx, GLint x, GLint y, GLfloat z,
 
    /* restore GL state */
    pipe->bind_rasterizer_state(pipe, ctx->st->state.rasterizer->data);
-   pipe->bind_fs_state(pipe, ctx->st->state.fs);
-   pipe->bind_vs_state(pipe, ctx->st->state.vs);
+   pipe->bind_fs_state(pipe, ctx->st->state.fs->data);
+   pipe->bind_vs_state(pipe, ctx->st->state.vs->data);
    pipe->set_texture_state(pipe, unit, ctx->st->state.texture[unit]);
    pipe->bind_sampler_state(pipe, unit, ctx->st->state.sampler[unit]);
    pipe->set_viewport_state(pipe, &ctx->st->state.viewport);
index 5245535a652475d0149b86c8e88918cb38ce153a..04b2016ffcc9be76163ac9cdef579af3dcd4c24e 100644 (file)
@@ -35,6 +35,7 @@
 
 #include "st_context.h"
 #include "st_atom.h"
+#include "st_cache.h"
 #include "st_draw.h"
 #include "st_program.h"
 #include "st_cb_rasterpos.h"
@@ -88,7 +89,7 @@ static void
 setup_feedback(GLcontext *ctx)
 {
    struct pipe_context *pipe = ctx->st->pipe;
-   const struct pipe_shader_state *vs = ctx->st->state.vs;
+   const struct pipe_shader_state *vs = &ctx->st->state.vs->state;
    struct pipe_feedback_state feedback;
    uint i;
 
index 93b642548019c4308ffbbfe5bc5b8026b0139de0..df976260f8e257a3bcfece4a4d9fcf88cba415e9 100644 (file)
@@ -79,8 +79,8 @@ struct st_context
       const struct pipe_sampler_state *sampler[PIPE_MAX_SAMPLERS];
       const struct pipe_depth_stencil_state *depth_stencil;
       const struct cso_rasterizer  *rasterizer;
-      const struct pipe_shader_state *fs;
-      const struct pipe_shader_state *vs;
+      const struct cso_fragment_shader *fs;
+      const struct cso_vertex_shader   *vs;
 
       struct pipe_alpha_test_state  alpha_test;
       struct pipe_blend_color  blend_color;
index 238ade00ac7682c88a3c916606a81ec53552cd80..633e4d9470897f4043b9e7f466bc8e83514b0fb5 100644 (file)
@@ -198,7 +198,7 @@ st_draw_vbo(GLcontext *ctx,
 
    /* must get these after state validation! */
    vp = ctx->st->vp;
-   vs = ctx->st->state.vs;
+   vs = &ctx->st->state.vs->state;
 
    /* loop over TGSI shader inputs */
    for (attr = 0; attr < vs->num_inputs; attr++) {
@@ -405,8 +405,8 @@ st_feedback_draw_vbo(GLcontext *ctx,
    assert(draw);
    draw_set_viewport_state(draw, &st->state.viewport);
    draw_set_clip_state(draw, &st->state.clip);
-   draw_set_rasterizer_state(draw, st->state.rasterizer->data);
-   draw_set_vertex_shader(draw, st->state.vs);
+   draw_set_rasterizer_state(draw, &st->state.rasterizer->state);
+   draw_set_vertex_shader(draw, &st->state.vs->state);
    /* XXX need to set vertex info too */
 
 
index 4945141d15422eb3276c1634d281ed14a8b69d5e..4f9ace3e6a8cc6c4b16c4193de285dfd8eeeddc5 100644 (file)
@@ -40,6 +40,8 @@
 
 #define ST_FP_MAX_TOKENS 1024
 
+struct cso_fragment_shader;
+struct cso_vertex_shader;
 
 struct st_fragment_program
 {
@@ -52,7 +54,7 @@ struct st_fragment_program
    GLboolean dirty;
 
    /** Pointer to the corresponding cached shader */
-   const struct pipe_shader_state *fs;
+   const struct cso_fragment_shader *fs;
 
    GLuint param_state;
 };
@@ -83,7 +85,7 @@ struct st_vertex_program
 #endif
 
    /** Pointer to the corresponding cached shader */
-   const struct pipe_shader_state *vs;
+   const struct cso_vertex_shader *vs;
 
    GLuint param_state;
 };
@@ -105,12 +107,12 @@ st_vertex_program( struct gl_vertex_program *vp )
 }
 
 
-extern struct pipe_shader_state *
+extern const struct cso_fragment_shader *
 st_translate_fragment_shader(struct st_context *st,
                              struct st_fragment_program *fp);
 
 
-extern struct pipe_shader_state *
+extern const struct cso_vertex_shader *
 st_translate_vertex_shader(struct st_context *st,
                            struct st_vertex_program *vp);