1 | /* -*- mode: C; tab-width:8; c-basic-offset:2 -*- */
|
---|
2 |
|
---|
3 | /*
|
---|
4 | * Mesa 3-D graphics library
|
---|
5 | * Version: 3.3
|
---|
6 | *
|
---|
7 | * Copyright (C) 1999 Brian Paul All Rights Reserved.
|
---|
8 | *
|
---|
9 | * Permission is hereby granted, free of charge, to any person obtaining a
|
---|
10 | * copy of this software and associated documentation files (the "Software"),
|
---|
11 | * to deal in the Software without restriction, including without limitation
|
---|
12 | * the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
---|
13 | * and/or sell copies of the Software, and to permit persons to whom the
|
---|
14 | * Software is furnished to do so, subject to the following conditions:
|
---|
15 | *
|
---|
16 | * The above copyright notice and this permission notice shall be included
|
---|
17 | * in all copies or substantial portions of the Software.
|
---|
18 | *
|
---|
19 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
---|
20 | * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
---|
21 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
---|
22 | * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
|
---|
23 | * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
---|
24 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
---|
25 | *
|
---|
26 | *
|
---|
27 | * Original Mesa / 3Dfx device driver (C) 1999 David Bucciarelli, by the
|
---|
28 | * terms stated above.
|
---|
29 | *
|
---|
30 | * Thank you for your contribution, David!
|
---|
31 | *
|
---|
32 | * Please make note of the above copyright/license statement. If you
|
---|
33 | * contributed code or bug fixes to this code under the previous (GNU
|
---|
34 | * Library) license and object to the new license, your code will be
|
---|
35 | * removed at your request. Please see the Mesa docs/COPYRIGHT file
|
---|
36 | * for more information.
|
---|
37 | *
|
---|
38 | * Additional Mesa/3Dfx driver developers:
|
---|
39 | * Daryll Strauss <daryll@precisioninsight.com>
|
---|
40 | * Keith Whitwell <keith@precisioninsight.com>
|
---|
41 | *
|
---|
42 | * See fxapi.h for more revision/author details.
|
---|
43 | */
|
---|
44 |
|
---|
45 |
|
---|
46 | /* fxdd.c - 3Dfx VooDoo Mesa span and pixel functions */
|
---|
47 |
|
---|
48 |
|
---|
49 | #ifdef HAVE_CONFIG_H
|
---|
50 | #include "conf.h"
|
---|
51 | #endif
|
---|
52 |
|
---|
53 | #if defined(FX)
|
---|
54 |
|
---|
55 | #include "fxdrv.h"
|
---|
56 |
|
---|
57 | #ifdef _MSC_VER
|
---|
58 | #ifdef _WIN32
|
---|
59 | #pragma warning( disable : 4090 4022 )
|
---|
60 | /* 4101 : "different 'const' qualifier"
|
---|
61 | * 4022 : "pointer mistmatch for actual parameter 'n'
|
---|
62 | */
|
---|
63 | #endif
|
---|
64 | #endif
|
---|
65 |
|
---|
66 |
|
---|
67 | #if !defined(FXMESA_USE_ARGB)
|
---|
68 |
|
---|
69 |
|
---|
70 | #if defined(FX_GLIDE3) && defined(XF86DRI)
|
---|
71 |
|
---|
72 | static FxBool writeRegionClipped(fxMesaContext fxMesa, GrBuffer_t dst_buffer,
|
---|
73 | FxU32 dst_x, FxU32 dst_y, GrLfbSrcFmt_t src_format,
|
---|
74 | FxU32 src_width, FxU32 src_height, FxI32 src_stride,
|
---|
75 | void *src_data)
|
---|
76 | {
|
---|
77 | int i, x, w, srcElt;
|
---|
78 | void *data;
|
---|
79 |
|
---|
80 | if (src_width==1 && src_height==1) { /* Easy case writing a point */
|
---|
81 | for (i=0; i<fxMesa->numClipRects; i++) {
|
---|
82 | if ((dst_x>=fxMesa->pClipRects[i].x1) &&
|
---|
83 | (dst_x<fxMesa->pClipRects[i].x2) &&
|
---|
84 | (dst_y>=fxMesa->pClipRects[i].y1) &&
|
---|
85 | (dst_y<fxMesa->pClipRects[i].y2)) {
|
---|
86 | FX_grLfbWriteRegion(dst_buffer, dst_x, dst_y, src_format,
|
---|
87 | 1, 1, src_stride, src_data);
|
---|
88 | return GL_TRUE;
|
---|
89 | }
|
---|
90 | }
|
---|
91 | } else if (src_height==1) { /* Writing a span */
|
---|
92 | if (src_format==GR_LFB_SRC_FMT_8888) srcElt=4;
|
---|
93 | else if (src_format==GR_LFB_SRC_FMT_ZA16) srcElt=2;
|
---|
94 | else {
|
---|
95 | fprintf(stderr, "Unknown src_format passed to writeRegionClipped\n");
|
---|
96 | return GL_FALSE;
|
---|
97 | }
|
---|
98 | for (i=0; i<fxMesa->numClipRects; i++) {
|
---|
99 | if (dst_y>=fxMesa->pClipRects[i].y1 && dst_y<fxMesa->pClipRects[i].y2) {
|
---|
100 | if (dst_x<fxMesa->pClipRects[i].x1) {
|
---|
101 | x=fxMesa->pClipRects[i].x1;
|
---|
102 | data=((char*)src_data)+srcElt*(dst_x-x);
|
---|
103 | w=src_width-(x-dst_x);
|
---|
104 | } else {
|
---|
105 | x=dst_x;
|
---|
106 | data=src_data;
|
---|
107 | w=src_width;
|
---|
108 | }
|
---|
109 | if (x+w>fxMesa->pClipRects[i].x2) {
|
---|
110 | w=fxMesa->pClipRects[i].x2-x;
|
---|
111 | }
|
---|
112 | FX_grLfbWriteRegion(dst_buffer, x, dst_y, src_format, w, 1,
|
---|
113 | src_stride, data);
|
---|
114 | }
|
---|
115 | }
|
---|
116 | } else { /* Punt on the case of arbitrary rectangles */
|
---|
117 | return GL_FALSE;
|
---|
118 | }
|
---|
119 | return GL_TRUE;
|
---|
120 | }
|
---|
121 |
|
---|
122 | #else
|
---|
123 |
|
---|
124 | #define writeRegionClipped(fxm,dst_buffer,dst_x,dst_y,src_format,src_width,src_height,src_stride,src_data) \
|
---|
125 | FX_grLfbWriteRegion(dst_buffer,dst_x,dst_y,src_format,src_width,src_height,src_stride,src_data)
|
---|
126 |
|
---|
127 | #endif
|
---|
128 |
|
---|
129 |
|
---|
130 | /* KW: Rearranged the args in the call to grLfbWriteRegion().
|
---|
131 | */
|
---|
132 | #define LFB_WRITE_SPAN_MESA(dst_buffer, \
|
---|
133 | dst_x, \
|
---|
134 | dst_y, \
|
---|
135 | src_width, \
|
---|
136 | src_stride, \
|
---|
137 | src_data) \
|
---|
138 | writeRegionClipped(fxMesa, dst_buffer, \
|
---|
139 | dst_x, \
|
---|
140 | dst_y, \
|
---|
141 | GR_LFB_SRC_FMT_8888, \
|
---|
142 | src_width, \
|
---|
143 | 1, \
|
---|
144 | src_stride, \
|
---|
145 | src_data) \
|
---|
146 |
|
---|
147 |
|
---|
148 | #else /* !defined(FXMESA_USE_RGBA) */
|
---|
149 |
|
---|
150 | #define writeRegionClipped(fxm,dst_buffer,dst_x,dst_y,src_format,src_width,src_height,src_stride,src_data) \
|
---|
151 | FX_grLfbWriteRegion(dst_buffer,dst_x,dst_y,src_format,src_width,src_height,src_stride,src_data)
|
---|
152 |
|
---|
153 |
|
---|
154 | #define MESACOLOR_TO_ARGB(c) ( \
|
---|
155 | ( ((unsigned int)(c[ACOMP]))<<24 ) | \
|
---|
156 | ( ((unsigned int)(c[RCOMP]))<<16 ) | \
|
---|
157 | ( ((unsigned int)(c[GCOMP]))<<8 ) | \
|
---|
158 | ( (unsigned int)(c[BCOMP])) )
|
---|
159 |
|
---|
160 | inline void LFB_WRITE_SPAN_MESA(GrBuffer_t dst_buffer,
|
---|
161 | FxU32 dst_x,
|
---|
162 | FxU32 dst_y,
|
---|
163 | FxU32 src_width,
|
---|
164 | FxI32 src_stride,
|
---|
165 | void *src_data )
|
---|
166 | {
|
---|
167 | /* Covert to ARGB */
|
---|
168 | GLubyte (*rgba)[4] = src_data;
|
---|
169 | GLuint argb[MAX_WIDTH];
|
---|
170 | int i;
|
---|
171 |
|
---|
172 | for (i = 0; i < src_width; i++)
|
---|
173 | {
|
---|
174 | argb[i] = MESACOLOR_TO_ARGB(rgba[i]);
|
---|
175 | }
|
---|
176 | writeRegionClipped( /*fxMesa,*/ NULL, dst_buffer,
|
---|
177 | dst_x,
|
---|
178 | dst_y,
|
---|
179 | GR_LFB_SRC_FMT_8888,
|
---|
180 | src_width,
|
---|
181 | 1,
|
---|
182 | src_stride,
|
---|
183 | (void*)argb);
|
---|
184 | }
|
---|
185 |
|
---|
186 | #endif /* !defined(FXMESA_USE_RGBA) */
|
---|
187 |
|
---|
188 |
|
---|
189 | /************************************************************************/
|
---|
190 | /***** Span functions *****/
|
---|
191 | /************************************************************************/
|
---|
192 |
|
---|
193 |
|
---|
194 | static void fxDDWriteRGBASpan(const GLcontext *ctx,
|
---|
195 | GLuint n, GLint x, GLint y,
|
---|
196 | const GLubyte rgba[][4], const GLubyte mask[])
|
---|
197 | {
|
---|
198 | fxMesaContext fxMesa=(fxMesaContext)ctx->DriverCtx;
|
---|
199 | GLuint i;
|
---|
200 | GLint bottom=fxMesa->height+fxMesa->y_offset-1;
|
---|
201 |
|
---|
202 | if (MESA_VERBOSE&VERBOSE_DRIVER) {
|
---|
203 | fprintf(stderr,"fxmesa: fxDDWriteRGBASpan(...)\n");
|
---|
204 | }
|
---|
205 |
|
---|
206 | x+=fxMesa->x_offset;
|
---|
207 | if (mask) {
|
---|
208 | int span=0;
|
---|
209 |
|
---|
210 | for (i=0;i<n;i++) {
|
---|
211 | if (mask[i]) {
|
---|
212 | ++span;
|
---|
213 | } else {
|
---|
214 | if (span > 0) {
|
---|
215 | LFB_WRITE_SPAN_MESA( fxMesa->currentFB, x+i-span, bottom-y,
|
---|
216 | /* GR_LFB_SRC_FMT_8888,*/ span, /*1,*/ 0, (void *) rgba[i-span] );
|
---|
217 | span = 0;
|
---|
218 | }
|
---|
219 | }
|
---|
220 | }
|
---|
221 |
|
---|
222 | if (span > 0)
|
---|
223 | LFB_WRITE_SPAN_MESA( fxMesa->currentFB, x+n-span, bottom-y,
|
---|
224 | /* GR_LFB_SRC_FMT_8888, */ span, /*1,*/ 0, (void *) rgba[n-span] );
|
---|
225 | } else
|
---|
226 | LFB_WRITE_SPAN_MESA( fxMesa->currentFB, x, bottom-y,/* GR_LFB_SRC_FMT_8888,*/
|
---|
227 | n,/* 1,*/ 0, (void *) rgba );
|
---|
228 | }
|
---|
229 |
|
---|
230 |
|
---|
231 | static void fxDDWriteRGBSpan(const GLcontext *ctx,
|
---|
232 | GLuint n, GLint x, GLint y,
|
---|
233 | const GLubyte rgb[][3], const GLubyte mask[])
|
---|
234 | {
|
---|
235 | fxMesaContext fxMesa=(fxMesaContext)ctx->DriverCtx;
|
---|
236 | GLuint i;
|
---|
237 | GLint bottom=fxMesa->height+fxMesa->y_offset-1;
|
---|
238 | GLubyte rgba[MAX_WIDTH][4];
|
---|
239 |
|
---|
240 | if (MESA_VERBOSE&VERBOSE_DRIVER) {
|
---|
241 | fprintf(stderr,"fxmesa: fxDDWriteRGBSpan()\n");
|
---|
242 | }
|
---|
243 |
|
---|
244 | x+=fxMesa->x_offset;
|
---|
245 | if (mask) {
|
---|
246 | int span=0;
|
---|
247 |
|
---|
248 | for (i=0;i<n;i++) {
|
---|
249 | if (mask[i]) {
|
---|
250 | rgba[span][RCOMP] = rgb[i][0];
|
---|
251 | rgba[span][GCOMP] = rgb[i][1];
|
---|
252 | rgba[span][BCOMP] = rgb[i][2];
|
---|
253 | rgba[span][ACOMP] = 255;
|
---|
254 | ++span;
|
---|
255 | } else {
|
---|
256 | if (span > 0) {
|
---|
257 | LFB_WRITE_SPAN_MESA( fxMesa->currentFB, x+i-span, bottom-y,
|
---|
258 | /*GR_LFB_SRC_FMT_8888,*/ span,/* 1,*/ 0, (void *) rgba );
|
---|
259 | span = 0;
|
---|
260 | }
|
---|
261 | }
|
---|
262 | }
|
---|
263 |
|
---|
264 | if (span > 0)
|
---|
265 | LFB_WRITE_SPAN_MESA( fxMesa->currentFB, x+n-span, bottom-y,
|
---|
266 | /*GR_LFB_SRC_FMT_8888,*/ span,/* 1,*/ 0, (void *) rgba );
|
---|
267 | } else {
|
---|
268 | for (i=0;i<n;i++) {
|
---|
269 | rgba[i][RCOMP]=rgb[i][0];
|
---|
270 | rgba[i][GCOMP]=rgb[i][1];
|
---|
271 | rgba[i][BCOMP]=rgb[i][2];
|
---|
272 | rgba[i][ACOMP]=255;
|
---|
273 | }
|
---|
274 |
|
---|
275 | LFB_WRITE_SPAN_MESA( fxMesa->currentFB, x, bottom-y,/* GR_LFB_SRC_FMT_8888,*/
|
---|
276 | n,/* 1,*/ 0, (void *) rgba );
|
---|
277 | }
|
---|
278 | }
|
---|
279 |
|
---|
280 |
|
---|
281 | static void fxDDWriteMonoRGBASpan(const GLcontext *ctx,
|
---|
282 | GLuint n, GLint x, GLint y,
|
---|
283 | const GLubyte mask[])
|
---|
284 | {
|
---|
285 | fxMesaContext fxMesa=(fxMesaContext)ctx->DriverCtx;
|
---|
286 | GLuint i;
|
---|
287 | GLint bottom=fxMesa->height+fxMesa->y_offset-1;
|
---|
288 | GLuint data[MAX_WIDTH];
|
---|
289 |
|
---|
290 | if (MESA_VERBOSE&VERBOSE_DRIVER) {
|
---|
291 | fprintf(stderr,"fxmesa: fxDDWriteMonoRGBASpan(...)\n");
|
---|
292 | }
|
---|
293 |
|
---|
294 | x+=fxMesa->x_offset;
|
---|
295 | if (mask) {
|
---|
296 | int span=0;
|
---|
297 |
|
---|
298 | for (i=0;i<n;i++) {
|
---|
299 | if (mask[i]) {
|
---|
300 | data[span] = (GLuint) fxMesa->color;
|
---|
301 | ++span;
|
---|
302 | } else {
|
---|
303 | if (span > 0) {
|
---|
304 | writeRegionClipped(fxMesa, fxMesa->currentFB, x+i-span, bottom-y,
|
---|
305 | GR_LFB_SRC_FMT_8888, span, 1, 0,
|
---|
306 | (void *) data );
|
---|
307 | span = 0;
|
---|
308 | }
|
---|
309 | }
|
---|
310 | }
|
---|
311 |
|
---|
312 | if (span > 0)
|
---|
313 | writeRegionClipped(fxMesa, fxMesa->currentFB, x+n-span, bottom-y,
|
---|
314 | GR_LFB_SRC_FMT_8888, span, 1, 0,
|
---|
315 | (void *) data );
|
---|
316 | } else {
|
---|
317 | for (i=0;i<n;i++) {
|
---|
318 | data[i]=(GLuint) fxMesa->color;
|
---|
319 | }
|
---|
320 |
|
---|
321 | writeRegionClipped(fxMesa, fxMesa->currentFB, x, bottom-y, GR_LFB_SRC_FMT_8888,
|
---|
322 | n, 1, 0, (void *) data );
|
---|
323 | }
|
---|
324 | }
|
---|
325 |
|
---|
326 |
|
---|
327 | static void fxDDReadRGBASpan(const GLcontext *ctx,
|
---|
328 | GLuint n, GLint x, GLint y, GLubyte rgba[][4])
|
---|
329 | {
|
---|
330 | fxMesaContext fxMesa=(fxMesaContext)ctx->DriverCtx;
|
---|
331 | GLushort data[MAX_WIDTH];
|
---|
332 | GLuint i;
|
---|
333 | GLint bottom=fxMesa->height+fxMesa->y_offset-1;
|
---|
334 |
|
---|
335 | if (MESA_VERBOSE&VERBOSE_DRIVER) {
|
---|
336 | fprintf(stderr,"fxmesa: fxDDReadRGBASpan(...)\n");
|
---|
337 | }
|
---|
338 |
|
---|
339 | assert(n < MAX_WIDTH);
|
---|
340 |
|
---|
341 | x+=fxMesa->x_offset;
|
---|
342 | FX_grLfbReadRegion( fxMesa->currentFB, x, bottom-y, n, 1, 0, data);
|
---|
343 |
|
---|
344 | for (i=0;i<n;i++) {
|
---|
345 | GLushort pixel = data[i];
|
---|
346 | rgba[i][RCOMP] = FX_PixelToR[pixel];
|
---|
347 | rgba[i][GCOMP] = FX_PixelToG[pixel];
|
---|
348 | rgba[i][BCOMP] = FX_PixelToB[pixel];
|
---|
349 | rgba[i][ACOMP] = 255;
|
---|
350 | }
|
---|
351 | }
|
---|
352 |
|
---|
353 | /************************************************************************/
|
---|
354 | /***** Pixel functions *****/
|
---|
355 | /************************************************************************/
|
---|
356 |
|
---|
357 | static void fxDDWriteRGBAPixels(const GLcontext *ctx,
|
---|
358 | GLuint n, const GLint x[], const GLint y[],
|
---|
359 | CONST GLubyte rgba[][4], const GLubyte mask[])
|
---|
360 | {
|
---|
361 | fxMesaContext fxMesa=(fxMesaContext)ctx->DriverCtx;
|
---|
362 | GLuint i;
|
---|
363 | GLint bottom=fxMesa->height+fxMesa->y_offset-1;
|
---|
364 |
|
---|
365 | if (MESA_VERBOSE&VERBOSE_DRIVER) {
|
---|
366 | fprintf(stderr,"fxmesa: fxDDWriteRGBAPixels(...)\n");
|
---|
367 | }
|
---|
368 |
|
---|
369 | for(i=0;i<n;i++)
|
---|
370 | if(mask[i])
|
---|
371 | LFB_WRITE_SPAN_MESA(fxMesa->currentFB, x[i]+fxMesa->x_offset, bottom-y[i],
|
---|
372 | 1, 1, (void *)rgba[i]);
|
---|
373 | }
|
---|
374 |
|
---|
375 | static void fxDDWriteMonoRGBAPixels(const GLcontext *ctx,
|
---|
376 | GLuint n, const GLint x[], const GLint y[],
|
---|
377 | const GLubyte mask[])
|
---|
378 | {
|
---|
379 | fxMesaContext fxMesa=(fxMesaContext)ctx->DriverCtx;
|
---|
380 | GLuint i;
|
---|
381 | GLint bottom=fxMesa->height+fxMesa->y_offset-1;
|
---|
382 |
|
---|
383 | if (MESA_VERBOSE&VERBOSE_DRIVER) {
|
---|
384 | fprintf(stderr,"fxmesa: fxDDWriteMonoRGBAPixels(...)\n");
|
---|
385 | }
|
---|
386 |
|
---|
387 | for(i=0;i<n;i++)
|
---|
388 | if(mask[i])
|
---|
389 | writeRegionClipped(fxMesa, fxMesa->currentFB,x[i]+fxMesa->x_offset,bottom-y[i],
|
---|
390 | GR_LFB_SRC_FMT_8888,1,1,0,(void *) &fxMesa->color);
|
---|
391 | }
|
---|
392 |
|
---|
393 | static void fxDDReadRGBAPixels(const GLcontext *ctx,
|
---|
394 | GLuint n, const GLint x[], const GLint y[],
|
---|
395 | GLubyte rgba[][4], const GLubyte mask[])
|
---|
396 | {
|
---|
397 | fxMesaContext fxMesa=(fxMesaContext)ctx->DriverCtx;
|
---|
398 | GLuint i;
|
---|
399 | GLint bottom=fxMesa->height+fxMesa->y_offset-1;
|
---|
400 |
|
---|
401 | if (MESA_VERBOSE&VERBOSE_DRIVER) {
|
---|
402 | fprintf(stderr,"fxmesa: fxDDReadRGBAPixels(...)\n");
|
---|
403 | }
|
---|
404 |
|
---|
405 | for(i=0;i<n;i++) {
|
---|
406 | if(mask[i]) {
|
---|
407 | GLushort pixel;
|
---|
408 | FX_grLfbReadRegion(fxMesa->currentFB,x[i],bottom-y[i],1,1,0,&pixel);
|
---|
409 | rgba[i][RCOMP] = FX_PixelToR[pixel];
|
---|
410 | rgba[i][GCOMP] = FX_PixelToG[pixel];
|
---|
411 | rgba[i][BCOMP] = FX_PixelToB[pixel];
|
---|
412 | rgba[i][ACOMP] = 255;
|
---|
413 | }
|
---|
414 | }
|
---|
415 | }
|
---|
416 |
|
---|
417 |
|
---|
418 | /************************************************************************/
|
---|
419 | /***** Depth functions *****/
|
---|
420 | /************************************************************************/
|
---|
421 |
|
---|
422 | void fxDDWriteDepthSpan(GLcontext *ctx,
|
---|
423 | GLuint n, GLint x, GLint y, const GLdepth depth[],
|
---|
424 | const GLubyte mask[])
|
---|
425 | {
|
---|
426 | fxMesaContext fxMesa = (fxMesaContext)ctx->DriverCtx;
|
---|
427 | GLint bottom = fxMesa->height + fxMesa->y_offset - 1;
|
---|
428 |
|
---|
429 | if (MESA_VERBOSE & VERBOSE_DRIVER) {
|
---|
430 | fprintf(stderr, "fxmesa: fxDDWriteDepthSpan(...)\n");
|
---|
431 | }
|
---|
432 |
|
---|
433 | x += fxMesa->x_offset;
|
---|
434 |
|
---|
435 | if (mask) {
|
---|
436 | GLint i;
|
---|
437 | for (i = 0; i < n; i++) {
|
---|
438 | if (mask[i]) {
|
---|
439 | GLshort d = depth[i];
|
---|
440 | writeRegionClipped(fxMesa, GR_BUFFER_AUXBUFFER, x + i, bottom - y,
|
---|
441 | GR_LFB_SRC_FMT_ZA16, 1, 1, 0, (void *) &d);
|
---|
442 | }
|
---|
443 | }
|
---|
444 | }
|
---|
445 | else {
|
---|
446 | GLushort depth16[MAX_WIDTH];
|
---|
447 | GLint i;
|
---|
448 | for (i = 0; i < n; i++) {
|
---|
449 | depth16[i] = depth[i];
|
---|
450 | }
|
---|
451 | writeRegionClipped(fxMesa, GR_BUFFER_AUXBUFFER, x, bottom - y,
|
---|
452 | GR_LFB_SRC_FMT_ZA16, n, 1, 0, (void *) depth16);
|
---|
453 | }
|
---|
454 | }
|
---|
455 |
|
---|
456 |
|
---|
457 | void fxDDReadDepthSpan(GLcontext *ctx,
|
---|
458 | GLuint n, GLint x, GLint y, GLdepth depth[])
|
---|
459 | {
|
---|
460 | fxMesaContext fxMesa = (fxMesaContext)ctx->DriverCtx;
|
---|
461 | GLint bottom = fxMesa->height + fxMesa->y_offset - 1;
|
---|
462 | GLushort depth16[MAX_WIDTH];
|
---|
463 | GLuint i;
|
---|
464 |
|
---|
465 | if (MESA_VERBOSE & VERBOSE_DRIVER) {
|
---|
466 | fprintf(stderr, "fxmesa: fxDDReadDepthSpan(...)\n");
|
---|
467 | }
|
---|
468 |
|
---|
469 | x += fxMesa->x_offset;
|
---|
470 | FX_grLfbReadRegion(GR_BUFFER_AUXBUFFER, x, bottom - y, n, 1, 0, depth16);
|
---|
471 | for (i = 0; i < n; i++) {
|
---|
472 | depth[i] = depth16[i];
|
---|
473 | }
|
---|
474 | }
|
---|
475 |
|
---|
476 |
|
---|
477 |
|
---|
478 | void fxDDWriteDepthPixels(GLcontext *ctx,
|
---|
479 | GLuint n, const GLint x[], const GLint y[],
|
---|
480 | const GLdepth depth[], const GLubyte mask[])
|
---|
481 | {
|
---|
482 | fxMesaContext fxMesa = (fxMesaContext)ctx->DriverCtx;
|
---|
483 | GLint bottom = fxMesa->height + fxMesa->y_offset - 1;
|
---|
484 | GLuint i;
|
---|
485 |
|
---|
486 | if (MESA_VERBOSE & VERBOSE_DRIVER) {
|
---|
487 | fprintf(stderr, "fxmesa: fxDDWriteDepthPixels(...)\n");
|
---|
488 | }
|
---|
489 |
|
---|
490 | for (i = 0; i < n; i++) {
|
---|
491 | if (mask[i]) {
|
---|
492 | int xpos = x[i] + fxMesa->x_offset;
|
---|
493 | int ypos = bottom - y[i];
|
---|
494 | GLushort d = depth[i];
|
---|
495 | writeRegionClipped(fxMesa, GR_BUFFER_AUXBUFFER, xpos, ypos,
|
---|
496 | GR_LFB_SRC_FMT_ZA16, 1, 1, 0, (void *) &d);
|
---|
497 | }
|
---|
498 | }
|
---|
499 | }
|
---|
500 |
|
---|
501 |
|
---|
502 | void fxDDReadDepthPixels(GLcontext *ctx, GLuint n,
|
---|
503 | const GLint x[], const GLint y[], GLdepth depth[])
|
---|
504 | {
|
---|
505 | fxMesaContext fxMesa = (fxMesaContext)ctx->DriverCtx;
|
---|
506 | GLint bottom = fxMesa->height + fxMesa->y_offset - 1;
|
---|
507 | GLuint i;
|
---|
508 |
|
---|
509 | if (MESA_VERBOSE & VERBOSE_DRIVER) {
|
---|
510 | fprintf(stderr, "fxmesa: fxDDReadDepthPixels(...)\n");
|
---|
511 | }
|
---|
512 |
|
---|
513 | for (i = 0; i < n; i++) {
|
---|
514 | int xpos = x[i] + fxMesa->x_offset;
|
---|
515 | int ypos = bottom - y[i];
|
---|
516 | GLushort d;
|
---|
517 | FX_grLfbReadRegion(GR_BUFFER_AUXBUFFER, xpos, ypos, 1, 1, 0, &d);
|
---|
518 | depth[i] = d;
|
---|
519 | }
|
---|
520 | }
|
---|
521 |
|
---|
522 |
|
---|
523 |
|
---|
524 |
|
---|
525 | /************************************************************************/
|
---|
526 |
|
---|
527 |
|
---|
528 | void fxSetupDDSpanPointers(GLcontext *ctx)
|
---|
529 | {
|
---|
530 | ctx->Driver.WriteRGBASpan =fxDDWriteRGBASpan;
|
---|
531 | ctx->Driver.WriteRGBSpan =fxDDWriteRGBSpan;
|
---|
532 | ctx->Driver.WriteMonoRGBASpan =fxDDWriteMonoRGBASpan;
|
---|
533 | ctx->Driver.WriteRGBAPixels =fxDDWriteRGBAPixels;
|
---|
534 | ctx->Driver.WriteMonoRGBAPixels =fxDDWriteMonoRGBAPixels;
|
---|
535 |
|
---|
536 | ctx->Driver.WriteCI8Span =NULL;
|
---|
537 | ctx->Driver.WriteCI32Span =NULL;
|
---|
538 | ctx->Driver.WriteMonoCISpan =NULL;
|
---|
539 | ctx->Driver.WriteCI32Pixels =NULL;
|
---|
540 | ctx->Driver.WriteMonoCIPixels =NULL;
|
---|
541 |
|
---|
542 | ctx->Driver.ReadRGBASpan =fxDDReadRGBASpan;
|
---|
543 | ctx->Driver.ReadRGBAPixels =fxDDReadRGBAPixels;
|
---|
544 |
|
---|
545 | ctx->Driver.ReadCI32Span =NULL;
|
---|
546 | ctx->Driver.ReadCI32Pixels =NULL;
|
---|
547 | }
|
---|
548 |
|
---|
549 |
|
---|
550 | #else
|
---|
551 |
|
---|
552 |
|
---|
553 | /*
|
---|
554 | * Need this to provide at least one external definition.
|
---|
555 | */
|
---|
556 |
|
---|
557 | int gl_fx_dummy_function_span(void)
|
---|
558 | {
|
---|
559 | return 0;
|
---|
560 | }
|
---|
561 |
|
---|
562 | #endif /* FX */
|
---|