971ea35838748152e7ad6206bbf8147339870ac0
[mesa.git] / src / mesa / state_tracker / st_atom.h
1 /**************************************************************************
2 *
3 * Copyright 2003 VMware, Inc.
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 VMWARE 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 * Keith Whitwell <keithw@vmware.com>
31 */
32
33
34 #ifndef ST_ATOM_H
35 #define ST_ATOM_H
36
37 #include "main/glheader.h"
38
39 struct st_context;
40
41 /**
42 * Enumeration of state tracker pipelines.
43 */
44 enum st_pipeline {
45 ST_PIPELINE_RENDER,
46 ST_PIPELINE_COMPUTE,
47 };
48
49 struct st_tracked_state {
50 void (*update)( struct st_context *st );
51 };
52
53
54 void st_init_atoms( struct st_context *st );
55 void st_destroy_atoms( struct st_context *st );
56 void st_validate_state( struct st_context *st, enum st_pipeline pipeline );
57 GLuint st_compare_func_to_pipe(GLenum func);
58
59 enum pipe_format
60 st_pipe_vertex_format(GLenum type, GLuint size, GLenum format,
61 GLboolean normalized, GLboolean integer);
62
63
64 /* Define ST_NEW_xxx_INDEX */
65 enum {
66 #define ST_STATE(FLAG, st_update) FLAG##_INDEX,
67 #include "st_atom_list.h"
68 #undef ST_STATE
69 };
70
71 /* Define ST_NEW_xxx values as static const uint64_t values.
72 * We can't use an enum type because MSVC doesn't allow 64-bit enum values.
73 */
74 #define ST_STATE(FLAG, st_update) static const uint64_t FLAG = 1llu << FLAG##_INDEX;
75 #include "st_atom_list.h"
76 #undef ST_STATE
77
78 /* Add extern struct declarations. */
79 #define ST_STATE(FLAG, st_update) extern const struct st_tracked_state st_update;
80 #include "st_atom_list.h"
81 #undef ST_STATE
82
83 /* Combined state flags. */
84 #define ST_NEW_SAMPLERS (ST_NEW_RENDER_SAMPLERS | \
85 ST_NEW_CS_SAMPLERS)
86
87 #define ST_NEW_FRAMEBUFFER (ST_NEW_FB_STATE | \
88 ST_NEW_SAMPLE_MASK | \
89 ST_NEW_SAMPLE_SHADING)
90
91 #define ST_NEW_VERTEX_PROGRAM (ST_NEW_VS_STATE | \
92 ST_NEW_VS_SAMPLER_VIEWS | \
93 ST_NEW_VS_IMAGES | \
94 ST_NEW_VS_CONSTANTS | \
95 ST_NEW_VS_UBOS | \
96 ST_NEW_VS_ATOMICS | \
97 ST_NEW_VS_SSBOS | \
98 ST_NEW_VERTEX_ARRAYS | \
99 ST_NEW_CLIP_STATE | \
100 ST_NEW_RASTERIZER | \
101 ST_NEW_RENDER_SAMPLERS)
102
103 #define ST_NEW_TCS_RESOURCES (ST_NEW_TCS_SAMPLER_VIEWS | \
104 ST_NEW_TCS_IMAGES | \
105 ST_NEW_TCS_CONSTANTS | \
106 ST_NEW_TCS_UBOS | \
107 ST_NEW_TCS_ATOMICS | \
108 ST_NEW_TCS_SSBOS)
109
110 #define ST_NEW_TESSCTRL_PROGRAM (ST_NEW_TCS_STATE | \
111 ST_NEW_TCS_RESOURCES | \
112 ST_NEW_RENDER_SAMPLERS)
113
114 #define ST_NEW_TES_RESOURCES (ST_NEW_TES_SAMPLER_VIEWS | \
115 ST_NEW_TES_IMAGES | \
116 ST_NEW_TES_CONSTANTS | \
117 ST_NEW_TES_UBOS | \
118 ST_NEW_TES_ATOMICS | \
119 ST_NEW_TES_SSBOS)
120
121 #define ST_NEW_TESSEVAL_PROGRAM (ST_NEW_TES_STATE | \
122 ST_NEW_TES_RESOURCES | \
123 ST_NEW_RASTERIZER | \
124 ST_NEW_RENDER_SAMPLERS)
125
126 #define ST_NEW_GS_RESOURCES (ST_NEW_GS_SAMPLER_VIEWS | \
127 ST_NEW_GS_IMAGES | \
128 ST_NEW_GS_CONSTANTS | \
129 ST_NEW_GS_UBOS | \
130 ST_NEW_GS_ATOMICS | \
131 ST_NEW_GS_SSBOS)
132
133 #define ST_NEW_GEOMETRY_PROGRAM (ST_NEW_GS_STATE | \
134 ST_NEW_GS_RESOURCES | \
135 ST_NEW_RASTERIZER | \
136 ST_NEW_RENDER_SAMPLERS)
137
138 #define ST_NEW_FRAGMENT_PROGRAM (ST_NEW_FS_STATE | \
139 ST_NEW_FS_SAMPLER_VIEWS | \
140 ST_NEW_FS_IMAGES | \
141 ST_NEW_FS_CONSTANTS | \
142 ST_NEW_FS_UBOS | \
143 ST_NEW_FS_ATOMICS | \
144 ST_NEW_FS_SSBOS | \
145 ST_NEW_SAMPLE_SHADING | \
146 ST_NEW_RENDER_SAMPLERS)
147
148 #define ST_NEW_COMPUTE_PROGRAM (ST_NEW_CS_STATE | \
149 ST_NEW_CS_SAMPLER_VIEWS | \
150 ST_NEW_CS_IMAGES | \
151 ST_NEW_CS_CONSTANTS | \
152 ST_NEW_CS_UBOS | \
153 ST_NEW_CS_ATOMICS | \
154 ST_NEW_CS_SSBOS | \
155 ST_NEW_CS_SAMPLERS)
156
157 #define ST_NEW_CONSTANTS (ST_NEW_VS_CONSTANTS | \
158 ST_NEW_TCS_CONSTANTS | \
159 ST_NEW_TES_CONSTANTS | \
160 ST_NEW_FS_CONSTANTS | \
161 ST_NEW_GS_CONSTANTS | \
162 ST_NEW_CS_CONSTANTS)
163
164 #define ST_NEW_UNIFORM_BUFFER (ST_NEW_VS_UBOS | \
165 ST_NEW_TCS_UBOS | \
166 ST_NEW_TES_UBOS | \
167 ST_NEW_FS_UBOS | \
168 ST_NEW_GS_UBOS | \
169 ST_NEW_CS_UBOS)
170
171 #define ST_NEW_SAMPLER_VIEWS (ST_NEW_VS_SAMPLER_VIEWS | \
172 ST_NEW_FS_SAMPLER_VIEWS | \
173 ST_NEW_GS_SAMPLER_VIEWS | \
174 ST_NEW_TCS_SAMPLER_VIEWS | \
175 ST_NEW_TES_SAMPLER_VIEWS | \
176 ST_NEW_CS_SAMPLER_VIEWS)
177
178 #define ST_NEW_ATOMIC_BUFFER (ST_NEW_VS_ATOMICS | \
179 ST_NEW_TCS_ATOMICS | \
180 ST_NEW_TES_ATOMICS | \
181 ST_NEW_FS_ATOMICS | \
182 ST_NEW_GS_ATOMICS | \
183 ST_NEW_CS_ATOMICS)
184
185 #define ST_NEW_STORAGE_BUFFER (ST_NEW_VS_SSBOS | \
186 ST_NEW_TCS_SSBOS | \
187 ST_NEW_TES_SSBOS | \
188 ST_NEW_FS_SSBOS | \
189 ST_NEW_GS_SSBOS | \
190 ST_NEW_CS_SSBOS)
191
192 #define ST_NEW_IMAGE_UNITS (ST_NEW_VS_IMAGES | \
193 ST_NEW_TCS_IMAGES | \
194 ST_NEW_TES_IMAGES | \
195 ST_NEW_GS_IMAGES | \
196 ST_NEW_FS_IMAGES | \
197 ST_NEW_CS_IMAGES)
198
199 /* All state flags within each group: */
200 #define ST_PIPELINE_RENDER_STATE_MASK (ST_NEW_CS_STATE - 1)
201 #define ST_PIPELINE_COMPUTE_STATE_MASK (ST_NEW_COMPUTE_PROGRAM | \
202 ST_NEW_CS_SAMPLERS)
203
204 #define ST_ALL_STATES_MASK (ST_PIPELINE_RENDER_STATE_MASK | \
205 ST_PIPELINE_COMPUTE_STATE_MASK)
206
207 #endif