draw: rewrite primitive assembler
[mesa.git] / src / gallium / auxiliary / draw / draw_private.h
index f30f9af388b7329ad1ed44a42e53520f119acae4..ba93b09337753508e413aca2ca075a25d6a96265 100644 (file)
@@ -55,6 +55,10 @@ struct gallivm_state;
 /** Sum of frustum planes and user-defined planes */
 #define DRAW_TOTAL_CLIP_PLANES (6 + PIPE_MAX_CLIP_PLANES)
 
+/**
+ * The largest possible index of a vertex that can be fetched.
+ */
+#define DRAW_MAX_FETCH_IDX 0xffffffff
 
 struct pipe_context;
 struct draw_vertex_shader;
@@ -64,6 +68,7 @@ struct vbuf_render;
 struct tgsi_exec_machine;
 struct tgsi_sampler;
 struct draw_pt_front_end;
+struct draw_assembler;
 
 
 /**
@@ -71,7 +76,7 @@ struct draw_pt_front_end;
  */
 struct draw_vertex_buffer {
    const void *map;
-   size_t size;
+   uint32_t size;
 };
 
 /**
@@ -306,6 +311,8 @@ struct draw_context
    } extra_shader_outputs;
 
    unsigned instance_id;
+   unsigned start_instance;
+   unsigned start_index;
 
 #ifdef HAVE_LLVM
    struct draw_llvm *llvm;
@@ -324,6 +331,8 @@ struct draw_context
    struct pipe_query_data_pipeline_statistics statistics;
    boolean collect_statistics;
 
+   struct draw_assembler *ia;
+
    void *driver_private;
 };
 
@@ -389,6 +398,9 @@ uint draw_current_shader_position_output(const struct draw_context *draw);
 uint draw_current_shader_viewport_index_output(const struct draw_context *draw);
 uint draw_current_shader_clipvertex_output(const struct draw_context *draw);
 uint draw_current_shader_clipdistance_output(const struct draw_context *draw, int index);
+uint draw_current_shader_num_written_clipdistances(const struct draw_context *draw);
+uint draw_current_shader_culldistance_output(const struct draw_context *draw, int index);
+uint draw_current_shader_num_written_culldistances(const struct draw_context *draw);
 int draw_alloc_extra_vertex_attrib(struct draw_context *draw,
                                    uint semantic_name, uint semantic_index);
 void draw_remove_extra_vertex_attribs(struct draw_context *draw);
@@ -460,14 +472,17 @@ draw_get_rasterizer_no_cull( struct draw_context *draw,
                              boolean scissor,
                              boolean flatshade );
 
+void
+draw_stats_clipper_primitives(struct draw_context *draw,
+                              const struct draw_prim_info *prim_info);
 
 /** 
  * Return index i from the index buffer.
  * If the index buffer would overflow we return the
- * index of the first element in the vb.
+ * maximum possible index.
  */
 #define DRAW_GET_IDX(_elts, _i)                   \
-   (((_i) >= draw->pt.user.eltMax) ? 0 : (_elts)[_i])
+   (((_i) >= draw->pt.user.eltMax) ? DRAW_MAX_FETCH_IDX : (_elts)[_i])
 
 /**
  * Return index of the given viewport clamping it
@@ -479,5 +494,20 @@ draw_clamp_viewport_idx(int idx)
    return ((PIPE_MAX_VIEWPORTS > idx || idx < 0) ? idx : 0);
 }
 
+/**
+ * Adds two unsigned integers and if the addition
+ * overflows then it returns the value from
+ * from the overflow_value variable.
+ */
+static INLINE unsigned
+draw_overflow_uadd(unsigned a, unsigned b,
+                   unsigned overflow_value)
+{
+   unsigned res = a + b;
+   if (res < a || res < b) {
+      res = overflow_value;
+   }
+   return res;
+}
 
 #endif /* DRAW_PRIVATE_H */