• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright © 2017 Intel Corporation
3  *
4  * Permission is hereby granted, free of charge, to any person obtaining a
5  * copy of this software and associated documentation files (the "Software"),
6  * to deal in the Software without restriction, including without limitation
7  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8  * and/or sell copies of the Software, and to permit persons to whom the
9  * Software is furnished to do so, subject to the following conditions:
10  *
11  * The above copyright notice and this permission notice (including the next
12  * paragraph) shall be included in all copies or substantial portions of the
13  * Software.
14  *
15  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
18  * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
20  * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
21  * IN THE SOFTWARE.
22  */
23 
24 #ifndef GL_NIR_LINKER_H
25 #define GL_NIR_LINKER_H
26 
27 #include <stdbool.h>
28 
29 #include "nir.h"
30 #include "util/glheader.h"
31 #include "main/menums.h"
32 
33 #ifdef __cplusplus
34 extern "C" {
35 #endif
36 
37 struct gl_constants;
38 struct gl_extensions;
39 struct gl_linked_shader;
40 struct gl_shader_program;
41 struct gl_program;
42 struct gl_transform_feedback_info;
43 struct xfb_decl;
44 struct nir_xfb_info;
45 
46 struct gl_nir_linker_options {
47    bool fill_parameters;
48 };
49 
50 #define nir_foreach_gl_uniform_variable(var, shader) \
51    nir_foreach_variable_with_modes(var, shader, nir_var_uniform | \
52                                                 nir_var_mem_ubo | \
53                                                 nir_var_mem_ssbo | \
54                                                 nir_var_image)
55 
56 void gl_nir_opts(nir_shader *nir);
57 
58 bool gl_nir_link_spirv(const struct gl_constants *consts,
59                        const struct gl_extensions *exts,
60                        struct gl_shader_program *prog,
61                        const struct gl_nir_linker_options *options);
62 
63 bool gl_nir_link_glsl(const struct gl_constants *consts,
64                       const struct gl_extensions *exts,
65                       gl_api api,
66                       struct gl_shader_program *prog);
67 
68 bool gl_nir_link_uniforms(const struct gl_constants *consts,
69                           struct gl_shader_program *prog,
70                           bool fill_parameters);
71 
72 bool gl_nir_link_varyings(const struct gl_constants *consts,
73                           const struct gl_extensions *exts,
74                           gl_api api, struct gl_shader_program *prog);
75 
76 struct nir_xfb_info *
77 gl_to_nir_xfb_info(struct gl_transform_feedback_info *info, void *mem_ctx);
78 
79 nir_variable * gl_nir_lower_xfb_varying(nir_shader *shader,
80                                         const char *old_var_name,
81                                         nir_variable *toplevel_var);
82 
83 void gl_nir_opt_dead_builtin_varyings(const struct gl_constants *consts,
84                                       gl_api api,
85                                       struct gl_shader_program *prog,
86                                       struct gl_linked_shader *producer,
87                                       struct gl_linked_shader *consumer,
88                                       unsigned num_tfeedback_decls,
89                                       struct xfb_decl *tfeedback_decls);
90 
91 void gl_nir_set_uniform_initializers(const struct gl_constants *consts,
92                                      struct gl_shader_program *prog);
93 
94 bool nir_add_packed_var_to_resource_list(const struct gl_constants *consts,
95                                          struct gl_shader_program *shProg,
96                                          struct set *resource_set,
97                                          nir_variable *var,
98                                          unsigned stage, GLenum type);
99 
100 void
101 init_program_resource_list(struct gl_shader_program *prog);
102 
103 void nir_build_program_resource_list(const struct gl_constants *consts,
104                                      struct gl_shader_program *prog,
105                                      bool rebuild_resourse_list);
106 
107 void gl_nir_link_assign_atomic_counter_resources(const struct gl_constants *consts,
108                                                  struct gl_shader_program *prog);
109 
110 void gl_nir_link_check_atomic_counter_resources(const struct gl_constants *consts,
111                                                 struct gl_shader_program *prog);
112 
113 void gl_nir_link_assign_xfb_resources(const struct gl_constants *consts,
114                                       struct gl_shader_program *prog);
115 
116 bool gl_nir_link_uniform_blocks(const struct gl_constants *consts,
117                                 struct gl_shader_program *prog);
118 
119 bool
120 gl_nir_can_add_pointsize_to_program(const struct gl_constants *consts,
121                                     struct gl_program *prog);
122 
123 bool
124 gl_nir_add_point_size(struct nir_shader *nir);
125 
126 bool lower_packed_varying_needs_lowering(nir_shader *shader, nir_variable *var,
127                                          bool xfb_enabled,
128                                          bool disable_xfb_packing,
129                                          bool disable_varying_packing);
130 
131 #ifdef __cplusplus
132 } /* extern "C" */
133 #endif
134 
135 #endif /* GL_NIR_LINKER_H */
136