b4f4f3ae41734ec01f1b311066eeb98cc47bcaea
[mesa.git] / src / gallium / auxiliary / cso_cache / cso_cache.h
1 /**************************************************************************
2 *
3 * Copyright 2007 Tungsten Graphics, Inc., Cedar Park, Texas.
4 * All Rights Reserved.
5 *
6 * Permission is hereby granted, free of charge, to any person obtaining a
7 * copy of this software and associated documentation files (the
8 * "Software"), to deal in the Software without restriction, including
9 * without limitation the rights to use, copy, modify, merge, publish,
10 * distribute, sub license, and/or sell copies of the Software, and to
11 * permit persons to whom the Software is furnished to do so, subject to
12 * the following conditions:
13 *
14 * The above copyright notice and this permission notice (including the
15 * next paragraph) shall be included in all copies or substantial portions
16 * of the Software.
17 *
18 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
19 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
20 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
21 * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR
22 * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
23 * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
24 * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
25 *
26 **************************************************************************/
27
28 /*
29 * Authors:
30 * Zack Rusin <zack@tungstengraphics.com>
31 */
32
33 #ifndef CSO_CACHE_H
34 #define CSO_CACHE_H
35
36 #include "pipe/p_context.h"
37 #include "pipe/p_state.h"
38
39 #include "cso_hash.h" /* for cso_hash_iter, as MSVC requires structures returned by value to be fully defined */
40
41
42 #ifdef __cplusplus
43 extern "C" {
44 #endif
45
46
47 struct cso_cache {
48 struct cso_hash *blend_hash;
49 struct cso_hash *depth_stencil_hash;
50 struct cso_hash *fs_hash;
51 struct cso_hash *vs_hash;
52 struct cso_hash *rasterizer_hash;
53 struct cso_hash *sampler_hash;
54 };
55
56 struct cso_blend {
57 struct pipe_blend_state state;
58 void *data;
59 };
60
61 struct cso_depth_stencil_alpha {
62 struct pipe_depth_stencil_alpha_state state;
63 void *data;
64 };
65
66 struct cso_rasterizer {
67 struct pipe_rasterizer_state state;
68 void *data;
69 };
70
71 struct cso_fragment_shader {
72 struct pipe_shader_state state;
73 void *data;
74 };
75
76 struct cso_vertex_shader {
77 struct pipe_shader_state state;
78 void *data;
79 };
80
81 struct cso_sampler {
82 struct pipe_sampler_state state;
83 void *data;
84 };
85
86
87 enum cso_cache_type {
88 CSO_BLEND,
89 CSO_SAMPLER,
90 CSO_DEPTH_STENCIL_ALPHA,
91 CSO_RASTERIZER,
92 CSO_FRAGMENT_SHADER,
93 CSO_VERTEX_SHADER
94 };
95
96 unsigned cso_construct_key(void *item, int item_size);
97
98 struct cso_cache *cso_cache_create(void);
99 void cso_cache_delete(struct cso_cache *sc);
100
101 struct cso_hash_iter cso_insert_state(struct cso_cache *sc,
102 unsigned hash_key, enum cso_cache_type type,
103 void *state);
104 struct cso_hash_iter cso_find_state(struct cso_cache *sc,
105 unsigned hash_key, enum cso_cache_type type);
106 struct cso_hash_iter cso_find_state_template(struct cso_cache *sc,
107 unsigned hash_key, enum cso_cache_type type,
108 void *templ);
109 void * cso_take_state(struct cso_cache *sc, unsigned hash_key,
110 enum cso_cache_type type);
111
112
113 #ifdef __cplusplus
114 }
115 #endif
116
117 #endif