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