1 /************************************************************************** 2 * 3 * Copyright 2020 Red Hat. 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 "Software"), 8 * to deal in the Software without restriction, including without limitation 9 * the rights to use, copy, modify, merge, publish, distribute, sublicense, 10 * and/or sell copies of the Software, and to permit persons to whom the 11 * Software is furnished to do so, subject to the following conditions: 12 * 13 * The above copyright notice and this permission notice shall be included 14 * in all copies or substantial portions of the Software. 15 * 16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 17 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 19 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 * SOFTWARE. 23 * 24 **************************************************************************/ 25 26 #ifndef DRAW_TESS_H 27 #define DRAW_TESS_H 28 29 #include "draw_context.h" 30 #include "draw_private.h" 31 32 #include "tgsi/tgsi_scan.h" 33 34 struct draw_context; 35 #if DRAW_LLVM_AVAILABLE 36 37 #define NUM_PATCH_INPUTS 32 38 #define NUM_TCS_INPUTS (PIPE_MAX_SHADER_INPUTS - NUM_PATCH_INPUTS) 39 40 struct draw_tcs_inputs { 41 /* num vertices per prim */ 42 float data[32][NUM_TCS_INPUTS][4]; 43 }; 44 45 struct draw_tcs_outputs { 46 /* num vertices per prim */ 47 float data[32][PIPE_MAX_SHADER_INPUTS][4]; 48 }; 49 50 struct draw_tes_inputs { 51 /* num vertices per prim */ 52 float data[32][PIPE_MAX_SHADER_INPUTS][4]; 53 }; 54 55 #endif 56 57 struct draw_tess_ctrl_shader { 58 struct draw_context *draw; 59 60 struct pipe_shader_state state; 61 struct tgsi_shader_info info; 62 63 unsigned vector_length; 64 unsigned vertices_out; 65 66 unsigned input_vertex_stride; 67 const float (*input)[4]; 68 const struct tgsi_shader_info *input_info; 69 #if DRAW_LLVM_AVAILABLE 70 struct draw_tcs_inputs *tcs_input; 71 struct draw_tcs_outputs *tcs_output; 72 struct lp_jit_resources *jit_resources; 73 struct draw_tcs_llvm_variant *current_variant; 74 #endif 75 }; 76 77 struct draw_tess_eval_shader { 78 struct draw_context *draw; 79 struct pipe_shader_state state; 80 struct tgsi_shader_info info; 81 82 enum mesa_prim prim_mode; 83 unsigned spacing; 84 unsigned vertex_order_cw; 85 unsigned point_mode; 86 87 unsigned position_output; 88 unsigned viewport_index_output; 89 unsigned clipvertex_output; 90 unsigned ccdistance_output[PIPE_MAX_CLIP_OR_CULL_DISTANCE_ELEMENT_COUNT]; 91 unsigned vector_length; 92 93 unsigned input_vertex_stride; 94 const float (*input)[4]; 95 const struct tgsi_shader_info *input_info; 96 97 #if DRAW_LLVM_AVAILABLE 98 struct draw_tes_inputs *tes_input; 99 struct lp_jit_resources *jit_resources; 100 struct draw_tes_llvm_variant *current_variant; 101 #endif 102 }; 103 104 enum mesa_prim get_tes_output_prim(struct draw_tess_eval_shader *shader); 105 106 int draw_tess_ctrl_shader_run(struct draw_tess_ctrl_shader *shader, 107 const struct draw_vertex_info *input_verts, 108 const struct draw_prim_info *input_prim, 109 const struct tgsi_shader_info *input_info, 110 struct draw_vertex_info *output_verts, 111 struct draw_prim_info *output_prims ); 112 113 int draw_tess_eval_shader_run(struct draw_tess_eval_shader *shader, 114 unsigned num_input_vertices_per_patch, 115 const struct draw_vertex_info *input_verts, 116 const struct draw_prim_info *input_prim, 117 const struct tgsi_shader_info *input_info, 118 struct draw_vertex_info *output_verts, 119 struct draw_prim_info *output_prims, 120 uint16_t **elts_out); 121 122 #if DRAW_LLVM_AVAILABLE 123 void draw_tcs_set_current_variant(struct draw_tess_ctrl_shader *shader, 124 struct draw_tcs_llvm_variant *variant); 125 void draw_tes_set_current_variant(struct draw_tess_eval_shader *shader, 126 struct draw_tes_llvm_variant *variant); 127 #endif 128 129 #endif 130