~ubuntu-branches/ubuntu/quantal/mesa/quantal

« back to all changes in this revision

Viewing changes to src/mesa/drivers/dri/radeon/radeon_swtcl.c

  • Committer: Bazaar Package Importer
  • Author(s): Sebastien Bacher
  • Date: 2007-02-21 12:44:07 UTC
  • mfrom: (1.2.1 upstream)
  • mto: This revision was merged to the branch mainline in revision 22.
  • Revision ID: james.westby@ubuntu.com-20070221124407-rgcacs32mycrtadl
ImportĀ upstreamĀ versionĀ 6.5.2

Show diffs side-by-side

added added

removed removed

Lines of Context:
246
246
   radeonContextPtr rmesa = RADEON_CONTEXT( ctx );
247
247
   TNLcontext *tnl = TNL_CONTEXT(ctx);
248
248
 
249
 
   GLuint se_coord_fmt;
 
249
   GLuint se_coord_fmt = rmesa->hw.set.cmd[SET_SE_COORDFMT];
 
250
   
 
251
   se_coord_fmt &= ~(RADEON_VTX_XY_PRE_MULT_1_OVER_W0 |
 
252
                     RADEON_VTX_Z_PRE_MULT_1_OVER_W0 |
 
253
                     RADEON_VTX_W0_IS_NOT_1_OVER_W0);
250
254
 
251
255
   /* We must ensure that we don't do _tnl_need_projected_coords while in a
252
256
    * rasterization fallback.  As this function will be called again when we
263
267
       !RENDERINPUTS_TEST( tnl->render_inputs_bitset, _TNL_ATTRIB_COLOR1 ))
264
268
       || (ctx->_TriangleCaps & (DD_TRI_LIGHT_TWOSIDE|DD_TRI_UNFILLED))) {
265
269
      rmesa->swtcl.needproj = GL_TRUE;
266
 
      se_coord_fmt = (RADEON_VTX_XY_PRE_MULT_1_OVER_W0 |
267
 
                      RADEON_VTX_Z_PRE_MULT_1_OVER_W0 |
268
 
                      RADEON_TEX1_W_ROUTING_USE_Q1);
 
270
      se_coord_fmt |= (RADEON_VTX_XY_PRE_MULT_1_OVER_W0 |
 
271
                      RADEON_VTX_Z_PRE_MULT_1_OVER_W0);
269
272
   }
270
273
   else {
271
274
      rmesa->swtcl.needproj = GL_FALSE;
272
 
      se_coord_fmt = (RADEON_VTX_W0_IS_NOT_1_OVER_W0 |
273
 
                      RADEON_TEX1_W_ROUTING_USE_Q1);
 
275
      se_coord_fmt |= (RADEON_VTX_W0_IS_NOT_1_OVER_W0);
274
276
   }
275
277
 
276
278
   _tnl_need_projected_coords( ctx, rmesa->swtcl.needproj );
458
460
 
459
461
 
460
462
 
461
 
 
462
463
const struct tnl_pipeline_stage _radeon_render_stage =
463
464
{
464
465
   "radeon render",
472
473
 
473
474
/**************************************************************************/
474
475
 
475
 
/* Radeon texture rectangle expects coords in 0..1 range, not 0..dimension
476
 
 * as in the extension spec.  Need to translate here.
477
 
 *
478
 
 * Note that swrast expects 0..dimension, so if a fallback is active,
479
 
 * don't do anything.  (Maybe need to configure swrast to match hw)
480
 
 */
481
 
struct texrect_stage_data {
482
 
   GLvector4f texcoord[MAX_TEXTURE_UNITS];
483
 
};
484
 
 
485
 
#define TEXRECT_STAGE_DATA(stage) ((struct texrect_stage_data *)stage->privatePtr)
486
 
 
487
 
 
488
 
static GLboolean run_texrect_stage( GLcontext *ctx,
489
 
                                    struct tnl_pipeline_stage *stage )
490
 
{
491
 
   struct texrect_stage_data *store = TEXRECT_STAGE_DATA(stage);
492
 
   radeonContextPtr rmesa = RADEON_CONTEXT(ctx);
493
 
   TNLcontext *tnl = TNL_CONTEXT(ctx);
494
 
   struct vertex_buffer *VB = &tnl->vb;
495
 
   GLuint i;
496
 
 
497
 
   if (rmesa->Fallback)
498
 
      return GL_TRUE;
499
 
 
500
 
   for (i = 0 ; i < ctx->Const.MaxTextureUnits ; i++) {
501
 
      if (ctx->Texture.Unit[i]._ReallyEnabled & TEXTURE_RECT_BIT) {
502
 
         struct gl_texture_object *texObj = ctx->Texture.Unit[i].CurrentRect;
503
 
         struct gl_texture_image *texImage = texObj->Image[0][texObj->BaseLevel];
504
 
         const GLfloat iw = 1.0/texImage->Width;
505
 
         const GLfloat ih = 1.0/texImage->Height;
506
 
         GLfloat *in = (GLfloat *)VB->TexCoordPtr[i]->data;
507
 
         GLint instride = VB->TexCoordPtr[i]->stride;
508
 
         GLfloat (*out)[4] = store->texcoord[i].data;
509
 
         GLint j;
510
 
 
511
 
         store->texcoord[i].size = VB->TexCoordPtr[i]->size;
512
 
         for (j = 0 ; j < VB->Count ; j++) {
513
 
            switch (VB->TexCoordPtr[i]->size) {
514
 
            case 4:
515
 
               out[j][3] = in[3];
516
 
            /* fallthrough */
517
 
            case 3:
518
 
               out[j][2] = in[2];
519
 
            /* fallthrough */
520
 
            default:
521
 
               out[j][0] = in[0] * iw;
522
 
               out[j][1] = in[1] * ih;
523
 
            }
524
 
            in = (GLfloat *)((GLubyte *)in + instride);
525
 
         }
526
 
 
527
 
         VB->AttribPtr[VERT_ATTRIB_TEX0+i] = VB->TexCoordPtr[i] = &store->texcoord[i];
528
 
      }
529
 
   }
530
 
 
531
 
   return GL_TRUE;
532
 
}
533
 
 
534
 
 
535
 
/* Called the first time stage->run() is invoked.
536
 
 */
537
 
static GLboolean alloc_texrect_data( GLcontext *ctx,
538
 
                                     struct tnl_pipeline_stage *stage )
539
 
{
540
 
   struct vertex_buffer *VB = &TNL_CONTEXT(ctx)->vb;
541
 
   struct texrect_stage_data *store;
542
 
   GLuint i;
543
 
 
544
 
   stage->privatePtr = CALLOC(sizeof(*store));
545
 
   store = TEXRECT_STAGE_DATA(stage);
546
 
   if (!store)
547
 
      return GL_FALSE;
548
 
 
549
 
   for (i = 0 ; i < ctx->Const.MaxTextureUnits ; i++)
550
 
      _mesa_vector4f_alloc( &store->texcoord[i], 0, VB->Size, 32 );
551
 
 
552
 
   return GL_TRUE;
553
 
}
554
 
 
555
 
static void free_texrect_data( struct tnl_pipeline_stage *stage )
556
 
{
557
 
   struct texrect_stage_data *store = TEXRECT_STAGE_DATA(stage);
558
 
   GLuint i;
559
 
 
560
 
   if (store) {
561
 
      for (i = 0 ; i < MAX_TEXTURE_UNITS ; i++)
562
 
         if (store->texcoord[i].data)
563
 
            _mesa_vector4f_free( &store->texcoord[i] );
564
 
      FREE( store );
565
 
      stage->privatePtr = NULL;
566
 
   }
567
 
}
568
 
 
569
 
const struct tnl_pipeline_stage _radeon_texrect_stage =
570
 
{
571
 
   "radeon texrect stage",                      /* name */
572
 
   NULL,
573
 
   alloc_texrect_data,
574
 
   free_texrect_data,
575
 
   NULL,
576
 
   run_texrect_stage
577
 
};
578
 
 
579
 
 
580
 
/**************************************************************************/
581
 
 
582
476
 
583
477
static const GLuint reduced_hw_prim[GL_POLYGON+1] = {
584
478
   RADEON_CP_VC_CNTL_PRIM_TYPE_POINT,