mesa/st: refactor vertex and fragment shader translation
[mesa.git] / src / mesa / main / context.c
index 03ee7fb04d90fde7abf2b001c4eeb80211b66a76..101d3c6b675dc02b65922209bc42f9ddb037ce92 100644 (file)
@@ -91,9 +91,7 @@
 #include "cpuinfo.h"
 #include "debug.h"
 #include "depth.h"
-#if FEATURE_dlist
 #include "dlist.h"
-#endif
 #include "eval.h"
 #include "enums.h"
 #include "extensions.h"
 #include "syncobj.h"
 #endif
 #include "rastpos.h"
+#include "remap.h"
 #include "scissor.h"
 #include "shared.h"
 #include "simple_list.h"
 #include "state.h"
 #include "stencil.h"
-#include "texcompress.h"
+#include "texcompress_s3tc.h"
 #include "teximage.h"
 #include "texobj.h"
 #include "texstate.h"
 #include "viewport.h"
 #include "vtxfmt.h"
 #include "glapi/glthread.h"
-#include "glapi/glapioffsets.h"
 #include "glapi/glapitable.h"
 #include "shader/program.h"
 #include "shader/prog_print.h"
@@ -175,6 +173,8 @@ GLfloat _mesa_ubyte_to_float_color_tab[256];
 void
 _mesa_notifySwapBuffers(__GLcontext *ctx)
 {
+   if (MESA_VERBOSE & VERBOSE_SWAPBUFFERS)
+      _mesa_debug(ctx, "SwapBuffers\n");
    FLUSH_CURRENT( ctx, 0 );
    if (ctx->Driver.Flush) {
       ctx->Driver.Flush(ctx);
@@ -407,6 +407,8 @@ one_time_init( GLcontext *ctx )
 
       _mesa_get_cpu_features();
 
+      _mesa_init_remap_table();
+
       _mesa_init_sqrt_table();
 
       for (i = 0; i < 256; i++) {
@@ -670,9 +672,7 @@ init_attrib_groups(GLcontext *ctx)
    _mesa_init_current( ctx );
    _mesa_init_depth( ctx );
    _mesa_init_debug( ctx );
-#if FEATURE_dlist
    _mesa_init_display_list( ctx );
-#endif
    _mesa_init_eval( ctx );
    _mesa_init_fbobjects( ctx );
    _mesa_init_feedback( ctx );
@@ -703,12 +703,7 @@ init_attrib_groups(GLcontext *ctx)
    if (!_mesa_init_texture( ctx ))
       return GL_FALSE;
 
-#if FEATURE_texture_s3tc
    _mesa_init_texture_s3tc( ctx );
-#endif
-#if FEATURE_texture_fxt1
-   _mesa_init_texture_fxt1( ctx );
-#endif
 
    /* Miscellaneous */
    ctx->NewState = _NEW_ALL;
@@ -864,15 +859,18 @@ _mesa_initialize_context(GLcontext *ctx,
       _mesa_free_shared_state(ctx, ctx->Shared);
       if (ctx->Exec)
          _mesa_free(ctx->Exec);
+      return GL_FALSE;
    }
 #if FEATURE_dispatch
    _mesa_init_exec_table(ctx->Exec);
 #endif
    ctx->CurrentDispatch = ctx->Exec;
+
 #if FEATURE_dlist
-   _mesa_init_dlist_table(ctx->Save);
+   _mesa_init_save_table(ctx->Save);
    _mesa_install_save_vtxfmt( ctx, &ctx->ListState.ListVtxfmt );
 #endif
+
    /* Neutral tnl module stuff */
    _mesa_init_exec_vtxfmt( ctx ); 
    ctx->TnlModule.Current = NULL;
@@ -1012,6 +1010,9 @@ _mesa_free_context_data( GLcontext *ctx )
       _mesa_free_shared_state( ctx, ctx->Shared );
    }
 
+   /* needs to be after freeing shared state */
+   _mesa_free_display_list_data(ctx);
+
    if (ctx->Extensions.String)
       _mesa_free((void *) ctx->Extensions.String);
 
@@ -1500,6 +1501,33 @@ _mesa_record_error(GLcontext *ctx, GLenum error)
 }
 
 
+/**
+ * Flush commands and wait for completion.
+ */
+void
+_mesa_finish(GLcontext *ctx)
+{
+   FLUSH_CURRENT( ctx, 0 );
+   if (ctx->Driver.Finish) {
+      ctx->Driver.Finish(ctx);
+   }
+}
+
+
+/**
+ * Flush commands.
+ */
+void
+_mesa_flush(GLcontext *ctx)
+{
+   FLUSH_CURRENT( ctx, 0 );
+   if (ctx->Driver.Flush) {
+      ctx->Driver.Flush(ctx);
+   }
+}
+
+
+
 /**
  * Execute glFinish().
  *
@@ -1511,10 +1539,7 @@ _mesa_Finish(void)
 {
    GET_CURRENT_CONTEXT(ctx);
    ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx);
-   FLUSH_CURRENT( ctx, 0 );
-   if (ctx->Driver.Finish) {
-      ctx->Driver.Finish(ctx);
-   }
+   _mesa_finish(ctx);
 }
 
 
@@ -1529,10 +1554,7 @@ _mesa_Flush(void)
 {
    GET_CURRENT_CONTEXT(ctx);
    ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx);
-   FLUSH_CURRENT( ctx, 0 );
-   if (ctx->Driver.Flush) {
-      ctx->Driver.Flush(ctx);
-   }
+   _mesa_flush(ctx);
 }