2 * Copyright 2007 NVIDIA, Corporation
3 * Copyright 2008 Ben Skeggs
5 * Permission is hereby granted, free of charge, to any person obtaining a
6 * copy of this software and associated documentation files (the "Software"),
7 * to deal in the Software without restriction, including without limitation
8 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
9 * and/or sell copies of the Software, and to permit persons to whom the
10 * Software is furnished to do so, subject to the following conditions:
12 * The above copyright notice and this permission notice shall be included in
13 * all copies or substantial portions of the Software.
15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
18 * THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
19 * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
20 * OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
24 #include "nv_include.h"
27 #include "nv50_accel.h"
28 #include "nv50_texture.h"
30 struct nv50_exa_state {
34 PictTransformPtr transform;
39 static struct nv50_exa_state exa_state;
41 #define NV50EXA_LOCALS(p) \
42 ScrnInfoPtr pScrn = xf86Screens[(p)->drawable.pScreen->myNum]; \
43 NVPtr pNv = NVPTR(pScrn); \
44 struct nouveau_channel *chan = pNv->chan; (void)chan; \
45 struct nouveau_grobj *eng2d = pNv->Nv2D; (void)eng2d; \
46 struct nouveau_grobj *tesla = pNv->Nv3D; (void)tesla; \
47 struct nv50_exa_state *state = &exa_state; (void)state
49 #define BF(f) (NV50TCL_BLEND_FUNC_SRC_RGB_##f | 0x4000)
51 struct nv50_blend_op {
58 static struct nv50_blend_op
60 /* Clear */ { 0, 0, BF( ZERO), BF( ZERO) },
61 /* Src */ { 0, 0, BF( ONE), BF( ZERO) },
62 /* Dst */ { 0, 0, BF( ZERO), BF( ONE) },
63 /* Over */ { 1, 0, BF( ONE), BF(ONE_MINUS_SRC_ALPHA) },
64 /* OverReverse */ { 0, 1, BF(ONE_MINUS_DST_ALPHA), BF( ONE) },
65 /* In */ { 0, 1, BF( DST_ALPHA), BF( ZERO) },
66 /* InReverse */ { 1, 0, BF( ZERO), BF( SRC_ALPHA) },
67 /* Out */ { 0, 1, BF(ONE_MINUS_DST_ALPHA), BF( ZERO) },
68 /* OutReverse */ { 1, 0, BF( ZERO), BF(ONE_MINUS_SRC_ALPHA) },
69 /* Atop */ { 1, 1, BF( DST_ALPHA), BF(ONE_MINUS_SRC_ALPHA) },
70 /* AtopReverse */ { 1, 1, BF(ONE_MINUS_DST_ALPHA), BF( SRC_ALPHA) },
71 /* Xor */ { 1, 1, BF(ONE_MINUS_DST_ALPHA), BF(ONE_MINUS_SRC_ALPHA) },
72 /* Add */ { 0, 0, BF( ONE), BF( ONE) },
76 NV50EXA2DSurfaceFormat(PixmapPtr ppix, uint32_t *fmt)
80 switch (ppix->drawable.depth) {
81 case 8 : *fmt = NV50_2D_SRC_FORMAT_8BPP; break;
82 case 15: *fmt = NV50_2D_SRC_FORMAT_15BPP; break;
83 case 16: *fmt = NV50_2D_SRC_FORMAT_16BPP; break;
84 case 24: *fmt = NV50_2D_SRC_FORMAT_24BPP; break;
85 case 32: *fmt = NV50_2D_SRC_FORMAT_32BPP; break;
87 xf86DrvMsg(pScrn->scrnIndex, X_ERROR,
88 "Unknown surface format for bpp=%d\n",
89 ppix->drawable.depth);
96 static void NV50EXASetClip(PixmapPtr ppix, int x, int y, int w, int h)
100 BEGIN_RING(chan, eng2d, NV50_2D_CLIP_X, 4);
108 NV50EXAAcquireSurface2D(PixmapPtr ppix, int is_src)
110 NV50EXA_LOCALS(ppix);
111 int mthd = is_src ? NV50_2D_SRC_FORMAT : NV50_2D_DST_FORMAT;
112 uint32_t fmt, bo_flags;
113 struct nouveau_pixmap *surf = nouveau_pixmap(ppix);
115 if (!NV50EXA2DSurfaceFormat(ppix, &fmt))
118 bo_flags = NOUVEAU_BO_VRAM;
119 bo_flags |= is_src ? NOUVEAU_BO_RD : NOUVEAU_BO_WR;
121 if (!surf->bo->tiled) {
122 BEGIN_RING(chan, eng2d, mthd, 2);
123 OUT_RING (chan, fmt);
125 BEGIN_RING(chan, eng2d, mthd + 0x14, 1);
126 OUT_RING (chan, (uint32_t)exaGetPixmapPitch(ppix));
128 BEGIN_RING(chan, eng2d, mthd, 5);
129 OUT_RING (chan, fmt);
136 BEGIN_RING(chan, eng2d, mthd + 0x18, 4);
137 OUT_RING (chan, ppix->drawable.width);
138 OUT_RING (chan, ppix->drawable.height);
139 OUT_RELOCh(chan, surf->bo, 0, bo_flags);
140 OUT_RELOCl(chan, surf->bo, 0, bo_flags);
143 NV50EXASetClip(ppix, 0, 0, ppix->drawable.width, ppix->drawable.height);
149 NV50EXASetPattern(PixmapPtr pdpix, int col0, int col1, int pat0, int pat1)
151 NV50EXA_LOCALS(pdpix);
153 BEGIN_RING(chan, eng2d, NV50_2D_PATTERN_COLOR(0), 4);
154 OUT_RING (chan, col0);
155 OUT_RING (chan, col1);
156 OUT_RING (chan, pat0);
157 OUT_RING (chan, pat1);
161 NV50EXASetROP(PixmapPtr pdpix, int alu, Pixel planemask)
163 NV50EXA_LOCALS(pdpix);
167 rop = NVROP[alu].copy_planemask;
169 rop = NVROP[alu].copy;
171 BEGIN_RING(chan, eng2d, NV50_2D_OPERATION, 1);
172 if (alu == GXcopy && planemask == ~0) {
173 OUT_RING (chan, NV50_2D_OPERATION_SRCCOPY);
176 OUT_RING (chan, NV50_2D_OPERATION_SRCCOPY_PREMULT);
179 BEGIN_RING(chan, eng2d, NV50_2D_PATTERN_FORMAT, 2);
180 switch (pdpix->drawable.depth) {
181 case 8: OUT_RING (chan, 3); break;
182 case 15: OUT_RING (chan, 1); break;
183 case 16: OUT_RING (chan, 0); break;
192 /* There are 16 alu's.
194 * 16-31: copy_planemask
197 if (planemask != ~0) {
199 NV50EXASetPattern(pdpix, 0, planemask, ~0, ~0);
201 if (pNv->currentRop > 15)
202 NV50EXASetPattern(pdpix, ~0, ~0, ~0, ~0);
205 if (pNv->currentRop != alu) {
206 BEGIN_RING(chan, eng2d, NV50_2D_ROP, 1);
207 OUT_RING (chan, rop);
208 pNv->currentRop = alu;
213 NV50EXAPrepareSolid(PixmapPtr pdpix, int alu, Pixel planemask, Pixel fg)
215 NV50EXA_LOCALS(pdpix);
218 planemask |= ~0 << pScrn->depth;
220 if (!NV50EXA2DSurfaceFormat(pdpix, &fmt))
221 NOUVEAU_FALLBACK("rect format\n");
222 if (!NV50EXAAcquireSurface2D(pdpix, 0))
223 NOUVEAU_FALLBACK("dest pixmap\n");
224 NV50EXASetROP(pdpix, alu, planemask);
226 BEGIN_RING(chan, eng2d, 0x580, 3);
228 OUT_RING (chan, fmt);
235 NV50EXASolid(PixmapPtr pdpix, int x1, int y1, int x2, int y2)
237 NV50EXA_LOCALS(pdpix);
239 BEGIN_RING(chan, eng2d, NV50_2D_RECT_X1, 4);
245 if((x2 - x1) * (y2 - y1) >= 512)
250 NV50EXADoneSolid(PixmapPtr pdpix)
255 NV50EXAPrepareCopy(PixmapPtr pspix, PixmapPtr pdpix, int dx, int dy,
256 int alu, Pixel planemask)
258 NV50EXA_LOCALS(pdpix);
260 planemask |= ~0 << pScrn->depth;
262 if (!NV50EXAAcquireSurface2D(pspix, 1))
263 NOUVEAU_FALLBACK("src pixmap\n");
264 if (!NV50EXAAcquireSurface2D(pdpix, 0))
265 NOUVEAU_FALLBACK("dest pixmap\n");
266 NV50EXASetROP(pdpix, alu, planemask);
272 NV50EXACopy(PixmapPtr pdpix, int srcX , int srcY,
274 int width, int height)
276 NV50EXA_LOCALS(pdpix);
278 BEGIN_RING(chan, eng2d, 0x0110, 1);
280 BEGIN_RING(chan, eng2d, 0x088c, 1);
282 BEGIN_RING(chan, eng2d, NV50_2D_BLIT_DST_X, 12);
283 OUT_RING (chan, dstX);
284 OUT_RING (chan, dstY);
285 OUT_RING (chan, width);
286 OUT_RING (chan, height);
292 OUT_RING (chan, srcX);
294 OUT_RING (chan, srcY);
296 if(width * height >= 512)
301 NV50EXADoneCopy(PixmapPtr pdpix)
306 NV50EXAUploadSIFC(const char *src, int src_pitch,
307 PixmapPtr pdpix, int x, int y, int w, int h, int cpp)
309 NV50EXA_LOCALS(pdpix);
310 int line_dwords = (w * cpp + 3) / 4;
313 if (!NV50EXA2DSurfaceFormat(pdpix, &sifc_fmt))
314 NOUVEAU_FALLBACK("hostdata format\n");
315 if (!NV50EXAAcquireSurface2D(pdpix, 0))
316 NOUVEAU_FALLBACK("dest pixmap\n");
318 /* If the pitch isn't aligned to a dword, then you can get corruption at the end of a line. */
319 NV50EXASetClip(pdpix, x, y, w, h);
321 BEGIN_RING(chan, eng2d, NV50_2D_OPERATION, 1);
322 OUT_RING (chan, NV50_2D_OPERATION_SRCCOPY);
323 BEGIN_RING(chan, eng2d, NV50_2D_SIFC_UNK0800, 2);
325 OUT_RING (chan, sifc_fmt);
326 BEGIN_RING(chan, eng2d, NV50_2D_SIFC_WIDTH, 10);
327 OUT_RING (chan, (line_dwords * 4) / cpp);
339 int count = line_dwords;
343 int size = count > 1792 ? 1792 : count;
345 BEGIN_RING(chan, eng2d,
346 NV50_2D_SIFC_DATA | 0x40000000, size);
347 OUT_RINGp (chan, p, size);
360 NV50EXACheckRenderTarget(PicturePtr ppict)
362 if (ppict->pDrawable->width > 8192 ||
363 ppict->pDrawable->height > 8192)
364 NOUVEAU_FALLBACK("render target dimensions exceeded %dx%d\n",
365 ppict->pDrawable->width,
366 ppict->pDrawable->height);
368 switch (ppict->format) {
375 NOUVEAU_FALLBACK("picture format 0x%08x\n", ppict->format);
382 NV50EXARenderTarget(PixmapPtr ppix, PicturePtr ppict)
384 NV50EXA_LOCALS(ppix);
386 struct nouveau_pixmap *rt = nouveau_pixmap(ppix);
388 /*XXX: Scanout buffer not tiled, someone needs to figure it out */
390 NOUVEAU_FALLBACK("pixmap is scanout buffer\n");
392 switch (ppict->format) {
393 case PICT_a8r8g8b8: format = NV50TCL_RT_FORMAT_32BPP; break;
394 case PICT_x8r8g8b8: format = NV50TCL_RT_FORMAT_24BPP; break;
395 case PICT_r5g6b5 : format = NV50TCL_RT_FORMAT_16BPP; break;
396 case PICT_a8 : format = NV50TCL_RT_FORMAT_8BPP; break;
398 NOUVEAU_FALLBACK("invalid picture format\n");
401 BEGIN_RING(chan, tesla, NV50TCL_RT_ADDRESS_HIGH(0), 5);
402 OUT_RELOCh(chan, rt->bo, 0, NOUVEAU_BO_VRAM | NOUVEAU_BO_WR);
403 OUT_RELOCl(chan, rt->bo, 0, NOUVEAU_BO_VRAM | NOUVEAU_BO_WR);
404 OUT_RING (chan, format);
406 OUT_RING (chan, 0x00000000);
407 BEGIN_RING(chan, tesla, NV50TCL_RT_HORIZ(0), 2);
408 OUT_RING (chan, ppix->drawable.width);
409 OUT_RING (chan, ppix->drawable.height);
410 BEGIN_RING(chan, tesla, 0x1224, 1);
411 OUT_RING (chan, 0x00000001);
417 NV50EXACheckTexture(PicturePtr ppict)
419 if (ppict->pDrawable->width > 8192 ||
420 ppict->pDrawable->height > 8192)
421 NOUVEAU_FALLBACK("texture dimensions exceeded %dx%d\n",
422 ppict->pDrawable->width,
423 ppict->pDrawable->height);
425 switch (ppict->format) {
434 NOUVEAU_FALLBACK("picture format 0x%08x\n", ppict->format);
437 switch (ppict->filter) {
438 case PictFilterNearest:
439 case PictFilterBilinear:
442 NOUVEAU_FALLBACK("picture filter %d\n", ppict->filter);
449 NV50EXATexture(PixmapPtr ppix, PicturePtr ppict, unsigned unit)
451 NV50EXA_LOCALS(ppix);
452 struct nouveau_pixmap *tex = nouveau_pixmap(ppix);
454 /*XXX: Scanout buffer not tiled, someone needs to figure it out */
456 NOUVEAU_FALLBACK("pixmap is scanout buffer\n");
458 BEGIN_RING(chan, tesla, NV50TCL_CB_ADDR, 1);
459 OUT_RING (chan, CB_TIC | ((unit * 8) << NV50TCL_CB_ADDR_ID_SHIFT));
460 BEGIN_RING(chan, tesla, NV50TCL_CB_DATA(0) | 0x40000000, 8);
461 switch (ppict->format) {
463 OUT_RING (chan, NV50TIC_0_0_MAPA_C3 | NV50TIC_0_0_TYPEA_UNORM |
464 NV50TIC_0_0_MAPR_C0 | NV50TIC_0_0_TYPER_UNORM |
465 NV50TIC_0_0_MAPG_C1 | NV50TIC_0_0_TYPEB_UNORM |
466 NV50TIC_0_0_MAPB_C2 | NV50TIC_0_0_TYPEG_UNORM |
467 NV50TIC_0_0_FMT_8_8_8_8);
470 OUT_RING (chan, NV50TIC_0_0_MAPA_C3 | NV50TIC_0_0_TYPEA_UNORM |
471 NV50TIC_0_0_MAPR_C2 | NV50TIC_0_0_TYPER_UNORM |
472 NV50TIC_0_0_MAPG_C1 | NV50TIC_0_0_TYPEB_UNORM |
473 NV50TIC_0_0_MAPB_C0 | NV50TIC_0_0_TYPEG_UNORM |
474 NV50TIC_0_0_FMT_8_8_8_8);
477 OUT_RING (chan, NV50TIC_0_0_MAPA_ONE | NV50TIC_0_0_TYPEA_UNORM |
478 NV50TIC_0_0_MAPR_C0 | NV50TIC_0_0_TYPER_UNORM |
479 NV50TIC_0_0_MAPG_C1 | NV50TIC_0_0_TYPEB_UNORM |
480 NV50TIC_0_0_MAPB_C2 | NV50TIC_0_0_TYPEG_UNORM |
481 NV50TIC_0_0_FMT_8_8_8_8);
484 OUT_RING (chan, NV50TIC_0_0_MAPA_ONE | NV50TIC_0_0_TYPEA_UNORM |
485 NV50TIC_0_0_MAPR_C2 | NV50TIC_0_0_TYPER_UNORM |
486 NV50TIC_0_0_MAPG_C1 | NV50TIC_0_0_TYPEB_UNORM |
487 NV50TIC_0_0_MAPB_C0 | NV50TIC_0_0_TYPEG_UNORM |
488 NV50TIC_0_0_FMT_8_8_8_8);
491 OUT_RING (chan, NV50TIC_0_0_MAPA_ONE | NV50TIC_0_0_TYPEA_UNORM |
492 NV50TIC_0_0_MAPR_C0 | NV50TIC_0_0_TYPER_UNORM |
493 NV50TIC_0_0_MAPG_C1 | NV50TIC_0_0_TYPEB_UNORM |
494 NV50TIC_0_0_MAPB_C2 | NV50TIC_0_0_TYPEG_UNORM |
495 NV50TIC_0_0_FMT_5_6_5);
498 OUT_RING (chan, NV50TIC_0_0_MAPA_C0 | NV50TIC_0_0_TYPEA_UNORM |
499 NV50TIC_0_0_MAPR_ZERO | NV50TIC_0_0_TYPER_UNORM |
500 NV50TIC_0_0_MAPG_ZERO | NV50TIC_0_0_TYPEB_UNORM |
501 NV50TIC_0_0_MAPB_ZERO | NV50TIC_0_0_TYPEG_UNORM |
505 NOUVEAU_FALLBACK("invalid picture format, this SHOULD NOT HAPPEN. Expect trouble.\n");
507 OUT_RELOCl(chan, tex->bo, 0, NOUVEAU_BO_VRAM | NOUVEAU_BO_RD);
508 OUT_RING (chan, 0xd0005000);
509 OUT_RING (chan, 0x00300000);
510 OUT_RING (chan, ppix->drawable.width);
511 OUT_RING (chan, (1 << NV50TIC_0_5_DEPTH_SHIFT) | ppix->drawable.height);
512 OUT_RING (chan, 0x03000000);
513 OUT_RELOCh(chan, tex->bo, 0, NOUVEAU_BO_VRAM | NOUVEAU_BO_RD);
515 BEGIN_RING(chan, tesla, NV50TCL_CB_ADDR, 1);
516 OUT_RING (chan, CB_TSC | ((unit * 8) << NV50TCL_CB_ADDR_ID_SHIFT));
517 BEGIN_RING(chan, tesla, NV50TCL_CB_DATA(0) | 0x40000000, 8);
519 switch (ppict->repeatType) {
521 OUT_RING (chan, NV50TSC_1_0_WRAPS_CLAMP |
522 NV50TSC_1_0_WRAPT_CLAMP |
523 NV50TSC_1_0_WRAPR_CLAMP | 0x00024000);
526 OUT_RING (chan, NV50TSC_1_0_WRAPS_MIRROR_REPEAT |
527 NV50TSC_1_0_WRAPT_MIRROR_REPEAT |
528 NV50TSC_1_0_WRAPR_MIRROR_REPEAT | 0x00024000);
532 OUT_RING (chan, NV50TSC_1_0_WRAPS_REPEAT |
533 NV50TSC_1_0_WRAPT_REPEAT |
534 NV50TSC_1_0_WRAPR_REPEAT | 0x00024000);
538 OUT_RING (chan, NV50TSC_1_0_WRAPS_CLAMP_TO_BORDER |
539 NV50TSC_1_0_WRAPT_CLAMP_TO_BORDER |
540 NV50TSC_1_0_WRAPR_CLAMP_TO_BORDER | 0x00024000);
542 if (ppict->filter == PictFilterBilinear) {
543 OUT_RING (chan, NV50TSC_1_1_MAGF_LINEAR |
544 NV50TSC_1_1_MINF_LINEAR |
545 NV50TSC_1_1_MIPF_NONE);
547 OUT_RING (chan, NV50TSC_1_1_MAGF_NEAREST |
548 NV50TSC_1_1_MINF_NEAREST |
549 NV50TSC_1_1_MIPF_NONE);
551 OUT_RING (chan, 0x00000000);
552 OUT_RING (chan, 0x00000000);
553 OUT_RING (chan, 0x00000000);
554 OUT_RING (chan, 0x00000000);
555 OUT_RING (chan, 0x00000000);
556 OUT_RING (chan, 0x00000000);
558 state->unit[unit].width = ppix->drawable.width;
559 state->unit[unit].height = ppix->drawable.height;
560 state->unit[unit].transform = ppict->transform;
565 NV50EXACheckBlend(int op)
568 NOUVEAU_FALLBACK("unsupported blend op %d\n", op);
573 NV50EXABlend(PixmapPtr ppix, PicturePtr ppict, int op, int component_alpha)
575 NV50EXA_LOCALS(ppix);
576 struct nv50_blend_op *b = &NV50EXABlendOp[op];
577 unsigned sblend = b->src_blend;
578 unsigned dblend = b->dst_blend;
581 if (!PICT_FORMAT_A(ppict->format)) {
582 if (sblend == BF(DST_ALPHA))
585 if (sblend == BF(ONE_MINUS_DST_ALPHA))
588 if (ppict->format == PICT_a8) {
589 if (sblend == BF(DST_ALPHA))
590 sblend = BF(DST_COLOR);
592 if (sblend == BF(ONE_MINUS_DST_ALPHA))
593 sblend = BF(ONE_MINUS_DST_COLOR);
597 if (b->src_alpha && (component_alpha || ppict->format == PICT_a8)) {
598 if (dblend == BF(SRC_ALPHA))
599 dblend = BF(SRC_COLOR);
601 if (dblend == BF(ONE_MINUS_SRC_ALPHA))
602 dblend = BF(ONE_MINUS_SRC_COLOR);
605 if (sblend == BF(ONE) && dblend == BF(ZERO)) {
606 BEGIN_RING(chan, tesla, NV50TCL_BLEND_ENABLE(0), 1);
609 BEGIN_RING(chan, tesla, NV50TCL_BLEND_ENABLE(0), 1);
611 BEGIN_RING(chan, tesla, NV50TCL_BLEND_EQUATION_RGB, 5);
612 OUT_RING (chan, NV50TCL_BLEND_EQUATION_RGB_FUNC_ADD);
613 OUT_RING (chan, sblend);
614 OUT_RING (chan, dblend);
615 OUT_RING (chan, NV50TCL_BLEND_EQUATION_ALPHA_FUNC_ADD);
616 OUT_RING (chan, sblend);
617 BEGIN_RING(chan, tesla, NV50TCL_BLEND_FUNC_DST_ALPHA, 1);
618 OUT_RING (chan, dblend);
623 NV50EXACheckComposite(int op,
624 PicturePtr pspict, PicturePtr pmpict, PicturePtr pdpict)
626 if (!NV50EXACheckBlend(op))
627 NOUVEAU_FALLBACK("blend not supported\n");
629 if (!NV50EXACheckRenderTarget(pdpict))
630 NOUVEAU_FALLBACK("render target invalid\n");
632 if (!NV50EXACheckTexture(pspict))
633 NOUVEAU_FALLBACK("src picture invalid\n");
636 if (pmpict->componentAlpha &&
637 PICT_FORMAT_RGB(pmpict->format) &&
638 NV50EXABlendOp[op].src_alpha &&
639 NV50EXABlendOp[op].src_blend != BF(ZERO))
640 NOUVEAU_FALLBACK("component-alpha not supported\n");
642 if (!NV50EXACheckTexture(pmpict))
643 NOUVEAU_FALLBACK("mask picture invalid\n");
650 NV50EXAPrepareComposite(int op,
651 PicturePtr pspict, PicturePtr pmpict, PicturePtr pdpict,
652 PixmapPtr pspix, PixmapPtr pmpix, PixmapPtr pdpix)
654 NV50EXA_LOCALS(pspix);
656 BEGIN_RING(chan, eng2d, 0x0110, 1);
659 if (!NV50EXARenderTarget(pdpix, pdpict))
660 NOUVEAU_FALLBACK("render target invalid\n");
662 NV50EXABlend(pdpix, pdpict, op, pmpict && pmpict->componentAlpha &&
663 PICT_FORMAT_RGB(pmpict->format));
666 if (!NV50EXATexture(pspix, pspict, 0))
667 NOUVEAU_FALLBACK("src picture invalid\n");
668 if (!NV50EXATexture(pmpix, pmpict, 1))
669 NOUVEAU_FALLBACK("mask picture invalid\n");
670 state->have_mask = TRUE;
672 BEGIN_RING(chan, tesla, NV50TCL_FP_START_ID, 1);
673 if (pdpict->format == PICT_a8) {
674 OUT_RING (chan, PFP_C_A8);
676 if (pmpict->componentAlpha &&
677 PICT_FORMAT_RGB(pmpict->format)) {
678 if (NV50EXABlendOp[op].src_alpha)
679 OUT_RING (chan, PFP_CCASA);
681 OUT_RING (chan, PFP_CCA);
683 OUT_RING (chan, PFP_C);
687 if (!NV50EXATexture(pspix, pspict, 0))
688 NOUVEAU_FALLBACK("src picture invalid\n");
689 state->have_mask = FALSE;
691 BEGIN_RING(chan, tesla, NV50TCL_FP_START_ID, 1);
692 if (pdpict->format == PICT_a8)
693 OUT_RING (chan, PFP_S_A8);
695 OUT_RING (chan, PFP_S);
698 BEGIN_RING(chan, tesla, 0x1334, 1);
701 BEGIN_RING(chan, tesla, 0x1458, 1);
703 BEGIN_RING(chan, tesla, 0x1458, 1);
704 OUT_RING (chan, 0x203);
706 BEGIN_RING(chan, tesla, NV50TCL_VERTEX_BEGIN, 1);
707 OUT_RING (chan, NV50TCL_VERTEX_BEGIN_QUADS);
712 #define xFixedToFloat(v) \
713 ((float)xFixedToInt((v)) + ((float)xFixedFrac(v) / 65536.0))
715 NV50EXATransform(PictTransformPtr t, int x, int y, float sx, float sy,
716 float *x_ret, float *y_ret)
721 v.vector[0] = IntToxFixed(x);
722 v.vector[1] = IntToxFixed(y);
723 v.vector[2] = xFixed1;
724 PictureTransformPoint(t, &v);
725 *x_ret = xFixedToFloat(v.vector[0]) / sx;
726 *y_ret = xFixedToFloat(v.vector[1]) / sy;
728 *x_ret = (float)x / sx;
729 *y_ret = (float)y / sy;
734 NV50EXAComposite(PixmapPtr pdpix, int sx, int sy, int mx, int my,
735 int dx, int dy, int w, int h)
737 NV50EXA_LOCALS(pdpix);
738 float sX0, sX1, sX2, sX3, sY0, sY1, sY2, sY3;
739 unsigned dX0 = dx, dX1 = dx + w, dY0 = dy, dY1 = dy + h;
741 NV50EXATransform(state->unit[0].transform, sx, sy,
742 state->unit[0].width, state->unit[0].height,
744 NV50EXATransform(state->unit[0].transform, sx + w, sy,
745 state->unit[0].width, state->unit[0].height,
747 NV50EXATransform(state->unit[0].transform, sx + w, sy + h,
748 state->unit[0].width, state->unit[0].height,
750 NV50EXATransform(state->unit[0].transform, sx, sy + h,
751 state->unit[0].width, state->unit[0].height,
754 if (state->have_mask) {
755 float mX0, mX1, mX2, mX3, mY0, mY1, mY2, mY3;
757 NV50EXATransform(state->unit[1].transform, mx, my,
758 state->unit[1].width, state->unit[1].height,
760 NV50EXATransform(state->unit[1].transform, mx + w, my,
761 state->unit[1].width, state->unit[1].height,
763 NV50EXATransform(state->unit[1].transform, mx + w, my + h,
764 state->unit[1].width, state->unit[1].height,
766 NV50EXATransform(state->unit[1].transform, mx, my + h,
767 state->unit[1].width, state->unit[1].height,
770 VTX2s(pNv, sX0, sY0, mX0, mY0, dX0, dY0);
771 VTX2s(pNv, sX1, sY1, mX1, mY1, dX1, dY0);
772 VTX2s(pNv, sX2, sY2, mX2, mY2, dX1, dY1);
773 VTX2s(pNv, sX3, sY3, mX3, mY3, dX0, dY1);
775 VTX1s(pNv, sX0, sY0, dX0, dY0);
776 VTX1s(pNv, sX1, sY1, dX1, dY0);
777 VTX1s(pNv, sX2, sY2, dX1, dY1);
778 VTX1s(pNv, sX3, sY3, dX0, dY1);
783 NV50EXADoneComposite(PixmapPtr pdpix)
785 NV50EXA_LOCALS(pdpix);
787 BEGIN_RING(chan, tesla, NV50TCL_VERTEX_END, 1);