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 NOUVEAU_FALLBACK("Unknown surface format for bpp=%d\n",
88 ppix->drawable.depth);
95 static void NV50EXASetClip(PixmapPtr ppix, int x, int y, int w, int h)
99 BEGIN_RING(chan, eng2d, NV50_2D_CLIP_X, 4);
107 NV50EXAAcquireSurface2D(PixmapPtr ppix, int is_src)
109 NV50EXA_LOCALS(ppix);
110 int mthd = is_src ? NV50_2D_SRC_FORMAT : NV50_2D_DST_FORMAT;
111 uint32_t fmt, bo_flags;
112 struct nouveau_pixmap *surf = nouveau_pixmap(ppix);
114 if (!NV50EXA2DSurfaceFormat(ppix, &fmt))
117 bo_flags = NOUVEAU_BO_VRAM;
118 bo_flags |= is_src ? NOUVEAU_BO_RD : NOUVEAU_BO_WR;
120 if (!surf->bo->tiled) {
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_RELOCh(chan, surf->bo, 0, bo_flags);
139 OUT_RELOCl(chan, surf->bo, 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);
385 struct nouveau_pixmap *rt = nouveau_pixmap(ppix);
387 /*XXX: Scanout buffer not tiled, someone needs to figure it out */
389 NOUVEAU_FALLBACK("pixmap is scanout buffer\n");
391 switch (ppict->format) {
392 case PICT_a8r8g8b8: format = NV50TCL_RT_FORMAT_32BPP; break;
393 case PICT_x8r8g8b8: format = NV50TCL_RT_FORMAT_24BPP; break;
394 case PICT_r5g6b5 : format = NV50TCL_RT_FORMAT_16BPP; break;
395 case PICT_a8 : format = NV50TCL_RT_FORMAT_8BPP; break;
397 NOUVEAU_FALLBACK("invalid picture format\n");
400 BEGIN_RING(chan, tesla, NV50TCL_RT_ADDRESS_HIGH(0), 5);
401 OUT_RELOCh(chan, rt->bo, 0, NOUVEAU_BO_VRAM | NOUVEAU_BO_WR);
402 OUT_RELOCl(chan, rt->bo, 0, NOUVEAU_BO_VRAM | NOUVEAU_BO_WR);
403 OUT_RING (chan, format);
405 OUT_RING (chan, 0x00000000);
406 BEGIN_RING(chan, tesla, NV50TCL_RT_HORIZ(0), 2);
407 OUT_RING (chan, ppix->drawable.width);
408 OUT_RING (chan, ppix->drawable.height);
409 BEGIN_RING(chan, tesla, 0x1224, 1);
410 OUT_RING (chan, 0x00000001);
416 NV50EXACheckTexture(PicturePtr ppict)
418 if (ppict->pDrawable->width > 8192 ||
419 ppict->pDrawable->height > 8192)
420 NOUVEAU_FALLBACK("texture dimensions exceeded %dx%d\n",
421 ppict->pDrawable->width,
422 ppict->pDrawable->height);
424 switch (ppict->format) {
433 NOUVEAU_FALLBACK("picture format 0x%08x\n", ppict->format);
436 switch (ppict->filter) {
437 case PictFilterNearest:
438 case PictFilterBilinear:
441 NOUVEAU_FALLBACK("picture filter %d\n", ppict->filter);
448 NV50EXATexture(PixmapPtr ppix, PicturePtr ppict, unsigned unit)
450 NV50EXA_LOCALS(ppix);
451 struct nouveau_pixmap *tex = nouveau_pixmap(ppix);
453 /*XXX: Scanout buffer not tiled, someone needs to figure it out */
455 NOUVEAU_FALLBACK("pixmap is scanout buffer\n");
457 BEGIN_RING(chan, tesla, NV50TCL_CB_ADDR, 1);
458 OUT_RING (chan, CB_TIC | ((unit * 8) << NV50TCL_CB_ADDR_ID_SHIFT));
459 BEGIN_RING(chan, tesla, NV50TCL_CB_DATA(0) | 0x40000000, 8);
460 switch (ppict->format) {
462 OUT_RING (chan, NV50TIC_0_0_MAPA_C3 | NV50TIC_0_0_TYPEA_UNORM |
463 NV50TIC_0_0_MAPR_C0 | NV50TIC_0_0_TYPER_UNORM |
464 NV50TIC_0_0_MAPG_C1 | NV50TIC_0_0_TYPEB_UNORM |
465 NV50TIC_0_0_MAPB_C2 | NV50TIC_0_0_TYPEG_UNORM |
466 NV50TIC_0_0_FMT_8_8_8_8);
469 OUT_RING (chan, NV50TIC_0_0_MAPA_C3 | NV50TIC_0_0_TYPEA_UNORM |
470 NV50TIC_0_0_MAPR_C2 | NV50TIC_0_0_TYPER_UNORM |
471 NV50TIC_0_0_MAPG_C1 | NV50TIC_0_0_TYPEB_UNORM |
472 NV50TIC_0_0_MAPB_C0 | NV50TIC_0_0_TYPEG_UNORM |
473 NV50TIC_0_0_FMT_8_8_8_8);
476 OUT_RING (chan, NV50TIC_0_0_MAPA_ONE | NV50TIC_0_0_TYPEA_UNORM |
477 NV50TIC_0_0_MAPR_C0 | NV50TIC_0_0_TYPER_UNORM |
478 NV50TIC_0_0_MAPG_C1 | NV50TIC_0_0_TYPEB_UNORM |
479 NV50TIC_0_0_MAPB_C2 | NV50TIC_0_0_TYPEG_UNORM |
480 NV50TIC_0_0_FMT_8_8_8_8);
483 OUT_RING (chan, NV50TIC_0_0_MAPA_ONE | NV50TIC_0_0_TYPEA_UNORM |
484 NV50TIC_0_0_MAPR_C2 | NV50TIC_0_0_TYPER_UNORM |
485 NV50TIC_0_0_MAPG_C1 | NV50TIC_0_0_TYPEB_UNORM |
486 NV50TIC_0_0_MAPB_C0 | NV50TIC_0_0_TYPEG_UNORM |
487 NV50TIC_0_0_FMT_8_8_8_8);
490 OUT_RING (chan, NV50TIC_0_0_MAPA_ONE | NV50TIC_0_0_TYPEA_UNORM |
491 NV50TIC_0_0_MAPR_C0 | NV50TIC_0_0_TYPER_UNORM |
492 NV50TIC_0_0_MAPG_C1 | NV50TIC_0_0_TYPEB_UNORM |
493 NV50TIC_0_0_MAPB_C2 | NV50TIC_0_0_TYPEG_UNORM |
494 NV50TIC_0_0_FMT_5_6_5);
497 OUT_RING (chan, NV50TIC_0_0_MAPA_C0 | NV50TIC_0_0_TYPEA_UNORM |
498 NV50TIC_0_0_MAPR_ZERO | NV50TIC_0_0_TYPER_UNORM |
499 NV50TIC_0_0_MAPG_ZERO | NV50TIC_0_0_TYPEB_UNORM |
500 NV50TIC_0_0_MAPB_ZERO | NV50TIC_0_0_TYPEG_UNORM |
504 NOUVEAU_FALLBACK("invalid picture format, this SHOULD NOT HAPPEN. Expect trouble.\n");
506 OUT_RELOCl(chan, tex->bo, 0, NOUVEAU_BO_VRAM | NOUVEAU_BO_RD);
507 OUT_RING (chan, 0xd0005000);
508 OUT_RING (chan, 0x00300000);
509 OUT_RING (chan, ppix->drawable.width);
510 OUT_RING (chan, (1 << NV50TIC_0_5_DEPTH_SHIFT) | ppix->drawable.height);
511 OUT_RING (chan, 0x03000000);
512 OUT_RELOCh(chan, tex->bo, 0, NOUVEAU_BO_VRAM | NOUVEAU_BO_RD);
514 BEGIN_RING(chan, tesla, NV50TCL_CB_ADDR, 1);
515 OUT_RING (chan, CB_TSC | ((unit * 8) << NV50TCL_CB_ADDR_ID_SHIFT));
516 BEGIN_RING(chan, tesla, NV50TCL_CB_DATA(0) | 0x40000000, 8);
518 switch (ppict->repeatType) {
520 OUT_RING (chan, NV50TSC_1_0_WRAPS_CLAMP |
521 NV50TSC_1_0_WRAPT_CLAMP |
522 NV50TSC_1_0_WRAPR_CLAMP | 0x00024000);
525 OUT_RING (chan, NV50TSC_1_0_WRAPS_MIRROR_REPEAT |
526 NV50TSC_1_0_WRAPT_MIRROR_REPEAT |
527 NV50TSC_1_0_WRAPR_MIRROR_REPEAT | 0x00024000);
531 OUT_RING (chan, NV50TSC_1_0_WRAPS_REPEAT |
532 NV50TSC_1_0_WRAPT_REPEAT |
533 NV50TSC_1_0_WRAPR_REPEAT | 0x00024000);
537 OUT_RING (chan, NV50TSC_1_0_WRAPS_CLAMP_TO_BORDER |
538 NV50TSC_1_0_WRAPT_CLAMP_TO_BORDER |
539 NV50TSC_1_0_WRAPR_CLAMP_TO_BORDER | 0x00024000);
541 if (ppict->filter == PictFilterBilinear) {
542 OUT_RING (chan, NV50TSC_1_1_MAGF_LINEAR |
543 NV50TSC_1_1_MINF_LINEAR |
544 NV50TSC_1_1_MIPF_NONE);
546 OUT_RING (chan, NV50TSC_1_1_MAGF_NEAREST |
547 NV50TSC_1_1_MINF_NEAREST |
548 NV50TSC_1_1_MIPF_NONE);
550 OUT_RING (chan, 0x00000000);
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);
557 state->unit[unit].width = ppix->drawable.width;
558 state->unit[unit].height = ppix->drawable.height;
559 state->unit[unit].transform = ppict->transform;
564 NV50EXACheckBlend(int op)
567 NOUVEAU_FALLBACK("unsupported blend op %d\n", op);
572 NV50EXABlend(PixmapPtr ppix, PicturePtr ppict, int op, int component_alpha)
574 NV50EXA_LOCALS(ppix);
575 struct nv50_blend_op *b = &NV50EXABlendOp[op];
576 unsigned sblend = b->src_blend;
577 unsigned dblend = b->dst_blend;
580 if (!PICT_FORMAT_A(ppict->format)) {
581 if (sblend == BF(DST_ALPHA))
584 if (sblend == BF(ONE_MINUS_DST_ALPHA))
587 if (ppict->format == PICT_a8) {
588 if (sblend == BF(DST_ALPHA))
589 sblend = BF(DST_COLOR);
591 if (sblend == BF(ONE_MINUS_DST_ALPHA))
592 sblend = BF(ONE_MINUS_DST_COLOR);
596 if (b->src_alpha && (component_alpha || ppict->format == PICT_a8)) {
597 if (dblend == BF(SRC_ALPHA))
598 dblend = BF(SRC_COLOR);
600 if (dblend == BF(ONE_MINUS_SRC_ALPHA))
601 dblend = BF(ONE_MINUS_SRC_COLOR);
604 if (sblend == BF(ONE) && dblend == BF(ZERO)) {
605 BEGIN_RING(chan, tesla, NV50TCL_BLEND_ENABLE(0), 1);
608 BEGIN_RING(chan, tesla, NV50TCL_BLEND_ENABLE(0), 1);
610 BEGIN_RING(chan, tesla, NV50TCL_BLEND_EQUATION_RGB, 5);
611 OUT_RING (chan, NV50TCL_BLEND_EQUATION_RGB_FUNC_ADD);
612 OUT_RING (chan, sblend);
613 OUT_RING (chan, dblend);
614 OUT_RING (chan, NV50TCL_BLEND_EQUATION_ALPHA_FUNC_ADD);
615 OUT_RING (chan, sblend);
616 BEGIN_RING(chan, tesla, NV50TCL_BLEND_FUNC_DST_ALPHA, 1);
617 OUT_RING (chan, dblend);
622 NV50EXACheckComposite(int op,
623 PicturePtr pspict, PicturePtr pmpict, PicturePtr pdpict)
625 if (!NV50EXACheckBlend(op))
626 NOUVEAU_FALLBACK("blend not supported\n");
628 if (!NV50EXACheckRenderTarget(pdpict))
629 NOUVEAU_FALLBACK("render target invalid\n");
631 if (!NV50EXACheckTexture(pspict))
632 NOUVEAU_FALLBACK("src picture invalid\n");
635 if (pmpict->componentAlpha &&
636 PICT_FORMAT_RGB(pmpict->format) &&
637 NV50EXABlendOp[op].src_alpha &&
638 NV50EXABlendOp[op].src_blend != BF(ZERO))
639 NOUVEAU_FALLBACK("component-alpha not supported\n");
641 if (!NV50EXACheckTexture(pmpict))
642 NOUVEAU_FALLBACK("mask picture invalid\n");
649 NV50EXAPrepareComposite(int op,
650 PicturePtr pspict, PicturePtr pmpict, PicturePtr pdpict,
651 PixmapPtr pspix, PixmapPtr pmpix, PixmapPtr pdpix)
653 NV50EXA_LOCALS(pspix);
655 BEGIN_RING(chan, eng2d, 0x0110, 1);
658 if (!NV50EXARenderTarget(pdpix, pdpict))
659 NOUVEAU_FALLBACK("render target invalid\n");
661 NV50EXABlend(pdpix, pdpict, op, pmpict && pmpict->componentAlpha &&
662 PICT_FORMAT_RGB(pmpict->format));
665 if (!NV50EXATexture(pspix, pspict, 0))
666 NOUVEAU_FALLBACK("src picture invalid\n");
667 if (!NV50EXATexture(pmpix, pmpict, 1))
668 NOUVEAU_FALLBACK("mask picture invalid\n");
669 state->have_mask = TRUE;
671 BEGIN_RING(chan, tesla, NV50TCL_FP_START_ID, 1);
672 if (pdpict->format == PICT_a8) {
673 OUT_RING (chan, PFP_C_A8);
675 if (pmpict->componentAlpha &&
676 PICT_FORMAT_RGB(pmpict->format)) {
677 if (NV50EXABlendOp[op].src_alpha)
678 OUT_RING (chan, PFP_CCASA);
680 OUT_RING (chan, PFP_CCA);
682 OUT_RING (chan, PFP_C);
686 if (!NV50EXATexture(pspix, pspict, 0))
687 NOUVEAU_FALLBACK("src picture invalid\n");
688 state->have_mask = FALSE;
690 BEGIN_RING(chan, tesla, NV50TCL_FP_START_ID, 1);
691 if (pdpict->format == PICT_a8)
692 OUT_RING (chan, PFP_S_A8);
694 OUT_RING (chan, PFP_S);
697 BEGIN_RING(chan, tesla, 0x1334, 1);
700 BEGIN_RING(chan, tesla, 0x1458, 1);
702 BEGIN_RING(chan, tesla, 0x1458, 1);
703 OUT_RING (chan, 0x203);
705 BEGIN_RING(chan, tesla, NV50TCL_VERTEX_BEGIN, 1);
706 OUT_RING (chan, NV50TCL_VERTEX_BEGIN_QUADS);
711 #define xFixedToFloat(v) \
712 ((float)xFixedToInt((v)) + ((float)xFixedFrac(v) / 65536.0))
714 NV50EXATransform(PictTransformPtr t, int x, int y, float sx, float sy,
715 float *x_ret, float *y_ret)
720 v.vector[0] = IntToxFixed(x);
721 v.vector[1] = IntToxFixed(y);
722 v.vector[2] = xFixed1;
723 PictureTransformPoint(t, &v);
724 *x_ret = xFixedToFloat(v.vector[0]) / sx;
725 *y_ret = xFixedToFloat(v.vector[1]) / sy;
727 *x_ret = (float)x / sx;
728 *y_ret = (float)y / sy;
733 NV50EXAComposite(PixmapPtr pdpix, int sx, int sy, int mx, int my,
734 int dx, int dy, int w, int h)
736 NV50EXA_LOCALS(pdpix);
737 float sX0, sX1, sX2, sX3, sY0, sY1, sY2, sY3;
738 unsigned dX0 = dx, dX1 = dx + w, dY0 = dy, dY1 = dy + h;
740 NV50EXATransform(state->unit[0].transform, sx, sy,
741 state->unit[0].width, state->unit[0].height,
743 NV50EXATransform(state->unit[0].transform, sx + w, sy,
744 state->unit[0].width, state->unit[0].height,
746 NV50EXATransform(state->unit[0].transform, sx + w, sy + h,
747 state->unit[0].width, state->unit[0].height,
749 NV50EXATransform(state->unit[0].transform, sx, sy + h,
750 state->unit[0].width, state->unit[0].height,
753 if (state->have_mask) {
754 float mX0, mX1, mX2, mX3, mY0, mY1, mY2, mY3;
756 NV50EXATransform(state->unit[1].transform, mx, my,
757 state->unit[1].width, state->unit[1].height,
759 NV50EXATransform(state->unit[1].transform, mx + w, my,
760 state->unit[1].width, state->unit[1].height,
762 NV50EXATransform(state->unit[1].transform, mx + w, my + h,
763 state->unit[1].width, state->unit[1].height,
765 NV50EXATransform(state->unit[1].transform, mx, my + h,
766 state->unit[1].width, state->unit[1].height,
769 VTX2s(pNv, sX0, sY0, mX0, mY0, dX0, dY0);
770 VTX2s(pNv, sX1, sY1, mX1, mY1, dX1, dY0);
771 VTX2s(pNv, sX2, sY2, mX2, mY2, dX1, dY1);
772 VTX2s(pNv, sX3, sY3, mX3, mY3, dX0, dY1);
774 VTX1s(pNv, sX0, sY0, dX0, dY0);
775 VTX1s(pNv, sX1, sY1, dX1, dY0);
776 VTX1s(pNv, sX2, sY2, dX1, dY1);
777 VTX1s(pNv, sX3, sY3, dX0, dY1);
782 NV50EXADoneComposite(PixmapPtr pdpix)
784 NV50EXA_LOCALS(pdpix);
786 BEGIN_RING(chan, tesla, NV50TCL_VERTEX_END, 1);