2 * Copyright © 2012 Intel Corporation
4 * Permission is hereby granted, free of charge, to any person obtaining a
5 * copy of this software and associated documentation files (the "Software"),
6 * to deal in the Software without restriction, including without limitation
7 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 * and/or sell copies of the Software, and to permit persons to whom the
9 * Software is furnished to do so, subject to the following conditions:
11 * The above copyright notice and this permission notice (including the next
12 * paragraph) shall be included in all copies or substantial portions of the
15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
18 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
20 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
26 * Custom functions for marshalling GL calls from the main thread to a worker
27 * thread when automatic code generation isn't appropriate.
30 #include "main/enums.h"
31 #include "main/macros.h"
36 _mesa_post_marshal_hook(struct gl_context
*ctx
)
38 /* This can be enabled for debugging whether a failure is a synchronization
39 * problem between the main thread and the worker thread, or a failure in
40 * how we actually marshal.
43 _mesa_glthread_finish(ctx
);
46 struct marshal_cmd_Flush
48 struct marshal_cmd_base cmd_base
;
53 _mesa_unmarshal_Flush(struct gl_context
*ctx
,
54 const struct marshal_cmd_Flush
*cmd
)
56 CALL_Flush(ctx
->CurrentServerDispatch
, ());
61 _mesa_marshal_Flush(void)
63 GET_CURRENT_CONTEXT(ctx
);
64 struct marshal_cmd_Flush
*cmd
=
65 _mesa_glthread_allocate_command(ctx
, DISPATCH_CMD_Flush
,
66 sizeof(struct marshal_cmd_Flush
));
68 _mesa_post_marshal_hook(ctx
);
70 /* Flush() needs to be handled specially. In addition to telling the
71 * background thread to flush, we need to ensure that our own buffer is
72 * submitted to the background thread so that it will complete in a finite
75 _mesa_glthread_flush_batch(ctx
);
78 /* Enable: marshalled asynchronously */
79 struct marshal_cmd_Enable
81 struct marshal_cmd_base cmd_base
;
86 _mesa_unmarshal_Enable(struct gl_context
*ctx
,
87 const struct marshal_cmd_Enable
*cmd
)
89 const GLenum cap
= cmd
->cap
;
90 CALL_Enable(ctx
->CurrentServerDispatch
, (cap
));
94 _mesa_marshal_Enable(GLenum cap
)
96 GET_CURRENT_CONTEXT(ctx
);
97 struct marshal_cmd_Enable
*cmd
;
98 debug_print_marshal("Enable");
100 if (cap
== GL_DEBUG_OUTPUT_SYNCHRONOUS_ARB
) {
101 _mesa_glthread_disable(ctx
, "Enable(DEBUG_OUTPUT_SYNCHRONOUS)");
103 cmd
= _mesa_glthread_allocate_command(ctx
, DISPATCH_CMD_Enable
,
106 _mesa_post_marshal_hook(ctx
);
110 _mesa_glthread_finish(ctx
);
111 debug_print_sync_fallback("Enable");
112 CALL_Enable(ctx
->CurrentServerDispatch
, (cap
));
115 struct marshal_cmd_ShaderSource
117 struct marshal_cmd_base cmd_base
;
120 /* Followed by GLint length[count], then the contents of all strings,
127 _mesa_unmarshal_ShaderSource(struct gl_context
*ctx
,
128 const struct marshal_cmd_ShaderSource
*cmd
)
130 const GLint
*cmd_length
= (const GLint
*) (cmd
+ 1);
131 const GLchar
*cmd_strings
= (const GLchar
*) (cmd_length
+ cmd
->count
);
132 /* TODO: how to deal with malloc failure? */
133 const GLchar
* *string
= malloc(cmd
->count
* sizeof(const GLchar
*));
136 for (i
= 0; i
< cmd
->count
; ++i
) {
137 string
[i
] = cmd_strings
;
138 cmd_strings
+= cmd_length
[i
];
140 CALL_ShaderSource(ctx
->CurrentServerDispatch
,
141 (cmd
->shader
, cmd
->count
, string
, cmd_length
));
142 free((void *)string
);
147 measure_ShaderSource_strings(GLsizei count
, const GLchar
* const *string
,
148 const GLint
*length_in
, GLint
*length_out
)
151 size_t total_string_length
= 0;
153 for (i
= 0; i
< count
; ++i
) {
154 if (length_in
== NULL
|| length_in
[i
] < 0) {
156 length_out
[i
] = strlen(string
[i
]);
158 length_out
[i
] = length_in
[i
];
160 total_string_length
+= length_out
[i
];
162 return total_string_length
;
167 _mesa_marshal_ShaderSource(GLuint shader
, GLsizei count
,
168 const GLchar
* const *string
, const GLint
*length
)
170 /* TODO: how to report an error if count < 0? */
172 GET_CURRENT_CONTEXT(ctx
);
173 /* TODO: how to deal with malloc failure? */
174 const size_t fixed_cmd_size
= sizeof(struct marshal_cmd_ShaderSource
);
175 STATIC_ASSERT(sizeof(struct marshal_cmd_ShaderSource
) % sizeof(GLint
) == 0);
176 size_t length_size
= count
* sizeof(GLint
);
177 GLint
*length_tmp
= malloc(length_size
);
178 size_t total_string_length
=
179 measure_ShaderSource_strings(count
, string
, length
, length_tmp
);
180 size_t total_cmd_size
= fixed_cmd_size
+ length_size
+ total_string_length
;
182 if (total_cmd_size
<= MARSHAL_MAX_CMD_SIZE
) {
183 struct marshal_cmd_ShaderSource
*cmd
=
184 _mesa_glthread_allocate_command(ctx
, DISPATCH_CMD_ShaderSource
,
186 GLint
*cmd_length
= (GLint
*) (cmd
+ 1);
187 GLchar
*cmd_strings
= (GLchar
*) (cmd_length
+ count
);
190 cmd
->shader
= shader
;
192 memcpy(cmd_length
, length_tmp
, length_size
);
193 for (i
= 0; i
< count
; ++i
) {
194 memcpy(cmd_strings
, string
[i
], cmd_length
[i
]);
195 cmd_strings
+= cmd_length
[i
];
197 _mesa_post_marshal_hook(ctx
);
199 _mesa_glthread_finish(ctx
);
200 CALL_ShaderSource(ctx
->CurrentServerDispatch
,
201 (shader
, count
, string
, length_tmp
));
207 /* BindBufferBase: marshalled asynchronously */
208 struct marshal_cmd_BindBufferBase
210 struct marshal_cmd_base cmd_base
;
216 /** Tracks the current bindings for the vertex array and index array buffers.
218 * This is part of what we need to enable glthread on compat-GL contexts that
219 * happen to use VBOs, without also supporting the full tracking of VBO vs
220 * user vertex array bindings per attribute on each vertex array for
221 * determining what to upload at draw call time.
223 * Note that GL core makes it so that a buffer binding with an invalid handle
224 * in the "buffer" parameter will throw an error, and then a
225 * glVertexAttribPointer() that followsmight not end up pointing at a VBO.
226 * However, in GL core the draw call would throw an error as well, so we don't
227 * really care if our tracking is wrong for this case -- we never need to
228 * marshal user data for draw calls, and the unmarshal will just generate an
229 * error or not as appropriate.
231 * For compatibility GL, we do need to accurately know whether the draw call
232 * on the unmarshal side will dereference a user pointer or load data from a
233 * VBO per vertex. That would make it seem like we need to track whether a
234 * "buffer" is valid, so that we can know when an error will be generated
235 * instead of updating the binding. However, compat GL has the ridiculous
236 * feature that if you pass a bad name, it just gens a buffer object for you,
237 * so we escape without having to know if things are valid or not.
240 track_vbo_binding(struct gl_context
*ctx
, GLenum target
, GLuint buffer
)
242 struct glthread_state
*glthread
= ctx
->GLThread
;
245 case GL_ARRAY_BUFFER
:
246 glthread
->vertex_array_is_vbo
= (buffer
!= 0);
248 case GL_ELEMENT_ARRAY_BUFFER
:
249 /* The current element array buffer binding is actually tracked in the
250 * vertex array object instead of the context, so this would need to
251 * change on vertex array object updates.
253 glthread
->element_array_is_vbo
= (buffer
!= 0);
259 struct marshal_cmd_BindBuffer
261 struct marshal_cmd_base cmd_base
;
267 * This is just like the code-generated glBindBuffer() support, except that we
268 * call track_vbo_binding().
271 _mesa_unmarshal_BindBuffer(struct gl_context
*ctx
,
272 const struct marshal_cmd_BindBuffer
*cmd
)
274 const GLenum target
= cmd
->target
;
275 const GLuint buffer
= cmd
->buffer
;
276 CALL_BindBuffer(ctx
->CurrentServerDispatch
, (target
, buffer
));
279 _mesa_marshal_BindBuffer(GLenum target
, GLuint buffer
)
281 GET_CURRENT_CONTEXT(ctx
);
282 size_t cmd_size
= sizeof(struct marshal_cmd_BindBuffer
);
283 struct marshal_cmd_BindBuffer
*cmd
;
284 debug_print_marshal("BindBuffer");
286 track_vbo_binding(ctx
, target
, buffer
);
288 if (cmd_size
<= MARSHAL_MAX_CMD_SIZE
) {
289 cmd
= _mesa_glthread_allocate_command(ctx
, DISPATCH_CMD_BindBuffer
,
291 cmd
->target
= target
;
292 cmd
->buffer
= buffer
;
293 _mesa_post_marshal_hook(ctx
);
295 _mesa_glthread_finish(ctx
);
296 CALL_BindBuffer(ctx
->CurrentServerDispatch
, (target
, buffer
));
300 /* BufferData: marshalled asynchronously */
301 struct marshal_cmd_BufferData
303 struct marshal_cmd_base cmd_base
;
307 bool data_null
; /* If set, no data follows for "data" */
308 /* Next size bytes are GLubyte data[size] */
312 _mesa_unmarshal_BufferData(struct gl_context
*ctx
,
313 const struct marshal_cmd_BufferData
*cmd
)
315 const GLenum target
= cmd
->target
;
316 const GLsizeiptr size
= cmd
->size
;
317 const GLenum usage
= cmd
->usage
;
323 data
= (const void *) (cmd
+ 1);
325 CALL_BufferData(ctx
->CurrentServerDispatch
, (target
, size
, data
, usage
));
329 _mesa_marshal_BufferData(GLenum target
, GLsizeiptr size
, const GLvoid
* data
,
332 GET_CURRENT_CONTEXT(ctx
);
334 sizeof(struct marshal_cmd_BufferData
) + (data
? size
: 0);
335 debug_print_marshal("BufferData");
337 if (unlikely(size
< 0)) {
338 _mesa_glthread_finish(ctx
);
339 _mesa_error(ctx
, GL_INVALID_VALUE
, "BufferData(size < 0)");
343 if (target
!= GL_EXTERNAL_VIRTUAL_MEMORY_BUFFER_AMD
&&
344 cmd_size
<= MARSHAL_MAX_CMD_SIZE
) {
345 struct marshal_cmd_BufferData
*cmd
=
346 _mesa_glthread_allocate_command(ctx
, DISPATCH_CMD_BufferData
,
349 cmd
->target
= target
;
352 cmd
->data_null
= !data
;
354 char *variable_data
= (char *) (cmd
+ 1);
355 memcpy(variable_data
, data
, size
);
357 _mesa_post_marshal_hook(ctx
);
359 _mesa_glthread_finish(ctx
);
360 CALL_BufferData(ctx
->CurrentServerDispatch
,
361 (target
, size
, data
, usage
));
365 /* BufferSubData: marshalled asynchronously */
366 struct marshal_cmd_BufferSubData
368 struct marshal_cmd_base cmd_base
;
372 /* Next size bytes are GLubyte data[size] */
376 _mesa_unmarshal_BufferSubData(struct gl_context
*ctx
,
377 const struct marshal_cmd_BufferSubData
*cmd
)
379 const GLenum target
= cmd
->target
;
380 const GLintptr offset
= cmd
->offset
;
381 const GLsizeiptr size
= cmd
->size
;
382 const void *data
= (const void *) (cmd
+ 1);
384 CALL_BufferSubData(ctx
->CurrentServerDispatch
,
385 (target
, offset
, size
, data
));
389 _mesa_marshal_BufferSubData(GLenum target
, GLintptr offset
, GLsizeiptr size
,
392 GET_CURRENT_CONTEXT(ctx
);
393 size_t cmd_size
= sizeof(struct marshal_cmd_BufferSubData
) + size
;
395 debug_print_marshal("BufferSubData");
396 if (unlikely(size
< 0)) {
397 _mesa_glthread_finish(ctx
);
398 _mesa_error(ctx
, GL_INVALID_VALUE
, "BufferSubData(size < 0)");
402 if (target
!= GL_EXTERNAL_VIRTUAL_MEMORY_BUFFER_AMD
&&
403 cmd_size
<= MARSHAL_MAX_CMD_SIZE
) {
404 struct marshal_cmd_BufferSubData
*cmd
=
405 _mesa_glthread_allocate_command(ctx
, DISPATCH_CMD_BufferSubData
,
407 cmd
->target
= target
;
408 cmd
->offset
= offset
;
410 char *variable_data
= (char *) (cmd
+ 1);
411 memcpy(variable_data
, data
, size
);
412 _mesa_post_marshal_hook(ctx
);
414 _mesa_glthread_finish(ctx
);
415 CALL_BufferSubData(ctx
->CurrentServerDispatch
,
416 (target
, offset
, size
, data
));
420 /* NamedBufferData: marshalled asynchronously */
421 struct marshal_cmd_NamedBufferData
423 struct marshal_cmd_base cmd_base
;
427 bool data_null
; /* If set, no data follows for "data" */
428 /* Next size bytes are GLubyte data[size] */
432 _mesa_unmarshal_NamedBufferData(struct gl_context
*ctx
,
433 const struct marshal_cmd_NamedBufferData
*cmd
)
435 const GLuint name
= cmd
->name
;
436 const GLsizei size
= cmd
->size
;
437 const GLenum usage
= cmd
->usage
;
443 data
= (const void *) (cmd
+ 1);
445 CALL_NamedBufferData(ctx
->CurrentServerDispatch
,
446 (name
, size
, data
, usage
));
450 _mesa_marshal_NamedBufferData(GLuint buffer
, GLsizeiptr size
,
451 const GLvoid
* data
, GLenum usage
)
453 GET_CURRENT_CONTEXT(ctx
);
454 size_t cmd_size
= sizeof(struct marshal_cmd_NamedBufferData
) + (data
? size
: 0);
456 debug_print_marshal("NamedBufferData");
457 if (unlikely(size
< 0)) {
458 _mesa_glthread_finish(ctx
);
459 _mesa_error(ctx
, GL_INVALID_VALUE
, "NamedBufferData(size < 0)");
463 if (buffer
> 0 && cmd_size
<= MARSHAL_MAX_CMD_SIZE
) {
464 struct marshal_cmd_NamedBufferData
*cmd
=
465 _mesa_glthread_allocate_command(ctx
, DISPATCH_CMD_NamedBufferData
,
470 cmd
->data_null
= !data
;
472 char *variable_data
= (char *) (cmd
+ 1);
473 memcpy(variable_data
, data
, size
);
475 _mesa_post_marshal_hook(ctx
);
477 _mesa_glthread_finish(ctx
);
478 CALL_NamedBufferData(ctx
->CurrentServerDispatch
,
479 (buffer
, size
, data
, usage
));
483 /* NamedBufferSubData: marshalled asynchronously */
484 struct marshal_cmd_NamedBufferSubData
486 struct marshal_cmd_base cmd_base
;
490 /* Next size bytes are GLubyte data[size] */
494 _mesa_unmarshal_NamedBufferSubData(struct gl_context
*ctx
,
495 const struct marshal_cmd_NamedBufferSubData
*cmd
)
497 const GLuint name
= cmd
->name
;
498 const GLintptr offset
= cmd
->offset
;
499 const GLsizei size
= cmd
->size
;
500 const void *data
= (const void *) (cmd
+ 1);
502 CALL_NamedBufferSubData(ctx
->CurrentServerDispatch
,
503 (name
, offset
, size
, data
));
507 _mesa_marshal_NamedBufferSubData(GLuint buffer
, GLintptr offset
,
508 GLsizeiptr size
, const GLvoid
* data
)
510 GET_CURRENT_CONTEXT(ctx
);
511 size_t cmd_size
= sizeof(struct marshal_cmd_NamedBufferSubData
) + size
;
513 debug_print_marshal("NamedBufferSubData");
514 if (unlikely(size
< 0)) {
515 _mesa_glthread_finish(ctx
);
516 _mesa_error(ctx
, GL_INVALID_VALUE
, "NamedBufferSubData(size < 0)");
520 if (buffer
> 0 && cmd_size
<= MARSHAL_MAX_CMD_SIZE
) {
521 struct marshal_cmd_NamedBufferSubData
*cmd
=
522 _mesa_glthread_allocate_command(ctx
, DISPATCH_CMD_NamedBufferSubData
,
525 cmd
->offset
= offset
;
527 char *variable_data
= (char *) (cmd
+ 1);
528 memcpy(variable_data
, data
, size
);
529 _mesa_post_marshal_hook(ctx
);
531 _mesa_glthread_finish(ctx
);
532 CALL_NamedBufferSubData(ctx
->CurrentServerDispatch
,
533 (buffer
, offset
, size
, data
));
537 /* ClearBuffer* (all variants): marshalled asynchronously */
538 struct marshal_cmd_ClearBuffer
540 struct marshal_cmd_base cmd_base
;
546 _mesa_unmarshal_ClearBufferfv(struct gl_context
*ctx
,
547 const struct marshal_cmd_ClearBuffer
*cmd
)
549 const GLenum buffer
= cmd
->buffer
;
550 const GLint drawbuffer
= cmd
->drawbuffer
;
551 const char *variable_data
= (const char *) (cmd
+ 1);
552 const GLfloat
*value
= (const GLfloat
*) variable_data
;
554 CALL_ClearBufferfv(ctx
->CurrentServerDispatch
,
555 (buffer
, drawbuffer
, value
));
559 _mesa_unmarshal_ClearBufferiv(struct gl_context
*ctx
,
560 const struct marshal_cmd_ClearBuffer
*cmd
)
562 const GLenum buffer
= cmd
->buffer
;
563 const GLint drawbuffer
= cmd
->drawbuffer
;
564 const char *variable_data
= (const char *) (cmd
+ 1);
565 const GLint
*value
= (const GLint
*) variable_data
;
567 CALL_ClearBufferiv(ctx
->CurrentServerDispatch
,
568 (buffer
, drawbuffer
, value
));
572 _mesa_unmarshal_ClearBufferuiv(struct gl_context
*ctx
,
573 const struct marshal_cmd_ClearBuffer
*cmd
)
575 const GLenum buffer
= cmd
->buffer
;
576 const GLint drawbuffer
= cmd
->drawbuffer
;
577 const char *variable_data
= (const char *) (cmd
+ 1);
578 const GLuint
*value
= (const GLuint
*) variable_data
;
580 CALL_ClearBufferuiv(ctx
->CurrentServerDispatch
,
581 (buffer
, drawbuffer
, value
));
585 _mesa_unmarshal_ClearBufferfi(struct gl_context
*ctx
,
586 const struct marshal_cmd_ClearBuffer
*cmd
)
588 const GLenum buffer
= cmd
->buffer
;
589 const GLint drawbuffer
= cmd
->drawbuffer
;
590 const char *variable_data
= (const char *) (cmd
+ 1);
591 const GLfloat
*depth
= (const GLfloat
*) variable_data
;
592 const GLint
*stencil
= (const GLint
*) (variable_data
+ 4);
594 CALL_ClearBufferfi(ctx
->CurrentServerDispatch
,
595 (buffer
, drawbuffer
, *depth
, *stencil
));
598 static inline size_t buffer_to_size(GLenum buffer
)
603 case GL_DEPTH_STENCIL
:
613 static inline bool clear_buffer_add_command(struct gl_context
*ctx
, uint16_t id
,
614 GLenum buffer
, GLint drawbuffer
,
615 const GLuint
*value
, size_t size
)
617 size_t cmd_size
= sizeof(struct marshal_cmd_ClearBuffer
) + 4 * size
;
618 if (cmd_size
<= MARSHAL_MAX_CMD_SIZE
) {
619 struct marshal_cmd_ClearBuffer
*cmd
=
620 _mesa_glthread_allocate_command(ctx
, id
,
622 cmd
->buffer
= buffer
;
623 cmd
->drawbuffer
= drawbuffer
;
624 GLuint
*variable_data
= (GLuint
*) (cmd
+ 1);
626 COPY_4V(variable_data
, value
);
628 COPY_2V(variable_data
, value
);
630 *variable_data
= *value
;
632 _mesa_post_marshal_hook(ctx
);
640 _mesa_marshal_ClearBufferfv(GLenum buffer
, GLint drawbuffer
,
641 const GLfloat
*value
)
643 GET_CURRENT_CONTEXT(ctx
);
644 debug_print_marshal("ClearBufferfv");
646 if (!(buffer
== GL_DEPTH
|| buffer
== GL_COLOR
)) {
647 _mesa_glthread_finish(ctx
);
649 /* Page 498 of the PDF, section '17.4.3.1 Clearing Individual Buffers'
650 * of the OpenGL 4.5 spec states:
652 * "An INVALID_ENUM error is generated by ClearBufferfv and
653 * ClearNamedFramebufferfv if buffer is not COLOR or DEPTH."
655 _mesa_error(ctx
, GL_INVALID_ENUM
, "glClearBufferfv(buffer=%s)",
656 _mesa_enum_to_string(buffer
));
659 size_t size
= buffer_to_size(buffer
);
660 if (!clear_buffer_add_command(ctx
, DISPATCH_CMD_ClearBufferfv
, buffer
,
661 drawbuffer
, (GLuint
*)value
, size
)) {
662 debug_print_sync("ClearBufferfv");
663 _mesa_glthread_finish(ctx
);
664 CALL_ClearBufferfv(ctx
->CurrentServerDispatch
,
665 (buffer
, drawbuffer
, value
));
670 _mesa_marshal_ClearBufferiv(GLenum buffer
, GLint drawbuffer
,
673 GET_CURRENT_CONTEXT(ctx
);
674 debug_print_marshal("ClearBufferiv");
676 if (!(buffer
== GL_STENCIL
|| buffer
== GL_COLOR
)) {
677 _mesa_glthread_finish(ctx
);
679 /* Page 498 of the PDF, section '17.4.3.1 Clearing Individual Buffers'
680 * of the OpenGL 4.5 spec states:
682 * "An INVALID_ENUM error is generated by ClearBufferiv and
683 * ClearNamedFramebufferiv if buffer is not COLOR or STENCIL."
685 _mesa_error(ctx
, GL_INVALID_ENUM
, "glClearBufferiv(buffer=%s)",
686 _mesa_enum_to_string(buffer
));
689 size_t size
= buffer_to_size(buffer
);
690 if (!clear_buffer_add_command(ctx
, DISPATCH_CMD_ClearBufferiv
, buffer
,
691 drawbuffer
, (GLuint
*)value
, size
)) {
692 debug_print_sync("ClearBufferiv");
693 _mesa_glthread_finish(ctx
);
694 CALL_ClearBufferiv(ctx
->CurrentServerDispatch
,
695 (buffer
, drawbuffer
, value
));
700 _mesa_marshal_ClearBufferuiv(GLenum buffer
, GLint drawbuffer
,
703 GET_CURRENT_CONTEXT(ctx
);
704 debug_print_marshal("ClearBufferuiv");
706 if (buffer
!= GL_COLOR
) {
707 _mesa_glthread_finish(ctx
);
709 /* Page 498 of the PDF, section '17.4.3.1 Clearing Individual Buffers'
710 * of the OpenGL 4.5 spec states:
712 * "An INVALID_ENUM error is generated by ClearBufferuiv and
713 * ClearNamedFramebufferuiv if buffer is not COLOR."
715 _mesa_error(ctx
, GL_INVALID_ENUM
, "glClearBufferuiv(buffer=%s)",
716 _mesa_enum_to_string(buffer
));
719 if (!clear_buffer_add_command(ctx
, DISPATCH_CMD_ClearBufferuiv
, buffer
,
720 drawbuffer
, (GLuint
*)value
, 4)) {
721 debug_print_sync("ClearBufferuiv");
722 _mesa_glthread_finish(ctx
);
723 CALL_ClearBufferuiv(ctx
->CurrentServerDispatch
,
724 (buffer
, drawbuffer
, value
));
729 _mesa_marshal_ClearBufferfi(GLenum buffer
, GLint drawbuffer
,
730 const GLfloat depth
, const GLint stencil
)
732 GET_CURRENT_CONTEXT(ctx
);
733 debug_print_marshal("ClearBufferfi");
735 if (buffer
!= GL_DEPTH_STENCIL
) {
736 _mesa_glthread_finish(ctx
);
738 /* Page 498 of the PDF, section '17.4.3.1 Clearing Individual Buffers'
739 * of the OpenGL 4.5 spec states:
741 * "An INVALID_ENUM error is generated by ClearBufferfi and
742 * ClearNamedFramebufferfi if buffer is not DEPTH_STENCIL."
744 _mesa_error(ctx
, GL_INVALID_ENUM
, "glClearBufferfi(buffer=%s)",
745 _mesa_enum_to_string(buffer
));
750 value
[1].i
= stencil
;
751 if (!clear_buffer_add_command(ctx
, DISPATCH_CMD_ClearBufferfi
, buffer
,
752 drawbuffer
, (GLuint
*)value
, 2)) {
753 debug_print_sync("ClearBufferfi");
754 _mesa_glthread_finish(ctx
);
755 CALL_ClearBufferfi(ctx
->CurrentServerDispatch
,
756 (buffer
, drawbuffer
, depth
, stencil
));