replace _mesa_logbase2 with util_logbase2
[mesa.git] / src / mesa / state_tracker / st_atom.h
index c7cffd85c8a89d03b2c729622108e29bce2077a8..dc7aa135ac671941a4f601a44bea492b1d876f97 100644 (file)
@@ -1,6 +1,6 @@
 /**************************************************************************
  * 
- * Copyright 2003 Tungsten Graphics, Inc., Cedar Park, Texas.
+ * Copyright 2003 VMware, Inc.
  * All Rights Reserved.
  * 
  * Permission is hereby granted, free of charge, to any person obtaining a
@@ -18,7 +18,7 @@
  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
  * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
- * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR
+ * IN NO EVENT SHALL VMWARE AND/OR ITS SUPPLIERS BE LIABLE FOR
  * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
  * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
  * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 
  /*
   * Authors:
-  *   Keith Whitwell <keith@tungstengraphics.com>
+  *   Keith Whitwell <keithw@vmware.com>
   */
     
 
 #ifndef ST_ATOM_H
 #define ST_ATOM_H
 
+#include "main/glheader.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_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
+};
+
+/* 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
+
+/* 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)
 
-void st_validate_state( struct st_context *st );
+#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)
 
-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_shader;
-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_sampler;
-extern const struct st_tracked_state st_update_texture;
-extern const struct st_tracked_state st_finalize_textures;
-extern const struct st_tracked_state st_update_fs_constants;
-extern const struct st_tracked_state st_update_vs_constants;
-extern const struct st_tracked_state st_update_pixel_transfer;
+#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)
 
-uint st_compare_func_to_pipe(GLenum func);
+#define ST_ALL_STATES_MASK (ST_PIPELINE_RENDER_STATE_MASK | \
+                            ST_PIPELINE_COMPUTE_STATE_MASK)
 
 #endif