17ec681f3Smrg/**************************************************************************
27ec681f3Smrg *
37ec681f3Smrg * Copyright 2020 Red Hat.
47ec681f3Smrg * All Rights Reserved.
57ec681f3Smrg *
67ec681f3Smrg * Permission is hereby granted, free of charge, to any person obtaining a
77ec681f3Smrg * copy of this software and associated documentation files (the "Software"),
87ec681f3Smrg * to deal in the Software without restriction, including without limitation
97ec681f3Smrg * the rights to use, copy, modify, merge, publish, distribute, sublicense,
107ec681f3Smrg * and/or sell copies of the Software, and to permit persons to whom the
117ec681f3Smrg * Software is furnished to do so, subject to the following conditions:
127ec681f3Smrg *
137ec681f3Smrg * The above copyright notice and this permission notice shall be included
147ec681f3Smrg * in all copies or substantial portions of the Software.
157ec681f3Smrg *
167ec681f3Smrg * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
177ec681f3Smrg * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
187ec681f3Smrg * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
197ec681f3Smrg * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
207ec681f3Smrg * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
217ec681f3Smrg * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
227ec681f3Smrg * SOFTWARE.
237ec681f3Smrg *
247ec681f3Smrg **************************************************************************/
257ec681f3Smrg
267ec681f3Smrg#ifndef DRAW_TESS_H
277ec681f3Smrg#define DRAW_TESS_H
287ec681f3Smrg
297ec681f3Smrg#include "draw_context.h"
307ec681f3Smrg#include "draw_private.h"
317ec681f3Smrg
327ec681f3Smrgstruct draw_context;
337ec681f3Smrg#ifdef DRAW_LLVM_AVAILABLE
347ec681f3Smrg
357ec681f3Smrg#define NUM_PATCH_INPUTS 32
367ec681f3Smrg#define NUM_TCS_INPUTS (PIPE_MAX_SHADER_INPUTS - NUM_PATCH_INPUTS)
377ec681f3Smrg
387ec681f3Smrgstruct draw_tcs_inputs {
397ec681f3Smrg  /* num vertices per prim */
407ec681f3Smrg  float data[32][NUM_TCS_INPUTS][4];
417ec681f3Smrg};
427ec681f3Smrg
437ec681f3Smrgstruct draw_tcs_outputs {
447ec681f3Smrg  /* num vertices per prim */
457ec681f3Smrg  float data[32][PIPE_MAX_SHADER_INPUTS][4];
467ec681f3Smrg};
477ec681f3Smrg
487ec681f3Smrgstruct draw_tes_inputs {
497ec681f3Smrg  /* num vertices per prim */
507ec681f3Smrg  float data[32][PIPE_MAX_SHADER_INPUTS][4];
517ec681f3Smrg};
527ec681f3Smrg
537ec681f3Smrg#endif
547ec681f3Smrg
557ec681f3Smrgstruct draw_tess_ctrl_shader {
567ec681f3Smrg   struct draw_context *draw;
577ec681f3Smrg
587ec681f3Smrg   struct pipe_shader_state state;
597ec681f3Smrg   struct tgsi_shader_info info;
607ec681f3Smrg
617ec681f3Smrg   unsigned vector_length;
627ec681f3Smrg   unsigned vertices_out;
637ec681f3Smrg
647ec681f3Smrg   unsigned input_vertex_stride;
657ec681f3Smrg   const float (*input)[4];
667ec681f3Smrg   const struct tgsi_shader_info *input_info;
677ec681f3Smrg#ifdef DRAW_LLVM_AVAILABLE
687ec681f3Smrg   struct draw_tcs_inputs *tcs_input;
697ec681f3Smrg   struct draw_tcs_outputs *tcs_output;
707ec681f3Smrg   struct draw_tcs_jit_context *jit_context;
717ec681f3Smrg   struct draw_tcs_llvm_variant *current_variant;
727ec681f3Smrg#endif
737ec681f3Smrg};
747ec681f3Smrg
757ec681f3Smrgstruct draw_tess_eval_shader {
767ec681f3Smrg   struct draw_context *draw;
777ec681f3Smrg   struct pipe_shader_state state;
787ec681f3Smrg   struct tgsi_shader_info info;
797ec681f3Smrg
807ec681f3Smrg   unsigned prim_mode;
817ec681f3Smrg   unsigned spacing;
827ec681f3Smrg   unsigned vertex_order_cw;
837ec681f3Smrg   unsigned point_mode;
847ec681f3Smrg
857ec681f3Smrg   unsigned position_output;
867ec681f3Smrg   unsigned viewport_index_output;
877ec681f3Smrg   unsigned clipvertex_output;
887ec681f3Smrg   unsigned ccdistance_output[PIPE_MAX_CLIP_OR_CULL_DISTANCE_ELEMENT_COUNT];
897ec681f3Smrg   unsigned vector_length;
907ec681f3Smrg
917ec681f3Smrg   unsigned input_vertex_stride;
927ec681f3Smrg   const float (*input)[4];
937ec681f3Smrg   const struct tgsi_shader_info *input_info;
947ec681f3Smrg
957ec681f3Smrg#ifdef DRAW_LLVM_AVAILABLE
967ec681f3Smrg   struct draw_tes_inputs *tes_input;
977ec681f3Smrg   struct draw_tes_jit_context *jit_context;
987ec681f3Smrg   struct draw_tes_llvm_variant *current_variant;
997ec681f3Smrg#endif
1007ec681f3Smrg};
1017ec681f3Smrg
1027ec681f3Smrgenum pipe_prim_type get_tes_output_prim(struct draw_tess_eval_shader *shader);
1037ec681f3Smrg
1047ec681f3Smrgint draw_tess_ctrl_shader_run(struct draw_tess_ctrl_shader *shader,
1057ec681f3Smrg                              const void *constants[PIPE_MAX_CONSTANT_BUFFERS],
1067ec681f3Smrg                              const unsigned constants_size[PIPE_MAX_CONSTANT_BUFFERS],
1077ec681f3Smrg                              const struct draw_vertex_info *input_verts,
1087ec681f3Smrg                              const struct draw_prim_info *input_prim,
1097ec681f3Smrg                              const struct tgsi_shader_info *input_info,
1107ec681f3Smrg                              struct draw_vertex_info *output_verts,
1117ec681f3Smrg                              struct draw_prim_info *output_prims );
1127ec681f3Smrg
1137ec681f3Smrgint draw_tess_eval_shader_run(struct draw_tess_eval_shader *shader,
1147ec681f3Smrg                              const void *constants[PIPE_MAX_CONSTANT_BUFFERS],
1157ec681f3Smrg                              const unsigned constants_size[PIPE_MAX_CONSTANT_BUFFERS],
1167ec681f3Smrg                              unsigned num_input_vertices_per_patch,
1177ec681f3Smrg                              const struct draw_vertex_info *input_verts,
1187ec681f3Smrg                              const struct draw_prim_info *input_prim,
1197ec681f3Smrg                              const struct tgsi_shader_info *input_info,
1207ec681f3Smrg                              struct draw_vertex_info *output_verts,
1217ec681f3Smrg                              struct draw_prim_info *output_prims,
1227ec681f3Smrg                              ushort **elts_out);
1237ec681f3Smrg
1247ec681f3Smrg#ifdef DRAW_LLVM_AVAILABLE
1257ec681f3Smrgvoid draw_tcs_set_current_variant(struct draw_tess_ctrl_shader *shader,
1267ec681f3Smrg                                  struct draw_tcs_llvm_variant *variant);
1277ec681f3Smrgvoid draw_tes_set_current_variant(struct draw_tess_eval_shader *shader,
1287ec681f3Smrg                                  struct draw_tes_llvm_variant *variant);
1297ec681f3Smrg#endif
1307ec681f3Smrg
1317ec681f3Smrg#endif
132