• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /**************************************************************************
2  *
3  * Copyright 2009, VMware, Inc.
4  * All Rights Reserved.
5  * Copyright 2010 George Sapountzis <gsapountzis@gmail.com>
6  *
7  * Permission is hereby granted, free of charge, to any person obtaining a
8  * copy of this software and associated documentation files (the
9  * "Software"), to deal in the Software without restriction, including
10  * without limitation the rights to use, copy, modify, merge, publish,
11  * distribute, sub license, and/or sell copies of the Software, and to
12  * permit persons to whom the Software is furnished to do so, subject to
13  * the following conditions:
14  *
15  * The above copyright notice and this permission notice (including the
16  * next paragraph) shall be included in all copies or substantial portions
17  * of the Software.
18  *
19  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
20  * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
21  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
22  * IN NO EVENT SHALL VMWARE AND/OR ITS SUPPLIERS BE LIABLE FOR
23  * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
24  * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
25  * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
26  *
27  **************************************************************************/
28 
29 #include "GL/internal/mesa_interface.h"
30 #include "git_sha1.h"
31 #include "util/format/u_format.h"
32 #include "util/u_memory.h"
33 #include "util/u_inlines.h"
34 #include "util/u_box.h"
35 #include "pipe/p_context.h"
36 #include "pipe-loader/pipe_loader.h"
37 #include "frontend/drisw_api.h"
38 #include "state_tracker/st_context.h"
39 
40 #include "dri_screen.h"
41 #include "dri_context.h"
42 #include "dri_drawable.h"
43 #include "dri_helpers.h"
44 #include "dri_query_renderer.h"
45 
46 DEBUG_GET_ONCE_BOOL_OPTION(swrast_no_present, "SWRAST_NO_PRESENT", false);
47 
48 static inline void
get_drawable_info(struct dri_drawable * drawable,int * x,int * y,int * w,int * h)49 get_drawable_info(struct dri_drawable *drawable, int *x, int *y, int *w, int *h)
50 {
51    const __DRIswrastLoaderExtension *loader = drawable->screen->swrast_loader;
52 
53    loader->getDrawableInfo(opaque_dri_drawable(drawable),
54                            x, y, w, h,
55                            drawable->loaderPrivate);
56 }
57 
58 static inline void
put_image(struct dri_drawable * drawable,void * data,unsigned width,unsigned height)59 put_image(struct dri_drawable *drawable, void *data, unsigned width, unsigned height)
60 {
61    const __DRIswrastLoaderExtension *loader = drawable->screen->swrast_loader;
62 
63    loader->putImage(opaque_dri_drawable(drawable), __DRI_SWRAST_IMAGE_OP_SWAP,
64                     0, 0, width, height,
65                     data, drawable->loaderPrivate);
66 }
67 
68 static inline void
put_image2(struct dri_drawable * drawable,void * data,int x,int y,unsigned width,unsigned height,unsigned stride)69 put_image2(struct dri_drawable *drawable, void *data, int x, int y,
70            unsigned width, unsigned height, unsigned stride)
71 {
72    const __DRIswrastLoaderExtension *loader = drawable->screen->swrast_loader;
73 
74    loader->putImage2(opaque_dri_drawable(drawable), __DRI_SWRAST_IMAGE_OP_SWAP,
75                      x, y, width, height, stride,
76                      data, drawable->loaderPrivate);
77 }
78 
79 static inline void
put_image_shm(struct dri_drawable * drawable,int shmid,char * shmaddr,unsigned offset,unsigned offset_x,int x,int y,unsigned width,unsigned height,unsigned stride)80 put_image_shm(struct dri_drawable *drawable, int shmid, char *shmaddr,
81               unsigned offset, unsigned offset_x, int x, int y,
82               unsigned width, unsigned height, unsigned stride)
83 {
84    const __DRIswrastLoaderExtension *loader = drawable->screen->swrast_loader;
85 
86    /* if we have the newer interface, don't have to add the offset_x here. */
87    if (loader->base.version > 4 && loader->putImageShm2)
88      loader->putImageShm2(opaque_dri_drawable(drawable), __DRI_SWRAST_IMAGE_OP_SWAP,
89                           x, y, width, height, stride,
90                           shmid, shmaddr, offset, drawable->loaderPrivate);
91    else
92      loader->putImageShm(opaque_dri_drawable(drawable), __DRI_SWRAST_IMAGE_OP_SWAP,
93                          x, y, width, height, stride,
94                          shmid, shmaddr, offset + offset_x, drawable->loaderPrivate);
95 }
96 
97 static inline void
get_image(struct dri_drawable * drawable,int x,int y,int width,int height,void * data)98 get_image(struct dri_drawable *drawable, int x, int y, int width, int height, void *data)
99 {
100    const __DRIswrastLoaderExtension *loader = drawable->screen->swrast_loader;
101 
102    loader->getImage(opaque_dri_drawable(drawable),
103                     x, y, width, height,
104                     data, drawable->loaderPrivate);
105 }
106 
107 static inline void
get_image2(struct dri_drawable * drawable,int x,int y,int width,int height,int stride,void * data)108 get_image2(struct dri_drawable *drawable, int x, int y, int width, int height, int stride, void *data)
109 {
110    const __DRIswrastLoaderExtension *loader = drawable->screen->swrast_loader;
111 
112    /* getImage2 support is only in version 3 or newer */
113    if (loader->base.version < 3)
114       return;
115 
116    loader->getImage2(opaque_dri_drawable(drawable),
117                      x, y, width, height, stride,
118                      data, drawable->loaderPrivate);
119 }
120 
121 static inline bool
get_image_shm(struct dri_drawable * drawable,int x,int y,int width,int height,struct pipe_resource * res)122 get_image_shm(struct dri_drawable *drawable, int x, int y, int width, int height,
123               struct pipe_resource *res)
124 {
125    const __DRIswrastLoaderExtension *loader = drawable->screen->swrast_loader;
126    struct winsys_handle whandle;
127 
128    whandle.type = WINSYS_HANDLE_TYPE_SHMID;
129 
130    if (loader->base.version < 4 || !loader->getImageShm)
131       return false;
132 
133    if (!res->screen->resource_get_handle(res->screen, NULL, res, &whandle, PIPE_HANDLE_USAGE_FRAMEBUFFER_WRITE))
134       return false;
135 
136    if (loader->base.version > 5 && loader->getImageShm2)
137       return loader->getImageShm2(opaque_dri_drawable(drawable), x, y, width, height, whandle.handle, drawable->loaderPrivate);
138 
139    loader->getImageShm(opaque_dri_drawable(drawable), x, y, width, height, whandle.handle, drawable->loaderPrivate);
140    return true;
141 }
142 
143 static void
drisw_update_drawable_info(struct dri_drawable * drawable)144 drisw_update_drawable_info(struct dri_drawable *drawable)
145 {
146    int x, y;
147 
148    get_drawable_info(drawable, &x, &y, &drawable->w, &drawable->h);
149 }
150 
151 static void
drisw_get_image(struct dri_drawable * drawable,int x,int y,unsigned width,unsigned height,unsigned stride,void * data)152 drisw_get_image(struct dri_drawable *drawable,
153                 int x, int y, unsigned width, unsigned height, unsigned stride,
154                 void *data)
155 {
156    int draw_x, draw_y, draw_w, draw_h;
157 
158    get_drawable_info(drawable, &draw_x, &draw_y, &draw_w, &draw_h);
159    get_image2(drawable, x, y, draw_w, draw_h, stride, data);
160 }
161 
162 static void
drisw_put_image(struct dri_drawable * drawable,void * data,unsigned width,unsigned height)163 drisw_put_image(struct dri_drawable *drawable,
164                 void *data, unsigned width, unsigned height)
165 {
166    put_image(drawable, data, width, height);
167 }
168 
169 static void
drisw_put_image2(struct dri_drawable * drawable,void * data,int x,int y,unsigned width,unsigned height,unsigned stride)170 drisw_put_image2(struct dri_drawable *drawable,
171                  void *data, int x, int y, unsigned width, unsigned height,
172                  unsigned stride)
173 {
174    put_image2(drawable, data, x, y, width, height, stride);
175 }
176 
177 static inline void
drisw_put_image_shm(struct dri_drawable * drawable,int shmid,char * shmaddr,unsigned offset,unsigned offset_x,int x,int y,unsigned width,unsigned height,unsigned stride)178 drisw_put_image_shm(struct dri_drawable *drawable,
179                     int shmid, char *shmaddr, unsigned offset,
180                     unsigned offset_x,
181                     int x, int y, unsigned width, unsigned height,
182                     unsigned stride)
183 {
184    put_image_shm(drawable, shmid, shmaddr, offset, offset_x, x, y, width, height, stride);
185 }
186 
187 static inline void
drisw_present_texture(struct pipe_context * pipe,struct dri_drawable * drawable,struct pipe_resource * ptex,struct pipe_box * sub_box)188 drisw_present_texture(struct pipe_context *pipe, struct dri_drawable *drawable,
189                       struct pipe_resource *ptex, struct pipe_box *sub_box)
190 {
191    struct dri_screen *screen = drawable->screen;
192 
193    if (screen->swrast_no_present)
194       return;
195 
196    screen->base.screen->flush_frontbuffer(screen->base.screen, pipe, ptex, 0, 0, drawable, sub_box);
197 }
198 
199 static inline void
drisw_invalidate_drawable(struct dri_drawable * drawable)200 drisw_invalidate_drawable(struct dri_drawable *drawable)
201 {
202    drawable->texture_stamp = drawable->lastStamp - 1;
203 
204    p_atomic_inc(&drawable->base.stamp);
205 }
206 
207 static inline void
drisw_copy_to_front(struct pipe_context * pipe,struct dri_drawable * drawable,struct pipe_resource * ptex)208 drisw_copy_to_front(struct pipe_context *pipe,
209                     struct dri_drawable *drawable,
210                     struct pipe_resource *ptex)
211 {
212    drisw_present_texture(pipe, drawable, ptex, NULL);
213 
214    drisw_invalidate_drawable(drawable);
215 }
216 
217 /*
218  * Backend functions for pipe_frontend_drawable and swap_buffers.
219  */
220 
221 static void
drisw_swap_buffers(struct dri_drawable * drawable)222 drisw_swap_buffers(struct dri_drawable *drawable)
223 {
224    struct dri_context *ctx = dri_get_current();
225    struct dri_screen *screen = drawable->screen;
226    struct pipe_resource *ptex;
227 
228    if (!ctx)
229       return;
230 
231    /* Wait for glthread to finish because we can't use pipe_context from
232     * multiple threads.
233     */
234    _mesa_glthread_finish(ctx->st->ctx);
235 
236    ptex = drawable->textures[ST_ATTACHMENT_BACK_LEFT];
237 
238    if (ptex) {
239       struct pipe_fence_handle *fence = NULL;
240       if (ctx->pp)
241          pp_run(ctx->pp, ptex, ptex, drawable->textures[ST_ATTACHMENT_DEPTH_STENCIL]);
242 
243       if (ctx->hud)
244          hud_run(ctx->hud, ctx->st->cso_context, ptex);
245 
246       st_context_flush(ctx->st, ST_FLUSH_FRONT, &fence, NULL, NULL);
247 
248       if (drawable->stvis.samples > 1) {
249          /* Resolve the back buffer. */
250          dri_pipe_blit(ctx->st->pipe,
251                        drawable->textures[ST_ATTACHMENT_BACK_LEFT],
252                        drawable->msaa_textures[ST_ATTACHMENT_BACK_LEFT]);
253       }
254 
255       screen->base.screen->fence_finish(screen->base.screen, ctx->st->pipe,
256                                         fence, OS_TIMEOUT_INFINITE);
257       screen->base.screen->fence_reference(screen->base.screen, &fence, NULL);
258       drisw_copy_to_front(ctx->st->pipe, drawable, ptex);
259       drawable->buffer_age = 1;
260 
261       /* TODO: remove this if the framebuffer state doesn't change. */
262       st_context_invalidate_state(ctx->st, ST_INVALIDATE_FB_STATE);
263    }
264 }
265 
266 static void
drisw_copy_sub_buffer(struct dri_drawable * drawable,int x,int y,int w,int h)267 drisw_copy_sub_buffer(struct dri_drawable *drawable, int x, int y,
268                       int w, int h)
269 {
270    struct dri_context *ctx = dri_get_current();
271    struct dri_screen *screen = drawable->screen;
272    struct pipe_resource *ptex;
273    struct pipe_box box;
274    if (!ctx)
275       return;
276 
277    ptex = drawable->textures[ST_ATTACHMENT_BACK_LEFT];
278 
279    if (ptex) {
280       /* Wait for glthread to finish because we can't use pipe_context from
281        * multiple threads.
282        */
283       _mesa_glthread_finish(ctx->st->ctx);
284 
285       struct pipe_fence_handle *fence = NULL;
286       if (ctx->pp && drawable->textures[ST_ATTACHMENT_DEPTH_STENCIL])
287          pp_run(ctx->pp, ptex, ptex, drawable->textures[ST_ATTACHMENT_DEPTH_STENCIL]);
288 
289       st_context_flush(ctx->st, ST_FLUSH_FRONT, &fence, NULL, NULL);
290 
291       screen->base.screen->fence_finish(screen->base.screen, ctx->st->pipe,
292                                         fence, OS_TIMEOUT_INFINITE);
293       screen->base.screen->fence_reference(screen->base.screen, &fence, NULL);
294 
295       if (drawable->stvis.samples > 1) {
296          /* Resolve the back buffer. */
297          dri_pipe_blit(ctx->st->pipe,
298                        drawable->textures[ST_ATTACHMENT_BACK_LEFT],
299                        drawable->msaa_textures[ST_ATTACHMENT_BACK_LEFT]);
300       }
301 
302       u_box_2d(x, drawable->h - y - h, w, h, &box);
303       drisw_present_texture(ctx->st->pipe, drawable, ptex, &box);
304    }
305 }
306 
307 static bool
drisw_flush_frontbuffer(struct dri_context * ctx,struct dri_drawable * drawable,enum st_attachment_type statt)308 drisw_flush_frontbuffer(struct dri_context *ctx,
309                         struct dri_drawable *drawable,
310                         enum st_attachment_type statt)
311 {
312    struct pipe_resource *ptex;
313 
314    if (!ctx || statt != ST_ATTACHMENT_FRONT_LEFT)
315       return false;
316 
317    /* Wait for glthread to finish because we can't use pipe_context from
318     * multiple threads.
319     */
320    _mesa_glthread_finish(ctx->st->ctx);
321 
322    if (drawable->stvis.samples > 1) {
323       /* Resolve the front buffer. */
324       dri_pipe_blit(ctx->st->pipe,
325                     drawable->textures[ST_ATTACHMENT_FRONT_LEFT],
326                     drawable->msaa_textures[ST_ATTACHMENT_FRONT_LEFT]);
327    }
328    ptex = drawable->textures[statt];
329 
330    if (ptex) {
331       drisw_copy_to_front(ctx->st->pipe, ctx->draw, ptex);
332    }
333 
334    return true;
335 }
336 
337 /**
338  * Allocate framebuffer attachments.
339  *
340  * During fixed-size operation, the function keeps allocating new attachments
341  * as they are requested. Unused attachments are not removed, not until the
342  * framebuffer is resized or destroyed.
343  */
344 static void
drisw_allocate_textures(struct dri_context * stctx,struct dri_drawable * drawable,const enum st_attachment_type * statts,unsigned count)345 drisw_allocate_textures(struct dri_context *stctx,
346                         struct dri_drawable *drawable,
347                         const enum st_attachment_type *statts,
348                         unsigned count)
349 {
350    struct dri_screen *screen = drawable->screen;
351    const __DRIswrastLoaderExtension *loader = drawable->screen->swrast_loader;
352    struct pipe_resource templ;
353    unsigned width, height;
354    bool resized;
355    unsigned i;
356 
357    /* Wait for glthread to finish because we can't use pipe_context from
358     * multiple threads.
359     */
360    _mesa_glthread_finish(stctx->st->ctx);
361 
362    width  = drawable->w;
363    height = drawable->h;
364 
365    resized = (drawable->old_w != width ||
366               drawable->old_h != height);
367 
368    /* remove outdated textures */
369    if (resized) {
370       for (i = 0; i < ST_ATTACHMENT_COUNT; i++) {
371          pipe_resource_reference(&drawable->textures[i], NULL);
372          pipe_resource_reference(&drawable->msaa_textures[i], NULL);
373       }
374       drawable->buffer_age = 0;
375    }
376 
377    memset(&templ, 0, sizeof(templ));
378    templ.target = screen->target;
379    templ.width0 = width;
380    templ.height0 = height;
381    templ.depth0 = 1;
382    templ.array_size = 1;
383    templ.last_level = 0;
384 
385    for (i = 0; i < count; i++) {
386       enum pipe_format format;
387       unsigned bind;
388 
389       /* the texture already exists or not requested */
390       if (drawable->textures[statts[i]])
391          continue;
392 
393       dri_drawable_get_format(drawable, statts[i], &format, &bind);
394 
395       /* if we don't do any present, no need for display targets */
396       if (statts[i] != ST_ATTACHMENT_DEPTH_STENCIL && !screen->swrast_no_present)
397          bind |= PIPE_BIND_DISPLAY_TARGET;
398 
399       if (format == PIPE_FORMAT_NONE)
400          continue;
401 
402       templ.format = format;
403       templ.bind = bind;
404       templ.nr_samples = 0;
405       templ.nr_storage_samples = 0;
406 
407       if (statts[i] == ST_ATTACHMENT_FRONT_LEFT &&
408                  screen->base.screen->resource_create_front &&
409                  loader->base.version >= 3) {
410          drawable->textures[statts[i]] =
411             screen->base.screen->resource_create_front(screen->base.screen, &templ, (const void *)drawable);
412       } else
413          drawable->textures[statts[i]] =
414             screen->base.screen->resource_create(screen->base.screen, &templ);
415 
416       if (drawable->stvis.samples > 1) {
417          templ.bind = templ.bind &
418             ~(PIPE_BIND_SCANOUT | PIPE_BIND_SHARED | PIPE_BIND_DISPLAY_TARGET);
419          templ.nr_samples = drawable->stvis.samples;
420          templ.nr_storage_samples = drawable->stvis.samples;
421          drawable->msaa_textures[statts[i]] =
422             screen->base.screen->resource_create(screen->base.screen, &templ);
423 
424          dri_pipe_blit(stctx->st->pipe,
425                        drawable->msaa_textures[statts[i]],
426                        drawable->textures[statts[i]]);
427       }
428    }
429 
430    drawable->old_w = width;
431    drawable->old_h = height;
432 }
433 
434 static void
drisw_update_tex_buffer(struct dri_drawable * drawable,struct dri_context * ctx,struct pipe_resource * res)435 drisw_update_tex_buffer(struct dri_drawable *drawable,
436                         struct dri_context *ctx,
437                         struct pipe_resource *res)
438 {
439    struct st_context *st_ctx = (struct st_context *)ctx->st;
440    struct pipe_context *pipe = st_ctx->pipe;
441    struct pipe_transfer *transfer;
442    char *map;
443    int x, y, w, h;
444    int ximage_stride, line;
445    int cpp = util_format_get_blocksize(res->format);
446 
447    /* Wait for glthread to finish because we can't use pipe_context from
448     * multiple threads.
449     */
450    _mesa_glthread_finish(ctx->st->ctx);
451 
452    get_drawable_info(drawable, &x, &y, &w, &h);
453 
454    map = pipe_texture_map(pipe, res,
455                            0, 0, // level, layer,
456                            PIPE_MAP_WRITE,
457                            x, y, w, h, &transfer);
458 
459    /* Copy the Drawable content to the mapped texture buffer */
460    if (!get_image_shm(drawable, x, y, w, h, res))
461       get_image(drawable, x, y, w, h, map);
462 
463    /* The pipe transfer has a pitch rounded up to the nearest 64 pixels.
464       get_image() has a pitch rounded up to 4 bytes.  */
465    ximage_stride = ((w * cpp) + 3) & -4;
466    for (line = h-1; line; --line) {
467       memmove(&map[line * transfer->stride],
468               &map[line * ximage_stride],
469               ximage_stride);
470    }
471 
472    pipe_texture_unmap(pipe, transfer);
473 }
474 
475 static __DRIimageExtension driSWImageExtension = {
476     .base = { __DRI_IMAGE, 6 },
477 
478     .createImageFromRenderbuffer  = dri2_create_image_from_renderbuffer,
479     .createImageFromTexture = dri2_create_from_texture,
480     .destroyImage = dri2_destroy_image,
481 };
482 
483 static const __DRIrobustnessExtension dri2Robustness = {
484    .base = { __DRI2_ROBUSTNESS, 1 }
485 };
486 
487 /*
488  * Backend function for init_screen.
489  */
490 
491 static const __DRIextension *drisw_screen_extensions[] = {
492    &driTexBufferExtension.base,
493    &dri2RendererQueryExtension.base,
494    &dri2ConfigQueryExtension.base,
495    &dri2FenceExtension.base,
496    &driSWImageExtension.base,
497    &dri2FlushControlExtension.base,
498    NULL
499 };
500 
501 static const __DRIextension *drisw_robust_screen_extensions[] = {
502    &driTexBufferExtension.base,
503    &dri2RendererQueryExtension.base,
504    &dri2ConfigQueryExtension.base,
505    &dri2FenceExtension.base,
506    &dri2Robustness.base,
507    &driSWImageExtension.base,
508    &dri2FlushControlExtension.base,
509    NULL
510 };
511 
512 static const struct drisw_loader_funcs drisw_lf = {
513    .get_image = drisw_get_image,
514    .put_image = drisw_put_image,
515    .put_image2 = drisw_put_image2
516 };
517 
518 static const struct drisw_loader_funcs drisw_shm_lf = {
519    .get_image = drisw_get_image,
520    .put_image = drisw_put_image,
521    .put_image2 = drisw_put_image2,
522    .put_image_shm = drisw_put_image_shm
523 };
524 
525 static struct dri_drawable *
drisw_create_drawable(struct dri_screen * screen,const struct gl_config * visual,bool isPixmap,void * loaderPrivate)526 drisw_create_drawable(struct dri_screen *screen, const struct gl_config * visual,
527                       bool isPixmap, void *loaderPrivate)
528 {
529    struct dri_drawable *drawable = dri_create_drawable(screen, visual, isPixmap,
530                                                        loaderPrivate);
531    if (!drawable)
532       return NULL;
533 
534    drawable->allocate_textures = drisw_allocate_textures;
535    drawable->update_drawable_info = drisw_update_drawable_info;
536    drawable->flush_frontbuffer = drisw_flush_frontbuffer;
537    drawable->update_tex_buffer = drisw_update_tex_buffer;
538    drawable->swap_buffers = drisw_swap_buffers;
539 
540    return drawable;
541 }
542 
543 static const __DRIconfig **
drisw_init_screen(struct dri_screen * screen)544 drisw_init_screen(struct dri_screen *screen)
545 {
546    const __DRIswrastLoaderExtension *loader = screen->swrast_loader;
547    const __DRIconfig **configs;
548    struct pipe_screen *pscreen = NULL;
549    const struct drisw_loader_funcs *lf = &drisw_lf;
550 
551    screen->swrast_no_present = debug_get_option_swrast_no_present();
552 
553    if (loader->base.version >= 4) {
554       if (loader->putImageShm)
555          lf = &drisw_shm_lf;
556    }
557 
558    bool success = false;
559 #ifdef HAVE_DRISW_KMS
560    if (screen->fd != -1)
561       success = pipe_loader_sw_probe_kms(&screen->dev, screen->fd);
562 #endif
563    if (!success)
564       success = pipe_loader_sw_probe_dri(&screen->dev, lf);
565 
566    if (success)
567       pscreen = pipe_loader_create_screen(screen->dev);
568 
569    if (!pscreen)
570       goto fail;
571 
572    dri_init_options(screen);
573    configs = dri_init_screen(screen, pscreen);
574    if (!configs)
575       goto fail;
576 
577    if (pscreen->get_param(pscreen, PIPE_CAP_DEVICE_RESET_STATUS_QUERY)) {
578       screen->extensions = drisw_robust_screen_extensions;
579       screen->has_reset_status_query = true;
580    }
581    else
582       screen->extensions = drisw_screen_extensions;
583    screen->lookup_egl_image = dri2_lookup_egl_image;
584 
585    const __DRIimageLookupExtension *image = screen->dri2.image;
586    if (image &&
587        image->base.version >= 2 &&
588        image->validateEGLImage &&
589        image->lookupEGLImageValidated) {
590       screen->validate_egl_image = dri2_validate_egl_image;
591       screen->lookup_egl_image_validated = dri2_lookup_egl_image_validated;
592    }
593 
594    screen->create_drawable = drisw_create_drawable;
595 
596    return configs;
597 fail:
598    dri_release_screen(screen);
599    return NULL;
600 }
601 
602 /* swrast copy sub buffer entrypoint. */
driswCopySubBuffer(__DRIdrawable * pdp,int x,int y,int w,int h)603 static void driswCopySubBuffer(__DRIdrawable *pdp, int x, int y,
604                                int w, int h)
605 {
606    struct dri_drawable *drawable = dri_drawable(pdp);
607 
608    assert(drawable->screen->swrast_loader);
609 
610    drisw_copy_sub_buffer(drawable, x, y, w, h);
611 }
612 
613 /* for swrast only */
614 const __DRIcopySubBufferExtension driSWCopySubBufferExtension = {
615    .base = { __DRI_COPY_SUB_BUFFER, 1 },
616 
617    .copySubBuffer               = driswCopySubBuffer,
618 };
619 
620 static const struct __DRImesaCoreExtensionRec mesaCoreExtension = {
621    .base = { __DRI_MESA, 1 },
622    .version_string = MESA_INTERFACE_VERSION_STRING,
623    .createNewScreen = driCreateNewScreen2,
624    .createContext = driCreateContextAttribs,
625    .initScreen = drisw_init_screen,
626 };
627 
628 /* This is the table of extensions that the loader will dlsym() for. */
629 const __DRIextension *galliumsw_driver_extensions[] = {
630     &driCoreExtension.base,
631     &mesaCoreExtension.base,
632     &driSWRastExtension.base,
633     &driSWCopySubBufferExtension.base,
634     &gallium_config_options.base,
635     NULL
636 };
637 
638 /* vim: set sw=3 ts=8 sts=3 expandtab: */
639