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

« back to all changes in this revision

Viewing changes to src/gallium/state_trackers/dri/drm/dri2.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:
44
44
 * DRI2 flush extension.
45
45
 */
46
46
static void
47
 
dri2_flush_drawable(__DRIdrawable *draw)
 
47
dri2_flush_drawable(__DRIdrawable *dPriv)
48
48
{
 
49
   struct dri_context *ctx = dri_get_current(dPriv->driScreenPriv);
 
50
   struct dri_drawable *drawable = dri_drawable(dPriv);
 
51
 
 
52
   struct pipe_resource *ptex = drawable->textures[ST_ATTACHMENT_BACK_LEFT];
 
53
 
 
54
   if (ctx) {
 
55
      if (ptex && ctx->pp && drawable->textures[ST_ATTACHMENT_DEPTH_STENCIL])
 
56
         pp_run(ctx->pp, ptex, ptex, drawable->textures[ST_ATTACHMENT_DEPTH_STENCIL]);
 
57
 
 
58
      ctx->st->flush(ctx->st, 0, NULL);
 
59
   }
49
60
}
50
61
 
51
62
static void
52
63
dri2_invalidate_drawable(__DRIdrawable *dPriv)
53
64
{
54
65
   struct dri_drawable *drawable = dri_drawable(dPriv);
55
 
   struct dri_context *ctx = drawable->context;
56
66
 
57
67
   dri2InvalidateDrawable(dPriv);
58
 
   drawable->dPriv->lastStamp = *drawable->dPriv->pStamp;
 
68
   drawable->dPriv->lastStamp = drawable->dPriv->dri2.stamp;
59
69
 
60
 
   if (ctx)
61
 
      ctx->st->notify_invalid_framebuffer(ctx->st, &drawable->base);
 
70
   p_atomic_inc(&drawable->base.stamp);
62
71
}
63
72
 
64
73
static const __DRI2flushExtension dri2FlushExtension = {
95
104
   for (i = 0; i < *count; i++) {
96
105
      enum pipe_format format;
97
106
      unsigned bind;
98
 
      int att, bpp;
 
107
      int att, depth;
99
108
 
100
109
      dri_drawable_get_format(drawable, statts[i], &format, &bind);
101
110
      if (format == PIPE_FORMAT_NONE)
125
134
         break;
126
135
      }
127
136
 
128
 
      bpp = util_format_get_blocksizebits(format);
 
137
      /*
 
138
       * In this switch statement we must support all formats that
 
139
       * may occur as the stvis->color_format or
 
140
       * stvis->depth_stencil_format.
 
141
       */
 
142
      switch(format) {
 
143
      case PIPE_FORMAT_B8G8R8A8_UNORM:
 
144
         depth = 32;
 
145
         break;
 
146
      case PIPE_FORMAT_B8G8R8X8_UNORM:
 
147
         depth = 24;
 
148
         break;
 
149
      case PIPE_FORMAT_B5G6R5_UNORM:
 
150
         depth = 16;
 
151
         break;
 
152
      case PIPE_FORMAT_Z16_UNORM:
 
153
         att = __DRI_BUFFER_DEPTH;
 
154
         depth = 16;
 
155
         break;
 
156
      case PIPE_FORMAT_Z24X8_UNORM:
 
157
      case PIPE_FORMAT_X8Z24_UNORM:
 
158
         att = __DRI_BUFFER_DEPTH;
 
159
         depth = 24;
 
160
         break;
 
161
      case PIPE_FORMAT_Z24_UNORM_S8_UINT:
 
162
      case PIPE_FORMAT_S8_UINT_Z24_UNORM:
 
163
         depth = 32;
 
164
         break;
 
165
      case PIPE_FORMAT_Z32_UNORM:
 
166
         att = __DRI_BUFFER_DEPTH;
 
167
         depth = 32;
 
168
         break;
 
169
      default:
 
170
         depth = util_format_get_blocksizebits(format);
 
171
         assert(!"Unexpected format in dri2_drawable_get_buffers()");
 
172
      }
129
173
 
130
174
      if (att >= 0) {
131
175
         attachments[num_attachments++] = att;
132
176
         if (with_format) {
133
 
            attachments[num_attachments++] = bpp;
 
177
            attachments[num_attachments++] = depth;
134
178
         }
135
179
      }
136
180
   }
149
193
            &num_buffers, dri_drawable->loaderPrivate);
150
194
   }
151
195
 
152
 
   if (buffers) {
153
 
      /* set one cliprect to cover the whole dri_drawable */
154
 
      dri_drawable->x = 0;
155
 
      dri_drawable->y = 0;
156
 
      dri_drawable->backX = 0;
157
 
      dri_drawable->backY = 0;
158
 
      dri_drawable->numClipRects = 1;
159
 
      dri_drawable->pClipRects[0].x1 = 0;
160
 
      dri_drawable->pClipRects[0].y1 = 0;
161
 
      dri_drawable->pClipRects[0].x2 = dri_drawable->w;
162
 
      dri_drawable->pClipRects[0].y2 = dri_drawable->h;
163
 
      dri_drawable->numBackClipRects = 1;
164
 
      dri_drawable->pBackClipRects[0].x1 = 0;
165
 
      dri_drawable->pBackClipRects[0].y1 = 0;
166
 
      dri_drawable->pBackClipRects[0].x2 = dri_drawable->w;
167
 
      dri_drawable->pBackClipRects[0].y2 = dri_drawable->h;
168
 
 
 
196
   if (buffers)
169
197
      *count = num_buffers;
170
 
   }
171
198
 
172
199
   return buffers;
173
200
}
268
295
   struct dri_screen *screen = dri_screen(sPriv);
269
296
   struct dri2_buffer *buffer;
270
297
   struct pipe_resource templ;
271
 
   enum st_attachment_type statt;
272
298
   enum pipe_format pf;
273
299
   unsigned bind = 0;
274
300
   struct winsys_handle whandle;
276
302
   switch (attachment) {
277
303
      case __DRI_BUFFER_FRONT_LEFT:
278
304
      case __DRI_BUFFER_FAKE_FRONT_LEFT:
279
 
         statt = ST_ATTACHMENT_FRONT_LEFT;
280
305
         bind = PIPE_BIND_RENDER_TARGET | PIPE_BIND_SAMPLER_VIEW;
281
306
         break;
282
307
      case __DRI_BUFFER_BACK_LEFT:
283
 
         statt = ST_ATTACHMENT_BACK_LEFT;
284
308
         bind = PIPE_BIND_RENDER_TARGET | PIPE_BIND_SAMPLER_VIEW;
285
309
         break;
286
310
      case __DRI_BUFFER_DEPTH:
287
311
      case __DRI_BUFFER_DEPTH_STENCIL:
288
312
      case __DRI_BUFFER_STENCIL:
289
 
            statt = ST_ATTACHMENT_DEPTH_STENCIL;
290
313
            bind = PIPE_BIND_DEPTH_STENCIL; /* XXX sampler? */
291
314
         break;
292
 
      default:
293
 
         statt = ST_ATTACHMENT_INVALID;
294
 
         break;
295
315
   }
296
316
 
297
317
   switch (format) {
321
341
 
322
342
   buffer->resource =
323
343
      screen->base.screen->resource_create(screen->base.screen, &templ);
324
 
   if (!buffer->resource)
 
344
   if (!buffer->resource) {
 
345
      FREE(buffer);
325
346
      return NULL;
 
347
   }
326
348
 
327
349
   memset(&whandle, 0, sizeof(whandle));
328
350
   whandle.type = DRM_API_HANDLE_TYPE_SHARED;
378
400
   }
379
401
}
380
402
 
 
403
static void
 
404
dri2_update_tex_buffer(struct dri_drawable *drawable,
 
405
                       struct dri_context *ctx,
 
406
                       struct pipe_resource *res)
 
407
{
 
408
   /* no-op */
 
409
}
 
410
 
381
411
static __DRIimage *
382
412
dri2_lookup_egl_image(struct dri_screen *screen, void *handle)
383
413
{
417
447
   case __DRI_IMAGE_FORMAT_ARGB8888:
418
448
      pf = PIPE_FORMAT_B8G8R8A8_UNORM;
419
449
      break;
 
450
   case __DRI_IMAGE_FORMAT_ABGR8888:
 
451
      pf = PIPE_FORMAT_R8G8B8A8_UNORM;
 
452
      break;
420
453
   default:
421
454
      pf = PIPE_FORMAT_NONE;
422
455
      break;
501
534
   case __DRI_IMAGE_FORMAT_ARGB8888:
502
535
      pf = PIPE_FORMAT_B8G8R8A8_UNORM;
503
536
      break;
 
537
   case __DRI_IMAGE_FORMAT_ABGR8888:
 
538
      pf = PIPE_FORMAT_R8G8B8A8_UNORM;
 
539
      break;
504
540
   default:
505
541
      pf = PIPE_FORMAT_NONE;
506
542
      break;
604
640
 */
605
641
 
606
642
static const __DRIextension *dri_screen_extensions[] = {
607
 
   &driReadDrawableExtension,
608
 
   &driCopySubBufferExtension.base,
609
 
   &driSwapControlExtension.base,
610
 
   &driMediaStreamCounterExtension.base,
611
 
   &driTexBufferExtension.base,
612
 
   &dri2FlushExtension.base,
613
 
   &dri2ImageExtension.base,
614
 
   &dri2ConfigQueryExtension.base,
 
643
   &driTexBufferExtension.base,
 
644
   &dri2FlushExtension.base,
 
645
   &dri2ImageExtension.base,
 
646
   &dri2ConfigQueryExtension.base,
 
647
   NULL
 
648
};
 
649
 
 
650
static const __DRIextension *dri_screen_extensions_throttle[] = {
 
651
   &driTexBufferExtension.base,
 
652
   &dri2FlushExtension.base,
 
653
   &dri2ImageExtension.base,
 
654
   &dri2ConfigQueryExtension.base,
 
655
   &dri2ThrottleExtension.base,
615
656
   NULL
616
657
};
617
658
 
626
667
   const __DRIconfig **configs;
627
668
   struct dri_screen *screen;
628
669
   struct pipe_screen *pscreen;
 
670
   const struct drm_conf_ret *throttle_ret = NULL;
629
671
 
630
672
   screen = CALLOC_STRUCT(dri_screen);
631
673
   if (!screen)
634
676
   screen->sPriv = sPriv;
635
677
   screen->fd = sPriv->fd;
636
678
 
637
 
   sPriv->private = (void *)screen;
638
 
   sPriv->extensions = dri_screen_extensions;
 
679
   sPriv->driverPrivate = (void *)screen;
639
680
 
640
681
   pscreen = driver_descriptor.create_screen(screen->fd);
 
682
   if (driver_descriptor.configuration)
 
683
      throttle_ret = driver_descriptor.configuration(DRM_CONF_THROTTLE);
 
684
 
 
685
   if (throttle_ret && throttle_ret->val.val_int != -1) {
 
686
      sPriv->extensions = dri_screen_extensions_throttle;
 
687
      screen->default_throttle_frames = throttle_ret->val.val_int;
 
688
   } else
 
689
      sPriv->extensions = dri_screen_extensions;
 
690
 
641
691
   /* dri_init_screen_helper checks pscreen for us */
642
692
 
643
693
   configs = dri_init_screen_helper(screen, pscreen, 32);
664
714
}
665
715
 
666
716
static boolean
667
 
dri2_create_context(gl_api api, const struct gl_config * visual,
668
 
                    __DRIcontext * cPriv, void *sharedContextPrivate)
669
 
{
670
 
   struct dri_context *ctx = NULL;
671
 
 
672
 
   if (!dri_create_context(api, visual, cPriv, sharedContextPrivate))
673
 
      return FALSE;
674
 
 
675
 
   ctx = cPriv->driverPrivate;
676
 
 
677
 
   return TRUE;
678
 
}
679
 
 
680
 
static boolean
681
717
dri2_create_buffer(__DRIscreen * sPriv,
682
718
                   __DRIdrawable * dPriv,
683
719
                   const struct gl_config * visual, boolean isPixmap)
691
727
 
692
728
   drawable->allocate_textures = dri2_allocate_textures;
693
729
   drawable->flush_frontbuffer = dri2_flush_frontbuffer;
 
730
   drawable->update_tex_buffer = dri2_update_tex_buffer;
694
731
 
695
732
   return TRUE;
696
733
}
701
738
 * DRI versions differ in their implementation of init_screen and swap_buffers.
702
739
 */
703
740
const struct __DriverAPIRec driDriverAPI = {
704
 
   .InitScreen = NULL,
705
 
   .InitScreen2 = dri2_init_screen,
 
741
   .InitScreen = dri2_init_screen,
706
742
   .DestroyScreen = dri_destroy_screen,
707
 
   .CreateContext = dri2_create_context,
 
743
   .CreateContext = dri_create_context,
708
744
   .DestroyContext = dri_destroy_context,
709
745
   .CreateBuffer = dri2_create_buffer,
710
746
   .DestroyBuffer = dri_destroy_buffer,
711
747
   .MakeCurrent = dri_make_current,
712
748
   .UnbindContext = dri_unbind_context,
713
749
 
714
 
   .GetSwapInfo = NULL,
715
 
   .GetDrawableMSC = NULL,
716
 
   .WaitForMSC = NULL,
717
 
 
718
 
   .SwapBuffers = NULL,
719
 
   .CopySubBuffer = NULL,
720
 
 
721
750
   .AllocateBuffer = dri2_allocate_buffer,
722
751
   .ReleaseBuffer  = dri2_release_buffer,
723
752
};
725
754
/* This is the table of extensions that the loader will dlsym() for. */
726
755
PUBLIC const __DRIextension *__driDriverExtensions[] = {
727
756
    &driCoreExtension.base,
728
 
    &driLegacyExtension.base,
729
757
    &driDRI2Extension.base,
730
758
    NULL
731
759
};