Details | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
5564 | serge | 1 | /* -*- c++ -*- */ |
2 | /* |
||
3 | * Copyright © 2010 Intel Corporation |
||
4 | * |
||
5 | * Permission is hereby granted, free of charge, to any person obtaining a |
||
6 | * copy of this software and associated documentation files (the "Software"), |
||
7 | * to deal in the Software without restriction, including without limitation |
||
8 | * the rights to use, copy, modify, merge, publish, distribute, sublicense, |
||
9 | * and/or sell copies of the Software, and to permit persons to whom the |
||
10 | * Software is furnished to do so, subject to the following conditions: |
||
11 | * |
||
12 | * The above copyright notice and this permission notice (including the next |
||
13 | * paragraph) shall be included in all copies or substantial portions of the |
||
14 | * Software. |
||
15 | * |
||
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
||
17 | * 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 |
||
21 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER |
||
22 | * DEALINGS IN THE SOFTWARE. |
||
23 | */ |
||
24 | |||
25 | #pragma once |
||
26 | #ifndef GLSL_LINKER_H |
||
27 | #define GLSL_LINKER_H |
||
28 | |||
29 | ir_function_signature * |
||
30 | link_get_main_function_signature(gl_shader *sh); |
||
31 | |||
32 | extern bool |
||
33 | link_function_calls(gl_shader_program *prog, gl_shader *main, |
||
34 | gl_shader **shader_list, unsigned num_shaders); |
||
35 | |||
36 | extern void |
||
37 | link_invalidate_variable_locations(exec_list *ir); |
||
38 | |||
39 | extern void |
||
40 | link_assign_uniform_locations(struct gl_shader_program *prog, |
||
41 | unsigned int boolean_true); |
||
42 | |||
43 | extern void |
||
44 | link_set_uniform_initializers(struct gl_shader_program *prog, |
||
45 | unsigned int boolean_true); |
||
46 | |||
47 | extern int |
||
48 | link_cross_validate_uniform_block(void *mem_ctx, |
||
49 | struct gl_uniform_block **linked_blocks, |
||
50 | unsigned int *num_linked_blocks, |
||
51 | struct gl_uniform_block *new_block); |
||
52 | |||
53 | extern bool |
||
54 | link_uniform_blocks_are_compatible(const gl_uniform_block *a, |
||
55 | const gl_uniform_block *b); |
||
56 | |||
57 | extern unsigned |
||
58 | link_uniform_blocks(void *mem_ctx, |
||
59 | struct gl_shader_program *prog, |
||
60 | struct gl_shader **shader_list, |
||
61 | unsigned num_shaders, |
||
62 | struct gl_uniform_block **blocks_ret); |
||
63 | |||
64 | bool |
||
65 | validate_intrastage_arrays(struct gl_shader_program *prog, |
||
66 | ir_variable *const var, |
||
67 | ir_variable *const existing); |
||
68 | |||
69 | void |
||
70 | validate_intrastage_interface_blocks(struct gl_shader_program *prog, |
||
71 | const gl_shader **shader_list, |
||
72 | unsigned num_shaders); |
||
73 | |||
74 | void |
||
75 | validate_interstage_inout_blocks(struct gl_shader_program *prog, |
||
76 | const gl_shader *producer, |
||
77 | const gl_shader *consumer); |
||
78 | |||
79 | void |
||
80 | validate_interstage_uniform_blocks(struct gl_shader_program *prog, |
||
81 | gl_shader **stages, int num_stages); |
||
82 | |||
83 | extern void |
||
84 | link_assign_atomic_counter_resources(struct gl_context *ctx, |
||
85 | struct gl_shader_program *prog); |
||
86 | |||
87 | extern void |
||
88 | link_check_atomic_counter_resources(struct gl_context *ctx, |
||
89 | struct gl_shader_program *prog); |
||
90 | |||
91 | /** |
||
92 | * Class for processing all of the leaf fields of a variable that corresponds |
||
93 | * to a program resource. |
||
94 | * |
||
95 | * The leaf fields are all the parts of the variable that the application |
||
96 | * could query using \c glGetProgramResourceIndex (or that could be returned |
||
97 | * by \c glGetProgramResourceName). |
||
98 | * |
||
99 | * Classes my derive from this class to implement specific functionality. |
||
100 | * This class only provides the mechanism to iterate over the leaves. Derived |
||
101 | * classes must implement \c ::visit_field and may override \c ::process. |
||
102 | */ |
||
103 | class program_resource_visitor { |
||
104 | public: |
||
105 | /** |
||
106 | * Begin processing a variable |
||
107 | * |
||
108 | * Classes that overload this function should call \c ::process from the |
||
109 | * base class to start the recursive processing of the variable. |
||
110 | * |
||
111 | * \param var The variable that is to be processed |
||
112 | * |
||
113 | * Calls \c ::visit_field for each leaf of the variable. |
||
114 | * |
||
115 | * \warning |
||
116 | * When processing a uniform block, this entry should only be used in cases |
||
117 | * where the row / column ordering of matrices in the block does not |
||
118 | * matter. For example, enumerating the names of members of the block, but |
||
119 | * not for determining the offsets of members. |
||
120 | */ |
||
121 | void process(ir_variable *var); |
||
122 | |||
123 | /** |
||
124 | * Begin processing a variable of a structured type. |
||
125 | * |
||
126 | * This flavor of \c process should be used to handle structured types |
||
127 | * (i.e., structures, interfaces, or arrays there of) that need special |
||
128 | * name handling. A common usage is to handle cases where the block name |
||
129 | * (instead of the instance name) is used for an interface block. |
||
130 | * |
||
131 | * \param type Type that is to be processed, associated with \c name |
||
132 | * \param name Base name of the structured variable being processed |
||
133 | * |
||
134 | * \note |
||
135 | * \c type must be \c GLSL_TYPE_RECORD, \c GLSL_TYPE_INTERFACE, or an array |
||
136 | * there of. |
||
137 | */ |
||
138 | void process(const glsl_type *type, const char *name); |
||
139 | |||
140 | protected: |
||
141 | /** |
||
142 | * Method invoked for each leaf of the variable |
||
143 | * |
||
144 | * \param type Type of the field. |
||
145 | * \param name Fully qualified name of the field. |
||
146 | * \param row_major For a matrix type, is it stored row-major. |
||
147 | * \param record_type Type of the record containing the field. |
||
148 | * \param last_field Set if \c name is the last field of the structure |
||
149 | * containing it. This will always be false for items |
||
150 | * not contained in a structure or interface block. |
||
151 | * |
||
152 | * The default implementation just calls the other \c visit_field method. |
||
153 | */ |
||
154 | virtual void visit_field(const glsl_type *type, const char *name, |
||
155 | bool row_major, const glsl_type *record_type, |
||
156 | bool last_field); |
||
157 | |||
158 | /** |
||
159 | * Method invoked for each leaf of the variable |
||
160 | * |
||
161 | * \param type Type of the field. |
||
162 | * \param name Fully qualified name of the field. |
||
163 | * \param row_major For a matrix type, is it stored row-major. |
||
164 | */ |
||
165 | virtual void visit_field(const glsl_type *type, const char *name, |
||
166 | bool row_major) = 0; |
||
167 | |||
168 | /** |
||
169 | * Visit a record before visiting its fields |
||
170 | * |
||
171 | * For structures-of-structures or interfaces-of-structures, this visits |
||
172 | * the inner structure before visiting its fields. |
||
173 | * |
||
174 | * The default implementation does nothing. |
||
175 | */ |
||
176 | virtual void visit_field(const glsl_struct_field *field); |
||
177 | |||
178 | virtual void enter_record(const glsl_type *type, const char *name, |
||
179 | bool row_major); |
||
180 | |||
181 | virtual void leave_record(const glsl_type *type, const char *name, |
||
182 | bool row_major); |
||
183 | |||
184 | private: |
||
185 | /** |
||
186 | * \param name_length Length of the current name \b not including the |
||
187 | * terminating \c NUL character. |
||
188 | * \param last_field Set if \c name is the last field of the structure |
||
189 | * containing it. This will always be false for items |
||
190 | * not contained in a structure or interface block. |
||
191 | */ |
||
192 | void recursion(const glsl_type *t, char **name, size_t name_length, |
||
193 | bool row_major, const glsl_type *record_type, |
||
194 | bool last_field); |
||
195 | }; |
||
196 | |||
197 | void |
||
198 | linker_error(gl_shader_program *prog, const char *fmt, ...); |
||
199 | |||
200 | void |
||
201 | linker_warning(gl_shader_program *prog, const char *fmt, ...); |
||
202 | |||
203 | #endif /* GLSL_LINKER_H */ |