diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/mesa/drivers/dri/r128/Makefile | 3 | ||||
-rw-r--r-- | src/mesa/drivers/dri/r128/r128_context.c | 5 | ||||
-rw-r--r-- | src/mesa/drivers/dri/r128/r128_context.h | 19 | ||||
-rw-r--r-- | src/mesa/drivers/dri/r128/r128_dd.c | 4 | ||||
-rw-r--r-- | src/mesa/drivers/dri/r128/r128_ioctl.h | 6 | ||||
-rw-r--r-- | src/mesa/drivers/dri/r128/r128_lock.c | 2 | ||||
-rw-r--r-- | src/mesa/drivers/dri/r128/r128_screen.c | 1 | ||||
-rw-r--r-- | src/mesa/drivers/dri/r128/r128_state.c | 1 | ||||
-rw-r--r-- | src/mesa/drivers/dri/r128/r128_tex.c | 1 | ||||
-rw-r--r-- | src/mesa/drivers/dri/r128/r128_texmem.c | 1 | ||||
-rw-r--r-- | src/mesa/drivers/dri/r128/r128_texstate.c | 1 | ||||
-rw-r--r-- | src/mesa/drivers/dri/r128/r128_tris.c | 356 | ||||
-rw-r--r-- | src/mesa/drivers/dri/r128/r128_vb.c | 507 | ||||
-rw-r--r-- | src/mesa/drivers/dri/r128/r128_vb.h | 74 |
14 files changed, 195 insertions, 786 deletions
diff --git a/src/mesa/drivers/dri/r128/Makefile b/src/mesa/drivers/dri/r128/Makefile index 65e872e90ca..01d912c89da 100644 --- a/src/mesa/drivers/dri/r128/Makefile +++ b/src/mesa/drivers/dri/r128/Makefile @@ -28,8 +28,7 @@ DRIVER_SOURCES = \ r128_tris.c \ r128_ioctl.c \ r128_span.c \ - r128_texmem.c \ - r128_vb.c + r128_texmem.c C_SOURCES = \ $(COMMON_SOURCES) \ diff --git a/src/mesa/drivers/dri/r128/r128_context.c b/src/mesa/drivers/dri/r128/r128_context.c index 8075270a8c9..2b0363d2921 100644 --- a/src/mesa/drivers/dri/r128/r128_context.c +++ b/src/mesa/drivers/dri/r128/r128_context.c @@ -56,7 +56,6 @@ USE OR OTHER DEALINGS IN THE SOFTWARE. #include "r128_span.h" #include "r128_tex.h" #include "r128_tris.h" -#include "r128_vb.h" #include "vblank.h" #include "utils.h" @@ -180,6 +179,7 @@ GLboolean r128CreateContext( const __GLcontextModes *glVisual, rmesa->RenderIndex = -1; /* Impossible value */ rmesa->vert_buf = NULL; rmesa->num_verts = 0; + rmesa->tnl_state = ~0; /* Set the maximum texture size small enough that we can guarentee that * all texture units can bind a maximal texture and have them both in @@ -243,7 +243,6 @@ GLboolean r128CreateContext( const __GLcontextModes *glVisual, if (sPriv->drmMinor >= 4) _mesa_enable_extension( ctx, "GL_MESA_ycbcr_texture" ); - r128InitVB( ctx ); r128InitTriFuncs( ctx ); r128DDInitStateFuncs( ctx ); r128DDInitSpanFuncs( ctx ); @@ -280,8 +279,6 @@ void r128DestroyContext( __DRIcontextPrivate *driContextPriv ) _ac_DestroyContext( rmesa->glCtx ); _swrast_DestroyContext( rmesa->glCtx ); - r128FreeVB( rmesa->glCtx ); - /* free the Mesa context */ rmesa->glCtx->DriverCtx = NULL; _mesa_destroy_context(rmesa->glCtx); diff --git a/src/mesa/drivers/dri/r128/r128_context.h b/src/mesa/drivers/dri/r128/r128_context.h index 3e4ac2bf329..7477b95fadf 100644 --- a/src/mesa/drivers/dri/r128/r128_context.h +++ b/src/mesa/drivers/dri/r128/r128_context.h @@ -43,6 +43,7 @@ USE OR OTHER DEALINGS IN THE SOFTWARE. #include "r128_drm.h" #include "mtypes.h" +#include "tnl/t_vertex.h" #include "r128_reg.h" @@ -81,6 +82,7 @@ typedef struct r128_context *r128ContextPtr; #define R128_FALLBACK_SEP_SPECULAR 0x0080 #define R128_FALLBACK_BLEND_EQ 0x0100 #define R128_FALLBACK_BLEND_FUNC 0x0200 +#define R128_FALLBACK_PROJTEX 0x0400 /* Use the templated vertex format: @@ -122,18 +124,21 @@ struct r128_context { GLuint dirty; /* Hardware state to be updated */ drm_r128_context_regs_t setup; + /* Vertex state */ + GLuint vertex_size; + GLuint vertex_format; + struct tnl_attr_map vertex_attrs[VERT_ATTRIB_MAX]; + GLuint vertex_attr_count; + char *verts; /* points to tnl->clipspace.vertex_buf */ + GLuint num_verts; + int coloroffset, specoffset; + int tnl_state; /* tnl->render_inputs for this _tnl_install_attrs */ + GLuint NewGLState; GLuint Fallback; - GLuint SetupIndex; - GLuint SetupNewInputs; GLuint RenderIndex; GLfloat hw_viewport[16]; GLfloat depth_scale; - GLuint vertex_size; - GLuint vertex_stride_shift; - GLuint vertex_format; - GLuint num_verts; - GLubyte *verts; uint32_t ClearColor; /* Color used to clear color buffer */ uint32_t ClearDepth; /* Value used to clear depth buffer */ diff --git a/src/mesa/drivers/dri/r128/r128_dd.c b/src/mesa/drivers/dri/r128/r128_dd.c index ce2e7f7d702..aec7f9d3d34 100644 --- a/src/mesa/drivers/dri/r128/r128_dd.c +++ b/src/mesa/drivers/dri/r128/r128_dd.c @@ -36,14 +36,14 @@ USE OR OTHER DEALINGS IN THE SOFTWARE. #include "r128_context.h" #include "r128_ioctl.h" #include "r128_state.h" -#include "r128_vb.h" #include "r128_dd.h" +#include "swrast/swrast.h" #include "context.h" #include "utils.h" -#define DRIVER_DATE "20030328" +#define DRIVER_DATE "20041001" /* Return the width and height of the current color buffer. diff --git a/src/mesa/drivers/dri/r128/r128_ioctl.h b/src/mesa/drivers/dri/r128/r128_ioctl.h index ee41843da97..c17d3ca8cb6 100644 --- a/src/mesa/drivers/dri/r128/r128_ioctl.h +++ b/src/mesa/drivers/dri/r128/r128_ioctl.h @@ -47,9 +47,11 @@ USE OR OTHER DEALINGS IN THE SOFTWARE. extern drmBufPtr r128GetBufferLocked( r128ContextPtr rmesa ); extern void r128FlushVerticesLocked( r128ContextPtr rmesa ); -static __inline void *r128AllocDmaLow( r128ContextPtr rmesa, int bytes ) +static __inline void *r128AllocDmaLow( r128ContextPtr rmesa, int count, + int vert_size ) { uint32_t *head; + int bytes = count * vert_size; if ( !rmesa->vert_buf ) { LOCK_HARDWARE( rmesa ); @@ -64,6 +66,8 @@ static __inline void *r128AllocDmaLow( r128ContextPtr rmesa, int bytes ) head = (uint32_t *)((char *)rmesa->vert_buf->address + rmesa->vert_buf->used); rmesa->vert_buf->used += bytes; + rmesa->num_verts += count; + return head; } diff --git a/src/mesa/drivers/dri/r128/r128_lock.c b/src/mesa/drivers/dri/r128/r128_lock.c index 8508f7dfe8a..876db765755 100644 --- a/src/mesa/drivers/dri/r128/r128_lock.c +++ b/src/mesa/drivers/dri/r128/r128_lock.c @@ -104,7 +104,7 @@ void r128GetLock( r128ContextPtr rmesa, GLuint flags ) r128UpdatePageFlipping( rmesa ); rmesa->lastStamp = dPriv->lastStamp; rmesa->new_state |= R128_NEW_CLIP; - rmesa->SetupNewInputs = ~0; + rmesa->tnl_state = ~0; } rmesa->dirty |= R128_UPLOAD_CONTEXT | R128_UPLOAD_CLIPRECTS; diff --git a/src/mesa/drivers/dri/r128/r128_screen.c b/src/mesa/drivers/dri/r128/r128_screen.c index 6d0fd9d1a1f..3ab4cd08563 100644 --- a/src/mesa/drivers/dri/r128/r128_screen.c +++ b/src/mesa/drivers/dri/r128/r128_screen.c @@ -38,7 +38,6 @@ USE OR OTHER DEALINGS IN THE SOFTWARE. #include "r128_context.h" #include "r128_ioctl.h" #include "r128_tris.h" -#include "r128_vb.h" #include "context.h" #include "imports.h" diff --git a/src/mesa/drivers/dri/r128/r128_state.c b/src/mesa/drivers/dri/r128/r128_state.c index f7b30dead22..cd3e4181b33 100644 --- a/src/mesa/drivers/dri/r128/r128_state.c +++ b/src/mesa/drivers/dri/r128/r128_state.c @@ -38,7 +38,6 @@ USE OR OTHER DEALINGS IN THE SOFTWARE. #include "r128_state.h" #include "r128_ioctl.h" #include "r128_tris.h" -#include "r128_vb.h" #include "r128_tex.h" #include "context.h" diff --git a/src/mesa/drivers/dri/r128/r128_tex.c b/src/mesa/drivers/dri/r128/r128_tex.c index 7355c9f3fe1..29fa901c055 100644 --- a/src/mesa/drivers/dri/r128/r128_tex.c +++ b/src/mesa/drivers/dri/r128/r128_tex.c @@ -36,7 +36,6 @@ USE OR OTHER DEALINGS IN THE SOFTWARE. #include "r128_context.h" #include "r128_state.h" #include "r128_ioctl.h" -#include "r128_vb.h" #include "r128_tris.h" #include "r128_tex.h" #include "r128_texobj.h" diff --git a/src/mesa/drivers/dri/r128/r128_texmem.c b/src/mesa/drivers/dri/r128/r128_texmem.c index 0f131be6061..f7413cf5e35 100644 --- a/src/mesa/drivers/dri/r128/r128_texmem.c +++ b/src/mesa/drivers/dri/r128/r128_texmem.c @@ -36,7 +36,6 @@ USE OR OTHER DEALINGS IN THE SOFTWARE. #include "r128_context.h" #include "r128_state.h" #include "r128_ioctl.h" -#include "r128_vb.h" #include "r128_tris.h" #include "r128_tex.h" diff --git a/src/mesa/drivers/dri/r128/r128_texstate.c b/src/mesa/drivers/dri/r128/r128_texstate.c index b287fc6f25e..c22323b68fb 100644 --- a/src/mesa/drivers/dri/r128/r128_texstate.c +++ b/src/mesa/drivers/dri/r128/r128_texstate.c @@ -42,7 +42,6 @@ USE OR OTHER DEALINGS IN THE SOFTWARE. #include "r128_context.h" #include "r128_state.h" #include "r128_ioctl.h" -#include "r128_vb.h" #include "r128_tris.h" #include "r128_tex.h" diff --git a/src/mesa/drivers/dri/r128/r128_tris.c b/src/mesa/drivers/dri/r128/r128_tris.c index 57ed56d535c..34d7c7ffee7 100644 --- a/src/mesa/drivers/dri/r128/r128_tris.c +++ b/src/mesa/drivers/dri/r128/r128_tris.c @@ -47,7 +47,6 @@ USE OR OTHER DEALINGS IN THE SOFTWARE. #include "r128_tris.h" #include "r128_state.h" #include "r128_tex.h" -#include "r128_vb.h" #include "r128_ioctl.h" static const GLuint hw_prim[GL_POLYGON+1] = { @@ -70,84 +69,27 @@ static void r128RenderPrimitive( GLcontext *ctx, GLenum prim ); /*********************************************************************** * Emit primitives as inline vertices * ***********************************************************************/ + +#define HAVE_QUADS 0 +#define HAVE_LINES 1 +#define HAVE_POINTS 1 +#define HAVE_LE32_VERTS 1 +#define CTX_ARG r128ContextPtr rmesa +#define CTX_ARG2 rmesa +#define GET_VERTEX_DWORDS() rmesa->vertex_size +#define ALLOC_VERTS( n, size ) r128AllocDmaLow( rmesa, (n), (size) * 4 ) +#undef LOCAL_VARS +#define LOCAL_VARS \ + r128ContextPtr rmesa = R128_CONTEXT(ctx); \ + const char *vertptr = rmesa->verts; +#define VERT(x) (r128Vertex *)(vertptr + ((x) * vertsize * 4)) +#define VERTEX r128Vertex +#undef TAG +#define TAG(x) r128_##x +#include "tnl_dd/t_dd_triemit.h" +#undef TAG +#undef LOCAL_VARS -#if defined(USE_X86_ASM) -#define COPY_DWORDS( j, vb, vertsize, v ) \ -do { \ - int __tmp; \ - __asm__ __volatile__( "rep ; movsl" \ - : "=%c" (j), "=D" (vb), "=S" (__tmp) \ - : "0" (vertsize), \ - "D" ((long)vb), \ - "S" ((long)v) ); \ -} while (0) -#else -#define COPY_DWORDS( j, vb, vertsize, v ) \ -do { \ - for ( j = 0 ; j < vertsize ; j++ ) \ - vb[j] = CPU_TO_LE32(((GLuint *)v)[j]); \ - vb += vertsize; \ -} while (0) -#endif - -static __inline void r128_draw_quad( r128ContextPtr rmesa, - r128VertexPtr v0, - r128VertexPtr v1, - r128VertexPtr v2, - r128VertexPtr v3 ) -{ - GLuint vertsize = rmesa->vertex_size; - GLuint *vb = (GLuint *)r128AllocDmaLow( rmesa, 6 * vertsize * 4 ); - GLuint j; - - rmesa->num_verts += 6; - COPY_DWORDS( j, vb, vertsize, v0 ); - COPY_DWORDS( j, vb, vertsize, v1 ); - COPY_DWORDS( j, vb, vertsize, v3 ); - COPY_DWORDS( j, vb, vertsize, v1 ); - COPY_DWORDS( j, vb, vertsize, v2 ); - COPY_DWORDS( j, vb, vertsize, v3 ); -} - - -static __inline void r128_draw_triangle( r128ContextPtr rmesa, - r128VertexPtr v0, - r128VertexPtr v1, - r128VertexPtr v2 ) -{ - GLuint vertsize = rmesa->vertex_size; - GLuint *vb = (GLuint *)r128AllocDmaLow( rmesa, 3 * vertsize * 4 ); - GLuint j; - - rmesa->num_verts += 3; - COPY_DWORDS( j, vb, vertsize, v0 ); - COPY_DWORDS( j, vb, vertsize, v1 ); - COPY_DWORDS( j, vb, vertsize, v2 ); -} - -static __inline void r128_draw_line( r128ContextPtr rmesa, - r128VertexPtr v0, - r128VertexPtr v1 ) -{ - GLuint vertsize = rmesa->vertex_size; - GLuint *vb = (GLuint *)r128AllocDmaLow( rmesa, 2 * vertsize * 4 ); - GLuint j; - - rmesa->num_verts += 2; - COPY_DWORDS( j, vb, vertsize, v0 ); - COPY_DWORDS( j, vb, vertsize, v1 ); -} - -static __inline void r128_draw_point( r128ContextPtr rmesa, - r128VertexPtr v0 ) -{ - int vertsize = rmesa->vertex_size; - GLuint *vb = (GLuint *)r128AllocDmaLow( rmesa, vertsize * 4 ); - int j; - - rmesa->num_verts += 1; - COPY_DWORDS( j, vb, vertsize, v0 ); -} /*********************************************************************** * Macros for t_dd_tritmp.h to draw basic primitives * @@ -158,7 +100,7 @@ do { \ if (DO_FALLBACK) \ rmesa->draw_tri( rmesa, a, b, c ); \ else \ - r128_draw_triangle( rmesa, a, b, c ); \ + r128_triangle( rmesa, a, b, c ); \ } while (0) #define QUAD( a, b, c, d ) \ @@ -167,7 +109,7 @@ do { \ rmesa->draw_tri( rmesa, a, b, d ); \ rmesa->draw_tri( rmesa, b, c, d ); \ } else \ - r128_draw_quad( rmesa, a, b, c, d ); \ + r128_quad( rmesa, a, b, c, d ); \ } while (0) #define LINE( v0, v1 ) \ @@ -175,7 +117,7 @@ do { \ if (DO_FALLBACK) \ rmesa->draw_line( rmesa, v0, v1 ); \ else \ - r128_draw_line( rmesa, v0, v1 ); \ + r128_line( rmesa, v0, v1 ); \ } while (0) #define POINT( v0 ) \ @@ -183,7 +125,7 @@ do { \ if (DO_FALLBACK) \ rmesa->draw_point( rmesa, v0 ); \ else \ - r128_draw_point( rmesa, v0 ); \ + r128_point( rmesa, v0 ); \ } while (0) @@ -247,35 +189,40 @@ do { \ #define VERT_SET_SPEC( v0, c ) \ do { \ if (havespec) { \ - UNCLAMPED_FLOAT_TO_UBYTE(v0->v.specular.red, (c)[0]); \ - UNCLAMPED_FLOAT_TO_UBYTE(v0->v.specular.green, (c)[1]); \ - UNCLAMPED_FLOAT_TO_UBYTE(v0->v.specular.blue, (c)[2]); \ + r128_color_t *spec = (r128_color_t *)&((v0)->ui[specoffset]); \ + UNCLAMPED_FLOAT_TO_UBYTE(spec->red, (c)[0]); \ + UNCLAMPED_FLOAT_TO_UBYTE(spec->green, (c)[1]); \ + UNCLAMPED_FLOAT_TO_UBYTE(spec->blue, (c)[2]); \ } \ } while (0) #define VERT_COPY_SPEC( v0, v1 ) \ do { \ if (havespec) { \ - v0->v.specular.red = v1->v.specular.red; \ - v0->v.specular.green = v1->v.specular.green; \ - v0->v.specular.blue = v1->v.specular.blue; \ + r128_color_t *spec0 = (r128_color_t *)&((v0)->ui[specoffset]); \ + r128_color_t *spec1 = (r128_color_t *)&((v1)->ui[specoffset]); \ + spec0->red = spec1->red; \ + spec0->green = spec1->green; \ + spec0->blue = spec1->blue; \ } \ } while (0) -/* These don't need LE32_TO_CPU() as they used to save and restore +/* These don't need LE32_TO_CPU() as they are used to save and restore * colors which are already in the correct format. */ #define VERT_SAVE_RGBA( idx ) color[idx] = v[idx]->ui[coloroffset] #define VERT_RESTORE_RGBA( idx ) v[idx]->ui[coloroffset] = color[idx] -#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 VERT_SAVE_SPEC( idx ) if (havespec) spec[idx] = v[idx]->ui[specoffset] +#define VERT_RESTORE_SPEC( idx ) if (havespec) v[idx]->ui[specoffset] = spec[idx] #define LOCAL_VARS(n) \ r128ContextPtr rmesa = R128_CONTEXT(ctx); \ GLuint color[n], spec[n]; \ - GLuint coloroffset = (rmesa->vertex_size == 4 ? 3 : 4); \ - GLboolean havespec = (rmesa->vertex_size == 4 ? 0 : 1); \ - (void) color; (void) spec; (void) coloroffset; (void) havespec; + GLuint coloroffset = rmesa->coloroffset; \ + GLuint specoffset = rmesa->specoffset; \ + GLboolean havespec = (rmesa->specoffset != 0); \ + (void) color; (void) spec; (void) specoffset; \ + (void) coloroffset; (void) havespec; /*********************************************************************** * Helpers for rendering unfilled primitives * @@ -400,9 +347,10 @@ r128_fallback_tri( r128ContextPtr rmesa, { GLcontext *ctx = rmesa->glCtx; SWvertex v[3]; - r128_translate_vertex( ctx, v0, &v[0] ); - r128_translate_vertex( ctx, v1, &v[1] ); - r128_translate_vertex( ctx, v2, &v[2] ); + _swsetup_Translate( ctx, v0, &v[0] ); + _swsetup_Translate( ctx, v1, &v[1] ); + _swsetup_Translate( ctx, v2, &v[2] ); + /* XXX: SpanRenderStart */ _swrast_Triangle( ctx, &v[0], &v[1], &v[2] ); } @@ -414,8 +362,8 @@ r128_fallback_line( r128ContextPtr rmesa, { GLcontext *ctx = rmesa->glCtx; SWvertex v[2]; - r128_translate_vertex( ctx, v0, &v[0] ); - r128_translate_vertex( ctx, v1, &v[1] ); + _swsetup_Translate( ctx, v0, &v[0] ); + _swsetup_Translate( ctx, v1, &v[1] ); _swrast_Line( ctx, &v[0], &v[1] ); } @@ -426,7 +374,7 @@ r128_fallback_point( r128ContextPtr rmesa, { GLcontext *ctx = rmesa->glCtx; SWvertex v[1]; - r128_translate_vertex( ctx, v0, &v[0] ); + _swsetup_Translate( ctx, v0, &v[0] ); _swrast_Point( ctx, &v[0] ); } @@ -436,16 +384,15 @@ r128_fallback_point( r128ContextPtr rmesa, /* Render unclipped begin/end objects */ /**********************************************************************/ -#define VERT(x) (r128Vertex *)(r128verts + (x * vertsize * sizeof(int))) #define RENDER_POINTS( start, count ) \ for ( ; start < count ; start++) \ - r128_draw_point( rmesa, VERT(start) ) + r128_point( rmesa, VERT(start) ) #define RENDER_LINE( v0, v1 ) \ - r128_draw_line( rmesa, VERT(v0), VERT(v1) ) + r128_line( rmesa, VERT(v0), VERT(v1) ) #define RENDER_TRI( v0, v1, v2 ) \ - r128_draw_triangle( rmesa, VERT(v0), VERT(v1), VERT(v2) ) + r128_triangle( rmesa, VERT(v0), VERT(v1), VERT(v2) ) #define RENDER_QUAD( v0, v1, v2, v3 ) \ - r128_draw_quad( rmesa, VERT(v0), VERT(v1), VERT(v2), VERT(v3) ) + r128_quad( rmesa, VERT(v0), VERT(v1), VERT(v2), VERT(v3) ) #define INIT(x) do { \ if (0) fprintf(stderr, "%s\n", __FUNCTION__); \ r128RenderPrimitive( ctx, x ); \ @@ -454,7 +401,7 @@ r128_fallback_point( r128ContextPtr rmesa, #define LOCAL_VARS \ r128ContextPtr rmesa = R128_CONTEXT(ctx); \ const GLuint vertsize = rmesa->vertex_size; \ - const char *r128verts = (char *)rmesa->verts; \ + const char *vertptr = (char *)rmesa->verts; \ const GLuint * const elt = TNL_CONTEXT(ctx)->vb.Elts; \ (void) elt; #define RESET_STIPPLE @@ -471,72 +418,15 @@ r128_fallback_point( r128ContextPtr rmesa, /**********************************************************************/ -/* Render clipped primitives */ -/**********************************************************************/ - -static void r128RenderClippedPoly( GLcontext *ctx, const GLuint *elts, - GLuint n ) -{ - TNLcontext *tnl = TNL_CONTEXT(ctx); - struct vertex_buffer *VB = &TNL_CONTEXT(ctx)->vb; - - /* 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; - } -} - -static void r128RenderClippedLine( GLcontext *ctx, GLuint ii, GLuint jj ) -{ - TNLcontext *tnl = TNL_CONTEXT(ctx); - tnl->Driver.Render.Line( ctx, ii, jj ); -} - -static void r128FastRenderClippedPoly( GLcontext *ctx, const GLuint *elts, - GLuint n ) -{ - r128ContextPtr rmesa = R128_CONTEXT( ctx ); - GLuint vertsize = rmesa->vertex_size; - GLuint *vb = r128AllocDmaLow( rmesa, (n-2) * 3 * 4 * vertsize ); - GLubyte *r128verts = (GLubyte *)rmesa->verts; - const GLuint *start = (const GLuint *)VERT(elts[0]); - int i,j; - - rmesa->num_verts += (n-2) * 3; - - for (i = 2 ; i < n ; i++) { - COPY_DWORDS( j, vb, vertsize, (r128VertexPtr) VERT(elts[i-1]) ); - COPY_DWORDS( j, vb, vertsize, (r128VertexPtr) VERT(elts[i]) ); - COPY_DWORDS( j, vb, vertsize, (r128VertexPtr) start ); - } -} - - - - -/**********************************************************************/ /* Choose render functions */ /**********************************************************************/ -#define _R128_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) - +#define _R128_NEW_RENDER_STATE (ANY_FALLBACK_FLAGS | ANY_RASTER_FLAGS) static void r128ChooseRenderState(GLcontext *ctx) { @@ -545,9 +435,9 @@ static void r128ChooseRenderState(GLcontext *ctx) GLuint index = 0; if (flags & (ANY_RASTER_FLAGS|ANY_FALLBACK_FLAGS)) { - rmesa->draw_point = r128_draw_point; - rmesa->draw_line = r128_draw_line; - rmesa->draw_tri = r128_draw_triangle; + rmesa->draw_point = r128_point; + rmesa->draw_line = r128_line; + rmesa->draw_tri = r128_triangle; if (flags & ANY_RASTER_FLAGS) { if (flags & DD_TRI_LIGHT_TWOSIDE) index |= R128_TWOSIDE_BIT; @@ -569,19 +459,18 @@ static void r128ChooseRenderState(GLcontext *ctx) TNLcontext *tnl = TNL_CONTEXT(ctx); tnl->Driver.Render.Points = rast_tab[index].points; tnl->Driver.Render.Line = rast_tab[index].line; + tnl->Driver.Render.ClippedLine = rast_tab[index].line; tnl->Driver.Render.Triangle = rast_tab[index].triangle; tnl->Driver.Render.Quad = rast_tab[index].quad; if (index == 0) { tnl->Driver.Render.PrimTabVerts = r128_render_tab_verts; tnl->Driver.Render.PrimTabElts = r128_render_tab_elts; - tnl->Driver.Render.ClippedLine = rast_tab[index].line; - tnl->Driver.Render.ClippedPolygon = r128FastRenderClippedPoly; + tnl->Driver.Render.ClippedPolygon = r128_fast_clipped_poly; } else { tnl->Driver.Render.PrimTabVerts = _tnl_render_tab_verts; tnl->Driver.Render.PrimTabElts = _tnl_render_tab_elts; - tnl->Driver.Render.ClippedLine = r128RenderClippedLine; - tnl->Driver.Render.ClippedPolygon = r128RenderClippedPoly; + tnl->Driver.Render.ClippedPolygon = _tnl_RenderClippedPolygon; } rmesa->RenderIndex = index; @@ -600,9 +489,6 @@ static void r128RunPipeline( GLcontext *ctx ) r128DDUpdateHWState( ctx ); if (!rmesa->Fallback && rmesa->NewGLState) { - if (rmesa->NewGLState & _R128_NEW_VERTEX_STATE) - r128ChooseVertexState( ctx ); - if (rmesa->NewGLState & _R128_NEW_RENDER_STATE) r128ChooseRenderState( ctx ); @@ -657,13 +543,100 @@ static void r128RenderPrimitive( GLcontext *ctx, GLenum prim ) r128RasterPrimitive( ctx, hw ); } +#define EMIT_ATTR( ATTR, STYLE, VF, SIZE ) \ +do { \ + rmesa->vertex_attrs[rmesa->vertex_attr_count].attrib = (ATTR); \ + rmesa->vertex_attrs[rmesa->vertex_attr_count].format = (STYLE); \ + rmesa->vertex_attr_count++; \ + vc_frmt |= (VF); \ + offset += (SIZE); \ +} while (0) + +#define EMIT_PAD( SIZE ) \ +do { \ + rmesa->vertex_attrs[rmesa->vertex_attr_count].attrib = 0; \ + rmesa->vertex_attrs[rmesa->vertex_attr_count].format = EMIT_PAD; \ + rmesa->vertex_attrs[rmesa->vertex_attr_count].offset = (SIZE); \ + rmesa->vertex_attr_count++; \ + offset += (SIZE); \ +} while (0) static void r128RenderStart( GLcontext *ctx ) { - /* Check for projective texturing. Make sure all texcoord - * pointers point to something. (fix in mesa?) + r128ContextPtr rmesa = R128_CONTEXT(ctx); + TNLcontext *tnl = TNL_CONTEXT(ctx); + struct vertex_buffer *VB = &tnl->vb; + GLuint index = tnl->render_inputs; + GLuint vc_frmt = 0; + GLboolean fallback_projtex = GL_FALSE; + GLuint offset = 0; + + /* Important: */ + VB->AttribPtr[VERT_ATTRIB_POS] = VB->NdcPtr; + rmesa->vertex_attr_count = 0; + rmesa->specoffset = 0; + + /* EMIT_ATTR's must be in order as they tell t_vertex.c how to + * build up a hardware vertex. + */ + if ( index & _TNL_BITS_TEX_ANY ) + EMIT_ATTR( _TNL_ATTRIB_POS, EMIT_4F_VIEWPORT, R128_CCE_VC_FRMT_RHW, 16 ); + else + EMIT_ATTR( _TNL_ATTRIB_POS, EMIT_3F_VIEWPORT, 0, 12 ); + + rmesa->coloroffset = offset; + EMIT_ATTR( _TNL_ATTRIB_COLOR0, EMIT_4UB_4F_BGRA, + R128_CCE_VC_FRMT_DIFFUSE_ARGB, 4 ); + + if ( index & (_TNL_BIT_COLOR1|_TNL_BIT_FOG) ) { + if ( index & _TNL_BIT_COLOR1) { + rmesa->specoffset = offset; + EMIT_ATTR( _TNL_ATTRIB_COLOR1, EMIT_3UB_3F_RGB, + R128_CCE_VC_FRMT_SPEC_FRGB, 3 ); + } else + EMIT_PAD( 3 ); + + if (index & _TNL_BIT_FOG) + EMIT_ATTR( _TNL_ATTRIB_FOG, EMIT_1UB_1F, R128_CCE_VC_FRMT_SPEC_FRGB, + 1 ); + else + EMIT_PAD( 1 ); + } + + if ( index & _TNL_BIT_TEX(0) ) { + if ( VB->TexCoordPtr[0]->size > 2 ) + fallback_projtex = GL_TRUE; + EMIT_ATTR( _TNL_ATTRIB_TEX0, EMIT_2F, R128_CCE_VC_FRMT_S_T, 8 ); + if ( index & _TNL_BIT_TEX(1) ) { + if ( VB->TexCoordPtr[1]->size > 2 ) + fallback_projtex = GL_TRUE; + EMIT_ATTR( _TNL_ATTRIB_TEX1, EMIT_2F, R128_CCE_VC_FRMT_S2_T2, 8 ); + } + } else if ( index & _TNL_BIT_TEX(1) ) { + if ( VB->TexCoordPtr[1]->size > 2 ) + fallback_projtex = GL_TRUE; + EMIT_ATTR( _TNL_ATTRIB_TEX1, EMIT_2F, R128_CCE_VC_FRMT_S_T, 8 ); + } + + /* projective textures are not supported by the hardware */ + FALLBACK( rmesa, R128_FALLBACK_TEXTURE, fallback_projtex ); + + /* Only need to change the vertex emit code if there has been a + * statechange to a TNL index. */ - r128CheckTexSizes( ctx ); + if ( index != rmesa->tnl_state ) { + FLUSH_BATCH( rmesa ); + rmesa->dirty |= R128_UPLOAD_CONTEXT; + + rmesa->vertex_size = + _tnl_install_attrs( ctx, + rmesa->vertex_attrs, + rmesa->vertex_attr_count, + rmesa->hw_viewport, 0 ); + rmesa->vertex_size >>= 2; + + rmesa->vertex_format = vc_frmt; + } } static void r128RenderFinish( GLcontext *ctx ) @@ -698,9 +671,19 @@ void r128Fallback( GLcontext *ctx, GLuint bit, GLboolean mode ) tnl->Driver.Render.Start = r128RenderStart; tnl->Driver.Render.PrimitiveNotify = r128RenderPrimitive; tnl->Driver.Render.Finish = r128RenderFinish; - tnl->Driver.Render.BuildVertices = r128BuildVertices; - rmesa->NewGLState |= (_R128_NEW_RENDER_STATE| - _R128_NEW_VERTEX_STATE); + + tnl->Driver.Render.BuildVertices = _tnl_build_vertices; + tnl->Driver.Render.CopyPV = _tnl_copy_pv; + tnl->Driver.Render.Interp = _tnl_interp; + + _tnl_invalidate_vertex_state( ctx, ~0 ); + _tnl_invalidate_vertices( ctx, ~0 ); + _tnl_install_attrs( ctx, + rmesa->vertex_attrs, + rmesa->vertex_attr_count, + rmesa->hw_viewport, 0 ); + + rmesa->NewGLState |= _R128_NEW_RENDER_STATE; } } } @@ -726,9 +709,16 @@ void r128InitTriFuncs( GLcontext *ctx ) tnl->Driver.Render.Finish = r128RenderFinish; tnl->Driver.Render.PrimitiveNotify = r128RenderPrimitive; tnl->Driver.Render.ResetLineStipple = _swrast_ResetLineStipple; - tnl->Driver.Render.BuildVertices = r128BuildVertices; - rmesa->NewGLState |= (_R128_NEW_RENDER_STATE| - _R128_NEW_VERTEX_STATE); + tnl->Driver.Render.BuildVertices = _tnl_build_vertices; + tnl->Driver.Render.CopyPV = _tnl_copy_pv; + tnl->Driver.Render.Interp = _tnl_interp; + + _tnl_init_vertices( ctx, ctx->Const.MaxArrayLockSize + 12, + (6 + 2 * ctx->Const.MaxTextureUnits) * sizeof(GLfloat) ); + rmesa->verts = (char *)tnl->clipspace.vertex_buf; + rmesa->tnl_state = -1; + + rmesa->NewGLState |= _R128_NEW_RENDER_STATE; /* r128Fallback( ctx, 0x100000, 1 ); */ } diff --git a/src/mesa/drivers/dri/r128/r128_vb.c b/src/mesa/drivers/dri/r128/r128_vb.c deleted file mode 100644 index 213a3350526..00000000000 --- a/src/mesa/drivers/dri/r128/r128_vb.c +++ /dev/null @@ -1,507 +0,0 @@ -/* $XFree86: xc/lib/GL/mesa/src/drv/r128/r128_vb.c,v 1.16 2003/03/26 20:43:49 tsi Exp $ */ -/************************************************************************** - -Copyright 2000, 2001 ATI Technologies Inc., Ontario, Canada, and - VA Linux Systems Inc., Fremont, California. - -All Rights Reserved. - -Permission is hereby granted, free of charge, to any person obtaining a -copy of this software and associated documentation files (the "Software"), -to deal in the Software without restriction, including without limitation -on the rights to use, copy, modify, merge, publish, distribute, sub -license, and/or sell copies of the Software, and to permit persons to whom -the Software is furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice (including the next -paragraph) shall be included in all copies or substantial portions of the -Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL -ATI, VA LINUX SYSTEMS AND/OR THEIR SUPPLIERS BE LIABLE FOR ANY CLAIM, -DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR -OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE -USE OR OTHER DEALINGS IN THE SOFTWARE. - -**************************************************************************/ - -/* - * Authors: - * Keith Whitwell <[email protected]> - * - */ - -#include "glheader.h" -#include "mtypes.h" -#include "imports.h" -#include "macros.h" -#include "colormac.h" - -#include "swrast_setup/swrast_setup.h" -#include "tnl/t_context.h" - -#include "r128_context.h" -#include "r128_vb.h" -#include "r128_ioctl.h" -#include "r128_tris.h" -#include "r128_state.h" - - -#define R128_TEX1_BIT 0x1 -#define R128_TEX0_BIT 0x2 -#define R128_RGBA_BIT 0x4 -#define R128_SPEC_BIT 0x8 -#define R128_FOG_BIT 0x10 -#define R128_XYZW_BIT 0x20 -#define R128_PTEX_BIT 0x40 -#define R128_MAX_SETUP 0x80 - -static struct { - void (*emit)( GLcontext *, GLuint, GLuint, void *, GLuint ); - tnl_interp_func interp; - tnl_copy_pv_func copy_pv; - GLboolean (*check_tex_sizes)( GLcontext *ctx ); - GLuint vertex_size; - GLuint vertex_format; -} setup_tab[R128_MAX_SETUP]; - -#define TINY_VERTEX_FORMAT (R128_CCE_VC_FRMT_DIFFUSE_ARGB) - -#define NOTEX_VERTEX_FORMAT (R128_CCE_VC_FRMT_RHW | \ - R128_CCE_VC_FRMT_DIFFUSE_ARGB |\ - R128_CCE_VC_FRMT_SPEC_FRGB) - -#define TEX0_VERTEX_FORMAT (R128_CCE_VC_FRMT_RHW | \ - R128_CCE_VC_FRMT_DIFFUSE_ARGB |\ - R128_CCE_VC_FRMT_SPEC_FRGB | \ - R128_CCE_VC_FRMT_S_T) - -#define TEX1_VERTEX_FORMAT (R128_CCE_VC_FRMT_RHW | \ - R128_CCE_VC_FRMT_DIFFUSE_ARGB |\ - R128_CCE_VC_FRMT_SPEC_FRGB | \ - R128_CCE_VC_FRMT_S_T | \ - R128_CCE_VC_FRMT_S2_T2) - - -#define PROJ_TEX1_VERTEX_FORMAT 0 -#define TEX2_VERTEX_FORMAT 0 -#define TEX3_VERTEX_FORMAT 0 -#define PROJ_TEX3_VERTEX_FORMAT 0 - -#define DO_XYZW (IND & R128_XYZW_BIT) -#define DO_RGBA (IND & R128_RGBA_BIT) -#define DO_SPEC (IND & R128_SPEC_BIT) -#define DO_FOG (IND & R128_FOG_BIT) -#define DO_TEX0 (IND & R128_TEX0_BIT) -#define DO_TEX1 (IND & R128_TEX1_BIT) -#define DO_TEX2 0 -#define DO_TEX3 0 -#define DO_PTEX (IND & R128_PTEX_BIT) - -#define VERTEX r128Vertex -#define VERTEX_COLOR r128_color_t -#define LOCALVARS r128ContextPtr rmesa = R128_CONTEXT(ctx); -#define GET_VIEWPORT_MAT() rmesa->hw_viewport -#define GET_TEXSOURCE(n) rmesa->tmu_source[n] -#define GET_VERTEX_FORMAT() rmesa->vertex_format -#define GET_VERTEX_STORE() rmesa->verts -#define GET_VERTEX_SIZE() rmesa->vertex_size * sizeof(GLuint) -#define INVALIDATE_STORED_VERTICES() - -#define HAVE_HW_VIEWPORT 0 -#define HAVE_HW_DIVIDE 0 -#define HAVE_RGBA_COLOR 0 -#define HAVE_TINY_VERTICES 1 -#define HAVE_NOTEX_VERTICES 1 -#define HAVE_TEX0_VERTICES 1 -#define HAVE_TEX1_VERTICES 1 -#define HAVE_TEX2_VERTICES 0 -#define HAVE_TEX3_VERTICES 0 -#define HAVE_PTEX_VERTICES 0 /* r128 rhw2 not supported by template */ - -#define UNVIEWPORT_VARS GLfloat h = R128_CONTEXT(ctx)->driDrawable->h -#define UNVIEWPORT_X(x) x - SUBPIXEL_X -#define UNVIEWPORT_Y(y) - y + h + SUBPIXEL_Y -#define UNVIEWPORT_Z(z) z / rmesa->depth_scale - -#define PTEX_FALLBACK() FALLBACK(R128_CONTEXT(ctx), R128_FALLBACK_TEXTURE, 1) - -#define INTERP_VERTEX setup_tab[rmesa->SetupIndex].interp -#define COPY_PV_VERTEX setup_tab[rmesa->SetupIndex].copy_pv - -/*********************************************************************** - * Generate pv-copying and translation functions * - ***********************************************************************/ - -#define TAG(x) r128_##x -#include "tnl_dd/t_dd_vb.c" - -/*********************************************************************** - * Generate vertex emit and interp functions * - ***********************************************************************/ - - -#define IND (R128_XYZW_BIT|R128_RGBA_BIT) -#define TAG(x) x##_wg -#include "tnl_dd/t_dd_vbtmp.h" - -#define IND (R128_XYZW_BIT|R128_RGBA_BIT|R128_SPEC_BIT) -#define TAG(x) x##_wgs -#include "tnl_dd/t_dd_vbtmp.h" - -#define IND (R128_XYZW_BIT|R128_RGBA_BIT|R128_TEX0_BIT) -#define TAG(x) x##_wgt0 -#include "tnl_dd/t_dd_vbtmp.h" - -#define IND (R128_XYZW_BIT|R128_RGBA_BIT|R128_TEX0_BIT|R128_TEX1_BIT) -#define TAG(x) x##_wgt0t1 -#include "tnl_dd/t_dd_vbtmp.h" - -#define IND (R128_XYZW_BIT|R128_RGBA_BIT|R128_TEX0_BIT|R128_PTEX_BIT) -#define TAG(x) x##_wgpt0 -#include "tnl_dd/t_dd_vbtmp.h" - -#define IND (R128_XYZW_BIT|R128_RGBA_BIT|R128_SPEC_BIT|R128_TEX0_BIT) -#define TAG(x) x##_wgst0 -#include "tnl_dd/t_dd_vbtmp.h" - -#define IND (R128_XYZW_BIT|R128_RGBA_BIT|R128_SPEC_BIT|R128_TEX0_BIT|\ - R128_TEX1_BIT) -#define TAG(x) x##_wgst0t1 -#include "tnl_dd/t_dd_vbtmp.h" - -#define IND (R128_XYZW_BIT|R128_RGBA_BIT|R128_SPEC_BIT|R128_TEX0_BIT|\ - R128_PTEX_BIT) -#define TAG(x) x##_wgspt0 -#include "tnl_dd/t_dd_vbtmp.h" - -#define IND (R128_XYZW_BIT|R128_RGBA_BIT|R128_FOG_BIT) -#define TAG(x) x##_wgf -#include "tnl_dd/t_dd_vbtmp.h" - -#define IND (R128_XYZW_BIT|R128_RGBA_BIT|R128_FOG_BIT|R128_SPEC_BIT) -#define TAG(x) x##_wgfs -#include "tnl_dd/t_dd_vbtmp.h" - -#define IND (R128_XYZW_BIT|R128_RGBA_BIT|R128_FOG_BIT|R128_TEX0_BIT) -#define TAG(x) x##_wgft0 -#include "tnl_dd/t_dd_vbtmp.h" - -#define IND (R128_XYZW_BIT|R128_RGBA_BIT|R128_FOG_BIT|R128_TEX0_BIT|\ - R128_TEX1_BIT) -#define TAG(x) x##_wgft0t1 -#include "tnl_dd/t_dd_vbtmp.h" - -#define IND (R128_XYZW_BIT|R128_RGBA_BIT|R128_FOG_BIT|R128_TEX0_BIT|\ - R128_PTEX_BIT) -#define TAG(x) x##_wgfpt0 -#include "tnl_dd/t_dd_vbtmp.h" - -#define IND (R128_XYZW_BIT|R128_RGBA_BIT|R128_FOG_BIT|R128_SPEC_BIT|\ - R128_TEX0_BIT) -#define TAG(x) x##_wgfst0 -#include "tnl_dd/t_dd_vbtmp.h" - -#define IND (R128_XYZW_BIT|R128_RGBA_BIT|R128_FOG_BIT|R128_SPEC_BIT|\ - R128_TEX0_BIT|R128_TEX1_BIT) -#define TAG(x) x##_wgfst0t1 -#include "tnl_dd/t_dd_vbtmp.h" - -#define IND (R128_XYZW_BIT|R128_RGBA_BIT|R128_FOG_BIT|R128_SPEC_BIT|\ - R128_TEX0_BIT|R128_PTEX_BIT) -#define TAG(x) x##_wgfspt0 -#include "tnl_dd/t_dd_vbtmp.h" - -#define IND (R128_TEX0_BIT) -#define TAG(x) x##_t0 -#include "tnl_dd/t_dd_vbtmp.h" - -#define IND (R128_TEX0_BIT|R128_TEX1_BIT) -#define TAG(x) x##_t0t1 -#include "tnl_dd/t_dd_vbtmp.h" - -#define IND (R128_FOG_BIT) -#define TAG(x) x##_f -#include "tnl_dd/t_dd_vbtmp.h" - -#define IND (R128_FOG_BIT|R128_TEX0_BIT) -#define TAG(x) x##_ft0 -#include "tnl_dd/t_dd_vbtmp.h" - -#define IND (R128_FOG_BIT|R128_TEX0_BIT|R128_TEX1_BIT) -#define TAG(x) x##_ft0t1 -#include "tnl_dd/t_dd_vbtmp.h" - -#define IND (R128_RGBA_BIT) -#define TAG(x) x##_g -#include "tnl_dd/t_dd_vbtmp.h" - -#define IND (R128_RGBA_BIT|R128_SPEC_BIT) -#define TAG(x) x##_gs -#include "tnl_dd/t_dd_vbtmp.h" - -#define IND (R128_RGBA_BIT|R128_TEX0_BIT) -#define TAG(x) x##_gt0 -#include "tnl_dd/t_dd_vbtmp.h" - -#define IND (R128_RGBA_BIT|R128_TEX0_BIT|R128_TEX1_BIT) -#define TAG(x) x##_gt0t1 -#include "tnl_dd/t_dd_vbtmp.h" - -#define IND (R128_RGBA_BIT|R128_SPEC_BIT|R128_TEX0_BIT) -#define TAG(x) x##_gst0 -#include "tnl_dd/t_dd_vbtmp.h" - -#define IND (R128_RGBA_BIT|R128_SPEC_BIT|R128_TEX0_BIT|R128_TEX1_BIT) -#define TAG(x) x##_gst0t1 -#include "tnl_dd/t_dd_vbtmp.h" - -#define IND (R128_RGBA_BIT|R128_FOG_BIT) -#define TAG(x) x##_gf -#include "tnl_dd/t_dd_vbtmp.h" - -#define IND (R128_RGBA_BIT|R128_FOG_BIT|R128_SPEC_BIT) -#define TAG(x) x##_gfs -#include "tnl_dd/t_dd_vbtmp.h" - -#define IND (R128_RGBA_BIT|R128_FOG_BIT|R128_TEX0_BIT) -#define TAG(x) x##_gft0 -#include "tnl_dd/t_dd_vbtmp.h" - -#define IND (R128_RGBA_BIT|R128_FOG_BIT|R128_TEX0_BIT|R128_TEX1_BIT) -#define TAG(x) x##_gft0t1 -#include "tnl_dd/t_dd_vbtmp.h" - -#define IND (R128_RGBA_BIT|R128_FOG_BIT|R128_SPEC_BIT|R128_TEX0_BIT) -#define TAG(x) x##_gfst0 -#include "tnl_dd/t_dd_vbtmp.h" - -#define IND (R128_RGBA_BIT|R128_FOG_BIT|R128_SPEC_BIT|R128_TEX0_BIT|\ - R128_TEX1_BIT) -#define TAG(x) x##_gfst0t1 -#include "tnl_dd/t_dd_vbtmp.h" - - -static void init_setup_tab( void ) -{ - init_wg(); - init_wgs(); - init_wgt0(); - init_wgt0t1(); - init_wgpt0(); - init_wgst0(); - init_wgst0t1(); - init_wgspt0(); - init_wgf(); - init_wgfs(); - init_wgft0(); - init_wgft0t1(); - init_wgfpt0(); - init_wgfst0(); - init_wgfst0t1(); - init_wgfspt0(); - init_t0(); - init_t0t1(); - init_f(); - init_ft0(); - init_ft0t1(); - init_g(); - init_gs(); - init_gt0(); - init_gt0t1(); - init_gst0(); - init_gst0t1(); - init_gf(); - init_gfs(); - init_gft0(); - init_gft0t1(); - init_gfst0(); - init_gfst0t1(); -} - - - -void r128PrintSetupFlags(char *msg, GLuint flags ) -{ - fprintf(stderr, "%s(%x): %s%s%s%s%s%s\n", - msg, - (int)flags, - (flags & R128_XYZW_BIT) ? " xyzw," : "", - (flags & R128_RGBA_BIT) ? " rgba," : "", - (flags & R128_SPEC_BIT) ? " spec," : "", - (flags & R128_FOG_BIT) ? " fog," : "", - (flags & R128_TEX0_BIT) ? " tex-0," : "", - (flags & R128_TEX1_BIT) ? " tex-1," : ""); -} - - - -void r128CheckTexSizes( GLcontext *ctx ) -{ - r128ContextPtr rmesa = R128_CONTEXT( ctx ); - - if (!setup_tab[rmesa->SetupIndex].check_tex_sizes(ctx)) { - TNLcontext *tnl = TNL_CONTEXT(ctx); - - /* Invalidate stored verts - */ - rmesa->SetupNewInputs = ~0; - rmesa->SetupIndex |= R128_PTEX_BIT; - - if (!rmesa->Fallback && - !(ctx->_TriangleCaps & (DD_TRI_LIGHT_TWOSIDE|DD_TRI_UNFILLED))) { - tnl->Driver.Render.Interp = setup_tab[rmesa->SetupIndex].interp; - tnl->Driver.Render.CopyPV = setup_tab[rmesa->SetupIndex].copy_pv; - } - if (rmesa->Fallback) { - tnl->Driver.Render.Start(ctx); - } - } -} - -void r128BuildVertices( GLcontext *ctx, - GLuint start, - GLuint count, - GLuint newinputs ) -{ - r128ContextPtr rmesa = R128_CONTEXT( ctx ); - GLuint stride = rmesa->vertex_size * sizeof(int); - GLubyte *v = ((GLubyte *)rmesa->verts + (start * stride)); - - newinputs |= rmesa->SetupNewInputs; - rmesa->SetupNewInputs = 0; - - if (!newinputs) - return; - - if (newinputs & VERT_BIT_POS) { - setup_tab[rmesa->SetupIndex].emit( ctx, start, count, v, stride ); - } else { - GLuint ind = 0; - - if (newinputs & VERT_BIT_COLOR0) - ind |= R128_RGBA_BIT; - - if (newinputs & VERT_BIT_COLOR1) - ind |= R128_SPEC_BIT; - - if (newinputs & VERT_BIT_TEX0) - ind |= R128_TEX0_BIT; - - if (newinputs & VERT_BIT_TEX1) - ind |= R128_TEX1_BIT; - - if (newinputs & VERT_BIT_FOG) - ind |= R128_FOG_BIT; - - if (rmesa->SetupIndex & R128_PTEX_BIT) - ind = ~0; - - ind &= rmesa->SetupIndex; - - if (ind) { - setup_tab[ind].emit( ctx, start, count, v, stride ); - } - } -} - -void r128ChooseVertexState( GLcontext *ctx ) -{ - TNLcontext *tnl = TNL_CONTEXT(ctx); - r128ContextPtr rmesa = R128_CONTEXT( ctx ); - GLuint ind = R128_XYZW_BIT|R128_RGBA_BIT; - - if (ctx->_TriangleCaps & DD_SEPARATE_SPECULAR) - ind |= R128_SPEC_BIT; - - if (ctx->Fog.Enabled) - ind |= R128_FOG_BIT; - - if (ctx->Texture._EnabledUnits) { - ind |= R128_TEX0_BIT; - if (ctx->Texture.Unit[0]._ReallyEnabled && - ctx->Texture.Unit[1]._ReallyEnabled) - ind |= R128_TEX1_BIT; - } - - rmesa->SetupIndex = ind; - - if (ctx->_TriangleCaps & (DD_TRI_LIGHT_TWOSIDE|DD_TRI_UNFILLED)) { - tnl->Driver.Render.Interp = r128_interp_extras; - tnl->Driver.Render.CopyPV = r128_copy_pv_extras; - } else { - tnl->Driver.Render.Interp = setup_tab[ind].interp; - tnl->Driver.Render.CopyPV = setup_tab[ind].copy_pv; - } - - if (setup_tab[ind].vertex_format != rmesa->vertex_format) { - FLUSH_BATCH(rmesa); - rmesa->vertex_format = setup_tab[ind].vertex_format; - rmesa->vertex_size = setup_tab[ind].vertex_size; - } -} - - - -void r128_emit_contiguous_verts( GLcontext *ctx, - GLuint start, - GLuint count ) -{ - r128ContextPtr rmesa = R128_CONTEXT(ctx); - GLuint vertex_size = rmesa->vertex_size * 4; - GLuint *dest = r128AllocDmaLow( rmesa, (count-start) * vertex_size); - setup_tab[rmesa->SetupIndex].emit( ctx, start, count, dest, vertex_size ); -} - - -#if 0 -void r128_emit_indexed_verts( GLcontext *ctx, GLuint start, GLuint count ) -{ - r128ContextPtr rmesa = R128_CONTEXT(ctx); - GLuint vertex_size = rmesa->vertex_size * 4; - GLuint bufsz = (count-start) * vertex_size; - int32_t *dest; - - rmesa->vertex_low = (rmesa->vertex_low + 63) & ~63; /* alignment */ - rmesa->vertex_last_prim = rmesa->vertex_low; - - dest = r128AllocDmaLow( rmesa, bufsz, __FUNCTION__); - setup_tab[rmesa->SetupIndex].emit( ctx, start, count, dest, vertex_size ); - - rmesa->retained_buffer = rmesa->vertex_buffer; - rmesa->vb_offset = (rmesa->vertex_buffer->idx * R128_BUFFER_SIZE + - rmesa->vertex_low - bufsz); - - rmesa->vertex_low = (rmesa->vertex_low + 0x7) & ~0x7; /* alignment */ - rmesa->vertex_last_prim = rmesa->vertex_low; -} -#endif - - -void r128InitVB( GLcontext *ctx ) -{ - r128ContextPtr rmesa = R128_CONTEXT(ctx); - GLuint size = TNL_CONTEXT(ctx)->vb.Size; - - rmesa->verts = (GLubyte *)ALIGN_MALLOC(size * 4 * 16, 32); - - { - static int firsttime = 1; - if (firsttime) { - init_setup_tab(); - firsttime = 0; - } - } -} - - -void r128FreeVB( GLcontext *ctx ) -{ - r128ContextPtr rmesa = R128_CONTEXT(ctx); - if (rmesa->verts) { - ALIGN_FREE(rmesa->verts); - rmesa->verts = 0; - } -} diff --git a/src/mesa/drivers/dri/r128/r128_vb.h b/src/mesa/drivers/dri/r128/r128_vb.h index 31afa74f1cf..e69de29bb2d 100644 --- a/src/mesa/drivers/dri/r128/r128_vb.h +++ b/src/mesa/drivers/dri/r128/r128_vb.h @@ -1,74 +0,0 @@ -/* $XFree86: xc/lib/GL/mesa/src/drv/r128/r128_vb.h,v 1.8 2002/10/30 12:51:46 alanh Exp $ */ -/************************************************************************** - -Copyright 2000, 2001 ATI Technologies Inc., Ontario, Canada, and - VA Linux Systems Inc., Fremont, California. - -All Rights Reserved. - -Permission is hereby granted, free of charge, to any person obtaining a -copy of this software and associated documentation files (the "Software"), -to deal in the Software without restriction, including without limitation -on the rights to use, copy, modify, merge, publish, distribute, sub -license, and/or sell copies of the Software, and to permit persons to whom -the Software is furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice (including the next -paragraph) shall be included in all copies or substantial portions of the -Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL -ATI, VA LINUX SYSTEMS AND/OR THEIR SUPPLIERS BE LIABLE FOR ANY CLAIM, -DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR -OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE -USE OR OTHER DEALINGS IN THE SOFTWARE. - -**************************************************************************/ - -/* - * Authors: - * Keith Whitwell <[email protected]> - * - */ - -#ifndef R128VB_INC -#define R128VB_INC - -#include "mtypes.h" -#include "swrast/swrast.h" -#include "r128_context.h" - -#define _R128_NEW_VERTEX_STATE (_DD_NEW_SEPARATE_SPECULAR | \ - _DD_NEW_TRI_LIGHT_TWOSIDE | \ - _DD_NEW_TRI_UNFILLED | \ - _NEW_TEXTURE | \ - _NEW_FOG) - -extern void r128CheckTexSizes( GLcontext *ctx ); -extern void r128ChooseVertexState( GLcontext *ctx ); - -extern void r128BuildVertices( GLcontext *ctx, GLuint start, GLuint count, - GLuint newinputs ); - -extern void r128PrintSetupFlags(char *msg, GLuint flags ); - -extern void r128InitVB( GLcontext *ctx ); -extern void r128FreeVB( GLcontext *ctx ); - -extern void r128_emit_contiguous_verts( GLcontext *ctx, - GLuint start, - GLuint count ); - -extern void r128_emit_indexed_verts( GLcontext *ctx, - GLuint start, - GLuint count ); - -extern void r128_translate_vertex( GLcontext *ctx, - const r128Vertex *src, - SWvertex *dst ); - -extern void r128_print_vertex( GLcontext *ctx, const r128Vertex *v ); - -#endif |