dri2.c 56.8 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
/*
 * Mesa 3-D graphics library
 *
 * Copyright 2009, VMware, Inc.
 * All Rights Reserved.
 * Copyright (C) 2010 LunarG Inc.
 *
 * Permission is hereby granted, free of charge, to any person obtaining a
 * copy of this software and associated documentation files (the "Software"),
 * to deal in the Software without restriction, including without limitation
 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
 * and/or sell copies of the Software, and to permit persons to whom the
 * Software is furnished to do so, subject to the following conditions:
 *
 * The above copyright notice and this permission notice shall be included
 * in all copies or substantial portions of the Software.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
21 22 23 24
 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
 * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
 * OTHER DEALINGS IN THE SOFTWARE.
25 26
 *
 * Authors:
27 28
 *    Keith Whitwell <keithw@vmware.com> Jakob Bornecrantz
 *    <wallbraker@gmail.com> Chia-I Wu <olv@lunarg.com>
29 30
 */

31
#include <xf86drm.h>
32
#include <dlfcn.h>
33
#include "GL/mesa_glinterop.h"
34 35 36 37
#include "util/u_memory.h"
#include "util/u_inlines.h"
#include "util/u_format.h"
#include "util/u_debug.h"
38
#include "state_tracker/drm_driver.h"
39 40 41
#include "state_tracker/st_cb_bufferobjects.h"
#include "state_tracker/st_cb_fbo.h"
#include "state_tracker/st_cb_texture.h"
42 43
#include "state_tracker/st_texture.h"
#include "state_tracker/st_context.h"
44
#include "pipe-loader/pipe_loader.h"
45
#include "main/bufferobj.h"
46
#include "main/texobj.h"
47 48 49 50

#include "dri_screen.h"
#include "dri_context.h"
#include "dri_drawable.h"
51
#include "dri_query_renderer.h"
52
#include "dri2_buffer.h"
Vinson Lee's avatar
Vinson Lee committed
53

54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84
static int convert_fourcc(int format, int *dri_components_p)
{
   int dri_components;
   switch(format) {
   case __DRI_IMAGE_FOURCC_RGB565:
      format = __DRI_IMAGE_FORMAT_RGB565;
      dri_components = __DRI_IMAGE_COMPONENTS_RGB;
      break;
   case __DRI_IMAGE_FOURCC_ARGB8888:
      format = __DRI_IMAGE_FORMAT_ARGB8888;
      dri_components = __DRI_IMAGE_COMPONENTS_RGBA;
      break;
   case __DRI_IMAGE_FOURCC_XRGB8888:
      format = __DRI_IMAGE_FORMAT_XRGB8888;
      dri_components = __DRI_IMAGE_COMPONENTS_RGB;
      break;
   case __DRI_IMAGE_FOURCC_ABGR8888:
      format = __DRI_IMAGE_FORMAT_ABGR8888;
      dri_components = __DRI_IMAGE_COMPONENTS_RGBA;
      break;
   case __DRI_IMAGE_FOURCC_XBGR8888:
      format = __DRI_IMAGE_FORMAT_XBGR8888;
      dri_components = __DRI_IMAGE_COMPONENTS_RGB;
      break;
   default:
      return -1;
   }
   *dri_components_p = dri_components;
   return format;
}

85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108
static int convert_to_fourcc(int format)
{
   switch(format) {
   case __DRI_IMAGE_FORMAT_RGB565:
      format = __DRI_IMAGE_FOURCC_RGB565;
      break;
   case __DRI_IMAGE_FORMAT_ARGB8888:
      format = __DRI_IMAGE_FOURCC_ARGB8888;
      break;
   case __DRI_IMAGE_FORMAT_XRGB8888:
      format = __DRI_IMAGE_FOURCC_XRGB8888;
      break;
   case __DRI_IMAGE_FORMAT_ABGR8888:
      format = __DRI_IMAGE_FOURCC_ABGR8888;
      break;
   case __DRI_IMAGE_FORMAT_XBGR8888:
      format = __DRI_IMAGE_FOURCC_XBGR8888;
      break;
   default:
      return -1;
   }
   return format;
}

109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133
static enum pipe_format dri2_format_to_pipe_format (int format)
{
   enum pipe_format pf;

   switch (format) {
   case __DRI_IMAGE_FORMAT_RGB565:
      pf = PIPE_FORMAT_B5G6R5_UNORM;
      break;
   case __DRI_IMAGE_FORMAT_XRGB8888:
      pf = PIPE_FORMAT_BGRX8888_UNORM;
      break;
   case __DRI_IMAGE_FORMAT_ARGB8888:
      pf = PIPE_FORMAT_BGRA8888_UNORM;
      break;
   case __DRI_IMAGE_FORMAT_ABGR8888:
      pf = PIPE_FORMAT_RGBA8888_UNORM;
      break;
   default:
      pf = PIPE_FORMAT_NONE;
      break;
   }

   return pf;
}

134 135 136 137
/**
 * DRI2 flush extension.
 */
static void
138
dri2_flush_drawable(__DRIdrawable *dPriv)
139
{
140
   dri_flush(dPriv->driContextPriv, dPriv, __DRI2_FLUSH_DRAWABLE, -1);
141 142 143 144 145 146 147 148
}

static void
dri2_invalidate_drawable(__DRIdrawable *dPriv)
{
   struct dri_drawable *drawable = dri_drawable(dPriv);

   dri2InvalidateDrawable(dPriv);
149
   drawable->dPriv->lastStamp = drawable->dPriv->dri2.stamp;
150

151
   p_atomic_inc(&drawable->base.stamp);
152 153 154
}

static const __DRI2flushExtension dri2FlushExtension = {
155 156 157 158 159
    .base = { __DRI2_FLUSH, 4 },

    .flush                = dri2_flush_drawable,
    .invalidate           = dri2_invalidate_drawable,
    .flush_with_flags     = dri_flush,
160 161 162 163 164 165
};

/**
 * Retrieve __DRIbuffer from the DRI loader.
 */
static __DRIbuffer *
166
dri2_drawable_get_buffers(struct dri_drawable *drawable,
167
                          const enum st_attachment_type *atts,
168
                          unsigned *count)
169 170
{
   __DRIdrawable *dri_drawable = drawable->dPriv;
171
   const __DRIdri2LoaderExtension *loader = drawable->sPriv->dri2.loader;
172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188
   boolean with_format;
   __DRIbuffer *buffers;
   int num_buffers;
   unsigned attachments[10];
   unsigned num_attachments, i;

   assert(loader);
   with_format = dri_with_format(drawable->sPriv);

   num_attachments = 0;

   /* for Xserver 1.6.0 (DRI2 version 1) we always need to ask for the front */
   if (!with_format)
      attachments[num_attachments++] = __DRI_BUFFER_FRONT_LEFT;

   for (i = 0; i < *count; i++) {
      enum pipe_format format;
189
      unsigned bind;
190
      int att, depth;
191

192
      dri_drawable_get_format(drawable, atts[i], &format, &bind);
193 194 195
      if (format == PIPE_FORMAT_NONE)
         continue;

196
      switch (atts[i]) {
197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212
      case ST_ATTACHMENT_FRONT_LEFT:
         /* already added */
         if (!with_format)
            continue;
         att = __DRI_BUFFER_FRONT_LEFT;
         break;
      case ST_ATTACHMENT_BACK_LEFT:
         att = __DRI_BUFFER_BACK_LEFT;
         break;
      case ST_ATTACHMENT_FRONT_RIGHT:
         att = __DRI_BUFFER_FRONT_RIGHT;
         break;
      case ST_ATTACHMENT_BACK_RIGHT:
         att = __DRI_BUFFER_BACK_RIGHT;
         break;
      default:
213
         continue;
214 215
      }

216 217
      /*
       * In this switch statement we must support all formats that
218
       * may occur as the stvis->color_format.
219 220
       */
      switch(format) {
221
      case PIPE_FORMAT_BGRA8888_UNORM:
222 223
	 depth = 32;
	 break;
224
      case PIPE_FORMAT_BGRX8888_UNORM:
225 226 227 228 229 230 231 232 233
	 depth = 24;
	 break;
      case PIPE_FORMAT_B5G6R5_UNORM:
	 depth = 16;
	 break;
      default:
	 depth = util_format_get_blocksizebits(format);
	 assert(!"Unexpected format in dri2_drawable_get_buffers()");
      }
234

235 236 237
      attachments[num_attachments++] = att;
      if (with_format) {
         attachments[num_attachments++] = depth;
238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254
      }
   }

   if (with_format) {
      num_attachments /= 2;
      buffers = loader->getBuffersWithFormat(dri_drawable,
            &dri_drawable->w, &dri_drawable->h,
            attachments, num_attachments,
            &num_buffers, dri_drawable->loaderPrivate);
   }
   else {
      buffers = loader->getBuffers(dri_drawable,
            &dri_drawable->w, &dri_drawable->h,
            attachments, num_attachments,
            &num_buffers, dri_drawable->loaderPrivate);
   }

255
   if (buffers)
256 257 258 259 260
      *count = num_buffers;

   return buffers;
}

261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293
static bool
dri_image_drawable_get_buffers(struct dri_drawable *drawable,
                               struct __DRIimageList *images,
                               const enum st_attachment_type *statts,
                               unsigned statts_count)
{
   __DRIdrawable *dPriv = drawable->dPriv;
   __DRIscreen *sPriv = drawable->sPriv;
   unsigned int image_format = __DRI_IMAGE_FORMAT_NONE;
   enum pipe_format pf;
   uint32_t buffer_mask = 0;
   unsigned i, bind;

   for (i = 0; i < statts_count; i++) {
      dri_drawable_get_format(drawable, statts[i], &pf, &bind);
      if (pf == PIPE_FORMAT_NONE)
         continue;

      switch (statts[i]) {
      case ST_ATTACHMENT_FRONT_LEFT:
         buffer_mask |= __DRI_IMAGE_BUFFER_FRONT;
         break;
      case ST_ATTACHMENT_BACK_LEFT:
         buffer_mask |= __DRI_IMAGE_BUFFER_BACK;
         break;
      default:
         continue;
      }

      switch (pf) {
      case PIPE_FORMAT_B5G6R5_UNORM:
         image_format = __DRI_IMAGE_FORMAT_RGB565;
         break;
294
      case PIPE_FORMAT_BGRX8888_UNORM:
295 296
         image_format = __DRI_IMAGE_FORMAT_XRGB8888;
         break;
297
      case PIPE_FORMAT_BGRA8888_UNORM:
298 299
         image_format = __DRI_IMAGE_FORMAT_ARGB8888;
         break;
300
      case PIPE_FORMAT_RGBA8888_UNORM:
301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346
         image_format = __DRI_IMAGE_FORMAT_ABGR8888;
         break;
      default:
         image_format = __DRI_IMAGE_FORMAT_NONE;
         break;
      }
   }

   return (*sPriv->image.loader->getBuffers) (dPriv, image_format,
                                       (uint32_t *) &drawable->base.stamp,
                                       dPriv->loaderPrivate, buffer_mask,
                                       images);
}

static __DRIbuffer *
dri2_allocate_buffer(__DRIscreen *sPriv,
                     unsigned attachment, unsigned format,
                     int width, int height)
{
   struct dri_screen *screen = dri_screen(sPriv);
   struct dri2_buffer *buffer;
   struct pipe_resource templ;
   enum pipe_format pf;
   unsigned bind = 0;
   struct winsys_handle whandle;

   switch (attachment) {
      case __DRI_BUFFER_FRONT_LEFT:
      case __DRI_BUFFER_FAKE_FRONT_LEFT:
         bind = PIPE_BIND_RENDER_TARGET | PIPE_BIND_SAMPLER_VIEW;
         break;
      case __DRI_BUFFER_BACK_LEFT:
         bind = PIPE_BIND_RENDER_TARGET | PIPE_BIND_SAMPLER_VIEW;
         break;
      case __DRI_BUFFER_DEPTH:
      case __DRI_BUFFER_DEPTH_STENCIL:
      case __DRI_BUFFER_STENCIL:
            bind = PIPE_BIND_DEPTH_STENCIL; /* XXX sampler? */
         break;
   }

   /* because we get the handle and stride */
   bind |= PIPE_BIND_SHARED;

   switch (format) {
      case 32:
347
         pf = PIPE_FORMAT_BGRA8888_UNORM;
348 349
         break;
      case 24:
350
         pf = PIPE_FORMAT_BGRX8888_UNORM;
351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380
         break;
      case 16:
         pf = PIPE_FORMAT_Z16_UNORM;
         break;
      default:
         return NULL;
   }

   buffer = CALLOC_STRUCT(dri2_buffer);
   if (!buffer)
      return NULL;

   memset(&templ, 0, sizeof(templ));
   templ.bind = bind;
   templ.format = pf;
   templ.target = PIPE_TEXTURE_2D;
   templ.last_level = 0;
   templ.width0 = width;
   templ.height0 = height;
   templ.depth0 = 1;
   templ.array_size = 1;

   buffer->resource =
      screen->base.screen->resource_create(screen->base.screen, &templ);
   if (!buffer->resource) {
      FREE(buffer);
      return NULL;
   }

   memset(&whandle, 0, sizeof(whandle));
381 382 383 384 385
   if (screen->can_share_buffer)
      whandle.type = DRM_API_HANDLE_TYPE_SHARED;
   else
      whandle.type = DRM_API_HANDLE_TYPE_KMS;

386
   screen->base.screen->resource_get_handle(screen->base.screen,
387 388
         buffer->resource, &whandle,
         PIPE_HANDLE_USAGE_EXPLICIT_FLUSH | PIPE_HANDLE_USAGE_READ);
389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408

   buffer->base.attachment = attachment;
   buffer->base.name = whandle.handle;
   buffer->base.cpp = util_format_get_blocksize(pf);
   buffer->base.pitch = whandle.stride;

   return &buffer->base;
}

static void
dri2_release_buffer(__DRIscreen *sPriv, __DRIbuffer *bPriv)
{
   struct dri2_buffer *buffer = dri2_buffer(bPriv);

   pipe_resource_reference(&buffer->resource, NULL);
   FREE(buffer);
}

/*
 * Backend functions for st_framebuffer interface.
409
 */
410

411
static void
412 413 414 415
dri2_allocate_textures(struct dri_context *ctx,
                       struct dri_drawable *drawable,
                       const enum st_attachment_type *statts,
                       unsigned statts_count)
416
{
417
   __DRIscreen *sPriv = drawable->sPriv;
418
   __DRIdrawable *dri_drawable = drawable->dPriv;
419
   struct dri_screen *screen = dri_screen(sPriv);
420
   struct pipe_resource templ;
421
   boolean alloc_depthstencil = FALSE;
422
   unsigned i, j, bind;
423 424 425 426
   const __DRIimageLoaderExtension *image = sPriv->image.loader;
   /* Image specific variables */
   struct __DRIimageList images;
   /* Dri2 specific variables */
427
   __DRIbuffer *buffers = NULL;
428 429
   struct winsys_handle whandle;
   unsigned num_buffers = statts_count;
430

431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447
   /* First get the buffers from the loader */
   if (image) {
      if (!dri_image_drawable_get_buffers(drawable, &images,
                                          statts, statts_count))
         return;
   }
   else {
      buffers = dri2_drawable_get_buffers(drawable, statts, &num_buffers);
      if (!buffers || (drawable->old_num == num_buffers &&
                       drawable->old_w == dri_drawable->w &&
                       drawable->old_h == dri_drawable->h &&
                       memcmp(drawable->old, buffers,
                              sizeof(__DRIbuffer) * num_buffers) == 0))
         return;
   }

   /* Second clean useless resources*/
448

449
   /* See if we need a depth-stencil buffer. */
450 451
   for (i = 0; i < statts_count; i++) {
      if (statts[i] == ST_ATTACHMENT_DEPTH_STENCIL) {
452 453 454 455 456 457 458 459 460 461 462
         alloc_depthstencil = TRUE;
         break;
      }
   }

   /* Delete the resources we won't need. */
   for (i = 0; i < ST_ATTACHMENT_COUNT; i++) {
      /* Don't delete the depth-stencil buffer, we can reuse it. */
      if (i == ST_ATTACHMENT_DEPTH_STENCIL && alloc_depthstencil)
         continue;

463 464 465 466 467 468 469 470
      /* Flush the texture before unreferencing, so that other clients can
       * see what the driver has rendered.
       */
      if (i != ST_ATTACHMENT_DEPTH_STENCIL && drawable->textures[i]) {
         struct pipe_context *pipe = ctx->st->pipe;
         pipe->flush_resource(pipe, drawable->textures[i]);
      }

471
      pipe_resource_reference(&drawable->textures[i], NULL);
472 473 474 475 476 477 478 479
   }

   if (drawable->stvis.samples > 1) {
      for (i = 0; i < ST_ATTACHMENT_COUNT; i++) {
         boolean del = TRUE;

         /* Don't delete MSAA resources for the attachments which are enabled,
          * we can reuse them. */
480 481
         for (j = 0; j < statts_count; j++) {
            if (i == statts[j]) {
482 483 484 485 486 487 488 489 490 491
               del = FALSE;
               break;
            }
         }

         if (del) {
            pipe_resource_reference(&drawable->msaa_textures[i], NULL);
         }
      }
   }
492

493 494
   /* Third use the buffers retrieved to fill the drawable info */

495
   memset(&templ, 0, sizeof(templ));
496
   templ.target = screen->target;
497 498
   templ.last_level = 0;
   templ.depth0 = 1;
499
   templ.array_size = 1;
500

501 502 503 504 505
   if (image) {
      if (images.image_mask & __DRI_IMAGE_BUFFER_FRONT) {
         struct pipe_resource **buf =
            &drawable->textures[ST_ATTACHMENT_FRONT_LEFT];
         struct pipe_resource *texture = images.front->texture;
506

507 508
         dri_drawable->w = texture->width0;
         dri_drawable->h = texture->height0;
509

510
         pipe_resource_reference(buf, texture);
511 512
      }

513 514 515 516
      if (images.image_mask & __DRI_IMAGE_BUFFER_BACK) {
         struct pipe_resource **buf =
            &drawable->textures[ST_ATTACHMENT_BACK_LEFT];
         struct pipe_resource *texture = images.back->texture;
517

518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557
         dri_drawable->w = texture->width0;
         dri_drawable->h = texture->height0;

         pipe_resource_reference(buf, texture);
      }

      /* Note: if there is both a back and a front buffer,
       * then they have the same size.
       */
      templ.width0 = dri_drawable->w;
      templ.height0 = dri_drawable->h;
   }
   else {
      memset(&whandle, 0, sizeof(whandle));

      /* Process DRI-provided buffers and get pipe_resources. */
      for (i = 0; i < num_buffers; i++) {
         __DRIbuffer *buf = &buffers[i];
         enum st_attachment_type statt;
         enum pipe_format format;

         switch (buf->attachment) {
         case __DRI_BUFFER_FRONT_LEFT:
            if (!screen->auto_fake_front) {
               continue; /* invalid attachment */
            }
            /* fallthrough */
         case __DRI_BUFFER_FAKE_FRONT_LEFT:
            statt = ST_ATTACHMENT_FRONT_LEFT;
            break;
         case __DRI_BUFFER_BACK_LEFT:
            statt = ST_ATTACHMENT_BACK_LEFT;
            break;
         default:
            continue; /* invalid attachment */
         }

         dri_drawable_get_format(drawable, statt, &format, &bind);
         if (format == PIPE_FORMAT_NONE)
            continue;
558

559 560 561 562 563 564 565 566
         /* dri2_drawable_get_buffers has already filled dri_drawable->w
          * and dri_drawable->h */
         templ.width0 = dri_drawable->w;
         templ.height0 = dri_drawable->h;
         templ.format = format;
         templ.bind = bind;
         whandle.handle = buf->name;
         whandle.stride = buf->pitch;
567
         whandle.offset = 0;
568 569 570 571
         if (screen->can_share_buffer)
            whandle.type = DRM_API_HANDLE_TYPE_SHARED;
         else
            whandle.type = DRM_API_HANDLE_TYPE_KMS;
572 573
         drawable->textures[statt] =
            screen->base.screen->resource_from_handle(screen->base.screen,
574 575
                  &templ, &whandle,
                  PIPE_HANDLE_USAGE_EXPLICIT_FLUSH | PIPE_HANDLE_USAGE_READ);
576 577
         assert(drawable->textures[statt]);
      }
578 579 580 581
   }

   /* Allocate private MSAA colorbuffers. */
   if (drawable->stvis.samples > 1) {
582 583
      for (i = 0; i < statts_count; i++) {
         enum st_attachment_type statt = statts[i];
584

585
         if (statt == ST_ATTACHMENT_DEPTH_STENCIL)
586 587
            continue;

588 589
         if (drawable->textures[statt]) {
            templ.format = drawable->textures[statt]->format;
590
            templ.bind = drawable->textures[statt]->bind & ~PIPE_BIND_SCANOUT;
591 592
            templ.nr_samples = drawable->stvis.samples;

593 594 595
            /* Try to reuse the resource.
             * (the other resource parameters should be constant)
             */
596 597 598
            if (!drawable->msaa_textures[statt] ||
                drawable->msaa_textures[statt]->width0 != templ.width0 ||
                drawable->msaa_textures[statt]->height0 != templ.height0) {
599
               /* Allocate a new one. */
600
               pipe_resource_reference(&drawable->msaa_textures[statt], NULL);
601

602
               drawable->msaa_textures[statt] =
603 604
                  screen->base.screen->resource_create(screen->base.screen,
                                                       &templ);
605
               assert(drawable->msaa_textures[statt]);
606 607 608 609 610 611 612 613 614 615 616

               /* If there are any MSAA resources, we should initialize them
                * such that they contain the same data as the single-sample
                * resources we just got from the X server.
                *
                * The reason for this is that the state tracker (and
                * therefore the app) can access the MSAA resources only.
                * The single-sample resources are not exposed
                * to the state tracker.
                *
                */
617
               dri_pipe_blit(ctx->st->pipe,
618 619
                             drawable->msaa_textures[statt],
                             drawable->textures[statt]);
620 621 622
            }
         }
         else {
623
            pipe_resource_reference(&drawable->msaa_textures[statt], NULL);
624
         }
625 626 627 628 629
      }
   }

   /* Allocate a private depth-stencil buffer. */
   if (alloc_depthstencil) {
630
      enum st_attachment_type statt = ST_ATTACHMENT_DEPTH_STENCIL;
631
      struct pipe_resource **zsbuf;
632 633 634
      enum pipe_format format;
      unsigned bind;

635
      dri_drawable_get_format(drawable, statt, &format, &bind);
636

637 638 639 640
      if (format) {
         templ.format = format;
         templ.bind = bind;

641 642
         if (drawable->stvis.samples > 1) {
            templ.nr_samples = drawable->stvis.samples;
643
            zsbuf = &drawable->msaa_textures[statt];
644 645 646
         }
         else {
            templ.nr_samples = 0;
647
            zsbuf = &drawable->textures[statt];
648 649 650 651 652 653 654 655 656 657 658 659 660
         }

         /* Try to reuse the resource.
          * (the other resource parameters should be constant)
          */
         if (!*zsbuf ||
             (*zsbuf)->width0 != templ.width0 ||
             (*zsbuf)->height0 != templ.height0) {
            /* Allocate a new one. */
            pipe_resource_reference(zsbuf, NULL);
            *zsbuf = screen->base.screen->resource_create(screen->base.screen,
                                                          &templ);
            assert(*zsbuf);
661
         }
662
      }
663
      else {
664 665
         pipe_resource_reference(&drawable->msaa_textures[statt], NULL);
         pipe_resource_reference(&drawable->textures[statt], NULL);
666
      }
667 668
   }

669 670 671 672 673 674 675 676 677 678 679 680
   /* For DRI2, we may get the same buffers again from the server.
    * To prevent useless imports of gem names, drawable->old* is used
    * to bypass the import if we get the same buffers. This doesn't apply
    * to DRI3/Wayland, users of image.loader, since the buffer is managed
    * by the client (no import), and the back buffer is going to change
    * at every redraw.
    */
   if (!image) {
      drawable->old_num = num_buffers;
      drawable->old_w = dri_drawable->w;
      drawable->old_h = dri_drawable->h;
      memcpy(drawable->old, buffers, sizeof(__DRIbuffer) * num_buffers);
681
   }
682 683
}

684
static void
685 686
dri2_flush_frontbuffer(struct dri_context *ctx,
                       struct dri_drawable *drawable,
687
                       enum st_attachment_type statt)
688 689
{
   __DRIdrawable *dri_drawable = drawable->dPriv;
690
   const __DRIimageLoaderExtension *image = drawable->sPriv->image.loader;
691
   const __DRIdri2LoaderExtension *loader = drawable->sPriv->dri2.loader;
692
   struct pipe_context *pipe = ctx->st->pipe;
693

694
   if (statt != ST_ATTACHMENT_FRONT_LEFT)
695 696
      return;

697
   if (drawable->stvis.samples > 1) {
698 699 700 701
      /* Resolve the front buffer. */
      dri_pipe_blit(ctx->st->pipe,
                    drawable->textures[ST_ATTACHMENT_FRONT_LEFT],
                    drawable->msaa_textures[ST_ATTACHMENT_FRONT_LEFT]);
702 703
   }

704 705 706 707 708 709
   if (drawable->textures[ST_ATTACHMENT_FRONT_LEFT]) {
      pipe->flush_resource(pipe, drawable->textures[ST_ATTACHMENT_FRONT_LEFT]);
   }

   pipe->flush(pipe, NULL, 0);

710 711 712 713
   if (image) {
      image->flushFrontBuffer(dri_drawable, dri_drawable->loaderPrivate);
   }
   else if (loader->flushFrontBuffer) {
714 715 716 717
      loader->flushFrontBuffer(dri_drawable, dri_drawable->loaderPrivate);
   }
}

718 719 720 721 722 723 724 725
static void
dri2_update_tex_buffer(struct dri_drawable *drawable,
                       struct dri_context *ctx,
                       struct pipe_resource *res)
{
   /* no-op */
}

726
static __DRIimage *
727
dri2_lookup_egl_image(struct dri_screen *screen, void *handle)
728
{
729
   const __DRIimageLookupExtension *loader = screen->sPriv->dri2.image;
730 731 732 733 734
   __DRIimage *img;

   if (!loader->lookupEGLImage)
      return NULL;

735 736
   img = loader->lookupEGLImage(screen->sPriv,
				handle, screen->sPriv->loaderPrivate);
737 738 739 740 741

   return img;
}

static __DRIimage *
742 743
dri2_create_image_from_winsys(__DRIscreen *_screen,
                              int width, int height, int format,
744
                              struct winsys_handle *whandle,
745
                              void *loaderPrivate)
746
{
747
   struct dri_screen *screen = dri_screen(_screen);
748
   __DRIimage *img;
749
   struct pipe_resource templ;
750 751 752
   unsigned tex_usage;
   enum pipe_format pf;

753
   tex_usage = PIPE_BIND_RENDER_TARGET | PIPE_BIND_SAMPLER_VIEW;
754

755
   pf = dri2_format_to_pipe_format (format);
756 757 758 759 760 761 762 763
   if (pf == PIPE_FORMAT_NONE)
      return NULL;

   img = CALLOC_STRUCT(__DRIimageRec);
   if (!img)
      return NULL;

   memset(&templ, 0, sizeof(templ));
764
   templ.bind = tex_usage;
765
   templ.format = pf;
766
   templ.target = screen->target;
767 768 769 770
   templ.last_level = 0;
   templ.width0 = width;
   templ.height0 = height;
   templ.depth0 = 1;
771
   templ.array_size = 1;
772

773
   whandle->offset = 0;
774

775
   img->texture = screen->base.screen->resource_from_handle(screen->base.screen,
776
         &templ, whandle, PIPE_HANDLE_USAGE_READ_WRITE);
777 778 779 780 781 782
   if (!img->texture) {
      FREE(img);
      return NULL;
   }

   img->level = 0;
783
   img->layer = 0;
784
   img->dri_format = format;
785
   img->use = 0;
786 787 788 789 790
   img->loader_private = loaderPrivate;

   return img;
}

791 792 793 794 795 796
static __DRIimage *
dri2_create_image_from_name(__DRIscreen *_screen,
                            int width, int height, int format,
                            int name, int pitch, void *loaderPrivate)
{
   struct winsys_handle whandle;
797
   enum pipe_format pf;
798 799 800 801 802

   memset(&whandle, 0, sizeof(whandle));
   whandle.type = DRM_API_HANDLE_TYPE_SHARED;
   whandle.handle = name;

803 804 805 806 807 808
   pf = dri2_format_to_pipe_format (format);
   if (pf == PIPE_FORMAT_NONE)
      return NULL;

   whandle.stride = pitch * util_format_get_blocksize(pf);

809
   return dri2_create_image_from_winsys(_screen, width, height, format,
810
                                        &whandle, loaderPrivate);
811 812 813 814 815
}

static __DRIimage *
dri2_create_image_from_fd(__DRIscreen *_screen,
                          int width, int height, int format,
816
                          int fd, int stride, void *loaderPrivate)
817 818 819 820 821 822 823 824 825
{
   struct winsys_handle whandle;

   if (fd < 0)
      return NULL;

   memset(&whandle, 0, sizeof(whandle));
   whandle.type = DRM_API_HANDLE_TYPE_FD;
   whandle.handle = (unsigned)fd;
826
   whandle.stride = stride;
827 828

   return dri2_create_image_from_winsys(_screen, width, height, format,
829
                                        &whandle, loaderPrivate);
830 831
}

832 833 834 835
static __DRIimage *
dri2_create_image_from_renderbuffer(__DRIcontext *context,
				    int renderbuffer, void *loaderPrivate)
{
836
   struct dri_context *ctx = dri_context(context);
837 838 839 840 841 842 843 844

   if (!ctx->st->get_resource_for_egl_image)
      return NULL;

   /* TODO */
   return NULL;
}

845 846 847 848 849 850 851 852 853 854 855 856
static __DRIimage *
dri2_create_image(__DRIscreen *_screen,
                   int width, int height, int format,
                   unsigned int use, void *loaderPrivate)
{
   struct dri_screen *screen = dri_screen(_screen);
   __DRIimage *img;
   struct pipe_resource templ;
   unsigned tex_usage;
   enum pipe_format pf;

   tex_usage = PIPE_BIND_RENDER_TARGET | PIPE_BIND_SAMPLER_VIEW;
857 858 859 860
   if (use & __DRI_IMAGE_USE_SCANOUT)
      tex_usage |= PIPE_BIND_SCANOUT;
   if (use & __DRI_IMAGE_USE_SHARE)
      tex_usage |= PIPE_BIND_SHARED;
861 862
   if (use & __DRI_IMAGE_USE_LINEAR)
      tex_usage |= PIPE_BIND_LINEAR;
863 864 865 866 867
   if (use & __DRI_IMAGE_USE_CURSOR) {
      if (width != 64 || height != 64)
         return NULL;
      tex_usage |= PIPE_BIND_CURSOR;
   }
868

869
   pf = dri2_format_to_pipe_format (format);
870 871 872 873 874 875 876 877 878 879 880 881 882 883 884
   if (pf == PIPE_FORMAT_NONE)
      return NULL;

   img = CALLOC_STRUCT(__DRIimageRec);
   if (!img)
      return NULL;

   memset(&templ, 0, sizeof(templ));
   templ.bind = tex_usage;
   templ.format = pf;
   templ.target = PIPE_TEXTURE_2D;
   templ.last_level = 0;
   templ.width0 = width;
   templ.height0 = height;
   templ.depth0 = 1;
885
   templ.array_size = 1;
886 887 888 889 890 891 892 893

   img->texture = screen->base.screen->resource_create(screen->base.screen, &templ);
   if (!img->texture) {
      FREE(img);
      return NULL;
   }

   img->level = 0;
894
   img->layer = 0;
895
   img->dri_format = format;
896
   img->dri_components = 0;
897
   img->use = use;
898 899 900 901 902

   img->loader_private = loaderPrivate;
   return img;
}

903 904 905 906
static GLboolean
dri2_query_image(__DRIimage *image, int attrib, int *value)
{
   struct winsys_handle whandle;
907 908 909 910 911 912 913
   unsigned usage;

   if (image->use & __DRI_IMAGE_USE_BACKBUFFER)
      usage = PIPE_HANDLE_USAGE_EXPLICIT_FLUSH | PIPE_HANDLE_USAGE_READ;
   else
      usage = PIPE_HANDLE_USAGE_READ_WRITE;

914 915 916 917
   memset(&whandle, 0, sizeof(whandle));

   switch (attrib) {
   case __DRI_IMAGE_ATTRIB_STRIDE:
918
      whandle.type = DRM_API_HANDLE_TYPE_KMS;
919
      image->texture->screen->resource_get_handle(image->texture->screen,
920
            image->texture, &whandle, usage);
921 922 923 924 925
      *value = whandle.stride;
      return GL_TRUE;
   case __DRI_IMAGE_ATTRIB_HANDLE:
      whandle.type = DRM_API_HANDLE_TYPE_KMS;
      image->texture->screen->resource_get_handle(image->texture->screen,
926
         image->texture, &whandle, usage);
927 928 929 930 931
      *value = whandle.handle;
      return GL_TRUE;
   case __DRI_IMAGE_ATTRIB_NAME:
      whandle.type = DRM_API_HANDLE_TYPE_SHARED;
      image->texture->screen->resource_get_handle(image->texture->screen,
932
         image->texture, &whandle, usage);
933 934
      *value = whandle.handle;
      return GL_TRUE;
935 936 937
   case __DRI_IMAGE_ATTRIB_FD:
      whandle.type= DRM_API_HANDLE_TYPE_FD;
      image->texture->screen->resource_get_handle(image->texture->screen,
938
         image->texture, &whandle, usage);
939 940
      *value = whandle.handle;
      return GL_TRUE;
941 942 943
   case __DRI_IMAGE_ATTRIB_FORMAT:
      *value = image->dri_format;
      return GL_TRUE;
944 945 946 947 948 949
   case __DRI_IMAGE_ATTRIB_WIDTH:
      *value = image->texture->width0;
      return GL_TRUE;
   case __DRI_IMAGE_ATTRIB_HEIGHT:
      *value = image->texture->height0;
      return GL_TRUE;
950 951 952 953 954
   case __DRI_IMAGE_ATTRIB_COMPONENTS:
      if (image->dri_components == 0)
         return GL_FALSE;
      *value = image->dri_components;
      return GL_TRUE;
955 956 957 958 959 960
   case __DRI_IMAGE_ATTRIB_FOURCC:
      *value = convert_to_fourcc(image->dri_format);
      return GL_TRUE;
   case __DRI_IMAGE_ATTRIB_NUM_PLANES:
      *value = 1;
      return GL_TRUE;
961 962 963 964 965
   default:
      return GL_FALSE;
   }
}

966 967 968 969 970 971 972 973 974 975 976 977 978
static __DRIimage *
dri2_dup_image(__DRIimage *image, void *loaderPrivate)
{
   __DRIimage *img;

   img = CALLOC_STRUCT(__DRIimageRec);
   if (!img)
      return NULL;

   img->texture = NULL;
   pipe_resource_reference(&img->texture, image->texture);
   img->level = image->level;
   img->layer = image->layer;
Axel Davy's avatar
Axel Davy committed
979
   img->dri_format = image->dri_format;
980 981
   /* This should be 0 for sub images, but dup is also used for base images. */
   img->dri_components = image->dri_components;
982 983 984 985 986
   img->loader_private = loaderPrivate;

   return img;
}

987 988 989 990 991 992 993 994 995 996 997 998 999 1000
static GLboolean
dri2_validate_usage(__DRIimage *image, unsigned int use)
{
   /*
    * Gallium drivers are bad at adding usages to the resources
    * once opened again in another process, which is the main use
    * case for this, so we have to lie.
    */
   if (image != NULL)
      return GL_TRUE;
   else
      return GL_FALSE;
}

1001 1002 1003 1004 1005 1006
static __DRIimage *
dri2_from_names(__DRIscreen *screen, int width, int height, int format,
                int *names, int num_names, int *strides, int *offsets,
                void *loaderPrivate)
{
   __DRIimage *img;
1007 1008
   int dri_components;
   struct winsys_handle whandle;
1009 1010 1011 1012 1013 1014

   if (num_names != 1)
      return NULL;
   if (offsets[0] != 0)
      return NULL;

1015 1016
   format = convert_fourcc(format, &dri_components);
   if (format == -1)
1017 1018
      return NULL;

1019 1020 1021 1022
   memset(&whandle, 0, sizeof(whandle));
   whandle.type = DRM_API_HANDLE_TYPE_SHARED;
   whandle.handle = names[0];
   whandle.stride = strides[0];
1023

1024 1025
   img = dri2_create_image_from_winsys(screen, width, height, format,
                                       &whandle, loaderPrivate);
1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052
   if (img == NULL)
      return NULL;

   img->dri_components = dri_components;
   return img;
}

static __DRIimage *
dri2_from_planar(__DRIimage *image, int plane, void *loaderPrivate)
{
   __DRIimage *img;

   if (plane != 0)
      return NULL;

   if (image->dri_components == 0)
      return NULL;

   img = dri2_dup_image(image, loaderPrivate);
   if (img == NULL)
      return NULL;

   /* set this to 0 for sub images. */
   img->dri_components = 0;
   return img;
}

1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118
static __DRIimage *
dri2_create_from_texture(__DRIcontext *context, int target, unsigned texture,
                         int depth, int level, unsigned *error,
                         void *loaderPrivate)
{
   __DRIimage *img;
   struct gl_context *ctx = ((struct st_context *)dri_context(context)->st)->ctx;
   struct gl_texture_object *obj;
   struct pipe_resource *tex;
   GLuint face = 0;

   obj = _mesa_lookup_texture(ctx, texture);
   if (!obj || obj->Target != target) {
      *error = __DRI_IMAGE_ERROR_BAD_PARAMETER;
      return NULL;
   }

   tex = st_get_texobj_resource(obj);
   if (!tex) {
      *error = __DRI_IMAGE_ERROR_BAD_PARAMETER;
      return NULL;
   }

   if (target == GL_TEXTURE_CUBE_MAP)
      face = depth;

   _mesa_test_texobj_completeness(ctx, obj);
   if (!obj->_BaseComplete || (level > 0 && !obj->_MipmapComplete)) {
      *error = __DRI_IMAGE_ERROR_BAD_PARAMETER;
      return NULL;
   }

   if (level < obj->BaseLevel || level > obj->_MaxLevel) {
      *error = __DRI_IMAGE_ERROR_BAD_MATCH;
      return NULL;
   }

   if (target == GL_TEXTURE_3D && obj->Image[face][level]->Depth < depth) {
      *error = __DRI_IMAGE_ERROR_BAD_MATCH;
      return NULL;
   }

   img = CALLOC_STRUCT(__DRIimageRec);
   if (!img) {
      *error = __DRI_IMAGE_ERROR_BAD_ALLOC;
      return NULL;
   }

   img->level = level;
   img->layer = depth;
   img->dri_format = driGLFormatToImageFormat(obj->Image[face][level]->TexFormat);

   img->loader_private = loaderPrivate;

   if (img->dri_format == __DRI_IMAGE_FORMAT_NONE) {
      *error = __DRI_IMAGE_ERROR_BAD_PARAMETER;
      free(img);
      return NULL;
   }

   pipe_resource_reference(&img->texture, tex);

   *error = __DRI_IMAGE_ERROR_SUCCESS;
   return img;
}

1119 1120 1121 1122 1123 1124
static __DRIimage *
dri2_from_fds(__DRIscreen *screen, int width, int height, int fourcc,
              int *fds, int num_fds, int *strides, int *offsets,
              void *loaderPrivate)
{
   __DRIimage *img;
1125
   int format, dri_components;
1126 1127 1128 1129 1130 1131

   if (num_fds != 1)
      return NULL;
   if (offsets[0] != 0)
      return NULL;

1132 1133
   format = convert_fourcc(fourcc, &dri_components);
   if (format == -1)
1134 1135 1136
      return NULL;

   img = dri2_create_image_from_fd(screen, width, height, format,
1137
                                   fds[0], strides[0], loaderPrivate);
1138 1139 1140 1141 1142 1143 1144
   if (img == NULL)
      return NULL;

   img->dri_components = dri_components;
   return img;
}

1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157
static __DRIimage *
dri2_from_dma_bufs(__DRIscreen *screen,
                   int width, int height, int fourcc,
                   int *fds, int num_fds,
                   int *strides, int *offsets,
                   enum __DRIYUVColorSpace yuv_color_space,
                   enum __DRISampleRange sample_range,
                   enum __DRIChromaSiting horizontal_siting,
                   enum __DRIChromaSiting vertical_siting,
                   unsigned *error,
                   void *loaderPrivate)
{
   __DRIimage *img;
1158
   int format, dri_components;
1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171

   if (num_fds != 1 || offsets[0] != 0) {
      *error = __DRI_IMAGE_ERROR_BAD_MATCH;
      return NULL;
   }

   format = convert_fourcc(fourcc, &dri_components);
   if (format == -1) {
      *error = __DRI_IMAGE_ERROR_BAD_MATCH;
      return NULL;
   }

   img = dri2_create_image_from_fd(screen, width, height, format,
1172
                                   fds[0], strides[0], loaderPrivate);
1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187
   if (img == NULL) {
      *error = __DRI_IMAGE_ERROR_BAD_ALLOC;
      return NULL;
   }

   img->yuv_color_space = yuv_color_space;
   img->sample_range = sample_range;
   img->horizontal_siting = horizontal_siting;
   img->vertical_siting = vertical_siting;
   img->dri_components = dri_components;

   *error = __DRI_IMAGE_ERROR_SUCCESS;
   return img;
}

Axel Davy's avatar
Axel Davy committed
1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234
static void
dri2_blit_image(__DRIcontext *context, __DRIimage *dst, __DRIimage *src,
                int dstx0, int dsty0, int dstwidth, int dstheight,
                int srcx0, int srcy0, int srcwidth, int srcheight,
                int flush_flag)
{
   struct dri_context *ctx = dri_context(context);
   struct pipe_context *pipe = ctx->st->pipe;
   struct pipe_screen *screen;
   struct pipe_fence_handle *fence;
   struct pipe_blit_info blit;

   if (!dst || !src)
      return;

   memset(&blit, 0, sizeof(blit));
   blit.dst.resource = dst->texture;
   blit.dst.box.x = dstx0;
   blit.dst.box.y = dsty0;
   blit.dst.box.width = dstwidth;
   blit.dst.box.height = dstheight;
   blit.dst.box.depth = 1;
   blit.dst.format = dst->texture->format;
   blit.src.resource = src->texture;
   blit.src.box.x = srcx0;
   blit.src.box.y = srcy0;
   blit.src.box.width = srcwidth;
   blit.src.box.height = srcheight;
   blit.src.box.depth = 1;
   blit.src.format = src->texture->format;
   blit.mask = PIPE_MASK_RGBA;
   blit.filter = PIPE_TEX_FILTER_NEAREST;

   pipe->blit(pipe, &blit);

   if (flush_flag == __BLIT_FLAG_FLUSH) {
      pipe->flush_resource(pipe, dst->texture);
      ctx->st->flush(ctx->st, 0, NULL);
   } else if (flush_flag == __BLIT_FLAG_FINISH) {
      screen = dri_screen(ctx->sPriv)->base.screen;
      pipe->flush_resource(pipe, dst->texture);
      ctx->st->flush(ctx->st, 0, &fence);
      (void) screen->fence_finish(screen, fence, PIPE_TIMEOUT_INFINITE);
      screen->fence_reference(screen, &fence, NULL);
   }
}

1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273
static void *
dri2_map_image(__DRIcontext *context, __DRIimage *image,
                int x0, int y0, int width, int height,
                unsigned int flags, int *stride, void **data)
{
   struct dri_context *ctx = dri_context(context);
   struct pipe_context *pipe = ctx->st->pipe;
   enum pipe_transfer_usage pipe_access = 0;
   struct pipe_transfer *trans;
   void *map;

   if (!image || !data || *data)
      return NULL;

   if (flags & __DRI_IMAGE_TRANSFER_READ)
         pipe_access |= PIPE_TRANSFER_READ;
   if (flags & __DRI_IMAGE_TRANSFER_WRITE)
         pipe_access |= PIPE_TRANSFER_WRITE;

   map = pipe_transfer_map(pipe, image->texture,
                           0, 0, pipe_access, x0, y0, width, height,
                           &trans);
   if (map) {
      *data = trans;
      *stride = trans->stride;
   }

   return map;
}

static void
dri2_unmap_image(__DRIcontext *context, __DRIimage *image, void *data)
{
   struct dri_context *ctx = dri_context(context);
   struct pipe_context *pipe = ctx->st->pipe;

   pipe_transfer_unmap(pipe, (struct pipe_transfer *)data);
}

1274 1275 1276
static void
dri2_destroy_image(__DRIimage *img)
{
1277
   pipe_resource_reference(&img->texture, NULL);
1278 1279 1280
   FREE(img);
}

1281 1282 1283 1284 1285 1286 1287 1288
static int
dri2_get_capabilities(__DRIscreen *_screen)
{
   struct dri_screen *screen = dri_screen(_screen);

   return (screen->can_share_buffer ? __DRI_IMAGE_CAP_GLOBAL_NAMES : 0);
}

1289 1290
/* The extension is modified during runtime if DRI_PRIME is detected */
static __DRIimageExtension dri2ImageExtension = {
1291
    .base = { __DRI_IMAGE, 12 },
1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302

    .createImageFromName          = dri2_create_image_from_name,
    .createImageFromRenderbuffer  = dri2_create_image_from_renderbuffer,
    .destroyImage                 = dri2_destroy_image,
    .createImage                  = dri2_create_image,
    .queryImage                   = dri2_query_image,
    .dupImage                     = dri2_dup_image,
    .validateUsage                = dri2_validate_usage,
    .createImageFromNames         = dri2_from_names,
    .fromPlanar                   = dri2_from_planar,
    .createImageFromTexture       = dri2_create_from_texture,
Axel Davy's avatar
Axel Davy committed
1303 1304 1305
    .createImageFromFds           = NULL,
    .createImageFromDmaBufs       = NULL,
    .blitImage                    = dri2_blit_image,
1306
    .getCapabilities              = dri2_get_capabilities,
1307 1308
    .mapImage                     = dri2_map_image,
    .unmapImage                   = dri2_unmap_image,
1309 1310
};

1311

1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324