[Mesa-dev] [PATCH 3/3] gallium/cso: kill off non-functional shader caching

Marek Olšák maraeo at gmail.com
Thu Feb 16 17:24:31 PST 2012


Suggested by José.
---
 src/gallium/auxiliary/cso_cache/cso_cache.c   |   24 -----
 src/gallium/auxiliary/cso_cache/cso_cache.h   |   16 ----
 src/gallium/auxiliary/cso_cache/cso_context.c |  118 -------------------------
 src/gallium/auxiliary/cso_cache/cso_context.h |   13 ---
 4 files changed, 0 insertions(+), 171 deletions(-)

diff --git a/src/gallium/auxiliary/cso_cache/cso_cache.c b/src/gallium/auxiliary/cso_cache/cso_cache.c
index c606992..e276fd1 100644
--- a/src/gallium/auxiliary/cso_cache/cso_cache.c
+++ b/src/gallium/auxiliary/cso_cache/cso_cache.c
@@ -119,22 +119,6 @@ static void delete_rasterizer_state(void *state, void *data)
    FREE(state);
 }
 
-static void delete_fs_state(void *state, void *data)
-{
-   struct cso_fragment_shader *cso = (struct cso_fragment_shader *)state;
-   if (cso->delete_state)
-      cso->delete_state(cso->context, cso->data);
-   FREE(state);
-}
-
-static void delete_vs_state(void *state, void *data)
-{
-   struct cso_vertex_shader *cso = (struct cso_vertex_shader *)state;
-   if (cso->delete_state)
-      cso->delete_state(cso->context, cso->data);
-   FREE(state);
-}
-
 static void delete_velements(void *state, void *data)
 {
    struct cso_velements *cso = (struct cso_velements *)state;
@@ -158,12 +142,6 @@ static INLINE void delete_cso(void *state, enum cso_cache_type type)
    case CSO_RASTERIZER:
       delete_rasterizer_state(state, 0);
       break;
-   case CSO_FRAGMENT_SHADER:
-      delete_fs_state(state, 0);
-      break;
-   case CSO_VERTEX_SHADER:
-      delete_vs_state(state, 0);
-      break;
    case CSO_VELEMENTS:
       delete_velements(state, 0);
       break;
@@ -309,8 +287,6 @@ void cso_cache_delete(struct cso_cache *sc)
    /* delete driver data */
    cso_for_each_state(sc, CSO_BLEND, delete_blend_state, 0);
    cso_for_each_state(sc, CSO_DEPTH_STENCIL_ALPHA, delete_depth_stencil_state, 0);
-   cso_for_each_state(sc, CSO_FRAGMENT_SHADER, delete_fs_state, 0);
-   cso_for_each_state(sc, CSO_VERTEX_SHADER, delete_vs_state, 0);
    cso_for_each_state(sc, CSO_RASTERIZER, delete_rasterizer_state, 0);
    cso_for_each_state(sc, CSO_SAMPLER, delete_sampler_state, 0);
    cso_for_each_state(sc, CSO_VELEMENTS, delete_velements, 0);
diff --git a/src/gallium/auxiliary/cso_cache/cso_cache.h b/src/gallium/auxiliary/cso_cache/cso_cache.h
index 1b17423..cc1f1c0 100644
--- a/src/gallium/auxiliary/cso_cache/cso_cache.h
+++ b/src/gallium/auxiliary/cso_cache/cso_cache.h
@@ -89,8 +89,6 @@ enum cso_cache_type {
    CSO_RASTERIZER,
    CSO_BLEND,
    CSO_DEPTH_STENCIL_ALPHA,
-   CSO_FRAGMENT_SHADER,
-   CSO_VERTEX_SHADER,
    CSO_SAMPLER,
    CSO_VELEMENTS,
    CSO_CACHE_MAX,
@@ -126,20 +124,6 @@ struct cso_rasterizer {
    struct pipe_context *context;
 };
 
-struct cso_fragment_shader {
-   struct pipe_shader_state state;
-   void *data;
-   cso_state_callback delete_state;
-   struct pipe_context *context;
-};
-
-struct cso_vertex_shader {
-   struct pipe_shader_state state;
-   void *data;
-   cso_state_callback delete_state;
-   struct pipe_context *context;
-};
-
 struct cso_sampler {
    struct pipe_sampler_state state;
    void *data;
diff --git a/src/gallium/auxiliary/cso_cache/cso_context.c b/src/gallium/auxiliary/cso_cache/cso_context.c
index c95a1ba..60a6e02 100644
--- a/src/gallium/auxiliary/cso_cache/cso_context.c
+++ b/src/gallium/auxiliary/cso_cache/cso_context.c
@@ -165,28 +165,6 @@ static boolean delete_rasterizer_state(struct cso_context *ctx, void *state)
    return TRUE;
 }
 
-static boolean delete_fs_state(struct cso_context *ctx, void *state)
-{
-   struct cso_fragment_shader *cso = (struct cso_fragment_shader *)state;
-   if (ctx->fragment_shader == cso->data)
-      return FALSE;
-   if (cso->delete_state)
-      cso->delete_state(cso->context, cso->data);
-   FREE(state);
-   return TRUE;
-}
-
-static boolean delete_vs_state(struct cso_context *ctx, void *state)
-{
-   struct cso_vertex_shader *cso = (struct cso_vertex_shader *)state;
-   if (ctx->vertex_shader == cso->data)
-      return TRUE;
-   if (cso->delete_state)
-      cso->delete_state(cso->context, cso->data);
-   FREE(state);
-   return FALSE;
-}
-
 static boolean delete_vertex_elements(struct cso_context *ctx,
                                       void *state)
 {
@@ -218,12 +196,6 @@ static INLINE boolean delete_cso(struct cso_context *ctx,
    case CSO_RASTERIZER:
       return delete_rasterizer_state(ctx, state);
       break;
-   case CSO_FRAGMENT_SHADER:
-      return delete_fs_state(ctx, state);
-      break;
-   case CSO_VERTEX_SHADER:
-      return delete_vs_state(ctx, state);
-      break;
    case CSO_VELEMENTS:
       return delete_vertex_elements(ctx, state);
       break;
@@ -571,52 +543,6 @@ void cso_delete_fragment_shader(struct cso_context *ctx, void *handle )
    ctx->pipe->delete_fs_state(ctx->pipe, handle);
 }
 
-/* Not really working:
- */
-#if 0
-enum pipe_error cso_set_fragment_shader(struct cso_context *ctx,
-                                        const struct pipe_shader_state *templ)
-{
-   const struct tgsi_token *tokens = templ->tokens;
-   unsigned num_tokens = tgsi_num_tokens(tokens);
-   size_t tokens_size = num_tokens*sizeof(struct tgsi_token);
-   unsigned hash_key = cso_construct_key((void*)tokens, tokens_size);
-   struct cso_hash_iter iter = cso_find_state_template(ctx->cache,
-                                                       hash_key, 
-                                                       CSO_FRAGMENT_SHADER,
-                                                       (void*)tokens,
-                                                       sizeof(*templ)); /* XXX correct? tokens_size? */
-   void *handle = NULL;
-
-   if (cso_hash_iter_is_null(iter)) {
-      struct cso_fragment_shader *cso = MALLOC(sizeof(struct cso_fragment_shader) + tokens_size);
-      struct tgsi_token *cso_tokens = (struct tgsi_token *)((char *)cso + sizeof(*cso));
-
-      if (!cso)
-         return PIPE_ERROR_OUT_OF_MEMORY;
-
-      memcpy(cso_tokens, tokens, tokens_size);
-      cso->state.tokens = cso_tokens;
-      cso->data = ctx->pipe->create_fs_state(ctx->pipe, &cso->state);
-      cso->delete_state = (cso_state_callback)ctx->pipe->delete_fs_state;
-      cso->context = ctx->pipe;
-
-      iter = cso_insert_state(ctx->cache, hash_key, CSO_FRAGMENT_SHADER, cso);
-      if (cso_hash_iter_is_null(iter)) {
-         FREE(cso);
-         return PIPE_ERROR_OUT_OF_MEMORY;
-      }
-
-      handle = cso->data;
-   }
-   else {
-      handle = ((struct cso_fragment_shader *)cso_hash_iter_data(iter))->data;
-   }
-
-   return cso_set_fragment_shader_handle( ctx, handle );
-}
-#endif
-
 void cso_save_fragment_shader(struct cso_context *ctx)
 {
    assert(!ctx->fragment_shader_saved);
@@ -653,50 +579,6 @@ void cso_delete_vertex_shader(struct cso_context *ctx, void *handle )
    ctx->pipe->delete_vs_state(ctx->pipe, handle);
 }
 
-
-/* Not really working:
- */
-#if 0
-enum pipe_error cso_set_vertex_shader(struct cso_context *ctx,
-                                      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(ctx->cache,
-                                                       hash_key, CSO_VERTEX_SHADER,
-                                                       (void*)templ,
-                                                       sizeof(*templ));
-   void *handle = NULL;
-
-   if (cso_hash_iter_is_null(iter)) {
-      struct cso_vertex_shader *cso = MALLOC(sizeof(struct cso_vertex_shader));
-
-      if (!cso)
-         return PIPE_ERROR_OUT_OF_MEMORY;
-
-      memcpy(cso->state, templ, sizeof(*templ));
-      cso->data = ctx->pipe->create_vs_state(ctx->pipe, &cso->state);
-      cso->delete_state = (cso_state_callback)ctx->pipe->delete_vs_state;
-      cso->context = ctx->pipe;
-
-      iter = cso_insert_state(ctx->cache, hash_key, CSO_VERTEX_SHADER, cso);
-      if (cso_hash_iter_is_null(iter)) {
-         FREE(cso);
-         return PIPE_ERROR_OUT_OF_MEMORY;
-      }
-
-      handle = cso->data;
-   }
-   else {
-      handle = ((struct cso_vertex_shader *)cso_hash_iter_data(iter))->data;
-   }
-
-   return cso_set_vertex_shader_handle( ctx, handle );
-}
-#endif
-
-
-
 void cso_save_vertex_shader(struct cso_context *ctx)
 {
    assert(!ctx->vertex_shader_saved);
diff --git a/src/gallium/auxiliary/cso_cache/cso_context.h b/src/gallium/auxiliary/cso_cache/cso_context.h
index 5102d70..aabf70c 100644
--- a/src/gallium/auxiliary/cso_cache/cso_context.h
+++ b/src/gallium/auxiliary/cso_cache/cso_context.h
@@ -125,18 +125,9 @@ void cso_save_stream_outputs(struct cso_context *ctx);
 void cso_restore_stream_outputs(struct cso_context *ctx);
 
 
-/* These aren't really sensible -- most of the time the api provides
- * object semantics for shaders anyway, and the cases where it doesn't
- * (eg mesa's internall-generated texenv programs), it will be up to
- * the state tracker to implement their own specialized caching.
- */
 enum pipe_error cso_set_fragment_shader_handle(struct cso_context *ctx,
                                                void *handle );
 void cso_delete_fragment_shader(struct cso_context *ctx, void *handle );
-/*
-enum pipe_error cso_set_fragment_shader( struct cso_context *cso,
-                                         const struct pipe_shader_state *shader );
-*/
 void cso_save_fragment_shader(struct cso_context *cso);
 void cso_restore_fragment_shader(struct cso_context *cso);
 
@@ -144,10 +135,6 @@ void cso_restore_fragment_shader(struct cso_context *cso);
 enum pipe_error cso_set_vertex_shader_handle(struct cso_context *ctx,
                                              void *handle );
 void cso_delete_vertex_shader(struct cso_context *ctx, void *handle );
-/*
-enum pipe_error cso_set_vertex_shader( struct cso_context *cso,
-                                       const struct pipe_shader_state *shader );
-*/
 void cso_save_vertex_shader(struct cso_context *cso);
 void cso_restore_vertex_shader(struct cso_context *cso);
 
-- 
1.7.5.4



More information about the mesa-dev mailing list