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

« back to all changes in this revision

Viewing changes to src/mesa/drivers/dri/r200/r200_tcl.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:
68
68
#define HAVE_ELTS        1
69
69
 
70
70
 
71
 
#define HW_POINTS           ((ctx->_TriangleCaps & DD_POINT_SIZE) ? \
 
71
#define HW_POINTS           ((ctx->Point.PointSprite || \
 
72
                                ((ctx->_TriangleCaps & (DD_POINT_SIZE | DD_POINT_ATTEN)) && \
 
73
                                !(ctx->_TriangleCaps & (DD_POINT_SMOOTH)))) ? \
72
74
                                R200_VF_PRIM_POINT_SPRITES : R200_VF_PRIM_POINTS)
73
75
#define HW_LINES            R200_VF_PRIM_LINES
74
76
#define HW_LINE_LOOP        0
268
270
 
269
271
   if (newprim != rmesa->tcl.hw_primitive ||
270
272
       !discrete_prim[hw_prim&0xf]) {
 
273
      /* need to disable perspective-correct texturing for point sprites */
 
274
      if ((prim & PRIM_MODE_MASK) == GL_POINTS && ctx->Point.PointSprite) {
 
275
         if (rmesa->hw.set.cmd[SET_RE_CNTL] & R200_PERSPECTIVE_ENABLE) {
 
276
            R200_STATECHANGE( rmesa, set );
 
277
            rmesa->hw.set.cmd[SET_RE_CNTL] &= ~R200_PERSPECTIVE_ENABLE;
 
278
         }
 
279
      }
 
280
      else if (!(rmesa->hw.set.cmd[SET_RE_CNTL] & R200_PERSPECTIVE_ENABLE)) {
 
281
         R200_STATECHANGE( rmesa, set );
 
282
         rmesa->hw.set.cmd[SET_RE_CNTL] |= R200_PERSPECTIVE_ENABLE;
 
283
      }
271
284
      R200_NEWPRIM( rmesa );
272
285
      rmesa->tcl.hw_primitive = newprim;
273
286
   }
371
384
   r200ContextPtr rmesa = R200_CONTEXT(ctx);
372
385
   TNLcontext *tnl = TNL_CONTEXT(ctx);
373
386
   struct vertex_buffer *VB = &tnl->vb;
374
 
   GLuint inputs = VERT_BIT_POS | VERT_BIT_COLOR0;
 
387
   GLuint inputs = 0;
375
388
   GLuint i;
376
389
 
377
390
   /* TODO: separate this from the swtnl pipeline 
391
404
      r200ValidateState( ctx );
392
405
 
393
406
   if (!ctx->VertexProgram._Enabled) {
 
407
      inputs = VERT_BIT_POS | VERT_BIT_COLOR0;
394
408
   /* NOTE: inputs != tnl->render_inputs - these are the untransformed
395
409
    * inputs.
396
410
    */
416
430
      }
417
431
   }
418
432
   else {
419
 
      GLuint out_vtxfmt0 = 0;
420
 
      GLuint out_vtxfmt1 = 0;
 
433
      /* vtx_tcl_output_vtxfmt_0/1 need to match configuration of "fragment
 
434
         part", since using some vertex interpolator later which is not in
 
435
         out_vtxfmt0/1 will lock up. It seems to be ok to write in vertex
 
436
         prog to a not enabled output however, so just don't mess with it.
 
437
         We only need to change compsel. */
421
438
      GLuint out_compsel = 0;
422
439
      GLuint vp_out = rmesa->curr_vp_hw->mesa_program.Base.OutputsWritten;
 
440
#if 0
423
441
      /* can't handle other inputs, generic attribs etc. currently - should never arrive here */
424
442
      assert ((rmesa->curr_vp_hw->mesa_program.Base.InputsRead &
425
443
         ~(VERT_BIT_POS | VERT_BIT_NORMAL | VERT_BIT_COLOR0 | VERT_BIT_COLOR1 |
426
444
          VERT_BIT_FOG | VERT_BIT_TEX0 | VERT_BIT_TEX1 | VERT_BIT_TEX2 |
427
445
          VERT_BIT_TEX3 | VERT_BIT_TEX4 | VERT_BIT_TEX5)) == 0);
 
446
#endif
428
447
      inputs |= rmesa->curr_vp_hw->mesa_program.Base.InputsRead;
429
 
      /* FIXME: this is a mess. Not really sure how to set up TCL_OUTPUT_VTXFMT
430
 
         in "undefined" cases (e.g. output needed later but not written by vertex program or vice versa)
431
 
         - however misconfiguration here will almost certainly lock up the chip.
432
 
         I think at the very least we need to enable tcl outputs which we write to. Maybe even need to
433
 
         fix up a vertex program so an output needed later always gets written?
434
 
         For now just set the compsel and output_vtxfmt to the outputs written.
435
 
         However, for simplicity we assume always all 4 values are written which may not be correct
436
 
         (but I don't know if it could lead to lockups). */
437
448
      assert(vp_out & (1 << VERT_RESULT_HPOS));
438
 
      out_vtxfmt0 = R200_VTX_XY | R200_VTX_Z0 | R200_VTX_W0;
439
 
      /* FIXME: need to always enable color_0 otherwise doom3's shadow vp (?) will lock up (?) */
440
 
      out_vtxfmt0 |= R200_VTX_FP_RGBA << R200_VTX_COLOR_0_SHIFT;
441
449
      out_compsel = R200_OUTPUT_XYZW;
442
450
      if (vp_out & (1 << VERT_RESULT_COL0)) {
443
 
         out_vtxfmt0 |= R200_VTX_FP_RGBA << R200_VTX_COLOR_0_SHIFT;
444
451
         out_compsel |= R200_OUTPUT_COLOR_0;
445
452
      }
446
453
      if (vp_out & (1 << VERT_RESULT_COL1)) {
447
 
         out_vtxfmt0 |= R200_VTX_FP_RGBA << R200_VTX_COLOR_1_SHIFT;
448
454
         out_compsel |= R200_OUTPUT_COLOR_1;
449
455
      }
450
 
      /* FIXME: probably not everything is set up for fogc and psiz to work correctly */
451
456
      if (vp_out & (1 << VERT_RESULT_FOGC)) {
452
 
         out_vtxfmt0 |= R200_VTX_DISCRETE_FOG;
453
457
         out_compsel |= R200_OUTPUT_DISCRETE_FOG;
454
458
      }
455
459
      if (vp_out & (1 << VERT_RESULT_PSIZ)) {
456
 
         out_vtxfmt0 |= R200_VTX_POINT_SIZE;
457
460
         out_compsel |= R200_OUTPUT_PT_SIZE;
458
461
      }
459
462
      for (i = VERT_RESULT_TEX0; i < VERT_RESULT_TEX6; i++) {
460
463
         if (vp_out & (1 << i)) {
461
 
            out_vtxfmt1 |= 4  << ((i - VERT_RESULT_TEX0) * 3);
462
464
            out_compsel |= R200_OUTPUT_TEX_0 << (i - VERT_RESULT_TEX0);
463
465
         }
464
466
      }
465
 
      if ((rmesa->hw.vtx.cmd[VTX_TCL_OUTPUT_VTXFMT_0] != out_vtxfmt0) ||
466
 
         (rmesa->hw.vtx.cmd[VTX_TCL_OUTPUT_VTXFMT_1] != out_vtxfmt1) ||
467
 
         (rmesa->hw.vtx.cmd[VTX_TCL_OUTPUT_COMPSEL] != out_compsel)) {
 
467
      if (rmesa->hw.vtx.cmd[VTX_TCL_OUTPUT_COMPSEL] != out_compsel) {
468
468
         R200_STATECHANGE( rmesa, vtx );
469
 
         rmesa->hw.vtx.cmd[VTX_TCL_OUTPUT_VTXFMT_0] = out_vtxfmt0;
470
 
         rmesa->hw.vtx.cmd[VTX_TCL_OUTPUT_VTXFMT_1] = out_vtxfmt1;
471
469
         rmesa->hw.vtx.cmd[VTX_TCL_OUTPUT_COMPSEL] = out_compsel;
472
 
         /* FIXME: should restore this when disabling vertex programs maybe? */
473
470
      }
474
471
   }
475
472
 
545
542
    * need to put the card into D3D mode to make it work:
546
543
    */
547
544
   R200_STATECHANGE( rmesa, vap );
548
 
   /* not sure if it's strictly necessary to disable VAP_PROG_VTX_SHADER_ENABLE in addition to VAP_TCL_ENABLE) */
549
545
   rmesa->hw.vap.cmd[VAP_SE_VAP_CNTL] &= ~(R200_VAP_TCL_ENABLE|R200_VAP_PROG_VTX_SHADER_ENABLE);
550
546
}
551
547
 
584
580
      rmesa->hw.ctx.cmd[CTX_PP_FOG_COLOR] &= ~R200_FOG_USE_MASK;
585
581
      rmesa->hw.ctx.cmd[CTX_PP_FOG_COLOR] |= R200_FOG_USE_VTX_FOG;
586
582
   }
587
 
   
 
583
 
588
584
   R200_STATECHANGE( rmesa, vte );
589
585
   rmesa->hw.vte.cmd[VTE_SE_VTE_CNTL] &= ~(R200_VTX_XY_FMT|R200_VTX_Z_FMT);
590
586
   rmesa->hw.vte.cmd[VTE_SE_VTE_CNTL] |= R200_VTX_W0_FMT;