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
, NULL
)) {
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.0F
|| ctx
->Pixel
.ZoomY
!= 1.0F
;
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.0f
|| ctx
->Pixel
.DepthBias
!= 0.0f
;
313 const GLboolean zoom
= ctx
->Pixel
.ZoomX
!= 1.0f
|| ctx
->Pixel
.ZoomY
!= 1.0f
;
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.0F
|| ctx
->Pixel
.ZoomY
!= 1.0F
;
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 GLint skipPixels
= 0;
452 /* use span array for temp color storage */
453 GLfloat
*rgba
= (GLfloat
*) span
.array
->attribs
[VARYING_SLOT_COL0
];
454 void *tempImage
= NULL
;
456 /* We have to deal with GL_COLOR_INDEX manually because
457 * _mesa_format_convert does not handle this format. So what we do here is
458 * convert it to RGBA ubyte first and then convert from that to dst as
461 if (format
== GL_COLOR_INDEX
) {
462 /* This will handle byte swapping and transferops if needed */
464 _mesa_unpack_color_index_to_rgba_ubyte(ctx
, 2,
465 pixels
, format
, type
,
470 _mesa_error(ctx
, GL_OUT_OF_MEMORY
, "glDrawPixels");
477 type
= GL_UNSIGNED_BYTE
;
478 } else if (unpack
->SwapBytes
) {
479 /* We have to handle byte-swapping scenarios before calling
480 * _mesa_format_convert
482 GLint swapSize
= _mesa_sizeof_packed_type(type
);
483 if (swapSize
== 2 || swapSize
== 4) {
484 int imageStride
= _mesa_image_image_stride(unpack
, width
, height
, format
, type
);
486 tempImage
= malloc(imageStride
);
488 _mesa_error(ctx
, GL_OUT_OF_MEMORY
, "glDrawPixels");
492 _mesa_swap_bytes_2d_image(format
, type
, unpack
,
493 width
, height
, tempImage
, pixels
);
499 const GLint srcStride
500 = _mesa_image_row_stride(unpack
, width
, format
, type
);
502 /* if the span is wider than SWRAST_MAX_WIDTH we have to do it in chunks */
503 while (skipPixels
< width
) {
504 const GLint spanWidth
= MIN2(width
- skipPixels
, SWRAST_MAX_WIDTH
);
505 const GLubyte
*source
506 = (const GLubyte
*) _mesa_image_address2d(unpack
, pixels
,
507 width
, height
, format
,
508 type
, 0, skipPixels
);
511 /* get image row as float/RGBA */
512 uint32_t srcMesaFormat
= _mesa_format_from_format_and_type(format
, type
);
513 for (row
= 0; row
< height
; row
++) {
514 int dstRowStride
= 4 * width
* sizeof(float);
515 _mesa_format_convert(rgba
, RGBA32_FLOAT
, dstRowStride
,
516 (void*)source
, srcMesaFormat
, srcStride
,
519 _mesa_apply_rgba_transfer_ops(ctx
, transferOps
, spanWidth
, (GLfloat (*)[4])rgba
);
520 /* Set these for each row since the _swrast_write_* functions
521 * may change them while clipping/rendering.
523 span
.array
->ChanType
= GL_FLOAT
;
524 span
.x
= x
+ skipPixels
;
526 span
.end
= spanWidth
;
527 span
.arrayMask
= arrayMask
;
528 span
.interpMask
= interpMask
;
530 _swrast_write_zoomed_rgba_span(ctx
, imgX
, imgY
, &span
, rgba
);
533 _swrast_write_rgba_span(ctx
, &span
);
539 skipPixels
+= spanWidth
;
540 } /* while skipPixels < width */
542 /* XXX this is ugly/temporary, to undo above change */
543 span
.array
->ChanType
= CHAN_TYPE
;
548 swrast_render_finish(ctx
);
553 * Draw depth+stencil values into a MESA_FORAMT_Z24_S8 or MESA_FORMAT_Z24_UNORM_S8_UINT
554 * renderbuffer. No masking, zooming, scaling, etc.
557 fast_draw_depth_stencil(struct gl_context
*ctx
, GLint x
, GLint y
,
558 GLsizei width
, GLsizei height
,
559 const struct gl_pixelstore_attrib
*unpack
,
560 const GLvoid
*pixels
)
562 const GLenum format
= GL_DEPTH_STENCIL_EXT
;
563 const GLenum type
= GL_UNSIGNED_INT_24_8
;
564 struct gl_renderbuffer
*rb
=
565 ctx
->DrawBuffer
->Attachment
[BUFFER_DEPTH
].Renderbuffer
;
566 struct swrast_renderbuffer
*srb
= swrast_renderbuffer(rb
);
568 GLint srcRowStride
, dstRowStride
;
571 src
= _mesa_image_address2d(unpack
, pixels
, width
, height
,
573 srcRowStride
= _mesa_image_row_stride(unpack
, width
, format
, type
);
575 dst
= _swrast_pixel_address(rb
, x
, y
);
576 dstRowStride
= srb
->RowStride
;
578 for (i
= 0; i
< height
; i
++) {
579 _mesa_pack_uint_24_8_depth_stencil_row(rb
->Format
, width
,
580 (const GLuint
*) src
, dst
);
589 * This is a bit different from drawing GL_DEPTH_COMPONENT pixels.
590 * The only per-pixel operations that apply are depth scale/bias,
591 * stencil offset/shift, GL_DEPTH_WRITEMASK and GL_STENCIL_WRITEMASK,
593 * Also, only the depth buffer and stencil buffers are touched, not the
597 draw_depth_stencil_pixels(struct gl_context
*ctx
, GLint x
, GLint y
,
598 GLsizei width
, GLsizei height
, GLenum type
,
599 const struct gl_pixelstore_attrib
*unpack
,
600 const GLvoid
*pixels
)
602 const GLint imgX
= x
, imgY
= y
;
603 const GLboolean scaleOrBias
604 = ctx
->Pixel
.DepthScale
!= 1.0F
|| ctx
->Pixel
.DepthBias
!= 0.0F
;
605 const GLuint stencilMask
= ctx
->Stencil
.WriteMask
[0];
606 const GLenum stencilType
= GL_UNSIGNED_BYTE
;
607 const GLboolean zoom
= ctx
->Pixel
.ZoomX
!= 1.0F
|| ctx
->Pixel
.ZoomY
!= 1.0F
;
608 struct gl_renderbuffer
*depthRb
, *stencilRb
;
609 struct gl_pixelstore_attrib clippedUnpack
= *unpack
;
612 if (!_mesa_clip_drawpixels(ctx
, &x
, &y
, &width
, &height
,
614 /* totally clipped */
619 depthRb
= ctx
->ReadBuffer
->Attachment
[BUFFER_DEPTH
].Renderbuffer
;
620 stencilRb
= ctx
->ReadBuffer
->Attachment
[BUFFER_STENCIL
].Renderbuffer
;
624 if (depthRb
== stencilRb
&&
625 (depthRb
->Format
== MESA_FORMAT_S8_UINT_Z24_UNORM
||
626 depthRb
->Format
== MESA_FORMAT_Z24_UNORM_S8_UINT
) &&
627 type
== GL_UNSIGNED_INT_24_8
&&
631 (stencilMask
& 0xff) == 0xff) {
632 fast_draw_depth_stencil(ctx
, x
, y
, width
, height
,
633 &clippedUnpack
, pixels
);
636 /* sub-optimal cases:
637 * Separate depth/stencil buffers, or pixel transfer ops required.
639 /* XXX need to handle very wide images (skippixels) */
640 GLuint
*zValues
; /* 32-bit Z values */
643 zValues
= malloc(width
* sizeof(GLuint
));
645 _mesa_error(ctx
, GL_OUT_OF_MEMORY
, "glDrawPixels");
649 for (i
= 0; i
< height
; i
++) {
650 const GLuint
*depthStencilSrc
= (const GLuint
*)
651 _mesa_image_address2d(&clippedUnpack
, pixels
, width
, height
,
652 GL_DEPTH_STENCIL_EXT
, type
, i
, 0);
654 if (ctx
->Depth
.Mask
) {
655 _mesa_unpack_depth_span(ctx
, width
,
656 GL_UNSIGNED_INT
, /* dest type */
657 zValues
, /* dest addr */
658 0xffffffff, /* depth max */
660 depthStencilSrc
, /* src addr */
663 _swrast_write_zoomed_z_span(ctx
, imgX
, imgY
, width
, x
,
667 GLubyte
*dst
= _swrast_pixel_address(depthRb
, x
, y
+ i
);
668 _mesa_pack_uint_z_row(depthRb
->Format
, width
, zValues
, dst
);
672 if (stencilMask
!= 0x0) {
673 GLubyte
*stencilValues
= (GLubyte
*) zValues
; /* re-use buffer */
674 /* get stencil values, with shift/offset/mapping */
675 _mesa_unpack_stencil_span(ctx
, width
, stencilType
, stencilValues
,
676 type
, depthStencilSrc
, &clippedUnpack
,
677 ctx
->_ImageTransferState
);
679 _swrast_write_zoomed_stencil_span(ctx
, imgX
, imgY
, width
,
680 x
, y
+ i
, stencilValues
);
682 _swrast_write_stencil_span(ctx
, width
, x
, y
+ i
, stencilValues
);
692 * Execute software-based glDrawPixels.
693 * By time we get here, all error checking will have been done.
696 _swrast_DrawPixels( struct gl_context
*ctx
,
698 GLsizei width
, GLsizei height
,
699 GLenum format
, GLenum type
,
700 const struct gl_pixelstore_attrib
*unpack
,
701 const GLvoid
*pixels
)
703 SWcontext
*swrast
= SWRAST_CONTEXT(ctx
);
704 GLboolean save_vp_override
= ctx
->VertexProgram
._Overriden
;
706 if (!_mesa_check_conditional_render(ctx
))
707 return; /* don't draw */
709 /* We are creating fragments directly, without going through vertex
712 * This override flag tells the fragment processing code that its input
713 * comes from a non-standard source, and it may therefore not rely on
714 * optimizations that assume e.g. constant color if there is no color
717 _mesa_set_vp_override(ctx
, GL_TRUE
);
720 _mesa_update_state(ctx
);
722 if (swrast
->NewState
)
723 _swrast_validate_derived( ctx
);
725 pixels
= _mesa_map_pbo_source(ctx
, unpack
, pixels
);
727 _mesa_set_vp_override(ctx
, save_vp_override
);
732 * By time we get here, all error checking should have been done.
735 case GL_STENCIL_INDEX
:
736 swrast_render_start(ctx
);
737 draw_stencil_pixels( ctx
, x
, y
, width
, height
, type
, unpack
, pixels
);
738 swrast_render_finish(ctx
);
740 case GL_DEPTH_COMPONENT
:
741 swrast_render_start(ctx
);
742 draw_depth_pixels( ctx
, x
, y
, width
, height
, type
, unpack
, pixels
);
743 swrast_render_finish(ctx
);
745 case GL_DEPTH_STENCIL_EXT
:
746 swrast_render_start(ctx
);
747 draw_depth_stencil_pixels(ctx
, x
, y
, width
, height
, type
, unpack
, pixels
);
748 swrast_render_finish(ctx
);
751 /* all other formats should be color formats */
752 draw_rgba_pixels(ctx
, x
, y
, width
, height
, format
, type
, unpack
, pixels
);
755 _mesa_set_vp_override(ctx
, save_vp_override
);
757 _mesa_unmap_pbo_source(ctx
, unpack
);