📄 gamma_tris.c
字号:
***********************************************************************/static const GLuint hw_prim[GL_POLYGON+1] = { B_PrimType_Points, B_PrimType_Lines, B_PrimType_Lines, B_PrimType_Lines, B_PrimType_Triangles, B_PrimType_Triangles, B_PrimType_Triangles, B_PrimType_Triangles, B_PrimType_Triangles, B_PrimType_Triangles};static void gammaResetLineStipple( GLcontext *ctx );static void gammaRasterPrimitive( GLcontext *ctx, GLuint hwprim );static void gammaRenderPrimitive( GLcontext *ctx, GLenum prim );#define RASTERIZE(x) if (gmesa->hw_primitive != hw_prim[x]) \ gammaRasterPrimitive( ctx, hw_prim[x] )#define RENDER_PRIMITIVE gmesa->render_primitive#define TAG(x) x#define IND GAMMA_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 (GAMMA_OFFSET_BIT)#define TAG(x) x##_offset#include "tnl_dd/t_dd_tritmp.h"#define IND (GAMMA_TWOSIDE_BIT)#define TAG(x) x##_twoside#include "tnl_dd/t_dd_tritmp.h"#define IND (GAMMA_TWOSIDE_BIT|GAMMA_OFFSET_BIT)#define TAG(x) x##_twoside_offset#include "tnl_dd/t_dd_tritmp.h"#define IND (GAMMA_UNFILLED_BIT)#define TAG(x) x##_unfilled#include "tnl_dd/t_dd_tritmp.h"#define IND (GAMMA_OFFSET_BIT|GAMMA_UNFILLED_BIT)#define TAG(x) x##_offset_unfilled#include "tnl_dd/t_dd_tritmp.h"#define IND (GAMMA_TWOSIDE_BIT|GAMMA_UNFILLED_BIT)#define TAG(x) x##_twoside_unfilled#include "tnl_dd/t_dd_tritmp.h"#define IND (GAMMA_TWOSIDE_BIT|GAMMA_OFFSET_BIT|GAMMA_UNFILLED_BIT)#define TAG(x) x##_twoside_offset_unfilled#include "tnl_dd/t_dd_tritmp.h"static void init_render_tab( void ){ init(); init_offset(); init_twoside(); init_twoside_offset(); init_unfilled(); init_offset_unfilled(); init_twoside_unfilled(); init_twoside_offset_unfilled();}/**********************************************************************//* Render unclipped begin/end objects *//**********************************************************************/#define VERT(x) (gammaVertex *)(gammaverts + (x * size * sizeof(int)))#define RENDER_POINTS( start, count ) \ for ( ; start < count ; start++) \ gmesa->draw_point( gmesa, VERT(start) )#define RENDER_LINE( v0, v1 ) \ gmesa->draw_line( gmesa, VERT(v0), VERT(v1) )#define RENDER_TRI( v0, v1, v2 ) \ gmesa->draw_tri( gmesa, VERT(v0), VERT(v1), VERT(v2) )#define RENDER_QUAD( v0, v1, v2, v3 ) \ gmesa->draw_quad( gmesa, VERT(v0), VERT(v1), VERT(v2), VERT(v3) )#define INIT(x) gammaRenderPrimitive( ctx, x );#undef LOCAL_VARS#define LOCAL_VARS \ gammaContextPtr gmesa = GAMMA_CONTEXT(ctx); \ const GLuint size = gmesa->vertex_size; \ const char *gammaverts = (char *)gmesa->verts; \ const GLboolean stipple = ctx->Line.StippleFlag; \ (void) stipple;#define RESET_STIPPLE if ( stipple ) gammaResetLineStipple( ctx );#define RESET_OCCLUSION#define PRESERVE_VB_DEFS#define ELT(x) (x)#define TAG(x) gamma_##x##_verts#include "tnl/t_vb_rendertmp.h"/**********************************************************************//* Render clipped primitives *//**********************************************************************/static void gammaRenderClippedPoly( GLcontext *ctx, const GLuint *elts, GLuint n ){ gammaContextPtr gmesa = GAMMA_CONTEXT(ctx); struct vertex_buffer *VB = &TNL_CONTEXT(ctx)->vb; TNLcontext *tnl = TNL_CONTEXT(ctx); GLuint prim = gmesa->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 gammaRenderClippedLine( GLcontext *ctx, GLuint ii, GLuint jj ){ TNLcontext *tnl = TNL_CONTEXT(ctx); tnl->Driver.Render.Line( ctx, ii, jj );}/**********************************************************************//* Choose render functions *//**********************************************************************/#define _GAMMA_NEW_RENDERSTATE (_DD_NEW_TRI_UNFILLED | \ _DD_NEW_TRI_LIGHT_TWOSIDE | \ _DD_NEW_TRI_OFFSET)#define ANY_RASTER_FLAGS (DD_TRI_LIGHT_TWOSIDE|DD_TRI_OFFSET|DD_TRI_UNFILLED)static void gammaChooseRenderState(GLcontext *ctx){ gammaContextPtr gmesa = GAMMA_CONTEXT(ctx); TNLcontext *tnl = TNL_CONTEXT(ctx); GLuint flags = ctx->_TriangleCaps; GLuint index = 0; if (flags & ANY_RASTER_FLAGS) { if (flags & DD_TRI_LIGHT_TWOSIDE) index |= GAMMA_TWOSIDE_BIT; if (flags & DD_TRI_OFFSET) index |= GAMMA_OFFSET_BIT; if (flags & DD_TRI_UNFILLED) index |= GAMMA_UNFILLED_BIT; } if (gmesa->RenderIndex != index) { gmesa->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 (gmesa->RenderIndex == 0) tnl->Driver.Render.PrimTabVerts = gamma_render_tab_verts; else tnl->Driver.Render.PrimTabVerts = _tnl_render_tab_verts; tnl->Driver.Render.PrimTabElts = _tnl_render_tab_elts; tnl->Driver.Render.ClippedLine = gammaRenderClippedLine; tnl->Driver.Render.ClippedPolygon = gammaRenderClippedPoly; }}/**********************************************************************//* 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 gammarender.c. */static void gammaRasterPrimitive( GLcontext *ctx, GLuint hwprim ){ gammaContextPtr gmesa = GAMMA_CONTEXT(ctx); if (gmesa->hw_primitive != hwprim) gmesa->hw_primitive = hwprim;}static void gammaRenderPrimitive( GLcontext *ctx, GLenum prim ){ gammaContextPtr gmesa = GAMMA_CONTEXT(ctx); gmesa->render_primitive = prim;}static void gammaRunPipeline( GLcontext *ctx ){ gammaContextPtr gmesa = GAMMA_CONTEXT(ctx); if ( gmesa->new_state ) gammaDDUpdateHWState( ctx ); if (gmesa->new_gl_state) { if (gmesa->new_gl_state & _NEW_TEXTURE) gammaUpdateTextureState( ctx ); if (!gmesa->Fallback) { if (gmesa->new_gl_state & _GAMMA_NEW_VERTEX) gammaChooseVertexState( ctx ); if (gmesa->new_gl_state & _GAMMA_NEW_RASTER_STATE) gammaChooseRasterState( ctx ); if (gmesa->new_gl_state & _GAMMA_NEW_RENDERSTATE) gammaChooseRenderState( ctx ); } gmesa->new_gl_state = 0; } _tnl_run_pipeline( ctx );}static void gammaRenderStart( GLcontext *ctx ){ /* Check for projective texturing. Make sure all texcoord * pointers point to something. (fix in mesa?) */ gammaCheckTexSizes( ctx );}static void gammaRenderFinish( GLcontext *ctx ){ if (0) _swrast_flush( ctx ); /* never needed */}static void gammaResetLineStipple( GLcontext *ctx ){ gammaContextPtr gmesa = GAMMA_CONTEXT(ctx); /* Reset the hardware stipple counter. */ CHECK_DMA_BUFFER(gmesa, 1); WRITE(gmesa->buf, UpdateLineStippleCounters, 0);}/**********************************************************************//* Transition to/from hardware rasterization. *//**********************************************************************/void gammaFallback( gammaContextPtr gmesa, GLuint bit, GLboolean mode ){ GLcontext *ctx = gmesa->glCtx; TNLcontext *tnl = TNL_CONTEXT(ctx); GLuint oldfallback = gmesa->Fallback; if (mode) { gmesa->Fallback |= bit; if (oldfallback == 0) { _swsetup_Wakeup( ctx ); _tnl_need_projected_coords( ctx, GL_TRUE ); gmesa->RenderIndex = ~0; } } else { gmesa->Fallback &= ~bit; if (oldfallback == bit) { _swrast_flush( ctx ); tnl->Driver.Render.Start = gammaRenderStart; tnl->Driver.Render.PrimitiveNotify = gammaRenderPrimitive; tnl->Driver.Render.Finish = gammaRenderFinish; tnl->Driver.Render.BuildVertices = gammaBuildVertices; tnl->Driver.Render.ResetLineStipple = gammaResetLineStipple; gmesa->new_gl_state |= (_GAMMA_NEW_RENDERSTATE| _GAMMA_NEW_RASTER_STATE| _GAMMA_NEW_VERTEX); } }}/**********************************************************************//* Initialization. *//**********************************************************************/void gammaDDInitTriFuncs( GLcontext *ctx ){ gammaContextPtr gmesa = GAMMA_CONTEXT(ctx); TNLcontext *tnl = TNL_CONTEXT(ctx); static int firsttime = 1; if (firsttime) { init_rast_tab(); init_render_tab(); firsttime = 0; } gmesa->RenderIndex = ~0; tnl->Driver.RunPipeline = gammaRunPipeline; tnl->Driver.Render.Start = gammaRenderStart; tnl->Driver.Render.Finish = gammaRenderFinish; tnl->Driver.Render.PrimitiveNotify = gammaRenderPrimitive; tnl->Driver.Render.ResetLineStipple = gammaResetLineStipple; tnl->Driver.Render.BuildVertices = gammaBuildVertices;}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -