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"
40 static void FFBWriteDepthSpan( GLcontext
*ctx
,
41 struct gl_renderbuffer
*rb
,
42 GLuint n
, GLint x
, GLint y
,
44 const GLubyte mask
[] )
46 const GLuint
*depth
= (const GLuint
*) values
;
48 fprintf(stderr
, "FFBWriteDepthSpan: n(%d) x(%d) y(%d)\n",
51 if (ctx
->Depth
.Mask
) {
52 ffbContextPtr fmesa
= FFB_CONTEXT(ctx
);
53 __DRIdrawablePrivate
*dPriv
= fmesa
->driDrawable
;
57 if (!fmesa
->hw_locked
)
60 fmesa
->regs
->fbc
= (FFB_FBC_WB_C
| FFB_FBC_ZE_ON
|
61 FFB_FBC_YE_OFF
| FFB_FBC_RGBE_OFF
);
62 fmesa
->regs
->ppc
= FFB_PPC_ZS_VAR
;
63 FFBWait(fmesa
, fmesa
->regs
);
67 ((char *)fmesa
->sfb32
+
68 ((dPriv
->x
+ x
) << 2) +
69 ((dPriv
->y
+ y
) << 13));
71 for (i
= 0; i
< n
; i
++) {
73 *zptr
= Z_FROM_MESA(depth
[i
]);
79 fmesa
->regs
->fbc
= fmesa
->fbc
;
80 fmesa
->regs
->ppc
= fmesa
->ppc
;
81 fmesa
->ffbScreen
->rp_active
= 1;
82 if (!fmesa
->hw_locked
)
83 UNLOCK_HARDWARE(fmesa
);
87 static void FFBWriteMonoDepthSpan( GLcontext
*ctx
,
88 struct gl_renderbuffer
*rb
,
89 GLuint n
, GLint x
, GLint y
,
90 const void *value
, const GLubyte mask
[] )
92 const GLuint depthVal
= *((GLuint
*) value
);
93 GLuint depths
[MAX_WIDTH
];
95 for (i
= 0; i
< n
; i
++)
97 FFBWriteDepthSpan(ctx
, rb
, n
, x
, y
, depths
, mask
);
100 static void FFBWriteDepthPixels( GLcontext
*ctx
,
101 struct gl_renderbuffer
*rb
,
106 const GLubyte mask
[] )
108 const GLuint
*depth
= (const GLuint
*) values
;
110 fprintf(stderr
, "FFBWriteDepthPixels: n(%d)\n", (int) n
);
112 if (ctx
->Depth
.Mask
) {
113 ffbContextPtr fmesa
= FFB_CONTEXT(ctx
);
114 __DRIdrawablePrivate
*dPriv
= fmesa
->driDrawable
;
118 if (!fmesa
->hw_locked
)
119 LOCK_HARDWARE(fmesa
);
121 fmesa
->regs
->fbc
= (FFB_FBC_WB_C
| FFB_FBC_ZE_ON
|
122 FFB_FBC_YE_OFF
| FFB_FBC_RGBE_OFF
);
123 fmesa
->regs
->ppc
= FFB_PPC_ZS_VAR
;
124 fmesa
->ffbScreen
->rp_active
= 1;
125 FFBWait(fmesa
, fmesa
->regs
);
127 zbase
= ((char *)fmesa
->sfb32
+
128 (dPriv
->x
<< 2) + (dPriv
->y
<< 13));
130 for (i
= 0; i
< n
; i
++) {
131 GLint y1
= (dPriv
->h
- y
[i
]);
136 (zbase
+ (x1
<< 2) + (y1
<< 13));
138 *zptr
= Z_FROM_MESA(depth
[i
]);
142 fmesa
->regs
->fbc
= fmesa
->fbc
;
143 fmesa
->regs
->ppc
= fmesa
->ppc
;
144 fmesa
->ffbScreen
->rp_active
= 1;
145 if (!fmesa
->hw_locked
)
146 UNLOCK_HARDWARE(fmesa
);
150 static void FFBReadDepthSpan( GLcontext
*ctx
,
151 struct gl_renderbuffer
*rb
,
152 GLuint n
, GLint x
, GLint y
,
155 GLuint
*depth
= (GLuint
*) values
;
156 ffbContextPtr fmesa
= FFB_CONTEXT(ctx
);
157 __DRIdrawablePrivate
*dPriv
= fmesa
->driDrawable
;
162 fprintf(stderr
, "FFBReadDepthSpan: n(%d) x(%d) y(%d)\n",
165 if (!fmesa
->hw_locked
)
166 LOCK_HARDWARE(fmesa
);
168 fmesa
->regs
->fbc
= FFB_FBC_RB_C
;
169 fmesa
->ffbScreen
->rp_active
= 1;
170 FFBWait(fmesa
, fmesa
->regs
);
174 ((char *)fmesa
->sfb32
+
175 ((dPriv
->x
+ x
) << 2) +
176 ((dPriv
->y
+ y
) << 13));
178 for (i
= 0; i
< n
; i
++) {
179 depth
[i
] = Z_TO_MESA(*zptr
);
184 fmesa
->regs
->fbc
= fmesa
->fbc
;
185 fmesa
->ffbScreen
->rp_active
= 1;
186 if (!fmesa
->hw_locked
)
187 UNLOCK_HARDWARE(fmesa
);
190 static void FFBReadDepthPixels( GLcontext
*ctx
,
191 struct gl_renderbuffer
*rb
,
193 const GLint x
[], const GLint y
[],
196 GLuint
*depth
= (GLuint
*) values
;
197 ffbContextPtr fmesa
= FFB_CONTEXT(ctx
);
198 __DRIdrawablePrivate
*dPriv
= fmesa
->driDrawable
;
203 fprintf(stderr
, "FFBReadDepthPixels: n(%d)\n", (int) n
);
205 if (!fmesa
->hw_locked
)
206 LOCK_HARDWARE(fmesa
);
208 fmesa
->regs
->fbc
= FFB_FBC_RB_C
;
209 fmesa
->ffbScreen
->rp_active
= 1;
210 FFBWait(fmesa
, fmesa
->regs
);
212 zbase
= ((char *)fmesa
->sfb32
+
213 (dPriv
->x
<< 2) + (dPriv
->y
<< 13));
215 for (i
= 0; i
< n
; i
++) {
216 GLint y1
= (dPriv
->h
- y
[i
]);
221 (zbase
+ (x1
<< 2) + (y1
<< 13));
222 depth
[i
] = Z_TO_MESA(*zptr
);
226 fmesa
->regs
->fbc
= fmesa
->fbc
;
227 fmesa
->ffbScreen
->rp_active
= 1;
228 if (!fmesa
->hw_locked
)
229 UNLOCK_HARDWARE(fmesa
);
233 * Plug in the Get/Put routines for the given driRenderbuffer.
236 ffbSetDepthFunctions(driRenderbuffer
*drb
, const GLvisual
*vis
)
238 assert(drb
->Base
.InternalFormat
== GL_DEPTH_COMPONENT16
);
239 drb
->Base
.GetRow
= FFBReadDepthSpan
;
240 drb
->Base
.GetValues
= FFBReadDepthPixels
;
241 drb
->Base
.PutRow
= FFBWriteDepthSpan
;
242 drb
->Base
.PutMonoRow
= FFBWriteMonoDepthSpan
;
243 drb
->Base
.PutValues
= FFBWriteDepthPixels
;
244 drb
->Base
.PutMonoValues
= NULL
;