xref: /aosp_15_r20/external/mesa3d/src/mesa/state_tracker/st_atom.h (revision 6104692788411f58d303aa86923a9ff6ecaded22)
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 <[email protected]>
31   */
32 
33 
34 #ifndef ST_ATOM_H
35 #define ST_ATOM_H
36 
37 #include "util/glheader.h"
38 #include "main/mtypes.h"
39 
40 #ifdef __cplusplus
41 extern "C" {
42 #endif
43 
44 struct st_context;
45 struct gl_vertex_program;
46 struct st_common_variant;
47 struct pipe_vertex_buffer;
48 struct pipe_vertex_element;
49 struct cso_velems_state;
50 
51 void
52 st_setup_arrays(struct st_context *st,
53                 const struct gl_vertex_program *vp,
54                 const struct st_common_variant *vp_variant,
55                 struct cso_velems_state *velements,
56                 struct pipe_vertex_buffer *vbuffer, unsigned *num_vbuffers);
57 
58 void
59 st_setup_current_user(struct st_context *st,
60                       const struct gl_vertex_program *vp,
61                       const struct st_common_variant *vp_variant,
62                       struct cso_velems_state *velements,
63                       struct pipe_vertex_buffer *vbuffer, unsigned *num_vbuffers);
64 
65 void
66 st_init_update_array(struct st_context *st);
67 
68 struct pipe_vertex_state *
69 st_create_gallium_vertex_state(struct gl_context *ctx,
70                                const struct gl_vertex_array_object *vao,
71                                struct gl_buffer_object *indexbuf,
72                                uint32_t enabled_attribs);
73 
74 /* Define ST_NEW_xxx_INDEX */
75 enum {
76 #define ST_STATE(FLAG, st_update) FLAG##_INDEX,
77 #include "st_atom_list.h"
78 #undef ST_STATE
79    ST_NUM_ATOMS,
80 };
81 
82 /* Define ST_NEW_xxx values as static const uint64_t values.
83  * We can't use an enum type because MSVC doesn't allow 64-bit enum values.
84  */
85 #define ST_STATE(FLAG, st_update) static const uint64_t FLAG = 1ull << FLAG##_INDEX;
86 #include "st_atom_list.h"
87 #undef ST_STATE
88 
89 /* Declare function prototypes. */
90 #define ST_STATE(FLAG, st_update) void st_update(struct st_context *st);
91 #include "st_atom_list.h"
92 #undef ST_STATE
93 
94 /* Combined state flags. */
95 #define ST_NEW_SAMPLERS         (ST_NEW_VS_SAMPLERS | \
96                                  ST_NEW_TCS_SAMPLERS | \
97                                  ST_NEW_TES_SAMPLERS | \
98                                  ST_NEW_GS_SAMPLERS | \
99                                  ST_NEW_FS_SAMPLERS | \
100                                  ST_NEW_CS_SAMPLERS)
101 
102 #define ST_NEW_FRAMEBUFFER      (ST_NEW_FB_STATE | \
103                                  ST_NEW_SAMPLE_STATE | \
104                                  ST_NEW_SAMPLE_SHADING)
105 
106 #define ST_NEW_VERTEX_PROGRAM(ctx, p) ((p)->affected_states | \
107                                       (st_user_clip_planes_enabled(ctx) ? \
108                                        ST_NEW_CLIP_STATE : 0))
109 
110 #define ST_NEW_CONSTANTS        (ST_NEW_VS_CONSTANTS | \
111                                  ST_NEW_TCS_CONSTANTS | \
112                                  ST_NEW_TES_CONSTANTS | \
113                                  ST_NEW_FS_CONSTANTS | \
114                                  ST_NEW_GS_CONSTANTS | \
115                                  ST_NEW_CS_CONSTANTS)
116 
117 #define ST_NEW_UNIFORM_BUFFER   (ST_NEW_VS_UBOS | \
118                                  ST_NEW_TCS_UBOS | \
119                                  ST_NEW_TES_UBOS | \
120                                  ST_NEW_FS_UBOS | \
121                                  ST_NEW_GS_UBOS | \
122                                  ST_NEW_CS_UBOS)
123 
124 #define ST_NEW_SAMPLER_VIEWS    (ST_NEW_VS_SAMPLER_VIEWS | \
125                                  ST_NEW_FS_SAMPLER_VIEWS | \
126                                  ST_NEW_GS_SAMPLER_VIEWS | \
127                                  ST_NEW_TCS_SAMPLER_VIEWS | \
128                                  ST_NEW_TES_SAMPLER_VIEWS | \
129                                  ST_NEW_CS_SAMPLER_VIEWS)
130 
131 #define ST_NEW_ATOMIC_BUFFER    (ST_NEW_VS_ATOMICS | \
132                                  ST_NEW_TCS_ATOMICS | \
133                                  ST_NEW_TES_ATOMICS | \
134                                  ST_NEW_FS_ATOMICS | \
135                                  ST_NEW_GS_ATOMICS | \
136                                  ST_NEW_CS_ATOMICS)
137 
138 #define ST_NEW_STORAGE_BUFFER   (ST_NEW_VS_SSBOS | \
139                                  ST_NEW_TCS_SSBOS | \
140                                  ST_NEW_TES_SSBOS | \
141                                  ST_NEW_FS_SSBOS | \
142                                  ST_NEW_GS_SSBOS | \
143                                  ST_NEW_CS_SSBOS)
144 
145 #define ST_NEW_IMAGE_UNITS      (ST_NEW_VS_IMAGES | \
146                                  ST_NEW_TCS_IMAGES | \
147                                  ST_NEW_TES_IMAGES | \
148                                  ST_NEW_GS_IMAGES | \
149                                  ST_NEW_FS_IMAGES | \
150                                  ST_NEW_CS_IMAGES)
151 
152 #define ST_ALL_SHADER_RESOURCES (ST_NEW_SAMPLER_VIEWS | \
153                                  ST_NEW_SAMPLERS | \
154                                  ST_NEW_UNIFORM_BUFFER | \
155                                  ST_NEW_ATOMIC_BUFFER | \
156                                  ST_NEW_STORAGE_BUFFER | \
157                                  ST_NEW_IMAGE_UNITS)
158 
159 /* All state flags within each group: */
160 #define ST_PIPELINE_RENDER_STATE_MASK  (ST_NEW_CS_STATE - 1)
161 #define ST_PIPELINE_RENDER_STATE_MASK_NO_VARRAYS \
162    (ST_PIPELINE_RENDER_STATE_MASK & ~ST_NEW_VERTEX_ARRAYS)
163 #define ST_PIPELINE_CLEAR_STATE_MASK (ST_NEW_FB_STATE | \
164                                       ST_NEW_SCISSOR | \
165                                       ST_NEW_WINDOW_RECTANGLES)
166 #define ST_PIPELINE_META_STATE_MASK ST_PIPELINE_RENDER_STATE_MASK_NO_VARRAYS
167 /* For ReadPixels, ReadBuffer, GetSamplePosition: */
168 #define ST_PIPELINE_UPDATE_FB_STATE_MASK (ST_NEW_FB_STATE)
169 
170 /* We add the ST_NEW_FB_STATE bit here as well, because glBindFramebuffer
171  * acts as a barrier that breaks feedback loops between the framebuffer
172  * and textures bound to the framebuffer, even when those textures are
173  * accessed by compute shaders; so we must inform the driver of new
174  * framebuffer state.
175  */
176 #define ST_PIPELINE_COMPUTE_STATE_MASK ((0xffull << ST_NEW_CS_STATE_INDEX) | \
177                                         ST_NEW_FB_STATE)
178 
179 #define ST_ALL_STATES_MASK (ST_PIPELINE_RENDER_STATE_MASK | \
180                             ST_PIPELINE_COMPUTE_STATE_MASK)
181 
182 #ifdef __cplusplus
183 }
184 #endif
185 
186 #endif
187