summaryrefslogtreecommitdiffstats
path: root/src/mesa/tnl/t_context.c
diff options
context:
space:
mode:
authorKeith Whitwell <[email protected]>2000-11-24 10:25:05 +0000
committerKeith Whitwell <[email protected]>2000-11-24 10:25:05 +0000
commitad2ac216fa0cbebc36530bf9e5256e902710b892 (patch)
tree2b44b0129679558d0a1760bf94d75bcdbfe145ad /src/mesa/tnl/t_context.c
parent00608a79dce1ea5e274f35b0a1883f7b623b9d7a (diff)
Support for swappable t&l modules, including an example one in the FX
driver (enable with FX_ALLOW_VTXFMT=t).
Diffstat (limited to 'src/mesa/tnl/t_context.c')
-rw-r--r--src/mesa/tnl/t_context.c173
1 files changed, 119 insertions, 54 deletions
diff --git a/src/mesa/tnl/t_context.c b/src/mesa/tnl/t_context.c
index 78608459b94..457aa1c85fc 100644
--- a/src/mesa/tnl/t_context.c
+++ b/src/mesa/tnl/t_context.c
@@ -1,5 +1,6 @@
#include "mtypes.h"
#include "mem.h"
+#include "vtxfmt.h"
#include "t_context.h"
#include "t_clip.h"
@@ -15,10 +16,11 @@
#include "t_vb.h"
#include "t_vbrender.h"
#include "t_vbxform.h"
+#include "t_vtxfmt.h"
#include "tnl.h"
#if !defined(THREADS)
-struct immediate *_mesa_CurrentInput = NULL;
+struct immediate *_tnl_CurrentInput = NULL;
#endif
@@ -31,9 +33,9 @@ _tnl_flush_vertices( GLcontext *ctx, GLuint flush_flags )
if ((IM->Flag[IM->Count] & (VERT_BEGIN|VERT_END)) != VERT_END ||
(flush_flags & (FLUSH_STORED_VERTICES|FLUSH_UPDATE_CURRENT)))
{
- if (IM->Flag[IM->Start])
- _mesa_flush_vb( ctx );
-
+ if (IM->Flag[IM->Start])
+ _tnl_maybe_transform_vb( IM );
+
/* Although this code updates the ctx->Current values, that bit
* is left set as there is no easy mechanism to set it
* elsewhere. This means that each time core wants to examine
@@ -50,6 +52,53 @@ _tnl_flush_vertices( GLcontext *ctx, GLuint flush_flags )
}
+
+ void
+_tnl_MakeCurrent( GLcontext *ctx,
+ GLframebuffer *drawBuffer,
+ GLframebuffer *readBuffer )
+{
+#ifndef THREADS
+ SET_IMMEDIATE( ctx, TNL_VB(ctx)->IM );
+#endif
+}
+
+
+/* Update all state that references _NeedEyeCoords
+ */
+ void
+_tnl_LightingSpaceChange( GLcontext *ctx )
+{
+ _tnl_update_normal_transform( ctx );
+}
+
+
+static void
+install_driver_callbacks( GLcontext *ctx )
+{
+ ctx->Driver.RenderVBCulledTab = _tnl_render_tab_cull;
+ ctx->Driver.RenderVBClippedTab = _tnl_render_tab_clipped;
+ ctx->Driver.RenderVBRawTab = _tnl_render_tab_raw;
+ ctx->Driver.NewList = _tnl_NewList;
+ ctx->Driver.EndList = _tnl_EndList;
+ ctx->Driver.FlushVertices = _tnl_flush_vertices;
+ ctx->Driver.NeedFlush = FLUSH_UPDATE_CURRENT;
+ ctx->Driver.LightingSpaceChange = _tnl_LightingSpaceChange;
+ ctx->Driver.MakeCurrent = _tnl_MakeCurrent;
+ ctx->Driver.VertexPointer = _tnl_VertexPointer;
+ ctx->Driver.NormalPointer = _tnl_NormalPointer;
+ ctx->Driver.ColorPointer = _tnl_ColorPointer;
+ ctx->Driver.FogCoordPointer = _tnl_FogCoordPointer;
+ ctx->Driver.IndexPointer = _tnl_IndexPointer;
+ ctx->Driver.SecondaryColorPointer = _tnl_SecondaryColorPointer;
+ ctx->Driver.TexCoordPointer = _tnl_TexCoordPointer;
+ ctx->Driver.EdgeFlagPointer = _tnl_EdgeFlagPointer;
+ ctx->Driver.LockArraysEXT = _tnl_LockArraysEXT;
+ ctx->Driver.UnlockArraysEXT = _tnl_UnlockArraysEXT;
+}
+
+
+
GLboolean
_tnl_CreateContext( GLcontext *ctx )
{
@@ -61,13 +110,13 @@ _tnl_CreateContext( GLcontext *ctx )
*/
if (firsttime) {
firsttime = 0;
- _tnl_clip_init( );
- _tnl_eval_init( );
- _tnl_shade_init( );
- _tnl_texture_init( );
- _tnl_trans_elt_init( );
- _tnl_vbrender_init( );
- _tnl_stages_init( );
+ _tnl_clip_init();
+ _tnl_eval_init();
+ _tnl_shade_init();
+ _tnl_texture_init();
+ _tnl_trans_elt_init();
+ _tnl_vbrender_init();
+ _tnl_stages_init();
}
/* Create the TNLcontext structure
@@ -79,7 +128,7 @@ _tnl_CreateContext( GLcontext *ctx )
/* Create and hook in the data structures available from ctx.
*/
- ctx->swtnl_vb = (void *)gl_vb_create_for_immediate( ctx );
+ ctx->swtnl_vb = (void *)_tnl_vb_create_for_immediate( ctx );
if (!ctx->swtnl_vb) {
FREE(tnl);
ctx->swtnl_context = 0;
@@ -93,6 +142,12 @@ _tnl_CreateContext( GLcontext *ctx )
*/
_tnl_dlist_init( ctx );
_tnl_pipeline_init( ctx );
+ _tnl_vtxfmt_init( ctx );
+ _tnl_cva_init( ctx );
+
+ _tnl_reset_vb( TNL_VB(ctx) );
+ _tnl_reset_input( ctx, 0, 0 ); /* initially outside begin/end */
+
tnl->_CurrentFlag = (VERT_NORM |
VERT_INDEX |
@@ -108,30 +163,14 @@ _tnl_CreateContext( GLcontext *ctx )
tnl->_CurrentPrimitive = GL_POLYGON+1;
- gl_reset_vb( TNL_VB(ctx) );
- gl_reset_input( ctx );
-
+ /* Hook our functions into exec and compile dispatch tables.
+ */
+ _mesa_install_save_vtxfmt( ctx, &tnl->vtxfmt );
+ _mesa_install_exec_vtxfmt( ctx, &tnl->vtxfmt );
- /* Set a few default values in the driver struct. This is a
- * temporary mechanism.
+ /* Set a few default values in the driver struct.
*/
- ctx->Driver.RenderVBCulledTab = _tnl_render_tab_cull;
- ctx->Driver.RenderVBClippedTab = _tnl_render_tab_clipped;
- ctx->Driver.RenderVBRawTab = _tnl_render_tab_raw;
- ctx->Driver.NewList = _tnl_NewList;
- ctx->Driver.EndList = _tnl_EndList;
- ctx->Driver.FlushVertices = _tnl_flush_vertices;
- ctx->Driver.NeedFlush = FLUSH_UPDATE_CURRENT;
- ctx->Driver.LightingSpaceChange = _tnl_LightingSpaceChange;
- ctx->Driver.MakeCurrent = _tnl_MakeCurrent;
- ctx->Driver.VertexPointer = _tnl_VertexPointer;
- ctx->Driver.NormalPointer = _tnl_NormalPointer;
- ctx->Driver.ColorPointer = _tnl_ColorPointer;
- ctx->Driver.FogCoordPointer = _tnl_FogCoordPointer;
- ctx->Driver.IndexPointer = _tnl_IndexPointer;
- ctx->Driver.SecondaryColorPointer = _tnl_SecondaryColorPointer;
- ctx->Driver.TexCoordPointer = _tnl_TexCoordPointer;
- ctx->Driver.EdgeFlagPointer = _tnl_EdgeFlagPointer;
+ install_driver_callbacks(ctx);
return GL_TRUE;
}
@@ -143,9 +182,9 @@ _tnl_DestroyContext( GLcontext *ctx )
TNLcontext *tnl = TNL_CONTEXT(ctx);
if (TNL_CURRENT_IM(ctx) != TNL_VB(ctx)->IM)
- gl_immediate_free( TNL_CURRENT_IM(ctx) );
+ _tnl_immediate_free( TNL_CURRENT_IM(ctx) );
- gl_vb_free( TNL_VB(ctx) );
+ _tnl_vb_free( TNL_VB(ctx) );
/* Free cache of immediate buffers. */
while (tnl->nr_im_queued-- > 0) {
@@ -156,23 +195,15 @@ _tnl_DestroyContext( GLcontext *ctx )
}
-/* Update all state that references _NeedEyeCoords
- */
-void
-_tnl_LightingSpaceChange( GLcontext *ctx )
-{
- _tnl_update_normal_transform( ctx );
-}
-
void
_tnl_InvalidateState( GLcontext *ctx, GLuint new_state )
{
if (new_state & _NEW_LIGHT)
- gl_update_lighting_function(ctx);
+ _tnl_update_lighting_function(ctx);
if (new_state & _NEW_ARRAY)
- gl_update_client_state( ctx );
+ _tnl_update_client_state( ctx );
if (new_state & _NEW_TEXTURE)
if (ctx->_Enabled & ENABLE_TEXGEN_ANY)
@@ -182,20 +213,54 @@ _tnl_InvalidateState( GLcontext *ctx, GLuint new_state )
_DD_NEW_TRI_LIGHT_TWOSIDE |
_DD_NEW_SEPERATE_SPECULAR |
_DD_NEW_TRI_UNFILLED ))
- gl_update_clipmask(ctx);
+ _tnl_update_clipmask(ctx);
if (new_state & _TNL_NEW_NORMAL_TRANSFORM)
_tnl_update_normal_transform( ctx );
- gl_update_pipelines(ctx);
+ _tnl_update_pipelines(ctx);
}
void
-_tnl_MakeCurrent( GLcontext *ctx,
- GLframebuffer *drawBuffer,
- GLframebuffer *readBuffer )
+_tnl_wakeup_exec( GLcontext *ctx )
{
-#ifndef THREADS
- SET_IMMEDIATE( ctx, TNL_VB(ctx)->IM );
-#endif
+ TNLcontext *tnl = TNL_CONTEXT(ctx);
+
+ fprintf(stderr, "%s\n", __FUNCTION__);
+
+ install_driver_callbacks(ctx);
+
+ /* Hook our functions into exec and compile dispatch tables.
+ */
+ _mesa_install_exec_vtxfmt( ctx, &tnl->vtxfmt );
+
+ /* Call all appropriate driver callbacks to revive state.
+ */
+ _tnl_MakeCurrent( ctx, ctx->DrawBuffer, ctx->ReadBuffer );
+ _tnl_UnlockArraysEXT( ctx );
+ _tnl_LockArraysEXT( ctx, ctx->Array.LockFirst, ctx->Array.LockCount );
+
+ /* Equivalent to calling all _tnl_*Pointer functions:
+ */
+ tnl->_ArrayNewState = ~0;
+
+ /* Assume we haven't been getting state updates either:
+ */
+ _tnl_InvalidateState( ctx, ~0 );
+
+ /* Special state not restored by other methods:
+ */
+ _tnl_recalc_current_flag( ctx );
}
+
+void
+_tnl_wakeup_save_exec( GLcontext *ctx )
+{
+ TNLcontext *tnl = TNL_CONTEXT(ctx);
+
+ fprintf(stderr, "%s\n", __FUNCTION__);
+
+ _tnl_wakeup_exec( ctx );
+ _mesa_install_save_vtxfmt( ctx, &tnl->vtxfmt );
+}
+