Convert the rasterizer cso to the new semantics.
authorZack Rusin <zack@tungstengraphics.com>
Wed, 19 Sep 2007 18:01:18 +0000 (14:01 -0400)
committerZack Rusin <zack@tungstengraphics.com>
Wed, 19 Sep 2007 18:01:18 +0000 (14:01 -0400)
Basically make cso hold the driver specific struct, while
managing the template.

15 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_rasterizer.c
src/mesa/state_tracker/st_atom_rasterizer.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_context.h
src/mesa/state_tracker/st_draw.c

index 7ac5908922951ef640a68895ca3653fea9efbec7..cd4b64eec4fa4e8c6f1d37e2cb2d7a598b18815f 100644 (file)
@@ -53,6 +53,11 @@ struct cso_blend {
    void   *data;
 };
 
+struct cso_rasterizer {
+   struct pipe_rasterizer_state state;
+   void *data;
+};
+
 enum cso_cache_type {
    CSO_BLEND,
    CSO_SAMPLER,
index ea7fb109b3bbacf5cf10a86055adeb441aee2ac1..a649899010f821a7f9ba3a99106c76c7bf1f1b1c 100644 (file)
@@ -73,7 +73,7 @@ struct failover_context {
    const struct fo_state                 *blend;
    const struct pipe_sampler_state       *sampler[PIPE_MAX_SAMPLERS];
    const struct pipe_depth_stencil_state *depth_stencil;
-   const struct pipe_rasterizer_state    *rasterizer;
+   const struct fo_state                 *rasterizer;
    const struct pipe_shader_state        *fragment_shader;
    const struct pipe_shader_state        *vertex_shader;
 
index ba110a6e4ff2917e0e150a7b633ce20c6ab10ae1..25725625e009798493b682bd031f599067c2fe40 100644 (file)
@@ -183,17 +183,42 @@ failover_set_polygon_stipple( struct pipe_context *pipe,
    failover->hw->set_polygon_stipple( failover->hw, stipple );
 }
 
+static void *
+failover_create_rasterizer_state(struct pipe_context *pipe,
+                                 const struct pipe_rasterizer_state *templ)
+{
+   struct fo_state *state = malloc(sizeof(struct fo_state));
+   struct failover_context *failover = failover_context(pipe);
 
+   state->sw_state = failover->sw->create_rasterizer_state(pipe, templ);
+   state->hw_state = failover->hw->create_rasterizer_state(pipe, templ);
+
+   return state;
+}
 
 static void
-failover_bind_rasterizer_state( struct pipe_context *pipe,
-                                const struct pipe_rasterizer_state *setup )
+failover_bind_rasterizer_state(struct pipe_context *pipe,
+                               void *raster)
 {
    struct failover_context *failover = failover_context(pipe);
 
-   failover->rasterizer = setup;
+   failover->rasterizer = (struct fo_state *)raster;
    failover->dirty |= FO_NEW_RASTERIZER;
-   failover->hw->bind_rasterizer_state( failover->hw, setup );
+   failover->hw->bind_rasterizer_state( failover->hw, raster );
+}
+
+static void
+failover_delete_rasterizer_state(struct pipe_context *pipe,
+                                 void *raster)
+{
+   struct fo_state *state = (struct fo_state*)raster;
+   struct failover_context *failover = failover_context(pipe);
+
+   failover->sw->delete_rasterizer_state(pipe, state->sw_state);
+   failover->hw->delete_rasterizer_state(pipe, state->hw_state);
+   state->sw_state = 0;
+   state->hw_state = 0;
+   free(state);
 }
 
 
@@ -284,7 +309,9 @@ failover_init_state_functions( struct failover_context *failover )
    failover->pipe.delete_blend_state = failover_delete_blend_state;
    failover->pipe.bind_sampler_state = failover_bind_sampler_state;
    failover->pipe.bind_depth_stencil_state = failover_bind_depth_stencil_state;
+   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;
 
index 72697c01a9ef372020641a2141a00878ac4fefaf..f2b0b1edc0ed0e457846be469815e825a955d881 100644 (file)
@@ -87,7 +87,8 @@ failover_state_emit( struct failover_context *failover )
       failover->sw->set_polygon_stipple( failover->sw, &failover->poly_stipple );
 
    if (failover->dirty & FO_NEW_RASTERIZER)
-      failover->sw->bind_rasterizer_state( failover->sw, failover->rasterizer );
+      failover->sw->bind_rasterizer_state( failover->sw,
+                                           failover->rasterizer->sw_state );
 
    if (failover->dirty & FO_NEW_SCISSOR)
       failover->sw->set_scissor_state( failover->sw, &failover->scissor );
index 4a4d26be659dae6dcf32fc1176f9e171146060d5..66aa9a0274b8b0d88b859855ff9fb15dbd481fda 100644 (file)
@@ -371,23 +371,19 @@ static void i915_set_viewport_state( struct pipe_context *pipe,
 }
 
 
-static const struct pipe_rasterizer_state *
+static void *
 i915_create_rasterizer_state(struct pipe_context *pipe,
                              const struct pipe_rasterizer_state *setup)
 {
-   struct pipe_rasterizer_state *raster =
-      malloc(sizeof(struct pipe_rasterizer_state));
-   memcpy(raster, setup, sizeof(struct pipe_rasterizer_state));
-
-   return raster;
+   return 0;
 }
 
 static void i915_bind_rasterizer_state( struct pipe_context *pipe,
-                                   const struct pipe_rasterizer_state *setup )
+                                        void *setup )
 {
    struct i915_context *i915 = i915_context(pipe);
 
-   i915->rasterizer = setup;
+   i915->rasterizer = (struct pipe_rasterizer_state *)setup;
 
    /* pass-through to draw module */
    draw_set_rasterizer_state(i915->draw, setup);
@@ -395,10 +391,10 @@ static void i915_bind_rasterizer_state( struct pipe_context *pipe,
    i915->dirty |= I915_NEW_RASTERIZER;
 }
 
-static void i915_delete_rasterizer_state( struct pipe_context *pipe,
-                                     const struct pipe_rasterizer_state *setup )
+static void i915_delete_rasterizer_state(struct pipe_context *pipe,
+                                         void *setup)
 {
-   free((struct pipe_rasterizer_state*)setup);
+   /* do nothing */
 }
 
 static void i915_set_vertex_buffer( struct pipe_context *pipe,
index adca6612d55abdf154b80cb82fab388500a1b2fb..1c0ab794f0bac42202792dd22e80ef0735f4ed29 100644 (file)
@@ -99,13 +99,10 @@ struct pipe_context {
    void (*delete_sampler_state)(struct pipe_context *,
                                 const struct pipe_sampler_state *);
 
-   const struct pipe_rasterizer_state *(*create_rasterizer_state)(
-      struct pipe_context *,
-      const struct pipe_rasterizer_state *);
-   void (*bind_rasterizer_state)(struct pipe_context *,
-                                 const struct pipe_rasterizer_state *);
-   void (*delete_rasterizer_state)(struct pipe_context *,
-                                   const struct pipe_rasterizer_state *);
+   void *(*create_rasterizer_state)(struct pipe_context *,
+                                    const struct pipe_rasterizer_state *);
+   void (*bind_rasterizer_state)(struct pipe_context *, void *);
+   void (*delete_rasterizer_state)(struct pipe_context *, void *);
 
    const struct pipe_depth_stencil_state * (*create_depth_stencil_state)(
       struct pipe_context *,
index 8e7776a6c7d460df4f71d9c99954c6e06d3aac43..a20ae1d4a229851afcb5454fc4348c6772a32a89 100644 (file)
@@ -58,13 +58,13 @@ void softpipe_bind_depth_stencil_state(struct pipe_context *,
 void softpipe_delete_depth_stencil_state(struct pipe_context *,
                                          const struct pipe_depth_stencil_state *);
 
-const struct pipe_rasterizer_state *
+void *
 softpipe_create_rasterizer_state(struct pipe_context *,
-                              const struct pipe_rasterizer_state *);
-void softpipe_bind_rasterizer_state(struct pipe_context *,
                                  const struct pipe_rasterizer_state *);
+void softpipe_bind_rasterizer_state(struct pipe_context *,
+                                    void *);
 void softpipe_delete_rasterizer_state(struct pipe_context *,
-                                   const struct pipe_rasterizer_state *);
+                                      void *);
 
 void softpipe_set_framebuffer_state( struct pipe_context *,
                             const struct pipe_framebuffer_state * );
index d832adb91b7c567c15076c696c137d57cc30d767..d7845cef826b517b934e13517734cd0cbb53e902 100644 (file)
 
 
 
-const struct pipe_rasterizer_state *
+void *
 softpipe_create_rasterizer_state(struct pipe_context *pipe,
-                              const struct pipe_rasterizer_state *setup)
+                                 const struct pipe_rasterizer_state *setup)
 {
-   struct pipe_rasterizer_state *raster =
-      malloc(sizeof(struct pipe_rasterizer_state));
-   memcpy(raster, setup, sizeof(struct pipe_rasterizer_state));
-
-   return raster;
+   return 0;
 }
 
 void softpipe_bind_rasterizer_state(struct pipe_context *pipe,
-                                 const struct pipe_rasterizer_state *setup)
+                                    void *setup)
 {
    struct softpipe_context *softpipe = softpipe_context(pipe);
 
    /* pass-through to draw module */
    draw_set_rasterizer_state(softpipe->draw, setup);
 
-   softpipe->rasterizer = setup;
+   softpipe->rasterizer = (struct pipe_rasterizer_state *)setup;
 
    softpipe->dirty |= SP_NEW_RASTERIZER;
 }
 
 void softpipe_delete_rasterizer_state(struct pipe_context *pipe,
-                                   const struct pipe_rasterizer_state *rasterizer)
+                                      void *rasterizer)
 {
-   free((struct pipe_rasterizer_state*)rasterizer);
+   /* do nothing */
 }
 
 
index cab8ad5cd6c1d09fc7b8235dc5f4c862ba8fcfcf..e0d83ddaea444ee214ad1c1ea7c8e45b8f423ee2 100644 (file)
@@ -73,7 +73,7 @@ static void update_raster_state( struct st_context *st )
 {
    GLcontext *ctx = st->ctx;
    struct pipe_rasterizer_state raster;
-   const struct pipe_rasterizer_state *cached;
+   const struct cso_rasterizer *cso;
 
    memset(&raster, 0, sizeof(raster));
    
@@ -206,10 +206,10 @@ static void update_raster_state( struct st_context *st )
    if (ctx->Scissor.Enabled)
       raster.scissor = 1;
 
-   cached = st_cached_rasterizer_state(st, &raster);
-   if (st->state.rasterizer != cached) {
-      st->state.rasterizer = cached;
-      st->pipe->bind_rasterizer_state( st->pipe, cached );
+   cso = st_cached_rasterizer_state(st, &raster);
+   if (st->state.rasterizer != cso) {
+      st->state.rasterizer = cso;
+      st->pipe->bind_rasterizer_state(st->pipe, cso->data);
    }
 }
 
index bd6c63b7a13b23a8667181ed0266a1084bc21372..0f233cea588a271d2d59a968f458d238ea06da21 100644 (file)
@@ -95,22 +95,24 @@ struct pipe_depth_stencil_state * st_cached_depth_stencil_state(
    return (struct pipe_depth_stencil_state*)(cso_hash_iter_data(iter));
 }
 
-struct pipe_rasterizer_state * st_cached_rasterizer_state(
+const struct cso_rasterizer* st_cached_rasterizer_state(
    struct st_context *st,
-   const struct pipe_rasterizer_state *raster)
+   const struct pipe_rasterizer_state *templ)
 {
-   unsigned hash_key = cso_construct_key((void*)raster,
+   unsigned hash_key = cso_construct_key((void*)templ,
                                          sizeof(struct pipe_rasterizer_state));
    struct cso_hash_iter iter = cso_find_state_template(st->cache,
                                                        hash_key, CSO_RASTERIZER,
-                                                       (void*)raster);
+                                                       (void*)templ);
    if (cso_hash_iter_is_null(iter)) {
-      const struct pipe_rasterizer_state *created_state =
-         st->pipe->create_rasterizer_state(st->pipe, raster);
-      iter = cso_insert_state(st->cache, hash_key, CSO_RASTERIZER,
-                              (void*)created_state);
+      struct cso_rasterizer *cso = malloc(sizeof(struct cso_rasterizer));
+      memcpy(&cso->state, templ, sizeof(struct pipe_rasterizer_state));
+      cso->data = st->pipe->create_rasterizer_state(st->pipe, templ);
+      if (!cso->data)
+         cso->data = &cso->state;
+      iter = cso_insert_state(st->cache, hash_key, CSO_RASTERIZER, cso);
    }
-   return (struct pipe_rasterizer_state*)(cso_hash_iter_data(iter));
+   return (struct cso_rasterizer*)(cso_hash_iter_data(iter));
 }
 
 struct pipe_shader_state * st_cached_fs_state(
index fb0ff0d4db85a0d65e21f5e437923ad884227f72..5b8c6168a8f2f46d301f1602f9c3ed8e4a29716c 100644 (file)
@@ -51,9 +51,9 @@ struct pipe_depth_stencil_state *st_cached_depth_stencil_state(
    struct st_context *st,
    const struct pipe_depth_stencil_state *depth_stencil);
 
-struct pipe_rasterizer_state *st_cached_rasterizer_state(
-   struct st_context *st,
-   const struct pipe_rasterizer_state *raster);
+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,
index 3a6991754ac2d3b0c029e8608e009a9ab29284da..5d5efd9eae1787f5e6502c570d6ee6305eec7453 100644 (file)
@@ -345,7 +345,7 @@ clear_with_quad(GLcontext *ctx,
    /* setup state: nothing */
    {
       struct pipe_rasterizer_state raster;
-      const struct pipe_rasterizer_state *cached;
+      const struct cso_rasterizer *cso;
       memset(&raster, 0, sizeof(raster));
 #if 0
       /* don't do per-pixel scissor; we'll just draw a PIPE_PRIM_QUAD
@@ -354,8 +354,8 @@ clear_with_quad(GLcontext *ctx,
       if (ctx->Scissor.Enabled)
          raster.scissor = 1;
 #endif
-      cached = st_cached_rasterizer_state(ctx->st, &raster);
-      pipe->bind_rasterizer_state(pipe, cached);
+      cso = st_cached_rasterizer_state(ctx->st, &raster);
+      pipe->bind_rasterizer_state(pipe, cso->data);
    }
 
    /* fragment shader state: color pass-through program */
@@ -415,7 +415,7 @@ clear_with_quad(GLcontext *ctx,
    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_rasterizer_state(pipe, st->state.rasterizer);
+   pipe->bind_rasterizer_state(pipe, st->state.rasterizer->data);
    pipe->set_viewport_state(pipe, &ctx->st->state.viewport);
    /* OR:
    st_invalidate_state(ctx, _NEW_COLOR | _NEW_DEPTH | _NEW_STENCIL);
index 4a554cd5a4ad4e22fdae11aab85bb07ad38f24c5..0fd728c93060a512e75d412f1f0df8b323818b6d 100644 (file)
@@ -328,12 +328,12 @@ draw_textured_quad(GLcontext *ctx, GLint x, GLint y, GLfloat z,
    /* setup state: just scissor */
    {
       struct pipe_rasterizer_state  setup;
-      struct pipe_rasterizer_state *cached;
+      const struct cso_rasterizer  *cso;
       memset(&setup, 0, sizeof(setup));
       if (ctx->Scissor.Enabled)
          setup.scissor = 1;
-      cached = st_cached_rasterizer_state(ctx->st, &setup);
-      pipe->bind_rasterizer_state(pipe, cached);
+      cso = st_cached_rasterizer_state(ctx->st, &setup);
+      pipe->bind_rasterizer_state(pipe, cso->data);
    }
 
    /* fragment shader state: TEX lookup program */
@@ -417,7 +417,7 @@ draw_textured_quad(GLcontext *ctx, GLint x, GLint y, GLfloat z,
    draw_quad(ctx, x0, y0, z, x1, y1);
 
    /* restore GL state */
-   pipe->bind_rasterizer_state(pipe, ctx->st->state.rasterizer);
+   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->set_texture_state(pipe, unit, ctx->st->state.texture[unit]);
index 966574b67c61c0829abf311c8f6a9cd7bdb48daa..93b642548019c4308ffbbfe5bc5b8026b0139de0 100644 (file)
@@ -78,7 +78,7 @@ struct st_context
       const struct cso_blend *blend;
       const struct pipe_sampler_state *sampler[PIPE_MAX_SAMPLERS];
       const struct pipe_depth_stencil_state *depth_stencil;
-      const struct pipe_rasterizer_state  *rasterizer;
+      const struct cso_rasterizer  *rasterizer;
       const struct pipe_shader_state *fs;
       const struct pipe_shader_state *vs;
 
index 6efe3ce8b8e993a85c2e512f6f2bfc4e9332e6f6..e36c10d595a09c73a912a5e2bbe4adbf66506e59 100644 (file)
@@ -404,7 +404,7 @@ 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);
+   draw_set_rasterizer_state(draw, st->state.rasterizer->data);
    draw_set_vertex_shader(draw, st->state.vs);
    /* XXX need to set vertex info too */