xref: /aosp_15_r20/external/mesa3d/src/gallium/auxiliary/draw/draw_pt.c (revision 6104692788411f58d303aa86923a9ff6ecaded22)
1 /**************************************************************************
2  *
3  * Copyright 2007 VMware, Inc.
4  * All Rights Reserved.
5  *
6  * Permission is hereby granted, free of charge, to any person obtaining a
7  * copy of this software and associated documentation files (the
8  * "Software"), to deal in the Software without restriction, including
9  * without limitation the rights to use, copy, modify, merge, publish,
10  * distribute, sub license, and/or sell copies of the Software, and to
11  * permit persons to whom the Software is furnished to do so, subject to
12  * the following conditions:
13  *
14  * The above copyright notice and this permission notice (including the
15  * next paragraph) shall be included in all copies or substantial portions
16  * of the Software.
17  *
18  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
19  * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
20  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
21  * IN NO EVENT SHALL VMWARE AND/OR ITS SUPPLIERS BE LIABLE FOR
22  * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
23  * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
24  * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
25  *
26  **************************************************************************/
27 
28  /*
29   * Authors:
30   *   Keith Whitwell <[email protected]>
31   */
32 
33 #include "draw/draw_context.h"
34 #include "draw/draw_gs.h"
35 #include "draw/draw_tess.h"
36 #include "draw/draw_private.h"
37 #include "draw/draw_pt.h"
38 #include "draw/draw_vbuf.h"
39 #include "draw/draw_vs.h"
40 #include "tgsi/tgsi_dump.h"
41 #include "util/u_math.h"
42 #include "util/u_prim.h"
43 #include "util/format/u_format.h"
44 #include "util/u_draw.h"
45 
46 
47 DEBUG_GET_ONCE_BOOL_OPTION(draw_fse, "DRAW_FSE", false)
48 DEBUG_GET_ONCE_BOOL_OPTION(draw_no_fse, "DRAW_NO_FSE", false)
49 
50 
51 /* Overall we split things into:
52  *     - frontend -- prepare fetch_elts, draw_elts - eg vsplit
53  *     - middle   -- fetch, shade, cliptest, viewport
54  *     - pipeline -- the prim pipeline: clipping, wide lines, etc
55  *     - backend  -- the vbuf_render provided by the driver.
56  */
57 static bool
draw_pt_arrays(struct draw_context * draw,enum mesa_prim prim,bool index_bias_varies,const struct pipe_draw_start_count_bias * draw_info,unsigned num_draws)58 draw_pt_arrays(struct draw_context *draw,
59                enum mesa_prim prim,
60                bool index_bias_varies,
61                const struct pipe_draw_start_count_bias *draw_info,
62                unsigned num_draws)
63 {
64    enum mesa_prim out_prim = prim;
65 
66    if (draw->gs.geometry_shader)
67       out_prim = draw->gs.geometry_shader->output_primitive;
68    else if (draw->tes.tess_eval_shader)
69       out_prim = get_tes_output_prim(draw->tes.tess_eval_shader);
70 
71    unsigned opt = PT_SHADE;
72    if (!draw->render) {
73       opt |= PT_PIPELINE;
74    }
75 
76    if (draw_need_pipeline(draw, draw->rasterizer, out_prim)) {
77       opt |= PT_PIPELINE;
78    }
79 
80    if ((draw->clip_xy ||
81          draw->clip_z ||
82          draw->clip_user) && !draw->pt.test_fse) {
83       opt |= PT_CLIPTEST;
84    }
85 
86    struct draw_pt_middle_end *middle;
87    if (draw->pt.middle.llvm) {
88       middle = draw->pt.middle.llvm;
89    } else {
90       if (opt == PT_SHADE && !draw->pt.no_fse)
91          middle = draw->pt.middle.fetch_shade_emit;
92       else
93          middle = draw->pt.middle.general;
94    }
95 
96    struct draw_pt_front_end *frontend = draw->pt.frontend;
97    if (frontend) {
98       if (draw->pt.prim != prim || draw->pt.opt != opt) {
99          /* In certain conditions switching primitives requires us to flush
100           * and validate the different stages. One example is when smooth
101           * lines are active but first drawn with triangles and then with
102           * lines.
103           */
104          draw_do_flush(draw, DRAW_FLUSH_STATE_CHANGE);
105          frontend = NULL;
106       } else if (draw->pt.eltSize != draw->pt.user.eltSize || draw->pt.viewid != draw->pt.user.viewid) {
107          /* Flush draw state if eltSize or viewid changed.
108           * eltSize changes could be improved so only the frontend is flushed since it
109           * converts all indices to ushorts and the fetch part of the middle
110           * always prepares both linear and indexed.
111           */
112          frontend->flush(frontend, DRAW_FLUSH_STATE_CHANGE);
113          frontend = NULL;
114       }
115    }
116 
117    if (!frontend) {
118       frontend = draw->pt.front.vsplit;
119 
120       frontend->prepare(frontend, prim, middle, opt);
121 
122       draw->pt.frontend = frontend;
123       draw->pt.eltSize = draw->pt.user.eltSize;
124       draw->pt.viewid = draw->pt.user.viewid;
125       draw->pt.prim = prim;
126       draw->pt.opt = opt;
127    }
128 
129    if (draw->pt.rebind_parameters) {
130       /* update constants, viewport dims, clip planes, etc */
131       middle->bind_parameters(middle);
132       draw->pt.rebind_parameters = false;
133    }
134 
135    for (unsigned i = 0; i < num_draws; i++) {
136       /* Sanitize primitive length:
137        */
138       unsigned first, incr;
139 
140       if (prim == MESA_PRIM_PATCHES) {
141          first = draw->pt.vertices_per_patch;
142          incr = draw->pt.vertices_per_patch;
143       } else {
144          draw_pt_split_prim(prim, &first, &incr);
145       }
146 
147       unsigned count = draw_pt_trim_count(draw_info[i].count, first, incr);
148       if (draw->pt.user.eltSize) {
149          if (index_bias_varies) {
150             draw->pt.user.eltBias = draw_info[i].index_bias;
151          } else {
152             draw->pt.user.eltBias = draw_info[0].index_bias;
153          }
154       } else {
155          draw->pt.user.eltBias = 0;
156       }
157 
158       draw->start_index = draw_info[i].start;
159 
160       if (count >= first)
161          frontend->run(frontend, draw_info[i].start, count);
162 
163       if (num_draws > 1 && draw->pt.user.increment_draw_id)
164          draw->pt.user.drawid++;
165    }
166 
167    return true;
168 }
169 
170 
171 void
draw_pt_flush(struct draw_context * draw,unsigned flags)172 draw_pt_flush(struct draw_context *draw, unsigned flags)
173 {
174    assert(flags);
175 
176    if (draw->pt.frontend) {
177       draw->pt.frontend->flush(draw->pt.frontend, flags);
178 
179       /* don't prepare if we only are flushing the backend */
180       if (flags & DRAW_FLUSH_STATE_CHANGE)
181          draw->pt.frontend = NULL;
182    }
183 
184    if (flags & DRAW_FLUSH_PARAMETER_CHANGE) {
185       draw->pt.rebind_parameters = true;
186    }
187 }
188 
189 
190 bool
draw_pt_init(struct draw_context * draw)191 draw_pt_init(struct draw_context *draw)
192 {
193    draw->pt.test_fse = debug_get_option_draw_fse();
194    draw->pt.no_fse = debug_get_option_draw_no_fse();
195 
196    draw->pt.front.vsplit = draw_pt_vsplit(draw);
197    if (!draw->pt.front.vsplit)
198       return false;
199 
200    draw->pt.middle.fetch_shade_emit = draw_pt_middle_fse(draw);
201    if (!draw->pt.middle.fetch_shade_emit)
202       return false;
203 
204    draw->pt.middle.general = draw_pt_fetch_pipeline_or_emit(draw);
205    if (!draw->pt.middle.general)
206       return false;
207 
208 #if DRAW_LLVM_AVAILABLE
209    if (draw->llvm) {
210       draw->pt.middle.llvm = draw_pt_fetch_pipeline_or_emit_llvm(draw);
211       draw->pt.middle.mesh = draw_pt_mesh_pipeline_or_emit(draw);
212    }
213 #endif
214 
215    return true;
216 }
217 
218 
219 void
draw_pt_destroy(struct draw_context * draw)220 draw_pt_destroy(struct draw_context *draw)
221 {
222    if (draw->pt.middle.mesh) {
223       draw->pt.middle.mesh->destroy(draw->pt.middle.mesh);
224       draw->pt.middle.mesh = NULL;
225    }
226 
227    if (draw->pt.middle.llvm) {
228       draw->pt.middle.llvm->destroy(draw->pt.middle.llvm);
229       draw->pt.middle.llvm = NULL;
230    }
231 
232    if (draw->pt.middle.general) {
233       draw->pt.middle.general->destroy(draw->pt.middle.general);
234       draw->pt.middle.general = NULL;
235    }
236 
237    if (draw->pt.middle.fetch_shade_emit) {
238       draw->pt.middle.fetch_shade_emit->destroy(draw->pt.middle.fetch_shade_emit);
239       draw->pt.middle.fetch_shade_emit = NULL;
240    }
241 
242    if (draw->pt.front.vsplit) {
243       draw->pt.front.vsplit->destroy(draw->pt.front.vsplit);
244       draw->pt.front.vsplit = NULL;
245    }
246 }
247 
248 
249 /**
250  * Debug- print the first 'count' vertices.
251  */
252 static void
draw_print_arrays(struct draw_context * draw,enum mesa_prim prim,int start,unsigned count,int index_bias)253 draw_print_arrays(struct draw_context *draw, enum mesa_prim prim,
254                   int start, unsigned count, int index_bias)
255 {
256    debug_printf("Draw arrays(prim = %u, start = %u, count = %u)\n",
257                 prim, start, count);
258 
259    for (unsigned i = 0; i < count; i++) {
260       unsigned ii = 0;
261 
262       if (draw->pt.user.eltSize) {
263          /* indexed arrays */
264 
265          switch (draw->pt.user.eltSize) {
266          case 1:
267             {
268                const uint8_t *elem = (const uint8_t *) draw->pt.user.elts;
269                ii = elem[start + i];
270             }
271             break;
272          case 2:
273             {
274                const uint16_t *elem = (const uint16_t *) draw->pt.user.elts;
275                ii = elem[start + i];
276             }
277             break;
278          case 4:
279             {
280                const uint32_t *elem = (const uint32_t *) draw->pt.user.elts;
281                ii = elem[start + i];
282             }
283             break;
284          default:
285             assert(0);
286             return;
287          }
288          ii += index_bias;
289          debug_printf("Element[%u + %u] + %i -> Vertex %u:\n", start, i,
290                       index_bias, ii);
291       }
292       else {
293          /* non-indexed arrays */
294          ii = start + i;
295          debug_printf("Vertex %u:\n", ii);
296       }
297 
298       for (unsigned j = 0; j < draw->pt.nr_vertex_elements; j++) {
299          unsigned buf = draw->pt.vertex_element[j].vertex_buffer_index;
300          uint8_t *ptr = (uint8_t *) draw->pt.user.vbuffer[buf].map;
301 
302          if (draw->pt.vertex_element[j].instance_divisor) {
303             ii = draw->instance_id / draw->pt.vertex_element[j].instance_divisor;
304          }
305 
306          ptr += draw->pt.vertex_buffer[buf].buffer_offset;
307          ptr += draw->pt.vertex_element[j].src_stride * ii;
308          ptr += draw->pt.vertex_element[j].src_offset;
309 
310          debug_printf("  Attr %u: ", j);
311          switch (draw->pt.vertex_element[j].src_format) {
312          case PIPE_FORMAT_R32_FLOAT:
313             {
314                float *v = (float *) ptr;
315                debug_printf("R %f  @ %p\n", v[0], (void *) v);
316             }
317             break;
318          case PIPE_FORMAT_R32G32_FLOAT:
319             {
320                float *v = (float *) ptr;
321                debug_printf("RG %f %f  @ %p\n", v[0], v[1], (void *) v);
322             }
323             break;
324          case PIPE_FORMAT_R32G32B32_FLOAT:
325             {
326                float *v = (float *) ptr;
327                debug_printf("RGB %f %f %f  @ %p\n", v[0], v[1], v[2], (void *) v);
328             }
329             break;
330          case PIPE_FORMAT_R32G32B32A32_FLOAT:
331             {
332                float *v = (float *) ptr;
333                debug_printf("RGBA %f %f %f %f  @ %p\n", v[0], v[1], v[2], v[3],
334                             (void *) v);
335             }
336             break;
337          case PIPE_FORMAT_B8G8R8A8_UNORM:
338             {
339                uint8_t *u = (uint8_t *) ptr;
340                debug_printf("BGRA %d %d %d %d  @ %p\n", u[0], u[1], u[2], u[3],
341                             (void *) u);
342             }
343             break;
344          case PIPE_FORMAT_A8R8G8B8_UNORM:
345             {
346                uint8_t *u = (uint8_t *) ptr;
347                debug_printf("ARGB %d %d %d %d  @ %p\n", u[0], u[1], u[2], u[3],
348                             (void *) u);
349             }
350             break;
351          default:
352             debug_printf("other format %s (fix me)\n",
353                      util_format_name(draw->pt.vertex_element[j].src_format));
354          }
355       }
356    }
357 }
358 
359 
360 /** Helper code for below */
361 static inline void
prim_restart_loop(struct draw_context * draw,const struct pipe_draw_info * info,const struct pipe_draw_start_count_bias * draw_info,const void * elements)362 prim_restart_loop(struct draw_context *draw,
363                   const struct pipe_draw_info *info,
364                   const struct pipe_draw_start_count_bias *draw_info,
365                   const void *elements)
366 {
367    const unsigned elt_max = draw->pt.user.eltMax;
368    struct pipe_draw_start_count_bias cur = *draw_info;
369    cur.count = 0;
370 
371    for (unsigned j = 0; j < draw_info->count; j++) {
372       unsigned index = 0;
373       unsigned i = util_clamped_uadd(draw_info->start, j);
374       if (i < elt_max) {
375          switch (draw->pt.user.eltSize) {
376          case 1:
377             index = ((const uint8_t*)elements)[i];
378             break;
379          case 2:
380             index = ((const uint16_t*)elements)[i];
381             break;
382          case 4:
383             index = ((const uint32_t*)elements)[i];
384             break;
385          default:
386             assert(0 && "bad eltSize in draw_arrays()");
387          }
388       }
389 
390       if (index == info->restart_index) {
391          if (cur.count > 0) {
392             /* draw elts up to prev pos */
393             draw_pt_arrays(draw, info->mode, info->index_bias_varies, &cur, 1);
394          }
395          /* begin new prim at next elt */
396          cur.start = i + 1;
397          cur.count = 0;
398       }
399       else {
400          cur.count++;
401       }
402    }
403    if (cur.count > 0) {
404       draw_pt_arrays(draw, info->mode, info->index_bias_varies, &cur, 1);
405    }
406 }
407 
408 
409 /**
410  * For drawing prims with primitive restart enabled.
411  * Scan for restart indexes and draw the runs of elements/vertices between
412  * the restarts.
413  */
414 static void
draw_pt_arrays_restart(struct draw_context * draw,const struct pipe_draw_info * info,const struct pipe_draw_start_count_bias * draw_info,unsigned num_draws)415 draw_pt_arrays_restart(struct draw_context *draw,
416                        const struct pipe_draw_info *info,
417                        const struct pipe_draw_start_count_bias *draw_info,
418                        unsigned num_draws)
419 {
420    assert(info->primitive_restart);
421 
422    if (draw->pt.user.eltSize) {
423       /* indexed prims (draw_elements) */
424       for (unsigned i = 0; i < num_draws; i++)
425          prim_restart_loop(draw, info, &draw_info[i], draw->pt.user.elts);
426    } else {
427       /* Non-indexed prims (draw_arrays).
428        * Primitive restart should have been handled in gallium frontends.
429        */
430       draw_pt_arrays(draw, info->mode, info->index_bias_varies, draw_info, num_draws);
431    }
432 }
433 
434 
435 /**
436  * Resolve true values within pipe_draw_info.
437  * If we're rendering from transform feedback/stream output
438  * buffers both the count and max_index need to be computed
439  * from the attached stream output target.
440  */
441 static void
resolve_draw_info(const struct pipe_draw_info * raw_info,const struct pipe_draw_indirect_info * indirect,const struct pipe_draw_start_count_bias * raw_draw,struct pipe_draw_info * info,struct pipe_draw_start_count_bias * draw,struct pipe_vertex_buffer * vertex_buffer,struct pipe_vertex_element * vertex_element)442 resolve_draw_info(const struct pipe_draw_info *raw_info,
443                   const struct pipe_draw_indirect_info *indirect,
444                   const struct pipe_draw_start_count_bias *raw_draw,
445                   struct pipe_draw_info *info,
446                   struct pipe_draw_start_count_bias *draw,
447                   struct pipe_vertex_buffer *vertex_buffer,
448                   struct pipe_vertex_element *vertex_element)
449 {
450    *info = *raw_info;
451    *draw = *raw_draw;
452 
453    struct draw_so_target *target =
454       (struct draw_so_target *)indirect->count_from_stream_output;
455    assert(vertex_buffer != NULL);
456    draw->count = vertex_element->src_stride == 0 ? 0 :
457                     target->internal_offset / vertex_element->src_stride;
458 
459    /* Stream output draw can not be indexed */
460    assert(!info->index_size);
461    info->max_index = draw->count - 1;
462 }
463 
464 
465 /*
466  * Loop over all instances and execute draws for them.
467  */
468 static void
draw_instances(struct draw_context * draw,unsigned drawid_offset,const struct pipe_draw_info * info,const struct pipe_draw_start_count_bias * draws,unsigned num_draws)469 draw_instances(struct draw_context *draw,
470                unsigned drawid_offset,
471                const struct pipe_draw_info *info,
472                const struct pipe_draw_start_count_bias *draws,
473                unsigned num_draws)
474 {
475    draw->start_instance = info->start_instance;
476 
477    for (unsigned instance = 0; instance < info->instance_count; instance++) {
478       unsigned instance_idx = instance + info->start_instance;
479       draw->instance_id = instance;
480       /* check for overflow */
481       if (instance_idx < instance ||
482           instance_idx < draw->start_instance) {
483          /* if we overflown just set the instance id to the max */
484          draw->instance_id = 0xffffffff;
485       }
486 
487       draw->pt.user.drawid = drawid_offset;
488       draw_new_instance(draw);
489 
490       if (info->primitive_restart) {
491          draw_pt_arrays_restart(draw, info, draws, num_draws);
492       } else {
493          draw_pt_arrays(draw, info->mode, info->index_bias_varies,
494                         draws, num_draws);
495       }
496    }
497 }
498 
499 
500 /**
501  * Draw vertex arrays.
502  * This is the main entrypoint into the drawing module.  If drawing an indexed
503  * primitive, the draw_set_indexes() function should have already been called
504  * to specify the element/index buffer information.
505  */
506 void
draw_vbo(struct draw_context * draw,const struct pipe_draw_info * info,unsigned drawid_offset,const struct pipe_draw_indirect_info * indirect,const struct pipe_draw_start_count_bias * draws,unsigned num_draws,uint8_t patch_vertices)507 draw_vbo(struct draw_context *draw,
508          const struct pipe_draw_info *info,
509          unsigned drawid_offset,
510          const struct pipe_draw_indirect_info *indirect,
511          const struct pipe_draw_start_count_bias *draws,
512          unsigned num_draws,
513          uint8_t patch_vertices)
514 {
515    unsigned fpstate = util_fpstate_get();
516    struct pipe_draw_info resolved_info;
517    struct pipe_draw_start_count_bias resolved_draw;
518    const struct pipe_draw_info *use_info;
519    const struct pipe_draw_start_count_bias *use_draws;
520 
521    if (info->instance_count == 0)
522       return;
523 
524    /* Make sure that denorms are treated like zeros. This is
525     * the behavior required by D3D10. OpenGL doesn't care.
526     */
527    util_fpstate_set_denorms_to_zero(fpstate);
528 
529    if (indirect && indirect->count_from_stream_output) {
530       resolve_draw_info(info, indirect, &draws[0], &resolved_info,
531                         &resolved_draw, &(draw->pt.vertex_buffer[0]),
532                         &(draw->pt.vertex_element[0]));
533       use_info = &resolved_info;
534       use_draws = &resolved_draw;
535       num_draws = 1;
536    } else {
537       use_info = info;
538       use_draws = draws;
539    }
540 
541    if (info->index_size) {
542       assert(draw->pt.user.elts);
543       draw->pt.user.min_index = use_info->index_bounds_valid ? use_info->min_index : 0;
544       draw->pt.user.max_index = use_info->index_bounds_valid ? use_info->max_index : ~0;
545    } else {
546       draw->pt.user.min_index = 0;
547       draw->pt.user.max_index = ~0;
548    }
549    draw->pt.user.eltSize = use_info->index_size ? draw->pt.user.eltSizeIB : 0;
550    draw->pt.user.drawid = drawid_offset;
551    draw->pt.user.increment_draw_id = use_info->increment_draw_id;
552    draw->pt.user.viewid = 0;
553    draw->pt.vertices_per_patch = patch_vertices;
554 
555    if (0) {
556       for (unsigned i = 0; i < num_draws; i++)
557          debug_printf("draw_vbo(mode=%u start=%u count=%u):\n",
558                       use_info->mode, use_draws[i].start, use_draws[i].count);
559    }
560 
561    if (0)
562       tgsi_dump(draw->vs.vertex_shader->state.tokens, 0);
563 
564    if (0) {
565       debug_printf("Elements:\n");
566       for (unsigned i = 0; i < draw->pt.nr_vertex_elements; i++) {
567          debug_printf("  %u: src_offset=%u src_stride=%u inst_div=%u   vbuf=%u  format=%s\n",
568                       i,
569                       draw->pt.vertex_element[i].src_offset,
570                       draw->pt.vertex_element[i].src_stride,
571                       draw->pt.vertex_element[i].instance_divisor,
572                       draw->pt.vertex_element[i].vertex_buffer_index,
573                       util_format_name(draw->pt.vertex_element[i].src_format));
574       }
575       debug_printf("Buffers:\n");
576       for (unsigned i = 0; i < draw->pt.nr_vertex_buffers; i++) {
577          debug_printf("  %u: offset=%u size=%d ptr=%p\n",
578                       i,
579                       draw->pt.vertex_buffer[i].buffer_offset,
580                       (int) draw->pt.user.vbuffer[i].size,
581                       draw->pt.user.vbuffer[i].map);
582       }
583    }
584 
585    if (0) {
586       for (unsigned i = 0; i < num_draws; i++)
587          draw_print_arrays(draw, use_info->mode, use_draws[i].start,
588                            MIN2(use_draws[i].count, 20),
589                            use_info->index_bias_varies
590                            ? use_draws[i].index_bias
591                            : use_draws[0].index_bias);
592    }
593 
594    unsigned index_limit = util_draw_max_index(draw->pt.vertex_buffer,
595                                               draw->pt.vertex_element,
596                                               draw->pt.nr_vertex_elements,
597                                               use_info);
598 #if DRAW_LLVM_AVAILABLE
599    if (!draw->llvm)
600 #endif
601    {
602       if (index_limit == 0) {
603          /* one of the buffers is too small to do any valid drawing */
604          debug_warning("draw: VBO too small to draw anything\n");
605          util_fpstate_set(fpstate);
606          return;
607       }
608    }
609 
610    /* If we're collecting stats then make sure we start from scratch */
611    if (draw->collect_statistics) {
612       memset(&draw->statistics, 0, sizeof(draw->statistics));
613    }
614 
615    draw->pt.max_index = index_limit - 1;
616 
617    /*
618     * TODO: We could use draw->pt.max_index to further narrow
619     * the min_index/max_index hints given by gallium frontends.
620     */
621 
622    if (use_info->view_mask) {
623       u_foreach_bit(i, use_info->view_mask) {
624          draw->pt.user.viewid = i;
625          draw_instances(draw, drawid_offset, use_info, use_draws, num_draws);
626       }
627    } else {
628       draw_instances(draw, drawid_offset, use_info, use_draws, num_draws);
629    }
630 
631    /* If requested emit the pipeline statistics for this run */
632    if (draw->collect_statistics) {
633       draw->render->pipeline_statistics(draw->render, &draw->statistics);
634    }
635    util_fpstate_set(fpstate);
636 }
637 
638 /* to be called after a mesh shader is run */
639 void
draw_mesh(struct draw_context * draw,struct draw_vertex_info * vert_info,struct draw_prim_info * prim_info)640 draw_mesh(struct draw_context *draw,
641           struct draw_vertex_info *vert_info,
642           struct draw_prim_info *prim_info)
643 {
644    struct draw_pt_middle_end *middle = draw->pt.middle.mesh;
645 
646    draw->pt.user.eltSize = 0;
647    draw->pt.user.viewid = 0;
648    draw->pt.user.drawid = 0;
649    draw->pt.user.increment_draw_id = false;
650    draw->pt.vertices_per_patch = 0;
651 
652    middle->prepare(middle, 0, 0, NULL);
653 
654    draw_mesh_middle_end_run(middle, vert_info, prim_info);
655 }
656