"Fossies" - the Fresh Open Source Software Archive

Member "mesa-20.1.8/src/gallium/auxiliary/draw/draw_context.c" (16 Sep 2020, 38422 Bytes) of package /linux/misc/mesa-20.1.8.tar.xz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) C and C++ source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file. For more information about "draw_context.c" see the Fossies "Dox" file reference documentation and the last Fossies "Diffs" side-by-side code changes report: 20.1.5_vs_20.2.0-rc1.

    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 <keithw@vmware.com>
   31   */
   32 
   33 
   34 #include "pipe/p_context.h"
   35 #include "util/u_memory.h"
   36 #include "util/u_math.h"
   37 #include "util/u_cpu_detect.h"
   38 #include "util/u_inlines.h"
   39 #include "util/u_helpers.h"
   40 #include "util/u_prim.h"
   41 #include "util/format/u_format.h"
   42 #include "draw_context.h"
   43 #include "draw_pipe.h"
   44 #include "draw_prim_assembler.h"
   45 #include "draw_vs.h"
   46 #include "draw_gs.h"
   47 #include "draw_tess.h"
   48 
   49 #ifdef LLVM_AVAILABLE
   50 #include "gallivm/lp_bld_init.h"
   51 #include "gallivm/lp_bld_limits.h"
   52 #include "draw_llvm.h"
   53 
   54 boolean
   55 draw_get_option_use_llvm(void)
   56 {
   57    return debug_get_bool_option("DRAW_USE_LLVM", TRUE);
   58 }
   59 #else
   60 boolean
   61 draw_get_option_use_llvm(void)
   62 {
   63    return FALSE;
   64 }
   65 #endif
   66 
   67 bool
   68 draw_has_llvm(void)
   69 {
   70 #ifdef LLVM_AVAILABLE
   71    return draw_get_option_use_llvm();
   72 #else
   73    return false;
   74 #endif
   75 }
   76 
   77 /**
   78  * Create new draw module context with gallivm state for LLVM JIT.
   79  */
   80 static struct draw_context *
   81 draw_create_context(struct pipe_context *pipe, void *context,
   82                     boolean try_llvm)
   83 {
   84    struct draw_context *draw = CALLOC_STRUCT( draw_context );
   85    if (!draw)
   86       goto err_out;
   87 
   88    /* we need correct cpu caps for disabling denorms in draw_vbo() */
   89    util_cpu_detect();
   90 
   91 #ifdef LLVM_AVAILABLE
   92    if (try_llvm && draw_get_option_use_llvm()) {
   93       draw->llvm = draw_llvm_create(draw, (LLVMContextRef)context);
   94    }
   95 #endif
   96 
   97    draw->pipe = pipe;
   98 
   99    if (!draw_init(draw))
  100       goto err_destroy;
  101 
  102    draw->ia = draw_prim_assembler_create(draw);
  103    if (!draw->ia)
  104       goto err_destroy;
  105 
  106    return draw;
  107 
  108 err_destroy:
  109    draw_destroy( draw );
  110 err_out:
  111    return NULL;
  112 }
  113 
  114 
  115 /**
  116  * Create new draw module context, with LLVM JIT.
  117  */
  118 struct draw_context *
  119 draw_create(struct pipe_context *pipe)
  120 {
  121    return draw_create_context(pipe, NULL, TRUE);
  122 }
  123 
  124 
  125 #ifdef LLVM_AVAILABLE
  126 struct draw_context *
  127 draw_create_with_llvm_context(struct pipe_context *pipe,
  128                               void *context)
  129 {
  130    return draw_create_context(pipe, context, TRUE);
  131 }
  132 #endif
  133 
  134 /**
  135  * Create a new draw context, without LLVM JIT.
  136  */
  137 struct draw_context *
  138 draw_create_no_llvm(struct pipe_context *pipe)
  139 {
  140    return draw_create_context(pipe, NULL, FALSE);
  141 }
  142 
  143 
  144 boolean draw_init(struct draw_context *draw)
  145 {
  146    /*
  147     * Note that several functions compute the clipmask of the predefined
  148     * formats with hardcoded formulas instead of using these. So modifications
  149     * here must be reflected there too.
  150     */
  151 
  152    ASSIGN_4V( draw->plane[0], -1,  0,  0, 1 );
  153    ASSIGN_4V( draw->plane[1],  1,  0,  0, 1 );
  154    ASSIGN_4V( draw->plane[2],  0, -1,  0, 1 );
  155    ASSIGN_4V( draw->plane[3],  0,  1,  0, 1 );
  156    ASSIGN_4V( draw->plane[4],  0,  0,  1, 1 ); /* yes these are correct */
  157    ASSIGN_4V( draw->plane[5],  0,  0, -1, 1 ); /* mesa's a bit wonky */
  158    draw->clip_xy = TRUE;
  159    draw->clip_z = TRUE;
  160 
  161    draw->pt.user.planes = (float (*) [DRAW_TOTAL_CLIP_PLANES][4]) &(draw->plane[0]);
  162    draw->pt.user.eltMax = ~0;
  163 
  164    if (!draw_pipeline_init( draw ))
  165       return FALSE;
  166 
  167    if (!draw_pt_init( draw ))
  168       return FALSE;
  169 
  170    if (!draw_vs_init( draw ))
  171       return FALSE;
  172 
  173    if (!draw_gs_init( draw ))
  174       return FALSE;
  175 
  176    draw->quads_always_flatshade_last = !draw->pipe->screen->get_param(
  177       draw->pipe->screen, PIPE_CAP_QUADS_FOLLOW_PROVOKING_VERTEX_CONVENTION);
  178 
  179    draw->floating_point_depth = false;
  180 
  181    return TRUE;
  182 }
  183 
  184 /*
  185  * Called whenever we're starting to draw a new instance.
  186  * Some internal structures don't want to have to reset internal
  187  * members on each invocation (because their state might have to persist
  188  * between multiple primitive restart rendering call) but might have to 
  189  * for each new instance. 
  190  * This is particularly the case for primitive id's in geometry shader.
  191  */
  192 void draw_new_instance(struct draw_context *draw)
  193 {
  194    draw_geometry_shader_new_instance(draw->gs.geometry_shader);
  195    draw_prim_assembler_new_instance(draw->ia);
  196 }
  197 
  198 
  199 void draw_destroy( struct draw_context *draw )
  200 {
  201    struct pipe_context *pipe;
  202    unsigned i, j;
  203 
  204    if (!draw)
  205       return;
  206 
  207    pipe = draw->pipe;
  208 
  209    /* free any rasterizer CSOs that we may have created.
  210     */
  211    for (i = 0; i < 2; i++) {
  212       for (j = 0; j < 2; j++) {
  213          if (draw->rasterizer_no_cull[i][j]) {
  214             pipe->delete_rasterizer_state(pipe, draw->rasterizer_no_cull[i][j]);
  215          }
  216       }
  217    }
  218 
  219    for (i = 0; i < draw->pt.nr_vertex_buffers; i++)
  220       pipe_vertex_buffer_unreference(&draw->pt.vertex_buffer[i]);
  221 
  222    /* Not so fast -- we're just borrowing this at the moment.
  223     * 
  224    if (draw->render)
  225       draw->render->destroy( draw->render );
  226    */
  227 
  228    draw_prim_assembler_destroy(draw->ia);
  229    draw_pipeline_destroy( draw );
  230    draw_pt_destroy( draw );
  231    draw_vs_destroy( draw );
  232    draw_gs_destroy( draw );
  233 #ifdef LLVM_AVAILABLE
  234    if (draw->llvm)
  235       draw_llvm_destroy( draw->llvm );
  236 #endif
  237 
  238    FREE( draw );
  239 }
  240 
  241 
  242 
  243 void draw_flush( struct draw_context *draw )
  244 {
  245    draw_do_flush( draw, DRAW_FLUSH_BACKEND );
  246 }
  247 
  248 
  249 /**
  250  * Specify the depth stencil format for the draw pipeline. This function
  251  * determines the Minimum Resolvable Depth factor for polygon offset.
  252  * This factor potentially depends on the number of Z buffer bits,
  253  * the rasterization algorithm and the arithmetic performed on Z
  254  * values between vertex shading and rasterization.
  255  */
  256 void draw_set_zs_format(struct draw_context *draw, enum pipe_format format)
  257 {
  258    const struct util_format_description *desc = util_format_description(format);
  259 
  260    draw->floating_point_depth =
  261       (util_get_depth_format_type(desc) == UTIL_FORMAT_TYPE_FLOAT);
  262 
  263    draw->mrd = util_get_depth_format_mrd(desc);
  264 }
  265 
  266 
  267 static bool
  268 draw_is_vs_window_space(struct draw_context *draw)
  269 {
  270    if (draw->vs.vertex_shader) {
  271       struct tgsi_shader_info *info = &draw->vs.vertex_shader->info;
  272 
  273       return info->properties[TGSI_PROPERTY_VS_WINDOW_SPACE_POSITION] != 0;
  274    }
  275    return false;
  276 }
  277 
  278 
  279 void
  280 draw_update_clip_flags(struct draw_context *draw)
  281 {
  282    bool window_space = draw_is_vs_window_space(draw);
  283 
  284    draw->clip_xy = !draw->driver.bypass_clip_xy && !window_space;
  285    draw->guard_band_xy = (!draw->driver.bypass_clip_xy &&
  286                           draw->driver.guard_band_xy);
  287    draw->clip_z = (!draw->driver.bypass_clip_z &&
  288                    draw->rasterizer && draw->rasterizer->depth_clip_near) &&
  289                   !window_space;
  290    draw->clip_user = draw->rasterizer &&
  291                      draw->rasterizer->clip_plane_enable != 0 &&
  292                      !window_space;
  293    draw->guard_band_points_xy = draw->guard_band_xy ||
  294                                 (draw->driver.bypass_clip_points &&
  295                                 (draw->rasterizer &&
  296                                  draw->rasterizer->point_tri_clip));
  297 }
  298 
  299 
  300 void
  301 draw_update_viewport_flags(struct draw_context *draw)
  302 {
  303    bool window_space = draw_is_vs_window_space(draw);
  304 
  305    draw->bypass_viewport = window_space || draw->identity_viewport;
  306 }
  307 
  308 
  309 /**
  310  * Register new primitive rasterization/rendering state.
  311  * This causes the drawing pipeline to be rebuilt.
  312  */
  313 void draw_set_rasterizer_state( struct draw_context *draw,
  314                                 const struct pipe_rasterizer_state *raster,
  315                                 void *rast_handle )
  316 {
  317    if (!draw->suspend_flushing) {
  318       draw_do_flush( draw, DRAW_FLUSH_STATE_CHANGE );
  319 
  320       draw->rasterizer = raster;
  321       draw->rast_handle = rast_handle;
  322       draw_update_clip_flags(draw);
  323    }
  324 }
  325 
  326 /* With a little more work, llvmpipe will be able to turn this off and
  327  * do its own x/y clipping.  
  328  *
  329  * Some hardware can turn off clipping altogether - in particular any
  330  * hardware with a TNL unit can do its own clipping, even if it is
  331  * relying on the draw module for some other reason.
  332  * Setting bypass_clip_points to achieve d3d-style point clipping (the driver
  333  * will need to do the "vp scissoring") _requires_ the driver to implement
  334  * wide points / point sprites itself (points will still be clipped if rasterizer
  335  * point_tri_clip isn't set). Only relevant if bypass_clip_xy isn't set.
  336  */
  337 void draw_set_driver_clipping( struct draw_context *draw,
  338                                boolean bypass_clip_xy,
  339                                boolean bypass_clip_z,
  340                                boolean guard_band_xy,
  341                                boolean bypass_clip_points)
  342 {
  343    draw_do_flush( draw, DRAW_FLUSH_STATE_CHANGE );
  344 
  345    draw->driver.bypass_clip_xy = bypass_clip_xy;
  346    draw->driver.bypass_clip_z = bypass_clip_z;
  347    draw->driver.guard_band_xy = guard_band_xy;
  348    draw->driver.bypass_clip_points = bypass_clip_points;
  349    draw_update_clip_flags(draw);
  350 }
  351 
  352 
  353 /** 
  354  * Plug in the primitive rendering/rasterization stage (which is the last
  355  * stage in the drawing pipeline).
  356  * This is provided by the device driver.
  357  */
  358 void draw_set_rasterize_stage( struct draw_context *draw,
  359                                struct draw_stage *stage )
  360 {
  361    draw_do_flush( draw, DRAW_FLUSH_STATE_CHANGE );
  362 
  363    draw->pipeline.rasterize = stage;
  364 }
  365 
  366 
  367 /**
  368  * Set the draw module's clipping state.
  369  */
  370 void draw_set_clip_state( struct draw_context *draw,
  371                           const struct pipe_clip_state *clip )
  372 {
  373    draw_do_flush(draw, DRAW_FLUSH_PARAMETER_CHANGE);
  374 
  375    memcpy(&draw->plane[6], clip->ucp, sizeof(clip->ucp));
  376 }
  377 
  378 
  379 /**
  380  * Set the draw module's viewport state.
  381  */
  382 void draw_set_viewport_states( struct draw_context *draw,
  383                                unsigned start_slot,
  384                                unsigned num_viewports,
  385                                const struct pipe_viewport_state *vps )
  386 {
  387    const struct pipe_viewport_state *viewport = vps;
  388    draw_do_flush(draw, DRAW_FLUSH_PARAMETER_CHANGE);
  389 
  390    debug_assert(start_slot < PIPE_MAX_VIEWPORTS);
  391    debug_assert((start_slot + num_viewports) <= PIPE_MAX_VIEWPORTS);
  392 
  393    memcpy(draw->viewports + start_slot, vps,
  394           sizeof(struct pipe_viewport_state) * num_viewports);
  395 
  396    draw->identity_viewport = (num_viewports == 1) &&
  397       (viewport->scale[0] == 1.0f &&
  398        viewport->scale[1] == 1.0f &&
  399        viewport->scale[2] == 1.0f &&
  400        viewport->translate[0] == 0.0f &&
  401        viewport->translate[1] == 0.0f &&
  402        viewport->translate[2] == 0.0f);
  403    draw_update_viewport_flags(draw);
  404 }
  405 
  406 
  407 
  408 void
  409 draw_set_vertex_buffers(struct draw_context *draw,
  410                         unsigned start_slot, unsigned count,
  411                         const struct pipe_vertex_buffer *buffers)
  412 {
  413    assert(start_slot + count <= PIPE_MAX_ATTRIBS);
  414 
  415    util_set_vertex_buffers_count(draw->pt.vertex_buffer,
  416                                  &draw->pt.nr_vertex_buffers,
  417                                  buffers, start_slot, count);
  418 }
  419 
  420 
  421 void
  422 draw_set_vertex_elements(struct draw_context *draw,
  423                          unsigned count,
  424                          const struct pipe_vertex_element *elements)
  425 {
  426    assert(count <= PIPE_MAX_ATTRIBS);
  427 
  428    /* We could improve this by only flushing the frontend and the fetch part
  429     * of the middle. This would avoid recalculating the emit keys.*/
  430    draw_do_flush( draw, DRAW_FLUSH_STATE_CHANGE );
  431 
  432    memcpy(draw->pt.vertex_element, elements, count * sizeof(elements[0]));
  433    draw->pt.nr_vertex_elements = count;
  434 }
  435 
  436 
  437 /**
  438  * Tell drawing context where to find mapped vertex buffers.
  439  */
  440 void
  441 draw_set_mapped_vertex_buffer(struct draw_context *draw,
  442                               unsigned attr, const void *buffer,
  443                               size_t size)
  444 {
  445    draw->pt.user.vbuffer[attr].map  = buffer;
  446    draw->pt.user.vbuffer[attr].size = size;
  447 }
  448 
  449 
  450 void
  451 draw_set_mapped_constant_buffer(struct draw_context *draw,
  452                                 enum pipe_shader_type shader_type,
  453                                 unsigned slot,
  454                                 const void *buffer,
  455                                 unsigned size )
  456 {
  457    debug_assert(shader_type == PIPE_SHADER_VERTEX ||
  458                 shader_type == PIPE_SHADER_GEOMETRY ||
  459                 shader_type == PIPE_SHADER_TESS_CTRL ||
  460                 shader_type == PIPE_SHADER_TESS_EVAL);
  461    debug_assert(slot < PIPE_MAX_CONSTANT_BUFFERS);
  462 
  463    draw_do_flush(draw, DRAW_FLUSH_PARAMETER_CHANGE);
  464 
  465    switch (shader_type) {
  466    case PIPE_SHADER_VERTEX:
  467       draw->pt.user.vs_constants[slot] = buffer;
  468       draw->pt.user.vs_constants_size[slot] = size;
  469       break;
  470    case PIPE_SHADER_GEOMETRY:
  471       draw->pt.user.gs_constants[slot] = buffer;
  472       draw->pt.user.gs_constants_size[slot] = size;
  473       break;
  474    case PIPE_SHADER_TESS_CTRL:
  475       draw->pt.user.tcs_constants[slot] = buffer;
  476       draw->pt.user.tcs_constants_size[slot] = size;
  477       break;
  478    case PIPE_SHADER_TESS_EVAL:
  479       draw->pt.user.tes_constants[slot] = buffer;
  480       draw->pt.user.tes_constants_size[slot] = size;
  481       break;
  482    default:
  483       assert(0 && "invalid shader type in draw_set_mapped_constant_buffer");
  484    }
  485 }
  486 
  487 void
  488 draw_set_mapped_shader_buffer(struct draw_context *draw,
  489                               enum pipe_shader_type shader_type,
  490                               unsigned slot,
  491                               const void *buffer,
  492                               unsigned size )
  493 {
  494    debug_assert(shader_type == PIPE_SHADER_VERTEX ||
  495                 shader_type == PIPE_SHADER_GEOMETRY ||
  496                 shader_type == PIPE_SHADER_TESS_CTRL ||
  497                 shader_type == PIPE_SHADER_TESS_EVAL);
  498    debug_assert(slot < PIPE_MAX_SHADER_BUFFERS);
  499 
  500    draw_do_flush(draw, DRAW_FLUSH_PARAMETER_CHANGE);
  501 
  502    switch (shader_type) {
  503    case PIPE_SHADER_VERTEX:
  504       draw->pt.user.vs_ssbos[slot] = buffer;
  505       draw->pt.user.vs_ssbos_size[slot] = size;
  506       break;
  507    case PIPE_SHADER_GEOMETRY:
  508       draw->pt.user.gs_ssbos[slot] = buffer;
  509       draw->pt.user.gs_ssbos_size[slot] = size;
  510       break;
  511    case PIPE_SHADER_TESS_CTRL:
  512       draw->pt.user.tcs_ssbos[slot] = buffer;
  513       draw->pt.user.tcs_ssbos_size[slot] = size;
  514       break;
  515    case PIPE_SHADER_TESS_EVAL:
  516       draw->pt.user.tes_ssbos[slot] = buffer;
  517       draw->pt.user.tes_ssbos_size[slot] = size;
  518       break;
  519    default:
  520       assert(0 && "invalid shader type in draw_set_mapped_shader_buffer");
  521    }
  522 }
  523 
  524 /**
  525  * Tells the draw module to draw points with triangles if their size
  526  * is greater than this threshold.
  527  */
  528 void
  529 draw_wide_point_threshold(struct draw_context *draw, float threshold)
  530 {
  531    draw_do_flush( draw, DRAW_FLUSH_STATE_CHANGE );
  532    draw->pipeline.wide_point_threshold = threshold;
  533 }
  534 
  535 
  536 /**
  537  * Should the draw module handle point->quad conversion for drawing sprites?
  538  */
  539 void
  540 draw_wide_point_sprites(struct draw_context *draw, boolean draw_sprite)
  541 {
  542    draw_do_flush( draw, DRAW_FLUSH_STATE_CHANGE );
  543    draw->pipeline.wide_point_sprites = draw_sprite;
  544 }
  545 
  546 
  547 /**
  548  * Tells the draw module to draw lines with triangles if their width
  549  * is greater than this threshold.
  550  */
  551 void
  552 draw_wide_line_threshold(struct draw_context *draw, float threshold)
  553 {
  554    draw_do_flush( draw, DRAW_FLUSH_STATE_CHANGE );
  555    draw->pipeline.wide_line_threshold = roundf(threshold);
  556 }
  557 
  558 
  559 /**
  560  * Tells the draw module whether or not to implement line stipple.
  561  */
  562 void
  563 draw_enable_line_stipple(struct draw_context *draw, boolean enable)
  564 {
  565    draw_do_flush( draw, DRAW_FLUSH_STATE_CHANGE );
  566    draw->pipeline.line_stipple = enable;
  567 }
  568 
  569 
  570 /**
  571  * Tells draw module whether to convert points to quads for sprite mode.
  572  */
  573 void
  574 draw_enable_point_sprites(struct draw_context *draw, boolean enable)
  575 {
  576    draw_do_flush( draw, DRAW_FLUSH_STATE_CHANGE );
  577    draw->pipeline.point_sprite = enable;
  578 }
  579 
  580 
  581 void
  582 draw_set_force_passthrough( struct draw_context *draw, boolean enable )
  583 {
  584    draw_do_flush( draw, DRAW_FLUSH_STATE_CHANGE );
  585    draw->force_passthrough = enable;
  586 }
  587 
  588 
  589 
  590 /**
  591  * Allocate an extra vertex/geometry shader vertex attribute, if it doesn't
  592  * exist already.
  593  *
  594  * This is used by some of the optional draw module stages such
  595  * as wide_point which may need to allocate additional generic/texcoord
  596  * attributes.
  597  */
  598 int
  599 draw_alloc_extra_vertex_attrib(struct draw_context *draw,
  600                                uint semantic_name, uint semantic_index)
  601 {
  602    int slot;
  603    uint num_outputs;
  604    uint n;
  605 
  606    slot = draw_find_shader_output(draw, semantic_name, semantic_index);
  607    if (slot >= 0) {
  608       return slot;
  609    }
  610 
  611    num_outputs = draw_current_shader_outputs(draw);
  612    n = draw->extra_shader_outputs.num;
  613 
  614    assert(n < ARRAY_SIZE(draw->extra_shader_outputs.semantic_name));
  615 
  616    draw->extra_shader_outputs.semantic_name[n] = semantic_name;
  617    draw->extra_shader_outputs.semantic_index[n] = semantic_index;
  618    draw->extra_shader_outputs.slot[n] = num_outputs + n;
  619    draw->extra_shader_outputs.num++;
  620 
  621    return draw->extra_shader_outputs.slot[n];
  622 }
  623 
  624 
  625 /**
  626  * Remove all extra vertex attributes that were allocated with
  627  * draw_alloc_extra_vertex_attrib().
  628  */
  629 void
  630 draw_remove_extra_vertex_attribs(struct draw_context *draw)
  631 {
  632    draw->extra_shader_outputs.num = 0;
  633 }
  634 
  635 
  636 /**
  637  * If a geometry shader is present, return its info, else the vertex shader's
  638  * info.
  639  */
  640 struct tgsi_shader_info *
  641 draw_get_shader_info(const struct draw_context *draw)
  642 {
  643 
  644    if (draw->gs.geometry_shader) {
  645       return &draw->gs.geometry_shader->info;
  646    } else if (draw->tes.tess_eval_shader) {
  647       return &draw->tes.tess_eval_shader->info;
  648    } else {
  649       return &draw->vs.vertex_shader->info;
  650    }
  651 }
  652 
  653 /**
  654  * Prepare outputs slots from the draw module
  655  *
  656  * Certain parts of the draw module can emit additional
  657  * outputs that can be quite useful to the backends, a good
  658  * example of it is the process of decomposing primitives
  659  * into wireframes (aka. lines) which normally would lose
  660  * the face-side information, but using this method we can
  661  * inject another shader output which passes the original
  662  * face side information to the backend.
  663  */
  664 void
  665 draw_prepare_shader_outputs(struct draw_context *draw)
  666 {
  667    draw_remove_extra_vertex_attribs(draw);
  668    draw_prim_assembler_prepare_outputs(draw->ia);
  669    draw_unfilled_prepare_outputs(draw, draw->pipeline.unfilled);
  670    if (draw->pipeline.aapoint)
  671       draw_aapoint_prepare_outputs(draw, draw->pipeline.aapoint);
  672    if (draw->pipeline.aaline)
  673       draw_aaline_prepare_outputs(draw, draw->pipeline.aaline);
  674 }
  675 
  676 /**
  677  * Ask the draw module for the location/slot of the given vertex attribute in
  678  * a post-transformed vertex.
  679  *
  680  * With this function, drivers that use the draw module should have no reason
  681  * to track the current vertex/geometry shader.
  682  *
  683  * Note that the draw module may sometimes generate vertices with extra
  684  * attributes (such as texcoords for AA lines).  The driver can call this
  685  * function to find those attributes.
  686  *
  687  * -1 is returned if the attribute is not found since this is
  688  * an undefined situation. Note, that zero is valid and can
  689  * be used by any of the attributes, because position is not
  690  * required to be attribute 0 or even at all present.
  691  */
  692 int
  693 draw_find_shader_output(const struct draw_context *draw,
  694                         uint semantic_name, uint semantic_index)
  695 {
  696    const struct tgsi_shader_info *info = draw_get_shader_info(draw);
  697    uint i;
  698 
  699    for (i = 0; i < info->num_outputs; i++) {
  700       if (info->output_semantic_name[i] == semantic_name &&
  701           info->output_semantic_index[i] == semantic_index)
  702          return i;
  703    }
  704 
  705    /* Search the extra vertex attributes */
  706    for (i = 0; i < draw->extra_shader_outputs.num; i++) {
  707       if (draw->extra_shader_outputs.semantic_name[i] == semantic_name &&
  708           draw->extra_shader_outputs.semantic_index[i] == semantic_index) {
  709          return draw->extra_shader_outputs.slot[i];
  710       }
  711    }
  712 
  713    return -1;
  714 }
  715 
  716 
  717 /**
  718  * Return total number of the shader outputs.  This function is similar to
  719  * draw_current_shader_outputs() but this function also counts any extra
  720  * vertex/geometry output attributes that may be filled in by some draw
  721  * stages (such as AA point, AA line).
  722  *
  723  * If geometry shader is present, its output will be returned,
  724  * if not vertex shader is used.
  725  */
  726 uint
  727 draw_num_shader_outputs(const struct draw_context *draw)
  728 {
  729    const struct tgsi_shader_info *info = draw_get_shader_info(draw);
  730    uint count;
  731 
  732    count = info->num_outputs;
  733    count += draw->extra_shader_outputs.num;
  734 
  735    return count;
  736 }
  737 
  738 
  739 /**
  740  * Return total number of the vertex shader outputs.  This function
  741  * also counts any extra vertex output attributes that may
  742  * be filled in by some draw stages (such as AA point, AA line,
  743  * front face).
  744  */
  745 uint
  746 draw_total_vs_outputs(const struct draw_context *draw)
  747 {
  748    const struct tgsi_shader_info *info = &draw->vs.vertex_shader->info;
  749 
  750    return info->num_outputs + draw->extra_shader_outputs.num;
  751 }
  752 
  753 /**
  754  * Return total number of the geometry shader outputs. This function
  755  * also counts any extra geometry output attributes that may
  756  * be filled in by some draw stages (such as AA point, AA line, front
  757  * face).
  758  */
  759 uint
  760 draw_total_gs_outputs(const struct draw_context *draw)
  761 {   
  762    const struct tgsi_shader_info *info;
  763 
  764    if (!draw->gs.geometry_shader)
  765       return 0;
  766 
  767    info = &draw->gs.geometry_shader->info;
  768 
  769    return info->num_outputs + draw->extra_shader_outputs.num;
  770 }
  771 
  772 /**
  773  * Return total number of the tess ctrl shader outputs.
  774  */
  775 uint
  776 draw_total_tcs_outputs(const struct draw_context *draw)
  777 {
  778    const struct tgsi_shader_info *info;
  779 
  780    if (!draw->tcs.tess_ctrl_shader)
  781       return 0;
  782 
  783    info = &draw->tcs.tess_ctrl_shader->info;
  784 
  785    return info->num_outputs;
  786 }
  787 
  788 /**
  789  * Return total number of the tess eval shader outputs.
  790  */
  791 uint
  792 draw_total_tes_outputs(const struct draw_context *draw)
  793 {
  794    const struct tgsi_shader_info *info;
  795 
  796    if (!draw->tes.tess_eval_shader)
  797       return 0;
  798 
  799    info = &draw->tes.tess_eval_shader->info;
  800 
  801    return info->num_outputs + draw->extra_shader_outputs.num;
  802 }
  803 
  804 /**
  805  * Provide TGSI sampler objects for vertex/geometry shaders that use
  806  * texture fetches.  This state only needs to be set once per context.
  807  * This might only be used by software drivers for the time being.
  808  */
  809 void
  810 draw_texture_sampler(struct draw_context *draw,
  811                      enum pipe_shader_type shader,
  812                      struct tgsi_sampler *sampler)
  813 {
  814    switch (shader) {
  815    case PIPE_SHADER_VERTEX:
  816       draw->vs.tgsi.sampler = sampler;
  817       break;
  818    case PIPE_SHADER_GEOMETRY:
  819       draw->gs.tgsi.sampler = sampler;
  820       break;
  821    case PIPE_SHADER_TESS_CTRL:
  822       draw->tcs.tgsi.sampler = sampler;
  823       break;
  824    case PIPE_SHADER_TESS_EVAL:
  825       draw->tes.tgsi.sampler = sampler;
  826       break;
  827    default:
  828       assert(0);
  829       break;
  830    }
  831 }
  832 
  833 /**
  834  * Provide TGSI image objects for vertex/geometry shaders that use
  835  * texture fetches.  This state only needs to be set once per context.
  836  * This might only be used by software drivers for the time being.
  837  */
  838 void
  839 draw_image(struct draw_context *draw,
  840            enum pipe_shader_type shader,
  841            struct tgsi_image *image)
  842 {
  843    switch (shader) {
  844    case PIPE_SHADER_VERTEX:
  845       draw->vs.tgsi.image = image;
  846       break;
  847    case PIPE_SHADER_GEOMETRY:
  848       draw->gs.tgsi.image = image;
  849       break;
  850    case PIPE_SHADER_TESS_CTRL:
  851       draw->tcs.tgsi.image = image;
  852       break;
  853    case PIPE_SHADER_TESS_EVAL:
  854       draw->tes.tgsi.image = image;
  855       break;
  856    default:
  857       assert(0);
  858       break;
  859    }
  860 }
  861 
  862 /**
  863  * Provide TGSI buffer objects for vertex/geometry shaders that use
  864  * load/store/atomic ops.  This state only needs to be set once per context.
  865  * This might only be used by software drivers for the time being.
  866  */
  867 void
  868 draw_buffer(struct draw_context *draw,
  869             enum pipe_shader_type shader,
  870             struct tgsi_buffer *buffer)
  871 {
  872    switch (shader) {
  873    case PIPE_SHADER_VERTEX:
  874       draw->vs.tgsi.buffer = buffer;
  875       break;
  876    case PIPE_SHADER_GEOMETRY:
  877       draw->gs.tgsi.buffer = buffer;
  878       break;
  879    case PIPE_SHADER_TESS_CTRL:
  880       draw->tcs.tgsi.buffer = buffer;
  881       break;
  882    case PIPE_SHADER_TESS_EVAL:
  883       draw->tes.tgsi.buffer = buffer;
  884       break;
  885    default:
  886       assert(0);
  887       break;
  888    }
  889 }
  890 
  891 
  892 void draw_set_render( struct draw_context *draw, 
  893               struct vbuf_render *render )
  894 {
  895    draw->render = render;
  896 }
  897 
  898 
  899 /**
  900  * Tell the draw module where vertex indexes/elements are located, and
  901  * their size (in bytes).
  902  */
  903 void
  904 draw_set_indexes(struct draw_context *draw,
  905                  const void *elements, unsigned elem_size,
  906                  unsigned elem_buffer_space)
  907 {
  908    assert(elem_size == 0 ||
  909           elem_size == 1 ||
  910           elem_size == 2 ||
  911           elem_size == 4);
  912    draw->pt.user.elts = elements;
  913    draw->pt.user.eltSizeIB = elem_size;
  914    if (elem_size)
  915       draw->pt.user.eltMax = elem_buffer_space / elem_size;
  916    else
  917       draw->pt.user.eltMax = 0;
  918 }
  919 
  920 
  921 /* Revamp me please:
  922  */
  923 void draw_do_flush( struct draw_context *draw, unsigned flags )
  924 {
  925    if (!draw->suspend_flushing)
  926    {
  927       assert(!draw->flushing); /* catch inadvertant recursion */
  928 
  929       draw->flushing = TRUE;
  930 
  931       draw_pipeline_flush( draw, flags );
  932 
  933       draw_pt_flush( draw, flags );
  934 
  935       draw->flushing = FALSE;
  936    }
  937 }
  938 
  939 
  940 /**
  941  * Return the number of output attributes produced by the geometry
  942  * shader, if present.  If no geometry shader, return the number of
  943  * outputs from the vertex shader.
  944  * \sa draw_num_shader_outputs
  945  */
  946 uint
  947 draw_current_shader_outputs(const struct draw_context *draw)
  948 {
  949    if (draw->gs.geometry_shader)
  950       return draw->gs.num_gs_outputs;
  951    return draw->vs.num_vs_outputs;
  952 }
  953 
  954 
  955 /**
  956  * Return the index of the shader output which will contain the
  957  * vertex position.
  958  */
  959 uint
  960 draw_current_shader_position_output(const struct draw_context *draw)
  961 {
  962    if (draw->gs.geometry_shader)
  963       return draw->gs.position_output;
  964    if (draw->tes.tess_eval_shader)
  965       return draw->tes.position_output;
  966    return draw->vs.position_output;
  967 }
  968 
  969 
  970 /**
  971  * Return the index of the shader output which will contain the
  972  * viewport index.
  973  */
  974 uint
  975 draw_current_shader_viewport_index_output(const struct draw_context *draw)
  976 {
  977    if (draw->gs.geometry_shader)
  978       return draw->gs.geometry_shader->viewport_index_output;
  979    else if (draw->tes.tess_eval_shader)
  980       return draw->tes.tess_eval_shader->viewport_index_output;
  981    return draw->vs.vertex_shader->viewport_index_output;
  982 }
  983 
  984 /**
  985  * Returns true if there's a geometry shader bound and the geometry
  986  * shader writes out a viewport index.
  987  */
  988 boolean
  989 draw_current_shader_uses_viewport_index(const struct draw_context *draw)
  990 {
  991    if (draw->gs.geometry_shader)
  992       return draw->gs.geometry_shader->info.writes_viewport_index;
  993    return draw->vs.vertex_shader->info.writes_viewport_index;
  994 }
  995 
  996 
  997 /**
  998  * Return the index of the shader output which will contain the
  999  * clip vertex position.
 1000  * Note we don't support clipvertex output in the gs. For clipping
 1001  * to work correctly hence we return ordinary position output instead.
 1002  */
 1003 uint
 1004 draw_current_shader_clipvertex_output(const struct draw_context *draw)
 1005 {
 1006    if (draw->gs.geometry_shader)
 1007       return draw->gs.position_output;
 1008    if (draw->tes.tess_eval_shader)
 1009       return draw->tes.position_output;
 1010    return draw->vs.clipvertex_output;
 1011 }
 1012 
 1013 uint
 1014 draw_current_shader_ccdistance_output(const struct draw_context *draw, int index)
 1015 {
 1016    debug_assert(index < PIPE_MAX_CLIP_OR_CULL_DISTANCE_ELEMENT_COUNT);
 1017    if (draw->gs.geometry_shader)
 1018       return draw->gs.geometry_shader->ccdistance_output[index];
 1019    if (draw->tes.tess_eval_shader)
 1020       return draw->tes.tess_eval_shader->ccdistance_output[index];
 1021    return draw->vs.ccdistance_output[index];
 1022 }
 1023 
 1024 
 1025 uint
 1026 draw_current_shader_num_written_clipdistances(const struct draw_context *draw)
 1027 {
 1028    if (draw->gs.geometry_shader)
 1029       return draw->gs.geometry_shader->info.num_written_clipdistance;
 1030    if (draw->tes.tess_eval_shader)
 1031       return draw->tes.tess_eval_shader->info.num_written_clipdistance;
 1032    return draw->vs.vertex_shader->info.num_written_clipdistance;
 1033 }
 1034 
 1035 uint
 1036 draw_current_shader_num_written_culldistances(const struct draw_context *draw)
 1037 {
 1038    if (draw->gs.geometry_shader)
 1039       return draw->gs.geometry_shader->info.num_written_culldistance;
 1040    if (draw->tes.tess_eval_shader)
 1041       return draw->tes.tess_eval_shader->info.num_written_culldistance;
 1042    return draw->vs.vertex_shader->info.num_written_culldistance;
 1043 }
 1044 
 1045 /**
 1046  * Return a pointer/handle for a driver/CSO rasterizer object which
 1047  * disabled culling, stippling, unfilled tris, etc.
 1048  * This is used by some pipeline stages (such as wide_point, aa_line
 1049  * and aa_point) which convert points/lines into triangles.  In those
 1050  * cases we don't want to accidentally cull the triangles.
 1051  *
 1052  * \param scissor  should the rasterizer state enable scissoring?
 1053  * \param flatshade  should the rasterizer state use flat shading?
 1054  * \return  rasterizer CSO handle
 1055  */
 1056 void *
 1057 draw_get_rasterizer_no_cull( struct draw_context *draw,
 1058                              boolean scissor,
 1059                              boolean flatshade )
 1060 {
 1061    if (!draw->rasterizer_no_cull[scissor][flatshade]) {
 1062       /* create now */
 1063       struct pipe_context *pipe = draw->pipe;
 1064       struct pipe_rasterizer_state rast;
 1065 
 1066       memset(&rast, 0, sizeof(rast));
 1067       rast.scissor = scissor;
 1068       rast.flatshade = flatshade;
 1069       rast.front_ccw = 1;
 1070       rast.half_pixel_center = draw->rasterizer->half_pixel_center;
 1071       rast.bottom_edge_rule = draw->rasterizer->bottom_edge_rule;
 1072       rast.clip_halfz = draw->rasterizer->clip_halfz;
 1073 
 1074       draw->rasterizer_no_cull[scissor][flatshade] =
 1075          pipe->create_rasterizer_state(pipe, &rast);
 1076    }
 1077    return draw->rasterizer_no_cull[scissor][flatshade];
 1078 }
 1079 
 1080 void
 1081 draw_set_mapped_so_targets(struct draw_context *draw,
 1082                            int num_targets,
 1083                            struct draw_so_target *targets[PIPE_MAX_SO_BUFFERS])
 1084 {
 1085    int i;
 1086 
 1087    draw_do_flush( draw, DRAW_FLUSH_STATE_CHANGE );
 1088 
 1089    for (i = 0; i < num_targets; i++)
 1090       draw->so.targets[i] = targets[i];
 1091    for (i = num_targets; i < PIPE_MAX_SO_BUFFERS; i++)
 1092       draw->so.targets[i] = NULL;
 1093 
 1094    draw->so.num_targets = num_targets;
 1095 }
 1096 
 1097 void
 1098 draw_set_sampler_views(struct draw_context *draw,
 1099                        enum pipe_shader_type shader_stage,
 1100                        struct pipe_sampler_view **views,
 1101                        unsigned num)
 1102 {
 1103    unsigned i;
 1104 
 1105    debug_assert(shader_stage < PIPE_SHADER_TYPES);
 1106    debug_assert(num <= PIPE_MAX_SHADER_SAMPLER_VIEWS);
 1107 
 1108    draw_do_flush( draw, DRAW_FLUSH_STATE_CHANGE );
 1109 
 1110    for (i = 0; i < num; ++i)
 1111       draw->sampler_views[shader_stage][i] = views[i];
 1112    for (i = num; i < draw->num_sampler_views[shader_stage]; ++i)
 1113       draw->sampler_views[shader_stage][i] = NULL;
 1114 
 1115    draw->num_sampler_views[shader_stage] = num;
 1116 }
 1117 
 1118 void
 1119 draw_set_samplers(struct draw_context *draw,
 1120                   enum pipe_shader_type shader_stage,
 1121                   struct pipe_sampler_state **samplers,
 1122                   unsigned num)
 1123 {
 1124    unsigned i;
 1125 
 1126    debug_assert(shader_stage < PIPE_SHADER_TYPES);
 1127    debug_assert(num <= PIPE_MAX_SAMPLERS);
 1128 
 1129    draw_do_flush( draw, DRAW_FLUSH_STATE_CHANGE );
 1130 
 1131    for (i = 0; i < num; ++i)
 1132       draw->samplers[shader_stage][i] = samplers[i];
 1133    for (i = num; i < PIPE_MAX_SAMPLERS; ++i)
 1134       draw->samplers[shader_stage][i] = NULL;
 1135 
 1136    draw->num_samplers[shader_stage] = num;
 1137 
 1138 #ifdef LLVM_AVAILABLE
 1139    if (draw->llvm)
 1140       draw_llvm_set_sampler_state(draw, shader_stage);
 1141 #endif
 1142 }
 1143 
 1144 void
 1145 draw_set_images(struct draw_context *draw,
 1146                 enum pipe_shader_type shader_stage,
 1147                 struct pipe_image_view *views,
 1148                 unsigned num)
 1149 {
 1150    unsigned i;
 1151 
 1152    debug_assert(shader_stage < PIPE_SHADER_TYPES);
 1153    debug_assert(num <= PIPE_MAX_SHADER_IMAGES);
 1154 
 1155    draw_do_flush( draw, DRAW_FLUSH_STATE_CHANGE );
 1156 
 1157    for (i = 0; i < num; ++i)
 1158       draw->images[shader_stage][i] = &views[i];
 1159    for (i = num; i < draw->num_sampler_views[shader_stage]; ++i)
 1160       draw->images[shader_stage][i] = NULL;
 1161 
 1162    draw->num_images[shader_stage] = num;
 1163 }
 1164 
 1165 void
 1166 draw_set_mapped_texture(struct draw_context *draw,
 1167                         enum pipe_shader_type shader_stage,
 1168                         unsigned sview_idx,
 1169                         uint32_t width, uint32_t height, uint32_t depth,
 1170                         uint32_t first_level, uint32_t last_level,
 1171                         const void *base_ptr,
 1172                         uint32_t row_stride[PIPE_MAX_TEXTURE_LEVELS],
 1173                         uint32_t img_stride[PIPE_MAX_TEXTURE_LEVELS],
 1174                         uint32_t mip_offsets[PIPE_MAX_TEXTURE_LEVELS])
 1175 {
 1176 #ifdef LLVM_AVAILABLE
 1177    if (draw->llvm)
 1178       draw_llvm_set_mapped_texture(draw,
 1179                                    shader_stage,
 1180                                    sview_idx,
 1181                                    width, height, depth, first_level,
 1182                                    last_level, base_ptr,
 1183                                    row_stride, img_stride, mip_offsets);
 1184 #endif
 1185 }
 1186 
 1187 void
 1188 draw_set_mapped_image(struct draw_context *draw,
 1189                       enum pipe_shader_type shader_stage,
 1190                       unsigned idx,
 1191                       uint32_t width, uint32_t height, uint32_t depth,
 1192                       const void *base_ptr,
 1193                       uint32_t row_stride,
 1194                       uint32_t img_stride)
 1195 {
 1196 #ifdef LLVM_AVAILABLE
 1197    if (draw->llvm)
 1198       draw_llvm_set_mapped_image(draw,
 1199                                  shader_stage,
 1200                                  idx,
 1201                                  width, height, depth,
 1202                                  base_ptr,
 1203                                  row_stride, img_stride);
 1204 #endif
 1205 }
 1206 
 1207 /**
 1208  * XXX: Results for PIPE_SHADER_CAP_MAX_TEXTURE_SAMPLERS because there are two
 1209  * different ways of setting textures, and drivers typically only support one.
 1210  */
 1211 int
 1212 draw_get_shader_param_no_llvm(enum pipe_shader_type shader,
 1213                               enum pipe_shader_cap param)
 1214 {
 1215    switch(shader) {
 1216    case PIPE_SHADER_VERTEX:
 1217    case PIPE_SHADER_GEOMETRY:
 1218       return tgsi_exec_get_shader_param(param);
 1219    default:
 1220       return 0;
 1221    }
 1222 }
 1223 
 1224 /**
 1225  * XXX: Results for PIPE_SHADER_CAP_MAX_TEXTURE_SAMPLERS because there are two
 1226  * different ways of setting textures, and drivers typically only support one.
 1227  * Drivers requesting a draw context explicitly without llvm must call
 1228  * draw_get_shader_param_no_llvm instead.
 1229  */
 1230 int
 1231 draw_get_shader_param(enum pipe_shader_type shader, enum pipe_shader_cap param)
 1232 {
 1233 
 1234 #ifdef LLVM_AVAILABLE
 1235    if (draw_get_option_use_llvm()) {
 1236       switch(shader) {
 1237       case PIPE_SHADER_VERTEX:
 1238       case PIPE_SHADER_GEOMETRY:
 1239       case PIPE_SHADER_TESS_CTRL:
 1240       case PIPE_SHADER_TESS_EVAL:
 1241          return gallivm_get_shader_param(param);
 1242       default:
 1243          return 0;
 1244       }
 1245    }
 1246 #endif
 1247 
 1248    return draw_get_shader_param_no_llvm(shader, param);
 1249 }
 1250 
 1251 /**
 1252  * Enables or disables collection of statistics.
 1253  *
 1254  * Draw module is capable of generating statistics for the vertex
 1255  * processing pipeline. Collection of that data isn't free and so
 1256  * it's disabled by default. The users of the module can enable
 1257  * (or disable) this functionality through this function.
 1258  * The actual data will be emitted through the VBUF interface,
 1259  * the 'pipeline_statistics' callback to be exact.
 1260  */
 1261 void
 1262 draw_collect_pipeline_statistics(struct draw_context *draw,
 1263                                  boolean enable)
 1264 {
 1265    draw->collect_statistics = enable;
 1266 }
 1267 
 1268 /**
 1269  * Enable/disable primitives generated gathering.
 1270  */
 1271 void draw_collect_primitives_generated(struct draw_context *draw,
 1272                                        bool enable)
 1273 {
 1274    draw->collect_primgen = enable;
 1275 }
 1276 
 1277 /**
 1278  * Computes clipper invocation statistics.
 1279  *
 1280  * Figures out how many primitives would have been
 1281  * sent to the clipper given the specified
 1282  * prim info data.
 1283  */
 1284 void
 1285 draw_stats_clipper_primitives(struct draw_context *draw,
 1286                               const struct draw_prim_info *prim_info)
 1287 {
 1288    if (draw->collect_statistics) {
 1289       unsigned i;
 1290       for (i = 0; i < prim_info->primitive_count; i++) {
 1291          draw->statistics.c_invocations +=
 1292             u_decomposed_prims_for_vertices(prim_info->prim,
 1293                                             prim_info->primitive_lengths[i]);
 1294       }
 1295    }
 1296 }
 1297 
 1298 
 1299 /**
 1300  * Returns true if the draw module will inject the frontface
 1301  * info into the outputs.
 1302  *
 1303  * Given the specified primitive and rasterizer state
 1304  * the function will figure out if the draw module
 1305  * will inject the front-face information into shader
 1306  * outputs. This is done to preserve the front-facing
 1307  * info when decomposing primitives into wireframes.
 1308  */
 1309 boolean
 1310 draw_will_inject_frontface(const struct draw_context *draw)
 1311 {
 1312    unsigned reduced_prim = u_reduced_prim(draw->pt.prim);
 1313    const struct pipe_rasterizer_state *rast = draw->rasterizer;
 1314 
 1315    if (reduced_prim != PIPE_PRIM_TRIANGLES) {
 1316       return FALSE;
 1317    }
 1318 
 1319    return (rast &&
 1320            (rast->fill_front != PIPE_POLYGON_MODE_FILL ||
 1321             rast->fill_back != PIPE_POLYGON_MODE_FILL));
 1322 }
 1323 
 1324 void
 1325 draw_set_tess_state(struct draw_context *draw,
 1326             const float default_outer_level[4],
 1327             const float default_inner_level[2])
 1328 {
 1329    for (unsigned i = 0; i < 4; i++)
 1330       draw->default_outer_tess_level[i] = default_outer_level[i];
 1331    for (unsigned i = 0; i < 2; i++)
 1332       draw->default_inner_tess_level[i] = default_inner_level[i];
 1333 }