"Fossies" - the Fresh Open Source Software Archive

Member "mesa-20.1.8/src/gallium/auxiliary/draw/draw_vs_llvm.c" (16 Sep 2020, 4329 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_vs_llvm.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 2010 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 #include "util/u_math.h"
   29 #include "util/u_memory.h"
   30 #include "pipe/p_shader_tokens.h"
   31 #include "pipe/p_screen.h"
   32 
   33 #include "draw_private.h"
   34 #include "draw_context.h"
   35 #include "draw_vs.h"
   36 #include "draw_llvm.h"
   37 
   38 #include "tgsi/tgsi_parse.h"
   39 #include "tgsi/tgsi_scan.h"
   40 #include "nir/nir_to_tgsi_info.h"
   41 #include "nir.h"
   42 
   43 static void
   44 vs_llvm_prepare(struct draw_vertex_shader *shader,
   45                 struct draw_context *draw)
   46 {
   47    /*struct llvm_vertex_shader *evs = llvm_vertex_shader(shader);*/
   48 }
   49 
   50 static void
   51 vs_llvm_run_linear( struct draw_vertex_shader *shader,
   52             const float (*input)[4],
   53             float (*output)[4],
   54                     const void *constants[PIPE_MAX_CONSTANT_BUFFERS],
   55                     const unsigned constants_size[PIPE_MAX_CONSTANT_BUFFERS],
   56             unsigned count,
   57             unsigned input_stride,
   58             unsigned output_stride,
   59             const unsigned *elts)
   60 {
   61    /* we should never get here since the entire pipeline is
   62     * generated in draw_pt_fetch_shade_pipeline_llvm.c */
   63    debug_assert(0);
   64 }
   65 
   66 
   67 static void
   68 vs_llvm_delete( struct draw_vertex_shader *dvs )
   69 {
   70    struct llvm_vertex_shader *shader = llvm_vertex_shader(dvs);
   71    struct draw_llvm_variant_list_item *li;
   72 
   73    li = first_elem(&shader->variants);
   74    while(!at_end(&shader->variants, li)) {
   75       struct draw_llvm_variant_list_item *next = next_elem(li);
   76       draw_llvm_destroy_variant(li->base);
   77       li = next;
   78    }
   79 
   80    assert(shader->variants_cached == 0);
   81    if (dvs->state.ir.nir)
   82       ralloc_free(dvs->state.ir.nir);
   83    FREE((void*) dvs->state.tokens);
   84    FREE( dvs );
   85 }
   86 
   87 
   88 struct draw_vertex_shader *
   89 draw_create_vs_llvm(struct draw_context *draw,
   90             const struct pipe_shader_state *state)
   91 {
   92    struct llvm_vertex_shader *vs = CALLOC_STRUCT( llvm_vertex_shader );
   93 
   94    if (!vs)
   95       return NULL;
   96 
   97    /* due to some bugs in the feedback state tracker we have to check
   98       for ir.nir & PIPE_SHADER_IR_NIR here. */
   99    if (state->ir.nir && state->type == PIPE_SHADER_IR_NIR) {
  100       vs->base.state.ir.nir = state->ir.nir;
  101       nir_tgsi_scan_shader(state->ir.nir, &vs->base.info, true);
  102    } else {
  103       /* we make a private copy of the tokens */
  104       vs->base.state.tokens = tgsi_dup_tokens(state->tokens);
  105       if (!vs->base.state.tokens) {
  106          FREE(vs);
  107          return NULL;
  108       }
  109 
  110       tgsi_scan_shader(state->tokens, &vs->base.info);
  111    }
  112 
  113    vs->variant_key_size = 
  114       draw_llvm_variant_key_size(
  115          vs->base.info.file_max[TGSI_FILE_INPUT]+1,
  116          MAX2(vs->base.info.file_max[TGSI_FILE_SAMPLER]+1,
  117               vs->base.info.file_max[TGSI_FILE_SAMPLER_VIEW]+1),
  118          vs->base.info.file_max[TGSI_FILE_IMAGE]+1);
  119 
  120    vs->base.state.type = state->type;
  121    vs->base.state.stream_output = state->stream_output;
  122    vs->base.draw = draw;
  123    vs->base.prepare = vs_llvm_prepare;
  124    vs->base.run_linear = vs_llvm_run_linear;
  125    vs->base.delete = vs_llvm_delete;
  126    vs->base.create_variant = draw_vs_create_variant_generic;
  127 
  128    make_empty_list(&vs->variants);
  129 
  130    return &vs->base;
  131 }