• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 struct draw_context;
33 #ifdef LLVM_AVAILABLE
34 
35 #define NUM_PATCH_INPUTS 32
36 #define NUM_TCS_INPUTS (PIPE_MAX_SHADER_INPUTS - NUM_PATCH_INPUTS)
37 
38 struct draw_tcs_inputs {
39   /* num vertices per prim */
40   float data[32][NUM_TCS_INPUTS][4];
41 };
42 
43 struct draw_tcs_outputs {
44   /* num vertices per prim */
45   float data[32][PIPE_MAX_SHADER_INPUTS][4];
46 };
47 
48 struct draw_tes_inputs {
49   /* num vertices per prim */
50   float data[32][PIPE_MAX_SHADER_INPUTS][4];
51 };
52 
53 #endif
54 
55 struct 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 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 
75 struct draw_tess_eval_shader {
76    struct draw_context *draw;
77    struct pipe_shader_state state;
78    struct tgsi_shader_info info;
79 
80    unsigned 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 ccdistance_output[PIPE_MAX_CLIP_OR_CULL_DISTANCE_ELEMENT_COUNT];
88    unsigned vector_length;
89 
90    unsigned input_vertex_stride;
91    const float (*input)[4];
92    const struct tgsi_shader_info *input_info;
93 
94 #ifdef LLVM_AVAILABLE
95    struct draw_tes_inputs *tes_input;
96    struct draw_tes_jit_context *jit_context;
97    struct draw_tes_llvm_variant *current_variant;
98 #endif
99 };
100 
101 enum pipe_prim_type get_tes_output_prim(struct draw_tess_eval_shader *shader);
102 
103 int draw_tess_ctrl_shader_run(struct draw_tess_ctrl_shader *shader,
104                               const void *constants[PIPE_MAX_CONSTANT_BUFFERS],
105                               const unsigned constants_size[PIPE_MAX_CONSTANT_BUFFERS],
106                               const struct draw_vertex_info *input_verts,
107                               const struct draw_prim_info *input_prim,
108                               const struct tgsi_shader_info *input_info,
109                               struct draw_vertex_info *output_verts,
110                               struct draw_prim_info *output_prims );
111 
112 int draw_tess_eval_shader_run(struct draw_tess_eval_shader *shader,
113                               const void *constants[PIPE_MAX_CONSTANT_BUFFERS],
114                               const unsigned constants_size[PIPE_MAX_CONSTANT_BUFFERS],
115                               unsigned num_input_vertices_per_patch,
116                               const struct draw_vertex_info *input_verts,
117                               const struct draw_prim_info *input_prim,
118                               const struct tgsi_shader_info *input_info,
119                               struct draw_vertex_info *output_verts,
120                               struct draw_prim_info *output_prims,
121                               ushort **elts_out);
122 
123 #ifdef LLVM_AVAILABLE
124 void draw_tcs_set_current_variant(struct draw_tess_ctrl_shader *shader,
125                                   struct draw_tcs_llvm_variant *variant);
126 void draw_tes_set_current_variant(struct draw_tess_eval_shader *shader,
127                                   struct draw_tes_llvm_variant *variant);
128 #endif
129 
130 #endif
131