📄 trident_tris.c
字号:
printf("0x%x\n",clr.i); MMIO_OUT32(MMIO, 0x002820 , clr.i ); clr.f = 5.0; MMIO_OUT32(MMIO, 0x002824 , clr.i ); clr.f = 1.0; MMIO_OUT32(MMIO, 0x002828 , clr.i ); MMIO_OUT32(MMIO, 0x00282C , 0xFF ); #if 0 clr.f = 1.0; MMIO_OUT32(MMIO, 0x002830 , clr.i ); clr.f = 0.0; MMIO_OUT32(MMIO, 0x002834 , clr.i );#endifprintf("sec TRI\n"); MMIO_OUT32(MMIO, 0x00281C , 0x00093980 ); clr.f = 395.0; MMIO_OUT32(MMIO, 0x002820 , clr.i ); clr.f = 595.0; MMIO_OUT32(MMIO, 0x002824 , clr.i ); clr.f = 1.0; MMIO_OUT32(MMIO, 0x002828 , clr.i ); MMIO_OUT32(MMIO, 0x00282C , 0x00FF00 ); #if 0 clr.f = 1.0; MMIO_OUT32(MMIO, 0x002830 , clr.i ); clr.f = 1.0; MMIO_OUT32(MMIO, 0x002834 , clr.i );#endif#if 0 MMIO_OUT32(MMIO, 0x002368 , MMIO_IN32(MMIO,0x002368)&0xfffffffe );#endifprintf("fin TRI\n"); return 0; }static INLINE void trident_draw_point(tridentContextPtr tmesa, const tridentVertex *v0 ){ unsigned char *MMIO = tmesa->tridentScreen->mmio.map; (void) MMIO;}static INLINE void trident_draw_line( tridentContextPtr tmesa, const tridentVertex *v0, const tridentVertex *v1 ){ unsigned char *MMIO = tmesa->tridentScreen->mmio.map; (void) MMIO;}static INLINE void trident_draw_triangle( tridentContextPtr tmesa, const tridentVertex *v0, const tridentVertex *v1, const tridentVertex *v2 ){}static INLINE void trident_draw_quad( tridentContextPtr tmesa, const tridentVertex *v0, const tridentVertex *v1, const tridentVertex *v2, const tridentVertex *v3 ){ GLuint vertsize = tmesa->vertex_size; GLint coloridx = (vertsize > 4) ? 4 : 3; unsigned char *MMIO = tmesa->tridentScreen->mmio.map; int clr; float *ftmp = (float *)(&clr); if (tmesa->dirty) tridentUploadHwStateLocked( tmesa );#if 0 DrawTriangle(tmesa); exit(0);#else#if 1 if (first) { Init3D(tmesa);#if 0 DrawTriangle(tmesa);#endif first = 0; }#endif LOCK_HARDWARE( tmesa ); MMIO_OUT32(MMIO, 0x002C00 , 0x00000010 ); MMIO_OUT32(MMIO, 0x002C04 , 0x029C00C0 ); /* Z buffer */ MMIO_OUT32(MMIO, 0x002C24 , 0x00100000 /*| (tmesa->tridentScreen->depthOffset)*/ ); MMIO_OUT32(MMIO, 0x002C28 , 0xE0000000 | (tmesa->tridentScreen->depthPitch * 4) ); /* front buffer */ MMIO_OUT32(MMIO, 0x002C50 , 0x00000000 | (tmesa->drawOffset) ); MMIO_OUT32(MMIO, 0x002C54 , 0x0C320000 | (tmesa->drawPitch * 4) ); /* clipper */ MMIO_OUT32(MMIO, 0x002C80 , 0x20008000 | tmesa->tridentScreen->height ); MMIO_OUT32(MMIO, 0x002C84 , 0x20000000 | tmesa->tridentScreen->width ); /* writemask */ MMIO_OUT32(MMIO, 0x002C94 , 0xFFFFFFFF );if (vertsize == 4) { MMIO_OUT32(MMIO, 0x002818 , 0x0003A020 ); MMIO_OUT32(MMIO, 0x00281C , 0x00098021 ); *ftmp = v0->v.x; MMIO_OUT32(MMIO, 0x002820 , clr ); *ftmp = v0->v.y; MMIO_OUT32(MMIO, 0x002824 , clr ); *ftmp = v0->v.z; MMIO_OUT32(MMIO, 0x002828 , clr );#if 0 *ftmp = v0->v.w; MMIO_OUT32(MMIO, 0x00282C , clr );#endif MMIO_OUT32(MMIO, 0x00282C , v0->ui[coloridx] ); *ftmp = v1->v.x; MMIO_OUT32(MMIO, 0x002820 , clr ); *ftmp = v1->v.y; MMIO_OUT32(MMIO, 0x002824 , clr ); *ftmp = v1->v.z; MMIO_OUT32(MMIO, 0x002828 , clr );#if 0 *ftmp = v1->v.w; MMIO_OUT32(MMIO, 0x00282C , clr );#endif MMIO_OUT32(MMIO, 0x00282C , v1->ui[coloridx] ); *ftmp = v2->v.x; MMIO_OUT32(MMIO, 0x002820 , clr ); *ftmp = v2->v.y; MMIO_OUT32(MMIO, 0x002824 , clr ); *ftmp = v2->v.z; MMIO_OUT32(MMIO, 0x002828 , clr );#if 0 *ftmp = v2->v.w; MMIO_OUT32(MMIO, 0x00282C , clr );#endif MMIO_OUT32(MMIO, 0x00282C , v2->ui[coloridx] ); MMIO_OUT32(MMIO, 0x00281C , 0x00093020 ); *ftmp = v3->v.x; MMIO_OUT32(MMIO, 0x002820 , clr ); *ftmp = v3->v.y; MMIO_OUT32(MMIO, 0x002824 , clr ); *ftmp = v3->v.z; MMIO_OUT32(MMIO, 0x002828 , clr );#if 0 *ftmp = v3->v.w; MMIO_OUT32(MMIO, 0x00282C , clr );#endif MMIO_OUT32(MMIO, 0x00282C , v3->ui[coloridx] ); }#endif UNLOCK_HARDWARE( tmesa );}/*********************************************************************** * Rasterization fallback helpers * ***********************************************************************//* This code is hit only when a mix of accelerated and unaccelerated * primitives are being drawn, and only for the unaccelerated * primitives. */#if 0static void trident_fallback_quad( tridentContextPtr tmesa, const tridentVertex *v0, const tridentVertex *v1, const tridentVertex *v2, const tridentVertex *v3 ){ GLcontext *ctx = tmesa->glCtx; SWvertex v[4]; trident_translate_vertex( ctx, v0, &v[0] ); trident_translate_vertex( ctx, v1, &v[1] ); trident_translate_vertex( ctx, v2, &v[2] ); trident_translate_vertex( ctx, v3, &v[3] ); _swrast_Quad( ctx, &v[0], &v[1], &v[2], &v[3] );}#endif/* XXX hack to get the prototype defined in time... */void trident_translate_vertex(GLcontext *ctx, const tridentVertex *src, SWvertex *dst);static void trident_fallback_tri( tridentContextPtr tmesa, const tridentVertex *v0, const tridentVertex *v1, const tridentVertex *v2 ){ GLcontext *ctx = tmesa->glCtx; SWvertex v[3]; trident_translate_vertex( ctx, v0, &v[0] ); trident_translate_vertex( ctx, v1, &v[1] ); trident_translate_vertex( ctx, v2, &v[2] ); _swrast_Triangle( ctx, &v[0], &v[1], &v[2] );}static void trident_fallback_line( tridentContextPtr tmesa, const tridentVertex *v0, const tridentVertex *v1 ){ GLcontext *ctx = tmesa->glCtx; SWvertex v[2]; trident_translate_vertex( ctx, v0, &v[0] ); trident_translate_vertex( ctx, v1, &v[1] ); _swrast_Line( ctx, &v[0], &v[1] );}static void trident_fallback_point( tridentContextPtr tmesa, const tridentVertex *v0 ){ GLcontext *ctx = tmesa->glCtx; SWvertex v[1]; trident_translate_vertex( ctx, v0, &v[0] ); _swrast_Point( ctx, &v[0] );}/*********************************************************************** * Macros for t_dd_tritmp.h to draw basic primitives * ***********************************************************************/#define TRI( a, b, c ) \do { \ if (DO_FALLBACK) \ tmesa->draw_tri( tmesa, a, b, c ); \ else \ trident_draw_triangle( tmesa, a, b, c ); \} while (0)#define QUAD( a, b, c, d ) \do { \ if (DO_FALLBACK) { \ tmesa->draw_tri( tmesa, a, b, d ); \ tmesa->draw_tri( tmesa, b, c, d ); \ } else \ trident_draw_quad( tmesa, a, b, c, d ); \} while (0)#define LINE( v0, v1 ) \do { \ if (DO_FALLBACK) \ tmesa->draw_line( tmesa, v0, v1 ); \ else \ trident_draw_line( tmesa, v0, v1 ); \} while (0)#define POINT( v0 ) \do { \ if (DO_FALLBACK) \ tmesa->draw_point( tmesa, v0 ); \ else \ trident_draw_point( tmesa, v0 ); \} while (0)/*********************************************************************** * Build render functions from dd templates * ***********************************************************************/#define TRIDENT_OFFSET_BIT 0x01#define TRIDENT_TWOSIDE_BIT 0x02#define TRIDENT_UNFILLED_BIT 0x04#define TRIDENT_FALLBACK_BIT 0x08#define TRIDENT_MAX_TRIFUNC 0x10static struct { tnl_points_func points; tnl_line_func line; tnl_triangle_func triangle; tnl_quad_func quad;} rast_tab[TRIDENT_MAX_TRIFUNC];#define DO_FALLBACK (IND & TRIDENT_FALLBACK_BIT)#define DO_OFFSET (IND & TRIDENT_OFFSET_BIT)#define DO_UNFILLED (IND & TRIDENT_UNFILLED_BIT)#define DO_TWOSIDE (IND & TRIDENT_TWOSIDE_BIT)#define DO_FLAT 0#define DO_TRI 1#define DO_QUAD 1#define DO_LINE 1#define DO_POINTS 1#define DO_FULL_QUAD 1#define HAVE_RGBA 1#define HAVE_SPEC 1#define HAVE_BACK_COLORS 0#define HAVE_HW_FLATSHADE 1#define VERTEX tridentVertex#define TAB rast_tab#define DEPTH_SCALE 1.0#define UNFILLED_TRI unfilled_tri#define UNFILLED_QUAD unfilled_quad#define VERT_X(_v) _v->v.x#define VERT_Y(_v) _v->v.y#define VERT_Z(_v) _v->v.z#define AREA_IS_CCW( a ) (a > 0)#define GET_VERTEX(e) (tmesa->verts + (e<<tmesa->vertex_stride_shift))#define TRIDENT_COLOR( dst, src ) \do { \ dst[0] = src[2]; \ dst[1] = src[1]; \ dst[2] = src[0]; \ dst[3] = src[3]; \} while (0)#define TRIDENT_SPEC( dst, src ) \do { \ dst[0] = src[2]; \ dst[1] = src[1]; \ dst[2] = src[0]; \} while (0)#define VERT_SET_RGBA( v, c ) TRIDENT_COLOR( v->ub4[coloroffset], c )#define VERT_COPY_RGBA( v0, v1 ) v0->ui[coloroffset] = v1->ui[coloroffset]#define VERT_SAVE_RGBA( idx ) color[idx] = v[idx]->ui[coloroffset]#define VERT_RESTORE_RGBA( idx ) v[idx]->ui[coloroffset] = color[idx]#define VERT_SET_SPEC( v, c ) if (havespec) TRIDENT_SPEC( v->ub4[5], c )#define VERT_COPY_SPEC( v0, v1 ) if (havespec) COPY_3V(v0->ub4[5], v1->ub4[5])#define VERT_SAVE_SPEC( idx ) if (havespec) spec[idx] = v[idx]->ui[5]#define VERT_RESTORE_SPEC( idx ) if (havespec) v[idx]->ui[5] = spec[idx]#define LOCAL_VARS(n) \ tridentContextPtr tmesa = TRIDENT_CONTEXT(ctx); \ GLuint color[n], spec[n]; \ GLuint coloroffset = (tmesa->vertex_size == 4 ? 3 : 4); \ GLboolean havespec = (tmesa->vertex_size == 4 ? 0 : 1); \ (void) color; (void) spec; (void) coloroffset; (void) havespec;/*********************************************************************** * Helpers for rendering unfilled primitives * ***********************************************************************/#if 0static 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};#endifstatic void tridentResetLineStipple( GLcontext *ctx );#if 0static void tridentRasterPrimitive( GLcontext *ctx, GLuint hwprim );#endifstatic void tridentRenderPrimitive( GLcontext *ctx, GLenum prim );#define RASTERIZE(x) /*if (tmesa->hw_primitive != hw_prim[x]) \ tridentRasterPrimitive( ctx, hw_prim[x] ) */#define RENDER_PRIMITIVE tmesa->render_primitive
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -