📄 trident_tris.c
字号:
#define TAG(x) x#define IND TRIDENT_FALLBACK_BIT#include "tnl_dd/t_dd_unfilled.h"#undef IND/*********************************************************************** * Generate GL render functions * ***********************************************************************/#define IND (0)#define TAG(x) x#include "tnl_dd/t_dd_tritmp.h"#define IND (TRIDENT_OFFSET_BIT)#define TAG(x) x##_offset#include "tnl_dd/t_dd_tritmp.h"#define IND (TRIDENT_TWOSIDE_BIT)#define TAG(x) x##_twoside#include "tnl_dd/t_dd_tritmp.h"#define IND (TRIDENT_TWOSIDE_BIT|TRIDENT_OFFSET_BIT)#define TAG(x) x##_twoside_offset#include "tnl_dd/t_dd_tritmp.h"#define IND (TRIDENT_UNFILLED_BIT)#define TAG(x) x##_unfilled#include "tnl_dd/t_dd_tritmp.h"#define IND (TRIDENT_OFFSET_BIT|TRIDENT_UNFILLED_BIT)#define TAG(x) x##_offset_unfilled#include "tnl_dd/t_dd_tritmp.h"#define IND (TRIDENT_TWOSIDE_BIT|TRIDENT_UNFILLED_BIT)#define TAG(x) x##_twoside_unfilled#include "tnl_dd/t_dd_tritmp.h"#define IND (TRIDENT_TWOSIDE_BIT|TRIDENT_OFFSET_BIT|TRIDENT_UNFILLED_BIT)#define TAG(x) x##_twoside_offset_unfilled#include "tnl_dd/t_dd_tritmp.h"#define IND (TRIDENT_FALLBACK_BIT)#define TAG(x) x##_fallback#include "tnl_dd/t_dd_tritmp.h"#define IND (TRIDENT_OFFSET_BIT|TRIDENT_FALLBACK_BIT)#define TAG(x) x##_offset_fallback#include "tnl_dd/t_dd_tritmp.h"#define IND (TRIDENT_TWOSIDE_BIT|TRIDENT_FALLBACK_BIT)#define TAG(x) x##_twoside_fallback#include "tnl_dd/t_dd_tritmp.h"#define IND (TRIDENT_TWOSIDE_BIT|TRIDENT_OFFSET_BIT|TRIDENT_FALLBACK_BIT)#define TAG(x) x##_twoside_offset_fallback#include "tnl_dd/t_dd_tritmp.h"#define IND (TRIDENT_UNFILLED_BIT|TRIDENT_FALLBACK_BIT)#define TAG(x) x##_unfilled_fallback#include "tnl_dd/t_dd_tritmp.h"#define IND (TRIDENT_OFFSET_BIT|TRIDENT_UNFILLED_BIT|TRIDENT_FALLBACK_BIT)#define TAG(x) x##_offset_unfilled_fallback#include "tnl_dd/t_dd_tritmp.h"#define IND (TRIDENT_TWOSIDE_BIT|TRIDENT_UNFILLED_BIT|TRIDENT_FALLBACK_BIT)#define TAG(x) x##_twoside_unfilled_fallback#include "tnl_dd/t_dd_tritmp.h"#define IND (TRIDENT_TWOSIDE_BIT|TRIDENT_OFFSET_BIT|TRIDENT_UNFILLED_BIT|TRIDENT_FALLBACK_BIT)#define TAG(x) x##_twoside_offset_unfilled_fallback#include "tnl_dd/t_dd_tritmp.h"static void init_rast_tab( void ){ init(); init_offset(); init_twoside(); init_twoside_offset(); init_unfilled(); init_offset_unfilled(); init_twoside_unfilled(); init_twoside_offset_unfilled(); init_fallback(); init_offset_fallback(); init_twoside_fallback(); init_twoside_offset_fallback(); init_unfilled_fallback(); init_offset_unfilled_fallback(); init_twoside_unfilled_fallback(); init_twoside_offset_unfilled_fallback();}/**********************************************************************//* Render unclipped begin/end objects *//**********************************************************************/#define VERT(x) (tridentVertex *)(tridentverts + (x << shift))#define RENDER_POINTS( start, count ) \ for ( ; start < count ; start++) \ trident_draw_point( tmesa, VERT(start) )#define RENDER_LINE( v0, v1 ) \ trident_draw_line( tmesa, VERT(v0), VERT(v1) )#define RENDER_TRI( v0, v1, v2 ) \ trident_draw_triangle( tmesa, VERT(v0), VERT(v1), VERT(v2) )#define RENDER_QUAD( v0, v1, v2, v3 ) \ trident_draw_quad( tmesa, VERT(v0), VERT(v1), VERT(v2), VERT(v3) )#define INIT(x) tridentRenderPrimitive( ctx, x );#undef LOCAL_VARS#define LOCAL_VARS \ tridentContextPtr tmesa = TRIDENT_CONTEXT(ctx); \ const GLuint shift = tmesa->vertex_stride_shift; \ const char *tridentverts = (char *)tmesa->verts; \ const GLboolean stipple = ctx->Line.StippleFlag; \ const GLuint * const elt = TNL_CONTEXT(ctx)->vb.Elts; \ (void) elt;#define RESET_STIPPLE if ( stipple ) tridentResetLineStipple( ctx );#define RESET_OCCLUSION#define PRESERVE_VB_DEFS#define ELT(x) (x)#define TAG(x) trident_##x##_verts#include "tnl/t_vb_rendertmp.h"#undef ELT#undef TAG#define TAG(x) trident_##x##_elts#define ELT(x) elt[x]#include "tnl/t_vb_rendertmp.h"/**********************************************************************//* Render clipped primitives *//**********************************************************************/static void tridentRenderClippedPoly( GLcontext *ctx, const GLuint *elts, GLuint n ){ tridentContextPtr tmesa = TRIDENT_CONTEXT(ctx); struct vertex_buffer *VB = &TNL_CONTEXT(ctx)->vb; TNLcontext *tnl = TNL_CONTEXT(ctx); GLuint prim = tmesa->render_primitive; /* Render the new vertices as an unclipped polygon. */ { GLuint *tmp = VB->Elts; VB->Elts = (GLuint *)elts; tnl->Driver.Render.PrimTabElts[GL_POLYGON]( ctx, 0, n, PRIM_BEGIN|PRIM_END ); VB->Elts = tmp; } /* Restore the render primitive */ if (prim != GL_POLYGON) tnl->Driver.Render.PrimitiveNotify( ctx, prim );}static void tridentRenderClippedLine( GLcontext *ctx, GLuint ii, GLuint jj ){ TNLcontext *tnl = TNL_CONTEXT(ctx); tnl->Driver.Render.Line( ctx, ii, jj );}/**********************************************************************//* Choose render functions *//**********************************************************************/#define _TRIDENT_NEW_RENDER_STATE (_DD_NEW_LINE_STIPPLE | \ _DD_NEW_LINE_SMOOTH | \ _DD_NEW_POINT_SMOOTH | \ _DD_NEW_TRI_SMOOTH | \ _DD_NEW_TRI_UNFILLED | \ _DD_NEW_TRI_LIGHT_TWOSIDE | \ _DD_NEW_TRI_OFFSET) \#define POINT_FALLBACK (DD_POINT_SMOOTH)#define LINE_FALLBACK (DD_LINE_STIPPLE|DD_LINE_SMOOTH)#define TRI_FALLBACK (DD_TRI_SMOOTH)#define ANY_FALLBACK_FLAGS (POINT_FALLBACK|LINE_FALLBACK|TRI_FALLBACK)#define ANY_RASTER_FLAGS (DD_TRI_LIGHT_TWOSIDE|DD_TRI_OFFSET|DD_TRI_UNFILLED)static void tridentChooseRenderState(GLcontext *ctx){ tridentContextPtr tmesa = TRIDENT_CONTEXT(ctx); TNLcontext *tnl = TNL_CONTEXT(ctx); GLuint flags = ctx->_TriangleCaps; GLuint index = 0; if (flags & (ANY_RASTER_FLAGS|ANY_FALLBACK_FLAGS)) { tmesa->draw_point = trident_draw_point; tmesa->draw_line = trident_draw_line; tmesa->draw_tri = trident_draw_triangle; if (flags & ANY_RASTER_FLAGS) { if (flags & DD_TRI_LIGHT_TWOSIDE) index |= TRIDENT_TWOSIDE_BIT; if (flags & DD_TRI_OFFSET) index |= TRIDENT_OFFSET_BIT; if (flags & DD_TRI_UNFILLED) index |= TRIDENT_UNFILLED_BIT; } /* Hook in fallbacks for specific primitives. */ if (flags & (POINT_FALLBACK|LINE_FALLBACK|TRI_FALLBACK)) { if (flags & POINT_FALLBACK) tmesa->draw_point = trident_fallback_point; if (flags & LINE_FALLBACK) tmesa->draw_line = trident_fallback_line; if (flags & TRI_FALLBACK) tmesa->draw_tri = trident_fallback_tri; index |= TRIDENT_FALLBACK_BIT; } } if (tmesa->RenderIndex != index) { tmesa->RenderIndex = index; tnl->Driver.Render.Points = rast_tab[index].points; tnl->Driver.Render.Line = rast_tab[index].line; tnl->Driver.Render.Triangle = rast_tab[index].triangle; tnl->Driver.Render.Quad = rast_tab[index].quad; if (tmesa->RenderIndex == 0) { tnl->Driver.Render.PrimTabVerts = trident_render_tab_verts; tnl->Driver.Render.PrimTabElts = trident_render_tab_elts; } else { tnl->Driver.Render.PrimTabVerts = _tnl_render_tab_verts; tnl->Driver.Render.PrimTabElts = _tnl_render_tab_elts; } tnl->Driver.Render.ClippedLine = tridentRenderClippedLine; tnl->Driver.Render.ClippedPolygon = tridentRenderClippedPoly; }}/**********************************************************************//* High level hooks for t_vb_render.c *//**********************************************************************//* Determine the rasterized primitive when not drawing unfilled * polygons. * * Used only for the default render stage which always decomposes * primitives to trianges/lines/points. For the accelerated stage, * which renders strips as strips, the equivalent calculations are * performed in tridentrender.c. */#if 0static void tridentRasterPrimitive( GLcontext *ctx, GLuint hwprim ){ tridentContextPtr tmesa = TRIDENT_CONTEXT(ctx); if (tmesa->hw_primitive != hwprim) tmesa->hw_primitive = hwprim;}#endifstatic void tridentRenderPrimitive( GLcontext *ctx, GLenum prim ){ tridentContextPtr tmesa = TRIDENT_CONTEXT(ctx); tmesa->render_primitive = prim;}static void tridentRunPipeline( GLcontext *ctx ){ tridentContextPtr tmesa = TRIDENT_CONTEXT(ctx); if ( tmesa->new_state ) tridentDDUpdateHWState( ctx ); if (tmesa->new_gl_state) {#if 0 if (tmesa->new_gl_state & _NEW_TEXTURE) tridentUpdateTextureState( ctx );#endif if (!tmesa->Fallback) { if (tmesa->new_gl_state & _TRIDENT_NEW_VERTEX) tridentChooseVertexState( ctx ); if (tmesa->new_gl_state & _TRIDENT_NEW_RENDER_STATE) tridentChooseRenderState( ctx ); } tmesa->new_gl_state = 0; } _tnl_run_pipeline( ctx );}static void tridentRenderStart( GLcontext *ctx ){ /* Check for projective texturing. Make sure all texcoord * pointers point to something. (fix in mesa?) */ tridentCheckTexSizes( ctx );}static void tridentRenderFinish( GLcontext *ctx ){ if (0) _swrast_flush( ctx ); /* never needed */}static void tridentResetLineStipple( GLcontext *ctx ){ tridentContextPtr tmesa = TRIDENT_CONTEXT(ctx); (void) tmesa; /* Reset the hardware stipple counter. */}/**********************************************************************//* Transition to/from hardware rasterization. *//**********************************************************************/void tridentFallback( tridentContextPtr tmesa, GLuint bit, GLboolean mode ){ GLcontext *ctx = tmesa->glCtx; TNLcontext *tnl = TNL_CONTEXT(ctx); GLuint oldfallback = tmesa->Fallback; _tnl_need_projected_coords( ctx, GL_FALSE ); if (mode) { tmesa->Fallback |= bit; if (oldfallback == 0) { _swsetup_Wakeup( ctx ); tmesa->RenderIndex = ~0; } } else { tmesa->Fallback &= ~bit; if (oldfallback == bit) { _swrast_flush( ctx ); tnl->Driver.Render.Start = tridentRenderStart; tnl->Driver.Render.PrimitiveNotify = tridentRenderPrimitive; tnl->Driver.Render.Finish = tridentRenderFinish; tnl->Driver.Render.BuildVertices = tridentBuildVertices; tnl->Driver.Render.ResetLineStipple = tridentResetLineStipple; tmesa->new_gl_state |= (_TRIDENT_NEW_RENDER_STATE| _TRIDENT_NEW_VERTEX); } }}/**********************************************************************//* Initialization. *//**********************************************************************/void tridentDDInitTriFuncs( GLcontext *ctx ){ tridentContextPtr tmesa = TRIDENT_CONTEXT(ctx); TNLcontext *tnl = TNL_CONTEXT(ctx); static int firsttime = 1; if (firsttime) { init_rast_tab(); firsttime = 0; } tmesa->RenderIndex = ~0; tnl->Driver.RunPipeline = tridentRunPipeline; tnl->Driver.Render.Start = tridentRenderStart; tnl->Driver.Render.Finish = tridentRenderFinish; tnl->Driver.Render.PrimitiveNotify = tridentRenderPrimitive; tnl->Driver.Render.ResetLineStipple = tridentResetLineStipple; tnl->Driver.Render.BuildVertices = tridentBuildVertices;}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -