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"
31 #include "ffb_context.h"
32 #include "ffb_depth.h"
38 static void FFBWriteDepthSpan( GLcontext
*ctx
,
39 struct gl_renderbuffer
*rb
,
40 GLuint n
, GLint x
, GLint y
,
42 const GLubyte mask
[] )
44 const GLuint
*depth
= (const GLuint
*) values
;
46 fprintf(stderr
, "FFBWriteDepthSpan: n(%d) x(%d) y(%d)\n",
49 if (ctx
->Depth
.Mask
) {
50 ffbContextPtr fmesa
= FFB_CONTEXT(ctx
);
51 __DRIdrawable
*dPriv
= fmesa
->driDrawable
;
55 if (!fmesa
->hw_locked
)
58 fmesa
->regs
->fbc
= (FFB_FBC_WB_C
| FFB_FBC_ZE_ON
|
59 FFB_FBC_YE_OFF
| FFB_FBC_RGBE_OFF
);
60 fmesa
->regs
->ppc
= FFB_PPC_ZS_VAR
;
61 FFBWait(fmesa
, fmesa
->regs
);
65 ((char *)fmesa
->sfb32
+
66 ((dPriv
->x
+ x
) << 2) +
67 ((dPriv
->y
+ y
) << 13));
69 for (i
= 0; i
< n
; i
++) {
71 *zptr
= Z_FROM_MESA(depth
[i
]);
77 fmesa
->regs
->fbc
= fmesa
->fbc
;
78 fmesa
->regs
->ppc
= fmesa
->ppc
;
79 fmesa
->ffbScreen
->rp_active
= 1;
80 if (!fmesa
->hw_locked
)
81 UNLOCK_HARDWARE(fmesa
);
85 static void FFBWriteMonoDepthSpan( GLcontext
*ctx
,
86 struct gl_renderbuffer
*rb
,
87 GLuint n
, GLint x
, GLint y
,
88 const void *value
, const GLubyte mask
[] )
90 const GLuint depthVal
= *((GLuint
*) value
);
91 GLuint depths
[MAX_WIDTH
];
93 for (i
= 0; i
< n
; i
++)
95 FFBWriteDepthSpan(ctx
, rb
, n
, x
, y
, depths
, mask
);
98 static void FFBWriteDepthPixels( GLcontext
*ctx
,
99 struct gl_renderbuffer
*rb
,
104 const GLubyte mask
[] )
106 const GLuint
*depth
= (const GLuint
*) values
;
108 fprintf(stderr
, "FFBWriteDepthPixels: n(%d)\n", (int) n
);
110 if (ctx
->Depth
.Mask
) {
111 ffbContextPtr fmesa
= FFB_CONTEXT(ctx
);
112 __DRIdrawable
*dPriv
= fmesa
->driDrawable
;
116 if (!fmesa
->hw_locked
)
117 LOCK_HARDWARE(fmesa
);
119 fmesa
->regs
->fbc
= (FFB_FBC_WB_C
| FFB_FBC_ZE_ON
|
120 FFB_FBC_YE_OFF
| FFB_FBC_RGBE_OFF
);
121 fmesa
->regs
->ppc
= FFB_PPC_ZS_VAR
;
122 fmesa
->ffbScreen
->rp_active
= 1;
123 FFBWait(fmesa
, fmesa
->regs
);
125 zbase
= ((char *)fmesa
->sfb32
+
126 (dPriv
->x
<< 2) + (dPriv
->y
<< 13));
128 for (i
= 0; i
< n
; i
++) {
129 GLint y1
= (dPriv
->h
- y
[i
]);
134 (zbase
+ (x1
<< 2) + (y1
<< 13));
136 *zptr
= Z_FROM_MESA(depth
[i
]);
140 fmesa
->regs
->fbc
= fmesa
->fbc
;
141 fmesa
->regs
->ppc
= fmesa
->ppc
;
142 fmesa
->ffbScreen
->rp_active
= 1;
143 if (!fmesa
->hw_locked
)
144 UNLOCK_HARDWARE(fmesa
);
148 static void FFBReadDepthSpan( GLcontext
*ctx
,
149 struct gl_renderbuffer
*rb
,
150 GLuint n
, GLint x
, GLint y
,
153 GLuint
*depth
= (GLuint
*) values
;
154 ffbContextPtr fmesa
= FFB_CONTEXT(ctx
);
155 __DRIdrawable
*dPriv
= fmesa
->driDrawable
;
160 fprintf(stderr
, "FFBReadDepthSpan: n(%d) x(%d) y(%d)\n",
163 if (!fmesa
->hw_locked
)
164 LOCK_HARDWARE(fmesa
);
166 fmesa
->regs
->fbc
= FFB_FBC_RB_C
;
167 fmesa
->ffbScreen
->rp_active
= 1;
168 FFBWait(fmesa
, fmesa
->regs
);
172 ((char *)fmesa
->sfb32
+
173 ((dPriv
->x
+ x
) << 2) +
174 ((dPriv
->y
+ y
) << 13));
176 for (i
= 0; i
< n
; i
++) {
177 depth
[i
] = Z_TO_MESA(*zptr
);
182 fmesa
->regs
->fbc
= fmesa
->fbc
;
183 fmesa
->ffbScreen
->rp_active
= 1;
184 if (!fmesa
->hw_locked
)
185 UNLOCK_HARDWARE(fmesa
);
188 static void FFBReadDepthPixels( GLcontext
*ctx
,
189 struct gl_renderbuffer
*rb
,
191 const GLint x
[], const GLint y
[],
194 GLuint
*depth
= (GLuint
*) values
;
195 ffbContextPtr fmesa
= FFB_CONTEXT(ctx
);
196 __DRIdrawable
*dPriv
= fmesa
->driDrawable
;
201 fprintf(stderr
, "FFBReadDepthPixels: n(%d)\n", (int) n
);
203 if (!fmesa
->hw_locked
)
204 LOCK_HARDWARE(fmesa
);
206 fmesa
->regs
->fbc
= FFB_FBC_RB_C
;
207 fmesa
->ffbScreen
->rp_active
= 1;
208 FFBWait(fmesa
, fmesa
->regs
);
210 zbase
= ((char *)fmesa
->sfb32
+
211 (dPriv
->x
<< 2) + (dPriv
->y
<< 13));
213 for (i
= 0; i
< n
; i
++) {
214 GLint y1
= (dPriv
->h
- y
[i
]);
219 (zbase
+ (x1
<< 2) + (y1
<< 13));
220 depth
[i
] = Z_TO_MESA(*zptr
);
224 fmesa
->regs
->fbc
= fmesa
->fbc
;
225 fmesa
->ffbScreen
->rp_active
= 1;
226 if (!fmesa
->hw_locked
)
227 UNLOCK_HARDWARE(fmesa
);
231 * Plug in the Get/Put routines for the given driRenderbuffer.
234 ffbSetDepthFunctions(driRenderbuffer
*drb
, const GLvisual
*vis
)
236 assert(drb
->Base
.InternalFormat
== GL_DEPTH_COMPONENT16
);
237 drb
->Base
.GetRow
= FFBReadDepthSpan
;
238 drb
->Base
.GetValues
= FFBReadDepthPixels
;
239 drb
->Base
.PutRow
= FFBWriteDepthSpan
;
240 drb
->Base
.PutMonoRow
= FFBWriteMonoDepthSpan
;
241 drb
->Base
.PutValues
= FFBWriteDepthPixels
;
242 drb
->Base
.PutMonoValues
= NULL
;