blob: 0d3d604095523cf97c243031ddbde150bcc788b5 [file] [log] [blame]
Keith Whitwell45efcc42008-09-21 11:00:44 -07001/*
Alan Hourihane13e6a482003-12-04 13:38:06 +00002 *
3 * GLX Hardware Device Driver for Sun Creator/Creator3D
4 * Copyright (C) 2000 David S. Miller
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, sublicense,
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 shall be included
14 * in all copies or substantial portions of the Software.
15 *
16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
17 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
19 * DAVID MILLER, OR ANY OTHER CONTRIBUTORS BE LIABLE FOR ANY CLAIM,
20 * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
21 * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE
22 * OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
23 *
24 *
25 * David S. Miller <davem@redhat.com>
26 */
27
Brian Paulecadb512008-09-18 15:17:05 -060028#include "main/mtypes.h"
Alan Hourihane13e6a482003-12-04 13:38:06 +000029#include "ffb_dd.h"
30#include "ffb_span.h"
31#include "ffb_context.h"
32#include "ffb_lock.h"
33
34#include "swrast/swrast.h"
35
36#define DBG 0
37
38#define HW_LOCK() \
39 ffbContextPtr fmesa = FFB_CONTEXT(ctx); \
40 if (!fmesa->hw_locked) \
41 LOCK_HARDWARE(fmesa);
42
43#define HW_UNLOCK() \
44 if (!fmesa->hw_locked) \
45 UNLOCK_HARDWARE(fmesa); \
46
47#define LOCAL_VARS \
48 __DRIdrawablePrivate *dPriv = fmesa->driDrawable; \
49 GLuint height = dPriv->h; \
50 GLuint p; \
51 char *buf; \
52 (void) p
53
54#define INIT_MONO_PIXEL(p, color) \
55 p = ((color[0] << 0) | \
56 (color[1] << 8) | \
57 (color[2] << 16))
58
59/* We use WID clipping, so this test always passes. */
60#define CLIPPIXEL(__x, __y) (1)
61
62/* And also, due to WID clipping, we need not do anything
63 * special here.
64 */
65#define CLIPSPAN(__x,__y,__n,__x1,__n1,__i) \
66 __n1 = __n; \
67 __x1 = __x; \
68
69#define HW_CLIPLOOP() \
70do { unsigned int fbc, ppc, cmp; \
71 FFBWait(fmesa, fmesa->regs); \
72 fbc = fmesa->regs->fbc; ppc = fmesa->regs->ppc; cmp = fmesa->regs->cmp; \
73 fmesa->regs->fbc = ((fbc & \
74 ~(FFB_FBC_WB_C | FFB_FBC_ZE_MASK | FFB_FBC_RGBE_MASK)) \
75 | (FFB_FBC_ZE_OFF | FFB_FBC_RGBE_MASK)); \
76 fmesa->regs->ppc = ((ppc & \
77 ~(FFB_PPC_XS_MASK | FFB_PPC_ABE_MASK | FFB_PPC_DCE_MASK | \
78 FFB_PPC_APE_MASK | FFB_PPC_CS_MASK)) \
79 | (FFB_PPC_XS_WID | FFB_PPC_ABE_DISABLE | \
80 FFB_PPC_DCE_DISABLE | FFB_PPC_APE_DISABLE | \
81 FFB_PPC_CS_VAR)); \
82 fmesa->regs->cmp = ((cmp & ~(0xff << 16)) | (0x80 << 16)); \
83 fmesa->ffbScreen->rp_active = 1; \
84 FFBWait(fmesa, fmesa->regs); \
85 buf = (char *)(fmesa->sfb32 + (dPriv->x << 2) + (dPriv->y << 13));\
86 if (dPriv->numClipRects) {
87
88#define HW_ENDCLIPLOOP() \
89 } \
90 fmesa->regs->fbc = fbc; \
91 fmesa->regs->ppc = ppc; \
92 fmesa->regs->cmp = cmp; \
93 fmesa->ffbScreen->rp_active = 1; \
94} while(0)
95
Brian Pauleae73db2005-09-04 15:01:33 +000096#define Y_FLIP(__y) (height - __y - 1)
Alan Hourihane13e6a482003-12-04 13:38:06 +000097
98#define READ_RGBA(rgba,__x,__y) \
99do { GLuint p = *(GLuint *)(buf + ((__x)<<2) + ((__y)<<13)); \
100 rgba[0] = (p >> 0) & 0xff; \
101 rgba[1] = (p >> 8) & 0xff; \
102 rgba[2] = (p >> 16) & 0xff; \
103 rgba[3] = 0xff; \
104} while(0)
105
106#define WRITE_RGBA(__x, __y, __r, __g, __b, __a) \
107 *(GLuint *)(buf + ((__x)<<2) + ((__y)<<13)) = \
108 ((((__r) & 0xff) << 0) | \
109 (((__g) & 0xff) << 8) | \
110 (((__b) & 0xff) << 16))
111
112#define WRITE_PIXEL(__x, __y, __p) \
113 *(GLuint *)(buf + ((__x)<<2) + ((__y)<<13)) = (__p)
114
115#define TAG(x) ffb##x##_888
116
Brian Paul687918b2005-09-03 16:43:02 +0000117#include "spantmp.h"
Alan Hourihane13e6a482003-12-04 13:38:06 +0000118
Alan Hourihanedf88dfe2005-07-18 13:52:34 +0000119/**
120 * Plug in the Get/Put routines for the given driRenderbuffer.
121 */
122void
123ffbSetSpanFunctions(driRenderbuffer *drb, const GLvisual *vis)
Alan Hourihane13e6a482003-12-04 13:38:06 +0000124{
Alan Hourihanedf88dfe2005-07-18 13:52:34 +0000125 assert(vis->redBits == 8);
126 assert(vis->greenBits == 8);
127 assert(vis->blueBits == 8);
Brian Pauleae73db2005-09-04 15:01:33 +0000128 ffbInitPointers_888(&drb->Base);
Alan Hourihane13e6a482003-12-04 13:38:06 +0000129}