Finish up conversions of shaders to immutable objects.
authorZack Rusin <zack@tungstengraphics.com>
Wed, 19 Sep 2007 10:46:32 +0000 (06:46 -0400)
committerZack Rusin <zack@tungstengraphics.com>
Wed, 19 Sep 2007 10:46:32 +0000 (06:46 -0400)
Create/Delete calls should be split since in create we'll be
compiling them so we want to know which one it is (vertex/fragment).

src/mesa/pipe/cso_cache/cso_cache.c
src/mesa/pipe/cso_cache/cso_cache.h
src/mesa/pipe/i915simple/i915_state.c
src/mesa/pipe/p_context.h
src/mesa/pipe/softpipe/sp_context.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

index be653d9494a96eb6a080d8dea9c78aab7c9aa491..e87733c7abab840c047bb74b83d9beb69fe8d7ca 100644 (file)
@@ -80,8 +80,10 @@ static struct cso_hash *_cso_hash_for_type(struct cso_cache *sc, enum cso_cache_
       hash = sc->depth_stencil_hash;
    case CSO_RASTERIZER:
       hash = sc->rasterizer_hash;
-   case CSO_SHADER:
-      hash = sc->shader_hash;
+   case CSO_FRAGMENT_SHADER:
+      hash = sc->fs_hash;
+   case CSO_VERTEX_SHADER:
+      hash = sc->vs_hash;
    }
 
    return hash;
@@ -98,7 +100,9 @@ static int _cso_size_for_type(enum cso_cache_type type)
       return sizeof(struct pipe_depth_stencil_state);
    case CSO_RASTERIZER:
       return sizeof(struct pipe_rasterizer_state);
-   case CSO_SHADER:
+   case CSO_FRAGMENT_SHADER:
+      return sizeof(struct pipe_shader_state);
+   case CSO_VERTEX_SHADER:
       return sizeof(struct pipe_shader_state);
    }
    return 0;
@@ -152,7 +156,8 @@ struct cso_cache *cso_cache_create(void)
    sc->sampler_hash       = cso_hash_create();
    sc->depth_stencil_hash = cso_hash_create();
    sc->rasterizer_hash    = cso_hash_create();
-   sc->shader_hash        = cso_hash_create();
+   sc->fs_hash            = cso_hash_create();
+   sc->vs_hash            = cso_hash_create();
 
    return sc;
 }
@@ -164,6 +169,7 @@ void cso_cache_delete(struct cso_cache *sc)
    cso_hash_delete(sc->sampler_hash);
    cso_hash_delete(sc->depth_stencil_hash);
    cso_hash_delete(sc->rasterizer_hash);
-   cso_hash_delete(sc->shader_hash);
+   cso_hash_delete(sc->fs_hash);
+   cso_hash_delete(sc->vs_hash);
    free(sc);
 }
index d9793ca8554bb13d830ef7c0c8c3ab32789b9fa8..352e1a6a5926751745ed859e6d53fe6fbc19155a 100644 (file)
@@ -44,7 +44,8 @@ struct cso_cache {
    struct cso_hash *sampler_hash;
    struct cso_hash *depth_stencil_hash;
    struct cso_hash *rasterizer_hash;
-   struct cso_hash *shader_hash;
+   struct cso_hash *fs_hash;
+   struct cso_hash *vs_hash;
 };
 
 enum cso_cache_type {
@@ -52,7 +53,8 @@ enum cso_cache_type {
    CSO_SAMPLER,
    CSO_DEPTH_STENCIL,
    CSO_RASTERIZER,
-   CSO_SHADER
+   CSO_FRAGMENT_SHADER,
+   CSO_VERTEX_SHADER
 };
 
 unsigned cso_construct_key(void *item, int item_size);
index fe835643e06fd3fa90ba9d45313b071d9797f161..aaf2ccf499c05250aea3fc495f3b35fdfc9d7415 100644 (file)
@@ -373,10 +373,12 @@ i915_init_state_functions( struct i915_context *i915 )
    i915->pipe.create_rasterizer_state = i915_create_rasterizer_state;
    i915->pipe.bind_rasterizer_state = i915_bind_rasterizer_state;
    i915->pipe.delete_rasterizer_state = i915_delete_rasterizer_state;
-   i915->pipe.create_shader_state = i915_create_shader_state;
+   i915->pipe.create_fs_state = i915_create_shader_state;
    i915->pipe.bind_fs_state = i915_bind_fs_state;
+   i915->pipe.delete_fs_state = i915_delete_shader_state;
+   i915->pipe.create_vs_state = i915_create_shader_state;
    i915->pipe.bind_vs_state = i915_bind_vs_state;
-   i915->pipe.delete_shader_state = i915_delete_shader_state;
+   i915->pipe.delete_vs_state = i915_delete_shader_state;
 
    i915->pipe.set_alpha_test_state = i915_set_alpha_test_state;
    i915->pipe.set_blend_color = i915_set_blend_color;
index c405051bce4108a0230469f481d60c7abd98265d..5766b2b7df3f2bc792d163c3f21b168587ad7101 100644 (file)
@@ -117,15 +117,20 @@ struct pipe_context {
    void (*delete_depth_stencil_state)(struct pipe_context *,
                                       const struct pipe_depth_stencil_state *);
 
-   const struct pipe_shader_state * (*create_shader_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_shader_state)(struct pipe_context *,
-                               const struct pipe_shader_state *);
+   void (*delete_vs_state)(struct pipe_context *,
+                           const struct pipe_shader_state *);
 
    void (*set_alpha_test_state)( struct pipe_context *,
                                  const struct pipe_alpha_test_state * );
index 25cb9d87450bc74b354a04df73e5f894c0587ba7..a56793d6838473608370a3f1b8e94bc16fd37a2f 100644 (file)
@@ -262,10 +262,12 @@ struct pipe_context *softpipe_create( struct pipe_winsys *pipe_winsys,
    softpipe->pipe.create_rasterizer_state = softpipe_create_rasterizer_state;
    softpipe->pipe.bind_rasterizer_state   = softpipe_bind_rasterizer_state;
    softpipe->pipe.delete_rasterizer_state = softpipe_delete_rasterizer_state;
-   softpipe->pipe.create_shader_state = softpipe_create_shader_state;
-   softpipe->pipe.bind_fs_state       = softpipe_bind_fs_state;
-   softpipe->pipe.bind_vs_state       = softpipe_bind_vs_state;
-   softpipe->pipe.delete_shader_state = softpipe_delete_shader_state;
+   softpipe->pipe.create_fs_state = softpipe_create_shader_state;
+   softpipe->pipe.bind_fs_state   = softpipe_bind_fs_state;
+   softpipe->pipe.delete_fs_state = softpipe_delete_shader_state;
+   softpipe->pipe.create_vs_state = softpipe_create_shader_state;
+   softpipe->pipe.bind_vs_state   = softpipe_bind_vs_state;
+   softpipe->pipe.delete_vs_state = softpipe_delete_shader_state;
 
    softpipe->pipe.set_alpha_test_state = softpipe_set_alpha_test_state;
    softpipe->pipe.set_blend_color = softpipe_set_blend_color;
index 3df2c6750ab6c449ce94e793ff4ffe5a113aa33a..6dd576a57cb71dfa33fa3d68716c957fe33f8b6a 100644 (file)
@@ -77,7 +77,7 @@ static void compile_fs( struct st_context *st )
    fs.outputs_written
       = tgsi_mesa_translate_fragment_output_mask(fp->Base.Base.OutputsWritten);
    fs.tokens = &fp->tokens[0];
-   cached = st_cached_shader_state(st, &fs);
+   cached = st_cached_fs_state(st, &fs);
    fp->fsx = cached;
 
    if (TGSI_DEBUG)
index 8de19e41eebf1f10efe046e7d1b2e00f6cf43472..166dc70b083dc65a7e03cc66fe29c937245b2712 100644 (file)
@@ -104,7 +104,7 @@ static void compile_vs( struct st_context *st )
 
    vs.tokens = &vp->tokens[0];
 
-   cached = st_cached_shader_state(st, &vs);
+   cached = st_cached_vs_state(st, &vs);
 
    vp->vs = cached;
 
index 7b851e3901bee256fc64aaee1ff1ae5125d716df..d84a396e183ee1c776e352b50542b11aa9b88487 100644 (file)
@@ -112,19 +112,37 @@ struct pipe_rasterizer_state * st_cached_rasterizer_state(
    return (struct pipe_rasterizer_state*)(cso_hash_iter_data(iter));
 }
 
-struct pipe_shader_state * st_cached_shader_state(
+struct pipe_shader_state * 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));
    struct cso_hash_iter iter = cso_find_state_template(st->cache,
-                                                       hash_key, CSO_SHADER,
+                                                       hash_key, CSO_FRAGMENT_SHADER,
                                                        (void*)templ);
    if (cso_hash_iter_is_null(iter)) {
       const struct pipe_shader_state *created_state =
-         st->pipe->create_shader_state(st->pipe, templ);
-      iter = cso_insert_state(st->cache, hash_key, CSO_SHADER,
+         st->pipe->create_fs_state(st->pipe, templ);
+      iter = cso_insert_state(st->cache, hash_key, CSO_FRAGMENT_SHADER,
+                              (void*)created_state);
+   }
+   return (struct pipe_shader_state*)(cso_hash_iter_data(iter));
+}
+
+struct pipe_shader_state * 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));
+   struct cso_hash_iter iter = cso_find_state_template(st->cache,
+                                                       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);
    }
    return (struct pipe_shader_state*)(cso_hash_iter_data(iter));
index 6a897a999332425408508cca33e1a316abb38ade..bcbe19b82361cfba0ce2b2d6ed4d12f45d887469 100644 (file)
@@ -53,7 +53,12 @@ struct pipe_rasterizer_state *st_cached_rasterizer_state(
    struct st_context *st,
    const struct pipe_rasterizer_state *raster);
 
-struct pipe_shader_state *st_cached_shader_state(
+struct pipe_shader_state *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);
 
index 65cac9dbde811c72e264047b0fd766c563a00d72..7c669ab4578e27ad611372daeb46cb7b768ab4e1 100644 (file)
@@ -370,7 +370,7 @@ clear_with_quad(GLcontext *ctx,
       fs.inputs_read = tgsi_mesa_translate_fragment_input_mask(stfp->Base.Base.InputsRead);
       fs.outputs_written = tgsi_mesa_translate_fragment_output_mask(stfp->Base.Base.OutputsWritten);
       fs.tokens = &stfp->tokens[0];
-      cached = st_cached_shader_state(st, &fs);
+      cached = st_cached_fs_state(st, &fs);
       pipe->bind_fs_state(pipe, cached);
    }
 
@@ -386,7 +386,7 @@ clear_with_quad(GLcontext *ctx,
       vs.inputs_read = stvp->Base.Base.InputsRead;
       vs.outputs_written = stvp->Base.Base.OutputsWritten;
       vs.tokens = &stvp->tokens[0];
-      cached = st_cached_shader_state(st, &vs);
+      cached = st_cached_vs_state(st, &vs);
       pipe->bind_vs_state(pipe, cached);
    }
 
index 731c060c11d5101fb97ed657e208e6b27aa536fc..67de781c831c29d8770e8dcf9c19e7c6d75e9323 100644 (file)
@@ -347,7 +347,7 @@ draw_textured_quad(GLcontext *ctx, GLint x, GLint y, GLfloat z,
       memset(&fs, 0, sizeof(fs));
       fs.inputs_read = stfp->Base.Base.InputsRead;
       fs.tokens = &stfp->tokens[0];
-      cached = st_cached_shader_state(ctx->st, &fs);
+      cached = st_cached_fs_state(ctx->st, &fs);
       pipe->bind_fs_state(pipe, cached);
    }
 
@@ -363,7 +363,7 @@ draw_textured_quad(GLcontext *ctx, GLint x, GLint y, GLfloat z,
       vs.inputs_read = stvp->Base.Base.InputsRead;
       vs.outputs_written = stvp->Base.Base.OutputsWritten;
       vs.tokens = &stvp->tokens[0];
-      cached = st_cached_shader_state(ctx->st, &vs);
+      cached = st_cached_vs_state(ctx->st, &vs);
       pipe->bind_vs_state(pipe, cached);
    }