• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 #ifdef __cplusplus
40 extern "C" {
41 #endif
42 
43 struct st_context;
44 struct gl_vertex_program;
45 struct st_common_variant;
46 struct pipe_vertex_buffer;
47 struct pipe_vertex_element;
48 struct cso_velems_state;
49 
50 /**
51  * Enumeration of state tracker pipelines.
52  */
53 enum st_pipeline {
54    ST_PIPELINE_RENDER,
55    ST_PIPELINE_RENDER_NO_VARRAYS,
56    ST_PIPELINE_CLEAR,
57    ST_PIPELINE_META,
58    ST_PIPELINE_UPDATE_FRAMEBUFFER,
59    ST_PIPELINE_COMPUTE,
60 };
61 
62 void st_init_atoms( struct st_context *st );
63 void st_destroy_atoms( struct st_context *st );
64 void st_validate_state( struct st_context *st, enum st_pipeline pipeline );
65 void st_update_edgeflags(struct st_context *st, bool per_vertex_edgeflags);
66 
67 void
68 st_setup_arrays(struct st_context *st,
69                 const struct gl_vertex_program *vp,
70                 const struct st_common_variant *vp_variant,
71                 struct cso_velems_state *velements,
72                 struct pipe_vertex_buffer *vbuffer, unsigned *num_vbuffers,
73                 bool *has_user_vertex_buffers);
74 
75 void
76 st_setup_current_user(struct st_context *st,
77                       const struct gl_vertex_program *vp,
78                       const struct st_common_variant *vp_variant,
79                       struct cso_velems_state *velements,
80                       struct pipe_vertex_buffer *vbuffer, unsigned *num_vbuffers);
81 
82 void
83 st_update_array_with_popcnt(struct st_context *st);
84 
85 struct pipe_vertex_state *
86 st_create_gallium_vertex_state(struct gl_context *ctx,
87                                const struct gl_vertex_array_object *vao,
88                                struct gl_buffer_object *indexbuf,
89                                uint32_t enabled_attribs);
90 
91 /* Define ST_NEW_xxx_INDEX */
92 enum {
93 #define ST_STATE(FLAG, st_update) FLAG##_INDEX,
94 #include "st_atom_list.h"
95 #undef ST_STATE
96    ST_NUM_ATOMS,
97 };
98 
99 /* Define ST_NEW_xxx values as static const uint64_t values.
100  * We can't use an enum type because MSVC doesn't allow 64-bit enum values.
101  */
102 #define ST_STATE(FLAG, st_update) static const uint64_t FLAG = 1ull << FLAG##_INDEX;
103 #include "st_atom_list.h"
104 #undef ST_STATE
105 
106 /* Declare function prototypes. */
107 #define ST_STATE(FLAG, st_update) void st_update(struct st_context *st);
108 #include "st_atom_list.h"
109 #undef ST_STATE
110 
111 /* Combined state flags. */
112 #define ST_NEW_SAMPLERS         (ST_NEW_VS_SAMPLERS | \
113                                  ST_NEW_TCS_SAMPLERS | \
114                                  ST_NEW_TES_SAMPLERS | \
115                                  ST_NEW_GS_SAMPLERS | \
116                                  ST_NEW_FS_SAMPLERS | \
117                                  ST_NEW_CS_SAMPLERS)
118 
119 #define ST_NEW_FRAMEBUFFER      (ST_NEW_FB_STATE | \
120                                  ST_NEW_SAMPLE_STATE | \
121                                  ST_NEW_SAMPLE_SHADING)
122 
123 #define ST_NEW_VERTEX_PROGRAM(st, p) ((p)->affected_states | \
124                                       (st_user_clip_planes_enabled(st->ctx) ? \
125                                        ST_NEW_CLIP_STATE : 0))
126 
127 #define ST_NEW_CONSTANTS        (ST_NEW_VS_CONSTANTS | \
128                                  ST_NEW_TCS_CONSTANTS | \
129                                  ST_NEW_TES_CONSTANTS | \
130                                  ST_NEW_FS_CONSTANTS | \
131                                  ST_NEW_GS_CONSTANTS | \
132                                  ST_NEW_CS_CONSTANTS)
133 
134 #define ST_NEW_UNIFORM_BUFFER   (ST_NEW_VS_UBOS | \
135                                  ST_NEW_TCS_UBOS | \
136                                  ST_NEW_TES_UBOS | \
137                                  ST_NEW_FS_UBOS | \
138                                  ST_NEW_GS_UBOS | \
139                                  ST_NEW_CS_UBOS)
140 
141 #define ST_NEW_SAMPLER_VIEWS    (ST_NEW_VS_SAMPLER_VIEWS | \
142                                  ST_NEW_FS_SAMPLER_VIEWS | \
143                                  ST_NEW_GS_SAMPLER_VIEWS | \
144                                  ST_NEW_TCS_SAMPLER_VIEWS | \
145                                  ST_NEW_TES_SAMPLER_VIEWS | \
146                                  ST_NEW_CS_SAMPLER_VIEWS)
147 
148 #define ST_NEW_ATOMIC_BUFFER    (ST_NEW_VS_ATOMICS | \
149                                  ST_NEW_TCS_ATOMICS | \
150                                  ST_NEW_TES_ATOMICS | \
151                                  ST_NEW_FS_ATOMICS | \
152                                  ST_NEW_GS_ATOMICS | \
153                                  ST_NEW_CS_ATOMICS)
154 
155 #define ST_NEW_STORAGE_BUFFER   (ST_NEW_VS_SSBOS | \
156                                  ST_NEW_TCS_SSBOS | \
157                                  ST_NEW_TES_SSBOS | \
158                                  ST_NEW_FS_SSBOS | \
159                                  ST_NEW_GS_SSBOS | \
160                                  ST_NEW_CS_SSBOS)
161 
162 #define ST_NEW_IMAGE_UNITS      (ST_NEW_VS_IMAGES | \
163                                  ST_NEW_TCS_IMAGES | \
164                                  ST_NEW_TES_IMAGES | \
165                                  ST_NEW_GS_IMAGES | \
166                                  ST_NEW_FS_IMAGES | \
167                                  ST_NEW_CS_IMAGES)
168 
169 #define ST_ALL_SHADER_RESOURCES (ST_NEW_SAMPLER_VIEWS | \
170                                  ST_NEW_SAMPLERS | \
171                                  ST_NEW_CONSTANTS | \
172                                  ST_NEW_UNIFORM_BUFFER | \
173                                  ST_NEW_ATOMIC_BUFFER | \
174                                  ST_NEW_STORAGE_BUFFER | \
175                                  ST_NEW_IMAGE_UNITS)
176 
177 /* All state flags within each group: */
178 #define ST_PIPELINE_RENDER_STATE_MASK  (ST_NEW_CS_STATE - 1)
179 #define ST_PIPELINE_RENDER_STATE_MASK_NO_VARRAYS \
180    (ST_PIPELINE_RENDER_STATE_MASK & ~ST_NEW_VERTEX_ARRAYS)
181 #define ST_PIPELINE_COMPUTE_STATE_MASK (0xffull << ST_NEW_CS_STATE_INDEX)
182 #define ST_PIPELINE_CLEAR_STATE_MASK (ST_NEW_FB_STATE | \
183                                       ST_NEW_SCISSOR | \
184                                       ST_NEW_WINDOW_RECTANGLES)
185 #define ST_PIPELINE_META_STATE_MASK ST_PIPELINE_RENDER_STATE_MASK_NO_VARRAYS
186 /* For ReadPixels, ReadBuffer, GetSamplePosition: */
187 #define ST_PIPELINE_UPDATE_FB_STATE_MASK (ST_NEW_FB_STATE)
188 
189 #define ST_ALL_STATES_MASK (ST_PIPELINE_RENDER_STATE_MASK | \
190                             ST_PIPELINE_COMPUTE_STATE_MASK)
191 
192 #ifdef __cplusplus
193 }
194 #endif
195 
196 #endif
197