1 /* $XFree86: xc/lib/GL/mesa/src/drv/ffb/ffb_depth.c,v 1.2 2002/02/22 21:32:58 dawes Exp $
3 * GLX Hardware Device Driver for Sun Creator/Creator3D
4 * Copyright (C) 2000 David S. Miller
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:
13 * The above copyright notice and this permission notice shall be included
14 * in all copies or substantial portions of the Software.
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.
25 * David S. Miller <davem@redhat.com>
29 #include "swrast/swrast.h"
32 #include "ffb_context.h"
33 #include "ffb_depth.h"
36 #include "swrast/swrast.h"
41 FFBWriteDepthSpan(GLcontext
*ctx
, GLuint n
, GLint x
, GLint y
,
42 const GLdepth depth
[], const GLubyte mask
[])
45 fprintf(stderr
, "FFBWriteDepthSpan: n(%d) x(%d) y(%d)\n",
48 if (ctx
->Depth
.Mask
) {
49 ffbContextPtr fmesa
= FFB_CONTEXT(ctx
);
50 __DRIdrawablePrivate
*dPriv
= fmesa
->driDrawable
;
54 if (!fmesa
->hw_locked
)
57 fmesa
->regs
->fbc
= (FFB_FBC_WB_C
| FFB_FBC_ZE_ON
|
58 FFB_FBC_YE_OFF
| FFB_FBC_RGBE_OFF
);
59 fmesa
->regs
->ppc
= FFB_PPC_ZS_VAR
;
60 FFBWait(fmesa
, fmesa
->regs
);
64 ((char *)fmesa
->sfb32
+
65 ((dPriv
->x
+ x
) << 2) +
66 ((dPriv
->y
+ y
) << 13));
68 for (i
= 0; i
< n
; i
++) {
70 *zptr
= Z_FROM_MESA(depth
[i
]);
76 fmesa
->regs
->fbc
= fmesa
->fbc
;
77 fmesa
->regs
->ppc
= fmesa
->ppc
;
78 fmesa
->ffbScreen
->rp_active
= 1;
79 if (!fmesa
->hw_locked
)
80 UNLOCK_HARDWARE(fmesa
);
85 FFBWriteDepthPixels(GLcontext
*ctx
, GLuint n
, const GLint x
[], const GLint y
[],
86 const GLdepth depth
[], const GLubyte mask
[])
89 fprintf(stderr
, "FFBWriteDepthPixels: n(%d)\n", (int) n
);
91 if (ctx
->Depth
.Mask
) {
92 ffbContextPtr fmesa
= FFB_CONTEXT(ctx
);
93 __DRIdrawablePrivate
*dPriv
= fmesa
->driDrawable
;
97 if (!fmesa
->hw_locked
)
100 fmesa
->regs
->fbc
= (FFB_FBC_WB_C
| FFB_FBC_ZE_ON
|
101 FFB_FBC_YE_OFF
| FFB_FBC_RGBE_OFF
);
102 fmesa
->regs
->ppc
= FFB_PPC_ZS_VAR
;
103 fmesa
->ffbScreen
->rp_active
= 1;
104 FFBWait(fmesa
, fmesa
->regs
);
106 zbase
= ((char *)fmesa
->sfb32
+
107 (dPriv
->x
<< 2) + (dPriv
->y
<< 13));
109 for (i
= 0; i
< n
; i
++) {
110 GLint y1
= (dPriv
->h
- y
[i
]);
115 (zbase
+ (x1
<< 2) + (y1
<< 13));
117 *zptr
= Z_FROM_MESA(depth
[i
]);
121 fmesa
->regs
->fbc
= fmesa
->fbc
;
122 fmesa
->regs
->ppc
= fmesa
->ppc
;
123 fmesa
->ffbScreen
->rp_active
= 1;
124 if (!fmesa
->hw_locked
)
125 UNLOCK_HARDWARE(fmesa
);
130 FFBReadDepthSpan(GLcontext
*ctx
, GLuint n
, GLint x
, GLint y
, GLdepth depth
[])
132 ffbContextPtr fmesa
= FFB_CONTEXT(ctx
);
133 __DRIdrawablePrivate
*dPriv
= fmesa
->driDrawable
;
138 fprintf(stderr
, "FFBReadDepthSpan: n(%d) x(%d) y(%d)\n",
141 if (!fmesa
->hw_locked
)
142 LOCK_HARDWARE(fmesa
);
144 fmesa
->regs
->fbc
= FFB_FBC_RB_C
;
145 fmesa
->ffbScreen
->rp_active
= 1;
146 FFBWait(fmesa
, fmesa
->regs
);
150 ((char *)fmesa
->sfb32
+
151 ((dPriv
->x
+ x
) << 2) +
152 ((dPriv
->y
+ y
) << 13));
154 for (i
= 0; i
< n
; i
++) {
155 depth
[i
] = Z_TO_MESA(*zptr
);
160 fmesa
->regs
->fbc
= fmesa
->fbc
;
161 fmesa
->ffbScreen
->rp_active
= 1;
162 if (!fmesa
->hw_locked
)
163 UNLOCK_HARDWARE(fmesa
);
167 FFBReadDepthPixels(GLcontext
*ctx
, GLuint n
, const GLint x
[], const GLint y
[],
170 ffbContextPtr fmesa
= FFB_CONTEXT(ctx
);
171 __DRIdrawablePrivate
*dPriv
= fmesa
->driDrawable
;
176 fprintf(stderr
, "FFBReadDepthPixels: n(%d)\n", (int) n
);
178 if (!fmesa
->hw_locked
)
179 LOCK_HARDWARE(fmesa
);
181 fmesa
->regs
->fbc
= FFB_FBC_RB_C
;
182 fmesa
->ffbScreen
->rp_active
= 1;
183 FFBWait(fmesa
, fmesa
->regs
);
185 zbase
= ((char *)fmesa
->sfb32
+
186 (dPriv
->x
<< 2) + (dPriv
->y
<< 13));
188 for (i
= 0; i
< n
; i
++) {
189 GLint y1
= (dPriv
->h
- y
[i
]);
194 (zbase
+ (x1
<< 2) + (y1
<< 13));
195 depth
[i
] = Z_TO_MESA(*zptr
);
199 fmesa
->regs
->fbc
= fmesa
->fbc
;
200 fmesa
->ffbScreen
->rp_active
= 1;
201 if (!fmesa
->hw_locked
)
202 UNLOCK_HARDWARE(fmesa
);
205 void ffbDDInitDepthFuncs(GLcontext
*ctx
)
207 struct swrast_device_driver
*swdd
=
208 _swrast_GetDeviceDriverReference(ctx
);
210 swdd
->WriteDepthSpan
= FFBWriteDepthSpan
;
211 swdd
->ReadDepthSpan
= FFBReadDepthSpan
;
212 swdd
->WriteDepthPixels
= FFBWriteDepthPixels
;
213 swdd
->ReadDepthPixels
= FFBReadDepthPixels
;