swrast: silence double->float assignment warnings
[mesa.git] / src / mesa / swrast / s_readpix.c
1 /*
2 * Mesa 3-D graphics library
3 * Version: 7.0.3
4 *
5 * Copyright (C) 1999-2007 Brian Paul All Rights Reserved.
6 *
7 * Permission is hereby granted, free of charge, to any person obtaining a
8 * copy of this software and associated documentation files (the "Software"),
9 * to deal in the Software without restriction, including without limitation
10 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
11 * and/or sell copies of the Software, and to permit persons to whom the
12 * Software is furnished to do so, subject to the following conditions:
13 *
14 * The above copyright notice and this permission notice shall be included
15 * in all copies or substantial portions of the Software.
16 *
17 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
18 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
20 * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
21 * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
22 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
23 */
24
25
26 #include "main/glheader.h"
27 #include "main/bufferobj.h"
28 #include "main/colormac.h"
29 #include "main/convolve.h"
30 #include "main/context.h"
31 #include "main/feedback.h"
32 #include "main/formats.h"
33 #include "main/image.h"
34 #include "main/macros.h"
35 #include "main/imports.h"
36 #include "main/state.h"
37
38 #include "s_context.h"
39 #include "s_depth.h"
40 #include "s_span.h"
41 #include "s_stencil.h"
42
43
44 /*
45 * Read a block of color index pixels.
46 */
47 static void
48 read_index_pixels( GLcontext *ctx,
49 GLint x, GLint y,
50 GLsizei width, GLsizei height,
51 GLenum type, GLvoid *pixels,
52 const struct gl_pixelstore_attrib *packing )
53 {
54 struct gl_renderbuffer *rb = ctx->ReadBuffer->_ColorReadBuffer;
55 GLint i;
56
57 if (!rb)
58 return;
59
60 /* width should never be > MAX_WIDTH since we did clipping earlier */
61 ASSERT(width <= MAX_WIDTH);
62
63 /* process image row by row */
64 for (i = 0; i < height; i++) {
65 GLuint index[MAX_WIDTH];
66 GLvoid *dest;
67 ASSERT(rb->DataType == GL_UNSIGNED_INT);
68 rb->GetRow(ctx, rb, width, x, y + i, index);
69
70 dest = _mesa_image_address2d(packing, pixels, width, height,
71 GL_COLOR_INDEX, type, i, 0);
72
73 _mesa_pack_index_span(ctx, width, type, dest, index,
74 &ctx->Pack, ctx->_ImageTransferState);
75 }
76 }
77
78
79
80 /**
81 * Read pixels for format=GL_DEPTH_COMPONENT.
82 */
83 static void
84 read_depth_pixels( GLcontext *ctx,
85 GLint x, GLint y,
86 GLsizei width, GLsizei height,
87 GLenum type, GLvoid *pixels,
88 const struct gl_pixelstore_attrib *packing )
89 {
90 struct gl_framebuffer *fb = ctx->ReadBuffer;
91 struct gl_renderbuffer *rb = fb->_DepthBuffer;
92 const GLboolean biasOrScale
93 = ctx->Pixel.DepthScale != 1.0 || ctx->Pixel.DepthBias != 0.0;
94
95 if (!rb)
96 return;
97
98 /* clipping should have been done already */
99 ASSERT(x >= 0);
100 ASSERT(y >= 0);
101 ASSERT(x + width <= (GLint) rb->Width);
102 ASSERT(y + height <= (GLint) rb->Height);
103 /* width should never be > MAX_WIDTH since we did clipping earlier */
104 ASSERT(width <= MAX_WIDTH);
105
106 if (type == GL_UNSIGNED_SHORT && fb->Visual.depthBits == 16
107 && !biasOrScale && !packing->SwapBytes) {
108 /* Special case: directly read 16-bit unsigned depth values. */
109 GLint j;
110 ASSERT(rb->Format == MESA_FORMAT_Z16);
111 ASSERT(rb->DataType == GL_UNSIGNED_SHORT);
112 for (j = 0; j < height; j++, y++) {
113 void *dest =_mesa_image_address2d(packing, pixels, width, height,
114 GL_DEPTH_COMPONENT, type, j, 0);
115 rb->GetRow(ctx, rb, width, x, y, dest);
116 }
117 }
118 else if (type == GL_UNSIGNED_INT && fb->Visual.depthBits == 24
119 && !biasOrScale && !packing->SwapBytes) {
120 /* Special case: directly read 24-bit unsigned depth values. */
121 GLint j;
122 ASSERT(rb->Format == MESA_FORMAT_X8_Z24 ||
123 rb->Format == MESA_FORMAT_S8_Z24 ||
124 rb->Format == MESA_FORMAT_Z24_X8 ||
125 rb->Format == MESA_FORMAT_Z24_S8);
126 ASSERT(rb->DataType == GL_UNSIGNED_INT ||
127 rb->DataType == GL_UNSIGNED_INT_24_8);
128 for (j = 0; j < height; j++, y++) {
129 GLuint *dest = (GLuint *)
130 _mesa_image_address2d(packing, pixels, width, height,
131 GL_DEPTH_COMPONENT, type, j, 0);
132 GLint k;
133 rb->GetRow(ctx, rb, width, x, y, dest);
134 /* convert range from 24-bit to 32-bit */
135 if (rb->Format == MESA_FORMAT_X8_Z24 ||
136 rb->Format == MESA_FORMAT_S8_Z24) {
137 for (k = 0; k < width; k++) {
138 /* Note: put MSByte of 24-bit value into LSByte */
139 dest[k] = (dest[k] << 8) | ((dest[k] >> 16) & 0xff);
140 }
141 }
142 else {
143 for (k = 0; k < width; k++) {
144 /* Note: fill in LSByte by replication */
145 dest[k] = dest[k] | ((dest[k] >> 8) & 0xff);
146 }
147 }
148 }
149 }
150 else if (type == GL_UNSIGNED_INT && fb->Visual.depthBits == 32
151 && !biasOrScale && !packing->SwapBytes) {
152 /* Special case: directly read 32-bit unsigned depth values. */
153 GLint j;
154 ASSERT(rb->Format == MESA_FORMAT_Z32);
155 ASSERT(rb->DataType == GL_UNSIGNED_INT);
156 for (j = 0; j < height; j++, y++) {
157 void *dest = _mesa_image_address2d(packing, pixels, width, height,
158 GL_DEPTH_COMPONENT, type, j, 0);
159 rb->GetRow(ctx, rb, width, x, y, dest);
160 }
161 }
162 else {
163 /* General case (slower) */
164 GLint j;
165 for (j = 0; j < height; j++, y++) {
166 GLfloat depthValues[MAX_WIDTH];
167 GLvoid *dest = _mesa_image_address2d(packing, pixels, width, height,
168 GL_DEPTH_COMPONENT, type, j, 0);
169 _swrast_read_depth_span_float(ctx, rb, width, x, y, depthValues);
170 _mesa_pack_depth_span(ctx, width, dest, type, depthValues, packing);
171 }
172 }
173 }
174
175
176 /**
177 * Read pixels for format=GL_STENCIL_INDEX.
178 */
179 static void
180 read_stencil_pixels( GLcontext *ctx,
181 GLint x, GLint y,
182 GLsizei width, GLsizei height,
183 GLenum type, GLvoid *pixels,
184 const struct gl_pixelstore_attrib *packing )
185 {
186 struct gl_framebuffer *fb = ctx->ReadBuffer;
187 struct gl_renderbuffer *rb = fb->_StencilBuffer;
188 GLint j;
189
190 if (!rb)
191 return;
192
193 /* width should never be > MAX_WIDTH since we did clipping earlier */
194 ASSERT(width <= MAX_WIDTH);
195
196 /* process image row by row */
197 for (j=0;j<height;j++,y++) {
198 GLvoid *dest;
199 GLstencil stencil[MAX_WIDTH];
200
201 _swrast_read_stencil_span(ctx, rb, width, x, y, stencil);
202
203 dest = _mesa_image_address2d(packing, pixels, width, height,
204 GL_STENCIL_INDEX, type, j, 0);
205
206 _mesa_pack_stencil_span(ctx, width, type, dest, stencil, packing);
207 }
208 }
209
210
211
212 /**
213 * Optimized glReadPixels for particular pixel formats when pixel
214 * scaling, biasing, mapping, etc. are disabled.
215 * \return GL_TRUE if success, GL_FALSE if unable to do the readpixels
216 */
217 static GLboolean
218 fast_read_rgba_pixels( GLcontext *ctx,
219 GLint x, GLint y,
220 GLsizei width, GLsizei height,
221 GLenum format, GLenum type,
222 GLvoid *pixels,
223 const struct gl_pixelstore_attrib *packing,
224 GLbitfield transferOps)
225 {
226 struct gl_renderbuffer *rb = ctx->ReadBuffer->_ColorReadBuffer;
227
228 if (!rb)
229 return GL_FALSE;
230
231 ASSERT(rb->_BaseFormat == GL_RGBA || rb->_BaseFormat == GL_RGB);
232
233 /* clipping should have already been done */
234 ASSERT(x + width <= (GLint) rb->Width);
235 ASSERT(y + height <= (GLint) rb->Height);
236
237 /* check for things we can't handle here */
238 if (transferOps ||
239 packing->SwapBytes ||
240 packing->LsbFirst) {
241 return GL_FALSE;
242 }
243
244 if (format == GL_RGBA && rb->DataType == type) {
245 const GLint dstStride = _mesa_image_row_stride(packing, width,
246 format, type);
247 GLubyte *dest
248 = (GLubyte *) _mesa_image_address2d(packing, pixels, width, height,
249 format, type, 0, 0);
250 GLint row;
251 ASSERT(rb->GetRow);
252 for (row = 0; row < height; row++) {
253 rb->GetRow(ctx, rb, width, x, y + row, dest);
254 dest += dstStride;
255 }
256 return GL_TRUE;
257 }
258
259 if (format == GL_RGB &&
260 rb->DataType == GL_UNSIGNED_BYTE &&
261 type == GL_UNSIGNED_BYTE) {
262 const GLint dstStride = _mesa_image_row_stride(packing, width,
263 format, type);
264 GLubyte *dest
265 = (GLubyte *) _mesa_image_address2d(packing, pixels, width, height,
266 format, type, 0, 0);
267 GLint row;
268 ASSERT(rb->GetRow);
269 for (row = 0; row < height; row++) {
270 GLubyte tempRow[MAX_WIDTH][4];
271 GLint col;
272 rb->GetRow(ctx, rb, width, x, y + row, tempRow);
273 /* convert RGBA to RGB */
274 for (col = 0; col < width; col++) {
275 dest[col * 3 + 0] = tempRow[col][0];
276 dest[col * 3 + 1] = tempRow[col][1];
277 dest[col * 3 + 2] = tempRow[col][2];
278 }
279 dest += dstStride;
280 }
281 return GL_TRUE;
282 }
283
284 /* not handled */
285 return GL_FALSE;
286 }
287
288
289 /**
290 * When we're using a low-precision color buffer (like 16-bit 5/6/5)
291 * we have to adjust our color values a bit to pass conformance.
292 * The problem is when a 5 or 6-bit color value is convert to an 8-bit
293 * value and then a floating point value, the floating point values don't
294 * increment uniformly as the 5 or 6-bit value is incremented.
295 *
296 * This function adjusts floating point values to compensate.
297 */
298 static void
299 adjust_colors(GLcontext *ctx, GLuint n, GLfloat rgba[][4])
300 {
301 const GLuint rShift = 8 - ctx->Visual.redBits;
302 const GLuint gShift = 8 - ctx->Visual.greenBits;
303 const GLuint bShift = 8 - ctx->Visual.blueBits;
304 const GLfloat rScale = 1.0F / (GLfloat) ((1 << ctx->Visual.redBits ) - 1);
305 const GLfloat gScale = 1.0F / (GLfloat) ((1 << ctx->Visual.greenBits) - 1);
306 const GLfloat bScale = 1.0F / (GLfloat) ((1 << ctx->Visual.blueBits ) - 1);
307 GLuint i;
308 for (i = 0; i < n; i++) {
309 GLint r, g, b;
310 /* convert float back to ubyte */
311 CLAMPED_FLOAT_TO_UBYTE(r, rgba[i][RCOMP]);
312 CLAMPED_FLOAT_TO_UBYTE(g, rgba[i][GCOMP]);
313 CLAMPED_FLOAT_TO_UBYTE(b, rgba[i][BCOMP]);
314 /* using only the N most significant bits of the ubyte value, convert to
315 * float in [0,1].
316 */
317 rgba[i][RCOMP] = (GLfloat) (r >> rShift) * rScale;
318 rgba[i][GCOMP] = (GLfloat) (g >> gShift) * gScale;
319 rgba[i][BCOMP] = (GLfloat) (b >> bShift) * bScale;
320 }
321 }
322
323
324
325 /*
326 * Read R, G, B, A, RGB, L, or LA pixels.
327 */
328 static void
329 read_rgba_pixels( GLcontext *ctx,
330 GLint x, GLint y,
331 GLsizei width, GLsizei height,
332 GLenum format, GLenum type, GLvoid *pixels,
333 const struct gl_pixelstore_attrib *packing )
334 {
335 SWcontext *swrast = SWRAST_CONTEXT(ctx);
336 GLbitfield transferOps = ctx->_ImageTransferState;
337 struct gl_framebuffer *fb = ctx->ReadBuffer;
338 struct gl_renderbuffer *rb = fb->_ColorReadBuffer;
339
340 if (!rb)
341 return;
342
343 if (type == GL_FLOAT && ((ctx->Color.ClampReadColor == GL_TRUE) ||
344 (ctx->Color.ClampReadColor == GL_FIXED_ONLY_ARB &&
345 rb->DataType != GL_FLOAT)))
346 transferOps |= IMAGE_CLAMP_BIT;
347
348 /* Try optimized path first */
349 if (fast_read_rgba_pixels(ctx, x, y, width, height,
350 format, type, pixels, packing, transferOps)) {
351 return; /* done! */
352 }
353
354 /* width should never be > MAX_WIDTH since we did clipping earlier */
355 ASSERT(width <= MAX_WIDTH);
356
357 if (ctx->Pixel.Convolution2DEnabled || ctx->Pixel.Separable2DEnabled) {
358 GLfloat *dest, *src, *tmpImage, *convImage;
359 GLint row;
360
361 tmpImage = (GLfloat *) _mesa_malloc(width * height * 4 * sizeof(GLfloat));
362 if (!tmpImage) {
363 _mesa_error(ctx, GL_OUT_OF_MEMORY, "glReadPixels");
364 return;
365 }
366 convImage = (GLfloat *) _mesa_malloc(width * height * 4 * sizeof(GLfloat));
367 if (!convImage) {
368 _mesa_free(tmpImage);
369 _mesa_error(ctx, GL_OUT_OF_MEMORY, "glReadPixels");
370 return;
371 }
372
373 /* read full RGBA, FLOAT image */
374 dest = tmpImage;
375 for (row = 0; row < height; row++, y++) {
376 if (fb->Visual.rgbMode) {
377 _swrast_read_rgba_span(ctx, rb, width, x, y, GL_FLOAT, dest);
378 }
379 else {
380 GLuint index[MAX_WIDTH];
381 ASSERT(rb->DataType == GL_UNSIGNED_INT);
382 rb->GetRow(ctx, rb, width, x, y, index);
383 _mesa_apply_ci_transfer_ops(ctx,
384 transferOps & IMAGE_SHIFT_OFFSET_BIT,
385 width, index);
386 _mesa_map_ci_to_rgba(ctx, width, index, (GLfloat (*)[4]) dest);
387 }
388 _mesa_apply_rgba_transfer_ops(ctx,
389 transferOps & IMAGE_PRE_CONVOLUTION_BITS,
390 width, (GLfloat (*)[4]) dest);
391 dest += width * 4;
392 }
393
394 /* do convolution */
395 if (ctx->Pixel.Convolution2DEnabled) {
396 _mesa_convolve_2d_image(ctx, &width, &height, tmpImage, convImage);
397 }
398 else {
399 ASSERT(ctx->Pixel.Separable2DEnabled);
400 _mesa_convolve_sep_image(ctx, &width, &height, tmpImage, convImage);
401 }
402 _mesa_free(tmpImage);
403
404 /* finish transfer ops and pack the resulting image */
405 src = convImage;
406 for (row = 0; row < height; row++) {
407 GLvoid *dest;
408 dest = _mesa_image_address2d(packing, pixels, width, height,
409 format, type, row, 0);
410 _mesa_pack_rgba_span_float(ctx, width, (GLfloat (*)[4]) src,
411 format, type, dest, packing,
412 transferOps & IMAGE_POST_CONVOLUTION_BITS);
413 src += width * 4;
414 }
415 _mesa_free(convImage);
416 }
417 else {
418 /* no convolution */
419 const GLint dstStride
420 = _mesa_image_row_stride(packing, width, format, type);
421 GLfloat (*rgba)[4] = swrast->SpanArrays->attribs[FRAG_ATTRIB_COL0];
422 GLint row;
423 GLubyte *dst
424 = (GLubyte *) _mesa_image_address2d(packing, pixels, width, height,
425 format, type, 0, 0);
426
427 /* make sure we don't apply 1D convolution */
428 transferOps &= ~(IMAGE_CONVOLUTION_BIT |
429 IMAGE_POST_CONVOLUTION_SCALE_BIAS);
430
431 for (row = 0; row < height; row++, y++) {
432
433 /* Get float rgba pixels */
434 if (fb->Visual.rgbMode) {
435 _swrast_read_rgba_span(ctx, rb, width, x, y, GL_FLOAT, rgba);
436 }
437 else {
438 /* read CI and convert to RGBA */
439 GLuint index[MAX_WIDTH];
440 ASSERT(rb->DataType == GL_UNSIGNED_INT);
441 rb->GetRow(ctx, rb, width, x, y, index);
442 _mesa_apply_ci_transfer_ops(ctx,
443 transferOps & IMAGE_SHIFT_OFFSET_BIT,
444 width, index);
445 _mesa_map_ci_to_rgba(ctx, width, index, rgba);
446 }
447
448 /* apply fudge factor for shallow color buffers */
449 if (fb->Visual.redBits < 8 ||
450 fb->Visual.greenBits < 8 ||
451 fb->Visual.blueBits < 8) {
452 adjust_colors(ctx, width, rgba);
453 }
454
455 /* pack the row of RGBA pixels into user's buffer */
456 _mesa_pack_rgba_span_float(ctx, width, rgba, format, type, dst,
457 packing, transferOps);
458
459 dst += dstStride;
460 }
461 }
462 }
463
464
465 /**
466 * Read combined depth/stencil values.
467 * We'll have already done error checking to be sure the expected
468 * depth and stencil buffers really exist.
469 */
470 static void
471 read_depth_stencil_pixels(GLcontext *ctx,
472 GLint x, GLint y,
473 GLsizei width, GLsizei height,
474 GLenum type, GLvoid *pixels,
475 const struct gl_pixelstore_attrib *packing )
476 {
477 const GLboolean scaleOrBias
478 = ctx->Pixel.DepthScale != 1.0 || ctx->Pixel.DepthBias != 0.0;
479 const GLboolean stencilTransfer = ctx->Pixel.IndexShift
480 || ctx->Pixel.IndexOffset || ctx->Pixel.MapStencilFlag;
481 struct gl_renderbuffer *depthRb, *stencilRb;
482
483 depthRb = ctx->ReadBuffer->_DepthBuffer;
484 stencilRb = ctx->ReadBuffer->_StencilBuffer;
485
486 if (!depthRb || !stencilRb)
487 return;
488
489 depthRb = ctx->ReadBuffer->Attachment[BUFFER_DEPTH].Renderbuffer;
490 stencilRb = ctx->ReadBuffer->Attachment[BUFFER_STENCIL].Renderbuffer;
491
492 if (depthRb->_BaseFormat == GL_DEPTH_STENCIL_EXT &&
493 stencilRb->_BaseFormat == GL_DEPTH_STENCIL_EXT &&
494 depthRb == stencilRb &&
495 !scaleOrBias &&
496 !stencilTransfer) {
497 /* This is the ideal case.
498 * Reading GL_DEPTH_STENCIL pixels from combined depth/stencil buffer.
499 * Plus, no pixel transfer ops to worry about!
500 */
501 GLint i;
502 GLint dstStride = _mesa_image_row_stride(packing, width,
503 GL_DEPTH_STENCIL_EXT, type);
504 GLubyte *dst = (GLubyte *) _mesa_image_address2d(packing, pixels,
505 width, height,
506 GL_DEPTH_STENCIL_EXT,
507 type, 0, 0);
508 for (i = 0; i < height; i++) {
509 depthRb->GetRow(ctx, depthRb, width, x, y + i, dst);
510 dst += dstStride;
511 }
512 }
513 else {
514 /* Reading GL_DEPTH_STENCIL pixels from separate depth/stencil buffers,
515 * or we need pixel transfer.
516 */
517 GLint i;
518 depthRb = ctx->ReadBuffer->_DepthBuffer;
519 stencilRb = ctx->ReadBuffer->_StencilBuffer;
520
521 for (i = 0; i < height; i++) {
522 GLstencil stencilVals[MAX_WIDTH];
523
524 GLuint *depthStencilDst = (GLuint *)
525 _mesa_image_address2d(packing, pixels, width, height,
526 GL_DEPTH_STENCIL_EXT, type, i, 0);
527
528 _swrast_read_stencil_span(ctx, stencilRb, width,
529 x, y + i, stencilVals);
530
531 if (!scaleOrBias && !stencilTransfer
532 && ctx->ReadBuffer->Visual.depthBits == 24) {
533 /* ideal case */
534 GLuint zVals[MAX_WIDTH]; /* 24-bit values! */
535 GLint j;
536 ASSERT(depthRb->DataType == GL_UNSIGNED_INT);
537 /* note, we've already been clipped */
538 depthRb->GetRow(ctx, depthRb, width, x, y + i, zVals);
539 for (j = 0; j < width; j++) {
540 depthStencilDst[j] = (zVals[j] << 8) | (stencilVals[j] & 0xff);
541 }
542 }
543 else {
544 /* general case */
545 GLfloat depthVals[MAX_WIDTH];
546 _swrast_read_depth_span_float(ctx, depthRb, width, x, y + i,
547 depthVals);
548 _mesa_pack_depth_stencil_span(ctx, width, depthStencilDst,
549 depthVals, stencilVals, packing);
550 }
551 }
552 }
553 }
554
555
556
557 /**
558 * Software fallback routine for ctx->Driver.ReadPixels().
559 * By time we get here, all error checking will have been done.
560 */
561 void
562 _swrast_ReadPixels( GLcontext *ctx,
563 GLint x, GLint y, GLsizei width, GLsizei height,
564 GLenum format, GLenum type,
565 const struct gl_pixelstore_attrib *packing,
566 GLvoid *pixels )
567 {
568 SWcontext *swrast = SWRAST_CONTEXT(ctx);
569 struct gl_pixelstore_attrib clippedPacking = *packing;
570
571 if (ctx->NewState)
572 _mesa_update_state(ctx);
573
574 /* Need to do swrast_render_start() before clipping or anything else
575 * since this is where a driver may grab the hw lock and get an updated
576 * window size.
577 */
578 swrast_render_start(ctx);
579
580 if (swrast->NewState)
581 _swrast_validate_derived( ctx );
582
583 /* Do all needed clipping here, so that we can forget about it later */
584 if (!_mesa_clip_readpixels(ctx, &x, &y, &width, &height, &clippedPacking)) {
585 /* The ReadPixels region is totally outside the window bounds */
586 swrast_render_finish(ctx);
587 return;
588 }
589
590 pixels = _mesa_map_pbo_dest(ctx, &clippedPacking, pixels);
591 if (!pixels)
592 return;
593
594 switch (format) {
595 case GL_COLOR_INDEX:
596 read_index_pixels(ctx, x, y, width, height, type, pixels,
597 &clippedPacking);
598 break;
599 case GL_STENCIL_INDEX:
600 read_stencil_pixels(ctx, x, y, width, height, type, pixels,
601 &clippedPacking);
602 break;
603 case GL_DEPTH_COMPONENT:
604 read_depth_pixels(ctx, x, y, width, height, type, pixels,
605 &clippedPacking);
606 break;
607 case GL_RED:
608 case GL_GREEN:
609 case GL_BLUE:
610 case GL_ALPHA:
611 case GL_RGB:
612 case GL_LUMINANCE:
613 case GL_LUMINANCE_ALPHA:
614 case GL_RGBA:
615 case GL_BGR:
616 case GL_BGRA:
617 case GL_ABGR_EXT:
618 read_rgba_pixels(ctx, x, y, width, height,
619 format, type, pixels, &clippedPacking);
620 break;
621 case GL_DEPTH_STENCIL_EXT:
622 read_depth_stencil_pixels(ctx, x, y, width, height,
623 type, pixels, &clippedPacking);
624 break;
625 default:
626 _mesa_problem(ctx, "unexpected format in _swrast_ReadPixels");
627 /* don't return yet, clean-up */
628 }
629
630 swrast_render_finish(ctx);
631
632 _mesa_unmap_pbo_dest(ctx, &clippedPacking);
633 }