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 "util/u_rect.h"
49 #define ACCEL_ENABLED TRUE
56 exa_get_pipe_format(int depth
, enum pipe_format
*format
, int *bbp
)
60 *format
= PIPE_FORMAT_A8R8G8B8_UNORM
;
64 *format
= PIPE_FORMAT_X8R8G8B8_UNORM
;
68 *format
= PIPE_FORMAT_R5G6B5_UNORM
;
72 *format
= PIPE_FORMAT_A1R5G5B5_UNORM
;
76 *format
= PIPE_FORMAT_L8_UNORM
;
81 *format
= PIPE_FORMAT_A8R8G8B8_UNORM
; /* bad bad bad */
90 xorg_exa_common_done(struct exa_context
*exa
)
92 renderer_draw_flush(exa
->renderer
);
96 exa
->transform
.has_src
= FALSE
;
97 exa
->transform
.has_mask
= FALSE
;
98 exa
->has_solid_color
= FALSE
;
99 exa
->num_bound_samplers
= 0;
103 * Static exported EXA functions
107 ExaWaitMarker(ScreenPtr pScreen
, int marker
)
109 ScrnInfoPtr pScrn
= xf86Screens
[pScreen
->myNum
];
110 modesettingPtr ms
= modesettingPTR(pScrn
);
111 struct exa_context
*exa
= ms
->exa
;
114 xorg_exa_flush(exa
, PIPE_FLUSH_RENDER_CACHE
, NULL
);
116 xorg_exa_finish(exa
);
121 ExaMarkSync(ScreenPtr pScreen
)
127 ExaDownloadFromScreen(PixmapPtr pPix
, int x
, int y
, int w
, int h
, char *dst
,
130 ScreenPtr pScreen
= pPix
->drawable
.pScreen
;
131 ScrnInfoPtr pScrn
= xf86Screens
[pScreen
->myNum
];
132 modesettingPtr ms
= modesettingPTR(pScrn
);
133 struct exa_context
*exa
= ms
->exa
;
134 struct exa_pixmap_priv
*priv
= exaGetPixmapDriverPrivate(pPix
);
135 struct pipe_transfer
*transfer
;
137 if (!priv
|| !priv
->tex
)
140 if (exa
->pipe
->is_texture_referenced(exa
->pipe
, priv
->tex
, 0, 0) &
141 PIPE_REFERENCED_FOR_WRITE
)
142 exa
->pipe
->flush(exa
->pipe
, 0, NULL
);
144 transfer
= exa
->scrn
->get_tex_transfer(exa
->scrn
, priv
->tex
, 0, 0, 0,
145 PIPE_TRANSFER_READ
, x
, y
, w
, h
);
150 debug_printf("------ ExaDownloadFromScreen(%d, %d, %d, %d, %d)\n",
151 x
, y
, w
, h
, dst_pitch
);
154 util_copy_rect((unsigned char*)dst
, &priv
->tex
->block
, dst_pitch
, 0, 0,
155 w
, h
, exa
->scrn
->transfer_map(exa
->scrn
, transfer
),
156 transfer
->stride
, 0, 0);
158 exa
->scrn
->transfer_unmap(exa
->scrn
, transfer
);
159 exa
->scrn
->tex_transfer_destroy(transfer
);
165 ExaUploadToScreen(PixmapPtr pPix
, int x
, int y
, int w
, int h
, char *src
,
168 ScreenPtr pScreen
= pPix
->drawable
.pScreen
;
169 ScrnInfoPtr pScrn
= xf86Screens
[pScreen
->myNum
];
170 modesettingPtr ms
= modesettingPTR(pScrn
);
171 struct exa_context
*exa
= ms
->exa
;
172 struct exa_pixmap_priv
*priv
= exaGetPixmapDriverPrivate(pPix
);
173 struct pipe_transfer
*transfer
;
175 if (!priv
|| !priv
->tex
)
178 transfer
= exa
->scrn
->get_tex_transfer(exa
->scrn
, priv
->tex
, 0, 0, 0,
179 PIPE_TRANSFER_WRITE
, x
, y
, w
, h
);
184 debug_printf("++++++ ExaUploadToScreen(%d, %d, %d, %d, %d)\n",
185 x
, y
, w
, h
, src_pitch
);
188 util_copy_rect(exa
->scrn
->transfer_map(exa
->scrn
, transfer
),
189 &priv
->tex
->block
, transfer
->stride
, 0, 0, w
, h
,
190 (unsigned char*)src
, src_pitch
, 0, 0);
192 exa
->scrn
->transfer_unmap(exa
->scrn
, transfer
);
193 exa
->scrn
->tex_transfer_destroy(transfer
);
199 ExaPrepareAccess(PixmapPtr pPix
, int index
)
201 ScreenPtr pScreen
= pPix
->drawable
.pScreen
;
202 ScrnInfoPtr pScrn
= xf86Screens
[pScreen
->myNum
];
203 modesettingPtr ms
= modesettingPTR(pScrn
);
204 struct exa_context
*exa
= ms
->exa
;
205 struct exa_pixmap_priv
*priv
;
207 priv
= exaGetPixmapDriverPrivate(pPix
);
215 if (priv
->map_count
== 0)
217 if (exa
->pipe
->is_texture_referenced(exa
->pipe
, priv
->tex
, 0, 0) &
218 PIPE_REFERENCED_FOR_WRITE
)
219 exa
->pipe
->flush(exa
->pipe
, 0, NULL
);
222 exa
->scrn
->get_tex_transfer(exa
->scrn
, priv
->tex
, 0, 0, 0,
223 #ifdef EXA_MIXED_PIXMAPS
224 PIPE_TRANSFER_MAP_DIRECTLY
|
226 PIPE_TRANSFER_READ_WRITE
,
227 0, 0, priv
->tex
->width
[0], priv
->tex
->height
[0]);
228 if (!priv
->map_transfer
)
229 #ifdef EXA_MIXED_PIXMAPS
232 FatalError("failed to create transfer\n");
235 pPix
->devPrivate
.ptr
=
236 exa
->scrn
->transfer_map(exa
->scrn
, priv
->map_transfer
);
237 pPix
->devKind
= priv
->map_transfer
->stride
;
246 ExaFinishAccess(PixmapPtr pPix
, int index
)
248 ScreenPtr pScreen
= pPix
->drawable
.pScreen
;
249 ScrnInfoPtr pScrn
= xf86Screens
[pScreen
->myNum
];
250 modesettingPtr ms
= modesettingPTR(pScrn
);
251 struct exa_context
*exa
= ms
->exa
;
252 struct exa_pixmap_priv
*priv
;
253 priv
= exaGetPixmapDriverPrivate(pPix
);
258 if (!priv
->map_transfer
)
261 if (--priv
->map_count
== 0) {
262 assert(priv
->map_transfer
);
263 exa
->scrn
->transfer_unmap(exa
->scrn
, priv
->map_transfer
);
264 exa
->scrn
->tex_transfer_destroy(priv
->map_transfer
);
265 priv
->map_transfer
= NULL
;
266 pPix
->devPrivate
.ptr
= NULL
;
271 ExaDone(PixmapPtr pPixmap
)
273 ScrnInfoPtr pScrn
= xf86Screens
[pPixmap
->drawable
.pScreen
->myNum
];
274 modesettingPtr ms
= modesettingPTR(pScrn
);
275 struct exa_pixmap_priv
*priv
= exaGetPixmapDriverPrivate(pPixmap
);
276 struct exa_context
*exa
= ms
->exa
;
281 xorg_exa_common_done(exa
);
285 ExaDoneComposite(PixmapPtr pPixmap
)
287 ScrnInfoPtr pScrn
= xf86Screens
[pPixmap
->drawable
.pScreen
->myNum
];
288 modesettingPtr ms
= modesettingPTR(pScrn
);
289 struct exa_context
*exa
= ms
->exa
;
291 xorg_exa_common_done(exa
);
295 ExaPrepareSolid(PixmapPtr pPixmap
, int alu
, Pixel planeMask
, Pixel fg
)
297 ScrnInfoPtr pScrn
= xf86Screens
[pPixmap
->drawable
.pScreen
->myNum
];
298 modesettingPtr ms
= modesettingPTR(pScrn
);
299 struct exa_pixmap_priv
*priv
= exaGetPixmapDriverPrivate(pPixmap
);
300 struct exa_context
*exa
= ms
->exa
;
303 debug_printf("ExaPrepareSolid(0x%x)\n", fg
);
306 XORG_FALLBACK("accle not enabled");
308 if (!priv
|| !priv
->tex
)
309 XORG_FALLBACK("%s", !priv
? "!priv" : "!priv->tex");
311 if (!EXA_PM_IS_SOLID(&pPixmap
->drawable
, planeMask
))
312 XORG_FALLBACK("planeMask is not solid");
315 XORG_FALLBACK("not GXcopy");
317 if (!exa
->scrn
->is_format_supported(exa
->scrn
, priv
->tex
->format
,
319 PIPE_TEXTURE_USAGE_RENDER_TARGET
, 0)) {
320 XORG_FALLBACK("format %s", pf_name(priv
->tex
->format
));
323 return ACCEL_ENABLED
&& xorg_solid_bind_state(exa
, priv
, fg
);
327 ExaSolid(PixmapPtr pPixmap
, int x0
, int y0
, int x1
, int y1
)
329 ScrnInfoPtr pScrn
= xf86Screens
[pPixmap
->drawable
.pScreen
->myNum
];
330 modesettingPtr ms
= modesettingPTR(pScrn
);
331 struct exa_context
*exa
= ms
->exa
;
332 struct exa_pixmap_priv
*priv
= exaGetPixmapDriverPrivate(pPixmap
);
335 debug_printf("\tExaSolid(%d, %d, %d, %d)\n", x0
, y0
, x1
, y1
);
338 xorg_solid(exa
, priv
, x0
, y0
, x1
, y1
) ;
342 ExaPrepareCopy(PixmapPtr pSrcPixmap
, PixmapPtr pDstPixmap
, int xdir
,
343 int ydir
, int alu
, Pixel planeMask
)
345 ScrnInfoPtr pScrn
= xf86Screens
[pDstPixmap
->drawable
.pScreen
->myNum
];
346 modesettingPtr ms
= modesettingPTR(pScrn
);
347 struct exa_context
*exa
= ms
->exa
;
348 struct exa_pixmap_priv
*priv
= exaGetPixmapDriverPrivate(pDstPixmap
);
349 struct exa_pixmap_priv
*src_priv
= exaGetPixmapDriverPrivate(pSrcPixmap
);
352 debug_printf("ExaPrepareCopy\n");
355 XORG_FALLBACK("accle not enabled");
357 if (!priv
|| !priv
->tex
)
358 XORG_FALLBACK("pDst %s", !priv
? "!priv" : "!priv->tex");
360 if (!src_priv
|| !src_priv
->tex
)
361 XORG_FALLBACK("pSrc %s", !src_priv
? "!priv" : "!priv->tex");
363 if (!EXA_PM_IS_SOLID(&pSrcPixmap
->drawable
, planeMask
))
364 XORG_FALLBACK("planeMask is not solid");
367 XORG_FALLBACK("alu not GXcopy");
369 if (!exa
->scrn
->is_format_supported(exa
->scrn
, priv
->tex
->format
,
371 PIPE_TEXTURE_USAGE_RENDER_TARGET
, 0))
372 XORG_FALLBACK("pDst format %s", pf_name(priv
->tex
->format
));
374 if (!exa
->scrn
->is_format_supported(exa
->scrn
, src_priv
->tex
->format
,
375 src_priv
->tex
->target
,
376 PIPE_TEXTURE_USAGE_SAMPLER
, 0))
377 XORG_FALLBACK("pSrc format %s", pf_name(src_priv
->tex
->format
));
379 exa
->copy
.src
= src_priv
;
380 exa
->copy
.dst
= priv
;
382 return ACCEL_ENABLED
;
386 ExaCopy(PixmapPtr pDstPixmap
, int srcX
, int srcY
, int dstX
, int dstY
,
387 int width
, int height
)
389 ScrnInfoPtr pScrn
= xf86Screens
[pDstPixmap
->drawable
.pScreen
->myNum
];
390 modesettingPtr ms
= modesettingPTR(pScrn
);
391 struct exa_context
*exa
= ms
->exa
;
392 struct exa_pixmap_priv
*priv
= exaGetPixmapDriverPrivate(pDstPixmap
);
395 debug_printf("\tExaCopy(srcx=%d, srcy=%d, dstX=%d, dstY=%d, w=%d, h=%d)\n",
396 srcX
, srcY
, dstX
, dstY
, width
, height
);
399 debug_assert(priv
== exa
->copy
.dst
);
401 renderer_copy_pixmap(exa
->renderer
, exa
->copy
.dst
, dstX
, dstY
,
402 exa
->copy
.src
, srcX
, srcY
,
407 ExaPrepareComposite(int op
, PicturePtr pSrcPicture
,
408 PicturePtr pMaskPicture
, PicturePtr pDstPicture
,
409 PixmapPtr pSrc
, PixmapPtr pMask
, PixmapPtr pDst
)
411 ScrnInfoPtr pScrn
= xf86Screens
[pDst
->drawable
.pScreen
->myNum
];
412 modesettingPtr ms
= modesettingPTR(pScrn
);
413 struct exa_context
*exa
= ms
->exa
;
414 struct exa_pixmap_priv
*priv
;
417 debug_printf("ExaPrepareComposite(%d, src=0x%p, mask=0x%p, dst=0x%p)\n",
418 op
, pSrcPicture
, pMaskPicture
, pDstPicture
);
421 XORG_FALLBACK("accle not enabled");
423 priv
= exaGetPixmapDriverPrivate(pDst
);
424 if (!priv
|| !priv
->tex
)
425 XORG_FALLBACK("pDst %s", !priv
? "!priv" : "!priv->tex");
427 if (!exa
->scrn
->is_format_supported(exa
->scrn
, priv
->tex
->format
,
429 PIPE_TEXTURE_USAGE_RENDER_TARGET
, 0))
430 XORG_FALLBACK("pDst format: %s", pf_name(priv
->tex
->format
));
433 priv
= exaGetPixmapDriverPrivate(pSrc
);
434 if (!priv
|| !priv
->tex
)
435 XORG_FALLBACK("pSrc %s", !priv
? "!priv" : "!priv->tex");
437 if (!exa
->scrn
->is_format_supported(exa
->scrn
, priv
->tex
->format
,
439 PIPE_TEXTURE_USAGE_SAMPLER
, 0))
440 XORG_FALLBACK("pSrc format: %s", pf_name(priv
->tex
->format
));
444 priv
= exaGetPixmapDriverPrivate(pMask
);
445 if (!priv
|| !priv
->tex
)
446 XORG_FALLBACK("pMask %s", !priv
? "!priv" : "!priv->tex");
448 if (!exa
->scrn
->is_format_supported(exa
->scrn
, priv
->tex
->format
,
450 PIPE_TEXTURE_USAGE_SAMPLER
, 0))
451 XORG_FALLBACK("pMask format: %s", pf_name(priv
->tex
->format
));
454 return ACCEL_ENABLED
&&
455 xorg_composite_bind_state(exa
, op
, pSrcPicture
, pMaskPicture
,
457 pSrc
? exaGetPixmapDriverPrivate(pSrc
) : NULL
,
458 pMask
? exaGetPixmapDriverPrivate(pMask
) : NULL
,
459 exaGetPixmapDriverPrivate(pDst
));
463 ExaComposite(PixmapPtr pDst
, int srcX
, int srcY
, int maskX
, int maskY
,
464 int dstX
, int dstY
, int width
, int height
)
466 ScrnInfoPtr pScrn
= xf86Screens
[pDst
->drawable
.pScreen
->myNum
];
467 modesettingPtr ms
= modesettingPTR(pScrn
);
468 struct exa_context
*exa
= ms
->exa
;
469 struct exa_pixmap_priv
*priv
= exaGetPixmapDriverPrivate(pDst
);
472 debug_printf("\tExaComposite(src[%d,%d], mask=[%d, %d], dst=[%d, %d], dim=[%d, %d])\n",
473 srcX
, srcY
, maskX
, maskY
, dstX
, dstY
, width
, height
);
474 debug_printf("\t Num bound samplers = %d\n",
475 exa
->num_bound_samplers
);
478 xorg_composite(exa
, priv
, srcX
, srcY
, maskX
, maskY
,
479 dstX
, dstY
, width
, height
);
483 ExaCheckComposite(int op
,
484 PicturePtr pSrcPicture
, PicturePtr pMaskPicture
,
485 PicturePtr pDstPicture
)
487 boolean accelerated
= xorg_composite_accelerated(op
,
492 debug_printf("ExaCheckComposite(%d, %p, %p, %p) = %d\n",
493 op
, pSrcPicture
, pMaskPicture
, pDstPicture
, accelerated
);
495 return ACCEL_ENABLED
&& accelerated
;
499 ExaCreatePixmap(ScreenPtr pScreen
, int size
, int align
)
501 struct exa_pixmap_priv
*priv
;
503 priv
= xcalloc(1, sizeof(struct exa_pixmap_priv
));
511 ExaDestroyPixmap(ScreenPtr pScreen
, void *dPriv
)
513 struct exa_pixmap_priv
*priv
= (struct exa_pixmap_priv
*)dPriv
;
518 pipe_texture_reference(&priv
->tex
, NULL
);
524 ExaPixmapIsOffscreen(PixmapPtr pPixmap
)
526 struct exa_pixmap_priv
*priv
;
528 priv
= exaGetPixmapDriverPrivate(pPixmap
);
540 xorg_exa_set_displayed_usage(PixmapPtr pPixmap
)
542 struct exa_pixmap_priv
*priv
;
543 priv
= exaGetPixmapDriverPrivate(pPixmap
);
546 FatalError("NO PIXMAP PRIVATE\n");
550 priv
->flags
|= PIPE_TEXTURE_USAGE_PRIMARY
;
556 xorg_exa_set_shared_usage(PixmapPtr pPixmap
)
558 struct exa_pixmap_priv
*priv
;
559 priv
= exaGetPixmapDriverPrivate(pPixmap
);
562 FatalError("NO PIXMAP PRIVATE\n");
566 priv
->flags
|= PIPE_TEXTURE_USAGE_DISPLAY_TARGET
;
572 xorg_exa_get_pixmap_handle(PixmapPtr pPixmap
, unsigned *stride_out
)
574 ScreenPtr pScreen
= pPixmap
->drawable
.pScreen
;
575 ScrnInfoPtr pScrn
= xf86Screens
[pScreen
->myNum
];
576 modesettingPtr ms
= modesettingPTR(pScrn
);
577 struct exa_pixmap_priv
*priv
;
582 FatalError("NO MS->EXA\n");
586 priv
= exaGetPixmapDriverPrivate(pPixmap
);
589 FatalError("NO PIXMAP PRIVATE\n");
593 ms
->api
->local_handle_from_texture(ms
->api
, ms
->screen
, priv
->tex
, &stride
, &handle
);
595 *stride_out
= stride
;
601 ExaModifyPixmapHeader(PixmapPtr pPixmap
, int width
, int height
,
602 int depth
, int bitsPerPixel
, int devKind
,
605 ScreenPtr pScreen
= pPixmap
->drawable
.pScreen
;
606 ScrnInfoPtr pScrn
= xf86Screens
[pScreen
->myNum
];
607 struct exa_pixmap_priv
*priv
= exaGetPixmapDriverPrivate(pPixmap
);
608 modesettingPtr ms
= modesettingPTR(pScrn
);
609 struct exa_context
*exa
= ms
->exa
;
611 if (!priv
|| pPixData
)
615 depth
= pPixmap
->drawable
.depth
;
617 if (bitsPerPixel
<= 0)
618 bitsPerPixel
= pPixmap
->drawable
.bitsPerPixel
;
621 width
= pPixmap
->drawable
.width
;
624 height
= pPixmap
->drawable
.height
;
626 if (width
<= 0 || height
<= 0 || depth
<= 0)
629 miModifyPixmapHeader(pPixmap
, width
, height
, depth
,
630 bitsPerPixel
, devKind
, NULL
);
632 /* Deal with screen resize */
634 (priv
->tex
->width
[0] != width
||
635 priv
->tex
->height
[0] != height
||
636 priv
->tex_flags
!= priv
->flags
)) {
637 struct pipe_texture
*texture
= NULL
;
638 struct pipe_texture
template;
640 memset(&template, 0, sizeof(template));
641 template.target
= PIPE_TEXTURE_2D
;
642 exa_get_pipe_format(depth
, &template.format
, &bitsPerPixel
);
643 pf_get_block(template.format
, &template.block
);
644 template.width
[0] = width
;
645 template.height
[0] = height
;
646 template.depth
[0] = 1;
647 template.last_level
= 0;
648 template.tex_usage
= PIPE_TEXTURE_USAGE_RENDER_TARGET
| priv
->flags
;
649 priv
->tex_flags
= priv
->flags
;
650 texture
= exa
->scrn
->texture_create(exa
->scrn
, &template);
653 struct pipe_surface
*dst_surf
;
654 struct pipe_surface
*src_surf
;
656 dst_surf
= exa
->scrn
->get_tex_surface(
657 exa
->scrn
, texture
, 0, 0, 0, PIPE_BUFFER_USAGE_GPU_WRITE
);
658 src_surf
= xorg_gpu_surface(exa
->pipe
->screen
, priv
);
659 if (exa
->pipe
->surface_copy
) {
660 exa
->pipe
->surface_copy(exa
->pipe
, dst_surf
, 0, 0, src_surf
,
661 0, 0, min(width
, texture
->width
[0]),
662 min(height
, texture
->height
[0]));
664 util_surface_copy(exa
->pipe
, FALSE
, dst_surf
, 0, 0, src_surf
,
665 0, 0, min(width
, texture
->width
[0]),
666 min(height
, texture
->height
[0]));
668 exa
->scrn
->tex_surface_destroy(dst_surf
);
669 exa
->scrn
->tex_surface_destroy(src_surf
);
672 pipe_texture_reference(&priv
->tex
, texture
);
673 /* the texture we create has one reference */
674 pipe_texture_reference(&texture
, NULL
);
680 struct pipe_texture
*
681 xorg_exa_get_texture(PixmapPtr pPixmap
)
683 struct exa_pixmap_priv
*priv
= exaGetPixmapDriverPrivate(pPixmap
);
684 struct pipe_texture
*tex
= NULL
;
685 pipe_texture_reference(&tex
, priv
->tex
);
690 xorg_exa_set_texture(PixmapPtr pPixmap
, struct pipe_texture
*tex
)
692 struct exa_pixmap_priv
*priv
= exaGetPixmapDriverPrivate(pPixmap
);
694 int mask
= PIPE_TEXTURE_USAGE_PRIMARY
| PIPE_TEXTURE_USAGE_DISPLAY_TARGET
;
699 if (pPixmap
->drawable
.width
!= tex
->width
[0] ||
700 pPixmap
->drawable
.height
!= tex
->height
[0])
703 pipe_texture_reference(&priv
->tex
, tex
);
704 priv
->tex_flags
= tex
->tex_usage
& mask
;
709 struct pipe_texture
*
710 xorg_exa_create_root_texture(ScrnInfoPtr pScrn
,
711 int width
, int height
,
712 int depth
, int bitsPerPixel
)
714 modesettingPtr ms
= modesettingPTR(pScrn
);
715 struct exa_context
*exa
= ms
->exa
;
716 struct pipe_texture
template;
718 memset(&template, 0, sizeof(template));
719 template.target
= PIPE_TEXTURE_2D
;
720 exa_get_pipe_format(depth
, &template.format
, &bitsPerPixel
);
721 pf_get_block(template.format
, &template.block
);
722 template.width
[0] = width
;
723 template.height
[0] = height
;
724 template.depth
[0] = 1;
725 template.last_level
= 0;
726 template.tex_usage
|= PIPE_TEXTURE_USAGE_RENDER_TARGET
;
727 template.tex_usage
|= PIPE_TEXTURE_USAGE_PRIMARY
;
728 template.tex_usage
|= PIPE_TEXTURE_USAGE_DISPLAY_TARGET
;
730 return exa
->scrn
->texture_create(exa
->scrn
, &template);
734 xorg_exa_close(ScrnInfoPtr pScrn
)
736 modesettingPtr ms
= modesettingPTR(pScrn
);
737 struct exa_context
*exa
= ms
->exa
;
739 renderer_destroy(exa
->renderer
);
742 exa
->pipe
->destroy(exa
->pipe
);
744 exaDriverFini(pScrn
->pScreen
);
750 xorg_exa_init(ScrnInfoPtr pScrn
)
752 modesettingPtr ms
= modesettingPTR(pScrn
);
753 struct exa_context
*exa
;
756 exa
= xcalloc(1, sizeof(struct exa_context
));
760 pExa
= exaDriverAlloc();
765 memset(pExa
, 0, sizeof(*pExa
));
769 pExa
->memoryBase
= 0;
770 pExa
->memorySize
= 0;
771 pExa
->offScreenBase
= 0;
772 pExa
->pixmapOffsetAlign
= 0;
773 pExa
->pixmapPitchAlign
= 1;
774 pExa
->flags
= EXA_OFFSCREEN_PIXMAPS
| EXA_HANDLES_PIXMAPS
;
775 #ifdef EXA_SUPPORTS_PREPARE_AUX
776 pExa
->flags
|= EXA_SUPPORTS_PREPARE_AUX
;
778 #ifdef EXA_MIXED_PIXMAPS
779 pExa
->flags
|= EXA_MIXED_PIXMAPS
;
781 pExa
->maxX
= 8191; /* FIXME */
782 pExa
->maxY
= 8191; /* FIXME */
784 pExa
->WaitMarker
= ExaWaitMarker
;
785 pExa
->MarkSync
= ExaMarkSync
;
786 pExa
->PrepareSolid
= ExaPrepareSolid
;
787 pExa
->Solid
= ExaSolid
;
788 pExa
->DoneSolid
= ExaDone
;
789 pExa
->PrepareCopy
= ExaPrepareCopy
;
790 pExa
->Copy
= ExaCopy
;
791 pExa
->DoneCopy
= ExaDone
;
792 pExa
->CheckComposite
= ExaCheckComposite
;
793 pExa
->PrepareComposite
= ExaPrepareComposite
;
794 pExa
->Composite
= ExaComposite
;
795 pExa
->DoneComposite
= ExaDoneComposite
;
796 pExa
->PixmapIsOffscreen
= ExaPixmapIsOffscreen
;
797 pExa
->DownloadFromScreen
= ExaDownloadFromScreen
;
798 pExa
->UploadToScreen
= ExaUploadToScreen
;
799 pExa
->PrepareAccess
= ExaPrepareAccess
;
800 pExa
->FinishAccess
= ExaFinishAccess
;
801 pExa
->CreatePixmap
= ExaCreatePixmap
;
802 pExa
->DestroyPixmap
= ExaDestroyPixmap
;
803 pExa
->ModifyPixmapHeader
= ExaModifyPixmapHeader
;
805 if (!exaDriverInit(pScrn
->pScreen
, pExa
)) {
809 exa
->scrn
= ms
->screen
;
810 exa
->pipe
= ms
->api
->create_context(ms
->api
, exa
->scrn
);
811 /* Share context with DRI */
814 exa
->renderer
= renderer_create(exa
->pipe
);
819 xorg_exa_close(pScrn
);
824 struct pipe_surface
*
825 xorg_gpu_surface(struct pipe_screen
*scrn
, struct exa_pixmap_priv
*priv
)
827 return scrn
->get_tex_surface(scrn
, priv
->tex
, 0, 0, 0,
828 PIPE_BUFFER_USAGE_GPU_READ
|
829 PIPE_BUFFER_USAGE_GPU_WRITE
);
833 void xorg_exa_flush(struct exa_context
*exa
, uint pipeFlushFlags
,
834 struct pipe_fence_handle
**fence
)
836 exa
->pipe
->flush(exa
->pipe
, pipeFlushFlags
, fence
);
839 void xorg_exa_finish(struct exa_context
*exa
)
841 struct pipe_fence_handle
*fence
= NULL
;
843 xorg_exa_flush(exa
, PIPE_FLUSH_RENDER_CACHE
, &fence
);
845 exa
->pipe
->screen
->fence_finish(exa
->pipe
->screen
, fence
, 0);
846 exa
->pipe
->screen
->fence_reference(exa
->pipe
->screen
, &fence
, NULL
);