llvmpipe: Truncate the binned constants to max const buffer size.
[mesa.git] / src / gallium / auxiliary / cso_cache / cso_cache.h
index 3b0fe100b85d0ab03525aa08a03179bfc083cb5f..052245f96f19ce2dea1f7baccbd020401e3ed2df 100644 (file)
@@ -1,6 +1,6 @@
 /**************************************************************************
  *
- * Copyright 2007-2008 Tungsten Graphics, Inc., Cedar Park, Texas.
+ * Copyright 2007-2008 VMware, Inc.
  * All Rights Reserved.
  *
  * Permission is hereby granted, free of charge, to any person obtaining a
@@ -18,7 +18,7 @@
  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
  * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
- * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR
+ * IN NO EVENT SHALL VMWARE AND/OR ITS SUPPLIERS BE LIABLE FOR
  * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
  * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
  * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -53,6 +53,7 @@
   * - rasterizer (old setup)
   * - sampler
   * - vertex shader
+  * - vertex elements
   *
   * Things that are not constant state objects include:
   * - blend_color
@@ -66,7 +67,7 @@
   * - texture_state
   * - viewport_state
   *
-  * @author Zack Rusin <zack@tungstengraphics.com>
+  * @author Zack Rusin <zackr@vmware.com>
   */
 
 #ifndef CSO_CACHE_H
 extern "C" {
 #endif
 
+enum cso_cache_type {
+   CSO_RASTERIZER,
+   CSO_BLEND,
+   CSO_DEPTH_STENCIL_ALPHA,
+   CSO_SAMPLER,
+   CSO_VELEMENTS,
+   CSO_CACHE_MAX,
+};
+
+typedef void (*cso_state_callback)(void *ctx, void *obj);
+
+typedef void (*cso_sanitize_callback)(struct cso_hash *hash,
+                                      enum cso_cache_type type,
+                                      int max_size,
+                                      void *user_data);
+
 struct cso_cache;
 
 struct cso_blend {
    struct pipe_blend_state state;
-   void   *data;
-   void   (*delete_state)(void *, void  *);
-   void   *context;
+   void *data;
+   cso_state_callback delete_state;
+   struct pipe_context *context;
 };
 
 struct cso_depth_stencil_alpha {
    struct pipe_depth_stencil_alpha_state state;
    void *data;
-   void   (*delete_state)(void *, void  *);
-   void   *context;
+   cso_state_callback delete_state;
+   struct pipe_context *context;
 };
 
 struct cso_rasterizer {
    struct pipe_rasterizer_state state;
    void *data;
-   void   (*delete_state)(void *, void  *);
-   void   *context;
-};
-
-struct cso_fragment_shader {
-   struct pipe_shader_state state;
-   void *data;
-   void   (*delete_state)(void *, void  *);
-   void   *context;
-};
-
-struct cso_vertex_shader {
-   struct pipe_shader_state state;
-   void *data;
-   void   (*delete_state)(void *, void  *);
-   void   *context;
+   cso_state_callback delete_state;
+   struct pipe_context *context;
 };
 
 struct cso_sampler {
    struct pipe_sampler_state state;
    void *data;
-   void   (*delete_state)(void *, void  *);
-   void   *context;
+   cso_state_callback delete_state;
+   struct pipe_context *context;
 };
 
-
-enum cso_cache_type {
-   CSO_BLEND,
-   CSO_SAMPLER,
-   CSO_DEPTH_STENCIL_ALPHA,
-   CSO_RASTERIZER,
-   CSO_FRAGMENT_SHADER,
-   CSO_VERTEX_SHADER
+struct cso_velems_state {
+   unsigned count;
+   struct pipe_vertex_element velems[PIPE_MAX_ATTRIBS];
 };
 
-typedef void (*cso_state_callback)(void *, void *);
+struct cso_velements {
+   struct cso_velems_state state;
+   void *data;
+   cso_state_callback delete_state;
+   struct pipe_context *context;
+};
 
 unsigned cso_construct_key(void *item, int item_size);
 
 struct cso_cache *cso_cache_create(void);
 void cso_cache_delete(struct cso_cache *sc);
 
+void cso_cache_set_sanitize_callback(struct cso_cache *sc,
+                                     cso_sanitize_callback cb,
+                                     void *user_data);
+
 struct cso_hash_iter cso_insert_state(struct cso_cache *sc,
                                       unsigned hash_key, enum cso_cache_type type,
                                       void *state);
@@ -152,7 +159,7 @@ struct cso_hash_iter cso_find_state(struct cso_cache *sc,
                                     unsigned hash_key, enum cso_cache_type type);
 struct cso_hash_iter cso_find_state_template(struct cso_cache *sc,
                                              unsigned hash_key, enum cso_cache_type type,
-                                             void *templ);
+                                             void *templ, unsigned size);
 void cso_for_each_state(struct cso_cache *sc, enum cso_cache_type type,
                         cso_state_callback func, void *user_data);
 void * cso_take_state(struct cso_cache *sc, unsigned hash_key,