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;
114 if (!NV50EXA2DSurfaceFormat(ppix, &fmt))
117 bo_flags = NOUVEAU_BO_VRAM;
118 bo_flags |= is_src ? NOUVEAU_BO_RD : NOUVEAU_BO_WR;
120 if (exaGetPixmapOffset(ppix) < pNv->EXADriverPtr->offScreenBase) {
121 BEGIN_RING(chan, eng2d, mthd, 2);
122 OUT_RING (chan, fmt);
124 BEGIN_RING(chan, eng2d, mthd + 0x14, 1);
125 OUT_RING (chan, (uint32_t)exaGetPixmapPitch(ppix));
127 BEGIN_RING(chan, eng2d, mthd, 5);
128 OUT_RING (chan, fmt);
135 BEGIN_RING(chan, eng2d, mthd + 0x18, 4);
136 OUT_RING (chan, ppix->drawable.width);
137 OUT_RING (chan, ppix->drawable.height);
138 OUT_PIXMAPh(chan, ppix, 0, bo_flags);
139 OUT_PIXMAPl(chan, ppix, 0, bo_flags);
142 NV50EXASetClip(ppix, 0, 0, ppix->drawable.width, ppix->drawable.height);
148 NV50EXASetPattern(PixmapPtr pdpix, int col0, int col1, int pat0, int pat1)
150 NV50EXA_LOCALS(pdpix);
152 BEGIN_RING(chan, eng2d, NV50_2D_PATTERN_COLOR(0), 4);
153 OUT_RING (chan, col0);
154 OUT_RING (chan, col1);
155 OUT_RING (chan, pat0);
156 OUT_RING (chan, pat1);
160 NV50EXASetROP(PixmapPtr pdpix, int alu, Pixel planemask)
162 NV50EXA_LOCALS(pdpix);
166 rop = NVROP[alu].copy_planemask;
168 rop = NVROP[alu].copy;
170 BEGIN_RING(chan, eng2d, NV50_2D_OPERATION, 1);
171 if (alu == GXcopy && planemask == ~0) {
172 OUT_RING (chan, NV50_2D_OPERATION_SRCCOPY);
175 OUT_RING (chan, NV50_2D_OPERATION_SRCCOPY_PREMULT);
178 BEGIN_RING(chan, eng2d, NV50_2D_PATTERN_FORMAT, 2);
179 switch (pdpix->drawable.depth) {
180 case 8: OUT_RING (chan, 3); break;
181 case 15: OUT_RING (chan, 1); break;
182 case 16: OUT_RING (chan, 0); break;
191 /* There are 16 alu's.
193 * 16-31: copy_planemask
196 if (planemask != ~0) {
198 NV50EXASetPattern(pdpix, 0, planemask, ~0, ~0);
200 if (pNv->currentRop > 15)
201 NV50EXASetPattern(pdpix, ~0, ~0, ~0, ~0);
204 if (pNv->currentRop != alu) {
205 BEGIN_RING(chan, eng2d, NV50_2D_ROP, 1);
206 OUT_RING (chan, rop);
207 pNv->currentRop = alu;
212 NV50EXAPrepareSolid(PixmapPtr pdpix, int alu, Pixel planemask, Pixel fg)
214 NV50EXA_LOCALS(pdpix);
217 planemask |= ~0 << pScrn->depth;
219 if (!NV50EXA2DSurfaceFormat(pdpix, &fmt))
220 NOUVEAU_FALLBACK("rect format\n");
221 if (!NV50EXAAcquireSurface2D(pdpix, 0))
222 NOUVEAU_FALLBACK("dest pixmap\n");
223 NV50EXASetROP(pdpix, alu, planemask);
225 BEGIN_RING(chan, eng2d, 0x580, 3);
227 OUT_RING (chan, fmt);
234 NV50EXASolid(PixmapPtr pdpix, int x1, int y1, int x2, int y2)
236 NV50EXA_LOCALS(pdpix);
238 BEGIN_RING(chan, eng2d, NV50_2D_RECT_X1, 4);
244 if((x2 - x1) * (y2 - y1) >= 512)
249 NV50EXADoneSolid(PixmapPtr pdpix)
254 NV50EXAPrepareCopy(PixmapPtr pspix, PixmapPtr pdpix, int dx, int dy,
255 int alu, Pixel planemask)
257 NV50EXA_LOCALS(pdpix);
259 planemask |= ~0 << pScrn->depth;
261 if (!NV50EXAAcquireSurface2D(pspix, 1))
262 NOUVEAU_FALLBACK("src pixmap\n");
263 if (!NV50EXAAcquireSurface2D(pdpix, 0))
264 NOUVEAU_FALLBACK("dest pixmap\n");
265 NV50EXASetROP(pdpix, alu, planemask);
271 NV50EXACopy(PixmapPtr pdpix, int srcX , int srcY,
273 int width, int height)
275 NV50EXA_LOCALS(pdpix);
277 BEGIN_RING(chan, eng2d, 0x0110, 1);
279 BEGIN_RING(chan, eng2d, 0x088c, 1);
281 BEGIN_RING(chan, eng2d, NV50_2D_BLIT_DST_X, 12);
282 OUT_RING (chan, dstX);
283 OUT_RING (chan, dstY);
284 OUT_RING (chan, width);
285 OUT_RING (chan, height);
291 OUT_RING (chan, srcX);
293 OUT_RING (chan, srcY);
295 if(width * height >= 512)
300 NV50EXADoneCopy(PixmapPtr pdpix)
305 NV50EXAUploadSIFC(const char *src, int src_pitch,
306 PixmapPtr pdpix, int x, int y, int w, int h, int cpp)
308 NV50EXA_LOCALS(pdpix);
309 int line_dwords = (w * cpp + 3) / 4;
312 if (!NV50EXA2DSurfaceFormat(pdpix, &sifc_fmt))
313 NOUVEAU_FALLBACK("hostdata format\n");
314 if (!NV50EXAAcquireSurface2D(pdpix, 0))
315 NOUVEAU_FALLBACK("dest pixmap\n");
317 /* If the pitch isn't aligned to a dword, then you can get corruption at the end of a line. */
318 NV50EXASetClip(pdpix, x, y, w, h);
320 BEGIN_RING(chan, eng2d, NV50_2D_OPERATION, 1);
321 OUT_RING (chan, NV50_2D_OPERATION_SRCCOPY);
322 BEGIN_RING(chan, eng2d, NV50_2D_SIFC_UNK0800, 2);
324 OUT_RING (chan, sifc_fmt);
325 BEGIN_RING(chan, eng2d, NV50_2D_SIFC_WIDTH, 10);
326 OUT_RING (chan, (line_dwords * 4) / cpp);
338 int count = line_dwords;
342 int size = count > 1792 ? 1792 : count;
344 BEGIN_RING(chan, eng2d,
345 NV50_2D_SIFC_DATA | 0x40000000, size);
346 OUT_RINGp (chan, p, size);
359 NV50EXACheckRenderTarget(PicturePtr ppict)
361 if (ppict->pDrawable->width > 8192 ||
362 ppict->pDrawable->height > 8192)
363 NOUVEAU_FALLBACK("render target dimensions exceeded %dx%d\n",
364 ppict->pDrawable->width,
365 ppict->pDrawable->height);
367 switch (ppict->format) {
374 NOUVEAU_FALLBACK("picture format 0x%08x\n", ppict->format);
381 NV50EXARenderTarget(PixmapPtr ppix, PicturePtr ppict)
383 NV50EXA_LOCALS(ppix);
386 /*XXX: Scanout buffer not tiled, someone needs to figure it out */
387 if (exaGetPixmapOffset(ppix) < pNv->EXADriverPtr->offScreenBase)
388 NOUVEAU_FALLBACK("pixmap is scanout buffer\n");
390 switch (ppict->format) {
391 case PICT_a8r8g8b8: format = NV50TCL_RT_FORMAT_32BPP; break;
392 case PICT_x8r8g8b8: format = NV50TCL_RT_FORMAT_24BPP; break;
393 case PICT_r5g6b5 : format = NV50TCL_RT_FORMAT_16BPP; break;
394 case PICT_a8 : format = NV50TCL_RT_FORMAT_8BPP; break;
396 NOUVEAU_FALLBACK("invalid picture format\n");
399 BEGIN_RING(chan, tesla, NV50TCL_RT_ADDRESS_HIGH(0), 5);
400 OUT_PIXMAPh(chan, ppix, 0, NOUVEAU_BO_VRAM | NOUVEAU_BO_WR);
401 OUT_PIXMAPl(chan, ppix, 0, NOUVEAU_BO_VRAM | NOUVEAU_BO_WR);
402 OUT_RING (chan, format);
404 OUT_RING (chan, 0x00000000);
405 BEGIN_RING(chan, tesla, NV50TCL_RT_HORIZ(0), 2);
406 OUT_RING (chan, ppix->drawable.width);
407 OUT_RING (chan, ppix->drawable.height);
408 BEGIN_RING(chan, tesla, 0x1224, 1);
409 OUT_RING (chan, 0x00000001);
415 NV50EXACheckTexture(PicturePtr ppict)
417 if (ppict->pDrawable->width > 8192 ||
418 ppict->pDrawable->height > 8192)
419 NOUVEAU_FALLBACK("texture dimensions exceeded %dx%d\n",
420 ppict->pDrawable->width,
421 ppict->pDrawable->height);
423 switch (ppict->format) {
432 NOUVEAU_FALLBACK("picture format 0x%08x\n", ppict->format);
435 switch (ppict->filter) {
436 case PictFilterNearest:
437 case PictFilterBilinear:
440 NOUVEAU_FALLBACK("picture filter %d\n", ppict->filter);
447 NV50EXATexture(PixmapPtr ppix, PicturePtr ppict, unsigned unit)
449 NV50EXA_LOCALS(ppix);
451 /*XXX: Scanout buffer not tiled, someone needs to figure it out */
452 if (exaGetPixmapOffset(ppix) < pNv->EXADriverPtr->offScreenBase)
453 NOUVEAU_FALLBACK("pixmap is scanout buffer\n");
455 BEGIN_RING(chan, tesla, NV50TCL_CB_ADDR, 1);
456 OUT_RING (chan, CB_TIC | ((unit * 8) << NV50TCL_CB_ADDR_ID_SHIFT));
457 BEGIN_RING(chan, tesla, NV50TCL_CB_DATA(0) | 0x40000000, 8);
458 switch (ppict->format) {
460 OUT_RING (chan, NV50TIC_0_0_MAPA_C3 | NV50TIC_0_0_TYPEA_UNORM |
461 NV50TIC_0_0_MAPR_C0 | NV50TIC_0_0_TYPER_UNORM |
462 NV50TIC_0_0_MAPG_C1 | NV50TIC_0_0_TYPEB_UNORM |
463 NV50TIC_0_0_MAPB_C2 | NV50TIC_0_0_TYPEG_UNORM |
464 NV50TIC_0_0_FMT_8_8_8_8);
467 OUT_RING (chan, NV50TIC_0_0_MAPA_C3 | NV50TIC_0_0_TYPEA_UNORM |
468 NV50TIC_0_0_MAPR_C2 | NV50TIC_0_0_TYPER_UNORM |
469 NV50TIC_0_0_MAPG_C1 | NV50TIC_0_0_TYPEB_UNORM |
470 NV50TIC_0_0_MAPB_C0 | NV50TIC_0_0_TYPEG_UNORM |
471 NV50TIC_0_0_FMT_8_8_8_8);
474 OUT_RING (chan, NV50TIC_0_0_MAPA_ONE | NV50TIC_0_0_TYPEA_UNORM |
475 NV50TIC_0_0_MAPR_C0 | NV50TIC_0_0_TYPER_UNORM |
476 NV50TIC_0_0_MAPG_C1 | NV50TIC_0_0_TYPEB_UNORM |
477 NV50TIC_0_0_MAPB_C2 | NV50TIC_0_0_TYPEG_UNORM |
478 NV50TIC_0_0_FMT_8_8_8_8);
481 OUT_RING (chan, NV50TIC_0_0_MAPA_ONE | NV50TIC_0_0_TYPEA_UNORM |
482 NV50TIC_0_0_MAPR_C2 | NV50TIC_0_0_TYPER_UNORM |
483 NV50TIC_0_0_MAPG_C1 | NV50TIC_0_0_TYPEB_UNORM |
484 NV50TIC_0_0_MAPB_C0 | NV50TIC_0_0_TYPEG_UNORM |
485 NV50TIC_0_0_FMT_8_8_8_8);
488 OUT_RING (chan, NV50TIC_0_0_MAPA_ONE | NV50TIC_0_0_TYPEA_UNORM |
489 NV50TIC_0_0_MAPR_C0 | NV50TIC_0_0_TYPER_UNORM |
490 NV50TIC_0_0_MAPG_C1 | NV50TIC_0_0_TYPEB_UNORM |
491 NV50TIC_0_0_MAPB_C2 | NV50TIC_0_0_TYPEG_UNORM |
492 NV50TIC_0_0_FMT_5_6_5);
495 OUT_RING (chan, NV50TIC_0_0_MAPA_C0 | NV50TIC_0_0_TYPEA_UNORM |
496 NV50TIC_0_0_MAPR_ZERO | NV50TIC_0_0_TYPER_UNORM |
497 NV50TIC_0_0_MAPG_ZERO | NV50TIC_0_0_TYPEB_UNORM |
498 NV50TIC_0_0_MAPB_ZERO | NV50TIC_0_0_TYPEG_UNORM |
502 NOUVEAU_FALLBACK("invalid picture format, this SHOULD NOT HAPPEN. Expect trouble.\n");
504 OUT_PIXMAPl(chan, ppix, 0, NOUVEAU_BO_VRAM | NOUVEAU_BO_RD);
505 OUT_RING (chan, 0xd0005000);
506 OUT_RING (chan, 0x00300000);
507 OUT_RING (chan, ppix->drawable.width);
508 OUT_RING (chan, (1 << NV50TIC_0_5_DEPTH_SHIFT) | ppix->drawable.height);
509 OUT_RING (chan, 0x03000000);
510 OUT_PIXMAPh(chan, ppix, 0, NOUVEAU_BO_VRAM | NOUVEAU_BO_RD);
512 BEGIN_RING(chan, tesla, NV50TCL_CB_ADDR, 1);
513 OUT_RING (chan, CB_TSC | ((unit * 8) << NV50TCL_CB_ADDR_ID_SHIFT));
514 BEGIN_RING(chan, tesla, NV50TCL_CB_DATA(0) | 0x40000000, 8);
516 switch (ppict->repeatType) {
518 OUT_RING (chan, NV50TSC_1_0_WRAPS_CLAMP |
519 NV50TSC_1_0_WRAPT_CLAMP |
520 NV50TSC_1_0_WRAPR_CLAMP | 0x00024000);
523 OUT_RING (chan, NV50TSC_1_0_WRAPS_MIRROR_REPEAT |
524 NV50TSC_1_0_WRAPT_MIRROR_REPEAT |
525 NV50TSC_1_0_WRAPR_MIRROR_REPEAT | 0x00024000);
529 OUT_RING (chan, NV50TSC_1_0_WRAPS_REPEAT |
530 NV50TSC_1_0_WRAPT_REPEAT |
531 NV50TSC_1_0_WRAPR_REPEAT | 0x00024000);
535 OUT_RING (chan, NV50TSC_1_0_WRAPS_CLAMP_TO_BORDER |
536 NV50TSC_1_0_WRAPT_CLAMP_TO_BORDER |
537 NV50TSC_1_0_WRAPR_CLAMP_TO_BORDER | 0x00024000);
539 if (ppict->filter == PictFilterBilinear) {
540 OUT_RING (chan, NV50TSC_1_1_MAGF_LINEAR |
541 NV50TSC_1_1_MINF_LINEAR |
542 NV50TSC_1_1_MIPF_NONE);
544 OUT_RING (chan, NV50TSC_1_1_MAGF_NEAREST |
545 NV50TSC_1_1_MINF_NEAREST |
546 NV50TSC_1_1_MIPF_NONE);
548 OUT_RING (chan, 0x00000000);
549 OUT_RING (chan, 0x00000000);
550 OUT_RING (chan, 0x00000000);
551 OUT_RING (chan, 0x00000000);
552 OUT_RING (chan, 0x00000000);
553 OUT_RING (chan, 0x00000000);
555 state->unit[unit].width = ppix->drawable.width;
556 state->unit[unit].height = ppix->drawable.height;
557 state->unit[unit].transform = ppict->transform;
562 NV50EXACheckBlend(int op)
565 NOUVEAU_FALLBACK("unsupported blend op %d\n", op);
570 NV50EXABlend(PixmapPtr ppix, PicturePtr ppict, int op, int component_alpha)
572 NV50EXA_LOCALS(ppix);
573 struct nv50_blend_op *b = &NV50EXABlendOp[op];
574 unsigned sblend = b->src_blend;
575 unsigned dblend = b->dst_blend;
578 if (!PICT_FORMAT_A(ppict->format)) {
579 if (sblend == BF(DST_ALPHA))
582 if (sblend == BF(ONE_MINUS_DST_ALPHA))
585 if (ppict->format == PICT_a8) {
586 if (sblend == BF(DST_ALPHA))
587 sblend = BF(DST_COLOR);
589 if (sblend == BF(ONE_MINUS_DST_ALPHA))
590 sblend = BF(ONE_MINUS_DST_COLOR);
594 if (b->src_alpha && (component_alpha || ppict->format == PICT_a8)) {
595 if (dblend == BF(SRC_ALPHA))
596 dblend = BF(SRC_COLOR);
598 if (dblend == BF(ONE_MINUS_SRC_ALPHA))
599 dblend = BF(ONE_MINUS_SRC_COLOR);
602 if (sblend == BF(ONE) && dblend == BF(ZERO)) {
603 BEGIN_RING(chan, tesla, NV50TCL_BLEND_ENABLE(0), 1);
606 BEGIN_RING(chan, tesla, NV50TCL_BLEND_ENABLE(0), 1);
608 BEGIN_RING(chan, tesla, NV50TCL_BLEND_EQUATION_RGB, 5);
609 OUT_RING (chan, NV50TCL_BLEND_EQUATION_RGB_FUNC_ADD);
610 OUT_RING (chan, sblend);
611 OUT_RING (chan, dblend);
612 OUT_RING (chan, NV50TCL_BLEND_EQUATION_ALPHA_FUNC_ADD);
613 OUT_RING (chan, sblend);
614 BEGIN_RING(chan, tesla, NV50TCL_BLEND_FUNC_DST_ALPHA, 1);
615 OUT_RING (chan, dblend);
620 NV50EXACheckComposite(int op,
621 PicturePtr pspict, PicturePtr pmpict, PicturePtr pdpict)
623 if (!NV50EXACheckBlend(op))
624 NOUVEAU_FALLBACK("blend not supported\n");
626 if (!NV50EXACheckRenderTarget(pdpict))
627 NOUVEAU_FALLBACK("render target invalid\n");
629 if (!NV50EXACheckTexture(pspict))
630 NOUVEAU_FALLBACK("src picture invalid\n");
633 if (pmpict->componentAlpha &&
634 PICT_FORMAT_RGB(pmpict->format) &&
635 NV50EXABlendOp[op].src_alpha &&
636 NV50EXABlendOp[op].src_blend != BF(ZERO))
637 NOUVEAU_FALLBACK("component-alpha not supported\n");
639 if (!NV50EXACheckTexture(pmpict))
640 NOUVEAU_FALLBACK("mask picture invalid\n");
647 NV50EXAPrepareComposite(int op,
648 PicturePtr pspict, PicturePtr pmpict, PicturePtr pdpict,
649 PixmapPtr pspix, PixmapPtr pmpix, PixmapPtr pdpix)
651 NV50EXA_LOCALS(pspix);
653 BEGIN_RING(chan, eng2d, 0x0110, 1);
656 if (!NV50EXARenderTarget(pdpix, pdpict))
657 NOUVEAU_FALLBACK("render target invalid\n");
659 NV50EXABlend(pdpix, pdpict, op, pmpict && pmpict->componentAlpha &&
660 PICT_FORMAT_RGB(pmpict->format));
663 if (!NV50EXATexture(pspix, pspict, 0))
664 NOUVEAU_FALLBACK("src picture invalid\n");
665 if (!NV50EXATexture(pmpix, pmpict, 1))
666 NOUVEAU_FALLBACK("mask picture invalid\n");
667 state->have_mask = TRUE;
669 BEGIN_RING(chan, tesla, NV50TCL_FP_START_ID, 1);
670 if (pdpict->format == PICT_a8) {
671 OUT_RING (chan, PFP_C_A8);
673 if (pmpict->componentAlpha &&
674 PICT_FORMAT_RGB(pmpict->format)) {
675 if (NV50EXABlendOp[op].src_alpha)
676 OUT_RING (chan, PFP_CCASA);
678 OUT_RING (chan, PFP_CCA);
680 OUT_RING (chan, PFP_C);
684 if (!NV50EXATexture(pspix, pspict, 0))
685 NOUVEAU_FALLBACK("src picture invalid\n");
686 state->have_mask = FALSE;
688 BEGIN_RING(chan, tesla, NV50TCL_FP_START_ID, 1);
689 if (pdpict->format == PICT_a8)
690 OUT_RING (chan, PFP_S_A8);
692 OUT_RING (chan, PFP_S);
695 BEGIN_RING(chan, tesla, 0x1334, 1);
698 BEGIN_RING(chan, tesla, 0x1458, 1);
700 BEGIN_RING(chan, tesla, 0x1458, 1);
701 OUT_RING (chan, 0x203);
703 BEGIN_RING(chan, tesla, NV50TCL_VERTEX_BEGIN, 1);
704 OUT_RING (chan, NV50TCL_VERTEX_BEGIN_QUADS);
709 #define xFixedToFloat(v) \
710 ((float)xFixedToInt((v)) + ((float)xFixedFrac(v) / 65536.0))
712 NV50EXATransform(PictTransformPtr t, int x, int y, float sx, float sy,
713 float *x_ret, float *y_ret)
718 v.vector[0] = IntToxFixed(x);
719 v.vector[1] = IntToxFixed(y);
720 v.vector[2] = xFixed1;
721 PictureTransformPoint(t, &v);
722 *x_ret = xFixedToFloat(v.vector[0]) / sx;
723 *y_ret = xFixedToFloat(v.vector[1]) / sy;
725 *x_ret = (float)x / sx;
726 *y_ret = (float)y / sy;
731 NV50EXAComposite(PixmapPtr pdpix, int sx, int sy, int mx, int my,
732 int dx, int dy, int w, int h)
734 NV50EXA_LOCALS(pdpix);
735 float sX0, sX1, sX2, sX3, sY0, sY1, sY2, sY3;
736 unsigned dX0 = dx, dX1 = dx + w, dY0 = dy, dY1 = dy + h;
738 NV50EXATransform(state->unit[0].transform, sx, sy,
739 state->unit[0].width, state->unit[0].height,
741 NV50EXATransform(state->unit[0].transform, sx + w, sy,
742 state->unit[0].width, state->unit[0].height,
744 NV50EXATransform(state->unit[0].transform, sx + w, sy + h,
745 state->unit[0].width, state->unit[0].height,
747 NV50EXATransform(state->unit[0].transform, sx, sy + h,
748 state->unit[0].width, state->unit[0].height,
751 if (state->have_mask) {
752 float mX0, mX1, mX2, mX3, mY0, mY1, mY2, mY3;
754 NV50EXATransform(state->unit[1].transform, mx, my,
755 state->unit[1].width, state->unit[1].height,
757 NV50EXATransform(state->unit[1].transform, mx + w, my,
758 state->unit[1].width, state->unit[1].height,
760 NV50EXATransform(state->unit[1].transform, mx + w, my + h,
761 state->unit[1].width, state->unit[1].height,
763 NV50EXATransform(state->unit[1].transform, mx, my + h,
764 state->unit[1].width, state->unit[1].height,
767 VTX2s(pNv, sX0, sY0, mX0, mY0, dX0, dY0);
768 VTX2s(pNv, sX1, sY1, mX1, mY1, dX1, dY0);
769 VTX2s(pNv, sX2, sY2, mX2, mY2, dX1, dY1);
770 VTX2s(pNv, sX3, sY3, mX3, mY3, dX0, dY1);
772 VTX1s(pNv, sX0, sY0, dX0, dY0);
773 VTX1s(pNv, sX1, sY1, dX1, dY0);
774 VTX1s(pNv, sX2, sY2, dX1, dY1);
775 VTX1s(pNv, sX3, sY3, dX0, dY1);
780 NV50EXADoneComposite(PixmapPtr pdpix)
782 NV50EXA_LOCALS(pdpix);
784 BEGIN_RING(chan, tesla, NV50TCL_VERTEX_END, 1);