replace _mesa_logbase2 with util_logbase2
[mesa.git] / src / mesa / state_tracker / st_atom.h
index 31bb2dd98bfb8815cfa19732cc63e63df342d335..dc7aa135ac671941a4f601a44bea492b1d876f97 100644 (file)
 
 #include "main/glheader.h"
 
-#include "state_tracker/st_api.h"
-#include "state_tracker/st_context.h"
-
 struct st_context;
-struct st_tracked_state;
+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,
+};
 
 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);
 
+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_validate_state( struct st_context *st, enum st_pipeline pipeline );
+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 {
+#define ST_STATE(FLAG, st_update) FLAG##_INDEX,
+#include "st_atom_list.h"
+#undef ST_STATE
+};
 
-extern const struct st_tracked_state st_update_array;
-extern const struct st_tracked_state st_update_framebuffer;
-extern const struct st_tracked_state st_update_clip;
-extern const struct st_tracked_state st_update_depth_stencil_alpha;
-extern const struct st_tracked_state st_update_fp;
-extern const struct st_tracked_state st_update_gp;
-extern const struct st_tracked_state st_update_tep;
-extern const struct st_tracked_state st_update_tcp;
-extern const struct st_tracked_state st_update_vp;
-extern const struct st_tracked_state st_update_cp;
-extern const struct st_tracked_state st_update_rasterizer;
-extern const struct st_tracked_state st_update_polygon_stipple;
-extern const struct st_tracked_state st_update_viewport;
-extern const struct st_tracked_state st_update_scissor;
-extern const struct st_tracked_state st_update_blend;
-extern const struct st_tracked_state st_update_msaa;
-extern const struct st_tracked_state st_update_sample_shading;
-extern const struct st_tracked_state st_update_sampler;
-extern const struct st_tracked_state st_update_fragment_texture;
-extern const struct st_tracked_state st_update_vertex_texture;
-extern const struct st_tracked_state st_update_geometry_texture;
-extern const struct st_tracked_state st_update_tessctrl_texture;
-extern const struct st_tracked_state st_update_tesseval_texture;
-extern const struct st_tracked_state st_update_compute_texture;
-extern const struct st_tracked_state st_update_fs_constants;
-extern const struct st_tracked_state st_update_gs_constants;
-extern const struct st_tracked_state st_update_tes_constants;
-extern const struct st_tracked_state st_update_tcs_constants;
-extern const struct st_tracked_state st_update_vs_constants;
-extern const struct st_tracked_state st_update_cs_constants;
-extern const struct st_tracked_state st_bind_fs_ubos;
-extern const struct st_tracked_state st_bind_vs_ubos;
-extern const struct st_tracked_state st_bind_gs_ubos;
-extern const struct st_tracked_state st_bind_tcs_ubos;
-extern const struct st_tracked_state st_bind_tes_ubos;
-extern const struct st_tracked_state st_bind_cs_ubos;
-extern const struct st_tracked_state st_bind_fs_atomics;
-extern const struct st_tracked_state st_bind_vs_atomics;
-extern const struct st_tracked_state st_bind_gs_atomics;
-extern const struct st_tracked_state st_bind_tcs_atomics;
-extern const struct st_tracked_state st_bind_tes_atomics;
-extern const struct st_tracked_state st_bind_cs_atomics;
-extern const struct st_tracked_state st_bind_fs_ssbos;
-extern const struct st_tracked_state st_bind_vs_ssbos;
-extern const struct st_tracked_state st_bind_gs_ssbos;
-extern const struct st_tracked_state st_bind_tcs_ssbos;
-extern const struct st_tracked_state st_bind_tes_ssbos;
-extern const struct st_tracked_state st_bind_cs_ssbos;
-extern const struct st_tracked_state st_bind_fs_images;
-extern const struct st_tracked_state st_bind_vs_images;
-extern const struct st_tracked_state st_bind_gs_images;
-extern const struct st_tracked_state st_bind_tcs_images;
-extern const struct st_tracked_state st_bind_tes_images;
-extern const struct st_tracked_state st_bind_cs_images;
-extern const struct st_tracked_state st_update_pixel_transfer;
-extern const struct st_tracked_state st_update_tess;
+/* 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
 
+/* Declare function prototypes. */
+#define ST_STATE(FLAG, st_update) void st_update(struct st_context *st);
+#include "st_atom_list.h"
+#undef ST_STATE
 
-GLuint st_compare_func_to_pipe(GLenum func);
+/* Combined state flags. */
+#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_STATE | \
+                                 ST_NEW_SAMPLE_SHADING)
+
+#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 | \
+                                 ST_NEW_TES_CONSTANTS | \
+                                 ST_NEW_FS_CONSTANTS | \
+                                 ST_NEW_GS_CONSTANTS | \
+                                 ST_NEW_CS_CONSTANTS)
+
+#define ST_NEW_UNIFORM_BUFFER   (ST_NEW_VS_UBOS | \
+                                 ST_NEW_TCS_UBOS | \
+                                 ST_NEW_TES_UBOS | \
+                                 ST_NEW_FS_UBOS | \
+                                 ST_NEW_GS_UBOS | \
+                                 ST_NEW_CS_UBOS)
+
+#define ST_NEW_SAMPLER_VIEWS    (ST_NEW_VS_SAMPLER_VIEWS | \
+                                 ST_NEW_FS_SAMPLER_VIEWS | \
+                                 ST_NEW_GS_SAMPLER_VIEWS | \
+                                 ST_NEW_TCS_SAMPLER_VIEWS | \
+                                 ST_NEW_TES_SAMPLER_VIEWS | \
+                                 ST_NEW_CS_SAMPLER_VIEWS)
+
+#define ST_NEW_ATOMIC_BUFFER    (ST_NEW_VS_ATOMICS | \
+                                 ST_NEW_TCS_ATOMICS | \
+                                 ST_NEW_TES_ATOMICS | \
+                                 ST_NEW_FS_ATOMICS | \
+                                 ST_NEW_GS_ATOMICS | \
+                                 ST_NEW_CS_ATOMICS)
+
+#define ST_NEW_STORAGE_BUFFER   (ST_NEW_VS_SSBOS | \
+                                 ST_NEW_TCS_SSBOS | \
+                                 ST_NEW_TES_SSBOS | \
+                                 ST_NEW_FS_SSBOS | \
+                                 ST_NEW_GS_SSBOS | \
+                                 ST_NEW_CS_SSBOS)
+
+#define ST_NEW_IMAGE_UNITS      (ST_NEW_VS_IMAGES | \
+                                 ST_NEW_TCS_IMAGES | \
+                                 ST_NEW_TES_IMAGES | \
+                                 ST_NEW_GS_IMAGES | \
+                                 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 (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)
 
-enum pipe_format
-st_pipe_vertex_format(GLenum type, GLuint size, GLenum format,
-                      GLboolean normalized, GLboolean integer);
+#define ST_ALL_STATES_MASK (ST_PIPELINE_RENDER_STATE_MASK | \
+                            ST_PIPELINE_COMPUTE_STATE_MASK)
 
 #endif