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 41static void 42vs_llvm_prepare(struct draw_vertex_shader *shader, 43 struct draw_context *draw) 44{ 45 /*struct llvm_vertex_shader *evs = llvm_vertex_shader(shader);*/ 46} 47 48static void 49vs_llvm_run_linear( struct draw_vertex_shader *shader, 50 const float (*input)[4], 51 float (*output)[4], 52 const void *constants[PIPE_MAX_CONSTANT_BUFFERS], 53 const unsigned constants_size[PIPE_MAX_CONSTANT_BUFFERS], 54 unsigned count, 55 unsigned input_stride, 56 unsigned output_stride, 57 const unsigned *elts) 58{ 59 /* we should never get here since the entire pipeline is 60 * generated in draw_pt_fetch_shade_pipeline_llvm.c */ 61 debug_assert(0); 62} 63 64 65static void 66vs_llvm_delete( struct draw_vertex_shader *dvs ) 67{ 68 struct llvm_vertex_shader *shader = llvm_vertex_shader(dvs); 69 struct draw_llvm_variant_list_item *li; 70 71 li = first_elem(&shader->variants); 72 while(!at_end(&shader->variants, li)) { 73 struct draw_llvm_variant_list_item *next = next_elem(li); 74 draw_llvm_destroy_variant(li->base); 75 li = next; 76 } 77 78 assert(shader->variants_cached == 0); 79 FREE((void*) dvs->state.tokens); 80 FREE( dvs ); 81} 82 83 84struct draw_vertex_shader * 85draw_create_vs_llvm(struct draw_context *draw, 86 const struct pipe_shader_state *state) 87{ 88 struct llvm_vertex_shader *vs = CALLOC_STRUCT( llvm_vertex_shader ); 89 90 if (!vs) 91 return NULL; 92 93 /* we make a private copy of the tokens */ 94 vs->base.state.tokens = tgsi_dup_tokens(state->tokens); 95 if (!vs->base.state.tokens) { 96 FREE(vs); 97 return NULL; 98 } 99 100 tgsi_scan_shader(state->tokens, &vs->base.info); 101 102 vs->variant_key_size = 103 draw_llvm_variant_key_size( 104 vs->base.info.file_max[TGSI_FILE_INPUT]+1, 105 MAX2(vs->base.info.file_max[TGSI_FILE_SAMPLER]+1, 106 vs->base.info.file_max[TGSI_FILE_SAMPLER_VIEW]+1)); 107 108 vs->base.state.stream_output = state->stream_output; 109 vs->base.draw = draw; 110 vs->base.prepare = vs_llvm_prepare; 111 vs->base.run_linear = vs_llvm_run_linear; 112 vs->base.delete = vs_llvm_delete; 113 vs->base.create_variant = draw_vs_create_variant_generic; 114 115 make_empty_list(&vs->variants); 116 117 return &vs->base; 118} 119