i965/vs: Implement integer quotient and remainder math operations.
[mesa.git] / src / mesa / drivers / dri / r300 / r300_swtcl.c
index b3793e28d58f2e6f33ef2a70d1f1217711a29891..4a6762ff8303f2deded4e35d81d375df3ae60bd9 100644 (file)
@@ -68,7 +68,7 @@ do { \
        ++num_attrs; \
 } while (0)
 
-void r300ChooseSwtclVertexFormat(GLcontext *ctx, GLuint *_InputsRead,  GLuint *_OutputsWritten)
+void r300ChooseSwtclVertexFormat(struct gl_context *ctx, GLuint *_InputsRead,  GLuint *_OutputsWritten)
 {
        r300ContextPtr rmesa = R300_CONTEXT( ctx );
        TNLcontext *tnl = TNL_CONTEXT(ctx);
@@ -80,10 +80,11 @@ void r300ChooseSwtclVertexFormat(GLcontext *ctx, GLuint *_InputsRead,  GLuint *_
        GLuint fp_reads = rmesa->selected_fp->InputsRead;
        struct vertex_attribute *attrs = rmesa->vbuf.attribs;
 
+       radeon_print(RADEON_SWRENDER, RADEON_VERBOSE, "%s\n", __func__);
        rmesa->swtcl.coloroffset = rmesa->swtcl.specoffset = 0;
        rmesa->radeon.swtcl.vertex_attr_count = 0;
 
-       if (RADEON_DEBUG & DEBUG_VERTS)
+       if (RADEON_DEBUG & RADEON_VERTS)
                fprintf(stderr, "%s\n", __func__);
 
        /* We always want non Ndc coords format */
@@ -123,7 +124,7 @@ void r300ChooseSwtclVertexFormat(GLcontext *ctx, GLuint *_InputsRead,  GLuint *_
        }
 
        if (ctx->Light.Enabled && ctx->Light.Model.TwoSide) {
-               VB->AttribPtr[VERT_ATTRIB_GENERIC0] = VB->ColorPtr[1];
+               VB->AttribPtr[VERT_ATTRIB_GENERIC0] = VB->BackfaceColorPtr;
                OutputsWritten |= 1 << VERT_RESULT_BFC0;
 #if MESA_LITTLE_ENDIAN
                EMIT_ATTR( _TNL_ATTRIB_GENERIC0, EMIT_4UB_4F_RGBA );
@@ -133,7 +134,7 @@ void r300ChooseSwtclVertexFormat(GLcontext *ctx, GLuint *_InputsRead,  GLuint *_
                ADD_ATTR(VERT_ATTRIB_GENERIC0, R300_DATA_TYPE_BYTE, SWTCL_OVM_COLOR2, SWIZZLE_XYZW, MASK_XYZW, 1);
 #endif
                if (fp_reads & FRAG_BIT_COL1) {
-                       VB->AttribPtr[VERT_ATTRIB_GENERIC1] = VB->SecondaryColorPtr[1];
+                       VB->AttribPtr[VERT_ATTRIB_GENERIC1] = VB->BackfaceSecondaryColorPtr;
                        GLuint swiz = MAKE_SWIZZLE4(SWIZZLE_X, SWIZZLE_Y, SWIZZLE_Z, SWIZZLE_ONE);
                        OutputsWritten |= 1 << VERT_RESULT_BFC1;
 #if MESA_LITTLE_ENDIAN
@@ -158,7 +159,7 @@ void r300ChooseSwtclVertexFormat(GLcontext *ctx, GLuint *_InputsRead,  GLuint *_
                int tex_id = rmesa->selected_fp->wpos_attr - FRAG_ATTRIB_TEX0;
 
                VB->AttribPtr[VERT_ATTRIB_TEX0 + tex_id] = VB->AttribPtr[VERT_ATTRIB_POS];
-               VB->TexCoordPtr[tex_id] = VB->AttribPtr[VERT_ATTRIB_POS];
+               VB->AttribPtr[_TNL_ATTRIB_TEX0 + tex_id] = VB->AttribPtr[VERT_ATTRIB_POS];
                RENDERINPUTS_SET(tnl->render_inputs_bitset, _TNL_ATTRIB_TEX0 + tex_id);
        }
 
@@ -166,7 +167,7 @@ void r300ChooseSwtclVertexFormat(GLcontext *ctx, GLuint *_InputsRead,  GLuint *_
                int tex_id = rmesa->selected_fp->fog_attr - FRAG_ATTRIB_TEX0;
 
                VB->AttribPtr[VERT_ATTRIB_TEX0 + tex_id] = VB->AttribPtr[VERT_ATTRIB_FOG];
-               VB->TexCoordPtr[tex_id] = VB->AttribPtr[VERT_ATTRIB_FOG];
+               VB->AttribPtr[_TNL_ATTRIB_TEX0 + tex_id] = VB->AttribPtr[VERT_ATTRIB_FOG];
                RENDERINPUTS_SET(tnl->render_inputs_bitset, _TNL_ATTRIB_TEX0 + tex_id);
        }
 
@@ -179,7 +180,7 @@ void r300ChooseSwtclVertexFormat(GLcontext *ctx, GLuint *_InputsRead,  GLuint *_
                GLuint swiz, format, hw_format;
                for (i = 0; i < ctx->Const.MaxTextureUnits; i++) {
                        if (fp_reads & FRAG_BIT_TEX(i)) {
-                               switch (VB->TexCoordPtr[i]->size) {
+                               switch (VB->AttribPtr[_TNL_ATTRIB_TEX0 + i]->size) {
                                        case 1:
                                                format = EMIT_1F;
                                                hw_format = R300_DATA_TYPE_FLOAT_1;
@@ -214,7 +215,7 @@ void r300ChooseSwtclVertexFormat(GLcontext *ctx, GLuint *_InputsRead,  GLuint *_
 
        if (first_free_tex >= ctx->Const.MaxTextureUnits) {
                fprintf(stderr, "\tout of free texcoords to write fog coordinate\n");
-               _mesa_exit(-1);
+               exit(-1);
        }
 
        R300_NEWPRIM(rmesa);
@@ -225,10 +226,11 @@ void r300ChooseSwtclVertexFormat(GLcontext *ctx, GLuint *_InputsRead,  GLuint *_
        RENDERINPUTS_COPY(rmesa->render_inputs_bitset, tnl->render_inputs_bitset);
 }
 
-static void r300PrepareVertices(GLcontext *ctx)
+static void r300PrepareVertices(struct gl_context *ctx)
 {
        r300ContextPtr rmesa = R300_CONTEXT(ctx);
        GLuint InputsRead, OutputsWritten;
+       radeon_print(RADEON_SWRENDER, RADEON_TRACE, "%s\n", __func__);
 
        r300ChooseSwtclVertexFormat(ctx, &InputsRead, &OutputsWritten);
        r300SetupVAP(ctx, InputsRead, OutputsWritten);
@@ -262,6 +264,10 @@ static void r300_predict_emit_size( r300ContextPtr rmesa )
 
                rmesa->radeon.swtcl.emit_prediction += rmesa->radeon.cmdbuf.cs->cdw
                        + vertex_size + scissor_size + prim_size + cache_flush_size * 2 + pre_emit_state;
+               radeon_print(RADEON_SWRENDER, RADEON_VERBOSE,
+                               "%s, size %d\n",
+                               __func__, rmesa->radeon.cmdbuf.cs->cdw
+                               + vertex_size + scissor_size + prim_size + cache_flush_size * 2 + pre_emit_state);
        }
 }
 
@@ -279,7 +285,7 @@ static GLuint reduced_prim[] = {
        GL_TRIANGLES,
 };
 
-static void r300RasterPrimitive( GLcontext *ctx, GLuint prim );
+static void r300RasterPrimitive( struct gl_context *ctx, GLuint prim );
 
 /***********************************************************************
  *                    Emit primitives as inline vertices               *
@@ -358,7 +364,6 @@ static struct {
 #define DO_POINTS    1
 #define DO_FULL_QUAD 1
 
-#define HAVE_RGBA   1
 #define HAVE_SPEC   1
 #define HAVE_BACK_COLORS  0
 #define HAVE_HW_FLATSHADE 1
@@ -492,14 +497,13 @@ static void init_rast_tab( void )
 /**********************************************************************/
 /*                    Choose render functions                         */
 /**********************************************************************/
-static void r300ChooseRenderState( GLcontext *ctx )
+static void r300ChooseRenderState( struct gl_context *ctx )
 {
        TNLcontext *tnl = TNL_CONTEXT(ctx);
        r300ContextPtr rmesa = R300_CONTEXT(ctx);
        GLuint index = 0;
        GLuint flags = ctx->_TriangleCaps;
-       if (RADEON_DEBUG & DEBUG_VERTS)
-               fprintf(stderr, "%s\n", __func__);
+       radeon_print(RADEON_SWRENDER, RADEON_VERBOSE, "%s\n", __func__);
 
        if (flags & DD_TRI_UNFILLED)      index |= R300_UNFILLED_BIT;
 
@@ -524,10 +528,9 @@ static void r300ChooseRenderState( GLcontext *ctx )
        }
 }
 
-void r300RenderStart(GLcontext *ctx)
+void r300RenderStart(struct gl_context *ctx)
 {
-       if (RADEON_DEBUG & DEBUG_VERTS)
-               fprintf(stderr, "%s\n", __func__);
+       radeon_print(RADEON_SWRENDER, RADEON_VERBOSE, "%s\n", __func__);
        r300ContextPtr rmesa = R300_CONTEXT( ctx );
 
        r300ChooseRenderState(ctx);
@@ -547,15 +550,14 @@ void r300RenderStart(GLcontext *ctx)
        }
 }
 
-void r300RenderFinish(GLcontext *ctx)
+void r300RenderFinish(struct gl_context *ctx)
 {
 }
 
-static void r300RasterPrimitive( GLcontext *ctx, GLuint hwprim )
+static void r300RasterPrimitive( struct gl_context *ctx, GLuint hwprim )
 {
        r300ContextPtr rmesa = R300_CONTEXT(ctx);
-       if (RADEON_DEBUG & DEBUG_VERTS)
-               fprintf(stderr, "%s\n", __func__);
+       radeon_print(RADEON_SWRENDER, RADEON_TRACE, "%s\n", __func__);
 
        if (rmesa->radeon.swtcl.hw_primitive != hwprim) {
                R300_NEWPRIM( rmesa );
@@ -563,13 +565,12 @@ static void r300RasterPrimitive( GLcontext *ctx, GLuint hwprim )
        }
 }
 
-void r300RenderPrimitive(GLcontext *ctx, GLenum prim)
+void r300RenderPrimitive(struct gl_context *ctx, GLenum prim)
 {
 
        r300ContextPtr rmesa = R300_CONTEXT(ctx);
        rmesa->radeon.swtcl.render_primitive = prim;
-       if (RADEON_DEBUG & DEBUG_VERTS)
-               fprintf(stderr, "%s\n", __func__);
+       radeon_print(RADEON_SWRENDER, RADEON_TRACE, "%s\n", __func__);
 
        if ((prim == GL_TRIANGLES) && (ctx->_TriangleCaps & DD_TRI_UNFILLED))
                return;
@@ -577,19 +578,18 @@ void r300RenderPrimitive(GLcontext *ctx, GLenum prim)
        r300RasterPrimitive( ctx, reduced_prim[prim] );
 }
 
-void r300ResetLineStipple(GLcontext *ctx)
+void r300ResetLineStipple(struct gl_context *ctx)
 {
-       if (RADEON_DEBUG & DEBUG_VERTS)
+       if (RADEON_DEBUG & RADEON_VERTS)
                fprintf(stderr, "%s\n", __func__);
 }
 
-void r300InitSwtcl(GLcontext *ctx)
+void r300InitSwtcl(struct gl_context *ctx)
 {
        TNLcontext *tnl = TNL_CONTEXT(ctx);
        r300ContextPtr rmesa = R300_CONTEXT(ctx);
        static int firsttime = 1;
-       if (RADEON_DEBUG & DEBUG_VERTS)
-               fprintf(stderr, "%s\n", __func__);
+       radeon_print(RADEON_SWRENDER, RADEON_NORMAL, "%s\n", __func__);
 
        if (firsttime) {
                init_rast_tab();
@@ -620,7 +620,7 @@ void r300InitSwtcl(GLcontext *ctx)
        _tnl_need_projected_coords( ctx, GL_FALSE );
 }
 
-void r300DestroySwtcl(GLcontext *ctx)
+void r300DestroySwtcl(struct gl_context *ctx)
 {
 }
 
@@ -628,8 +628,8 @@ static void r300EmitVertexAOS(r300ContextPtr rmesa, GLuint vertex_size, struct r
 {
        BATCH_LOCALS(&rmesa->radeon);
 
-       if (RADEON_DEBUG & DEBUG_VERTS)
-               fprintf(stderr, "%s:  vertex_size %d, offset 0x%x \n",
+       radeon_print(RADEON_SWRENDER, RADEON_TRACE,
+               "%s:  vertex_size %d, offset 0x%x \n",
                        __FUNCTION__, vertex_size, offset);
 
        BEGIN_BATCH(7);
@@ -644,7 +644,7 @@ static void r300EmitVbufPrim(r300ContextPtr rmesa, GLuint primitive, GLuint vert
 {
        BATCH_LOCALS(&rmesa->radeon);
        int type, num_verts;
-       if (RADEON_DEBUG & DEBUG_VERTS)
+       if (RADEON_DEBUG & RADEON_VERTS)
                fprintf(stderr, "%s\n", __func__);
 
        type = r300PrimitiveType(rmesa, primitive);
@@ -656,20 +656,19 @@ static void r300EmitVbufPrim(r300ContextPtr rmesa, GLuint primitive, GLuint vert
        END_BATCH();
 }
 
-void r300_swtcl_flush(GLcontext *ctx, uint32_t current_offset)
+void r300_swtcl_flush(struct gl_context *ctx, uint32_t current_offset)
 {
-       if (RADEON_DEBUG & DEBUG_VERTS)
-               fprintf(stderr, "%s\n", __func__);
+       radeon_print(RADEON_SWRENDER, RADEON_TRACE, "%s\n", __func__);
        r300ContextPtr rmesa = R300_CONTEXT(ctx);
 
        r300EmitCacheFlush(rmesa);
 
        radeonEmitState(&rmesa->radeon);
-    r300_emit_scissor(ctx);
+       r300_emit_scissor(ctx);
        r300EmitVertexAOS(rmesa,
-                       rmesa->radeon.swtcl.vertex_size,
-                       first_elem(&rmesa->radeon.dma.reserved)->bo,
-                       current_offset);
+                         rmesa->radeon.swtcl.vertex_size,
+                         rmesa->radeon.swtcl.bo,
+                         current_offset);
 
        r300EmitVbufPrim(rmesa,
                   rmesa->radeon.swtcl.hw_primitive,