diff options
Diffstat (limited to 'src/mesa/drivers/dri')
-rw-r--r-- | src/mesa/drivers/dri/sis/Makefile | 3 | ||||
-rw-r--r-- | src/mesa/drivers/dri/sis/sis_context.c | 39 | ||||
-rw-r--r-- | src/mesa/drivers/dri/sis/sis_context.h | 39 | ||||
-rw-r--r-- | src/mesa/drivers/dri/sis/sis_dd.c | 13 | ||||
-rw-r--r-- | src/mesa/drivers/dri/sis/sis_reg.h | 10 | ||||
-rw-r--r-- | src/mesa/drivers/dri/sis/sis_screen.c | 2 | ||||
-rw-r--r-- | src/mesa/drivers/dri/sis/sis_span.c | 11 | ||||
-rw-r--r-- | src/mesa/drivers/dri/sis/sis_span.h | 3 | ||||
-rw-r--r-- | src/mesa/drivers/dri/sis/sis_state.c | 63 | ||||
-rw-r--r-- | src/mesa/drivers/dri/sis/sis_tris.c | 801 | ||||
-rw-r--r-- | src/mesa/drivers/dri/sis/sis_tris.h | 30 | ||||
-rw-r--r-- | src/mesa/drivers/dri/sis/sis_tritmp.h | 104 | ||||
-rw-r--r-- | src/mesa/drivers/dri/sis/sis_vb.c | 445 | ||||
-rw-r--r-- | src/mesa/drivers/dri/sis/sis_vb.h | 62 |
14 files changed, 588 insertions, 1037 deletions
diff --git a/src/mesa/drivers/dri/sis/Makefile b/src/mesa/drivers/dri/sis/Makefile index bd4c0201d07..1135d61404b 100644 --- a/src/mesa/drivers/dri/sis/Makefile +++ b/src/mesa/drivers/dri/sis/Makefile @@ -32,8 +32,7 @@ DRIVER_SOURCES = \ sis_stencil.c \ sis_tex.c \ sis_texstate.c \ - sis_tris.c \ - sis_vb.c + sis_tris.c C_SOURCES = \ $(COMMON_SOURCES) \ diff --git a/src/mesa/drivers/dri/sis/sis_context.c b/src/mesa/drivers/dri/sis/sis_context.c index c49db5fe34b..a9b791f1011 100644 --- a/src/mesa/drivers/dri/sis/sis_context.c +++ b/src/mesa/drivers/dri/sis/sis_context.c @@ -41,7 +41,7 @@ USE OR OTHER DEALINGS IN THE SOFTWARE. #include "sis_stencil.h" #include "sis_tex.h" #include "sis_tris.h" -#include "sis_vb.h" +#include "sis_alloc.h" #include "imports.h" #include "matrix.h" @@ -199,18 +199,29 @@ sisCreateContext( const __GLcontextModes *glVisual, smesa->AGPBase = sisScreen->agp.map; smesa->AGPAddr = sisScreen->agp.handle; - /* set AGP command buffer */ - if (smesa->AGPSize != 0 && sisScreen->AGPCmdBufSize != 0 && + /* Create AGP command buffer */ + if (smesa->AGPSize != 0 && !driQueryOptionb(&smesa->optionCache, "agp_disable")) - { - smesa->AGPCmdBufBase = smesa->AGPBase + sisScreen->AGPCmdBufOffset; - smesa->AGPCmdBufAddr = smesa->AGPAddr + sisScreen->AGPCmdBufOffset; - smesa->AGPCmdBufSize = sisScreen->AGPCmdBufSize; - - smesa->pAGPCmdBufNext = (GLint *)&(smesa->sarea->AGPCmdBufNext); - smesa->AGPCmdModeEnabled = GL_TRUE; - } else { - smesa->AGPCmdModeEnabled = GL_FALSE; + { + smesa->vb = sisAllocAGP(smesa, 64 * 1024, &smesa->vb_agp_handle); + if (smesa->vb != NULL) { + smesa->using_agp = GL_TRUE; + smesa->vb_cur = smesa->vb; + smesa->vb_last = smesa->vb; + smesa->vb_end = smesa->vb + 64 * 1024; + smesa->vb_agp_offset = ((long)smesa->vb - (long)smesa->AGPBase + + (long)smesa->AGPAddr); + } + } + if (!smesa->using_agp) { + smesa->vb = malloc(64 * 1024); + if (smesa->vb == NULL) { + FREE(smesa); + return GL_FALSE; + } + smesa->vb_cur = smesa->vb; + smesa->vb_last = smesa->vb; + smesa->vb_end = smesa->vb + 64 * 1024; } smesa->GlobalFlag = 0L; @@ -232,7 +243,6 @@ sisCreateContext( const __GLcontextModes *glVisual, /* XXX these should really go right after _mesa_init_driver_functions() */ sisDDInitStateFuncs( ctx ); sisDDInitState( smesa ); /* Initializes smesa->zFormat, important */ - sisInitVB( ctx ); sisInitTriFuncs( ctx ); sisDDInitSpanFuncs( ctx ); sisDDInitStencilFuncs( ctx ); @@ -264,6 +274,9 @@ sisDestroyContext ( __DRIcontextPrivate *driContextPriv ) _ac_DestroyContext( smesa->glCtx ); _swrast_DestroyContext( smesa->glCtx ); + if (smesa->using_agp) + sisFreeAGP(smesa, smesa->vb_agp_handle); + /* free the Mesa context */ /* XXX: Is the next line needed? The DriverCtx (smesa) reference is * needed for sisDDDeleteTexture, since it needs to call the FB/AGP free diff --git a/src/mesa/drivers/dri/sis/sis_context.h b/src/mesa/drivers/dri/sis/sis_context.h index cc35c028727..0ea2e2a59ac 100644 --- a/src/mesa/drivers/dri/sis/sis_context.h +++ b/src/mesa/drivers/dri/sis/sis_context.h @@ -40,6 +40,7 @@ USE OR OTHER DEALINGS IN THE SOFTWARE. #include "drm.h" #include "drm_sarea.h" #include "xmlconfig.h" +#include "tnl/t_vertex.h" #include "sis_screen.h" #include "sis_common2.h" @@ -237,18 +238,26 @@ struct sis_context /* This must be first in this structure */ GLcontext *glCtx; + /* Vertex state */ + GLuint vertex_size; + struct tnl_attr_map vertex_attrs[VERT_ATTRIB_MAX]; + GLuint vertex_attr_count; + char *verts; /* points to tnl->clipspace.vertex_buf */ + + /* Vertex buffer (in system memory or AGP) state. */ + unsigned char *vb; /* Beginning of vertex buffer */ + unsigned char *vb_cur; /* Current write location in vertex buffer */ + unsigned char *vb_last; /* Last written location in vertex buffer */ + unsigned char *vb_end; /* End of vertex buffer */ + void *vb_agp_handle; + GLuint vb_agp_offset; + GLboolean using_agp; + 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; unsigned int virtualX, virtualY; unsigned int bytesPerPixel; @@ -288,15 +297,6 @@ struct sis_context unsigned char *AGPBase; unsigned int AGPAddr; - /* AGP Command Buffer */ - /* TODO: use Global variables */ - - unsigned char *AGPCmdBufBase; - GLint AGPCmdBufAddr; - unsigned int AGPCmdBufSize; - GLint *pAGPCmdBufNext; - GLboolean AGPCmdModeEnabled; - /* register 0x89F4 */ GLint AGPParseSet; @@ -313,6 +313,7 @@ struct sis_context GLboolean blockWrite; GLint GlobalFlag; + GLuint last_tcl_state; /* Stereo */ GLboolean useStereo; @@ -382,7 +383,7 @@ struct sis_context #define MMIO(reg, value) \ {\ - *(GLint *)(GET_IOBase(smesa) + (reg)) = value; \ + *(volatile GLint *)(smesa->IOBase + (reg)) = value; \ } #define MMIO_READ(reg) *(volatile GLint *)(smesa->IOBase + (reg)) @@ -390,8 +391,8 @@ struct sis_context #define mEndPrimitive() \ { \ - *(GET_IOBase(smesa) + REG_3D_EndPrimitiveList) = 0xFF; \ - *(GLint *)(GET_IOBase(smesa) + 0x8b60) = (GLint)(-1); \ + *(volatile char *)(smesa->IOBase + REG_3D_EndPrimitiveList) = 0xFF; \ + *(volatile GLint *)(smesa->IOBase + 0x8b60) = (GLint)(-1); \ } #define sis_fatal_error(msg) \ diff --git a/src/mesa/drivers/dri/sis/sis_dd.c b/src/mesa/drivers/dri/sis/sis_dd.c index 1cfca69af21..152df5622e0 100644 --- a/src/mesa/drivers/dri/sis/sis_dd.c +++ b/src/mesa/drivers/dri/sis/sis_dd.c @@ -38,12 +38,13 @@ USE OR OTHER DEALINGS IN THE SOFTWARE. #include "sis_lock.h" #include "sis_alloc.h" #include "sis_state.h" +#include "sis_tris.h" #include "swrast/swrast.h" #include "utils.h" -#define DRIVER_DATE "20030810" +#define DRIVER_DATE "20040608" /* Return the width and height of the given buffer. */ @@ -85,12 +86,14 @@ sisGetString( GLcontext *ctx, GLenum name ) } } -/* Send all commands to the hardware. No-op, due to mmio. +/* Send all commands to the hardware. */ static void sisFlush( GLcontext *ctx ) { - /* Do nothing */ + sisContextPtr smesa = SIS_CONTEXT(ctx); + + SIS_FIREVERTICES(smesa); } /* Make sure all commands have been sent to the hardware and have @@ -101,8 +104,10 @@ sisFinish( GLcontext *ctx ) { sisContextPtr smesa = SIS_CONTEXT(ctx); - sisFlush( ctx ); + SIS_FIREVERTICES(smesa); + LOCK_HARDWARE(); WaitEngIdle( smesa ); + UNLOCK_HARDWARE(); } void diff --git a/src/mesa/drivers/dri/sis/sis_reg.h b/src/mesa/drivers/dri/sis/sis_reg.h index 8af5e02a696..e0806f4e36c 100644 --- a/src/mesa/drivers/dri/sis/sis_reg.h +++ b/src/mesa/drivers/dri/sis/sis_reg.h @@ -230,6 +230,16 @@ USE OR OTHER DEALINGS IN THE SOFTWARE. */ #define MASK_VertexDWSize 0xf0000000 #define MASK_VertexDataFormat 0x0fff0000 +/* Because the original MASK_PsVertex_* names of these bits appared to be + * wrong, new names SiS_PS_* based off of the 4.3.0 driver and research are + * below. + */ +#define SiS_PS_HAS_XYZ 0x08000000 +#define SiS_PS_HAS_W 0x04000000 +#define SiS_PS_HAS_SPECULAR 0x02000000 /* XXX ? */ +#define SiS_PS_HAS_DIFFUSE 0x01000000 +#define SiS_PS_HAS_UV0 0x00400000 +#define SiS_PS_HAS_UV1 0x00200000 #define MASK_PsVertex_HAS_RHW 0x08000000 #define MASK_PsVertex_HAS_NORMALXYZ 0x04000000 #define MASK_PsVertex_HAS_DIFFUSE 0x02000000 diff --git a/src/mesa/drivers/dri/sis/sis_screen.c b/src/mesa/drivers/dri/sis/sis_screen.c index e67370f172a..986f32040bf 100644 --- a/src/mesa/drivers/dri/sis/sis_screen.c +++ b/src/mesa/drivers/dri/sis/sis_screen.c @@ -48,7 +48,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. const char __driConfigOptions[] = DRI_CONF_BEGIN DRI_CONF_SECTION_DEBUG - DRI_CONF_OPT_BEGIN(agp_disable,bool,false) + DRI_CONF_OPT_BEGIN(agp_disable,bool,true) DRI_CONF_DESC(en,"Disable AGP vertex dispatch") DRI_CONF_OPT_END DRI_CONF_OPT_BEGIN(fallback_force,bool,false) diff --git a/src/mesa/drivers/dri/sis/sis_span.c b/src/mesa/drivers/dri/sis/sis_span.c index fd2bc26d31c..47790a5f852 100644 --- a/src/mesa/drivers/dri/sis/sis_span.c +++ b/src/mesa/drivers/dri/sis/sis_span.c @@ -34,6 +34,8 @@ USE OR OTHER DEALINGS IN THE SOFTWARE. #include "sis_context.h" #include "sis_span.h" +#include "sis_lock.h" +#include "sis_tris.h" #include "swrast/swrast.h" @@ -216,16 +218,21 @@ static void sisDDSetBuffer( GLcontext *ctx, } } -static void sisSpanRenderStart( GLcontext *ctx ) +void sisSpanRenderStart( GLcontext *ctx ) { sisContextPtr smesa = SIS_CONTEXT(ctx); + SIS_FIREVERTICES(smesa); + LOCK_HARDWARE(); WaitEngIdle( smesa ); } -static void sisSpanRenderFinish( GLcontext *ctx ) +void sisSpanRenderFinish( GLcontext *ctx ) { + sisContextPtr smesa = SIS_CONTEXT(ctx); + _swrast_flush( ctx ); + UNLOCK_HARDWARE(); } void diff --git a/src/mesa/drivers/dri/sis/sis_span.h b/src/mesa/drivers/dri/sis/sis_span.h index f0d64df19c4..d95a0eef301 100644 --- a/src/mesa/drivers/dri/sis/sis_span.h +++ b/src/mesa/drivers/dri/sis/sis_span.h @@ -34,6 +34,9 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. #ifdef GLX_DIRECT_RENDERING +extern void sisSpanRenderStart( GLcontext *ctx ); +extern void sisSpanRenderFinish( GLcontext *ctx ); + extern void sisDDInitSpanFuncs( GLcontext *ctx ); #endif diff --git a/src/mesa/drivers/dri/sis/sis_state.c b/src/mesa/drivers/dri/sis/sis_state.c index ec911875199..decee53a742 100644 --- a/src/mesa/drivers/dri/sis/sis_state.c +++ b/src/mesa/drivers/dri/sis/sis_state.c @@ -629,51 +629,6 @@ sisDDEnable( GLcontext * ctx, GLenum cap, GLboolean state ) } } -/* ============================================================= - * Pixel functions - */ - -static void -sisDDDrawPixels( GLcontext *ctx, - GLint x, GLint y, GLsizei width, GLsizei height, - GLenum format, GLenum type, - const struct gl_pixelstore_attrib *unpack, - const GLvoid *pixels ) -{ - sisContextPtr smesa = SIS_CONTEXT(ctx); - - LOCK_HARDWARE(); - _swrast_DrawPixels( ctx, x, y, width, height, format, type, unpack, pixels ); - UNLOCK_HARDWARE(); -} - -static void -sisDDReadPixels( GLcontext *ctx, - GLint x, GLint y, GLsizei width, GLsizei height, - GLenum format, GLenum type, - const struct gl_pixelstore_attrib *pack, - GLvoid *pixels ) -{ - sisContextPtr smesa = SIS_CONTEXT(ctx); - - LOCK_HARDWARE(); - _swrast_ReadPixels( ctx, x, y, width, height, format, type, pack, - pixels); - UNLOCK_HARDWARE(); -} - -static void -sisDDBitmap( GLcontext *ctx, GLint px, GLint py, - GLsizei width, GLsizei height, - const struct gl_pixelstore_attrib *unpack, - const GLubyte *bitmap ) -{ - sisContextPtr smesa = SIS_CONTEXT(ctx); - - LOCK_HARDWARE(); - _swrast_Bitmap( ctx, px, py, width, height, unpack, bitmap ); - UNLOCK_HARDWARE(); -} /* ============================================================= * State initialization, management @@ -687,9 +642,6 @@ sisUpdateHWState( GLcontext *ctx ) __GLSiSHardware *prev = &smesa->prev; __GLSiSHardware *current = &smesa->current; - if (smesa->NewGLState & _NEW_TEXTURE) - sisUpdateTextureState( ctx ); - /* enable setting 1 */ if (current->hwCapEnable ^ prev->hwCapEnable) { prev->hwCapEnable = current->hwCapEnable; @@ -822,7 +774,7 @@ void sisDDInitState( sisContextPtr smesa ) smesa->clearColorPattern = 0; - smesa->AGPParseSet = MASK_PsTexture1FromB; + smesa->AGPParseSet = MASK_PsTexture1FromB | MASK_PsBumpTextureFromC; smesa->dwPrimitiveSet = OP_3D_Texture1FromB | OP_3D_TextureBumpFromC; sisUpdateZStencilPattern( smesa, 1.0, 0 ); @@ -848,7 +800,6 @@ void sisDDInitStateFuncs( GLcontext *ctx ) ctx->Driver.ClearStencil = sisDDClearStencil; ctx->Driver.AlphaFunc = sisDDAlphaFunc; - ctx->Driver.Bitmap = sisDDBitmap; ctx->Driver.BlendFuncSeparate = sisDDBlendFuncSeparate; ctx->Driver.ColorMask = sisDDColorMask; ctx->Driver.CullFace = sisDDCullFace; @@ -856,7 +807,6 @@ void sisDDInitStateFuncs( GLcontext *ctx ) ctx->Driver.DepthFunc = sisDDDepthFunc; ctx->Driver.DepthRange = sisDDDepthRange; ctx->Driver.DrawBuffer = sisDDDrawBuffer; - ctx->Driver.DrawPixels = sisDDDrawPixels; ctx->Driver.Enable = sisDDEnable; ctx->Driver.FrontFace = sisDDFrontFace; ctx->Driver.Fogfv = sisDDFogfv; @@ -866,16 +816,17 @@ void sisDDInitStateFuncs( GLcontext *ctx ) ctx->Driver.PolygonMode = NULL; ctx->Driver.PolygonStipple = NULL; ctx->Driver.ReadBuffer = NULL; - ctx->Driver.ReadPixels = sisDDReadPixels; ctx->Driver.RenderMode = NULL; ctx->Driver.Scissor = sisDDScissor; ctx->Driver.ShadeModel = sisDDShadeModel; ctx->Driver.Viewport = sisDDViewport; - /* Pixel path fallbacks. - */ - ctx->Driver.Accum = _swrast_Accum; - ctx->Driver.CopyPixels = _swrast_CopyPixels; + /* Pixel path fallbacks. */ + ctx->Driver.Accum = _swrast_Accum; + ctx->Driver.Bitmap = _swrast_Bitmap; + ctx->Driver.CopyPixels = _swrast_CopyPixels; + ctx->Driver.DrawPixels = _swrast_DrawPixels; + ctx->Driver.ReadPixels = _swrast_ReadPixels; /* Swrast hooks for imaging extensions: */ diff --git a/src/mesa/drivers/dri/sis/sis_tris.c b/src/mesa/drivers/dri/sis/sis_tris.c index 21ec99c878f..479cc8f6785 100644 --- a/src/mesa/drivers/dri/sis/sis_tris.c +++ b/src/mesa/drivers/dri/sis/sis_tris.c @@ -39,14 +39,16 @@ USE OR OTHER DEALINGS IN THE SOFTWARE. #include "swrast/swrast.h" #include "swrast_setup/swrast_setup.h" -#include "tnl/tnl.h" #include "tnl/t_context.h" #include "tnl/t_pipeline.h" +#include "sis_context.h" #include "sis_tris.h" #include "sis_state.h" -#include "sis_vb.h" #include "sis_lock.h" +#include "sis_span.h" +#include "sis_alloc.h" +#include "sis_tex.h" static const GLuint hw_prim[GL_POLYGON+1] = { OP_3D_POINT_DRAW, /* GL_POINTS */ @@ -87,145 +89,243 @@ static const GLuint hw_prim_agp_shade[OP_3D_TRIANGLE_DRAW+1] = { static void sisRasterPrimitive( GLcontext *ctx, GLuint hwprim ); static void sisRenderPrimitive( GLcontext *ctx, GLenum prim ); -static void sisMakeRoomAGP( sisContextPtr smesa, GLint num ); -static void sisUpdateAGP( sisContextPtr smesa ); -static void sisFireVertsAGP( sisContextPtr smesa ); - -static float *AGP_StartPtr; -static float *AGP_WritePtr; /* Current write position */ -static float *AGP_ReadPtr; /* Last known engine readposition */ -static long AGP_SpaceLeft; /* Last known engine readposition */ /*********************************************************************** * Emit primitives as inline vertices * ***********************************************************************/ -/* Future optimizations: - * - * The previous code only emitted W when fog or textures were enabled. - */ +#define HAVE_QUADS 0 +#define HAVE_LINES 1 +#define HAVE_POINTS 1 +#define CTX_ARG sisContextPtr smesa +#define CTX_ARG2 smesa +#define GET_VERTEX_DWORDS() smesa->vertex_size +#define ALLOC_VERTS( n, size ) sisAllocDmaLow( smesa, n * size * sizeof(int) ) +#undef LOCAL_VARS +#define LOCAL_VARS \ + sisContextPtr smesa = SIS_CONTEXT(ctx); \ + const char *vertptr = smesa->verts; +#define VERT(x) (sisVertex *)(vertptr + (x * vertsize * sizeof(int))) +#define VERTEX sisVertex +#undef TAG +#define TAG(x) sis_##x +#include "tnl_dd/t_dd_triemit.h" +#undef TAG +#undef LOCAL_VARS + +/*********************************************************************** + * Dispatch vertices to hardware through MMIO * + ***********************************************************************/ +/* The ARGB write of the last vertex of the primitive fires the 3d engine, so + * save it until the end. + */ #define SIS_MMIO_WRITE_VERTEX(_v, i, lastvert) \ do { \ - MMIOBase[(REG_3D_TSXa+(i)*0x30)/4] = _v->v.x; \ - MMIOBase[(REG_3D_TSYa+(i)*0x30)/4] = _v->v.y; \ - MMIOBase[(REG_3D_TSZa+(i)*0x30)/4] = _v->v.z; \ - MMIOBase[(REG_3D_TSWGa+(i)*0x30)/4] = _v->v.w; \ - /*((GLint *) MMIOBase)[(REG_3D_TSFSa+(i)*0x30)/4] = _v->ui[5];*/ \ - if (SIS_STATES & SIS_VERT_TEX0) { \ - MMIOBase[(REG_3D_TSUAa+(i)*0x30)/4] = _v->v.u0; \ - MMIOBase[(REG_3D_TSVAa+(i)*0x30)/4] = _v->v.v0; \ + GLuint __color, __i = 0; \ + MMIO(REG_3D_TSXa+(i)*0x30, _v->ui[__i++]); \ + MMIO(REG_3D_TSYa+(i)*0x30, _v->ui[__i++]); \ + MMIO(REG_3D_TSZa+(i)*0x30, _v->ui[__i++]); \ + if (SIS_STATES & VERT_W) \ + MMIO(REG_3D_TSWGa+(i)*0x30, _v->ui[__i++]); \ + __color = _v->ui[__i++]; \ + if (SIS_STATES & VERT_SPEC) \ + MMIO(REG_3D_TSFSa+(i)*0x30, _v->ui[__i++]); \ + if (SIS_STATES & VERT_UV0) { \ + MMIO(REG_3D_TSUAa+(i)*0x30, _v->ui[__i++]); \ + MMIO(REG_3D_TSVAa+(i)*0x30, _v->ui[__i++]); \ } \ - if (SIS_STATES & SIS_VERT_TEX1) { \ - MMIOBase[(REG_3D_TSUBa+(i)*0x30)/4] = _v->v.u1; \ - MMIOBase[(REG_3D_TSVBa+(i)*0x30)/4] = _v->v.v1; \ + if (SIS_STATES & VERT_UV1) { \ + MMIO(REG_3D_TSUBa+(i)*0x30, _v->ui[__i++]); \ + MMIO(REG_3D_TSVBa+(i)*0x30, _v->ui[__i++]); \ } \ - /*MMIOBase[(REG_3D_TSUCa+(i)*0x30)/4] = _v->v.u2; \ - MMIOBase[(REG_3D_TSVCa+(i)*0x30)/4] = _v->v.v2;*/ \ - /* the ARGB write of the last vertex of the primitive fires the 3d engine*/ \ - if (lastvert || (SIS_STATES & SIS_VERT_SMOOTH)) \ - ((GLint *) MMIOBase)[(REG_3D_TSARGBa+(i)*0x30)/4] = _v->ui[4]; \ -} while (0); - -#define SIS_AGP_WRITE_VERTEX(_v) \ -do { \ - AGP_WritePtr[0] = _v->v.x; \ - AGP_WritePtr[1] = _v->v.y; \ - AGP_WritePtr[2] = _v->v.z; \ - AGP_WritePtr[3] = _v->v.w; \ - ((GLint *)AGP_WritePtr)[4] = _v->ui[4]; \ - AGP_WritePtr += 5; \ - if (SIS_STATES & SIS_VERT_TEX0) { \ - AGP_WritePtr[0] = _v->v.u0; \ - AGP_WritePtr[1] = _v->v.v0; \ - AGP_WritePtr += 2; \ - } \ - if (SIS_STATES & SIS_VERT_TEX1) { \ - AGP_WritePtr[0] = _v->v.u1; \ - AGP_WritePtr[1] = _v->v.v1; \ - AGP_WritePtr += 2; \ - } \ -} while(0) + if (lastvert || (SIS_STATES & VERT_SMOOTH)) \ + MMIO(REG_3D_TSARGBa+(i)*0x30, __color); \ +} while (0) #define MMIO_VERT_REG_COUNT 10 -#define SIS_VERT_SMOOTH 0x01 -#define SIS_VERT_TEX0 0x02 -#define SIS_VERT_TEX1 0x04 - -static sis_quad_func sis_quad_func_agp[8]; -static sis_tri_func sis_tri_func_agp[8]; -static sis_line_func sis_line_func_agp[8]; -static sis_point_func sis_point_func_agp[8]; -static sis_quad_func sis_quad_func_mmio[8]; -static sis_tri_func sis_tri_func_mmio[8]; -static sis_line_func sis_line_func_mmio[8]; -static sis_point_func sis_point_func_mmio[8]; - -/* XXX: These definitions look questionable */ -#define USE_XYZ MASK_PsVertex_HAS_RHW -#define USE_W MASK_PsVertex_HAS_NORMALXYZ -#define USE_RGB MASK_PsVertex_HAS_SPECULAR -#define USE_UV1 MASK_PsVertex_HAS_UVSet2 -#define USE_UV2 MASK_PsVertex_HAS_UVSet3 - -static GLint AGPParsingValues[8] = { - (5 << 28) | USE_XYZ | USE_W | USE_RGB, - (5 << 28) | USE_XYZ | USE_W | USE_RGB, - (7 << 28) | USE_XYZ | USE_W | USE_RGB | USE_UV1, - (7 << 28) | USE_XYZ | USE_W | USE_RGB | USE_UV1, - (7 << 28) | USE_XYZ | USE_W | USE_RGB | USE_UV2, - (7 << 28) | USE_XYZ | USE_W | USE_RGB | USE_UV2, - (9 << 28) | USE_XYZ | USE_W | USE_RGB | USE_UV1 | USE_UV2, - (9 << 28) | USE_XYZ | USE_W | USE_RGB | USE_UV1 | USE_UV2, -}; +#define VERT_SMOOTH 0x01 +#define VERT_W 0x02 +#define VERT_SPEC 0x04 +#define VERT_UV0 0x08 +#define VERT_UV1 0x10 + +typedef void (*mmio_draw_func)(sisContextPtr smesa, char *verts); +static mmio_draw_func sis_tri_func_mmio[32]; +static mmio_draw_func sis_line_func_mmio[32]; +static mmio_draw_func sis_point_func_mmio[32]; #define SIS_STATES (0) #define TAG(x) x##_none #include "sis_tritmp.h" -#define SIS_STATES (SIS_VERT_SMOOTH) +#define SIS_STATES (VERT_SMOOTH) +#define TAG(x) x##_g +#include "sis_tritmp.h" + +#define SIS_STATES (VERT_W) +#define TAG(x) x##_w +#include "sis_tritmp.h" + +#define SIS_STATES (VERT_SMOOTH | VERT_W) +#define TAG(x) x##_gw +#include "sis_tritmp.h" + +#define SIS_STATES (VERT_SPEC) #define TAG(x) x##_s #include "sis_tritmp.h" -#define SIS_STATES (SIS_VERT_TEX0) +#define SIS_STATES (VERT_SMOOTH | VERT_SPEC) +#define TAG(x) x##_gs +#include "sis_tritmp.h" + +#define SIS_STATES (VERT_W | VERT_SPEC) +#define TAG(x) x##_ws +#include "sis_tritmp.h" + +#define SIS_STATES (VERT_SMOOTH | VERT_W | VERT_SPEC) +#define TAG(x) x##_gws +#include "sis_tritmp.h" + +#define SIS_STATES (VERT_UV0) #define TAG(x) x##_t0 #include "sis_tritmp.h" -#define SIS_STATES (SIS_VERT_SMOOTH | SIS_VERT_TEX0) +#define SIS_STATES (VERT_SMOOTH | VERT_UV0) +#define TAG(x) x##_gt0 +#include "sis_tritmp.h" + +#define SIS_STATES (VERT_W | VERT_UV0) +#define TAG(x) x##_wt0 +#include "sis_tritmp.h" + +#define SIS_STATES (VERT_SMOOTH | VERT_W | VERT_UV0) +#define TAG(x) x##_gwt0 +#include "sis_tritmp.h" + +#define SIS_STATES (VERT_SPEC | VERT_UV0) #define TAG(x) x##_st0 #include "sis_tritmp.h" -#define SIS_STATES (SIS_VERT_TEX1) +#define SIS_STATES (VERT_SMOOTH | VERT_SPEC | VERT_UV0) +#define TAG(x) x##_gst0 +#include "sis_tritmp.h" + +#define SIS_STATES (VERT_W | VERT_SPEC | VERT_UV0) +#define TAG(x) x##_wst0 +#include "sis_tritmp.h" + +#define SIS_STATES (VERT_SMOOTH | VERT_W | VERT_SPEC | VERT_UV0) +#define TAG(x) x##_gwst0 +#include "sis_tritmp.h" + +#define SIS_STATES (VERT_UV1) #define TAG(x) x##_t1 #include "sis_tritmp.h" -#define SIS_STATES (SIS_VERT_SMOOTH | SIS_VERT_TEX1) +#define SIS_STATES (VERT_SMOOTH | VERT_UV1) +#define TAG(x) x##_gt1 +#include "sis_tritmp.h" + +#define SIS_STATES (VERT_W | VERT_UV1) +#define TAG(x) x##_wt1 +#include "sis_tritmp.h" + +#define SIS_STATES (VERT_SMOOTH | VERT_W | VERT_UV1) +#define TAG(x) x##_gwt1 +#include "sis_tritmp.h" + +#define SIS_STATES (VERT_SPEC | VERT_UV1) #define TAG(x) x##_st1 #include "sis_tritmp.h" -#define SIS_STATES (SIS_VERT_TEX0 | SIS_VERT_TEX1) +#define SIS_STATES (VERT_SMOOTH | VERT_SPEC | VERT_UV1) +#define TAG(x) x##_gst1 +#include "sis_tritmp.h" + +#define SIS_STATES (VERT_W | VERT_SPEC | VERT_UV1) +#define TAG(x) x##_wst1 +#include "sis_tritmp.h" + +#define SIS_STATES (VERT_SMOOTH | VERT_W | VERT_SPEC | VERT_UV1) +#define TAG(x) x##_gwst1 +#include "sis_tritmp.h" + +#define SIS_STATES (VERT_UV0 | VERT_UV1) #define TAG(x) x##_t0t1 #include "sis_tritmp.h" -#define SIS_STATES (SIS_VERT_SMOOTH | SIS_VERT_TEX0 | SIS_VERT_TEX1) +#define SIS_STATES (VERT_SMOOTH | VERT_UV0 | VERT_UV1) +#define TAG(x) x##_gt0t1 +#include "sis_tritmp.h" + +#define SIS_STATES (VERT_W | VERT_UV0 | VERT_UV1) +#define TAG(x) x##_wt0t1 +#include "sis_tritmp.h" + +#define SIS_STATES (VERT_SMOOTH | VERT_W | VERT_UV0 | VERT_UV1) +#define TAG(x) x##_gwt0t1 +#include "sis_tritmp.h" + +#define SIS_STATES (VERT_SPEC | VERT_UV0 | VERT_UV1) #define TAG(x) x##_st0t1 #include "sis_tritmp.h" +#define SIS_STATES (VERT_SMOOTH | VERT_SPEC | VERT_UV0 | VERT_UV1) +#define TAG(x) x##_gst0t1 +#include "sis_tritmp.h" + +#define SIS_STATES (VERT_W | VERT_SPEC | VERT_UV0 | VERT_UV1) +#define TAG(x) x##_wst0t1 +#include "sis_tritmp.h" + +#define SIS_STATES (VERT_SMOOTH | VERT_W | VERT_SPEC | VERT_UV0 | VERT_UV1) +#define TAG(x) x##_gwst0t1 +#include "sis_tritmp.h" + /*********************************************************************** * Macros for t_dd_tritmp.h to draw basic primitives * ***********************************************************************/ -#define POINT( v0 ) smesa->draw_point( smesa, v0 ) -#define LINE( v0, v1 ) smesa->draw_line( smesa, v0, v1 ) -#define TRI( a, b, c ) smesa->draw_tri( smesa, a, b, c ) -#define QUAD( a, b, c, d ) smesa->draw_quad( smesa, a, b, c, d ) +#define TRI( a, b, c ) \ +do { \ + if (DO_FALLBACK) \ + smesa->draw_tri( smesa, a, b, c ); \ + else \ + sis_triangle( smesa, a, b, c ); \ +} while (0) + +#define QUAD( a, b, c, d ) \ +do { \ + if (DO_FALLBACK) { \ + smesa->draw_tri( smesa, a, b, d ); \ + smesa->draw_tri( smesa, b, c, d ); \ + } else \ + sis_quad( smesa, a, b, c, d ); \ +} while (0) + +#define LINE( v0, v1 ) \ +do { \ + if (DO_FALLBACK) \ + smesa->draw_line( smesa, v0, v1 ); \ + else \ + sis_line( smesa, v0, v1 ); \ +} while (0) + +#define POINT( v0 ) \ +do { \ + if (DO_FALLBACK) \ + smesa->draw_point( smesa, v0 ); \ + else \ + sis_point( smesa, v0 ); \ +} while (0) /*********************************************************************** * Build render functions from dd templates * ***********************************************************************/ -#define SIS_OFFSET_BIT 0x01 +#define SIS_OFFSET_BIT 0x01 #define SIS_TWOSIDE_BIT 0x02 #define SIS_UNFILLED_BIT 0x04 #define SIS_FALLBACK_BIT 0x08 @@ -258,7 +358,7 @@ static struct { #define VERTEX sisVertex #define TAB rast_tab -#define DEPTH_SCALE 1.0 +#define DEPTH_SCALE smesa->depth_scale #define UNFILLED_TRI unfilled_tri #define UNFILLED_QUAD unfilled_quad #define VERT_X(_v) _v->v.x @@ -337,7 +437,7 @@ do { \ #define TAG(x) x##_twoside #include "tnl_dd/t_dd_tritmp.h" -#define IND (SIS_TWOSIDE_BIT | SIS_OFFSET_BIT) +#define IND (SIS_TWOSIDE_BIT|SIS_OFFSET_BIT) #define TAG(x) x##_twoside_offset #include "tnl_dd/t_dd_tritmp.h" @@ -345,15 +445,15 @@ do { \ #define TAG(x) x##_unfilled #include "tnl_dd/t_dd_tritmp.h" -#define IND (SIS_OFFSET_BIT | SIS_UNFILLED_BIT) +#define IND (SIS_OFFSET_BIT|SIS_UNFILLED_BIT) #define TAG(x) x##_offset_unfilled #include "tnl_dd/t_dd_tritmp.h" -#define IND (SIS_TWOSIDE_BIT | SIS_UNFILLED_BIT) +#define IND (SIS_TWOSIDE_BIT|SIS_UNFILLED_BIT) #define TAG(x) x##_twoside_unfilled #include "tnl_dd/t_dd_tritmp.h" -#define IND (SIS_TWOSIDE_BIT | SIS_OFFSET_BIT | SIS_UNFILLED_BIT) +#define IND (SIS_TWOSIDE_BIT|SIS_OFFSET_BIT|SIS_UNFILLED_BIT) #define TAG(x) x##_twoside_offset_unfilled #include "tnl_dd/t_dd_tritmp.h" @@ -361,31 +461,31 @@ do { \ #define TAG(x) x##_fallback #include "tnl_dd/t_dd_tritmp.h" -#define IND (SIS_OFFSET_BIT | SIS_FALLBACK_BIT) +#define IND (SIS_OFFSET_BIT|SIS_FALLBACK_BIT) #define TAG(x) x##_offset_fallback #include "tnl_dd/t_dd_tritmp.h" -#define IND (SIS_TWOSIDE_BIT | SIS_FALLBACK_BIT) +#define IND (SIS_TWOSIDE_BIT|SIS_FALLBACK_BIT) #define TAG(x) x##_twoside_fallback #include "tnl_dd/t_dd_tritmp.h" -#define IND (SIS_TWOSIDE_BIT | SIS_OFFSET_BIT | SIS_FALLBACK_BIT) +#define IND (SIS_TWOSIDE_BIT|SIS_OFFSET_BIT|SIS_FALLBACK_BIT) #define TAG(x) x##_twoside_offset_fallback #include "tnl_dd/t_dd_tritmp.h" -#define IND (SIS_UNFILLED_BIT | SIS_FALLBACK_BIT) +#define IND (SIS_UNFILLED_BIT|SIS_FALLBACK_BIT) #define TAG(x) x##_unfilled_fallback #include "tnl_dd/t_dd_tritmp.h" -#define IND (SIS_OFFSET_BIT | SIS_UNFILLED_BIT | SIS_FALLBACK_BIT) +#define IND (SIS_OFFSET_BIT|SIS_UNFILLED_BIT|SIS_FALLBACK_BIT) #define TAG(x) x##_offset_unfilled_fallback #include "tnl_dd/t_dd_tritmp.h" -#define IND (SIS_TWOSIDE_BIT | SIS_UNFILLED_BIT | SIS_FALLBACK_BIT) +#define IND (SIS_TWOSIDE_BIT|SIS_UNFILLED_BIT|SIS_FALLBACK_BIT) #define TAG(x) x##_twoside_unfilled_fallback #include "tnl_dd/t_dd_tritmp.h" -#define IND (SIS_TWOSIDE_BIT | SIS_OFFSET_BIT | SIS_UNFILLED_BIT | \ +#define IND (SIS_TWOSIDE_BIT|SIS_OFFSET_BIT|SIS_UNFILLED_BIT| \ SIS_FALLBACK_BIT) #define TAG(x) x##_twoside_offset_unfilled_fallback #include "tnl_dd/t_dd_tritmp.h" @@ -422,22 +522,6 @@ static void init_rast_tab( void ) * primitives are being drawn, and only for the unaccelerated * primitives. */ -static void -sis_fallback_quad( sisContextPtr smesa, - sisVertex *v0, - sisVertex *v1, - sisVertex *v2, - sisVertex *v3 ) -{ - GLcontext *ctx = smesa->glCtx; - SWvertex v[4]; - sis_translate_vertex( ctx, v0, &v[0] ); - sis_translate_vertex( ctx, v1, &v[1] ); - sis_translate_vertex( ctx, v2, &v[2] ); - sis_translate_vertex( ctx, v3, &v[3] ); - _swrast_Triangle( ctx, &v[0], &v[1], &v[3] ); - _swrast_Triangle( ctx, &v[1], &v[2], &v[3] ); -} static void sis_fallback_tri( sisContextPtr smesa, @@ -447,10 +531,13 @@ sis_fallback_tri( sisContextPtr smesa, { GLcontext *ctx = smesa->glCtx; SWvertex v[3]; - sis_translate_vertex( ctx, v0, &v[0] ); - sis_translate_vertex( ctx, v1, &v[1] ); - sis_translate_vertex( ctx, v2, &v[2] ); + _swsetup_Translate( ctx, v0, &v[0] ); + _swsetup_Translate( ctx, v1, &v[1] ); + _swsetup_Translate( ctx, v2, &v[2] ); + sisSpanRenderStart( ctx ); _swrast_Triangle( ctx, &v[0], &v[1], &v[2] ); + sisSpanRenderFinish( ctx ); + _swrast_flush( ctx ); } @@ -461,9 +548,12 @@ sis_fallback_line( sisContextPtr smesa, { GLcontext *ctx = smesa->glCtx; SWvertex v[2]; - sis_translate_vertex( ctx, v0, &v[0] ); - sis_translate_vertex( ctx, v1, &v[1] ); + _swsetup_Translate( ctx, v0, &v[0] ); + _swsetup_Translate( ctx, v1, &v[1] ); + sisSpanRenderStart( ctx ); _swrast_Line( ctx, &v[0], &v[1] ); + sisSpanRenderFinish( ctx ); + _swrast_flush( ctx ); } @@ -473,8 +563,11 @@ sis_fallback_point( sisContextPtr smesa, { GLcontext *ctx = smesa->glCtx; SWvertex v[1]; - sis_translate_vertex( ctx, v0, &v[0] ); + _swsetup_Translate( ctx, v0, &v[0] ); + sisSpanRenderStart( ctx ); _swrast_Point( ctx, &v[0] ); + sisSpanRenderFinish( ctx ); + _swrast_flush( ctx ); } @@ -483,21 +576,20 @@ sis_fallback_point( sisContextPtr smesa, /* Render unclipped begin/end objects */ /**********************************************************************/ -#define VERT(x) (sisVertex *)(sisverts + (x * vertsize * sizeof(int))) +#define IND 0 +#define V(x) (sisVertex *)(vertptr + (x * vertsize * sizeof(int))) #define RENDER_POINTS( start, count ) \ for ( ; start < count ; start++) \ - smesa->draw_point( smesa, VERT(start) ) -#define RENDER_LINE( v0, v1 ) smesa->draw_line( smesa, VERT(v0), VERT(v1) ) -#define RENDER_TRI( v0, v1, v2 ) smesa->draw_tri( smesa, VERT(v0), VERT(v1), \ - VERT(v2) ) -#define RENDER_QUAD( v0, v1, v2, v3 ) smesa->draw_quad( smesa, VERT(v0), \ - VERT(v1), VERT(v2), VERT(v3)) + POINT( V(ELT(start)) ) +#define RENDER_LINE( v0, v1 ) LINE( V(v0), V(v1) ) +#define RENDER_TRI( v0, v1, v2 ) TRI( V(v0), V(v1), V(v2) ) +#define RENDER_QUAD( v0, v1, v2, v3 ) QUAD( V(v0), V(v1), V(v2), V(v3) ) #define INIT(x) sisRenderPrimitive( ctx, x ) #undef LOCAL_VARS #define LOCAL_VARS \ sisContextPtr smesa = SIS_CONTEXT(ctx); \ const GLuint vertsize = smesa->vertex_size; \ - const char *sisverts = (char *)smesa->verts; \ + const char *vertptr = (char *)smesa->verts; \ const GLuint * const elt = TNL_CONTEXT(ctx)->vb.Elts; \ (void) elt; #define RESET_STIPPLE @@ -514,65 +606,16 @@ sis_fallback_point( sisContextPtr smesa, /**********************************************************************/ -/* Render clipped primitives */ -/**********************************************************************/ - -static void sisRenderClippedPoly( 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 sisRenderClippedLine( GLcontext *ctx, GLuint ii, GLuint jj ) -{ - TNLcontext *tnl = TNL_CONTEXT(ctx); - tnl->Driver.Render.Line( ctx, ii, jj ); -} - -#if 0 -static void sisFastRenderClippedPoly( GLcontext *ctx, const GLuint *elts, - GLuint n ) -{ - sisContextPtr smesa = SIS_CONTEXT( ctx ); - GLuint vertsize = smesa->vertex_size; - GLuint *vb = r128AllocDmaLow( rmesa, (n-2) * 3 * 4 * vertsize ); - GLubyte *sisverts = (GLubyte *)smesa->verts; - const GLuint *start = (const GLuint *)VERT(elts[0]); - int i,j; - - smesa->num_verts += (n-2) * 3; - - for (i = 2 ; i < n ; i++) { - COPY_DWORDS( j, vb, vertsize, (sisVertexPtr) VERT(elts[i-1]) ); - COPY_DWORDS( j, vb, vertsize, (sisVertexPtr) VERT(elts[i]) ); - COPY_DWORDS( j, vb, vertsize, (sisVertexPtr) start ); - } -} -#endif - - - - -/**********************************************************************/ /* Choose render functions */ /**********************************************************************/ #define _SIS_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) \ + _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) @@ -584,31 +627,10 @@ static void sisFastRenderClippedPoly( GLcontext *ctx, const GLuint *elts, static void sisChooseRenderState(GLcontext *ctx) { + TNLcontext *tnl = TNL_CONTEXT(ctx); sisContextPtr smesa = SIS_CONTEXT( ctx ); GLuint flags = ctx->_TriangleCaps; GLuint index = 0; - GLuint vertindex = 0; - - if (ctx->Texture.Unit[0]._ReallyEnabled) - vertindex |= SIS_VERT_TEX0; - if (ctx->Texture.Unit[1]._ReallyEnabled) - vertindex |= SIS_VERT_TEX1; - if (ctx->Light.ShadeModel == GL_SMOOTH) - vertindex |= SIS_VERT_SMOOTH; - - if (smesa->AGPCmdModeEnabled) { - smesa->draw_quad = sis_quad_func_agp[vertindex]; - smesa->draw_tri = sis_tri_func_agp[vertindex]; - smesa->draw_line = sis_line_func_agp[vertindex]; - smesa->draw_point = sis_point_func_agp[vertindex]; - } else { - smesa->draw_quad = sis_quad_func_mmio[vertindex]; - smesa->draw_tri = sis_tri_func_mmio[vertindex]; - smesa->draw_line = sis_line_func_mmio[vertindex]; - smesa->draw_point = sis_point_func_mmio[vertindex]; - } - smesa->AGPParseSet &= ~(MASK_VertexDWSize | MASK_VertexDataFormat); - smesa->AGPParseSet |= AGPParsingValues[vertindex]; if (flags & (ANY_RASTER_FLAGS|ANY_FALLBACK_FLAGS)) { @@ -618,6 +640,9 @@ static void sisChooseRenderState(GLcontext *ctx) if (flags & DD_TRI_UNFILLED) index |= SIS_UNFILLED_BIT; } + smesa->draw_point = sis_point; + smesa->draw_line = sis_line; + smesa->draw_tri = sis_triangle; /* Hook in fallbacks for specific primitives. */ if (flags & ANY_FALLBACK_FLAGS) { @@ -625,35 +650,30 @@ static void sisChooseRenderState(GLcontext *ctx) smesa->draw_point = sis_fallback_point; if (flags & LINE_FALLBACK) smesa->draw_line = sis_fallback_line; - if (flags & TRI_FALLBACK) { - smesa->draw_quad = sis_fallback_quad; + if (flags & TRI_FALLBACK) smesa->draw_tri = sis_fallback_tri; - } index |= SIS_FALLBACK_BIT; } } if (index != smesa->RenderIndex) { - TNLcontext *tnl = TNL_CONTEXT(ctx); + smesa->RenderIndex = index; + 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 = sis_render_tab_verts; tnl->Driver.Render.PrimTabElts = sis_render_tab_elts; - tnl->Driver.Render.ClippedLine = rast_tab[index].line; - /*XXX: sisFastRenderClippedPoly*/ - tnl->Driver.Render.ClippedPolygon = sisRenderClippedPoly; + tnl->Driver.Render.ClippedPolygon = sis_fast_clipped_poly; } else { tnl->Driver.Render.PrimTabVerts = _tnl_render_tab_verts; tnl->Driver.Render.PrimTabElts = _tnl_render_tab_elts; - tnl->Driver.Render.ClippedLine = sisRenderClippedLine; - tnl->Driver.Render.ClippedPolygon = sisRenderClippedPoly; + tnl->Driver.Render.ClippedPolygon = _tnl_RenderClippedPolygon; } - - smesa->RenderIndex = index; } } @@ -706,20 +726,11 @@ static void sisRunPipeline( GLcontext *ctx ) { sisContextPtr smesa = SIS_CONTEXT( ctx ); - LOCK_HARDWARE(); - sisUpdateHWState( ctx ); - - if (smesa->AGPCmdModeEnabled) { - AGP_WritePtr = (GLfloat *)smesa->AGPCmdBufBase + *smesa->pAGPCmdBufNext; - AGP_StartPtr = AGP_WritePtr; - AGP_ReadPtr = (GLfloat *)((long)MMIO_READ(REG_3D_AGPCmBase) - - (long)smesa->AGPCmdBufAddr + (long)smesa->AGPCmdBufBase); - sisUpdateAGP( smesa ); - } - if (!smesa->Fallback && smesa->NewGLState) { - if (smesa->NewGLState & _SIS_NEW_VERTEX_STATE) - sisChooseVertexState( ctx ); + if (smesa->NewGLState & _NEW_TEXTURE) { + SIS_FIREVERTICES(smesa); + sisUpdateTextureState(ctx); + } if (smesa->NewGLState & (_SIS_NEW_RENDER_STATE | _NEW_TEXTURE)) sisChooseRenderState( ctx ); @@ -729,11 +740,10 @@ static void sisRunPipeline( GLcontext *ctx ) _tnl_run_pipeline( ctx ); - if (smesa->AGPCmdModeEnabled) - sisFireVertsAGP( smesa ); - else - mEndPrimitive(); - UNLOCK_HARDWARE(); + /* XXX: If we put flushing in sis_state.c and friends, we can avoid this. + * Is it worth it? + */ + SIS_FIREVERTICES(smesa); } /**********************************************************************/ @@ -749,26 +759,21 @@ static void sisRasterPrimitive( GLcontext *ctx, GLuint hwprim ) { sisContextPtr smesa = SIS_CONTEXT(ctx); if (smesa->hw_primitive != hwprim) { - if (smesa->AGPCmdModeEnabled) { - sisFireVertsAGP( smesa ); - smesa->AGPParseSet &= ~(MASK_PsDataType | MASK_PsShadingMode); - smesa->AGPParseSet |= hw_prim_agp_type[hwprim]; - if (ctx->Light.ShadeModel == GL_FLAT) - smesa->AGPParseSet |= hw_prim_agp_shade[hwprim]; - else - smesa->AGPParseSet |= MASK_PsShadingSmooth; + SIS_FIREVERTICES(smesa); + smesa->hw_primitive = hwprim; + smesa->AGPParseSet &= ~(MASK_PsDataType | MASK_PsShadingMode); + smesa->dwPrimitiveSet &= ~(MASK_DrawPrimitiveCommand | + MASK_SetFirePosition | MASK_ShadingMode); + smesa->AGPParseSet |= hw_prim_agp_type[hwprim]; + smesa->dwPrimitiveSet |= hwprim | hw_prim_mmio_fire[hwprim]; + if (ctx->Light.ShadeModel == GL_FLAT) { + smesa->AGPParseSet |= hw_prim_agp_shade[hwprim]; + smesa->dwPrimitiveSet |= hw_prim_mmio_shade[hwprim]; } else { - mEndPrimitive(); - smesa->dwPrimitiveSet &= ~(MASK_DrawPrimitiveCommand | - MASK_SetFirePosition | MASK_ShadingMode); - smesa->dwPrimitiveSet |= hwprim | hw_prim_mmio_fire[hwprim]; - if (ctx->Light.ShadeModel == GL_FLAT) - smesa->dwPrimitiveSet |= hw_prim_mmio_shade[hwprim]; - else - smesa->dwPrimitiveSet |= SHADE_GOURAUD; + smesa->AGPParseSet |= MASK_PsShadingSmooth; + smesa->dwPrimitiveSet |= SHADE_GOURAUD; } } - smesa->hw_primitive = hwprim; } static void sisRenderPrimitive( GLcontext *ctx, GLenum prim ) @@ -776,21 +781,38 @@ static void sisRenderPrimitive( GLcontext *ctx, GLenum prim ) sisContextPtr smesa = SIS_CONTEXT(ctx); smesa->render_primitive = prim; + if (prim >= GL_TRIANGLES && (ctx->_TriangleCaps & DD_TRI_UNFILLED)) return; sisRasterPrimitive( ctx, hw_prim[prim] ); } +#define EMIT_ATTR( ATTR, STYLE) \ +do { \ + smesa->vertex_attrs[smesa->vertex_attr_count].attrib = (ATTR); \ + smesa->vertex_attrs[smesa->vertex_attr_count].format = (STYLE); \ + smesa->vertex_attr_count++; \ +} while (0) + +#define EMIT_PAD( N ) \ +do { \ + smesa->vertex_attrs[smesa->vertex_attr_count].attrib = 0; \ + smesa->vertex_attrs[smesa->vertex_attr_count].format = EMIT_PAD; \ + smesa->vertex_attrs[smesa->vertex_attr_count].offset = (N); \ + smesa->vertex_attr_count++; \ +} while (0) +#define SIS_TCL_STATE_BITS \ + (_TNL_BITS_TEX_ANY | _TNL_BIT_COLOR1 | _TNL_BIT_FOG) + static void sisRenderStart( GLcontext *ctx ) { TNLcontext *tnl = TNL_CONTEXT(ctx); sisContextPtr smesa = SIS_CONTEXT(ctx); - - /* Check for projective texturing. Make sure all texcoord - * pointers point to something. (fix in mesa?) - */ - sisCheckTexSizes( ctx ); + struct vertex_buffer *VB = &tnl->vb; + GLuint index = tnl->render_inputs; + GLuint AGPParseSet = smesa->AGPParseSet; + GLboolean tex_fallback = GL_FALSE; if (ctx->Color._DrawDestMask == DD_FRONT_LEFT_BIT && smesa->driDrawable->numClipRects != 0) @@ -803,83 +825,143 @@ static void sisRenderStart( GLcontext *ctx ) } else { tnl->Driver.Render.Multipass = NULL; } + + /* Important: + */ + VB->AttribPtr[VERT_ATTRIB_POS] = VB->NdcPtr; + smesa->vertex_attr_count = 0; + + /* EMIT_ATTR's must be in order as they tell t_vertex.c how to build up a + * hardware vertex. + */ + + AGPParseSet &= ~(MASK_VertexDWSize | MASK_VertexDataFormat); + AGPParseSet |= SiS_PS_HAS_XYZ | SiS_PS_HAS_DIFFUSE; + if (index & _TNL_BITS_TEX_ANY) { + EMIT_ATTR(_TNL_ATTRIB_POS, EMIT_4F_VIEWPORT); + AGPParseSet |= SiS_PS_HAS_W; + } else { + EMIT_ATTR(_TNL_ATTRIB_POS, EMIT_3F_VIEWPORT); + } + + EMIT_ATTR(_TNL_ATTRIB_COLOR0, EMIT_4UB_4F_BGRA); + + if (index & (_TNL_BIT_COLOR1|_TNL_BIT_FOG)) { + AGPParseSet |= SiS_PS_HAS_SPECULAR; + + if (index & _TNL_BIT_COLOR1) { + EMIT_ATTR(_TNL_ATTRIB_COLOR1, EMIT_3UB_3F_BGR); + } else { + EMIT_PAD(3); + } + + if (index & _TNL_BIT_FOG) + EMIT_ATTR(_TNL_ATTRIB_FOG, EMIT_1UB_1F); + else + EMIT_PAD(1); + } + + /* projective textures are not supported by the hardware */ + if (index & _TNL_BIT_TEX(0)) { + if (VB->TexCoordPtr[0]->size > 2) + tex_fallback = GL_TRUE; + EMIT_ATTR(_TNL_ATTRIB_TEX0, EMIT_2F); + AGPParseSet |= SiS_PS_HAS_UV0; + } + if (index & _TNL_BIT_TEX(1)) { + if (VB->TexCoordPtr[1]->size > 2) + tex_fallback = GL_TRUE; + EMIT_ATTR(_TNL_ATTRIB_TEX1, EMIT_2F); + AGPParseSet |= SiS_PS_HAS_UV1; + } + FALLBACK(smesa, SIS_FALLBACK_TEXTURE, tex_fallback); + + if (smesa->last_tcl_state != index) { + smesa->AGPParseSet = AGPParseSet; + + smesa->vertex_size = _tnl_install_attrs( ctx, smesa->vertex_attrs, + smesa->vertex_attr_count, smesa->hw_viewport, 0 ); + + smesa->vertex_size >>= 2; + smesa->AGPParseSet |= smesa->vertex_size << 28; + } } static void sisRenderFinish( GLcontext *ctx ) { } -/* Update SpaceLeft after an engine or current write pointer update */ -static void sisUpdateAGP( sisContextPtr smesa ) -{ - /* ReadPtr == WritePtr is the empty case */ - if (AGP_ReadPtr <= AGP_WritePtr) - AGP_SpaceLeft = (long)smesa->AGPCmdBufBase + (long)smesa->AGPCmdBufSize - - (long)AGP_WritePtr; - else - AGP_SpaceLeft = AGP_ReadPtr - AGP_WritePtr - 4; -} +/**********************************************************************/ +/* AGP/PCI vertex submission */ +/**********************************************************************/ -/* Fires a set of vertices that have been written from AGP_StartPtr to - * AGP_WritePtr, using the smesa->AGPParseSet format. - */ void -sisFireVertsAGP( sisContextPtr smesa ) +sisFlushPrimsLocked(sisContextPtr smesa) { - if (AGP_WritePtr == AGP_StartPtr) - return; + GLuint *start; - mWait3DCmdQueue(5); - mEndPrimitive(); - MMIO(REG_3D_AGPCmBase, (long)AGP_StartPtr - (long)smesa->AGPCmdBufBase + - (long)smesa->AGPCmdBufAddr); - MMIO(REG_3D_AGPTtDwNum, (((long)AGP_WritePtr - (long)AGP_StartPtr) >> 2) | - 0x50000000); - MMIO(REG_3D_ParsingSet, smesa->AGPParseSet); - - MMIO(REG_3D_AGPCmFire, (GLint)(-1)); - mEndPrimitive(); - - *(smesa->pAGPCmdBufNext) = (((long)AGP_WritePtr - - (long)smesa->AGPCmdBufBase) + 0xf) & ~0xf; - AGP_StartPtr = AGP_WritePtr; - sisUpdateAGP( smesa ); -} + sisUpdateHWState(smesa->glCtx); -/* Make sure there are more than num dwords left in the AGP queue. */ -static void -sisMakeRoomAGP( sisContextPtr smesa, GLint num ) -{ - int size = num * 4; - - if (size <= AGP_SpaceLeft) { - AGP_SpaceLeft -= size; - return; - } - /* Wrapping */ - if (AGP_WritePtr + num > (GLfloat *)(smesa->AGPCmdBufBase + - smesa->AGPCmdBufSize)) - { - sisFireVertsAGP( smesa ); - AGP_WritePtr = (GLfloat *)smesa->AGPCmdBufBase; - AGP_StartPtr = AGP_WritePtr; - sisUpdateAGP( smesa ); - WaitEngIdle( smesa ); /* XXX Why is this necessary? */ - } - - if (size > AGP_SpaceLeft) { - /* Update the cached engine read pointer */ - AGP_ReadPtr = (GLfloat *)((long)MMIO_READ(REG_3D_AGPCmBase) - - (long)smesa->AGPCmdBufAddr + (long)smesa->AGPCmdBufBase); - sisUpdateAGP( smesa ); - while (size > AGP_SpaceLeft) { - /* Spin until space is available. */ - AGP_ReadPtr = (GLfloat *)((long)MMIO_READ(REG_3D_AGPCmBase) - - (long)smesa->AGPCmdBufAddr + (long)smesa->AGPCmdBufBase); - sisUpdateAGP( smesa ); + if (smesa->using_agp) { + mWait3DCmdQueue(8); + mEndPrimitive(); + MMIO(REG_3D_AGPCmBase, (smesa->vb_last - smesa->vb) + + smesa->vb_agp_offset); + MMIO(REG_3D_AGPTtDwNum, (smesa->vb_cur - smesa->vb_last) / 4 | + 0x50000000); + MMIO(REG_3D_ParsingSet, smesa->AGPParseSet); + MMIO(REG_3D_AGPCmFire, (GLint)(-1)); + mEndPrimitive(); + } else { + int mmio_index = 0, incr = 0; + void (*emit_func)(sisContextPtr smesa, char *verts) = NULL; + + if (smesa->AGPParseSet & MASK_PsShadingSmooth) + mmio_index |= VERT_SMOOTH; + if (smesa->AGPParseSet & SiS_PS_HAS_SPECULAR) + mmio_index |= VERT_SPEC; + if (smesa->AGPParseSet & SiS_PS_HAS_W) + mmio_index |= VERT_W; + if (smesa->AGPParseSet & SiS_PS_HAS_UV0) + mmio_index |= VERT_UV0; + if (smesa->AGPParseSet & SiS_PS_HAS_UV1) + mmio_index |= VERT_UV1; + + switch (smesa->AGPParseSet & MASK_PsDataType) { + case MASK_PsPointList: + incr = smesa->vertex_size * 4; + emit_func = sis_point_func_mmio[mmio_index]; + break; + case MASK_PsLineList: + incr = smesa->vertex_size * 4 * 2; + emit_func = sis_line_func_mmio[mmio_index]; + break; + case MASK_PsTriangleList: + incr = smesa->vertex_size * 4 * 3; + emit_func = sis_tri_func_mmio[mmio_index]; + break; + } + + mWait3DCmdQueue(1); + MMIO(REG_3D_PrimitiveSet, smesa->dwPrimitiveSet); + while (smesa->vb_last < smesa->vb_cur) { + emit_func(smesa, smesa->vb_last); + smesa->vb_last += incr; } + mWait3DCmdQueue(1); + mEndPrimitive(); + + /* With PCI, we can just start writing to the start of the VB again. */ + smesa->vb_cur = smesa->vb; } - AGP_SpaceLeft -= size; + smesa->vb_last = smesa->vb_cur; +} + +void sisFlushPrims(sisContextPtr smesa) +{ + LOCK_HARDWARE(); + sisFlushPrimsLocked(smesa); + UNLOCK_HARDWARE(); } /**********************************************************************/ @@ -895,6 +977,7 @@ void sisFallback( GLcontext *ctx, GLuint bit, GLboolean mode ) if (mode) { smesa->Fallback |= bit; if (oldfallback == 0) { + SIS_FIREVERTICES(smesa); _swsetup_Wakeup( ctx ); smesa->RenderIndex = ~0; } @@ -906,9 +989,19 @@ void sisFallback( GLcontext *ctx, GLuint bit, GLboolean mode ) tnl->Driver.Render.Start = sisRenderStart; tnl->Driver.Render.PrimitiveNotify = sisRenderPrimitive; tnl->Driver.Render.Finish = sisRenderFinish; - tnl->Driver.Render.BuildVertices = sisBuildVertices; - smesa->NewGLState |= (_SIS_NEW_RENDER_STATE| - _SIS_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, + smesa->vertex_attrs, + smesa->vertex_attr_count, + smesa->hw_viewport, 0 ); + + smesa->NewGLState |= _SIS_NEW_RENDER_STATE; } } } @@ -929,29 +1022,59 @@ void sisInitTriFuncs( GLcontext *ctx ) firsttime = 0; sis_vert_init_none(); + sis_vert_init_g(); + sis_vert_init_w(); + sis_vert_init_gw(); sis_vert_init_s(); + sis_vert_init_gs(); + sis_vert_init_ws(); + sis_vert_init_gws(); sis_vert_init_t0(); + sis_vert_init_gt0(); + sis_vert_init_wt0(); + sis_vert_init_gwt0(); sis_vert_init_st0(); + sis_vert_init_gst0(); + sis_vert_init_wst0(); + sis_vert_init_gwst0(); sis_vert_init_t1(); + sis_vert_init_gt1(); + sis_vert_init_wt1(); + sis_vert_init_gwt1(); sis_vert_init_st1(); + sis_vert_init_gst1(); + sis_vert_init_wst1(); + sis_vert_init_gwst1(); sis_vert_init_t0t1(); + sis_vert_init_gt0t1(); + sis_vert_init_wt0t1(); + sis_vert_init_gwt0t1(); sis_vert_init_st0t1(); + sis_vert_init_gst0t1(); + sis_vert_init_wst0t1(); + sis_vert_init_gwst0t1(); } + if (driQueryOptionb(&smesa->optionCache, "fallback_force")) + sisFallback(ctx, SIS_FALLBACK_FORCE, 1); + else + sisFallback(ctx, SIS_FALLBACK_FORCE, 0); + + smesa->RenderIndex = ~0; + smesa->NewGLState |= _SIS_NEW_RENDER_STATE; + tnl->Driver.RunPipeline = sisRunPipeline; tnl->Driver.Render.Start = sisRenderStart; tnl->Driver.Render.Finish = sisRenderFinish; tnl->Driver.Render.PrimitiveNotify = sisRenderPrimitive; tnl->Driver.Render.ResetLineStipple = _swrast_ResetLineStipple; - tnl->Driver.Render.BuildVertices = sisBuildVertices; - tnl->Driver.Render.Multipass = NULL; - if (driQueryOptionb(&smesa->optionCache, "fallback_force")) - sisFallback(ctx, SIS_FALLBACK_FORCE, 1); - else - sisFallback(ctx, SIS_FALLBACK_FORCE, 0); + tnl->Driver.Render.BuildVertices = _tnl_build_vertices; + tnl->Driver.Render.CopyPV = _tnl_copy_pv; + tnl->Driver.Render.Interp = _tnl_interp; - smesa->RenderIndex = ~0; - smesa->NewGLState |= (_SIS_NEW_RENDER_STATE| - _SIS_NEW_VERTEX_STATE); + _tnl_init_vertices( ctx, ctx->Const.MaxArrayLockSize + 12, + (6 + 2*ctx->Const.MaxTextureUnits) * sizeof(GLfloat) ); + + smesa->verts = (char *)tnl->clipspace.vertex_buf; } diff --git a/src/mesa/drivers/dri/sis/sis_tris.h b/src/mesa/drivers/dri/sis/sis_tris.h index d0ca7c12c0e..0a8620e5ee1 100644 --- a/src/mesa/drivers/dri/sis/sis_tris.h +++ b/src/mesa/drivers/dri/sis/sis_tris.h @@ -32,13 +32,39 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. #ifndef __SIS_TRIS_H__ #define __SIS_TRIS_H__ +#include "sis_lock.h" #include "mtypes.h" extern void sisInitTriFuncs( GLcontext *ctx ); - - +extern void sisFlushPrims( sisContextPtr smesa ); +extern void sisFlushPrimsLocked( sisContextPtr smesa ); extern void sisFallback( GLcontext *ctx, GLuint bit, GLboolean mode ); + #define FALLBACK( smesa, bit, mode ) sisFallback( smesa->glCtx, bit, mode ) +#define SIS_FIREVERTICES(smesa) \ +do { \ + if (smesa->vb_cur != smesa->vb_last) \ + sisFlushPrims(smesa); \ +} while (0) + +static __inline GLuint *sisAllocDmaLow(sisContextPtr smesa, int bytes) +{ + GLuint *start; + if (smesa->vb_cur + bytes >= smesa->vb_end) { + LOCK_HARDWARE(); + sisFlushPrimsLocked(smesa); + if (smesa->using_agp) { + WaitEngIdle(smesa); + smesa->vb_cur = smesa->vb; + smesa->vb_last = smesa->vb_cur; + } + UNLOCK_HARDWARE(); + } + + start = (GLuint *)smesa->vb_cur; + smesa->vb_cur += bytes; + return start; +} #endif /* __SIS_TRIS_H__ */ diff --git a/src/mesa/drivers/dri/sis/sis_tritmp.h b/src/mesa/drivers/dri/sis/sis_tritmp.h index 77596585430..bd2ecd1c4cd 100644 --- a/src/mesa/drivers/dri/sis/sis_tritmp.h +++ b/src/mesa/drivers/dri/sis/sis_tritmp.h @@ -29,122 +29,42 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. * Eric Anholt <[email protected]> */ -#define AGP_VERT_REG_COUNT (5 + \ - ((SIS_STATES & SIS_VERT_TEX0) != 0) * 2 + \ - ((SIS_STATES & SIS_VERT_TEX1) != 0) * 2) - -static void TAG(sis_draw_quad_mmio)( sisContextPtr smesa, - sisVertexPtr v0, - sisVertexPtr v1, - sisVertexPtr v2, - sisVertexPtr v3 ) -{ - float *MMIOBase = (float *)GET_IOBase (smesa); - - mWait3DCmdQueue (MMIO_VERT_REG_COUNT * 6 + 1); - ((GLint *) MMIOBase)[REG_3D_PrimitiveSet / 4] = smesa->dwPrimitiveSet; - SIS_MMIO_WRITE_VERTEX(v0, 0, 0); - SIS_MMIO_WRITE_VERTEX(v1, 1, 0); - SIS_MMIO_WRITE_VERTEX(v3, 2, 1); - SIS_MMIO_WRITE_VERTEX(v1, 0, 0); - SIS_MMIO_WRITE_VERTEX(v2, 1, 0); - SIS_MMIO_WRITE_VERTEX(v3, 2, 1); -} - -static void TAG(sis_draw_tri_mmio)( sisContextPtr smesa, - sisVertexPtr v0, - sisVertexPtr v1, - sisVertexPtr v2 ) +static void TAG(sis_draw_tri_mmio)(sisContextPtr smesa, char *verts) { - float *MMIOBase = (float *)GET_IOBase (smesa); + sisVertexPtr v0 = (sisVertexPtr)verts; + sisVertexPtr v1 = (sisVertexPtr)(verts + smesa->vertex_size * 4); + sisVertexPtr v2 = (sisVertexPtr)(verts + smesa->vertex_size * 4 * 2); - mWait3DCmdQueue (MMIO_VERT_REG_COUNT * 3 + 1); - ((GLint *) MMIOBase)[REG_3D_PrimitiveSet / 4] = smesa->dwPrimitiveSet; + mWait3DCmdQueue (MMIO_VERT_REG_COUNT * 3); SIS_MMIO_WRITE_VERTEX(v0, 0, 0); SIS_MMIO_WRITE_VERTEX(v1, 1, 0); SIS_MMIO_WRITE_VERTEX(v2, 2, 1); } -static void TAG(sis_draw_line_mmio)( sisContextPtr smesa, - sisVertexPtr v0, - sisVertexPtr v1 ) +static void TAG(sis_draw_line_mmio)(sisContextPtr smesa, char *verts) { - float *MMIOBase = (float *)GET_IOBase (smesa); + sisVertexPtr v0 = (sisVertexPtr)verts; + sisVertexPtr v1 = (sisVertexPtr)(verts + smesa->vertex_size * 4); - mWait3DCmdQueue (MMIO_VERT_REG_COUNT * 2 + 1); - ((GLint *) MMIOBase)[REG_3D_PrimitiveSet / 4] = smesa->dwPrimitiveSet; + mWait3DCmdQueue (MMIO_VERT_REG_COUNT * 2); SIS_MMIO_WRITE_VERTEX(v0, 0, 0); SIS_MMIO_WRITE_VERTEX(v1, 1, 1); } -static void TAG(sis_draw_point_mmio)( sisContextPtr smesa, - sisVertexPtr v0 ) +static void TAG(sis_draw_point_mmio)(sisContextPtr smesa, char *verts) { - float *MMIOBase = (float *)GET_IOBase (smesa); + sisVertexPtr v0 = (sisVertexPtr)verts; - mWait3DCmdQueue (MMIO_VERT_REG_COUNT * 1 + 1); - ((GLint *) MMIOBase)[REG_3D_PrimitiveSet / 4] = smesa->dwPrimitiveSet; + mWait3DCmdQueue (MMIO_VERT_REG_COUNT * 1); SIS_MMIO_WRITE_VERTEX(v0, 1, 1); } -static void TAG(sis_draw_quad_agp)( sisContextPtr smesa, - sisVertexPtr v0, - sisVertexPtr v1, - sisVertexPtr v2, - sisVertexPtr v3 ) -{ - sisMakeRoomAGP(smesa, AGP_VERT_REG_COUNT * 6); - - SIS_AGP_WRITE_VERTEX(v0); - SIS_AGP_WRITE_VERTEX(v1); - SIS_AGP_WRITE_VERTEX(v3); - SIS_AGP_WRITE_VERTEX(v1); - SIS_AGP_WRITE_VERTEX(v2); - SIS_AGP_WRITE_VERTEX(v3); -} - -static void TAG(sis_draw_tri_agp)( sisContextPtr smesa, - sisVertexPtr v0, - sisVertexPtr v1, - sisVertexPtr v2 ) -{ - sisMakeRoomAGP(smesa, AGP_VERT_REG_COUNT * 3); - - SIS_AGP_WRITE_VERTEX(v0); - SIS_AGP_WRITE_VERTEX(v1); - SIS_AGP_WRITE_VERTEX(v2); -} - -static void TAG(sis_draw_line_agp)( sisContextPtr smesa, - sisVertexPtr v0, - sisVertexPtr v1 ) -{ - sisMakeRoomAGP(smesa, AGP_VERT_REG_COUNT * 2); - - SIS_AGP_WRITE_VERTEX(v0); - SIS_AGP_WRITE_VERTEX(v1); -} - -static void TAG(sis_draw_point_agp)( sisContextPtr smesa, - sisVertexPtr v0 ) -{ - sisMakeRoomAGP(smesa, AGP_VERT_REG_COUNT * 1); - - SIS_AGP_WRITE_VERTEX(v0); -} - static __inline void TAG(sis_vert_init)( void ) { - sis_quad_func_agp[SIS_STATES] = TAG(sis_draw_quad_agp); - sis_tri_func_agp[SIS_STATES] = TAG(sis_draw_tri_agp); - sis_line_func_agp[SIS_STATES] = TAG(sis_draw_line_agp); - sis_point_func_agp[SIS_STATES] = TAG(sis_draw_point_agp); - sis_quad_func_mmio[SIS_STATES] = TAG(sis_draw_quad_mmio); sis_tri_func_mmio[SIS_STATES] = TAG(sis_draw_tri_mmio); sis_line_func_mmio[SIS_STATES] = TAG(sis_draw_line_mmio); sis_point_func_mmio[SIS_STATES] = TAG(sis_draw_point_mmio); } -#undef AGP_VERT_REG_COUNT #undef TAG #undef SIS_STATES diff --git a/src/mesa/drivers/dri/sis/sis_vb.c b/src/mesa/drivers/dri/sis/sis_vb.c deleted file mode 100644 index acff4601e96..00000000000 --- a/src/mesa/drivers/dri/sis/sis_vb.c +++ /dev/null @@ -1,445 +0,0 @@ -/* $XFree86$ */ -/************************************************************************** - -Copyright 2003 Eric Anholt -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 -ERIC ANHOLT 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: - * Eric Anholt <[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 "sis_context.h" -#include "sis_vb.h" -#include "sis_tris.h" -#include "sis_state.h" - - -#define SIS_TEX1_BIT 0x1 -#define SIS_TEX0_BIT 0x2 -#define SIS_RGBA_BIT 0x4 -#define SIS_SPEC_BIT 0x8 -#define SIS_FOG_BIT 0x10 -#define SIS_XYZW_BIT 0x20 -#define SIS_PTEX_BIT 0x40 -#define SIS_MAX_SETUP 0x80 - -static struct { - void (*emit)( GLcontext *, GLuint, GLuint, void *, GLuint ); - interp_func interp; - copy_pv_func copy_pv; - GLboolean (*check_tex_sizes)( GLcontext *ctx ); - GLuint vertex_size; - GLuint vertex_format; -} setup_tab[SIS_MAX_SETUP]; - -#define TEX0_VERTEX_FORMAT 1 -#define TEX1_VERTEX_FORMAT 2 - -#define TINY_VERTEX_FORMAT 0 -#define NOTEX_VERTEX_FORMAT 0 -#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 & SIS_XYZW_BIT) -#define DO_RGBA (IND & SIS_RGBA_BIT) -#define DO_SPEC (IND & SIS_SPEC_BIT) -#define DO_FOG (IND & SIS_FOG_BIT) -#define DO_TEX0 (IND & SIS_TEX0_BIT) -#define DO_TEX1 (IND & SIS_TEX1_BIT) -#define DO_TEX2 0 -#define DO_TEX3 0 -#define DO_PTEX (IND & SIS_PTEX_BIT) - -#define VERTEX sisVertex -#define VERTEX_COLOR sis_color_t -#define LOCALVARS sisContextPtr smesa = SIS_CONTEXT(ctx); -#define GET_VIEWPORT_MAT() smesa->hw_viewport -#define GET_TEXSOURCE(n) n -#define GET_VERTEX_FORMAT() smesa->vertex_format -#define GET_VERTEX_STORE() smesa->verts -#define GET_VERTEX_SIZE() smesa->vertex_size * sizeof(GLuint) - -#define HAVE_HW_VIEWPORT 0 -#define HAVE_HW_DIVIDE 0 -#define HAVE_RGBA_COLOR 0 -#define HAVE_TINY_VERTICES 0 -#define HAVE_NOTEX_VERTICES 0 -#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 - -#define UNVIEWPORT_VARS GLfloat h = SIS_CONTEXT(ctx)->driDrawable->h -#define UNVIEWPORT_X(x) x - SUBPIXEL_X -#define UNVIEWPORT_Y(y) - y + h + SUBPIXEL_Y -#define UNVIEWPORT_Z(z) z / smesa->depth_scale - -#define PTEX_FALLBACK() FALLBACK(smesa, SIS_FALLBACK_TEXTURE, 1) - -#define INTERP_VERTEX setup_tab[smesa->SetupIndex].interp -#define COPY_PV_VERTEX setup_tab[smesa->SetupIndex].copy_pv - -/*********************************************************************** - * Generate pv-copying and translation functions * - ***********************************************************************/ - -#define TAG(x) sis_##x -#include "tnl_dd/t_dd_vb.c" - -/*********************************************************************** - * Generate vertex emit and interp functions * - ***********************************************************************/ - - -#define IND (SIS_XYZW_BIT|SIS_RGBA_BIT) -#define TAG(x) x##_wg -#include "tnl_dd/t_dd_vbtmp.h" - -#define IND (SIS_XYZW_BIT|SIS_RGBA_BIT|SIS_SPEC_BIT) -#define TAG(x) x##_wgs -#include "tnl_dd/t_dd_vbtmp.h" - -#define IND (SIS_XYZW_BIT|SIS_RGBA_BIT|SIS_TEX0_BIT) -#define TAG(x) x##_wgt0 -#include "tnl_dd/t_dd_vbtmp.h" - -#define IND (SIS_XYZW_BIT|SIS_RGBA_BIT|SIS_TEX0_BIT|SIS_TEX1_BIT) -#define TAG(x) x##_wgt0t1 -#include "tnl_dd/t_dd_vbtmp.h" - -#define IND (SIS_XYZW_BIT|SIS_RGBA_BIT|SIS_TEX0_BIT|SIS_PTEX_BIT) -#define TAG(x) x##_wgpt0 -#include "tnl_dd/t_dd_vbtmp.h" - -#define IND (SIS_XYZW_BIT|SIS_RGBA_BIT|SIS_SPEC_BIT|SIS_TEX0_BIT) -#define TAG(x) x##_wgst0 -#include "tnl_dd/t_dd_vbtmp.h" - -#define IND (SIS_XYZW_BIT|SIS_RGBA_BIT|SIS_SPEC_BIT|SIS_TEX0_BIT|\ - SIS_TEX1_BIT) -#define TAG(x) x##_wgst0t1 -#include "tnl_dd/t_dd_vbtmp.h" - -#define IND (SIS_XYZW_BIT|SIS_RGBA_BIT|SIS_SPEC_BIT|SIS_TEX0_BIT|\ - SIS_PTEX_BIT) -#define TAG(x) x##_wgspt0 -#include "tnl_dd/t_dd_vbtmp.h" - -#define IND (SIS_XYZW_BIT|SIS_RGBA_BIT|SIS_FOG_BIT) -#define TAG(x) x##_wgf -#include "tnl_dd/t_dd_vbtmp.h" - -#define IND (SIS_XYZW_BIT|SIS_RGBA_BIT|SIS_FOG_BIT|SIS_SPEC_BIT) -#define TAG(x) x##_wgfs -#include "tnl_dd/t_dd_vbtmp.h" - -#define IND (SIS_XYZW_BIT|SIS_RGBA_BIT|SIS_FOG_BIT|SIS_TEX0_BIT) -#define TAG(x) x##_wgft0 -#include "tnl_dd/t_dd_vbtmp.h" - -#define IND (SIS_XYZW_BIT|SIS_RGBA_BIT|SIS_FOG_BIT|SIS_TEX0_BIT|\ - SIS_TEX1_BIT) -#define TAG(x) x##_wgft0t1 -#include "tnl_dd/t_dd_vbtmp.h" - -#define IND (SIS_XYZW_BIT|SIS_RGBA_BIT|SIS_FOG_BIT|SIS_TEX0_BIT|\ - SIS_PTEX_BIT) -#define TAG(x) x##_wgfpt0 -#include "tnl_dd/t_dd_vbtmp.h" - -#define IND (SIS_XYZW_BIT|SIS_RGBA_BIT|SIS_FOG_BIT|SIS_SPEC_BIT|\ - SIS_TEX0_BIT) -#define TAG(x) x##_wgfst0 -#include "tnl_dd/t_dd_vbtmp.h" - -#define IND (SIS_XYZW_BIT|SIS_RGBA_BIT|SIS_FOG_BIT|SIS_SPEC_BIT|\ - SIS_TEX0_BIT|SIS_TEX1_BIT) -#define TAG(x) x##_wgfst0t1 -#include "tnl_dd/t_dd_vbtmp.h" - -#define IND (SIS_XYZW_BIT|SIS_RGBA_BIT|SIS_FOG_BIT|SIS_SPEC_BIT|\ - SIS_TEX0_BIT|SIS_PTEX_BIT) -#define TAG(x) x##_wgfspt0 -#include "tnl_dd/t_dd_vbtmp.h" - -#define IND (SIS_TEX0_BIT) -#define TAG(x) x##_t0 -#include "tnl_dd/t_dd_vbtmp.h" - -#define IND (SIS_TEX0_BIT|SIS_TEX1_BIT) -#define TAG(x) x##_t0t1 -#include "tnl_dd/t_dd_vbtmp.h" - -#define IND (SIS_FOG_BIT) -#define TAG(x) x##_f -#include "tnl_dd/t_dd_vbtmp.h" - -#define IND (SIS_FOG_BIT|SIS_TEX0_BIT) -#define TAG(x) x##_ft0 -#include "tnl_dd/t_dd_vbtmp.h" - -#define IND (SIS_FOG_BIT|SIS_TEX0_BIT|SIS_TEX1_BIT) -#define TAG(x) x##_ft0t1 -#include "tnl_dd/t_dd_vbtmp.h" - -#define IND (SIS_RGBA_BIT) -#define TAG(x) x##_g -#include "tnl_dd/t_dd_vbtmp.h" - -#define IND (SIS_RGBA_BIT|SIS_SPEC_BIT) -#define TAG(x) x##_gs -#include "tnl_dd/t_dd_vbtmp.h" - -#define IND (SIS_RGBA_BIT|SIS_TEX0_BIT) -#define TAG(x) x##_gt0 -#include "tnl_dd/t_dd_vbtmp.h" - -#define IND (SIS_RGBA_BIT|SIS_TEX0_BIT|SIS_TEX1_BIT) -#define TAG(x) x##_gt0t1 -#include "tnl_dd/t_dd_vbtmp.h" - -#define IND (SIS_RGBA_BIT|SIS_SPEC_BIT|SIS_TEX0_BIT) -#define TAG(x) x##_gst0 -#include "tnl_dd/t_dd_vbtmp.h" - -#define IND (SIS_RGBA_BIT|SIS_SPEC_BIT|SIS_TEX0_BIT|SIS_TEX1_BIT) -#define TAG(x) x##_gst0t1 -#include "tnl_dd/t_dd_vbtmp.h" - -#define IND (SIS_RGBA_BIT|SIS_FOG_BIT) -#define TAG(x) x##_gf -#include "tnl_dd/t_dd_vbtmp.h" - -#define IND (SIS_RGBA_BIT|SIS_FOG_BIT|SIS_SPEC_BIT) -#define TAG(x) x##_gfs -#include "tnl_dd/t_dd_vbtmp.h" - -#define IND (SIS_RGBA_BIT|SIS_FOG_BIT|SIS_TEX0_BIT) -#define TAG(x) x##_gft0 -#include "tnl_dd/t_dd_vbtmp.h" - -#define IND (SIS_RGBA_BIT|SIS_FOG_BIT|SIS_TEX0_BIT|SIS_TEX1_BIT) -#define TAG(x) x##_gft0t1 -#include "tnl_dd/t_dd_vbtmp.h" - -#define IND (SIS_RGBA_BIT|SIS_FOG_BIT|SIS_SPEC_BIT|SIS_TEX0_BIT) -#define TAG(x) x##_gfst0 -#include "tnl_dd/t_dd_vbtmp.h" - -#define IND (SIS_RGBA_BIT|SIS_FOG_BIT|SIS_SPEC_BIT|SIS_TEX0_BIT|\ - SIS_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 sisPrintSetupFlags(char *msg, GLuint flags ) -{ - fprintf(stderr, "%s(%x): %s%s%s%s%s%s\n", - msg, - (int)flags, - (flags & SIS_XYZW_BIT) ? " xyzw," : "", - (flags & SIS_RGBA_BIT) ? " rgba," : "", - (flags & SIS_SPEC_BIT) ? " spec," : "", - (flags & SIS_FOG_BIT) ? " fog," : "", - (flags & SIS_TEX0_BIT) ? " tex-0," : "", - (flags & SIS_TEX1_BIT) ? " tex-1," : ""); -} - - - -void sisCheckTexSizes( GLcontext *ctx ) -{ - sisContextPtr smesa = SIS_CONTEXT( ctx ); - - if (!setup_tab[smesa->SetupIndex].check_tex_sizes(ctx)) { - TNLcontext *tnl = TNL_CONTEXT(ctx); - - /* Invalidate stored verts - */ - smesa->SetupNewInputs = ~0; - smesa->SetupIndex |= SIS_PTEX_BIT; - - if (!smesa->Fallback && - !(ctx->_TriangleCaps & (DD_TRI_LIGHT_TWOSIDE|DD_TRI_UNFILLED))) { - tnl->Driver.Render.Interp = setup_tab[smesa->SetupIndex].interp; - tnl->Driver.Render.CopyPV = setup_tab[smesa->SetupIndex].copy_pv; - } - } -} - -void sisBuildVertices( GLcontext *ctx, - GLuint start, - GLuint count, - GLuint newinputs ) -{ - sisContextPtr smesa = SIS_CONTEXT( ctx ); - GLuint stride = smesa->vertex_size * sizeof(int); - GLubyte *v = ((GLubyte *)smesa->verts + (start * stride)); - - newinputs |= smesa->SetupNewInputs; - smesa->SetupNewInputs = 0; - - if (!newinputs) - return; - - if (newinputs & VERT_BIT_POS) { - setup_tab[smesa->SetupIndex].emit( ctx, start, count, v, stride ); - } else { - GLuint ind = 0; - - if (newinputs & VERT_BIT_COLOR0) - ind |= SIS_RGBA_BIT; - - if (newinputs & VERT_BIT_COLOR1) - ind |= SIS_SPEC_BIT; - - if (newinputs & VERT_BIT_TEX0) - ind |= SIS_TEX0_BIT; - - if (newinputs & VERT_BIT_TEX1) - ind |= SIS_TEX1_BIT; - - if (newinputs & VERT_BIT_FOG) - ind |= SIS_FOG_BIT; - - if (smesa->SetupIndex & SIS_PTEX_BIT) - ind = ~0; - - ind &= smesa->SetupIndex; - - if (ind) { - setup_tab[ind].emit( ctx, start, count, v, stride ); - } - } -} - -void sisChooseVertexState( GLcontext *ctx ) -{ - TNLcontext *tnl = TNL_CONTEXT(ctx); - sisContextPtr smesa = SIS_CONTEXT( ctx ); - GLuint ind = SIS_XYZW_BIT | SIS_RGBA_BIT; - - if (ctx->_TriangleCaps & DD_SEPARATE_SPECULAR) - ind |= SIS_SPEC_BIT; - - if (ctx->Fog.Enabled) - ind |= SIS_FOG_BIT; - - if (ctx->Texture._EnabledUnits) { - ind |= SIS_TEX0_BIT; - if (ctx->Texture.Unit[0]._ReallyEnabled && - ctx->Texture.Unit[1]._ReallyEnabled) - ind |= SIS_TEX1_BIT; - } - - smesa->SetupIndex = ind; - - if (ctx->_TriangleCaps & (DD_TRI_LIGHT_TWOSIDE | DD_TRI_UNFILLED)) { - tnl->Driver.Render.Interp = sis_interp_extras; - tnl->Driver.Render.CopyPV = sis_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 != smesa->vertex_format) { - smesa->vertex_format = setup_tab[ind].vertex_format; - smesa->vertex_size = setup_tab[ind].vertex_size; - } -} - - -void sisInitVB( GLcontext *ctx ) -{ - sisContextPtr smesa = SIS_CONTEXT( ctx ); - GLuint size = TNL_CONTEXT(ctx)->vb.Size; - static int firsttime = 1; - - smesa->verts = (GLubyte *)ALIGN_MALLOC(size * 4 * 16, 32); - - if (firsttime) { - init_setup_tab(); - firsttime = 0; - } -} - -void sisFreeVB( GLcontext *ctx ) -{ - sisContextPtr smesa = SIS_CONTEXT( ctx ); - if (smesa->verts) { - ALIGN_FREE(smesa->verts); - smesa->verts = NULL; - } -} diff --git a/src/mesa/drivers/dri/sis/sis_vb.h b/src/mesa/drivers/dri/sis/sis_vb.h deleted file mode 100644 index 68965298876..00000000000 --- a/src/mesa/drivers/dri/sis/sis_vb.h +++ /dev/null @@ -1,62 +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 2003 Eric Anholt -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 -ERIC ANHOLT 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: - * Eric Anholt <[email protected]> - */ - -#ifndef __SIS_VB_H__ -#define __SIS_VB_H__ - -#include "mtypes.h" -#include "swrast/swrast.h" -#include "sis_context.h" - -#define _SIS_NEW_VERTEX_STATE (_DD_NEW_SEPARATE_SPECULAR | \ - _DD_NEW_TRI_LIGHT_TWOSIDE | \ - _DD_NEW_TRI_UNFILLED | \ - _NEW_TEXTURE | \ - _NEW_FOG) - -extern void sisCheckTexSizes( GLcontext *ctx ); -extern void sisChooseVertexState( GLcontext *ctx ); - -extern void sisBuildVertices( GLcontext *ctx, GLuint start, GLuint count, - GLuint newinputs ); - -extern void sisPrintSetupFlags( char *msg, GLuint flags ); - -extern void sisInitVB( GLcontext *ctx ); -extern void sisFreeVB( GLcontext *ctx ); - -extern void sis_translate_vertex( GLcontext *ctx, - const sisVertex *src, - SWvertex *dst ); - -extern void sis_print_vertex( GLcontext *ctx, const sisVertex *v ); - -#endif |