summaryrefslogtreecommitdiffstats
path: root/src/mesa/main/context.c
diff options
context:
space:
mode:
authorKeith Whitwell <[email protected]>2000-11-16 21:05:34 +0000
committerKeith Whitwell <[email protected]>2000-11-16 21:05:34 +0000
commit23caf20169ac38436ee9c13914f1d6aa7cf6bb5e (patch)
tree21307f7bbcaf9ee1e841d7e7bee130570a7b5b95 /src/mesa/main/context.c
parent179516673211a2350e479d5321840291f339f5dd (diff)
Move the transform and lighting code to two new directories
math: Provides basic matrix and vector functionality that might be useful to multiple software t&l implementations, and is used by core mesa to manage the Model, Project, etc matrices. tnl: The real transform & lighting code from core mesa, including everything from glVertex3f through vertex buffer handling, transformation, clipping, lighting and handoff to a driver for rasterization. The interfaces of these can be further tightened up, but the basic splitting up of state and code move is done.
Diffstat (limited to 'src/mesa/main/context.c')
-rw-r--r--src/mesa/main/context.c250
1 files changed, 101 insertions, 149 deletions
diff --git a/src/mesa/main/context.c b/src/mesa/main/context.c
index aff60fb5073..c0e75e92984 100644
--- a/src/mesa/main/context.c
+++ b/src/mesa/main/context.c
@@ -1,4 +1,4 @@
-/* $Id: context.c,v 1.105 2000/11/15 16:38:40 brianp Exp $ */
+/* $Id: context.c,v 1.106 2000/11/16 21:05:34 keithw Exp $ */
/*
* Mesa 3-D graphics library
@@ -33,7 +33,6 @@
#include "clip.h"
#include "colortab.h"
#include "context.h"
-#include "cva.h"
#include "dlist.h"
#include "eval.h"
#include "enums.h"
@@ -46,25 +45,21 @@
#include "imports.h"
#include "light.h"
#include "macros.h"
-#include "matrix.h"
#include "mem.h"
#include "mmath.h"
-#include "pipeline.h"
-#include "shade.h"
#include "simple_list.h"
-#include "stages.h"
#include "state.h"
-#include "translate.h"
#include "teximage.h"
#include "texobj.h"
#include "texture.h"
#include "types.h"
#include "varray.h"
-#include "vb.h"
-#include "vbrender.h"
-#include "vbxform.h"
-#include "vertices.h"
-#include "xform.h"
+
+#include "math/m_translate.h"
+#include "math/m_vertices.h"
+#include "math/m_matrix.h"
+#include "math/m_xform.h"
+#include "math/math.h"
#endif
#if defined(MESA_TRACE)
@@ -73,6 +68,25 @@
#endif
+#ifndef MESA_VERBOSE
+int MESA_VERBOSE = 0
+/* | VERBOSE_PIPELINE */
+/* | VERBOSE_IMMEDIATE */
+/* | VERBOSE_VARRAY */
+/* | VERBOSE_TEXTURE */
+/* | VERBOSE_API */
+/* | VERBOSE_DRIVER */
+/* | VERBOSE_STATE */
+/* | VERBOSE_CULL */
+/* | VERBOSE_DISPLAY_LIST */
+;
+#endif
+
+#ifndef MESA_DEBUG_FLAGS
+int MESA_DEBUG_FLAGS = 0
+/* | DEBUG_ALWAYS_FLUSH */
+;
+#endif
/**********************************************************************/
/***** OpenGL SI-style interface (new in Mesa 3.5) *****/
@@ -145,12 +159,6 @@ __glCoreNopDispatch(void)
/**********************************************************************/
-#if !defined(THREADS)
-
-struct immediate *_mesa_CurrentInput = NULL;
-
-#endif
-
/**********************************************************************/
/***** GL Visual allocation/destruction *****/
@@ -442,17 +450,10 @@ one_time_init( void )
assert( sizeof(GLushort) >= 2 );
assert( sizeof(GLuint) >= 4 );
- gl_init_clip();
- gl_init_eval();
- _mesa_init_math();
gl_init_lists();
- gl_init_shade();
- gl_init_texture();
- gl_init_transformation();
- gl_init_translate();
- gl_init_vbrender();
- gl_init_vbxform();
- gl_init_vertices();
+
+ _mesa_init_math();
+ _math_init();
if (getenv("MESA_DEBUG")) {
_glapi_noop_enable_warnings(GL_TRUE);
@@ -809,45 +810,43 @@ init_attrib_groups( GLcontext *ctx )
ctx->Const.NumCompressedTextureFormats = 0;
/* Modelview matrix */
- gl_matrix_ctr( &ctx->ModelView );
- gl_matrix_alloc_inv( &ctx->ModelView );
+ _math_matrix_ctr( &ctx->ModelView );
+ _math_matrix_alloc_inv( &ctx->ModelView );
ctx->ModelViewStackDepth = 0;
for (i = 0; i < MAX_MODELVIEW_STACK_DEPTH - 1; i++) {
- gl_matrix_ctr( &ctx->ModelViewStack[i] );
- gl_matrix_alloc_inv( &ctx->ModelViewStack[i] );
+ _math_matrix_ctr( &ctx->ModelViewStack[i] );
+ _math_matrix_alloc_inv( &ctx->ModelViewStack[i] );
}
/* Projection matrix - need inv for user clipping in clip space*/
- gl_matrix_ctr( &ctx->ProjectionMatrix );
- gl_matrix_alloc_inv( &ctx->ProjectionMatrix );
-
- gl_matrix_ctr( &ctx->_ModelProjectMatrix );
+ _math_matrix_ctr( &ctx->ProjectionMatrix );
+ _math_matrix_alloc_inv( &ctx->ProjectionMatrix );
ctx->ProjectionStackDepth = 0;
- ctx->NearFarStack[0][0] = 1.0; /* These values seem weird by make */
- ctx->NearFarStack[0][1] = 0.0; /* sense mathematically. */
-
for (i = 0; i < MAX_PROJECTION_STACK_DEPTH - 1; i++) {
- gl_matrix_ctr( &ctx->ProjectionStack[i] );
- gl_matrix_alloc_inv( &ctx->ProjectionStack[i] );
+ _math_matrix_ctr( &ctx->ProjectionStack[i] );
+ _math_matrix_alloc_inv( &ctx->ProjectionStack[i] );
}
+ /* Derived ModelProject matrix */
+ _math_matrix_ctr( &ctx->_ModelProjectMatrix );
+
/* Texture matrix */
for (i = 0; i < MAX_TEXTURE_UNITS; i++) {
- gl_matrix_ctr( &ctx->TextureMatrix[i] );
+ _math_matrix_ctr( &ctx->TextureMatrix[i] );
ctx->TextureStackDepth[i] = 0;
for (j = 0; j < MAX_TEXTURE_STACK_DEPTH - 1; j++) {
- gl_matrix_ctr( &ctx->TextureStack[i][j] );
+ _math_matrix_ctr( &ctx->TextureStack[i][j] );
ctx->TextureStack[i][j].inv = 0;
}
}
/* Color matrix */
- gl_matrix_ctr(&ctx->ColorMatrix);
+ _math_matrix_ctr(&ctx->ColorMatrix);
ctx->ColorStackDepth = 0;
for (j = 0; j < MAX_COLOR_STACK_DEPTH - 1; j++) {
- gl_matrix_ctr(&ctx->ColorStack[j]);
+ _math_matrix_ctr(&ctx->ColorStack[j]);
}
/* Accumulate buffer group */
@@ -893,19 +892,6 @@ init_attrib_groups( GLcontext *ctx )
ctx->Current.RasterPosValid = GL_TRUE;
ctx->Current.EdgeFlag = GL_TRUE;
ASSIGN_3V( ctx->Current.Normal, 0.0, 0.0, 1.0 );
- ctx->Current.Primitive = (GLenum) (GL_POLYGON + 1);
-
- ctx->Current.Flag = (VERT_NORM |
- VERT_INDEX |
- VERT_RGBA |
- VERT_SPEC_RGB |
- VERT_FOG_COORD |
- VERT_EDGE |
- VERT_TEX0_12 |
- VERT_TEX1_12 |
- VERT_TEX2_12 |
- VERT_TEX3_12 |
- VERT_MATERIAL);
init_fallback_arrays( ctx );
@@ -1023,15 +1009,9 @@ init_attrib_groups( GLcontext *ctx )
ctx->MinMax.Min[BCOMP] = 1000; ctx->MinMax.Max[BCOMP] = -1000;
ctx->MinMax.Min[ACOMP] = 1000; ctx->MinMax.Max[ACOMP] = -1000;
- /* Pipeline */
- gl_pipeline_init( ctx );
- gl_cva_init( ctx );
-
/* Extensions */
gl_extensions_ctr( ctx );
- ctx->AllowVertexCull = CLIP_CULLED_BIT;
-
/* Lighting group */
for (i=0;i<MAX_LIGHTS;i++) {
init_light( &ctx->Light.Light[i], i );
@@ -1227,7 +1207,7 @@ init_attrib_groups( GLcontext *ctx )
ctx->Viewport.Height = 0;
ctx->Viewport.Near = 0.0;
ctx->Viewport.Far = 1.0;
- gl_matrix_ctr(&ctx->Viewport._WindowMap);
+ _math_matrix_ctr(&ctx->Viewport._WindowMap);
#define Sz 10
#define Tz 14
@@ -1454,12 +1434,6 @@ _mesa_initialize_context( GLcontext *ctx,
ctx->Visual = *visual;
ctx->DrawBuffer = NULL;
ctx->ReadBuffer = NULL;
-
- ctx->VB = gl_vb_create_for_immediate( ctx );
- if (!ctx->VB) {
- return GL_FALSE;
- }
- ctx->input = ctx->VB->IM;
if (share_list) {
/* share the group of display lists of another context */
@@ -1469,7 +1443,6 @@ _mesa_initialize_context( GLcontext *ctx,
/* allocate new group of display lists */
ctx->Shared = alloc_shared_state();
if (!ctx->Shared) {
- ALIGN_FREE( ctx->VB );
return GL_FALSE;
}
}
@@ -1479,9 +1452,6 @@ _mesa_initialize_context( GLcontext *ctx,
init_attrib_groups( ctx );
- gl_reset_vb( ctx->VB );
- gl_reset_input( ctx );
-
if (visual->DBflag) {
ctx->Color.DrawBuffer = GL_BACK;
ctx->Color.DriverDrawBuffer = GL_BACK_LEFT;
@@ -1499,7 +1469,6 @@ _mesa_initialize_context( GLcontext *ctx,
if (!alloc_proxy_textures(ctx)) {
free_shared_state(ctx, ctx->Shared);
- ALIGN_FREE( ctx->VB );
return GL_FALSE;
}
@@ -1526,7 +1495,6 @@ _mesa_initialize_context( GLcontext *ctx,
ctx->Save = (struct _glapi_table *) CALLOC(dispatchSize * sizeof(void*));
if (!ctx->Exec || !ctx->Save) {
free_shared_state(ctx, ctx->Shared);
- ALIGN_FREE( ctx->VB );
if (ctx->Exec)
FREE( ctx->Exec );
}
@@ -1541,7 +1509,6 @@ _mesa_initialize_context( GLcontext *ctx,
or should we just trap in NewTrace (currently done)? */
if (!(ctx->TraceCtx)) {
free_shared_state(ctx, ctx->Shared);
- ALIGN_FREE( ctx->VB );
FREE( ctx->Exec );
FREE( ctx->Save );
return GL_FALSE;
@@ -1554,7 +1521,6 @@ _mesa_initialize_context( GLcontext *ctx,
#if 0
if (!(ctx->TraceCtx)) {
free_shared_state(ctx, ctx->Shared);
- ALIGN_FREE( ctx->VB );
FREE( ctx->Exec );
FREE( ctx->Save );
FREE( ctx->TraceCtx );
@@ -1613,26 +1579,21 @@ _mesa_free_context_data( GLcontext *ctx )
_mesa_make_current(NULL, NULL);
}
- gl_matrix_dtr( &ctx->ModelView );
+ _math_matrix_dtr( &ctx->ModelView );
for (i = 0; i < MAX_MODELVIEW_STACK_DEPTH - 1; i++) {
- gl_matrix_dtr( &ctx->ModelViewStack[i] );
+ _math_matrix_dtr( &ctx->ModelViewStack[i] );
}
- gl_matrix_dtr( &ctx->ProjectionMatrix );
+ _math_matrix_dtr( &ctx->ProjectionMatrix );
for (i = 0; i < MAX_PROJECTION_STACK_DEPTH - 1; i++) {
- gl_matrix_dtr( &ctx->ProjectionStack[i] );
+ _math_matrix_dtr( &ctx->ProjectionStack[i] );
}
for (i = 0; i < MAX_TEXTURE_UNITS; i++) {
- gl_matrix_dtr( &ctx->TextureMatrix[i] );
+ _math_matrix_dtr( &ctx->TextureMatrix[i] );
for (j = 0; j < MAX_TEXTURE_STACK_DEPTH - 1; j++) {
- gl_matrix_dtr( &ctx->TextureStack[i][j] );
+ _math_matrix_dtr( &ctx->TextureStack[i][j] );
}
}
- if (ctx->input != ctx->VB->IM)
- gl_immediate_free( ctx->input );
-
- gl_vb_free( ctx->VB );
-
_glthread_LOCK_MUTEX(ctx->Shared->Mutex);
ctx->Shared->RefCount--;
assert(ctx->Shared->RefCount >= 0);
@@ -1696,12 +1657,6 @@ _mesa_free_context_data( GLcontext *ctx )
_mesa_free_colortable_data( &ctx->PostColorMatrixColorTable );
_mesa_free_colortable_data( &ctx->Texture.Palette );
- /* Free cache of immediate buffers. */
- while (ctx->nr_im_queued-- > 0) {
- struct immediate * next = ctx->freed_im_queue->next;
- ALIGN_FREE( ctx->freed_im_queue );
- ctx->freed_im_queue = next;
- }
gl_extensions_dtr(ctx);
FREE(ctx->Exec);
@@ -1828,6 +1783,29 @@ _mesa_make_current( GLcontext *newCtx, GLframebuffer *buffer )
}
+static void print_info( void )
+{
+ fprintf(stderr, "Mesa GL_VERSION = %s\n",
+ (char *) _mesa_GetString(GL_VERSION));
+ fprintf(stderr, "Mesa GL_RENDERER = %s\n",
+ (char *) _mesa_GetString(GL_RENDERER));
+ fprintf(stderr, "Mesa GL_VENDOR = %s\n",
+ (char *) _mesa_GetString(GL_VENDOR));
+ fprintf(stderr, "Mesa GL_EXTENSIONS = %s\n",
+ (char *) _mesa_GetString(GL_EXTENSIONS));
+#if defined(THREADS)
+ fprintf(stderr, "Mesa thread-safe: YES\n");
+#else
+ fprintf(stderr, "Mesa thread-safe: NO\n");
+#endif
+#if defined(USE_X86_ASM)
+ fprintf(stderr, "Mesa x86-optimized: YES\n");
+#else
+ fprintf(stderr, "Mesa x86-optimized: NO\n");
+#endif
+}
+
+
/*
* Bind the given context to the given draw-buffer and read-buffer
* and make it the current context for this thread.
@@ -1836,23 +1814,8 @@ void
_mesa_make_current2( GLcontext *newCtx, GLframebuffer *drawBuffer,
GLframebuffer *readBuffer )
{
-#if 0
- GLcontext *oldCtx = gl_get_context();
-
- /* Flush the old context
- */
- if (oldCtx) {
- ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(oldCtx, "_mesa_make_current");
-
- /* unbind frame buffers from context */
- if (oldCtx->DrawBuffer) {
- oldCtx->DrawBuffer = NULL;
- }
- if (oldCtx->ReadBuffer) {
- oldCtx->ReadBuffer = NULL;
- }
- }
-#endif
+ if (MESA_VERBOSE)
+ fprintf(stderr, "_mesa_make_current2()\n");
/* We call this function periodically (just here for now) in
* order to detect when multithreading has begun.
@@ -1861,47 +1824,36 @@ _mesa_make_current2( GLcontext *newCtx, GLframebuffer *drawBuffer,
_glapi_set_context((void *) newCtx);
ASSERT(_mesa_get_current_context() == newCtx);
- if (newCtx) {
- SET_IMMEDIATE(newCtx, newCtx->input);
- _glapi_set_dispatch(newCtx->CurrentDispatch);
- }
- else {
+
+
+ if (!newCtx) {
_glapi_set_dispatch(NULL); /* none current */
}
+ else {
+ _glapi_set_dispatch(newCtx->CurrentDispatch);
- if (MESA_VERBOSE) fprintf(stderr, "_mesa_make_current()\n");
+ if (drawBuffer && readBuffer) {
+ /* TODO: check if newCtx and buffer's visual match??? */
+ newCtx->DrawBuffer = drawBuffer;
+ newCtx->ReadBuffer = readBuffer;
+ newCtx->NewState |= _NEW_BUFFERS;
+ /* gl_update_state( newCtx ); */
+ }
- if (newCtx && drawBuffer && readBuffer) {
- /* TODO: check if newCtx and buffer's visual match??? */
- newCtx->DrawBuffer = drawBuffer;
- newCtx->ReadBuffer = readBuffer;
- newCtx->NewState |= _NEW_BUFFERS;
- gl_update_state( newCtx );
- }
+ if (newCtx->Driver.MakeCurrent)
+ newCtx->Driver.MakeCurrent( newCtx, drawBuffer, readBuffer );
- /* We can use this to help debug user's problems. Tell the to set
- * the MESA_INFO env variable before running their app. Then the
- * first time each context is made current we'll print some useful
- * information.
- */
- if (newCtx && newCtx->FirstTimeCurrent) {
- if (getenv("MESA_INFO")) {
- fprintf(stderr, "Mesa GL_VERSION = %s\n", (char *) _mesa_GetString(GL_VERSION));
- fprintf(stderr, "Mesa GL_RENDERER = %s\n", (char *) _mesa_GetString(GL_RENDERER));
- fprintf(stderr, "Mesa GL_VENDOR = %s\n", (char *) _mesa_GetString(GL_VENDOR));
- fprintf(stderr, "Mesa GL_EXTENSIONS = %s\n", (char *) _mesa_GetString(GL_EXTENSIONS));
-#if defined(THREADS)
- fprintf(stderr, "Mesa thread-safe: YES\n");
-#else
- fprintf(stderr, "Mesa thread-safe: NO\n");
-#endif
-#if defined(USE_X86_ASM)
- fprintf(stderr, "Mesa x86-optimized: YES\n");
-#else
- fprintf(stderr, "Mesa x86-optimized: NO\n");
-#endif
+ /* We can use this to help debug user's problems. Tell them to set
+ * the MESA_INFO env variable before running their app. Then the
+ * first time each context is made current we'll print some useful
+ * information.
+ */
+ if (newCtx->FirstTimeCurrent) {
+ if (getenv("MESA_INFO")) {
+ print_info();
+ }
+ newCtx->FirstTimeCurrent = GL_FALSE;
}
- newCtx->FirstTimeCurrent = GL_FALSE;
}
}
@@ -1927,7 +1879,7 @@ _mesa_get_current_context( void )
void
_mesa_swapbuffers(GLcontext *ctx)
{
- FLUSH_VB( ctx, "swap buffers" );
+ FLUSH_TNL( ctx, FLUSH_STORED_VERTICES );
}