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>
28 #include "main/mtypes.h"
29 #include "swrast/swrast.h"
32 #include "ffb_context.h"
33 #include "ffb_depth.h"
39 static void FFBWriteDepthSpan( GLcontext
*ctx
,
40 struct gl_renderbuffer
*rb
,
41 GLuint n
, GLint x
, GLint y
,
43 const GLubyte mask
[] )
45 const GLuint
*depth
= (const GLuint
*) values
;
47 fprintf(stderr
, "FFBWriteDepthSpan: n(%d) x(%d) y(%d)\n",
50 if (ctx
->Depth
.Mask
) {
51 ffbContextPtr fmesa
= FFB_CONTEXT(ctx
);
52 __DRIdrawablePrivate
*dPriv
= fmesa
->driDrawable
;
56 if (!fmesa
->hw_locked
)
59 fmesa
->regs
->fbc
= (FFB_FBC_WB_C
| FFB_FBC_ZE_ON
|
60 FFB_FBC_YE_OFF
| FFB_FBC_RGBE_OFF
);
61 fmesa
->regs
->ppc
= FFB_PPC_ZS_VAR
;
62 FFBWait(fmesa
, fmesa
->regs
);
66 ((char *)fmesa
->sfb32
+
67 ((dPriv
->x
+ x
) << 2) +
68 ((dPriv
->y
+ y
) << 13));
70 for (i
= 0; i
< n
; i
++) {
72 *zptr
= Z_FROM_MESA(depth
[i
]);
78 fmesa
->regs
->fbc
= fmesa
->fbc
;
79 fmesa
->regs
->ppc
= fmesa
->ppc
;
80 fmesa
->ffbScreen
->rp_active
= 1;
81 if (!fmesa
->hw_locked
)
82 UNLOCK_HARDWARE(fmesa
);
86 static void FFBWriteMonoDepthSpan( GLcontext
*ctx
,
87 struct gl_renderbuffer
*rb
,
88 GLuint n
, GLint x
, GLint y
,
89 const void *value
, const GLubyte mask
[] )
91 const GLuint depthVal
= *((GLuint
*) value
);
92 GLuint depths
[MAX_WIDTH
];
94 for (i
= 0; i
< n
; i
++)
96 FFBWriteDepthSpan(ctx
, rb
, n
, x
, y
, depths
, mask
);
99 static void FFBWriteDepthPixels( GLcontext
*ctx
,
100 struct gl_renderbuffer
*rb
,
105 const GLubyte mask
[] )
107 const GLuint
*depth
= (const GLuint
*) values
;
109 fprintf(stderr
, "FFBWriteDepthPixels: n(%d)\n", (int) n
);
111 if (ctx
->Depth
.Mask
) {
112 ffbContextPtr fmesa
= FFB_CONTEXT(ctx
);
113 __DRIdrawablePrivate
*dPriv
= fmesa
->driDrawable
;
117 if (!fmesa
->hw_locked
)
118 LOCK_HARDWARE(fmesa
);
120 fmesa
->regs
->fbc
= (FFB_FBC_WB_C
| FFB_FBC_ZE_ON
|
121 FFB_FBC_YE_OFF
| FFB_FBC_RGBE_OFF
);
122 fmesa
->regs
->ppc
= FFB_PPC_ZS_VAR
;
123 fmesa
->ffbScreen
->rp_active
= 1;
124 FFBWait(fmesa
, fmesa
->regs
);
126 zbase
= ((char *)fmesa
->sfb32
+
127 (dPriv
->x
<< 2) + (dPriv
->y
<< 13));
129 for (i
= 0; i
< n
; i
++) {
130 GLint y1
= (dPriv
->h
- y
[i
]);
135 (zbase
+ (x1
<< 2) + (y1
<< 13));
137 *zptr
= Z_FROM_MESA(depth
[i
]);
141 fmesa
->regs
->fbc
= fmesa
->fbc
;
142 fmesa
->regs
->ppc
= fmesa
->ppc
;
143 fmesa
->ffbScreen
->rp_active
= 1;
144 if (!fmesa
->hw_locked
)
145 UNLOCK_HARDWARE(fmesa
);
149 static void FFBReadDepthSpan( GLcontext
*ctx
,
150 struct gl_renderbuffer
*rb
,
151 GLuint n
, GLint x
, GLint y
,
154 GLuint
*depth
= (GLuint
*) values
;
155 ffbContextPtr fmesa
= FFB_CONTEXT(ctx
);
156 __DRIdrawablePrivate
*dPriv
= fmesa
->driDrawable
;
161 fprintf(stderr
, "FFBReadDepthSpan: n(%d) x(%d) y(%d)\n",
164 if (!fmesa
->hw_locked
)
165 LOCK_HARDWARE(fmesa
);
167 fmesa
->regs
->fbc
= FFB_FBC_RB_C
;
168 fmesa
->ffbScreen
->rp_active
= 1;
169 FFBWait(fmesa
, fmesa
->regs
);
173 ((char *)fmesa
->sfb32
+
174 ((dPriv
->x
+ x
) << 2) +
175 ((dPriv
->y
+ y
) << 13));
177 for (i
= 0; i
< n
; i
++) {
178 depth
[i
] = Z_TO_MESA(*zptr
);
183 fmesa
->regs
->fbc
= fmesa
->fbc
;
184 fmesa
->ffbScreen
->rp_active
= 1;
185 if (!fmesa
->hw_locked
)
186 UNLOCK_HARDWARE(fmesa
);
189 static void FFBReadDepthPixels( GLcontext
*ctx
,
190 struct gl_renderbuffer
*rb
,
192 const GLint x
[], const GLint y
[],
195 GLuint
*depth
= (GLuint
*) values
;
196 ffbContextPtr fmesa
= FFB_CONTEXT(ctx
);
197 __DRIdrawablePrivate
*dPriv
= fmesa
->driDrawable
;
202 fprintf(stderr
, "FFBReadDepthPixels: n(%d)\n", (int) n
);
204 if (!fmesa
->hw_locked
)
205 LOCK_HARDWARE(fmesa
);
207 fmesa
->regs
->fbc
= FFB_FBC_RB_C
;
208 fmesa
->ffbScreen
->rp_active
= 1;
209 FFBWait(fmesa
, fmesa
->regs
);
211 zbase
= ((char *)fmesa
->sfb32
+
212 (dPriv
->x
<< 2) + (dPriv
->y
<< 13));
214 for (i
= 0; i
< n
; i
++) {
215 GLint y1
= (dPriv
->h
- y
[i
]);
220 (zbase
+ (x1
<< 2) + (y1
<< 13));
221 depth
[i
] = Z_TO_MESA(*zptr
);
225 fmesa
->regs
->fbc
= fmesa
->fbc
;
226 fmesa
->ffbScreen
->rp_active
= 1;
227 if (!fmesa
->hw_locked
)
228 UNLOCK_HARDWARE(fmesa
);
232 * Plug in the Get/Put routines for the given driRenderbuffer.
235 ffbSetDepthFunctions(driRenderbuffer
*drb
, const GLvisual
*vis
)
237 assert(drb
->Base
.InternalFormat
== GL_DEPTH_COMPONENT16
);
238 drb
->Base
.GetRow
= FFBReadDepthSpan
;
239 drb
->Base
.GetValues
= FFBReadDepthPixels
;
240 drb
->Base
.PutRow
= FFBWriteDepthSpan
;
241 drb
->Base
.PutMonoRow
= FFBWriteMonoDepthSpan
;
242 drb
->Base
.PutValues
= FFBWriteDepthPixels
;
243 drb
->Base
.PutMonoValues
= NULL
;