replace _mesa_logbase2 with util_logbase2
[mesa.git] / src / mesa / state_tracker / st_atom.h
index 961c395b89db6eafaf46576cee7abd5eba1bc7e2..dc7aa135ac671941a4f601a44bea492b1d876f97 100644 (file)
 #include "main/glheader.h"
 
 struct st_context;
+struct st_vertex_program;
+struct st_common_variant;
+struct pipe_vertex_buffer;
+struct pipe_vertex_element;
+struct cso_velems_state;
 
 /**
  * Enumeration of state tracker pipelines.
  */
 enum st_pipeline {
    ST_PIPELINE_RENDER,
+   ST_PIPELINE_CLEAR,
+   ST_PIPELINE_META,
+   ST_PIPELINE_UPDATE_FRAMEBUFFER,
    ST_PIPELINE_COMPUTE,
 };
 
-struct st_tracked_state {
-   void (*update)( struct st_context *st );
-};
-
-
 void st_init_atoms( struct st_context *st );
 void st_destroy_atoms( struct st_context *st );
 void st_validate_state( struct st_context *st, enum st_pipeline pipeline );
 GLuint st_compare_func_to_pipe(GLenum func);
 
-enum pipe_format
-st_pipe_vertex_format(GLenum type, GLuint size, GLenum format,
-                      GLboolean normalized, GLboolean integer);
-
+void
+st_setup_arrays(struct st_context *st,
+                const struct st_vertex_program *vp,
+                const struct st_common_variant *vp_variant,
+                struct cso_velems_state *velements,
+                struct pipe_vertex_buffer *vbuffer, unsigned *num_vbuffers,
+                bool *has_user_vertex_buffers);
+
+void
+st_setup_current_user(struct st_context *st,
+                      const struct st_vertex_program *vp,
+                      const struct st_common_variant *vp_variant,
+                      struct cso_velems_state *velements,
+                      struct pipe_vertex_buffer *vbuffer, unsigned *num_vbuffers);
 
 /* Define ST_NEW_xxx_INDEX */
 enum {
@@ -68,85 +81,33 @@ enum {
 #undef ST_STATE
 };
 
-/* Define ST_NEW_xxx */
-enum {
-#define ST_STATE(FLAG, st_update) FLAG = 1llu << FLAG##_INDEX,
+/* Define ST_NEW_xxx values as static const uint64_t values.
+ * We can't use an enum type because MSVC doesn't allow 64-bit enum values.
+ */
+#define ST_STATE(FLAG, st_update) static const uint64_t FLAG = 1ull << FLAG##_INDEX;
 #include "st_atom_list.h"
 #undef ST_STATE
-};
 
-/* Add extern struct declarations. */
-#define ST_STATE(FLAG, st_update) extern const struct st_tracked_state st_update;
+/* Declare function prototypes. */
+#define ST_STATE(FLAG, st_update) void st_update(struct st_context *st);
 #include "st_atom_list.h"
 #undef ST_STATE
 
 /* Combined state flags. */
-#define ST_NEW_SAMPLERS         (ST_NEW_RENDER_SAMPLERS | \
+#define ST_NEW_SAMPLERS         (ST_NEW_VS_SAMPLERS | \
+                                 ST_NEW_TCS_SAMPLERS | \
+                                 ST_NEW_TES_SAMPLERS | \
+                                 ST_NEW_GS_SAMPLERS | \
+                                 ST_NEW_FS_SAMPLERS | \
                                  ST_NEW_CS_SAMPLERS)
 
 #define ST_NEW_FRAMEBUFFER      (ST_NEW_FB_STATE | \
-                                 ST_NEW_SAMPLE_MASK | \
+                                 ST_NEW_SAMPLE_STATE | \
                                  ST_NEW_SAMPLE_SHADING)
 
-#define ST_NEW_VERTEX_PROGRAM   (ST_NEW_VS_STATE | \
-                                 ST_NEW_VS_SAMPLER_VIEWS | \
-                                 ST_NEW_VS_IMAGES | \
-                                 ST_NEW_VS_CONSTANTS | \
-                                 ST_NEW_VS_UBOS | \
-                                 ST_NEW_VS_ATOMICS | \
-                                 ST_NEW_VS_SSBOS | \
-                                 ST_NEW_VERTEX_ARRAYS | \
-                                 ST_NEW_CLIP_STATE | \
-                                 ST_NEW_RASTERIZER)
-
-#define ST_NEW_TCS_RESOURCES    (ST_NEW_TCS_SAMPLER_VIEWS | \
-                                 ST_NEW_TCS_IMAGES | \
-                                 ST_NEW_TCS_CONSTANTS | \
-                                 ST_NEW_TCS_UBOS | \
-                                 ST_NEW_TCS_ATOMICS | \
-                                 ST_NEW_TCS_SSBOS)
-
-#define ST_NEW_TESSCTRL_PROGRAM (ST_NEW_TCS_STATE | \
-                                 ST_NEW_TCS_RESOURCES)
-
-#define ST_NEW_TES_RESOURCES    (ST_NEW_TES_SAMPLER_VIEWS | \
-                                 ST_NEW_TES_IMAGES | \
-                                 ST_NEW_TES_CONSTANTS | \
-                                 ST_NEW_TES_UBOS | \
-                                 ST_NEW_TES_ATOMICS | \
-                                 ST_NEW_TES_SSBOS)
-
-#define ST_NEW_TESSEVAL_PROGRAM (ST_NEW_TES_STATE | \
-                                 ST_NEW_TES_RESOURCES | \
-                                 ST_NEW_RASTERIZER)
-
-#define ST_NEW_GS_RESOURCES     (ST_NEW_GS_SAMPLER_VIEWS | \
-                                 ST_NEW_GS_IMAGES | \
-                                 ST_NEW_GS_CONSTANTS | \
-                                 ST_NEW_GS_UBOS | \
-                                 ST_NEW_GS_ATOMICS | \
-                                 ST_NEW_GS_SSBOS)
-
-#define ST_NEW_GEOMETRY_PROGRAM (ST_NEW_GS_STATE | \
-                                 ST_NEW_GS_RESOURCES | \
-                                 ST_NEW_RASTERIZER)
-
-#define ST_NEW_FRAGMENT_PROGRAM (ST_NEW_FS_STATE | \
-                                 ST_NEW_FS_SAMPLER_VIEWS | \
-                                 ST_NEW_FS_IMAGES | \
-                                 ST_NEW_FS_CONSTANTS | \
-                                 ST_NEW_FS_UBOS | \
-                                 ST_NEW_FS_ATOMICS | \
-                                 ST_NEW_FS_SSBOS | \
-                                 ST_NEW_SAMPLE_SHADING)
-
-#define ST_NEW_COMPUTE_PROGRAM  (ST_NEW_CS_STATE | \
-                                 ST_NEW_CS_SAMPLER_VIEWS | \
-                                 ST_NEW_CS_IMAGES | \
-                                 ST_NEW_CS_CONSTANTS | \
-                                 ST_NEW_CS_UBOS | \
-                                 ST_NEW_CS_ATOMICS | \
-                                 ST_NEW_CS_SSBOS)
+#define ST_NEW_VERTEX_PROGRAM(st, p) ((p)->affected_states | \
+                                      (st_user_clip_planes_enabled(st->ctx) ? \
+                                       ST_NEW_CLIP_STATE : 0))
 
 #define ST_NEW_CONSTANTS        (ST_NEW_VS_CONSTANTS | \
                                  ST_NEW_TCS_CONSTANTS | \
@@ -190,10 +151,24 @@ enum {
                                  ST_NEW_FS_IMAGES | \
                                  ST_NEW_CS_IMAGES)
 
+#define ST_ALL_SHADER_RESOURCES (ST_NEW_SAMPLER_VIEWS | \
+                                 ST_NEW_SAMPLERS | \
+                                 ST_NEW_CONSTANTS | \
+                                 ST_NEW_UNIFORM_BUFFER | \
+                                 ST_NEW_ATOMIC_BUFFER | \
+                                 ST_NEW_STORAGE_BUFFER | \
+                                 ST_NEW_IMAGE_UNITS)
+
 /* All state flags within each group: */
 #define ST_PIPELINE_RENDER_STATE_MASK  (ST_NEW_CS_STATE - 1)
-#define ST_PIPELINE_COMPUTE_STATE_MASK (ST_NEW_COMPUTE_PROGRAM | \
-                                        ST_NEW_CS_SAMPLERS)
+#define ST_PIPELINE_COMPUTE_STATE_MASK (0xffull << ST_NEW_CS_STATE_INDEX)
+#define ST_PIPELINE_CLEAR_STATE_MASK (ST_NEW_FB_STATE | \
+                                      ST_NEW_SCISSOR | \
+                                      ST_NEW_WINDOW_RECTANGLES)
+#define ST_PIPELINE_META_STATE_MASK (ST_PIPELINE_RENDER_STATE_MASK & \
+                                     ~ST_NEW_VERTEX_ARRAYS)
+/* For ReadPixels, ReadBuffer, GetSamplePosition: */
+#define ST_PIPELINE_UPDATE_FB_STATE_MASK (ST_NEW_FB_STATE)
 
 #define ST_ALL_STATES_MASK (ST_PIPELINE_RENDER_STATE_MASK | \
                             ST_PIPELINE_COMPUTE_STATE_MASK)