cso_cache.h

Go to the documentation of this file.
00001 /**************************************************************************
00002  *
00003  * Copyright 2007-2008 Tungsten Graphics, Inc., Cedar Park, Texas.
00004  * All Rights Reserved.
00005  *
00006  * Permission is hereby granted, free of charge, to any person obtaining a
00007  * copy of this software and associated documentation files (the
00008  * "Software"), to deal in the Software without restriction, including
00009  * without limitation the rights to use, copy, modify, merge, publish,
00010  * distribute, sub license, and/or sell copies of the Software, and to
00011  * permit persons to whom the Software is furnished to do so, subject to
00012  * the following conditions:
00013  *
00014  * The above copyright notice and this permission notice (including the
00015  * next paragraph) shall be included in all copies or substantial portions
00016  * of the Software.
00017  *
00018  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
00019  * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
00020  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
00021  * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR
00022  * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
00023  * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
00024  * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
00025  *
00026  **************************************************************************/
00027 
00072 #ifndef CSO_CACHE_H
00073 #define CSO_CACHE_H
00074 
00075 #include "pipe/p_context.h"
00076 #include "pipe/p_state.h"
00077 
00078 /* cso_hash.h is necessary for cso_hash_iter, as MSVC requires structures
00079  * returned by value to be fully defined */
00080 #include "cso_hash.h"
00081 
00082 
00083 #ifdef  __cplusplus
00084 extern "C" {
00085 #endif
00086 
00087 enum cso_cache_type {
00088    CSO_BLEND,
00089    CSO_SAMPLER,
00090    CSO_DEPTH_STENCIL_ALPHA,
00091    CSO_RASTERIZER,
00092    CSO_FRAGMENT_SHADER,
00093    CSO_VERTEX_SHADER
00094 };
00095 
00096 typedef void (*cso_state_callback)(void *ctx, void *obj);
00097 
00098 typedef void (*cso_sanitize_callback)(struct cso_hash *hash,
00099                                       enum cso_cache_type type,
00100                                       int max_size,
00101                                       void *user_data);
00102 
00103 struct cso_cache;
00104 
00105 struct cso_blend {
00106    struct pipe_blend_state state;
00107    void *data;
00108    cso_state_callback delete_state;
00109    struct pipe_context *context;
00110 };
00111 
00112 struct cso_depth_stencil_alpha {
00113    struct pipe_depth_stencil_alpha_state state;
00114    void *data;
00115    cso_state_callback delete_state;
00116    struct pipe_context *context;
00117 };
00118 
00119 struct cso_rasterizer {
00120    struct pipe_rasterizer_state state;
00121    void *data;
00122    cso_state_callback delete_state;
00123    struct pipe_context *context;
00124 };
00125 
00126 struct cso_fragment_shader {
00127    struct pipe_shader_state state;
00128    void *data;
00129    cso_state_callback delete_state;
00130    struct pipe_context *context;
00131 };
00132 
00133 struct cso_vertex_shader {
00134    struct pipe_shader_state state;
00135    void *data;
00136    cso_state_callback delete_state;
00137    struct pipe_context *context;
00138 };
00139 
00140 struct cso_sampler {
00141    struct pipe_sampler_state state;
00142    void *data;
00143    cso_state_callback delete_state;
00144    struct pipe_context *context;
00145 };
00146 
00147 unsigned cso_construct_key(void *item, int item_size);
00148 
00149 struct cso_cache *cso_cache_create(void);
00150 void cso_cache_delete(struct cso_cache *sc);
00151 
00152 void cso_cache_set_sanitize_callback(struct cso_cache *sc,
00153                                      cso_sanitize_callback cb,
00154                                      void *user_data);
00155 
00156 struct cso_hash_iter cso_insert_state(struct cso_cache *sc,
00157                                       unsigned hash_key, enum cso_cache_type type,
00158                                       void *state);
00159 struct cso_hash_iter cso_find_state(struct cso_cache *sc,
00160                                     unsigned hash_key, enum cso_cache_type type);
00161 struct cso_hash_iter cso_find_state_template(struct cso_cache *sc,
00162                                              unsigned hash_key, enum cso_cache_type type,
00163                                              void *templ);
00164 void cso_for_each_state(struct cso_cache *sc, enum cso_cache_type type,
00165                         cso_state_callback func, void *user_data);
00166 void * cso_take_state(struct cso_cache *sc, unsigned hash_key,
00167                       enum cso_cache_type type);
00168 
00169 void cso_set_maximum_cache_size(struct cso_cache *sc, int number);
00170 int cso_maximum_cache_size(const struct cso_cache *sc);
00171 
00172 #ifdef  __cplusplus
00173 }
00174 #endif
00175 
00176 #endif

Generated on Tue Sep 29 06:25:14 2009 for Gallium3D by  doxygen 1.5.4