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.
28 * glClearColor, glClearIndex, glClear() functions.
46 _mesa_ClearIndex( GLfloat c
)
48 GET_CURRENT_CONTEXT(ctx
);
50 ctx
->Color
.ClearIndex
= (GLuint
) c
;
55 * Specify the clear values for the color buffers.
57 * \param red red color component.
58 * \param green green color component.
59 * \param blue blue color component.
60 * \param alpha alpha component.
65 _mesa_ClearColor( GLclampf red
, GLclampf green
, GLclampf blue
, GLclampf alpha
)
67 GET_CURRENT_CONTEXT(ctx
);
69 ctx
->Color
.ClearColor
.f
[0] = red
;
70 ctx
->Color
.ClearColor
.f
[1] = green
;
71 ctx
->Color
.ClearColor
.f
[2] = blue
;
72 ctx
->Color
.ClearColor
.f
[3] = alpha
;
77 * GL_EXT_texture_integer
80 _mesa_ClearColorIiEXT(GLint r
, GLint g
, GLint b
, GLint a
)
82 GET_CURRENT_CONTEXT(ctx
);
84 ctx
->Color
.ClearColor
.i
[0] = r
;
85 ctx
->Color
.ClearColor
.i
[1] = g
;
86 ctx
->Color
.ClearColor
.i
[2] = b
;
87 ctx
->Color
.ClearColor
.i
[3] = a
;
92 * GL_EXT_texture_integer
95 _mesa_ClearColorIuiEXT(GLuint r
, GLuint g
, GLuint b
, GLuint a
)
97 GET_CURRENT_CONTEXT(ctx
);
99 ctx
->Color
.ClearColor
.ui
[0] = r
;
100 ctx
->Color
.ClearColor
.ui
[1] = g
;
101 ctx
->Color
.ClearColor
.ui
[2] = b
;
102 ctx
->Color
.ClearColor
.ui
[3] = a
;
107 * Returns true if color writes are enabled for the given color attachment.
109 * Beyond checking ColorMask, this uses _mesa_format_has_color_component to
110 * ignore components that don't actually exist in the format (such as X in
114 color_buffer_writes_enabled(const struct gl_context
*ctx
, unsigned idx
)
116 struct gl_renderbuffer
*rb
= ctx
->DrawBuffer
->_ColorDrawBuffers
[idx
];
120 for (c
= 0; c
< 4; c
++) {
121 if (GET_COLORMASK_BIT(ctx
->Color
.ColorMask
, idx
, c
) &&
122 _mesa_format_has_color_component(rb
->Format
, c
)) {
135 * \param mask bit-mask indicating the buffers to be cleared.
137 * Flushes the vertices and verifies the parameter.
138 * If __struct gl_contextRec::NewState is set then calls _mesa_update_state()
139 * to update gl_frame_buffer::_Xmin, etc. If the rasterization mode is set to
140 * GL_RENDER then requests the driver to clear the buffers, via the
141 * dd_function_table::Clear callback.
143 static ALWAYS_INLINE
void
144 clear(struct gl_context
*ctx
, GLbitfield mask
, bool no_error
)
146 FLUSH_VERTICES(ctx
, 0);
149 if (mask
& ~(GL_COLOR_BUFFER_BIT
|
150 GL_DEPTH_BUFFER_BIT
|
151 GL_STENCIL_BUFFER_BIT
|
152 GL_ACCUM_BUFFER_BIT
)) {
153 _mesa_error( ctx
, GL_INVALID_VALUE
, "glClear(0x%x)", mask
);
157 /* Accumulation buffers were removed in core contexts, and they never
158 * existed in OpenGL ES.
160 if ((mask
& GL_ACCUM_BUFFER_BIT
) != 0
161 && (ctx
->API
== API_OPENGL_CORE
|| _mesa_is_gles(ctx
))) {
162 _mesa_error( ctx
, GL_INVALID_VALUE
, "glClear(GL_ACCUM_BUFFER_BIT)");
168 _mesa_update_state( ctx
); /* update _Xmin, etc */
171 if (!no_error
&& ctx
->DrawBuffer
->_Status
!= GL_FRAMEBUFFER_COMPLETE_EXT
) {
172 _mesa_error(ctx
, GL_INVALID_FRAMEBUFFER_OPERATION_EXT
,
173 "glClear(incomplete framebuffer)");
177 if (ctx
->RasterDiscard
)
180 if (ctx
->RenderMode
== GL_RENDER
) {
181 GLbitfield bufferMask
;
183 /* don't clear depth buffer if depth writing disabled */
184 if (!ctx
->Depth
.Mask
)
185 mask
&= ~GL_DEPTH_BUFFER_BIT
;
187 /* Build the bitmask to send to device driver's Clear function.
188 * Note that the GL_COLOR_BUFFER_BIT flag will expand to 0, 1, 2 or 4
189 * of the BUFFER_BIT_FRONT/BACK_LEFT/RIGHT flags, or one of the
190 * BUFFER_BIT_COLORn flags.
193 if (mask
& GL_COLOR_BUFFER_BIT
) {
195 for (i
= 0; i
< ctx
->DrawBuffer
->_NumColorDrawBuffers
; i
++) {
196 gl_buffer_index buf
= ctx
->DrawBuffer
->_ColorDrawBufferIndexes
[i
];
198 if (buf
!= BUFFER_NONE
&& color_buffer_writes_enabled(ctx
, i
)) {
199 bufferMask
|= 1 << buf
;
204 if ((mask
& GL_DEPTH_BUFFER_BIT
)
205 && ctx
->DrawBuffer
->Visual
.depthBits
> 0) {
206 bufferMask
|= BUFFER_BIT_DEPTH
;
209 if ((mask
& GL_STENCIL_BUFFER_BIT
)
210 && ctx
->DrawBuffer
->Visual
.stencilBits
> 0) {
211 bufferMask
|= BUFFER_BIT_STENCIL
;
214 if ((mask
& GL_ACCUM_BUFFER_BIT
)
215 && ctx
->DrawBuffer
->Visual
.accumRedBits
> 0) {
216 bufferMask
|= BUFFER_BIT_ACCUM
;
219 assert(ctx
->Driver
.Clear
);
220 ctx
->Driver
.Clear(ctx
, bufferMask
);
226 _mesa_Clear_no_error(GLbitfield mask
)
228 GET_CURRENT_CONTEXT(ctx
);
229 clear(ctx
, mask
, true);
234 _mesa_Clear(GLbitfield mask
)
236 GET_CURRENT_CONTEXT(ctx
);
238 if (MESA_VERBOSE
& VERBOSE_API
)
239 _mesa_debug(ctx
, "glClear 0x%x\n", mask
);
241 clear(ctx
, mask
, false);
245 /** Returned by make_color_buffer_mask() for errors */
246 #define INVALID_MASK ~0x0U
250 * Convert the glClearBuffer 'drawbuffer' parameter into a bitmask of
251 * BUFFER_BIT_x values.
252 * Return INVALID_MASK if the drawbuffer value is invalid.
255 make_color_buffer_mask(struct gl_context
*ctx
, GLint drawbuffer
)
257 const struct gl_renderbuffer_attachment
*att
= ctx
->DrawBuffer
->Attachment
;
258 GLbitfield mask
= 0x0;
260 /* From the GL 4.0 specification:
261 * If buffer is COLOR, a particular draw buffer DRAW_BUFFERi is
262 * specified by passing i as the parameter drawbuffer, and value
263 * points to a four-element vector specifying the R, G, B, and A
264 * color to clear that draw buffer to. If the draw buffer is one
265 * of FRONT, BACK, LEFT, RIGHT, or FRONT_AND_BACK, identifying
266 * multiple buffers, each selected buffer is cleared to the same
269 * Note that "drawbuffer" and "draw buffer" have different meaning.
270 * "drawbuffer" specifies DRAW_BUFFERi, while "draw buffer" is what's
271 * assigned to DRAW_BUFFERi. It could be COLOR_ATTACHMENT0, FRONT, BACK,
274 if (drawbuffer
< 0 || drawbuffer
>= (GLint
)ctx
->Const
.MaxDrawBuffers
) {
278 switch (ctx
->DrawBuffer
->ColorDrawBuffer
[drawbuffer
]) {
280 if (att
[BUFFER_FRONT_LEFT
].Renderbuffer
)
281 mask
|= BUFFER_BIT_FRONT_LEFT
;
282 if (att
[BUFFER_FRONT_RIGHT
].Renderbuffer
)
283 mask
|= BUFFER_BIT_FRONT_RIGHT
;
286 /* For GLES contexts with a single buffered configuration, we actually
287 * only have a front renderbuffer, so any clear calls to GL_BACK should
288 * affect that buffer. See draw_buffer_enum_to_bitmask for details.
290 if (_mesa_is_gles(ctx
))
291 if (!ctx
->DrawBuffer
->Visual
.doubleBufferMode
)
292 if (att
[BUFFER_FRONT_LEFT
].Renderbuffer
)
293 mask
|= BUFFER_BIT_FRONT_LEFT
;
294 if (att
[BUFFER_BACK_LEFT
].Renderbuffer
)
295 mask
|= BUFFER_BIT_BACK_LEFT
;
296 if (att
[BUFFER_BACK_RIGHT
].Renderbuffer
)
297 mask
|= BUFFER_BIT_BACK_RIGHT
;
300 if (att
[BUFFER_FRONT_LEFT
].Renderbuffer
)
301 mask
|= BUFFER_BIT_FRONT_LEFT
;
302 if (att
[BUFFER_BACK_LEFT
].Renderbuffer
)
303 mask
|= BUFFER_BIT_BACK_LEFT
;
306 if (att
[BUFFER_FRONT_RIGHT
].Renderbuffer
)
307 mask
|= BUFFER_BIT_FRONT_RIGHT
;
308 if (att
[BUFFER_BACK_RIGHT
].Renderbuffer
)
309 mask
|= BUFFER_BIT_BACK_RIGHT
;
311 case GL_FRONT_AND_BACK
:
312 if (att
[BUFFER_FRONT_LEFT
].Renderbuffer
)
313 mask
|= BUFFER_BIT_FRONT_LEFT
;
314 if (att
[BUFFER_BACK_LEFT
].Renderbuffer
)
315 mask
|= BUFFER_BIT_BACK_LEFT
;
316 if (att
[BUFFER_FRONT_RIGHT
].Renderbuffer
)
317 mask
|= BUFFER_BIT_FRONT_RIGHT
;
318 if (att
[BUFFER_BACK_RIGHT
].Renderbuffer
)
319 mask
|= BUFFER_BIT_BACK_RIGHT
;
323 gl_buffer_index buf
=
324 ctx
->DrawBuffer
->_ColorDrawBufferIndexes
[drawbuffer
];
326 if (buf
!= BUFFER_NONE
&& att
[buf
].Renderbuffer
) {
339 * Clear signed integer color buffer or stencil buffer (not depth).
341 static ALWAYS_INLINE
void
342 clear_bufferiv(struct gl_context
*ctx
, GLenum buffer
, GLint drawbuffer
,
343 const GLint
*value
, bool no_error
)
345 FLUSH_VERTICES(ctx
, 0);
348 _mesa_update_state( ctx
);
351 if (!no_error
&& ctx
->DrawBuffer
->_Status
!= GL_FRAMEBUFFER_COMPLETE_EXT
) {
352 _mesa_error(ctx
, GL_INVALID_FRAMEBUFFER_OPERATION_EXT
,
353 "glClearBufferiv(incomplete framebuffer)");
359 /* Page 264 (page 280 of the PDF) of the OpenGL 3.0 spec says:
361 * "ClearBuffer generates an INVALID VALUE error if buffer is
362 * COLOR and drawbuffer is less than zero, or greater than the
363 * value of MAX DRAW BUFFERS minus one; or if buffer is DEPTH,
364 * STENCIL, or DEPTH STENCIL and drawbuffer is not zero."
366 if (!no_error
&& drawbuffer
!= 0) {
367 _mesa_error(ctx
, GL_INVALID_VALUE
, "glClearBufferiv(drawbuffer=%d)",
371 else if (ctx
->DrawBuffer
->Attachment
[BUFFER_STENCIL
].Renderbuffer
372 && !ctx
->RasterDiscard
) {
373 /* Save current stencil clear value, set to 'value', do the
374 * stencil clear and restore the clear value.
375 * XXX in the future we may have a new ctx->Driver.ClearBuffer()
378 const GLuint clearSave
= ctx
->Stencil
.Clear
;
379 ctx
->Stencil
.Clear
= *value
;
380 ctx
->Driver
.Clear(ctx
, BUFFER_BIT_STENCIL
);
381 ctx
->Stencil
.Clear
= clearSave
;
386 const GLbitfield mask
= make_color_buffer_mask(ctx
, drawbuffer
);
387 if (!no_error
&& mask
== INVALID_MASK
) {
388 _mesa_error(ctx
, GL_INVALID_VALUE
, "glClearBufferiv(drawbuffer=%d)",
392 else if (mask
&& !ctx
->RasterDiscard
) {
393 union gl_color_union clearSave
;
396 clearSave
= ctx
->Color
.ClearColor
;
398 COPY_4V(ctx
->Color
.ClearColor
.i
, value
);
399 /* clear buffer(s) */
400 ctx
->Driver
.Clear(ctx
, mask
);
402 ctx
->Color
.ClearColor
= clearSave
;
408 /* Page 498 of the PDF, section '17.4.3.1 Clearing Individual Buffers'
409 * of the OpenGL 4.5 spec states:
411 * "An INVALID_ENUM error is generated by ClearBufferiv and
412 * ClearNamedFramebufferiv if buffer is not COLOR or STENCIL."
414 _mesa_error(ctx
, GL_INVALID_ENUM
, "glClearBufferiv(buffer=%s)",
415 _mesa_enum_to_string(buffer
));
423 _mesa_ClearBufferiv_no_error(GLenum buffer
, GLint drawbuffer
, const GLint
*value
)
425 GET_CURRENT_CONTEXT(ctx
);
426 clear_bufferiv(ctx
, buffer
, drawbuffer
, value
, true);
431 _mesa_ClearBufferiv(GLenum buffer
, GLint drawbuffer
, const GLint
*value
)
433 GET_CURRENT_CONTEXT(ctx
);
434 clear_bufferiv(ctx
, buffer
, drawbuffer
, value
, false);
439 * The ClearBuffer framework is so complicated and so riddled with the
440 * assumption that the framebuffer is bound that, for now, we will just fake
441 * direct state access clearing for the user.
444 _mesa_ClearNamedFramebufferiv(GLuint framebuffer
, GLenum buffer
,
445 GLint drawbuffer
, const GLint
*value
)
449 _mesa_GetIntegerv(GL_DRAW_FRAMEBUFFER_BINDING
, &oldfb
);
450 _mesa_BindFramebuffer(GL_DRAW_FRAMEBUFFER
, framebuffer
);
451 _mesa_ClearBufferiv(buffer
, drawbuffer
, value
);
452 _mesa_BindFramebuffer(GL_DRAW_FRAMEBUFFER
, (GLuint
) oldfb
);
458 * Clear unsigned integer color buffer (not depth, not stencil).
460 static ALWAYS_INLINE
void
461 clear_bufferuiv(struct gl_context
*ctx
, GLenum buffer
, GLint drawbuffer
,
462 const GLuint
*value
, bool no_error
)
464 FLUSH_VERTICES(ctx
, 0);
467 _mesa_update_state( ctx
);
473 const GLbitfield mask
= make_color_buffer_mask(ctx
, drawbuffer
);
474 if (!no_error
&& mask
== INVALID_MASK
) {
475 _mesa_error(ctx
, GL_INVALID_VALUE
, "glClearBufferuiv(drawbuffer=%d)",
479 else if (mask
&& !ctx
->RasterDiscard
) {
480 union gl_color_union clearSave
;
483 clearSave
= ctx
->Color
.ClearColor
;
485 COPY_4V(ctx
->Color
.ClearColor
.ui
, value
);
486 /* clear buffer(s) */
487 ctx
->Driver
.Clear(ctx
, mask
);
489 ctx
->Color
.ClearColor
= clearSave
;
495 /* Page 498 of the PDF, section '17.4.3.1 Clearing Individual Buffers'
496 * of the OpenGL 4.5 spec states:
498 * "An INVALID_ENUM error is generated by ClearBufferuiv and
499 * ClearNamedFramebufferuiv if buffer is not COLOR."
501 _mesa_error(ctx
, GL_INVALID_ENUM
, "glClearBufferuiv(buffer=%s)",
502 _mesa_enum_to_string(buffer
));
510 _mesa_ClearBufferuiv_no_error(GLenum buffer
, GLint drawbuffer
,
513 GET_CURRENT_CONTEXT(ctx
);
514 clear_bufferuiv(ctx
, buffer
, drawbuffer
, value
, true);
519 _mesa_ClearBufferuiv(GLenum buffer
, GLint drawbuffer
, const GLuint
*value
)
521 GET_CURRENT_CONTEXT(ctx
);
522 clear_bufferuiv(ctx
, buffer
, drawbuffer
, value
, false);
527 * The ClearBuffer framework is so complicated and so riddled with the
528 * assumption that the framebuffer is bound that, for now, we will just fake
529 * direct state access clearing for the user.
532 _mesa_ClearNamedFramebufferuiv(GLuint framebuffer
, GLenum buffer
,
533 GLint drawbuffer
, const GLuint
*value
)
537 _mesa_GetIntegerv(GL_DRAW_FRAMEBUFFER_BINDING
, &oldfb
);
538 _mesa_BindFramebuffer(GL_DRAW_FRAMEBUFFER
, framebuffer
);
539 _mesa_ClearBufferuiv(buffer
, drawbuffer
, value
);
540 _mesa_BindFramebuffer(GL_DRAW_FRAMEBUFFER
, (GLuint
) oldfb
);
546 * Clear fixed-pt or float color buffer or depth buffer (not stencil).
548 static ALWAYS_INLINE
void
549 clear_bufferfv(struct gl_context
*ctx
, GLenum buffer
, GLint drawbuffer
,
550 const GLfloat
*value
, bool no_error
)
552 FLUSH_VERTICES(ctx
, 0);
555 _mesa_update_state( ctx
);
560 /* Page 264 (page 280 of the PDF) of the OpenGL 3.0 spec says:
562 * "ClearBuffer generates an INVALID VALUE error if buffer is
563 * COLOR and drawbuffer is less than zero, or greater than the
564 * value of MAX DRAW BUFFERS minus one; or if buffer is DEPTH,
565 * STENCIL, or DEPTH STENCIL and drawbuffer is not zero."
567 if (!no_error
&& drawbuffer
!= 0) {
568 _mesa_error(ctx
, GL_INVALID_VALUE
, "glClearBufferfv(drawbuffer=%d)",
572 else if (ctx
->DrawBuffer
->Attachment
[BUFFER_DEPTH
].Renderbuffer
573 && !ctx
->RasterDiscard
) {
574 /* Save current depth clear value, set to 'value', do the
575 * depth clear and restore the clear value.
576 * XXX in the future we may have a new ctx->Driver.ClearBuffer()
579 const GLclampd clearSave
= ctx
->Depth
.Clear
;
580 ctx
->Depth
.Clear
= *value
;
581 ctx
->Driver
.Clear(ctx
, BUFFER_BIT_DEPTH
);
582 ctx
->Depth
.Clear
= clearSave
;
584 /* clear depth buffer to value */
588 const GLbitfield mask
= make_color_buffer_mask(ctx
, drawbuffer
);
589 if (!no_error
&& mask
== INVALID_MASK
) {
590 _mesa_error(ctx
, GL_INVALID_VALUE
, "glClearBufferfv(drawbuffer=%d)",
594 else if (mask
&& !ctx
->RasterDiscard
) {
595 union gl_color_union clearSave
;
598 clearSave
= ctx
->Color
.ClearColor
;
600 COPY_4V(ctx
->Color
.ClearColor
.f
, value
);
601 /* clear buffer(s) */
602 ctx
->Driver
.Clear(ctx
, mask
);
604 ctx
->Color
.ClearColor
= clearSave
;
610 /* Page 498 of the PDF, section '17.4.3.1 Clearing Individual Buffers'
611 * of the OpenGL 4.5 spec states:
613 * "An INVALID_ENUM error is generated by ClearBufferfv and
614 * ClearNamedFramebufferfv if buffer is not COLOR or DEPTH."
616 _mesa_error(ctx
, GL_INVALID_ENUM
, "glClearBufferfv(buffer=%s)",
617 _mesa_enum_to_string(buffer
));
625 _mesa_ClearBufferfv_no_error(GLenum buffer
, GLint drawbuffer
,
626 const GLfloat
*value
)
628 GET_CURRENT_CONTEXT(ctx
);
629 clear_bufferfv(ctx
, buffer
, drawbuffer
, value
, true);
634 _mesa_ClearBufferfv(GLenum buffer
, GLint drawbuffer
, const GLfloat
*value
)
636 GET_CURRENT_CONTEXT(ctx
);
637 clear_bufferfv(ctx
, buffer
, drawbuffer
, value
, false);
642 * The ClearBuffer framework is so complicated and so riddled with the
643 * assumption that the framebuffer is bound that, for now, we will just fake
644 * direct state access clearing for the user.
647 _mesa_ClearNamedFramebufferfv(GLuint framebuffer
, GLenum buffer
,
648 GLint drawbuffer
, const GLfloat
*value
)
652 _mesa_GetIntegerv(GL_DRAW_FRAMEBUFFER_BINDING
, &oldfb
);
653 _mesa_BindFramebuffer(GL_DRAW_FRAMEBUFFER
, framebuffer
);
654 _mesa_ClearBufferfv(buffer
, drawbuffer
, value
);
655 _mesa_BindFramebuffer(GL_DRAW_FRAMEBUFFER
, (GLuint
) oldfb
);
661 * Clear depth/stencil buffer only.
663 static ALWAYS_INLINE
void
664 clear_bufferfi(struct gl_context
*ctx
, GLenum buffer
, GLint drawbuffer
,
665 GLfloat depth
, GLint stencil
, bool no_error
)
669 FLUSH_VERTICES(ctx
, 0);
672 if (buffer
!= GL_DEPTH_STENCIL
) {
673 _mesa_error(ctx
, GL_INVALID_ENUM
, "glClearBufferfi(buffer=%s)",
674 _mesa_enum_to_string(buffer
));
678 /* Page 264 (page 280 of the PDF) of the OpenGL 3.0 spec says:
680 * "ClearBuffer generates an INVALID VALUE error if buffer is
681 * COLOR and drawbuffer is less than zero, or greater than the
682 * value of MAX DRAW BUFFERS minus one; or if buffer is DEPTH,
683 * STENCIL, or DEPTH STENCIL and drawbuffer is not zero."
685 if (drawbuffer
!= 0) {
686 _mesa_error(ctx
, GL_INVALID_VALUE
, "glClearBufferfi(drawbuffer=%d)",
692 if (ctx
->RasterDiscard
)
696 _mesa_update_state( ctx
);
699 if (!no_error
&& ctx
->DrawBuffer
->_Status
!= GL_FRAMEBUFFER_COMPLETE_EXT
) {
700 _mesa_error(ctx
, GL_INVALID_FRAMEBUFFER_OPERATION_EXT
,
701 "glClearBufferfi(incomplete framebuffer)");
705 if (ctx
->DrawBuffer
->Attachment
[BUFFER_DEPTH
].Renderbuffer
)
706 mask
|= BUFFER_BIT_DEPTH
;
707 if (ctx
->DrawBuffer
->Attachment
[BUFFER_STENCIL
].Renderbuffer
)
708 mask
|= BUFFER_BIT_STENCIL
;
711 /* save current clear values */
712 const GLclampd clearDepthSave
= ctx
->Depth
.Clear
;
713 const GLuint clearStencilSave
= ctx
->Stencil
.Clear
;
715 /* set new clear values */
716 ctx
->Depth
.Clear
= depth
;
717 ctx
->Stencil
.Clear
= stencil
;
720 ctx
->Driver
.Clear(ctx
, mask
);
723 ctx
->Depth
.Clear
= clearDepthSave
;
724 ctx
->Stencil
.Clear
= clearStencilSave
;
730 _mesa_ClearBufferfi_no_error(GLenum buffer
, GLint drawbuffer
,
731 GLfloat depth
, GLint stencil
)
733 GET_CURRENT_CONTEXT(ctx
);
734 clear_bufferfi(ctx
, buffer
, drawbuffer
, depth
, stencil
, true);
739 _mesa_ClearBufferfi(GLenum buffer
, GLint drawbuffer
,
740 GLfloat depth
, GLint stencil
)
742 GET_CURRENT_CONTEXT(ctx
);
743 clear_bufferfi(ctx
, buffer
, drawbuffer
, depth
, stencil
, false);
748 * The ClearBuffer framework is so complicated and so riddled with the
749 * assumption that the framebuffer is bound that, for now, we will just fake
750 * direct state access clearing for the user.
753 _mesa_ClearNamedFramebufferfi(GLuint framebuffer
, GLenum buffer
,
754 GLint drawbuffer
, GLfloat depth
, GLint stencil
)
758 _mesa_GetIntegerv(GL_DRAW_FRAMEBUFFER_BINDING
, &oldfb
);
759 _mesa_BindFramebuffer(GL_DRAW_FRAMEBUFFER
, framebuffer
);
760 _mesa_ClearBufferfi(buffer
, drawbuffer
, depth
, stencil
);
761 _mesa_BindFramebuffer(GL_DRAW_FRAMEBUFFER
, (GLuint
) oldfb
);