Esempio n. 1
0
static void radeonVtxfmtFlushVertices( GLcontext *ctx, GLuint flags )
{
   radeonContextPtr rmesa = RADEON_CONTEXT( ctx );

   if (RADEON_DEBUG & DEBUG_VFMT)
      fprintf(stderr, "%s\n", __FUNCTION__);

   assert(rmesa->vb.installed);

   if (flags & FLUSH_UPDATE_CURRENT) {
      radeon_copy_to_current( ctx );
      if (RADEON_DEBUG & DEBUG_VFMT)
	 fprintf(stderr, "reinstall on update_current\n");
      _mesa_install_exec_vtxfmt( ctx, &rmesa->vb.vtxfmt );
      ctx->Driver.NeedFlush &= ~FLUSH_UPDATE_CURRENT;
   }

   if (flags & FLUSH_STORED_VERTICES) {
      radeonContextPtr rmesa = RADEON_CONTEXT( ctx );
      assert (rmesa->dma.flush == 0 ||
	      rmesa->dma.flush == flush_prims);
      if (rmesa->dma.flush == flush_prims)
	 flush_prims( RADEON_CONTEXT( ctx ) );
      ctx->Driver.NeedFlush &= ~FLUSH_STORED_VERTICES;
   }
}
Esempio n. 2
0
static void note_last_prim( radeonContextPtr rmesa, GLuint flags )
{
   if (RADEON_DEBUG & DEBUG_VFMT)
      fprintf(stderr, "%s %d\n", __FUNCTION__, rmesa->vb.initial_counter - rmesa->vb.counter);

   if (rmesa->vb.prim[0] != GL_POLYGON+1) {
      rmesa->vb.primlist[rmesa->vb.nrprims].prim |= flags;
      rmesa->vb.primlist[rmesa->vb.nrprims].end = rmesa->vb.initial_counter - rmesa->vb.counter;

      if (++(rmesa->vb.nrprims) == RADEON_MAX_PRIMS)
	 flush_prims( rmesa );
   }
}
Esempio n. 3
0
/* Begin/End
 */
static void radeon_Begin( GLenum mode )
{
   GET_CURRENT_CONTEXT(ctx);
   radeonContextPtr rmesa = RADEON_CONTEXT(ctx);

   if (RADEON_DEBUG & DEBUG_VFMT)
      fprintf(stderr, "%s( %s )\n", __FUNCTION__,
	      _mesa_lookup_enum_by_nr( mode ));

   if (mode > GL_POLYGON) {
      _mesa_error( ctx, GL_INVALID_ENUM, "glBegin" );
      return;
   }

   if (rmesa->vb.prim[0] != GL_POLYGON+1) {
      _mesa_error( ctx, GL_INVALID_OPERATION, "glBegin" );
      return;
   }
   
   if (ctx->NewState) 
      _mesa_update_state( ctx );

   if (rmesa->NewGLState)
      radeonValidateState( ctx );

   if (rmesa->vb.recheck) 
      radeonVtxfmtValidate( ctx );

   if (!rmesa->vb.installed) {
      CALL_Begin(GET_DISPATCH(), (mode));
      return;
   }


   if (rmesa->dma.flush && rmesa->vb.counter < 12) {
      if (RADEON_DEBUG & DEBUG_VFMT)
	 fprintf(stderr, "%s: flush almost-empty buffers\n", __FUNCTION__);
      flush_prims( rmesa );
   }

   /* Need to arrange to save vertices here?  Or always copy from dma (yuk)?
    */
   if (!rmesa->dma.flush) {
/* FIXME: what are these constants? */
      if (rmesa->dma.current.ptr + 12*rmesa->vb.vertex_size*4 > 
	  rmesa->dma.current.end) {
	 RADEON_NEWPRIM( rmesa );
	 radeonRefillCurrentDmaRegion( rmesa );
      }

      rmesa->vb.dmaptr = (int *)(rmesa->dma.current.address + rmesa->dma.current.ptr);
      rmesa->vb.counter = (rmesa->dma.current.end - rmesa->dma.current.ptr) / 
	 (rmesa->vb.vertex_size * 4);
      rmesa->vb.counter--;
      rmesa->vb.initial_counter = rmesa->vb.counter;
      rmesa->vb.notify = wrap_buffer;
      rmesa->dma.flush = flush_prims;
      ctx->Driver.NeedFlush |= FLUSH_STORED_VERTICES;
   }
   
   
   rmesa->vb.prim[0] = mode;
   start_prim( rmesa, mode | PRIM_BEGIN );
}
Esempio n. 4
0
static void wrap_buffer( void )
{
   GET_CURRENT_CONTEXT(ctx);
   radeonContextPtr rmesa = RADEON_CONTEXT(ctx);
   GLfloat tmp[3][RADEON_MAX_VERTEX_SIZE];
   GLuint i, nrverts;

   if (RADEON_DEBUG & (DEBUG_VFMT|DEBUG_PRIMS))
      fprintf(stderr, "%s %d\n", __FUNCTION__, rmesa->vb.initial_counter - rmesa->vb.counter);

   /* Don't deal with parity.
    */
   if ((((rmesa->vb.initial_counter - rmesa->vb.counter) -  
	 rmesa->vb.primlist[rmesa->vb.nrprims].start) & 1)) {
      rmesa->vb.counter++;
      rmesa->vb.initial_counter++;
      return;
   }

   /* Copy vertices out of dma:
    */
   if (rmesa->vb.prim[0] == GL_POLYGON+1) 
      nrverts = 0;
   else {
      nrverts = copy_dma_verts( rmesa, tmp );

      if (RADEON_DEBUG & DEBUG_VFMT)
	 fprintf(stderr, "%d vertices to copy\n", nrverts);
   
      /* Finish the prim at this point:
       */
      note_last_prim( rmesa, 0 );
   }

   /* Fire any buffered primitives
    */
   flush_prims( rmesa );

   /* Get new buffer
    */
   radeonRefillCurrentDmaRegion( rmesa );

   /* Reset counter, dmaptr
    */
   rmesa->vb.dmaptr = (int *)(rmesa->dma.current.ptr + rmesa->dma.current.address);
   rmesa->vb.counter = (rmesa->dma.current.end - rmesa->dma.current.ptr) / 
      (rmesa->vb.vertex_size * 4);
   rmesa->vb.counter--;
   rmesa->vb.initial_counter = rmesa->vb.counter;
   rmesa->vb.notify = wrap_buffer;

   rmesa->dma.flush = flush_prims;

   /* Restart wrapped primitive:
    */
   if (rmesa->vb.prim[0] != GL_POLYGON+1)
      start_prim( rmesa, rmesa->vb.prim[0] );

   /* Reemit saved vertices
    */
   for (i = 0 ; i < nrverts; i++) {
      if (RADEON_DEBUG & DEBUG_VERTS) {
	 int j;
	 fprintf(stderr, "re-emit vertex %d to %p\n", i, (void *)rmesa->vb.dmaptr);
	 if (RADEON_DEBUG & DEBUG_VERBOSE)
	    for (j = 0 ; j < rmesa->vb.vertex_size; j++) 
	       fprintf(stderr, "\t%08x/%f\n", *(int*)&tmp[i][j], tmp[i][j]);
      }

      memcpy( rmesa->vb.dmaptr, tmp[i], rmesa->vb.vertex_size * 4 );
      rmesa->vb.dmaptr += rmesa->vb.vertex_size;
      rmesa->vb.counter--;
   }
}
Esempio n. 5
0
static void VFMT_FALLBACK( const char *caller )
{
   GET_CURRENT_CONTEXT(ctx);
   radeonContextPtr rmesa = RADEON_CONTEXT(ctx);
   GLfloat tmp[3][RADEON_MAX_VERTEX_SIZE];
   GLuint i, prim;
   GLuint ind = rmesa->vb.vertex_format;
   GLuint nrverts;
   GLfloat alpha = 1.0;
   GLuint unit;

   if (RADEON_DEBUG & (DEBUG_FALLBACKS|DEBUG_VFMT))
      fprintf(stderr, "%s from %s\n", __FUNCTION__, caller);

   if (rmesa->vb.prim[0] == GL_POLYGON+1) {
      VFMT_FALLBACK_OUTSIDE_BEGIN_END( __FUNCTION__ );
      return;
   }

   /* Copy vertices out of dma:
    */
   nrverts = copy_dma_verts( rmesa, tmp );

   /* Finish the prim at this point:
    */
   note_last_prim( rmesa, 0 );
   flush_prims( rmesa );

   /* Update ctx->Driver.CurrentExecPrimitive and swap in swtnl. 
    */
   prim = rmesa->vb.prim[0];
   ctx->Driver.CurrentExecPrimitive = GL_POLYGON+1;
   _tnl_wakeup_exec( ctx );
   ctx->Driver.FlushVertices = radeonFlushVertices;

   assert(rmesa->dma.flush == 0);
   rmesa->vb.fell_back = GL_TRUE;
   rmesa->vb.installed = GL_FALSE;
   CALL_Begin(GET_DISPATCH(), (prim));
   
   if (rmesa->vb.installed_color_3f_sz == 4)
      alpha = ctx->Current.Attrib[VERT_ATTRIB_COLOR0][3];

   /* Replay saved vertices
    */
   for (i = 0 ; i < nrverts; i++) {
      GLuint offset = 3;
      if (ind & RADEON_CP_VC_FRMT_N0) {
	 CALL_Normal3fv(GET_DISPATCH(), (&tmp[i][offset]));
	 offset += 3;
      }

      if (ind & RADEON_CP_VC_FRMT_PKCOLOR) {
	 radeon_color_t *col = (radeon_color_t *)&tmp[i][offset];
	 CALL_Color4ub(GET_DISPATCH(), (col->red, col->green, col->blue, col->alpha));
	 offset++;
      }
      else if (ind & RADEON_CP_VC_FRMT_FPALPHA) {
	 CALL_Color4fv(GET_DISPATCH(), (&tmp[i][offset]));
	 offset+=4;
      } 
      else if (ind & RADEON_CP_VC_FRMT_FPCOLOR) {
	 CALL_Color3fv(GET_DISPATCH(), (&tmp[i][offset]));
	 offset+=3;
      }

      if (ind & RADEON_CP_VC_FRMT_PKSPEC) {
	 radeon_color_t *spec = (radeon_color_t *)&tmp[i][offset];
	 CALL_SecondaryColor3ubEXT(GET_DISPATCH(), (spec->red, spec->green, spec->blue));
	 offset++;
      }

      for (unit = 0 ; unit < ctx->Const.MaxTextureUnits; unit++) {
	 if (ind & RADEON_ST_BIT(unit)) {
	    CALL_MultiTexCoord2fvARB(GET_DISPATCH(), ((GL_TEXTURE0 + unit), &tmp[i][offset]));
	    offset += 2;
	 }
      }
      CALL_Vertex3fv(GET_DISPATCH(), (&tmp[i][0]));
   }

   /* Replay current vertex
    */
   if (ind & RADEON_CP_VC_FRMT_N0) 
      CALL_Normal3fv(GET_DISPATCH(), (rmesa->vb.normalptr));

   if (ind & RADEON_CP_VC_FRMT_PKCOLOR)
      CALL_Color4ub(GET_DISPATCH(), (rmesa->vb.colorptr->red, rmesa->vb.colorptr->green,
      				     rmesa->vb.colorptr->blue, rmesa->vb.colorptr->alpha));
   else if (ind & RADEON_CP_VC_FRMT_FPALPHA)
      CALL_Color4fv(GET_DISPATCH(), (rmesa->vb.floatcolorptr));
   else if (ind & RADEON_CP_VC_FRMT_FPCOLOR) {
      if (rmesa->vb.installed_color_3f_sz == 4 && alpha != 1.0)
	 CALL_Color4f(GET_DISPATCH(), (rmesa->vb.floatcolorptr[0],
				       rmesa->vb.floatcolorptr[1],
				       rmesa->vb.floatcolorptr[2],
				       alpha));
      else
	 CALL_Color3fv(GET_DISPATCH(), (rmesa->vb.floatcolorptr));
   }

   if (ind & RADEON_CP_VC_FRMT_PKSPEC) 
       CALL_SecondaryColor3ubEXT(GET_DISPATCH(), (rmesa->vb.specptr->red,
       						  rmesa->vb.specptr->green,
						  rmesa->vb.specptr->blue));

   for (unit = 0 ; unit < ctx->Const.MaxTextureUnits; unit++) {
      if (ind & RADEON_ST_BIT(unit)) {
	 CALL_MultiTexCoord2fvARB(GET_DISPATCH(), ((GL_TEXTURE0 + unit),
	 			  rmesa->vb.texcoordptr[unit]));
      }
   }
}
Esempio n. 6
0
void VFMT_FALLBACK( const char *caller )
{
    GET_CURRENT_CONTEXT(ctx);
    r200ContextPtr rmesa = R200_CONTEXT(ctx);
    GLfloat tmp[3][R200_MAX_VERTEX_SIZE];
    GLuint i, prim;
    GLuint ind0 = rmesa->vb.vtxfmt_0;
    GLuint ind1 = rmesa->vb.vtxfmt_1;
    GLuint nrverts;
    GLfloat alpha = 1.0;
    GLuint count;
    GLuint unit;

    if (R200_DEBUG & (DEBUG_FALLBACKS|DEBUG_VFMT))
        fprintf(stderr, "%s from %s\n", __FUNCTION__, caller);

    if (rmesa->vb.prim[0] == GL_POLYGON+1) {
        VFMT_FALLBACK_OUTSIDE_BEGIN_END( __FUNCTION__ );
        return;
    }

    /* Copy vertices out of dma:
     */
    nrverts = copy_dma_verts( rmesa, tmp );

    /* Finish the prim at this point:
     */
    note_last_prim( rmesa, 0 );
    flush_prims( rmesa );

    /* Update ctx->Driver.CurrentExecPrimitive and swap in swtnl.
     */
    prim = rmesa->vb.prim[0];
    ctx->Driver.CurrentExecPrimitive = GL_POLYGON+1;
    _tnl_wakeup_exec( ctx );
    ctx->Driver.FlushVertices = r200FlushVertices;

    assert(rmesa->dma.flush == 0);
    rmesa->vb.fell_back = GL_TRUE;
    rmesa->vb.installed = GL_FALSE;
    CALL_Begin(GET_DISPATCH(), (prim));

    if (rmesa->vb.installed_color_3f_sz == 4)
        alpha = ctx->Current.Attrib[VERT_ATTRIB_COLOR0][3];

    /* Replay saved vertices
     */
    for (i = 0 ; i < nrverts; i++) {
        GLuint offset = 3;

        if (ind0 & R200_VTX_N0) {
            CALL_Normal3fv(GET_DISPATCH(), (&tmp[i][offset]));
            offset += 3;
        }

        if (ind0 & R200_VTX_DISCRETE_FOG) {
            CALL_FogCoordfvEXT(GET_DISPATCH(), (&tmp[i][offset]));
            offset++;
        }

        if (VTX_COLOR(ind0, 0) == R200_VTX_PK_RGBA) {
            CALL_Color4ubv(GET_DISPATCH(), ((GLubyte *)&tmp[i][offset]));
            offset++;
        }
        else if (VTX_COLOR(ind0, 0) == R200_VTX_FP_RGBA) {
            CALL_Color4fv(GET_DISPATCH(), (&tmp[i][offset]));
            offset+=4;
        }
        else if (VTX_COLOR(ind0, 0) == R200_VTX_FP_RGB) {
            CALL_Color3fv(GET_DISPATCH(), (&tmp[i][offset]));
            offset+=3;
        }

        if (VTX_COLOR(ind0, 1) == R200_VTX_PK_RGBA) {
            CALL_SecondaryColor3ubvEXT(GET_DISPATCH(), ((GLubyte *)&tmp[i][offset]));
            offset++;
        }

        for ( unit = 0 ; unit < ctx->Const.MaxTextureUnits ; unit++ ) {
            count = VTX_TEXn_COUNT( ind1, unit );
            dispatch_multitexcoord( count, unit, &tmp[i][offset] );
            offset += count;
        }

        CALL_Vertex3fv(GET_DISPATCH(), (&tmp[i][0]));
    }

    /* Replay current vertex
     */
    if (ind0 & R200_VTX_N0)
        CALL_Normal3fv(GET_DISPATCH(), (rmesa->vb.normalptr));
    if (ind0 & R200_VTX_DISCRETE_FOG) {
        CALL_FogCoordfvEXT(GET_DISPATCH(), (rmesa->vb.fogptr));
    }

    if (VTX_COLOR(ind0, 0) == R200_VTX_PK_RGBA) {
        CALL_Color4ub(GET_DISPATCH(), (rmesa->vb.colorptr->red,
                                       rmesa->vb.colorptr->green,
                                       rmesa->vb.colorptr->blue,
                                       rmesa->vb.colorptr->alpha));
    }
    else if (VTX_COLOR(ind0, 0) == R200_VTX_FP_RGBA) {
        CALL_Color4fv(GET_DISPATCH(), (rmesa->vb.floatcolorptr));
    }
    else if (VTX_COLOR(ind0, 0) == R200_VTX_FP_RGB) {
        if (rmesa->vb.installed_color_3f_sz == 4 && alpha != 1.0) {
            CALL_Color4f(GET_DISPATCH(), (rmesa->vb.floatcolorptr[0],
                                          rmesa->vb.floatcolorptr[1],
                                          rmesa->vb.floatcolorptr[2],
                                          alpha));
        }
        else {
            CALL_Color3fv(GET_DISPATCH(), (rmesa->vb.floatcolorptr));
        }
    }

    if (VTX_COLOR(ind0, 1) == R200_VTX_PK_RGBA)
        CALL_SecondaryColor3ubEXT(GET_DISPATCH(), (rmesa->vb.specptr->red,
                                  rmesa->vb.specptr->green,
                                  rmesa->vb.specptr->blue));

    for ( unit = 0 ; unit < ctx->Const.MaxTextureUnits ; unit++ ) {
        count = VTX_TEXn_COUNT( ind1, unit );
        dispatch_multitexcoord( count, unit, rmesa->vb.texcoordptr[unit] );
    }
}