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
32struct draw_context;
33#ifdef DRAW_LLVM_AVAILABLE
34
35#define NUM_PATCH_INPUTS 32
36#define NUM_TCS_INPUTS (PIPE_MAX_SHADER_INPUTS - NUM_PATCH_INPUTS)
37
38struct draw_tcs_inputs {
39  /* num vertices per prim */
40  float data[32][NUM_TCS_INPUTS][4];
41};
42
43struct draw_tcs_outputs {
44  /* num vertices per prim */
45  float data[32][PIPE_MAX_SHADER_INPUTS][4];
46};
47
48struct draw_tes_inputs {
49  /* num vertices per prim */
50  float data[32][PIPE_MAX_SHADER_INPUTS][4];
51};
52
53#endif
54
55struct draw_tess_ctrl_shader {
56   struct draw_context *draw;
57
58   struct pipe_shader_state state;
59   struct tgsi_shader_info info;
60
61   unsigned vector_length;
62   unsigned vertices_out;
63
64   unsigned input_vertex_stride;
65   const float (*input)[4];
66   const struct tgsi_shader_info *input_info;
67#ifdef DRAW_LLVM_AVAILABLE
68   struct draw_tcs_inputs *tcs_input;
69   struct draw_tcs_outputs *tcs_output;
70   struct draw_tcs_jit_context *jit_context;
71   struct draw_tcs_llvm_variant *current_variant;
72#endif
73};
74
75struct draw_tess_eval_shader {
76   struct draw_context *draw;
77   struct pipe_shader_state state;
78   struct tgsi_shader_info info;
79
80   enum pipe_prim_type prim_mode;
81   unsigned spacing;
82   unsigned vertex_order_cw;
83   unsigned point_mode;
84
85   unsigned position_output;
86   unsigned viewport_index_output;
87   unsigned clipvertex_output;
88   unsigned ccdistance_output[PIPE_MAX_CLIP_OR_CULL_DISTANCE_ELEMENT_COUNT];
89   unsigned vector_length;
90
91   unsigned input_vertex_stride;
92   const float (*input)[4];
93   const struct tgsi_shader_info *input_info;
94
95#ifdef DRAW_LLVM_AVAILABLE
96   struct draw_tes_inputs *tes_input;
97   struct draw_tes_jit_context *jit_context;
98   struct draw_tes_llvm_variant *current_variant;
99#endif
100};
101
102enum pipe_prim_type get_tes_output_prim(struct draw_tess_eval_shader *shader);
103
104int draw_tess_ctrl_shader_run(struct draw_tess_ctrl_shader *shader,
105                              const void *constants[PIPE_MAX_CONSTANT_BUFFERS],
106                              const unsigned constants_size[PIPE_MAX_CONSTANT_BUFFERS],
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
113int draw_tess_eval_shader_run(struct draw_tess_eval_shader *shader,
114                              const void *constants[PIPE_MAX_CONSTANT_BUFFERS],
115                              const unsigned constants_size[PIPE_MAX_CONSTANT_BUFFERS],
116                              unsigned num_input_vertices_per_patch,
117                              const struct draw_vertex_info *input_verts,
118                              const struct draw_prim_info *input_prim,
119                              const struct tgsi_shader_info *input_info,
120                              struct draw_vertex_info *output_verts,
121                              struct draw_prim_info *output_prims,
122                              ushort **elts_out);
123
124#ifdef DRAW_LLVM_AVAILABLE
125void draw_tcs_set_current_variant(struct draw_tess_ctrl_shader *shader,
126                                  struct draw_tcs_llvm_variant *variant);
127void draw_tes_set_current_variant(struct draw_tess_eval_shader *shader,
128                                  struct draw_tes_llvm_variant *variant);
129#endif
130
131#endif
132