remove final imports.h and imports.c bits
[mesa.git] / src / mesa / tnl / t_context.h
index 48d7ced791fcfcb8ab549d31bdb56333172611be..a5bcdb80dbba1d01edadeaa8f9fee7c8563a6e33 100644 (file)
 #define _T_CONTEXT_H
 
 #include "main/glheader.h"
-#include "main/imports.h"
+
 #include "main/mtypes.h"
 
 #include "math/m_vector.h"
 
 #include "vbo/vbo.h"
 
+#include "tnl.h"
+
 #define MAX_PIPELINE_STAGES     30
 
 /*
@@ -158,8 +160,8 @@ enum {
 #define _TNL_FIRST_GENERIC _TNL_ATTRIB_GENERIC0
 #define _TNL_LAST_GENERIC  _TNL_ATTRIB_GENERIC15
 
-#define _TNL_FIRST_MAT       _TNL_ATTRIB_MAT_FRONT_AMBIENT /* GENERIC0 */
-#define _TNL_LAST_MAT        _TNL_ATTRIB_MAT_BACK_INDEXES  /* GENERIC11 */
+#define _TNL_FIRST_MAT       _TNL_ATTRIB_MAT_FRONT_AMBIENT /* GENERIC4 */
+#define _TNL_LAST_MAT        _TNL_ATTRIB_MAT_BACK_INDEXES  /* GENERIC15 */
 
 /* Number of available texture attributes */
 #define _TNL_NUM_TEX 8
@@ -203,7 +205,7 @@ struct vertex_buffer
     * such as backface color or eye-space coordinates, they are stored
     * here.
     */
-   GLuint      *Elts;                          
+   GLuint      *Elts;
    GLvector4f  *EyePtr;                                /* _TNL_BIT_POS */
    GLvector4f  *ClipPtr;                       /* _TNL_BIT_POS */
    GLvector4f  *NdcPtr;                         /* _TNL_BIT_POS */
@@ -216,8 +218,8 @@ struct vertex_buffer
    GLvector4f  *BackfaceColorPtr;
    GLvector4f  *BackfaceSecondaryColorPtr;
 
-   const struct _mesa_prim  *Primitive;                      
-   GLuint      PrimitiveCount;       
+   const struct _mesa_prim  *Primitive;
+   GLuint      PrimitiveCount;
 
    /* Inputs to the vertex program stage */
    GLvector4f *AttribPtr[_TNL_ATTRIB_MAX];
@@ -262,10 +264,10 @@ struct tnl_pipeline_stage
 
 
 /** Contains the array of all pipeline stages.
- * The default values are defined at the end of t_pipeline.c 
+ * The default values are defined at the end of t_pipeline.c
  */
 struct tnl_pipeline {
-   
+
    GLuint last_attrib_stride[_TNL_ATTRIB_MAX];
    GLuint last_attrib_size[_TNL_ATTRIB_MAX];
    GLuint input_changes;
@@ -278,16 +280,16 @@ struct tnl_pipeline {
 struct tnl_clipspace;
 struct tnl_clipspace_attr;
 
-typedef void (*tnl_extract_func)( const struct tnl_clipspace_attr *a, 
-                                 GLfloat *out, 
+typedef void (*tnl_extract_func)( const struct tnl_clipspace_attr *a,
+                                 GLfloat *out,
                                  const GLubyte *v );
 
-typedef void (*tnl_insert_func)( const struct tnl_clipspace_attr *a, 
-                                GLubyte *v, 
+typedef void (*tnl_insert_func)( const struct tnl_clipspace_attr *a,
+                                GLubyte *v,
                                 const GLfloat *in );
 
-typedef void (*tnl_emit_func)( struct gl_context *ctx, 
-                              GLuint count, 
+typedef void (*tnl_emit_func)( struct gl_context *ctx,
+                              GLuint count,
                               GLubyte *dest );
 
 
@@ -355,7 +357,7 @@ struct tnl_clipspace_fastpath {
 struct tnl_clipspace
 {
    GLboolean need_extras;
-   
+
    GLuint new_inputs;
 
    GLubyte *vertex_buf;
@@ -372,13 +374,13 @@ struct tnl_clipspace
    /* Parameters and constants for codegen:
     */
    GLboolean need_viewport;
-   GLfloat vp_scale[4];                
+   GLfloat vp_scale[4];
    GLfloat vp_xlate[4];
    GLfloat chan_scale[4];
    GLfloat identity[4];
 
    struct tnl_clipspace_fastpath *fastpath;
-   
+
    void (*codegen_emit)( struct gl_context *ctx );
 };
 
@@ -406,7 +408,7 @@ struct tnl_device_driver
    void (*RunPipeline)(struct gl_context *ctx);
    /* Replaces PipelineStart/PipelineFinish -- intended to allow
     * drivers to wrap _tnl_run_pipeline() with code to validate state
-    * and grab/release hardware locks.  
+    * and grab/release hardware locks.
     */
 
    void (*NotifyMaterialChange)(struct gl_context *ctx);
@@ -481,7 +483,7 @@ struct tnl_device_driver
        *
        * This function is called only from _tnl_render_stage in tnl/t_render.c.
        */
-      
+
 
       GLboolean (*Multipass)( struct gl_context *ctx, GLuint passno );
       /* Driver may request additional render passes by returning GL_TRUE
@@ -496,6 +498,41 @@ struct tnl_device_driver
 };
 
 
+/**
+ * Utility that tracks and updates the current array entries.
+ */
+struct tnl_inputs
+{
+   /**
+    * Array of inputs to be set to the _DrawArrays pointer.
+    * The array contains pointers into the _DrawVAO and to the vbo modules
+    * current values. The array of pointers is updated incrementally
+    * based on the current and vertex_processing_mode values below.
+    */
+   struct tnl_vertex_array inputs[VERT_ATTRIB_MAX];
+   /** Those VERT_BIT_'s where the inputs array point to current values. */
+   GLbitfield current;
+   /** Store which aliasing current values - generics or materials - are set. */
+   gl_vertex_processing_mode vertex_processing_mode;
+};
+
+
+/**
+ * Initialize inputs.
+ */
+void
+_tnl_init_inputs(struct tnl_inputs *inputs);
+
+
+/**
+ * Update the tnl_vertex_array array inside the tnl_inputs structure
+ * provided the current _VPMode, the provided vao and
+ * the vao's enabled arrays filtered by the filter bitmask.
+ */
+void
+_tnl_update_inputs(struct gl_context *ctx, struct tnl_inputs *inputs);
+
+
 /**
  * Context state for T&L context.
  */
@@ -526,7 +563,7 @@ typedef struct
 
    GLvector4f tmp_inputs[VERT_ATTRIB_MAX];
 
-   /* Temp storage for t_draw.c: 
+   /* Temp storage for t_draw.c:
     */
    GLubyte *block[VERT_ATTRIB_MAX];
    GLuint nr_blocks;
@@ -536,6 +573,9 @@ typedef struct
    struct tnl_shine_tab *_ShineTable[2]; /**< Active shine tables */
    struct tnl_shine_tab *_ShineTabList;  /**< MRU list of inactive shine tables */
    /**@}*/
+
+   /* The list of tnl_vertex_array inputs. */
+   struct tnl_inputs draw_arrays;
 } TNLcontext;