radeon: use t->bo to figure out of settexbuffer override is in action
[mesa.git] / src / mesa / drivers / dri / r200 / r200_tcl.c
index 4a31578c891f36bb516ebe3d99f4df0eb8cf981b..8e0fb14e70e1a0ce873678985b12beefb1953981 100644 (file)
@@ -123,7 +123,7 @@ static GLboolean discrete_prim[0x10] = {
 
 #define RESET_STIPPLE() do {                   \
    R200_STATECHANGE( rmesa, lin );             \
-   r200EmitState( rmesa );                     \
+   radeonEmitState(&rmesa->radeon);                    \
 } while (0)
 
 #define AUTO_STIPPLE( mode )  do {             \
@@ -134,7 +134,7 @@ static GLboolean discrete_prim[0x10] = {
    else                                                \
       rmesa->hw.lin.cmd[LIN_RE_LINE_PATTERN] &=        \
         ~R200_LINE_PATTERN_AUTO_RESET; \
-   r200EmitState( rmesa );                     \
+   radeonEmitState(&rmesa->radeon);                    \
 } while (0)
 
 
@@ -142,22 +142,21 @@ static GLboolean discrete_prim[0x10] = {
 
 static GLushort *r200AllocElts( r200ContextPtr rmesa, GLuint nr ) 
 {
-   if (rmesa->dma.flush == r200FlushElts &&
-       rmesa->store.cmd_used + nr*2 < R200_CMD_BUF_SZ) {
+   if (rmesa->radeon.dma.flush == r200FlushElts &&
+       rmesa->tcl.elt_used + nr*2 < R200_ELT_BUF_SZ) {
 
-      GLushort *dest = (GLushort *)(rmesa->store.cmd_buf +
-                                   rmesa->store.cmd_used);
+      GLushort *dest = (GLushort *)(rmesa->tcl.elt_dma_bo->ptr +
+                                   rmesa->tcl.elt_used);
 
-      rmesa->store.cmd_used += nr*2;
+      rmesa->tcl.elt_used += nr*2;
 
       return dest;
    }
    else {
-      if (rmesa->dma.flush)
-        rmesa->dma.flush( rmesa->radeon.glCtx );
+      if (rmesa->radeon.dma.flush)
+        rmesa->radeon.dma.flush( rmesa->radeon.glCtx );
 
-      rcommonEnsureCmdBufSpace(rmesa, AOS_BUFSZ(rmesa->tcl.nr_aos_components) +
-                            rmesa->hw.max_state_size + ELTS_BUFSZ(nr) );
+      rcommonEnsureCmdBufSpace(&rmesa->radeon, AOS_BUFSZ(rmesa->tcl.nr_aos_components), __FUNCTION__);
 
       r200EmitAOS( rmesa,
                   rmesa->tcl.nr_aos_components, 0 );
@@ -187,8 +186,10 @@ static void r200EmitPrim( GLcontext *ctx,
    r200ContextPtr rmesa = R200_CONTEXT( ctx );
    r200TclPrimitive( ctx, prim, hwprim );
    
-   rcommonEnsureCmdBufSpace( rmesa, AOS_BUFSZ(rmesa->tcl.nr_aos_components) +
-                            rmesa->hw.max_state_size + VBUF_BUFSZ );
+   //   fprintf(stderr,"Emit prim %d\n", rmesa->tcl.nr_aos_components);
+   rcommonEnsureCmdBufSpace( &rmesa->radeon,
+                            AOS_BUFSZ(rmesa->tcl.nr_aos_components) +
+                            rmesa->radeon.hw.max_state_size + VBUF_BUFSZ, __FUNCTION__ );
 
    r200EmitAOS( rmesa,
                rmesa->tcl.nr_aos_components,
@@ -404,7 +405,8 @@ static GLboolean r200_run_tcl_render( GLcontext *ctx,
    /* Validate state:
     */
    if (rmesa->radeon.NewGLState)
-      r200ValidateState( ctx );
+      if (!r200ValidateState( ctx ))
+         return GL_TRUE; /* fallback to sw t&l */
 
    if (!ctx->VertexProgram._Enabled) {
    /* NOTE: inputs != tnl->render_inputs - these are the untransformed
@@ -563,15 +565,11 @@ static void transition_to_hwtnl( GLcontext *ctx )
 
    tnl->Driver.NotifyMaterialChange = r200UpdateMaterial;
 
-   if ( rmesa->dma.flush )                     
-      rmesa->dma.flush( rmesa->radeon.glCtx ); 
+   if ( rmesa->radeon.dma.flush )                      
+      rmesa->radeon.dma.flush( rmesa->radeon.glCtx );  
 
-   rmesa->dma.flush = NULL;
+   rmesa->radeon.dma.flush = NULL;
    
-   //   if (rmesa->swtcl.indexed_verts.buf) 
-     //      r200ReleaseDmaRegion( rmesa, &rmesa->swtcl.indexed_verts, 
-     //                              __FUNCTION__ );
-
    R200_STATECHANGE( rmesa, vap );
    rmesa->hw.vap.cmd[VAP_SE_VAP_CNTL] |= R200_VAP_TCL_ENABLE;
    rmesa->hw.vap.cmd[VAP_SE_VAP_CNTL] &= ~R200_VAP_FORCE_W_TO_ONE;