2 * Mesa 3-D graphics library
4 * Copyright (C) 1999-2007 Brian Paul All Rights Reserved.
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 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
20 * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
21 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
22 * OTHER DEALINGS IN THE SOFTWARE.
26 #include "main/glheader.h"
27 #include "main/bufferobj.h"
28 #include "main/colormac.h"
29 #include "main/condrender.h"
30 #include "main/context.h"
31 #include "main/format_pack.h"
32 #include "main/format_utils.h"
33 #include "main/glformats.h"
34 #include "main/image.h"
35 #include "main/imports.h"
36 #include "main/macros.h"
37 #include "main/pack.h"
39 #include "main/pixeltransfer.h"
40 #include "main/state.h"
42 #include "s_context.h"
44 #include "s_stencil.h"
49 * Handle a common case of drawing GL_RGB/GL_UNSIGNED_BYTE into a
50 * MESA_FORMAT_XRGB888 or MESA_FORMAT_ARGB888 renderbuffer.
53 fast_draw_rgb_ubyte_pixels(struct gl_context
*ctx
,
54 struct gl_renderbuffer
*rb
,
56 GLsizei width
, GLsizei height
,
57 const struct gl_pixelstore_attrib
*unpack
,
60 const GLubyte
*src
= (const GLubyte
*)
61 _mesa_image_address2d(unpack
, pixels
, width
,
62 height
, GL_RGB
, GL_UNSIGNED_BYTE
, 0, 0);
63 const GLint srcRowStride
= _mesa_image_row_stride(unpack
, width
,
64 GL_RGB
, GL_UNSIGNED_BYTE
);
69 ctx
->Driver
.MapRenderbuffer(ctx
, rb
, x
, y
, width
, height
,
70 GL_MAP_WRITE_BIT
, &dst
, &dstRowStride
);
73 _mesa_error(ctx
, GL_OUT_OF_MEMORY
, "glDrawPixels");
77 if (ctx
->Pixel
.ZoomY
== -1.0f
) {
78 dst
= dst
+ (height
- 1) * dstRowStride
;
79 dstRowStride
= -dstRowStride
;
82 for (i
= 0; i
< height
; i
++) {
83 GLuint
*dst4
= (GLuint
*) dst
;
84 for (j
= 0; j
< width
; j
++) {
85 dst4
[j
] = PACK_COLOR_8888(0xff, src
[j
*3+0], src
[j
*3+1], src
[j
*3+2]);
91 ctx
->Driver
.UnmapRenderbuffer(ctx
, rb
);
96 * Handle a common case of drawing GL_RGBA/GL_UNSIGNED_BYTE into a
97 * MESA_FORMAT_ARGB888 or MESA_FORMAT_xRGB888 renderbuffer.
100 fast_draw_rgba_ubyte_pixels(struct gl_context
*ctx
,
101 struct gl_renderbuffer
*rb
,
103 GLsizei width
, GLsizei height
,
104 const struct gl_pixelstore_attrib
*unpack
,
105 const GLvoid
*pixels
)
107 const GLubyte
*src
= (const GLubyte
*)
108 _mesa_image_address2d(unpack
, pixels
, width
,
109 height
, GL_RGBA
, GL_UNSIGNED_BYTE
, 0, 0);
110 const GLint srcRowStride
=
111 _mesa_image_row_stride(unpack
, width
, GL_RGBA
, GL_UNSIGNED_BYTE
);
116 ctx
->Driver
.MapRenderbuffer(ctx
, rb
, x
, y
, width
, height
,
117 GL_MAP_WRITE_BIT
, &dst
, &dstRowStride
);
120 _mesa_error(ctx
, GL_OUT_OF_MEMORY
, "glDrawPixels");
124 if (ctx
->Pixel
.ZoomY
== -1.0f
) {
125 dst
= dst
+ (height
- 1) * dstRowStride
;
126 dstRowStride
= -dstRowStride
;
129 for (i
= 0; i
< height
; i
++) {
130 GLuint
*dst4
= (GLuint
*) dst
;
131 for (j
= 0; j
< width
; j
++) {
132 dst4
[j
] = PACK_COLOR_8888(src
[j
*4+3], src
[j
*4+0],
133 src
[j
*4+1], src
[j
*4+2]);
139 ctx
->Driver
.UnmapRenderbuffer(ctx
, rb
);
144 * Handle a common case of drawing a format/type combination that
145 * exactly matches the renderbuffer format.
148 fast_draw_generic_pixels(struct gl_context
*ctx
,
149 struct gl_renderbuffer
*rb
,
151 GLsizei width
, GLsizei height
,
152 GLenum format
, GLenum type
,
153 const struct gl_pixelstore_attrib
*unpack
,
154 const GLvoid
*pixels
)
156 const GLubyte
*src
= (const GLubyte
*)
157 _mesa_image_address2d(unpack
, pixels
, width
,
158 height
, format
, type
, 0, 0);
159 const GLint srcRowStride
=
160 _mesa_image_row_stride(unpack
, width
, format
, type
);
161 const GLint rowLength
= width
* _mesa_get_format_bytes(rb
->Format
);
166 ctx
->Driver
.MapRenderbuffer(ctx
, rb
, x
, y
, width
, height
,
167 GL_MAP_WRITE_BIT
, &dst
, &dstRowStride
);
170 _mesa_error(ctx
, GL_OUT_OF_MEMORY
, "glDrawPixels");
174 if (ctx
->Pixel
.ZoomY
== -1.0f
) {
175 dst
= dst
+ (height
- 1) * dstRowStride
;
176 dstRowStride
= -dstRowStride
;
179 for (i
= 0; i
< height
; i
++) {
180 memcpy(dst
, src
, rowLength
);
185 ctx
->Driver
.UnmapRenderbuffer(ctx
, rb
);
190 * Try to do a fast and simple RGB(a) glDrawPixels.
191 * Return: GL_TRUE if success, GL_FALSE if slow path must be used instead
194 fast_draw_rgba_pixels(struct gl_context
*ctx
, GLint x
, GLint y
,
195 GLsizei width
, GLsizei height
,
196 GLenum format
, GLenum type
,
197 const struct gl_pixelstore_attrib
*userUnpack
,
198 const GLvoid
*pixels
)
200 struct gl_renderbuffer
*rb
= ctx
->DrawBuffer
->_ColorDrawBuffers
[0];
201 SWcontext
*swrast
= SWRAST_CONTEXT(ctx
);
202 struct gl_pixelstore_attrib unpack
;
205 return GL_TRUE
; /* no-op */
207 if (ctx
->DrawBuffer
->_NumColorDrawBuffers
> 1 ||
208 (swrast
->_RasterMask
& ~CLIP_BIT
) ||
209 ctx
->Texture
._EnabledCoordUnits
||
210 userUnpack
->SwapBytes
||
211 ctx
->Pixel
.ZoomX
!= 1.0f
||
212 fabsf(ctx
->Pixel
.ZoomY
) != 1.0f
||
213 ctx
->_ImageTransferState
) {
214 /* can't handle any of those conditions */
218 unpack
= *userUnpack
;
221 if (!_mesa_clip_drawpixels(ctx
, &x
, &y
, &width
, &height
, &unpack
)) {
222 /* image was completely clipped: no-op, all done */
226 if (format
== GL_RGB
&&
227 type
== GL_UNSIGNED_BYTE
&&
228 (rb
->Format
== MESA_FORMAT_B8G8R8X8_UNORM
||
229 rb
->Format
== MESA_FORMAT_B8G8R8A8_UNORM
)) {
230 fast_draw_rgb_ubyte_pixels(ctx
, rb
, x
, y
, width
, height
,
235 if (format
== GL_RGBA
&&
236 type
== GL_UNSIGNED_BYTE
&&
237 (rb
->Format
== MESA_FORMAT_B8G8R8X8_UNORM
||
238 rb
->Format
== MESA_FORMAT_B8G8R8A8_UNORM
)) {
239 fast_draw_rgba_ubyte_pixels(ctx
, rb
, x
, y
, width
, height
,
244 if (_mesa_format_matches_format_and_type(rb
->Format
, format
, type
,
245 ctx
->Unpack
.SwapBytes
)) {
246 fast_draw_generic_pixels(ctx
, rb
, x
, y
, width
, height
,
247 format
, type
, &unpack
, pixels
);
251 /* can't handle this pixel format and/or data type */
258 * Draw stencil image.
261 draw_stencil_pixels( struct gl_context
*ctx
, GLint x
, GLint y
,
262 GLsizei width
, GLsizei height
,
264 const struct gl_pixelstore_attrib
*unpack
,
265 const GLvoid
*pixels
)
267 const GLboolean zoom
= ctx
->Pixel
.ZoomX
!= 1.0 || ctx
->Pixel
.ZoomY
!= 1.0;
268 const GLenum destType
= GL_UNSIGNED_BYTE
;
272 values
= malloc(width
* sizeof(GLubyte
));
274 _mesa_error(ctx
, GL_OUT_OF_MEMORY
, "glDrawPixels");
278 for (row
= 0; row
< height
; row
++) {
279 const GLvoid
*source
= _mesa_image_address2d(unpack
, pixels
,
281 GL_STENCIL_INDEX
, type
,
283 _mesa_unpack_stencil_span(ctx
, width
, destType
, values
,
284 type
, source
, unpack
,
285 ctx
->_ImageTransferState
);
287 _swrast_write_zoomed_stencil_span(ctx
, x
, y
, width
,
291 _swrast_write_stencil_span(ctx
, width
, x
, y
, values
);
305 draw_depth_pixels( struct gl_context
*ctx
, GLint x
, GLint y
,
306 GLsizei width
, GLsizei height
,
308 const struct gl_pixelstore_attrib
*unpack
,
309 const GLvoid
*pixels
)
311 const GLboolean scaleOrBias
312 = ctx
->Pixel
.DepthScale
!= 1.0 || ctx
->Pixel
.DepthBias
!= 0.0;
313 const GLboolean zoom
= ctx
->Pixel
.ZoomX
!= 1.0 || ctx
->Pixel
.ZoomY
!= 1.0;
316 INIT_SPAN(span
, GL_BITMAP
);
317 span
.arrayMask
= SPAN_Z
;
318 _swrast_span_default_attribs(ctx
, &span
);
320 if (type
== GL_UNSIGNED_SHORT
321 && ctx
->DrawBuffer
->Visual
.depthBits
== 16
324 && width
<= SWRAST_MAX_WIDTH
325 && !unpack
->SwapBytes
) {
326 /* Special case: directly write 16-bit depth values */
328 for (row
= 0; row
< height
; row
++) {
329 const GLushort
*zSrc
= (const GLushort
*)
330 _mesa_image_address2d(unpack
, pixels
, width
, height
,
331 GL_DEPTH_COMPONENT
, type
, row
, 0);
333 for (i
= 0; i
< width
; i
++)
334 span
.array
->z
[i
] = zSrc
[i
];
338 _swrast_write_rgba_span(ctx
, &span
);
341 else if (type
== GL_UNSIGNED_INT
344 && width
<= SWRAST_MAX_WIDTH
345 && !unpack
->SwapBytes
) {
346 /* Special case: shift 32-bit values down to Visual.depthBits */
347 const GLint shift
= 32 - ctx
->DrawBuffer
->Visual
.depthBits
;
349 for (row
= 0; row
< height
; row
++) {
350 const GLuint
*zSrc
= (const GLuint
*)
351 _mesa_image_address2d(unpack
, pixels
, width
, height
,
352 GL_DEPTH_COMPONENT
, type
, row
, 0);
354 memcpy(span
.array
->z
, zSrc
, width
* sizeof(GLuint
));
358 for (col
= 0; col
< width
; col
++)
359 span
.array
->z
[col
] = zSrc
[col
] >> shift
;
364 _swrast_write_rgba_span(ctx
, &span
);
369 const GLuint depthMax
= ctx
->DrawBuffer
->_DepthMax
;
370 GLint skipPixels
= 0;
372 /* in case width > SWRAST_MAX_WIDTH do the copy in chunks */
373 while (skipPixels
< width
) {
374 const GLint spanWidth
= MIN2(width
- skipPixels
, SWRAST_MAX_WIDTH
);
376 ASSERT(span
.end
<= SWRAST_MAX_WIDTH
);
377 for (row
= 0; row
< height
; row
++) {
378 const GLvoid
*zSrc
= _mesa_image_address2d(unpack
,
379 pixels
, width
, height
,
380 GL_DEPTH_COMPONENT
, type
,
383 /* Set these for each row since the _swrast_write_* function may
384 * change them while clipping.
386 span
.x
= x
+ skipPixels
;
388 span
.end
= spanWidth
;
390 _mesa_unpack_depth_span(ctx
, spanWidth
,
391 GL_UNSIGNED_INT
, span
.array
->z
, depthMax
,
394 _swrast_write_zoomed_depth_span(ctx
, x
, y
, &span
);
397 _swrast_write_rgba_span(ctx
, &span
);
400 skipPixels
+= spanWidth
;
411 draw_rgba_pixels( struct gl_context
*ctx
, GLint x
, GLint y
,
412 GLsizei width
, GLsizei height
,
413 GLenum format
, GLenum type
,
414 const struct gl_pixelstore_attrib
*unpack
,
415 const GLvoid
*pixels
)
417 const GLint imgX
= x
, imgY
= y
;
418 const GLboolean zoom
= ctx
->Pixel
.ZoomX
!=1.0 || ctx
->Pixel
.ZoomY
!=1.0;
419 GLbitfield transferOps
= ctx
->_ImageTransferState
;
422 /* Try an optimized glDrawPixels first */
423 if (fast_draw_rgba_pixels(ctx
, x
, y
, width
, height
, format
, type
,
428 swrast_render_start(ctx
);
430 INIT_SPAN(span
, GL_BITMAP
);
431 _swrast_span_default_attribs(ctx
, &span
);
432 span
.arrayMask
= SPAN_RGBA
;
433 span
.arrayAttribs
= VARYING_BIT_COL0
; /* we're fill in COL0 attrib values */
435 if (ctx
->DrawBuffer
->_NumColorDrawBuffers
> 0) {
436 GLenum datatype
= _mesa_get_format_datatype(
437 ctx
->DrawBuffer
->_ColorDrawBuffers
[0]->Format
);
438 if (datatype
!= GL_FLOAT
&&
439 ctx
->Color
.ClampFragmentColor
!= GL_FALSE
) {
440 /* need to clamp colors before applying fragment ops */
441 transferOps
|= IMAGE_CLAMP_BIT
;
449 const GLbitfield interpMask
= span
.interpMask
;
450 const GLbitfield arrayMask
= span
.arrayMask
;
451 const GLint srcStride
452 = _mesa_image_row_stride(unpack
, width
, format
, type
);
453 GLint skipPixels
= 0;
454 /* use span array for temp color storage */
455 GLfloat
*rgba
= (GLfloat
*) span
.array
->attribs
[VARYING_SLOT_COL0
];
456 void *tempImage
= NULL
;
458 if (unpack
->SwapBytes
) {
459 /* We have to handle byte-swapping scenarios before calling
460 * _mesa_format_convert
462 GLint swapSize
= _mesa_sizeof_packed_type(type
);
463 if (swapSize
== 2 || swapSize
== 4) {
464 int components
= _mesa_components_in_format(format
);
465 int elementCount
= width
* height
* components
;
466 tempImage
= malloc(elementCount
* swapSize
);
468 _mesa_error(ctx
, GL_OUT_OF_MEMORY
, "glDrawPixels");
472 _mesa_swap2_copy(tempImage
, (GLushort
*) pixels
, elementCount
);
474 _mesa_swap4_copy(tempImage
, (GLuint
*) pixels
, elementCount
);
479 /* if the span is wider than SWRAST_MAX_WIDTH we have to do it in chunks */
480 while (skipPixels
< width
) {
481 const GLint spanWidth
= MIN2(width
- skipPixels
, SWRAST_MAX_WIDTH
);
482 const GLubyte
*source
483 = (const GLubyte
*) _mesa_image_address2d(unpack
, pixels
,
484 width
, height
, format
,
485 type
, 0, skipPixels
);
488 /* get image row as float/RGBA */
489 uint32_t srcMesaFormat
= _mesa_format_from_format_and_type(format
, type
);
490 for (row
= 0; row
< height
; row
++) {
491 int dstRowStride
= 4 * width
* sizeof(float);
492 _mesa_format_convert(rgba
, RGBA32_FLOAT
, dstRowStride
,
493 (void*)source
, srcMesaFormat
, srcStride
,
496 _mesa_apply_rgba_transfer_ops(ctx
, transferOps
, spanWidth
, (GLfloat (*)[4])rgba
);
497 /* Set these for each row since the _swrast_write_* functions
498 * may change them while clipping/rendering.
500 span
.array
->ChanType
= GL_FLOAT
;
501 span
.x
= x
+ skipPixels
;
503 span
.end
= spanWidth
;
504 span
.arrayMask
= arrayMask
;
505 span
.interpMask
= interpMask
;
507 _swrast_write_zoomed_rgba_span(ctx
, imgX
, imgY
, &span
, rgba
);
510 _swrast_write_rgba_span(ctx
, &span
);
516 skipPixels
+= spanWidth
;
517 } /* while skipPixels < width */
519 /* XXX this is ugly/temporary, to undo above change */
520 span
.array
->ChanType
= CHAN_TYPE
;
525 swrast_render_finish(ctx
);
530 * Draw depth+stencil values into a MESA_FORAMT_Z24_S8 or MESA_FORMAT_Z24_UNORM_S8_UINT
531 * renderbuffer. No masking, zooming, scaling, etc.
534 fast_draw_depth_stencil(struct gl_context
*ctx
, GLint x
, GLint y
,
535 GLsizei width
, GLsizei height
,
536 const struct gl_pixelstore_attrib
*unpack
,
537 const GLvoid
*pixels
)
539 const GLenum format
= GL_DEPTH_STENCIL_EXT
;
540 const GLenum type
= GL_UNSIGNED_INT_24_8
;
541 struct gl_renderbuffer
*rb
=
542 ctx
->DrawBuffer
->Attachment
[BUFFER_DEPTH
].Renderbuffer
;
543 struct swrast_renderbuffer
*srb
= swrast_renderbuffer(rb
);
545 GLint srcRowStride
, dstRowStride
;
548 src
= _mesa_image_address2d(unpack
, pixels
, width
, height
,
550 srcRowStride
= _mesa_image_row_stride(unpack
, width
, format
, type
);
552 dst
= _swrast_pixel_address(rb
, x
, y
);
553 dstRowStride
= srb
->RowStride
;
555 for (i
= 0; i
< height
; i
++) {
556 _mesa_pack_uint_24_8_depth_stencil_row(rb
->Format
, width
,
557 (const GLuint
*) src
, dst
);
566 * This is a bit different from drawing GL_DEPTH_COMPONENT pixels.
567 * The only per-pixel operations that apply are depth scale/bias,
568 * stencil offset/shift, GL_DEPTH_WRITEMASK and GL_STENCIL_WRITEMASK,
570 * Also, only the depth buffer and stencil buffers are touched, not the
574 draw_depth_stencil_pixels(struct gl_context
*ctx
, GLint x
, GLint y
,
575 GLsizei width
, GLsizei height
, GLenum type
,
576 const struct gl_pixelstore_attrib
*unpack
,
577 const GLvoid
*pixels
)
579 const GLint imgX
= x
, imgY
= y
;
580 const GLboolean scaleOrBias
581 = ctx
->Pixel
.DepthScale
!= 1.0 || ctx
->Pixel
.DepthBias
!= 0.0;
582 const GLuint stencilMask
= ctx
->Stencil
.WriteMask
[0];
583 const GLenum stencilType
= GL_UNSIGNED_BYTE
;
584 const GLboolean zoom
= ctx
->Pixel
.ZoomX
!= 1.0 || ctx
->Pixel
.ZoomY
!= 1.0;
585 struct gl_renderbuffer
*depthRb
, *stencilRb
;
586 struct gl_pixelstore_attrib clippedUnpack
= *unpack
;
589 if (!_mesa_clip_drawpixels(ctx
, &x
, &y
, &width
, &height
,
591 /* totally clipped */
596 depthRb
= ctx
->ReadBuffer
->Attachment
[BUFFER_DEPTH
].Renderbuffer
;
597 stencilRb
= ctx
->ReadBuffer
->Attachment
[BUFFER_STENCIL
].Renderbuffer
;
601 if (depthRb
== stencilRb
&&
602 (depthRb
->Format
== MESA_FORMAT_S8_UINT_Z24_UNORM
||
603 depthRb
->Format
== MESA_FORMAT_Z24_UNORM_S8_UINT
) &&
604 type
== GL_UNSIGNED_INT_24_8
&&
608 (stencilMask
& 0xff) == 0xff) {
609 fast_draw_depth_stencil(ctx
, x
, y
, width
, height
,
610 &clippedUnpack
, pixels
);
613 /* sub-optimal cases:
614 * Separate depth/stencil buffers, or pixel transfer ops required.
616 /* XXX need to handle very wide images (skippixels) */
617 GLuint
*zValues
; /* 32-bit Z values */
620 zValues
= malloc(width
* sizeof(GLuint
));
622 _mesa_error(ctx
, GL_OUT_OF_MEMORY
, "glDrawPixels");
626 for (i
= 0; i
< height
; i
++) {
627 const GLuint
*depthStencilSrc
= (const GLuint
*)
628 _mesa_image_address2d(&clippedUnpack
, pixels
, width
, height
,
629 GL_DEPTH_STENCIL_EXT
, type
, i
, 0);
631 if (ctx
->Depth
.Mask
) {
632 _mesa_unpack_depth_span(ctx
, width
,
633 GL_UNSIGNED_INT
, /* dest type */
634 zValues
, /* dest addr */
635 0xffffffff, /* depth max */
637 depthStencilSrc
, /* src addr */
640 _swrast_write_zoomed_z_span(ctx
, imgX
, imgY
, width
, x
,
644 GLubyte
*dst
= _swrast_pixel_address(depthRb
, x
, y
+ i
);
645 _mesa_pack_uint_z_row(depthRb
->Format
, width
, zValues
, dst
);
649 if (stencilMask
!= 0x0) {
650 GLubyte
*stencilValues
= (GLubyte
*) zValues
; /* re-use buffer */
651 /* get stencil values, with shift/offset/mapping */
652 _mesa_unpack_stencil_span(ctx
, width
, stencilType
, stencilValues
,
653 type
, depthStencilSrc
, &clippedUnpack
,
654 ctx
->_ImageTransferState
);
656 _swrast_write_zoomed_stencil_span(ctx
, imgX
, imgY
, width
,
657 x
, y
+ i
, stencilValues
);
659 _swrast_write_stencil_span(ctx
, width
, x
, y
+ i
, stencilValues
);
669 * Execute software-based glDrawPixels.
670 * By time we get here, all error checking will have been done.
673 _swrast_DrawPixels( struct gl_context
*ctx
,
675 GLsizei width
, GLsizei height
,
676 GLenum format
, GLenum type
,
677 const struct gl_pixelstore_attrib
*unpack
,
678 const GLvoid
*pixels
)
680 SWcontext
*swrast
= SWRAST_CONTEXT(ctx
);
681 GLboolean save_vp_override
= ctx
->VertexProgram
._Overriden
;
683 if (!_mesa_check_conditional_render(ctx
))
684 return; /* don't draw */
686 /* We are creating fragments directly, without going through vertex
689 * This override flag tells the fragment processing code that its input
690 * comes from a non-standard source, and it may therefore not rely on
691 * optimizations that assume e.g. constant color if there is no color
694 _mesa_set_vp_override(ctx
, GL_TRUE
);
697 _mesa_update_state(ctx
);
699 if (swrast
->NewState
)
700 _swrast_validate_derived( ctx
);
702 pixels
= _mesa_map_pbo_source(ctx
, unpack
, pixels
);
704 _mesa_set_vp_override(ctx
, save_vp_override
);
709 * By time we get here, all error checking should have been done.
712 case GL_STENCIL_INDEX
:
713 swrast_render_start(ctx
);
714 draw_stencil_pixels( ctx
, x
, y
, width
, height
, type
, unpack
, pixels
);
715 swrast_render_finish(ctx
);
717 case GL_DEPTH_COMPONENT
:
718 swrast_render_start(ctx
);
719 draw_depth_pixels( ctx
, x
, y
, width
, height
, type
, unpack
, pixels
);
720 swrast_render_finish(ctx
);
722 case GL_DEPTH_STENCIL_EXT
:
723 swrast_render_start(ctx
);
724 draw_depth_stencil_pixels(ctx
, x
, y
, width
, height
, type
, unpack
, pixels
);
725 swrast_render_finish(ctx
);
728 /* all other formats should be color formats */
729 draw_rgba_pixels(ctx
, x
, y
, width
, height
, format
, type
, unpack
, pixels
);
732 _mesa_set_vp_override(ctx
, save_vp_override
);
734 _mesa_unmap_pbo_source(ctx
, unpack
);