2 * Copyright 2008 Tungsten Graphics, Inc., Cedar Park, Texas.
5 * Permission is hereby granted, free of charge, to any person obtaining a
6 * copy of this software and associated documentation files (the
7 * "Software"), to deal in the Software without restriction, including
8 * without limitation the rights to use, copy, modify, merge, publish,
9 * distribute, sub license, and/or sell copies of the Software, and to
10 * permit persons to whom the Software is furnished to do so, subject to
11 * the following conditions:
13 * The above copyright notice and this permission notice (including the
14 * next paragraph) shall be included in all copies or substantial portions
17 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
18 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
19 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
20 * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR
21 * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
22 * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
23 * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
26 * Author: Alan Hourihane <alanh@tungstengraphics.com>
27 * Author: Jakob Bornecrantz <wallbraker@gmail.com>
32 #include "xorg_tracker.h"
33 #include "xorg_composite.h"
34 #include "xorg_exa_tgsi.h"
36 #include <xorg-server.h>
38 #include <picturestr.h>
41 #include "pipe/p_format.h"
42 #include "pipe/p_context.h"
43 #include "pipe/p_state.h"
44 #include "pipe/p_inlines.h"
46 #include "cso_cache/cso_context.h"
48 #include "util/u_rect.h"
57 exa_get_pipe_format(int depth
, enum pipe_format
*format
, int *bbp
)
61 *format
= PIPE_FORMAT_A8R8G8B8_UNORM
;
65 *format
= PIPE_FORMAT_X8R8G8B8_UNORM
;
69 *format
= PIPE_FORMAT_R5G6B5_UNORM
;
73 *format
= PIPE_FORMAT_A1R5G5B5_UNORM
;
77 *format
= PIPE_FORMAT_A8_UNORM
;
82 *format
= PIPE_FORMAT_A8R8G8B8_UNORM
; /* bad bad bad */
91 xorg_exa_init_state(struct exa_context
*exa
)
93 struct pipe_depth_stencil_alpha_state dsa
;
95 /* set common initial clip state */
96 memset(&dsa
, 0, sizeof(struct pipe_depth_stencil_alpha_state
));
97 cso_set_depth_stencil_alpha(exa
->cso
, &dsa
);
101 xorg_exa_common_done(struct exa_context
*exa
)
103 exa
->copy
.src
= NULL
;
104 exa
->copy
.dst
= NULL
;
105 exa
->has_solid_color
= FALSE
;
106 exa
->num_bound_samplers
= 0;
110 * Static exported EXA functions
114 ExaWaitMarker(ScreenPtr pScreen
, int marker
)
119 ExaMarkSync(ScreenPtr pScreen
)
125 ExaDownloadFromScreen(PixmapPtr pPix
, int x
, int y
, int w
, int h
, char *dst
,
128 ScreenPtr pScreen
= pPix
->drawable
.pScreen
;
129 ScrnInfoPtr pScrn
= xf86Screens
[pScreen
->myNum
];
130 modesettingPtr ms
= modesettingPTR(pScrn
);
131 struct exa_context
*exa
= ms
->exa
;
132 struct exa_pixmap_priv
*priv
= exaGetPixmapDriverPrivate(pPix
);
133 struct pipe_transfer
*transfer
;
135 if (!priv
|| !priv
->tex
)
138 if (exa
->pipe
->is_texture_referenced(exa
->pipe
, priv
->tex
, 0, 0) &
139 PIPE_REFERENCED_FOR_WRITE
)
140 exa
->pipe
->flush(exa
->pipe
, 0, NULL
);
142 transfer
= exa
->scrn
->get_tex_transfer(exa
->scrn
, priv
->tex
, 0, 0, 0,
143 PIPE_TRANSFER_READ
, x
, y
, w
, h
);
147 util_copy_rect((unsigned char*)dst
, &priv
->tex
->block
, dst_pitch
, 0, 0,
148 w
, h
, exa
->scrn
->transfer_map(exa
->scrn
, transfer
),
149 transfer
->stride
, 0, 0);
151 exa
->scrn
->transfer_unmap(exa
->scrn
, transfer
);
152 exa
->scrn
->tex_transfer_destroy(transfer
);
158 ExaUploadToScreen(PixmapPtr pPix
, int x
, int y
, int w
, int h
, char *src
,
161 ScreenPtr pScreen
= pPix
->drawable
.pScreen
;
162 ScrnInfoPtr pScrn
= xf86Screens
[pScreen
->myNum
];
163 modesettingPtr ms
= modesettingPTR(pScrn
);
164 struct exa_context
*exa
= ms
->exa
;
165 struct exa_pixmap_priv
*priv
= exaGetPixmapDriverPrivate(pPix
);
166 struct pipe_transfer
*transfer
;
168 if (!priv
|| !priv
->tex
)
171 transfer
= exa
->scrn
->get_tex_transfer(exa
->scrn
, priv
->tex
, 0, 0, 0,
172 PIPE_TRANSFER_WRITE
, x
, y
, w
, h
);
176 util_copy_rect(exa
->scrn
->transfer_map(exa
->scrn
, transfer
),
177 &priv
->tex
->block
, transfer
->stride
, 0, 0, w
, h
,
178 (unsigned char*)src
, src_pitch
, 0, 0);
180 exa
->scrn
->transfer_unmap(exa
->scrn
, transfer
);
181 exa
->scrn
->tex_transfer_destroy(transfer
);
187 ExaPrepareAccess(PixmapPtr pPix
, int index
)
189 ScreenPtr pScreen
= pPix
->drawable
.pScreen
;
190 ScrnInfoPtr pScrn
= xf86Screens
[pScreen
->myNum
];
191 modesettingPtr ms
= modesettingPTR(pScrn
);
192 struct exa_context
*exa
= ms
->exa
;
193 struct exa_pixmap_priv
*priv
;
195 priv
= exaGetPixmapDriverPrivate(pPix
);
203 if (priv
->map_count
++ == 0)
205 if (exa
->pipe
->is_texture_referenced(exa
->pipe
, priv
->tex
, 0, 0) &
206 PIPE_REFERENCED_FOR_WRITE
)
207 exa
->pipe
->flush(exa
->pipe
, 0, NULL
);
210 exa
->scrn
->get_tex_transfer(exa
->scrn
, priv
->tex
, 0, 0, 0,
211 PIPE_TRANSFER_READ_WRITE
,
212 0, 0, priv
->tex
->width
[0], priv
->tex
->height
[0]);
214 pPix
->devPrivate
.ptr
=
215 exa
->scrn
->transfer_map(exa
->scrn
, priv
->map_transfer
);
216 pPix
->devKind
= priv
->map_transfer
->stride
;
223 ExaFinishAccess(PixmapPtr pPix
, int index
)
225 ScreenPtr pScreen
= pPix
->drawable
.pScreen
;
226 ScrnInfoPtr pScrn
= xf86Screens
[pScreen
->myNum
];
227 modesettingPtr ms
= modesettingPTR(pScrn
);
228 struct exa_context
*exa
= ms
->exa
;
229 struct exa_pixmap_priv
*priv
;
230 priv
= exaGetPixmapDriverPrivate(pPix
);
235 if (!priv
->map_transfer
)
238 if (--priv
->map_count
== 0) {
239 assert(priv
->map_transfer
);
240 exa
->scrn
->transfer_unmap(exa
->scrn
, priv
->map_transfer
);
241 exa
->scrn
->tex_transfer_destroy(priv
->map_transfer
);
242 priv
->map_transfer
= NULL
;
243 pPix
->devPrivate
.ptr
= NULL
;
248 ExaDone(PixmapPtr pPixmap
)
250 ScrnInfoPtr pScrn
= xf86Screens
[pPixmap
->drawable
.pScreen
->myNum
];
251 modesettingPtr ms
= modesettingPTR(pScrn
);
252 struct exa_pixmap_priv
*priv
= exaGetPixmapDriverPrivate(pPixmap
);
253 struct exa_context
*exa
= ms
->exa
;
259 xorg_exa_flush(exa
, PIPE_FLUSH_RENDER_CACHE
, NULL
);
261 xorg_exa_finish(exa
);
263 xorg_exa_common_done(exa
);
267 ExaDoneComposite(PixmapPtr pPixmap
)
269 ScrnInfoPtr pScrn
= xf86Screens
[pPixmap
->drawable
.pScreen
->myNum
];
270 modesettingPtr ms
= modesettingPTR(pScrn
);
271 struct exa_context
*exa
= ms
->exa
;
273 xorg_exa_common_done(exa
);
277 ExaPrepareSolid(PixmapPtr pPixmap
, int alu
, Pixel planeMask
, Pixel fg
)
279 ScrnInfoPtr pScrn
= xf86Screens
[pPixmap
->drawable
.pScreen
->myNum
];
280 modesettingPtr ms
= modesettingPTR(pScrn
);
281 struct exa_pixmap_priv
*priv
= exaGetPixmapDriverPrivate(pPixmap
);
282 struct exa_context
*exa
= ms
->exa
;
285 debug_printf("ExaPrepareSolid - test\n");
287 if (!EXA_PM_IS_SOLID(&pPixmap
->drawable
, planeMask
))
290 if (!priv
|| !priv
->tex
)
293 if (!exa
->scrn
->is_format_supported(exa
->scrn
, priv
->tex
->format
,
295 PIPE_TEXTURE_USAGE_RENDER_TARGET
, 0))
310 debug_printf(" ExaPrepareSolid(0x%x)\n", fg
);
313 return xorg_solid_bind_state(exa
, priv
, fg
);
317 ExaSolid(PixmapPtr pPixmap
, int x0
, int y0
, int x1
, int y1
)
319 ScrnInfoPtr pScrn
= xf86Screens
[pPixmap
->drawable
.pScreen
->myNum
];
320 modesettingPtr ms
= modesettingPTR(pScrn
);
321 struct exa_context
*exa
= ms
->exa
;
322 struct exa_pixmap_priv
*priv
= exaGetPixmapDriverPrivate(pPixmap
);
324 debug_printf("\tExaSolid(%d, %d, %d, %d)\n", x0
, y0
, x1
, y1
);
327 if (x0
== 0 && y0
== 0 &&
328 x1
== priv
->tex
->width
[0] &&
329 y1
== priv
->tex
->height
[0]) {
330 exa
->ctx
->clear(exa
->pipe
, PIPE_CLEAR_COLOR
,
331 exa
->solid_color
, 1., 0);
336 exa
->solid_color
[0] = 0.f
;
337 exa
->solid_color
[1] = 1.f
;
338 exa
->solid_color
[2] = 0.f
;
339 exa
->solid_color
[3] = 1.f
;
340 xorg_solid(exa
, priv
, 0, 0, 1024, 768);
341 exa
->solid_color
[0] = 1.f
;
342 exa
->solid_color
[1] = 0.f
;
343 exa
->solid_color
[2] = 0.f
;
344 exa
->solid_color
[3] = 1.f
;
345 xorg_solid(exa
, priv
, 0, 0, 300, 300);
346 xorg_solid(exa
, priv
, 300, 300, 350, 350);
347 xorg_solid(exa
, priv
, 350, 350, 500, 500);
349 xorg_solid(exa
, priv
,
350 priv
->tex
->width
[0] - 10,
351 priv
->tex
->height
[0] - 10,
353 priv
->tex
->height
[0]);
355 exa
->solid_color
[0] = 0.f
;
356 exa
->solid_color
[1] = 0.f
;
357 exa
->solid_color
[2] = 1.f
;
358 exa
->solid_color
[3] = 1.f
;
360 exa
->has_solid_color
= FALSE
;
361 ExaPrepareCopy(pPixmap
, pPixmap
, 0, 0, GXcopy
, 0xffffffff);
362 ExaCopy(pPixmap
, 0, 0, 50, 50, 500, 500);
364 xorg_solid(exa
, priv
, x0
, y0
, x1
, y1
) ;
369 ExaPrepareCopy(PixmapPtr pSrcPixmap
, PixmapPtr pDstPixmap
, int xdir
,
370 int ydir
, int alu
, Pixel planeMask
)
372 ScrnInfoPtr pScrn
= xf86Screens
[pDstPixmap
->drawable
.pScreen
->myNum
];
373 modesettingPtr ms
= modesettingPTR(pScrn
);
374 struct exa_context
*exa
= ms
->exa
;
375 struct exa_pixmap_priv
*priv
= exaGetPixmapDriverPrivate(pDstPixmap
);
376 struct exa_pixmap_priv
*src_priv
= exaGetPixmapDriverPrivate(pSrcPixmap
);
378 debug_printf("ExaPrepareCopy\n");
383 if (!EXA_PM_IS_SOLID(&pSrcPixmap
->drawable
, planeMask
))
386 if (!priv
|| !src_priv
)
389 if (!exa
->scrn
->is_format_supported(exa
->scrn
, priv
->tex
->format
,
391 PIPE_TEXTURE_USAGE_RENDER_TARGET
, 0) ||
392 !exa
->scrn
->is_format_supported(exa
->scrn
, src_priv
->tex
->format
,
393 src_priv
->tex
->target
,
394 PIPE_TEXTURE_USAGE_SAMPLER
, 0))
397 if (!priv
->tex
|| !src_priv
->tex
)
403 exa
->copy
.src
= src_priv
;
404 exa
->copy
.dst
= priv
;
406 /*XXX disabled until some issues with syncing are fixed */
411 ExaCopy(PixmapPtr pDstPixmap
, int srcX
, int srcY
, int dstX
, int dstY
,
412 int width
, int height
)
414 ScrnInfoPtr pScrn
= xf86Screens
[pDstPixmap
->drawable
.pScreen
->myNum
];
415 modesettingPtr ms
= modesettingPTR(pScrn
);
416 struct exa_context
*exa
= ms
->exa
;
417 struct exa_pixmap_priv
*priv
= exaGetPixmapDriverPrivate(pDstPixmap
);
419 debug_printf("\tExaCopy(srcx=%d, srcy=%d, dstX=%d, dstY=%d, w=%d, h=%d)\n",
420 srcX
, srcY
, dstX
, dstY
, width
, height
);
422 debug_assert(priv
== exa
->copy
.dst
);
424 xorg_copy_pixmap(exa
, exa
->copy
.dst
, dstX
, dstY
,
425 exa
->copy
.src
, srcX
, srcY
,
430 ExaPrepareComposite(int op
, PicturePtr pSrcPicture
,
431 PicturePtr pMaskPicture
, PicturePtr pDstPicture
,
432 PixmapPtr pSrc
, PixmapPtr pMask
, PixmapPtr pDst
)
434 ScrnInfoPtr pScrn
= xf86Screens
[pDst
->drawable
.pScreen
->myNum
];
435 modesettingPtr ms
= modesettingPTR(pScrn
);
436 struct exa_context
*exa
= ms
->exa
;
438 debug_printf("ExaPrepareComposite\n");
440 return xorg_composite_bind_state(exa
, op
, pSrcPicture
, pMaskPicture
,
442 exaGetPixmapDriverPrivate(pSrc
),
443 exaGetPixmapDriverPrivate(pMask
),
444 exaGetPixmapDriverPrivate(pDst
));
448 ExaComposite(PixmapPtr pDst
, int srcX
, int srcY
, int maskX
, int maskY
,
449 int dstX
, int dstY
, int width
, int height
)
451 ScrnInfoPtr pScrn
= xf86Screens
[pDst
->drawable
.pScreen
->myNum
];
452 modesettingPtr ms
= modesettingPTR(pScrn
);
453 struct exa_context
*exa
= ms
->exa
;
454 struct exa_pixmap_priv
*priv
= exaGetPixmapDriverPrivate(pDst
);
456 debug_printf("\tExaComposite\n");
458 xorg_composite(exa
, priv
, srcX
, srcY
, maskX
, maskY
,
459 dstX
, dstY
, width
, height
);
463 ExaCheckComposite(int op
,
464 PicturePtr pSrcPicture
, PicturePtr pMaskPicture
,
465 PicturePtr pDstPicture
)
467 return xorg_composite_accelerated(op
,
474 ExaCreatePixmap(ScreenPtr pScreen
, int size
, int align
)
476 struct exa_pixmap_priv
*priv
;
478 priv
= xcalloc(1, sizeof(struct exa_pixmap_priv
));
486 ExaDestroyPixmap(ScreenPtr pScreen
, void *dPriv
)
488 struct exa_pixmap_priv
*priv
= (struct exa_pixmap_priv
*)dPriv
;
493 pipe_texture_reference(&priv
->tex
, NULL
);
499 ExaPixmapIsOffscreen(PixmapPtr pPixmap
)
501 struct exa_pixmap_priv
*priv
;
503 priv
= exaGetPixmapDriverPrivate(pPixmap
);
515 xorg_exa_set_displayed_usage(PixmapPtr pPixmap
)
517 struct exa_pixmap_priv
*priv
;
518 priv
= exaGetPixmapDriverPrivate(pPixmap
);
521 FatalError("NO PIXMAP PRIVATE\n");
525 priv
->flags
|= PIPE_TEXTURE_USAGE_PRIMARY
;
531 xorg_exa_set_shared_usage(PixmapPtr pPixmap
)
533 struct exa_pixmap_priv
*priv
;
534 priv
= exaGetPixmapDriverPrivate(pPixmap
);
537 FatalError("NO PIXMAP PRIVATE\n");
541 priv
->flags
|= PIPE_TEXTURE_USAGE_DISPLAY_TARGET
;
547 xorg_exa_get_pixmap_handle(PixmapPtr pPixmap
, unsigned *stride_out
)
549 ScreenPtr pScreen
= pPixmap
->drawable
.pScreen
;
550 ScrnInfoPtr pScrn
= xf86Screens
[pScreen
->myNum
];
551 modesettingPtr ms
= modesettingPTR(pScrn
);
552 struct exa_pixmap_priv
*priv
;
557 FatalError("NO MS->EXA\n");
561 priv
= exaGetPixmapDriverPrivate(pPixmap
);
564 FatalError("NO PIXMAP PRIVATE\n");
568 ms
->api
->local_handle_from_texture(ms
->api
, ms
->screen
, priv
->tex
, &stride
, &handle
);
570 *stride_out
= stride
;
576 ExaModifyPixmapHeader(PixmapPtr pPixmap
, int width
, int height
,
577 int depth
, int bitsPerPixel
, int devKind
,
580 ScreenPtr pScreen
= pPixmap
->drawable
.pScreen
;
581 ScrnInfoPtr pScrn
= xf86Screens
[pScreen
->myNum
];
582 struct exa_pixmap_priv
*priv
= exaGetPixmapDriverPrivate(pPixmap
);
583 modesettingPtr ms
= modesettingPTR(pScrn
);
584 struct exa_context
*exa
= ms
->exa
;
586 if (!priv
|| pPixData
)
590 depth
= pPixmap
->drawable
.depth
;
592 if (bitsPerPixel
<= 0)
593 bitsPerPixel
= pPixmap
->drawable
.bitsPerPixel
;
596 width
= pPixmap
->drawable
.width
;
599 height
= pPixmap
->drawable
.height
;
601 if (width
<= 0 || height
<= 0 || depth
<= 0)
604 miModifyPixmapHeader(pPixmap
, width
, height
, depth
,
605 bitsPerPixel
, devKind
, NULL
);
607 /* Deal with screen resize */
609 (priv
->tex
->width
[0] != width
||
610 priv
->tex
->height
[0] != height
||
611 priv
->tex_flags
!= priv
->flags
)) {
612 struct pipe_texture
*texture
= NULL
;
614 #ifdef DRM_MODE_FEATURE_DIRTYFB
618 struct pipe_texture
template;
620 memset(&template, 0, sizeof(template));
621 template.target
= PIPE_TEXTURE_2D
;
622 exa_get_pipe_format(depth
, &template.format
, &bitsPerPixel
);
623 pf_get_block(template.format
, &template.block
);
624 template.width
[0] = width
;
625 template.height
[0] = height
;
626 template.depth
[0] = 1;
627 template.last_level
= 0;
628 template.tex_usage
= PIPE_TEXTURE_USAGE_RENDER_TARGET
| priv
->flags
;
629 priv
->tex_flags
= priv
->flags
;
630 texture
= exa
->scrn
->texture_create(exa
->scrn
, &template);
633 struct pipe_surface
*dst_surf
;
634 struct pipe_surface
*src_surf
;
636 dst_surf
= exa
->scrn
->get_tex_surface(
637 exa
->scrn
, texture
, 0, 0, 0, PIPE_BUFFER_USAGE_GPU_WRITE
);
638 src_surf
= exa_gpu_surface(exa
, priv
);
639 exa
->pipe
->surface_copy(exa
->pipe
, dst_surf
, 0, 0, src_surf
,
640 0, 0, min(width
, texture
->width
[0]),
641 min(height
, texture
->height
[0]));
642 exa
->scrn
->tex_surface_destroy(dst_surf
);
643 exa
->scrn
->tex_surface_destroy(src_surf
);
644 } else if (pPixmap
->devPrivate
.ptr
) {
645 struct pipe_transfer
*transfer
;
647 if (priv
->map_count
!= 0)
648 FatalError("doing ExaModifyPixmapHeader on mapped buffer\n");
651 exa
->scrn
->get_tex_transfer(exa
->scrn
, texture
, 0, 0, 0,
653 0, 0, width
, height
);
654 util_copy_rect(exa
->scrn
->transfer_map(exa
->scrn
, transfer
),
655 &texture
->block
, transfer
->stride
, 0, 0,
656 width
, height
, pPixmap
->devPrivate
.ptr
,
657 pPixmap
->devKind
, 0, 0);
658 exa
->scrn
->transfer_unmap(exa
->scrn
, transfer
);
659 exa
->scrn
->tex_transfer_destroy(transfer
);
661 xfree(pPixmap
->devPrivate
.ptr
);
662 pPixmap
->devPrivate
.ptr
= NULL
;
665 #ifdef DRM_MODE_FEATURE_DIRTYFB
667 xfree(pPixmap
->devPrivate
.ptr
);
668 pPixmap
->devPrivate
.ptr
= xalloc(pPixmap
->drawable
.height
*
673 pipe_texture_reference(&priv
->tex
, texture
);
674 /* the texture we create has one reference */
675 pipe_texture_reference(&texture
, NULL
);
681 struct pipe_texture
*
682 xorg_exa_get_texture(PixmapPtr pPixmap
)
684 struct exa_pixmap_priv
*priv
= exaGetPixmapDriverPrivate(pPixmap
);
685 struct pipe_texture
*tex
= NULL
;
686 pipe_texture_reference(&tex
, priv
->tex
);
691 xorg_exa_close(ScrnInfoPtr pScrn
)
693 modesettingPtr ms
= modesettingPTR(pScrn
);
694 struct exa_context
*exa
= ms
->exa
;
695 struct pipe_constant_buffer
*vsbuf
= &exa
->vs_const_buffer
;
696 struct pipe_constant_buffer
*fsbuf
= &exa
->fs_const_buffer
;
699 xorg_shaders_destroy(exa
->shaders
);
702 if (vsbuf
&& vsbuf
->buffer
)
703 pipe_buffer_reference(&vsbuf
->buffer
, NULL
);
705 if (fsbuf
&& fsbuf
->buffer
)
706 pipe_buffer_reference(&fsbuf
->buffer
, NULL
);
709 cso_release_all(exa
->cso
);
710 cso_destroy_context(exa
->cso
);
714 exa
->pipe
->destroy(exa
->pipe
);
716 exaDriverFini(pScrn
->pScreen
);
722 xorg_exa_init(ScrnInfoPtr pScrn
)
724 modesettingPtr ms
= modesettingPTR(pScrn
);
725 struct exa_context
*exa
;
728 exa
= xcalloc(1, sizeof(struct exa_context
));
732 pExa
= exaDriverAlloc();
737 memset(pExa
, 0, sizeof(*pExa
));
741 pExa
->memoryBase
= 0;
742 pExa
->memorySize
= 0;
743 pExa
->offScreenBase
= 0;
744 pExa
->pixmapOffsetAlign
= 0;
745 pExa
->pixmapPitchAlign
= 1;
746 pExa
->flags
= EXA_OFFSCREEN_PIXMAPS
| EXA_HANDLES_PIXMAPS
;
747 #ifdef EXA_SUPPORTS_PREPARE_AUX
748 pExa
->flags
|= EXA_SUPPORTS_PREPARE_AUX
;
750 #ifdef EXA_MIXED_PIXMAPS
751 pExa
->flags
|= EXA_MIXED_PIXMAPS
;
753 pExa
->maxX
= 8191; /* FIXME */
754 pExa
->maxY
= 8191; /* FIXME */
756 pExa
->WaitMarker
= ExaWaitMarker
;
757 pExa
->MarkSync
= ExaMarkSync
;
758 pExa
->PrepareSolid
= ExaPrepareSolid
;
759 pExa
->Solid
= ExaSolid
;
760 pExa
->DoneSolid
= ExaDone
;
761 pExa
->PrepareCopy
= ExaPrepareCopy
;
762 pExa
->Copy
= ExaCopy
;
763 pExa
->DoneCopy
= ExaDone
;
764 pExa
->CheckComposite
= ExaCheckComposite
;
765 pExa
->PrepareComposite
= ExaPrepareComposite
;
766 pExa
->Composite
= ExaComposite
;
767 pExa
->DoneComposite
= ExaDoneComposite
;
768 pExa
->PixmapIsOffscreen
= ExaPixmapIsOffscreen
;
769 pExa
->DownloadFromScreen
= ExaDownloadFromScreen
;
770 pExa
->UploadToScreen
= ExaUploadToScreen
;
771 pExa
->PrepareAccess
= ExaPrepareAccess
;
772 pExa
->FinishAccess
= ExaFinishAccess
;
773 pExa
->CreatePixmap
= ExaCreatePixmap
;
774 pExa
->DestroyPixmap
= ExaDestroyPixmap
;
775 pExa
->ModifyPixmapHeader
= ExaModifyPixmapHeader
;
777 if (!exaDriverInit(pScrn
->pScreen
, pExa
)) {
781 exa
->scrn
= ms
->screen
;
782 exa
->pipe
= ms
->api
->create_context(ms
->api
, exa
->scrn
);
783 /* Share context with DRI */
786 exa
->cso
= cso_create_context(exa
->pipe
);
787 exa
->shaders
= xorg_shaders_create(exa
);
789 xorg_exa_init_state(exa
);
794 xorg_exa_close(pScrn
);
799 struct pipe_surface
*
800 exa_gpu_surface(struct exa_context
*exa
, struct exa_pixmap_priv
*priv
)
802 return exa
->scrn
->get_tex_surface(exa
->scrn
, priv
->tex
, 0, 0, 0,
803 PIPE_BUFFER_USAGE_GPU_READ
|
804 PIPE_BUFFER_USAGE_GPU_WRITE
);
808 void xorg_exa_flush(struct exa_context
*exa
, uint pipeFlushFlags
,
809 struct pipe_fence_handle
**fence
)
811 exa
->pipe
->flush(exa
->pipe
, pipeFlushFlags
, fence
);
814 void xorg_exa_finish(struct exa_context
*exa
)
816 struct pipe_fence_handle
*fence
= NULL
;
818 xorg_exa_flush(exa
, PIPE_FLUSH_RENDER_CACHE
, &fence
);
820 exa
->pipe
->screen
->fence_finish(exa
->pipe
->screen
, fence
, 0);
821 exa
->pipe
->screen
->fence_reference(exa
->pipe
->screen
, &fence
, NULL
);