Merge remote branch 'origin/master' into pipe-video
[mesa.git] / src / mesa / main / vtxfmt.c
index c9eea8ab8300ab34ddf3d818eba289dddae03f0d..8ec6bb3b7cc51d13aa719c5b659bbaf169890ca5 100644 (file)
 
 #include "glheader.h"
 #include "api_arrayelt.h"
-#include "api_loopback.h"
 #include "context.h"
 #include "imports.h"
 #include "mtypes.h"
-#include "state.h"
 #include "vtxfmt.h"
 #include "eval.h"
 #include "dlist.h"
+#include "main/dispatch.h"
 
 
 #if FEATURE_beginend
 
-
-/* The neutral vertex format.  This wraps all tnl module functions,
- * verifying that the currently-installed module is valid and then
- * installing the function pointers in a lazy fashion.  It records the
- * function pointers that have been swapped out, which allows a fast
- * restoration of the neutral module in almost all cases -- a typical
- * app might only require 4-6 functions to be modified from the neutral
- * baseline, and only restoring these is certainly preferable to doing
- * the entire module's 60 or so function pointers.
- */
-
-#define PRE_LOOPBACK( FUNC )                                           \
-{                                                                      \
-   GET_CURRENT_CONTEXT(ctx);                                           \
-   struct gl_tnl_module * const tnl = &(ctx->TnlModule);               \
-   const int tmp_offset = _gloffset_ ## FUNC ;                         \
-                                                                       \
-   ASSERT( tnl->Current );                                             \
-   ASSERT( tnl->SwapCount < NUM_VERTEX_FORMAT_ENTRIES );               \
-   ASSERT( tmp_offset >= 0 );                                          \
-                                                                        \
-   if (tnl->SwapCount == 0)                                             \
-      ctx->Driver.BeginVertices( ctx );                                 \
-                                                                        \
-   /* Save the swapped function's dispatch entry so it can be */        \
-   /* restored later. */                                                \
-   tnl->Swapped[tnl->SwapCount].location = & (((_glapi_proc *)ctx->Exec)[tmp_offset]); \
-   tnl->Swapped[tnl->SwapCount].function = (_glapi_proc)TAG(FUNC);     \
-   tnl->SwapCount++;                                                   \
-                                                                       \
-   if ( 0 )                                                            \
-      _mesa_debug(ctx, "   swapping gl" #FUNC"...\n" );                        \
-                                                                       \
-   /* Install the tnl function pointer.        */                              \
-   SET_ ## FUNC(ctx->Exec, tnl->Current->FUNC);                                \
-}
-
-#define TAG(x) neutral_##x
-#include "vtxfmt_tmp.h"
-
-
 /**
- * Use the per-vertex functions found in <vfmt> to initialze the given
+ * Use the per-vertex functions found in <vfmt> to initialoze the given
  * API dispatch table.
  */
 static void
@@ -130,11 +88,14 @@ install_vtxfmt( struct _glapi_table *tab, const GLvertexformat *vfmt )
    SET_Vertex4f(tab, vfmt->Vertex4f);
    SET_Vertex4fv(tab, vfmt->Vertex4fv);
 
-   _mesa_install_dlist_vtxfmt(tab, vfmt);
+   _mesa_install_dlist_vtxfmt(tab, vfmt);   /* glCallList / glCallLists */
 
    SET_Begin(tab, vfmt->Begin);
    SET_End(tab, vfmt->End);
+   SET_PrimitiveRestartNV(tab, vfmt->PrimitiveRestartNV);
+
    SET_Rectf(tab, vfmt->Rectf);
+
    SET_DrawArrays(tab, vfmt->DrawArrays);
    SET_DrawElements(tab, vfmt->DrawElements);
    SET_DrawRangeElements(tab, vfmt->DrawRangeElements);
@@ -142,6 +103,8 @@ install_vtxfmt( struct _glapi_table *tab, const GLvertexformat *vfmt )
    SET_DrawElementsBaseVertex(tab, vfmt->DrawElementsBaseVertex);
    SET_DrawRangeElementsBaseVertex(tab, vfmt->DrawRangeElementsBaseVertex);
    SET_MultiDrawElementsBaseVertex(tab, vfmt->MultiDrawElementsBaseVertex);
+   SET_DrawArraysInstanced(tab, vfmt->DrawArraysInstanced);
+   SET_DrawElementsInstanced(tab, vfmt->DrawElementsInstanced);
 
    /* GL_NV_vertex_program */
    SET_VertexAttrib1fNV(tab, vfmt->VertexAttrib1fNV);
@@ -162,41 +125,46 @@ install_vtxfmt( struct _glapi_table *tab, const GLvertexformat *vfmt )
    SET_VertexAttrib4fARB(tab, vfmt->VertexAttrib4fARB);
    SET_VertexAttrib4fvARB(tab, vfmt->VertexAttrib4fvARB);
 #endif
-}
-
 
-void _mesa_init_exec_vtxfmt( GLcontext *ctx )
-{
-   install_vtxfmt( ctx->Exec, &neutral_vtxfmt );
-   ctx->TnlModule.SwapCount = 0;
-}
-
-
-void _mesa_install_exec_vtxfmt( GLcontext *ctx, const GLvertexformat *vfmt )
-{
-   ctx->TnlModule.Current = vfmt;
-   _mesa_restore_exec_vtxfmt( ctx );
+   /* GL_EXT_gpu_shader4 / OpenGL 3.0 */
+   SET_VertexAttribI1iEXT(tab, vfmt->VertexAttribI1i);
+   SET_VertexAttribI2iEXT(tab, vfmt->VertexAttribI2i);
+   SET_VertexAttribI3iEXT(tab, vfmt->VertexAttribI3i);
+   SET_VertexAttribI4iEXT(tab, vfmt->VertexAttribI4i);
+   SET_VertexAttribI2ivEXT(tab, vfmt->VertexAttribI2iv);
+   SET_VertexAttribI3ivEXT(tab, vfmt->VertexAttribI3iv);
+   SET_VertexAttribI4ivEXT(tab, vfmt->VertexAttribI4iv);
+
+   SET_VertexAttribI1uiEXT(tab, vfmt->VertexAttribI1ui);
+   SET_VertexAttribI2uiEXT(tab, vfmt->VertexAttribI2ui);
+   SET_VertexAttribI3uiEXT(tab, vfmt->VertexAttribI3ui);
+   SET_VertexAttribI4uiEXT(tab, vfmt->VertexAttribI4ui);
+   SET_VertexAttribI2uivEXT(tab, vfmt->VertexAttribI2uiv);
+   SET_VertexAttribI3uivEXT(tab, vfmt->VertexAttribI3uiv);
+   SET_VertexAttribI4uivEXT(tab, vfmt->VertexAttribI4uiv);
 }
 
 
-void _mesa_install_save_vtxfmt( GLcontext *ctx, const GLvertexformat *vfmt )
+/**
+ * Install per-vertex functions into the API dispatch table for execution.
+ */
+void
+_mesa_install_exec_vtxfmt(struct gl_context *ctx, const GLvertexformat *vfmt)
 {
-   install_vtxfmt( ctx->Save, vfmt );
+   if (ctx->API == API_OPENGL)
+      install_vtxfmt( ctx->Exec, vfmt );
 }
 
 
-void _mesa_restore_exec_vtxfmt( GLcontext *ctx )
+/**
+ * Install per-vertex functions into the API dispatch table for display
+ * list compilation.
+ */
+void
+_mesa_install_save_vtxfmt(struct gl_context *ctx, const GLvertexformat *vfmt)
 {
-   struct gl_tnl_module *tnl = &(ctx->TnlModule);
-   GLuint i;
-
-   /* Restore the neutral tnl module wrapper.
-    */
-   for ( i = 0 ; i < tnl->SwapCount ; i++ ) {
-      *(tnl->Swapped[i].location) = tnl->Swapped[i].function;
-   }
-
-   tnl->SwapCount = 0;
+   if (ctx->API == API_OPENGL)
+      install_vtxfmt( ctx->Save, vfmt );
 }