Merge branch 'llvm-cliptest-viewport'
[mesa.git] / src / mesa / tnl / t_context.c
index ce37dc04282e12c78e50d94052ffefd96085b71e..47aeeb885943de21beccfa9c5191bf7053b461a2 100644 (file)
 #include "main/macros.h"
 #include "main/mtypes.h"
 #include "main/light.h"
+#include "math/m_translate.h"
+#include "math/m_xform.h"
 
 #include "tnl.h"
 #include "t_context.h"
 #include "t_pipeline.h"
-#include "t_vp_build.h"
 
 #include "vbo/vbo.h"
 
 GLboolean
-_tnl_CreateContext( GLcontext *ctx )
+_tnl_CreateContext( struct gl_context *ctx )
 {
    TNLcontext *tnl;
 
@@ -79,14 +80,17 @@ _tnl_CreateContext( GLcontext *ctx )
    tnl->nr_blocks = 0;
 
    /* plug in the VBO drawing function */
-   vbo_set_draw_func(ctx, _tnl_draw_prims);
+   vbo_set_draw_func(ctx, _tnl_vbo_draw_prims);
+
+   _math_init_transformation();
+   _math_init_translate();
 
    return GL_TRUE;
 }
 
 
 void
-_tnl_DestroyContext( GLcontext *ctx )
+_tnl_DestroyContext( struct gl_context *ctx )
 {
    TNLcontext *tnl = TNL_CONTEXT(ctx);
 
@@ -98,11 +102,12 @@ _tnl_DestroyContext( GLcontext *ctx )
 
 
 void
-_tnl_InvalidateState( GLcontext *ctx, GLuint new_state )
+_tnl_InvalidateState( struct gl_context *ctx, GLuint new_state )
 {
    TNLcontext *tnl = TNL_CONTEXT(ctx);
    const struct gl_vertex_program *vp = ctx->VertexProgram._Current;
    const struct gl_fragment_program *fp = ctx->FragmentProgram._Current;
+   GLuint i;
 
    if (new_state & (_NEW_HINT | _NEW_PROGRAM)) {
       ASSERT(tnl->AllowVertexFog || tnl->AllowPixelFog);
@@ -112,41 +117,34 @@ _tnl_InvalidateState( GLcontext *ctx, GLuint new_state )
 
    tnl->pipeline.new_state |= new_state;
 
-   /* Calculate tnl->render_inputs:
+   /* Calculate tnl->render_inputs.  This bitmask indicates which vertex
+    * attributes need to be emitted to the rasterizer.
     */
-   if (ctx->Visual.rgbMode) {
-      GLuint i;
+   RENDERINPUTS_ZERO( tnl->render_inputs_bitset );
+   RENDERINPUTS_SET( tnl->render_inputs_bitset, _TNL_ATTRIB_POS );
 
-      RENDERINPUTS_ZERO( tnl->render_inputs_bitset );
-      RENDERINPUTS_SET( tnl->render_inputs_bitset, _TNL_ATTRIB_POS );
-      if (!fp || (fp->Base.InputsRead & FRAG_BIT_COL0)) {
-         RENDERINPUTS_SET( tnl->render_inputs_bitset, _TNL_ATTRIB_COLOR0 );
-      }
-      for (i = 0; i < ctx->Const.MaxTextureCoordUnits; i++) {
-         if (ctx->Texture._EnabledCoordUnits & (1 << i)) {
-            RENDERINPUTS_SET( tnl->render_inputs_bitset, _TNL_ATTRIB_TEX(i) );
-         }
-      }
-
-      if (NEED_SECONDARY_COLOR(ctx))
-         RENDERINPUTS_SET( tnl->render_inputs_bitset, _TNL_ATTRIB_COLOR1 );
+   if (!fp || (fp->Base.InputsRead & FRAG_BIT_COL0)) {
+     RENDERINPUTS_SET( tnl->render_inputs_bitset, _TNL_ATTRIB_COLOR0 );
    }
-   else {
-      RENDERINPUTS_SET( tnl->render_inputs_bitset, _TNL_ATTRIB_POS );
-      RENDERINPUTS_SET( tnl->render_inputs_bitset, _TNL_ATTRIB_COLOR_INDEX );
+
+   if (NEED_SECONDARY_COLOR(ctx))
+     RENDERINPUTS_SET( tnl->render_inputs_bitset, _TNL_ATTRIB_COLOR1 );
+
+   for (i = 0; i < ctx->Const.MaxTextureCoordUnits; i++) {
+     if (ctx->Texture._EnabledCoordUnits & (1 << i) ||
+        (fp && fp->Base.InputsRead & FRAG_BIT_TEX(i))) {
+       RENDERINPUTS_SET( tnl->render_inputs_bitset, _TNL_ATTRIB_TEX(i) );
+     }
    }
 
    if (ctx->Fog.Enabled) {
       /* fixed-function fog */
       RENDERINPUTS_SET( tnl->render_inputs_bitset, _TNL_ATTRIB_FOG );
    }
-   else if (ctx->FragmentProgram._Active || ctx->FragmentProgram._Current) {
-      struct gl_fragment_program *fp = ctx->FragmentProgram._Current;
-      if (fp) {
-         if (fp->FogOption != GL_NONE || (fp->Base.InputsRead & FRAG_BIT_FOGC)) {
-            /* fragment program needs fog coord */
-            RENDERINPUTS_SET( tnl->render_inputs_bitset, _TNL_ATTRIB_FOG );
-         }
+   else if (fp) {
+      if (fp->FogOption != GL_NONE || (fp->Base.InputsRead & FRAG_BIT_FOGC)) {
+         /* fragment program needs fog coord */
+         RENDERINPUTS_SET( tnl->render_inputs_bitset, _TNL_ATTRIB_FOG );
       }
    }
 
@@ -165,7 +163,7 @@ _tnl_InvalidateState( GLcontext *ctx, GLuint new_state )
    if (vp) {
       GLuint i;
       for (i = 0; i < MAX_VARYING; i++) {
-         if (vp->Base.OutputsWritten & (1 << (VERT_RESULT_VAR0 + i))) {
+        if (vp->Base.OutputsWritten & BITFIELD64_BIT(VERT_RESULT_VAR0 + i)) {
             RENDERINPUTS_SET(tnl->render_inputs_bitset,
                              _TNL_ATTRIB_GENERIC(i));
          }
@@ -175,7 +173,7 @@ _tnl_InvalidateState( GLcontext *ctx, GLuint new_state )
 
 
 void
-_tnl_wakeup( GLcontext *ctx )
+_tnl_wakeup( struct gl_context *ctx )
 {
    /* Assume we haven't been getting state updates either:
     */
@@ -198,14 +196,14 @@ _tnl_wakeup( GLcontext *ctx )
  * we should "Divide-by-W".  Software renders will want that.
  */
 void
-_tnl_need_projected_coords( GLcontext *ctx, GLboolean mode )
+_tnl_need_projected_coords( struct gl_context *ctx, GLboolean mode )
 {
    TNLcontext *tnl = TNL_CONTEXT(ctx);
    tnl->NeedNdcCoords = mode;
 }
 
 void
-_tnl_allow_vertex_fog( GLcontext *ctx, GLboolean value )
+_tnl_allow_vertex_fog( struct gl_context *ctx, GLboolean value )
 {
    TNLcontext *tnl = TNL_CONTEXT(ctx);
    tnl->AllowVertexFog = value;
@@ -215,7 +213,7 @@ _tnl_allow_vertex_fog( GLcontext *ctx, GLboolean value )
 }
 
 void
-_tnl_allow_pixel_fog( GLcontext *ctx, GLboolean value )
+_tnl_allow_pixel_fog( struct gl_context *ctx, GLboolean value )
 {
    TNLcontext *tnl = TNL_CONTEXT(ctx);
    tnl->AllowPixelFog = value;