~ubuntu-branches/ubuntu/precise/mesa/precise-updates

« back to all changes in this revision

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

  • Committer: Package Import Robot
  • Author(s): Robert Hooker
  • Date: 2012-02-02 12:05:48 UTC
  • mfrom: (1.7.1) (3.3.27 sid)
  • Revision ID: package-import@ubuntu.com-20120202120548-nvkma85jq0h4coix
Tags: 8.0~rc2-0ubuntu4
Drop drisearchdir handling, it is no longer needed with multiarch
and dri-alternates being removed.

Show diffs side-by-side

added added

removed removed

Lines of Context:
51
51
 
52
52
#define STANDALONE_MMIO
53
53
 
54
 
#include "vblank.h"
55
 
 
56
54
#define RADEON_TIMEOUT             512
57
55
#define RADEON_IDLE_RETRY           16
58
56
 
91
89
      insert_at_tail(&rmesa->radeon.hw.atomlist, &rmesa->hw.lit[i]);
92
90
   for (i = 0; i < 6; ++i)
93
91
      insert_at_tail(&rmesa->radeon.hw.atomlist, &rmesa->hw.ucp[i]);
94
 
   if (rmesa->radeon.radeonScreen->kernel_mm)
95
 
      insert_at_tail(&rmesa->radeon.hw.atomlist, &rmesa->hw.stp);
 
92
   insert_at_tail(&rmesa->radeon.hw.atomlist, &rmesa->hw.stp);
96
93
   insert_at_tail(&rmesa->radeon.hw.atomlist, &rmesa->hw.eye);
97
94
   insert_at_tail(&rmesa->radeon.hw.atomlist, &rmesa->hw.grd);
98
95
   insert_at_tail(&rmesa->radeon.hw.atomlist, &rmesa->hw.fog);
102
99
static void radeonEmitScissor(r100ContextPtr rmesa)
103
100
{
104
101
    BATCH_LOCALS(&rmesa->radeon);
105
 
    if (!rmesa->radeon.radeonScreen->kernel_mm) {
106
 
       return;
107
 
    }
108
102
    if (rmesa->radeon.state.scissor.enabled) {
109
103
        BEGIN_BATCH(6);
110
104
        OUT_BATCH(CP_PACKET0(RADEON_PP_CNTL, 0));
142
136
#if RADEON_OLD_PACKETS
143
137
   BEGIN_BATCH(8);
144
138
   OUT_BATCH_PACKET3_CLIP(RADEON_CP_PACKET3_3D_RNDR_GEN_INDX_PRIM, 3);
145
 
   if (!rmesa->radeon.radeonScreen->kernel_mm) {
146
 
     OUT_BATCH_RELOC(rmesa->ioctl.vertex_offset, rmesa->ioctl.bo, rmesa->ioctl.vertex_offset, RADEON_GEM_DOMAIN_GTT, 0, 0);
147
 
   } else {
148
 
     OUT_BATCH(rmesa->ioctl.vertex_offset);
149
 
   }
 
139
   OUT_BATCH(rmesa->ioctl.vertex_offset);
150
140
 
151
141
   OUT_BATCH(vertex_nr);
152
142
   OUT_BATCH(vertex_format);
155
145
             RADEON_CP_VC_CNTL_VTX_FMT_RADEON_MODE |
156
146
             (vertex_nr << RADEON_CP_VC_CNTL_NUM_SHIFT));
157
147
 
158
 
   if (rmesa->radeon.radeonScreen->kernel_mm) {
159
 
     radeon_cs_write_reloc(rmesa->radeon.cmdbuf.cs,
160
 
                           rmesa->ioctl.bo,
161
 
                           RADEON_GEM_DOMAIN_GTT,
162
 
                           0, 0);
163
 
   }
 
148
   radeon_cs_write_reloc(rmesa->radeon.cmdbuf.cs,
 
149
                         rmesa->ioctl.bo,
 
150
                         RADEON_GEM_DOMAIN_GTT,
 
151
                         0, 0);
164
152
 
165
153
   END_BATCH();
166
154
 
195
183
   nr = rmesa->tcl.elt_used;
196
184
 
197
185
#if RADEON_OLD_PACKETS
198
 
   if (rmesa->radeon.radeonScreen->kernel_mm) {
199
 
     dwords -= 2;
200
 
   }
 
186
   dwords -= 2;
201
187
#endif
202
188
 
203
189
#if RADEON_OLD_PACKETS
212
198
   rmesa->radeon.cmdbuf.cs->section_cdw += dwords;
213
199
 
214
200
#if RADEON_OLD_PACKETS
215
 
   if (rmesa->radeon.radeonScreen->kernel_mm) {
216
 
      radeon_cs_write_reloc(rmesa->radeon.cmdbuf.cs,
217
 
                            rmesa->ioctl.bo,
218
 
                            RADEON_GEM_DOMAIN_GTT,
219
 
                            0, 0);
220
 
   }
 
201
   radeon_cs_write_reloc(rmesa->radeon.cmdbuf.cs,
 
202
                         rmesa->ioctl.bo,
 
203
                         RADEON_GEM_DOMAIN_GTT,
 
204
                         0, 0);
221
205
#endif
222
206
 
223
207
   END_BATCH();
254
238
#if RADEON_OLD_PACKETS
255
239
   BEGIN_BATCH_NO_AUTOSTATE(2+ELTS_BUFSZ(align_min_nr)/4);
256
240
   OUT_BATCH_PACKET3_CLIP(RADEON_CP_PACKET3_3D_RNDR_GEN_INDX_PRIM, 0);
257
 
   if (!rmesa->radeon.radeonScreen->kernel_mm) {
258
 
     OUT_BATCH_RELOC(rmesa->ioctl.vertex_offset, rmesa->ioctl.bo, rmesa->ioctl.vertex_offset, RADEON_GEM_DOMAIN_GTT, 0, 0);
259
 
   } else {
260
 
     OUT_BATCH(rmesa->ioctl.vertex_offset);
261
 
   }
 
241
   OUT_BATCH(rmesa->ioctl.vertex_offset);
262
242
   OUT_BATCH(rmesa->ioctl.vertex_max);
263
243
   OUT_BATCH(vertex_format);
264
244
   OUT_BATCH(primitive |
343
323
   OUT_BATCH_PACKET3(RADEON_CP_PACKET3_3D_LOAD_VBPNTR, sz - 1);
344
324
   OUT_BATCH(nr);
345
325
 
346
 
   if (!rmesa->radeon.radeonScreen->kernel_mm) {
347
 
      for (i = 0; i + 1 < nr; i += 2) {
348
 
         OUT_BATCH((rmesa->radeon.tcl.aos[i].components << 0) |
349
 
                   (rmesa->radeon.tcl.aos[i].stride << 8) |
350
 
                   (rmesa->radeon.tcl.aos[i + 1].components << 16) |
351
 
                   (rmesa->radeon.tcl.aos[i + 1].stride << 24));
352
 
 
353
 
         voffset =  rmesa->radeon.tcl.aos[i + 0].offset +
354
 
            offset * 4 * rmesa->radeon.tcl.aos[i + 0].stride;
355
 
         OUT_BATCH_RELOC(voffset,
356
 
                         rmesa->radeon.tcl.aos[i].bo,
357
 
                         voffset,
358
 
                         RADEON_GEM_DOMAIN_GTT,
359
 
                         0, 0);
360
 
         voffset =  rmesa->radeon.tcl.aos[i + 1].offset +
361
 
            offset * 4 * rmesa->radeon.tcl.aos[i + 1].stride;
362
 
         OUT_BATCH_RELOC(voffset,
363
 
                         rmesa->radeon.tcl.aos[i+1].bo,
364
 
                         voffset,
365
 
                         RADEON_GEM_DOMAIN_GTT,
366
 
                         0, 0);
367
 
      }
368
 
 
369
 
      if (nr & 1) {
370
 
         OUT_BATCH((rmesa->radeon.tcl.aos[nr - 1].components << 0) |
371
 
                   (rmesa->radeon.tcl.aos[nr - 1].stride << 8));
372
 
         voffset =  rmesa->radeon.tcl.aos[nr - 1].offset +
373
 
            offset * 4 * rmesa->radeon.tcl.aos[nr - 1].stride;
374
 
         OUT_BATCH_RELOC(voffset,
375
 
                         rmesa->radeon.tcl.aos[nr - 1].bo,
376
 
                         voffset,
377
 
                         RADEON_GEM_DOMAIN_GTT,
378
 
                         0, 0);
379
 
      }
380
 
   } else {
 
326
   {
381
327
      for (i = 0; i + 1 < nr; i += 2) {
382
328
         OUT_BATCH((rmesa->radeon.tcl.aos[i].components << 0) |
383
329
                   (rmesa->radeon.tcl.aos[i].stride << 8) |
432
378
 */
433
379
#define RADEON_MAX_CLEARS       256
434
380
 
435
 
static void radeonKernelClear(struct gl_context *ctx, GLuint flags)
436
 
{
437
 
     r100ContextPtr rmesa = R100_CONTEXT(ctx);
438
 
   __DRIdrawable *dPriv = radeon_get_drawable(&rmesa->radeon);
439
 
   drm_radeon_sarea_t *sarea = rmesa->radeon.sarea;
440
 
   uint32_t clear;
441
 
   GLint ret, i;
442
 
   GLint cx, cy, cw, ch;
443
 
 
444
 
   radeonEmitState(&rmesa->radeon);
445
 
 
446
 
   LOCK_HARDWARE( &rmesa->radeon );
447
 
 
448
 
   /* compute region after locking: */
449
 
   cx = ctx->DrawBuffer->_Xmin;
450
 
   cy = ctx->DrawBuffer->_Ymin;
451
 
   cw = ctx->DrawBuffer->_Xmax - cx;
452
 
   ch = ctx->DrawBuffer->_Ymax - cy;
453
 
 
454
 
   /* Flip top to bottom */
455
 
   cx += dPriv->x;
456
 
   cy  = dPriv->y + dPriv->h - cy - ch;
457
 
 
458
 
   /* Throttle the number of clear ioctls we do.
459
 
    */
460
 
   while ( 1 ) {
461
 
      int ret;
462
 
      drm_radeon_getparam_t gp;
463
 
 
464
 
      gp.param = RADEON_PARAM_LAST_CLEAR;
465
 
      gp.value = (int *)&clear;
466
 
      ret = drmCommandWriteRead( rmesa->radeon.dri.fd,
467
 
                                 DRM_RADEON_GETPARAM, &gp, sizeof(gp) );
468
 
 
469
 
      if ( ret ) {
470
 
         fprintf( stderr, "%s: drm_radeon_getparam_t: %d\n", __FUNCTION__, ret );
471
 
         exit(1);
472
 
      }
473
 
 
474
 
      if ( sarea->last_clear - clear <= RADEON_MAX_CLEARS ) {
475
 
         break;
476
 
      }
477
 
 
478
 
      if ( rmesa->radeon.do_usleeps ) {
479
 
         UNLOCK_HARDWARE( &rmesa->radeon );
480
 
         DO_USLEEP( 1 );
481
 
         LOCK_HARDWARE( &rmesa->radeon );
482
 
      }
483
 
   }
484
 
 
485
 
   /* Send current state to the hardware */
486
 
   rcommonFlushCmdBufLocked( &rmesa->radeon, __FUNCTION__ );
487
 
 
488
 
   for ( i = 0 ; i < dPriv->numClipRects ; ) {
489
 
      GLint nr = MIN2( i + RADEON_NR_SAREA_CLIPRECTS, dPriv->numClipRects );
490
 
      drm_clip_rect_t *box = dPriv->pClipRects;
491
 
      drm_clip_rect_t *b = rmesa->radeon.sarea->boxes;
492
 
      drm_radeon_clear_t clear;
493
 
      drm_radeon_clear_rect_t depth_boxes[RADEON_NR_SAREA_CLIPRECTS];
494
 
      GLint n = 0;
495
 
 
496
 
      if (cw != dPriv->w || ch != dPriv->h) {
497
 
         /* clear subregion */
498
 
         for ( ; i < nr ; i++ ) {
499
 
            GLint x = box[i].x1;
500
 
            GLint y = box[i].y1;
501
 
            GLint w = box[i].x2 - x;
502
 
            GLint h = box[i].y2 - y;
503
 
 
504
 
            if ( x < cx ) w -= cx - x, x = cx;
505
 
            if ( y < cy ) h -= cy - y, y = cy;
506
 
            if ( x + w > cx + cw ) w = cx + cw - x;
507
 
            if ( y + h > cy + ch ) h = cy + ch - y;
508
 
            if ( w <= 0 ) continue;
509
 
            if ( h <= 0 ) continue;
510
 
 
511
 
            b->x1 = x;
512
 
            b->y1 = y;
513
 
            b->x2 = x + w;
514
 
            b->y2 = y + h;
515
 
            b++;
516
 
            n++;
517
 
         }
518
 
      } else {
519
 
         /* clear whole buffer */
520
 
         for ( ; i < nr ; i++ ) {
521
 
            *b++ = box[i];
522
 
            n++;
523
 
         }
524
 
      }
525
 
 
526
 
      rmesa->radeon.sarea->nbox = n;
527
 
 
528
 
      clear.flags       = flags;
529
 
      clear.clear_color = rmesa->radeon.state.color.clear;
530
 
      clear.clear_depth = rmesa->radeon.state.depth.clear;
531
 
      clear.color_mask  = rmesa->hw.msk.cmd[MSK_RB3D_PLANEMASK];
532
 
      clear.depth_mask  = rmesa->radeon.state.stencil.clear;
533
 
      clear.depth_boxes = depth_boxes;
534
 
 
535
 
      n--;
536
 
      b = rmesa->radeon.sarea->boxes;
537
 
      for ( ; n >= 0 ; n-- ) {
538
 
         depth_boxes[n].f[CLEAR_X1] = (float)b[n].x1;
539
 
         depth_boxes[n].f[CLEAR_Y1] = (float)b[n].y1;
540
 
         depth_boxes[n].f[CLEAR_X2] = (float)b[n].x2;
541
 
         depth_boxes[n].f[CLEAR_Y2] = (float)b[n].y2;
542
 
         depth_boxes[n].f[CLEAR_DEPTH] =
543
 
            (float)rmesa->radeon.state.depth.clear;
544
 
      }
545
 
 
546
 
      ret = drmCommandWrite( rmesa->radeon.dri.fd, DRM_RADEON_CLEAR,
547
 
                             &clear, sizeof(drm_radeon_clear_t));
548
 
 
549
 
      if ( ret ) {
550
 
         UNLOCK_HARDWARE( &rmesa->radeon );
551
 
         fprintf( stderr, "DRM_RADEON_CLEAR: return = %d\n", ret );
552
 
         exit( 1 );
553
 
      }
554
 
   }
555
 
   UNLOCK_HARDWARE( &rmesa->radeon );
556
 
}
557
 
 
558
381
static void radeonClear( struct gl_context *ctx, GLbitfield mask )
559
382
{
560
383
   r100ContextPtr rmesa = R100_CONTEXT(ctx);
561
 
   __DRIdrawable *dPriv = radeon_get_drawable(&rmesa->radeon);
562
384
   GLuint flags = 0;
563
 
   GLuint color_mask = 0;
564
385
   GLuint orig_mask = mask;
565
386
 
566
387
   if (mask & (BUFFER_BIT_FRONT_LEFT | BUFFER_BIT_FRONT_RIGHT)) {
571
392
      fprintf( stderr, "radeonClear\n");
572
393
   }
573
394
 
574
 
   {
575
 
      LOCK_HARDWARE( &rmesa->radeon );
576
 
      UNLOCK_HARDWARE( &rmesa->radeon );
577
 
      if ( dPriv->numClipRects == 0 )
578
 
         return;
579
 
   }
580
 
 
581
395
   radeon_firevertices(&rmesa->radeon);
582
396
 
583
397
   if ( mask & BUFFER_BIT_FRONT_LEFT ) {
584
398
      flags |= RADEON_FRONT;
585
 
      color_mask = rmesa->hw.msk.cmd[MSK_RB3D_PLANEMASK];
586
399
      mask &= ~BUFFER_BIT_FRONT_LEFT;
587
400
   }
588
401
 
589
402
   if ( mask & BUFFER_BIT_BACK_LEFT ) {
590
403
      flags |= RADEON_BACK;
591
 
      color_mask = rmesa->hw.msk.cmd[MSK_RB3D_PLANEMASK];
592
404
      mask &= ~BUFFER_BIT_BACK_LEFT;
593
405
   }
594
406
 
621
433
      }
622
434
   }
623
435
 
624
 
   if (rmesa->radeon.radeonScreen->kernel_mm)
625
 
     radeonUserClear(ctx, orig_mask);
626
 
   else {
627
 
      radeonKernelClear(ctx, flags);
628
 
      rmesa->radeon.hw.all_dirty = GL_TRUE;
629
 
   }
 
436
   radeonUserClear(ctx, orig_mask);
630
437
}
631
438
 
632
439
void radeonInitIoctlFuncs( struct gl_context *ctx )