~ubuntu-branches/ubuntu/precise/xserver-xorg-video-openchrome-lts-trusty/precise-proposed

« back to all changes in this revision

Viewing changes to src/via_exa_h6.c

  • Committer: Package Import Robot
  • Author(s): Maarten Lankhorst
  • Date: 2014-05-15 12:47:33 UTC
  • Revision ID: package-import@ubuntu.com-20140515124733-qw5cb5dqlvejqsy3
Tags: upstream-0.3.3
Import upstream version 0.3.3

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * Copyright 1998-2008 VIA Technologies, Inc. All Rights Reserved.
 
3
 * Copyright 2001-2003 S3 Graphics, Inc. All Rights Reserved.
 
4
 * Copyright 2006 Thomas Hellström. All Rights Reserved.
 
5
 *
 
6
 * Permission is hereby granted, free of charge, to any person obtaining a
 
7
 * copy of this software and associated documentation files (the "Software"),
 
8
 * to deal in the Software without restriction, including without limitation
 
9
 * the rights to use, copy, modify, merge, publish, distribute, sub license,
 
10
 * and/or sell copies of the Software, and to permit persons to whom the
 
11
 * Software is furnished to do so, subject to the following conditions:
 
12
 *
 
13
 * The above copyright notice and this permission notice (including the
 
14
 * next paragraph) shall be included in all copies or substantial portions
 
15
 * of the Software.
 
16
 *
 
17
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 
18
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 
19
 * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
 
20
 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 
21
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
 
22
 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
 
23
 * DEALINGS IN THE SOFTWARE.
 
24
 */
 
25
 
 
26
/*
 
27
 * 2D acceleration functions for the VIA/S3G UniChrome IGPs.
 
28
 *
 
29
 * Mostly rewritten, and modified for EXA support, by Thomas Hellström.
 
30
 */
 
31
 
 
32
#ifdef HAVE_CONFIG_H
 
33
#include "config.h"
 
34
#endif
 
35
 
 
36
#include <X11/Xarch.h>
 
37
#include "miline.h"
 
38
 
 
39
#include "via_driver.h"
 
40
#include "via_regs.h"
 
41
#include "via_dmabuffer.h"
 
42
#include "via_rop.h"
 
43
 
 
44
/*
 
45
 * Emit clipping borders to the command buffer and update the 2D context
 
46
 * current command with clipping info.
 
47
 */
 
48
static int
 
49
viaAccelClippingHelper_H6(VIAPtr pVia, int refY)
 
50
{
 
51
    ViaTwodContext *tdc = &pVia->td;
 
52
 
 
53
    RING_VARS;
 
54
 
 
55
    if (tdc->clipping) {
 
56
        refY = (refY < tdc->clipY1) ? refY : tdc->clipY1;
 
57
        tdc->cmd |= VIA_GEC_CLIP_ENABLE;
 
58
        BEGIN_RING(4);
 
59
        OUT_RING_H1(VIA_REG_CLIPTL_M1,
 
60
                    ((tdc->clipY1 - refY) << 16) | tdc->clipX1);
 
61
        OUT_RING_H1(VIA_REG_CLIPBR_M1,
 
62
                    ((tdc->clipY2 - refY) << 16) | tdc->clipX2);
 
63
    } else {
 
64
        tdc->cmd &= ~VIA_GEC_CLIP_ENABLE;
 
65
    }
 
66
    return refY;
 
67
}
 
68
 
 
69
/*
 
70
 * Check if we can use a planeMask and update the 2D context accordingly.
 
71
 */
 
72
static Bool
 
73
viaAccelPlaneMaskHelper_H6(ViaTwodContext * tdc, CARD32 planeMask)
 
74
{
 
75
    CARD32 modeMask = (1 << ((1 << tdc->bytesPPShift) << 3)) - 1;
 
76
    CARD32 curMask = 0x00000000;
 
77
    CARD32 curByteMask;
 
78
    int i;
 
79
 
 
80
    if ((planeMask & modeMask) != modeMask) {
 
81
 
 
82
        /* Masking doesn't work in 8bpp. */
 
83
        if (modeMask == 0xFF) {
 
84
            tdc->keyControl &= 0x0FFFFFFF;
 
85
            return FALSE;
 
86
        }
 
87
 
 
88
        /* Translate the bit planemask to a byte planemask. */
 
89
        for (i = 0; i < (1 << tdc->bytesPPShift); ++i) {
 
90
            curByteMask = (0xFF << (i << 3));
 
91
 
 
92
            if ((planeMask & curByteMask) == 0) {
 
93
                curMask |= (1 << i);
 
94
            } else if ((planeMask & curByteMask) != curByteMask) {
 
95
                tdc->keyControl &= 0x0FFFFFFF;
 
96
                return FALSE;
 
97
            }
 
98
        }
 
99
        ErrorF("DEBUG: planeMask 0x%08x, curMask 0%02x\n",
 
100
               (unsigned)planeMask, (unsigned)curMask);
 
101
 
 
102
        tdc->keyControl = (tdc->keyControl & 0x0FFFFFFF) | (curMask << 28);
 
103
    }
 
104
 
 
105
    return TRUE;
 
106
}
 
107
 
 
108
/*
 
109
 * Emit transparency state and color to the command buffer.
 
110
 */
 
111
static void
 
112
viaAccelTransparentHelper_H6(VIAPtr pVia, CARD32 keyControl,
 
113
                          CARD32 transColor, Bool usePlaneMask)
 
114
{
 
115
    ViaTwodContext *tdc = &pVia->td;
 
116
 
 
117
    RING_VARS;
 
118
 
 
119
    tdc->keyControl &= ((usePlaneMask) ? 0xF0000000 : 0x00000000);
 
120
    tdc->keyControl |= (keyControl & 0x0FFFFFFF);
 
121
    BEGIN_RING(4);
 
122
    OUT_RING_H1(VIA_REG_KEYCONTROL_M1, tdc->keyControl);
 
123
    if (keyControl) {
 
124
        OUT_RING_H1(VIA_REG_SRCCOLORKEY_M1, transColor);
 
125
    }
 
126
}
 
127
 
 
128
/*
 
129
 * Mark Sync using the 2D blitter for AGP. NoOp for PCI.
 
130
 * In the future one could even launch a NULL PCI DMA command
 
131
 * to have an interrupt generated, provided it is possible to
 
132
 * write to the PCI DMA engines from the AGP command stream.
 
133
 */
 
134
int
 
135
viaAccelMarkSync_H6(ScreenPtr pScreen)
 
136
{
 
137
    ScrnInfoPtr pScrn = xf86ScreenToScrn(pScreen);
 
138
    VIAPtr pVia = VIAPTR(pScrn);
 
139
 
 
140
    RING_VARS;
 
141
 
 
142
    ++pVia->curMarker;
 
143
 
 
144
    /* Wrap around without affecting the sign bit. */
 
145
    pVia->curMarker &= 0x7FFFFFFF;
 
146
 
 
147
    if (pVia->agpDMA) {
 
148
        BEGIN_RING(16);
 
149
 
 
150
        OUT_RING_H1(VIA_REG_KEYCONTROL_M1, 0x00);
 
151
        OUT_RING_H1(VIA_REG_GEMODE_M1, VIA_GEM_32bpp);
 
152
        OUT_RING_H1(VIA_REG_DSTBASE_M1, pVia->curMarker >> 3);
 
153
        OUT_RING_H1(VIA_REG_PITCH_M1, 0);
 
154
        OUT_RING_H1(VIA_REG_DSTPOS_M1, 0);
 
155
        OUT_RING_H1(VIA_REG_DIMENSION_M1, 0);
 
156
        OUT_RING_H1(VIA_REG_MONOPATFGC_M1, pVia->curMarker);
 
157
        OUT_RING_H1(VIA_REG_GECMD_M1, (0xF0 << 24) | VIA_GEC_BLT | VIA_GEC_FIXCOLOR_PAT);
 
158
 
 
159
        ADVANCE_RING;
 
160
    }
 
161
    return pVia->curMarker;
 
162
}
 
163
 
 
164
/*
 
165
 * Exa functions. It is assumed that EXA does not exceed the blitter limits.
 
166
 */
 
167
Bool
 
168
viaExaPrepareSolid_H6(PixmapPtr pPixmap, int alu, Pixel planeMask, Pixel fg)
 
169
{
 
170
    ScrnInfoPtr pScrn = xf86ScreenToScrn(pPixmap->drawable.pScreen);
 
171
    VIAPtr pVia = VIAPTR(pScrn);
 
172
    ViaTwodContext *tdc = &pVia->td;
 
173
 
 
174
    RING_VARS;
 
175
 
 
176
    if (exaGetPixmapPitch(pPixmap) & 7)
 
177
        return FALSE;
 
178
 
 
179
    if (!viaAccelSetMode(pPixmap->drawable.depth, tdc))
 
180
        return FALSE;
 
181
 
 
182
    if (!viaAccelPlaneMaskHelper_H6(tdc, planeMask))
 
183
        return FALSE;
 
184
 
 
185
    viaAccelTransparentHelper_H6(pVia, 0x0, 0x0, TRUE);
 
186
 
 
187
    tdc->cmd = VIA_GEC_BLT | VIA_GEC_FIXCOLOR_PAT | VIAACCELPATTERNROP(alu);
 
188
 
 
189
    tdc->fgColor = fg;
 
190
 
 
191
    return TRUE;
 
192
}
 
193
 
 
194
void
 
195
viaExaSolid_H6(PixmapPtr pPixmap, int x1, int y1, int x2, int y2)
 
196
{
 
197
    ScrnInfoPtr pScrn = xf86ScreenToScrn(pPixmap->drawable.pScreen);
 
198
    CARD32 dstOffset = exaGetPixmapOffset(pPixmap);
 
199
    CARD32 dstPitch = exaGetPixmapPitch(pPixmap);
 
200
    int w = x2 - x1, h = y2 - y1;
 
201
    VIAPtr pVia = VIAPTR(pScrn);
 
202
    ViaTwodContext *tdc = &pVia->td;
 
203
 
 
204
    RING_VARS;
 
205
 
 
206
    BEGIN_RING(14);
 
207
    OUT_RING_H1(VIA_REG_GEMODE_M1, tdc->mode);
 
208
    OUT_RING_H1(VIA_REG_DSTBASE_M1, dstOffset >> 3);
 
209
    OUT_RING_H1(VIA_REG_PITCH_M1, (dstPitch >> 3) << 16);
 
210
    OUT_RING_H1(VIA_REG_DSTPOS_M1, (y1 << 16) | (x1 & 0xFFFF));
 
211
    OUT_RING_H1(VIA_REG_DIMENSION_M1, ((h - 1) << 16) | (w - 1));
 
212
    OUT_RING_H1(VIA_REG_MONOPATFGC_M1, tdc->fgColor);
 
213
    OUT_RING_H1(VIA_REG_GECMD_M1, tdc->cmd);
 
214
 
 
215
    ADVANCE_RING;
 
216
}
 
217
 
 
218
void
 
219
viaExaDoneSolidCopy_H6(PixmapPtr pPixmap)
 
220
{
 
221
}
 
222
 
 
223
Bool
 
224
viaExaPrepareCopy_H6(PixmapPtr pSrcPixmap, PixmapPtr pDstPixmap, int xdir,
 
225
                        int ydir, int alu, Pixel planeMask)
 
226
{
 
227
    ScrnInfoPtr pScrn = xf86ScreenToScrn(pDstPixmap->drawable.pScreen);
 
228
    VIAPtr pVia = VIAPTR(pScrn);
 
229
    ViaTwodContext *tdc = &pVia->td;
 
230
 
 
231
    RING_VARS;
 
232
 
 
233
    if (pSrcPixmap->drawable.bitsPerPixel != pDstPixmap->drawable.bitsPerPixel)
 
234
        return FALSE;
 
235
 
 
236
    if ((tdc->srcPitch = exaGetPixmapPitch(pSrcPixmap)) & 3)
 
237
        return FALSE;
 
238
 
 
239
    if (exaGetPixmapPitch(pDstPixmap) & 7)
 
240
        return FALSE;
 
241
 
 
242
    tdc->srcOffset = exaGetPixmapOffset(pSrcPixmap);
 
243
 
 
244
    tdc->cmd = VIA_GEC_BLT | VIAACCELCOPYROP(alu);
 
245
    if (xdir < 0)
 
246
        tdc->cmd |= VIA_GEC_DECX;
 
247
    if (ydir < 0)
 
248
        tdc->cmd |= VIA_GEC_DECY;
 
249
 
 
250
    if (!viaAccelSetMode(pDstPixmap->drawable.bitsPerPixel, tdc))
 
251
        return FALSE;
 
252
 
 
253
    if (!viaAccelPlaneMaskHelper_H6(tdc, planeMask))
 
254
        return FALSE;
 
255
    viaAccelTransparentHelper_H6(pVia, 0x0, 0x0, TRUE);
 
256
 
 
257
    return TRUE;
 
258
}
 
259
 
 
260
void
 
261
viaExaCopy_H6(PixmapPtr pDstPixmap, int srcX, int srcY, int dstX, int dstY,
 
262
                int width, int height)
 
263
{
 
264
    ScrnInfoPtr pScrn = xf86ScreenToScrn(pDstPixmap->drawable.pScreen);
 
265
    CARD32 dstOffset = exaGetPixmapOffset(pDstPixmap), val;
 
266
    CARD32 dstPitch = exaGetPixmapPitch(pDstPixmap);
 
267
    VIAPtr pVia = VIAPTR(pScrn);
 
268
    ViaTwodContext *tdc = &pVia->td;
 
269
 
 
270
    if (!width || !height)
 
271
        return;
 
272
 
 
273
    RING_VARS;
 
274
 
 
275
    if (tdc->cmd & VIA_GEC_DECY) {
 
276
        srcY += height - 1;
 
277
        dstY += height - 1;
 
278
    }
 
279
 
 
280
    if (tdc->cmd & VIA_GEC_DECX) {
 
281
        srcX += width - 1;
 
282
        dstX += width - 1;
 
283
    }
 
284
    val = (dstPitch >> 3) << 16 | (tdc->srcPitch >> 3);
 
285
 
 
286
    BEGIN_RING(16);
 
287
    OUT_RING_H1(VIA_REG_GEMODE_M1, tdc->mode);
 
288
    OUT_RING_H1(VIA_REG_SRCBASE_M1, tdc->srcOffset >> 3);
 
289
    OUT_RING_H1(VIA_REG_DSTBASE_M1, dstOffset >> 3);
 
290
    OUT_RING_H1(VIA_REG_PITCH_M1, val);
 
291
 
 
292
    OUT_RING_H1(VIA_REG_SRCPOS_M1, (srcY << 16) | (srcX & 0xFFFF));
 
293
    OUT_RING_H1(VIA_REG_DSTPOS_M1, (dstY << 16) | (dstX & 0xFFFF));
 
294
    OUT_RING_H1(VIA_REG_DIMENSION_M1, ((height - 1) << 16) | (width - 1));
 
295
    OUT_RING_H1(VIA_REG_GECMD_M1, tdc->cmd);
 
296
 
 
297
    ADVANCE_RING;
 
298
}
 
299
 
 
300
Bool
 
301
viaExaCheckComposite_H6(int op, PicturePtr pSrcPicture,
 
302
                        PicturePtr pMaskPicture, PicturePtr pDstPicture)
 
303
{
 
304
    ScrnInfoPtr pScrn = xf86ScreenToScrn(pDstPicture->pDrawable->pScreen);
 
305
    VIAPtr pVia = VIAPTR(pScrn);
 
306
    Via3DState *v3d = &pVia->v3d;
 
307
 
 
308
    if (!pSrcPicture->pDrawable) {
 
309
        return FALSE;
 
310
    }
 
311
    /* Reject small composites early. They are done much faster in software. */
 
312
    if (!pSrcPicture->repeat &&
 
313
        pSrcPicture->pDrawable->width *
 
314
        pSrcPicture->pDrawable->height < VIA_MIN_COMPOSITE) {
 
315
 
 
316
#ifdef VIA_DEBUG_COMPOSITE
 
317
        viaExaPrintCompositeInfo("Source picture too small", op,  pSrcPicture, pMaskPicture, pDstPicture);
 
318
#endif
 
319
        return FALSE;
 
320
    }
 
321
 
 
322
    if (pMaskPicture && pMaskPicture->pDrawable &&
 
323
        !pMaskPicture->repeat &&
 
324
        pMaskPicture->pDrawable->width *
 
325
        pMaskPicture->pDrawable->height < VIA_MIN_COMPOSITE) {
 
326
#ifdef VIA_DEBUG_COMPOSITE
 
327
        viaExaPrintCompositeInfo("Mask picture too small", op,  pSrcPicture, pMaskPicture, pDstPicture);
 
328
#endif
 
329
        return FALSE;
 
330
    }
 
331
 
 
332
    if (pMaskPicture && pMaskPicture->repeat && pMaskPicture->repeatType != RepeatNormal) {
 
333
#ifdef VIA_DEBUG_COMPOSITE
 
334
        viaExaPrintCompositeInfo("Repeat is different than normal", op,  pSrcPicture, pMaskPicture, pDstPicture);
 
335
#endif
 
336
        return FALSE;
 
337
    }
 
338
    if (pMaskPicture && pMaskPicture->componentAlpha) {
 
339
#ifdef VIA_DEBUG_COMPOSITE
 
340
        viaExaPrintCompositeInfo("Component Alpha operation", op,  pSrcPicture, pMaskPicture, pDstPicture);
 
341
#endif
 
342
        return FALSE;
 
343
    }
 
344
 
 
345
    if (!v3d->opSupported(op)) {
 
346
#ifdef VIA_DEBUG_COMPOSITE
 
347
        viaExaPrintCompositeInfo("Operator not supported", op, pSrcPicture, pMaskPicture, pDstPicture);
 
348
#endif
 
349
        return FALSE;
 
350
    }
 
351
 
 
352
    /*
 
353
     * FIXME: A8 destination formats are currently not supported and do not
 
354
     * seem supported by the hardware, although there are some leftover
 
355
     * register settings apparent in the via_3d_reg.h file. We need to fix this
 
356
     * (if important), by using component ARGB8888 operations with bitmask.
 
357
     */
 
358
 
 
359
    if (!v3d->dstSupported(pDstPicture->format)) {
 
360
#ifdef VIA_DEBUG_COMPOSITE
 
361
        viaExaPrintCompositeInfo("Destination format not supported", op, pSrcPicture, pMaskPicture, pDstPicture);
 
362
#endif
 
363
        return FALSE;
 
364
    }
 
365
 
 
366
    if (v3d->texSupported(pSrcPicture->format)) {
 
367
        if (pMaskPicture && (PICT_FORMAT_A(pMaskPicture->format) == 0 ||
 
368
                             !v3d->texSupported(pMaskPicture->format))) {
 
369
#ifdef VIA_DEBUG_COMPOSITE
 
370
            viaExaPrintCompositeInfo("Mask format not supported", op, pSrcPicture, pMaskPicture, pDstPicture);
 
371
#endif
 
372
            return FALSE;
 
373
        }
 
374
        return TRUE;
 
375
    }
 
376
#ifdef VIA_DEBUG_COMPOSITE
 
377
    viaExaPrintCompositeInfo("Src format not supported",op, pSrcPicture, pMaskPicture, pDstPicture);
 
378
#endif
 
379
    return FALSE;
 
380
}
 
381
 
 
382
static Bool
 
383
viaIsAGP(VIAPtr pVia, PixmapPtr pPix, unsigned long *offset)
 
384
{
 
385
#ifdef HAVE_DRI
 
386
    unsigned long offs;
 
387
 
 
388
    if (pVia->directRenderingType && !pVia->IsPCI) {
 
389
        offs = ((unsigned long)pPix->devPrivate.ptr
 
390
                - (unsigned long)pVia->agpMappedAddr);
 
391
 
 
392
        if ((offs - pVia->scratchOffset) < pVia->agpSize) {
 
393
            *offset = offs + pVia->agpAddr;
 
394
            return TRUE;
 
395
        }
 
396
    }
 
397
#endif
 
398
    return FALSE;
 
399
}
 
400
 
 
401
static Bool
 
402
viaExaIsOffscreen(PixmapPtr pPix)
 
403
{
 
404
    ScrnInfoPtr pScrn = xf86ScreenToScrn(pPix->drawable.pScreen);
 
405
    VIAPtr pVia = VIAPTR(pScrn);
 
406
 
 
407
    return ((unsigned long)pPix->devPrivate.ptr -
 
408
            (unsigned long) drm_bo_map(pScrn, pVia->drmmode.front_bo)) < pVia->drmmode.front_bo->size;
 
409
}
 
410
 
 
411
Bool
 
412
viaExaPrepareComposite_H6(int op, PicturePtr pSrcPicture,
 
413
                            PicturePtr pMaskPicture, PicturePtr pDstPicture,
 
414
                            PixmapPtr pSrc, PixmapPtr pMask, PixmapPtr pDst)
 
415
{
 
416
    CARD32 height, width;
 
417
    ScrnInfoPtr pScrn = xf86ScreenToScrn(pDst->drawable.pScreen);
 
418
    VIAPtr pVia = VIAPTR(pScrn);
 
419
    Via3DState *v3d = &pVia->v3d;
 
420
    int curTex = 0;
 
421
    ViaTexBlendingModes srcMode;
 
422
    Bool isAGP;
 
423
    unsigned long offset;
 
424
 
 
425
    /* Workaround: EXA crash with new libcairo2 on a VIA VX800 (#298) */
 
426
    /* TODO Add real source only pictures */
 
427
    if (!pSrc) {
 
428
            ErrorF("pSrc is NULL\n");
 
429
            return FALSE;
 
430
        }
 
431
 
 
432
    v3d->setDestination(v3d, exaGetPixmapOffset(pDst),
 
433
                        exaGetPixmapPitch(pDst), pDstPicture->format);
 
434
    v3d->setCompositeOperator(v3d, op);
 
435
    v3d->setDrawing(v3d, 0x0c, 0xFFFFFFFF, 0x000000FF, 0xFF);
 
436
 
 
437
    viaOrder(pSrc->drawable.width, &width);
 
438
    viaOrder(pSrc->drawable.height, &height);
 
439
 
 
440
    /*
 
441
     * For one-pixel repeat mask pictures we avoid using multitexturing by
 
442
     * modifying the src's texture blending equation and feed the pixel
 
443
     * value as a constant alpha for the src's texture. Multitexturing on the
 
444
     * Unichromes seems somewhat slow, so this speeds up translucent windows.
 
445
     */
 
446
 
 
447
    srcMode = via_src;
 
448
    pVia->maskP = NULL;
 
449
    if (pMaskPicture &&
 
450
        (pMaskPicture->pDrawable->height == 1) &&
 
451
        (pMaskPicture->pDrawable->width == 1) &&
 
452
        pMaskPicture->repeat && viaExpandablePixel(pMaskPicture->format)) {
 
453
        pVia->maskP = pMask->devPrivate.ptr;
 
454
        pVia->maskFormat = pMaskPicture->format;
 
455
        pVia->componentAlpha = pMaskPicture->componentAlpha;
 
456
        srcMode = ((pMaskPicture->componentAlpha)
 
457
                   ? via_src_onepix_comp_mask : via_src_onepix_mask);
 
458
    }
 
459
 
 
460
    /*
 
461
     * One-Pixel repeat src pictures go as solid color instead of textures.
 
462
     * Speeds up window shadows.
 
463
     */
 
464
 
 
465
    pVia->srcP = NULL;
 
466
    if (pSrcPicture && pSrcPicture->repeat
 
467
        && (pSrcPicture->pDrawable->height == 1)
 
468
        && (pSrcPicture->pDrawable->width == 1)
 
469
        && viaExpandablePixel(pSrcPicture->format)) {
 
470
        pVia->srcP = pSrc->devPrivate.ptr;
 
471
        pVia->srcFormat = pSrcPicture->format;
 
472
    }
 
473
 
 
474
    /* Exa should be smart enough to eliminate this IN operation. */
 
475
    if (pVia->srcP && pVia->maskP) {
 
476
        ErrorF("Bad one-pixel IN composite operation. "
 
477
               "EXA needs to be smarter.\n");
 
478
        return FALSE;
 
479
    }
 
480
 
 
481
    if (!pVia->srcP) {
 
482
        offset = exaGetPixmapOffset(pSrc);
 
483
        isAGP = viaIsAGP(pVia, pSrc, &offset);
 
484
        if (!isAGP && !viaExaIsOffscreen(pSrc))
 
485
            return FALSE;
 
486
        if (!v3d->setTexture(v3d, curTex, offset,
 
487
                             exaGetPixmapPitch(pSrc), pVia->nPOT[curTex],
 
488
                             1 << width, 1 << height, pSrcPicture->format,
 
489
                             via_repeat, via_repeat, srcMode, isAGP)) {
 
490
            return FALSE;
 
491
        }
 
492
        curTex++;
 
493
    }
 
494
 
 
495
    if (pMaskPicture && !pVia->maskP) {
 
496
        offset = exaGetPixmapOffset(pMask);
 
497
        isAGP = viaIsAGP(pVia, pMask, &offset);
 
498
        if (!isAGP && !viaExaIsOffscreen(pMask))
 
499
            return FALSE;
 
500
        viaOrder(pMask->drawable.width, &width);
 
501
        viaOrder(pMask->drawable.height, &height);
 
502
        if (!v3d->setTexture(v3d, curTex, offset,
 
503
                             exaGetPixmapPitch(pMask), pVia->nPOT[curTex],
 
504
                             1 << width, 1 << height, pMaskPicture->format,
 
505
                             via_repeat, via_repeat,
 
506
                             ((pMaskPicture->componentAlpha)
 
507
                              ? via_comp_mask : via_mask), isAGP)) {
 
508
            return FALSE;
 
509
        }
 
510
        curTex++;
 
511
    }
 
512
 
 
513
    v3d->setFlags(v3d, curTex, FALSE, TRUE, TRUE);
 
514
    v3d->emitState(v3d, &pVia->cb, viaCheckUpload(pScrn, v3d));
 
515
    v3d->emitClipRect(v3d, &pVia->cb, 0, 0, pDst->drawable.width,
 
516
                      pDst->drawable.height);
 
517
 
 
518
    return TRUE;
 
519
}
 
520
 
 
521
void
 
522
viaExaComposite_H6(PixmapPtr pDst, int srcX, int srcY, int maskX, int maskY,
 
523
                    int dstX, int dstY, int width, int height)
 
524
{
 
525
    ScrnInfoPtr pScrn = xf86ScreenToScrn(pDst->drawable.pScreen);
 
526
    VIAPtr pVia = VIAPTR(pScrn);
 
527
    Via3DState *v3d = &pVia->v3d;
 
528
    CARD32 col;
 
529
 
 
530
    if (pVia->maskP) {
 
531
        viaPixelARGB8888(pVia->maskFormat, pVia->maskP, &col);
 
532
        v3d->setTexBlendCol(v3d, 0, pVia->componentAlpha, col);
 
533
    }
 
534
    if (pVia->srcP) {
 
535
        viaPixelARGB8888(pVia->srcFormat, pVia->srcP, &col);
 
536
        v3d->setDrawing(v3d, 0x0c, 0xFFFFFFFF, col & 0x00FFFFFF, col >> 24);
 
537
        srcX = maskX;
 
538
        srcY = maskY;
 
539
    }
 
540
 
 
541
    if (pVia->maskP || pVia->srcP)
 
542
        v3d->emitState(v3d, &pVia->cb, viaCheckUpload(pScrn, v3d));
 
543
 
 
544
    v3d->emitQuad(v3d, &pVia->cb, dstX, dstY, srcX, srcY, maskX, maskY,
 
545
                  width, height);
 
546
}