Eric Anholt | c22c400 | 2010-03-26 18:20:30 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright © 2010 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 |
| 21 | * DEALINGS IN THE SOFTWARE. |
| 22 | */ |
| 23 | |
| 24 | #include <stdlib.h> |
Eric Anholt | d1e3195 | 2010-03-28 01:55:38 -0700 | [diff] [blame] | 25 | #include <math.h> |
Eric Anholt | c22c400 | 2010-03-26 18:20:30 -0700 | [diff] [blame] | 26 | #include "glsl_symbol_table.h" |
| 27 | #include "glsl_parser_extras.h" |
| 28 | #include "glsl_types.h" |
| 29 | #include "ir.h" |
| 30 | |
| 31 | static void |
Eric Anholt | 2eec73f | 2010-03-27 12:25:20 -0700 | [diff] [blame] | 32 | generate_unop(exec_list *instructions, |
| 33 | ir_variable **declarations, |
| 34 | const glsl_type *type, |
| 35 | enum ir_expression_operation op) |
Eric Anholt | c22c400 | 2010-03-26 18:20:30 -0700 | [diff] [blame] | 36 | { |
Eric Anholt | c22c400 | 2010-03-26 18:20:30 -0700 | [diff] [blame] | 37 | ir_dereference *const arg = new ir_dereference(declarations[0]); |
| 38 | ir_rvalue *result; |
| 39 | |
Eric Anholt | 2eec73f | 2010-03-27 12:25:20 -0700 | [diff] [blame] | 40 | result = new ir_expression(op, type, arg, NULL); |
Eric Anholt | c22c400 | 2010-03-26 18:20:30 -0700 | [diff] [blame] | 41 | |
Eric Anholt | 7e78e07 | 2010-04-07 13:34:15 -0700 | [diff] [blame^] | 42 | ir_instruction *inst = new ir_return(result); |
Eric Anholt | c22c400 | 2010-03-26 18:20:30 -0700 | [diff] [blame] | 43 | instructions->push_tail(inst); |
| 44 | } |
| 45 | |
Eric Anholt | 2eec73f | 2010-03-27 12:25:20 -0700 | [diff] [blame] | 46 | static void |
Eric Anholt | bfe380a | 2010-03-27 12:43:13 -0700 | [diff] [blame] | 47 | generate_binop(exec_list *instructions, |
| 48 | ir_variable **declarations, |
| 49 | const glsl_type *type, |
| 50 | enum ir_expression_operation op) |
| 51 | { |
Eric Anholt | bfe380a | 2010-03-27 12:43:13 -0700 | [diff] [blame] | 52 | ir_dereference *const arg1 = new ir_dereference(declarations[0]); |
| 53 | ir_dereference *const arg2 = new ir_dereference(declarations[1]); |
| 54 | ir_rvalue *result; |
| 55 | |
| 56 | result = new ir_expression(op, type, arg1, arg2); |
| 57 | |
Eric Anholt | 7e78e07 | 2010-04-07 13:34:15 -0700 | [diff] [blame^] | 58 | ir_instruction *inst = new ir_return(result); |
Eric Anholt | bfe380a | 2010-03-27 12:43:13 -0700 | [diff] [blame] | 59 | instructions->push_tail(inst); |
| 60 | } |
| 61 | |
| 62 | static void |
Eric Anholt | d1e3195 | 2010-03-28 01:55:38 -0700 | [diff] [blame] | 63 | generate_radians(exec_list *instructions, |
| 64 | ir_variable **declarations, |
| 65 | const glsl_type *type) |
| 66 | { |
Eric Anholt | d1e3195 | 2010-03-28 01:55:38 -0700 | [diff] [blame] | 67 | ir_dereference *const arg = new ir_dereference(declarations[0]); |
| 68 | ir_rvalue *result; |
| 69 | |
| 70 | result = new ir_expression(ir_binop_mul, type, |
| 71 | arg, |
| 72 | new ir_constant((float)(M_PI / 180.0))); |
| 73 | |
Eric Anholt | 7e78e07 | 2010-04-07 13:34:15 -0700 | [diff] [blame^] | 74 | ir_instruction *inst = new ir_return(result); |
Eric Anholt | d1e3195 | 2010-03-28 01:55:38 -0700 | [diff] [blame] | 75 | instructions->push_tail(inst); |
| 76 | } |
| 77 | |
| 78 | static void |
| 79 | generate_degrees(exec_list *instructions, |
| 80 | ir_variable **declarations, |
| 81 | const glsl_type *type) |
| 82 | { |
Eric Anholt | d1e3195 | 2010-03-28 01:55:38 -0700 | [diff] [blame] | 83 | ir_dereference *const arg = new ir_dereference(declarations[0]); |
| 84 | ir_rvalue *result; |
| 85 | |
| 86 | result = new ir_expression(ir_binop_mul, type, |
| 87 | arg, |
| 88 | new ir_constant((float)(180.0 / M_PI))); |
| 89 | |
Eric Anholt | 7e78e07 | 2010-04-07 13:34:15 -0700 | [diff] [blame^] | 90 | ir_instruction *inst = new ir_return(result); |
Eric Anholt | d1e3195 | 2010-03-28 01:55:38 -0700 | [diff] [blame] | 91 | instructions->push_tail(inst); |
| 92 | } |
| 93 | |
| 94 | static void |
Eric Anholt | 2eec73f | 2010-03-27 12:25:20 -0700 | [diff] [blame] | 95 | generate_exp(exec_list *instructions, |
| 96 | ir_variable **declarations, |
| 97 | const glsl_type *type) |
| 98 | { |
| 99 | generate_unop(instructions, declarations, type, ir_unop_exp); |
| 100 | } |
| 101 | |
| 102 | static void |
| 103 | generate_log(exec_list *instructions, |
| 104 | ir_variable **declarations, |
| 105 | const glsl_type *type) |
| 106 | { |
| 107 | generate_unop(instructions, declarations, type, ir_unop_log); |
| 108 | } |
| 109 | |
| 110 | static void |
Eric Anholt | 0166526 | 2010-03-27 13:56:35 -0700 | [diff] [blame] | 111 | generate_exp2(exec_list *instructions, |
| 112 | ir_variable **declarations, |
| 113 | const glsl_type *type) |
| 114 | { |
| 115 | generate_unop(instructions, declarations, type, ir_unop_exp2); |
| 116 | } |
| 117 | |
| 118 | static void |
| 119 | generate_log2(exec_list *instructions, |
| 120 | ir_variable **declarations, |
| 121 | const glsl_type *type) |
| 122 | { |
| 123 | generate_unop(instructions, declarations, type, ir_unop_log2); |
| 124 | } |
| 125 | |
| 126 | static void |
Eric Anholt | 2eec73f | 2010-03-27 12:25:20 -0700 | [diff] [blame] | 127 | generate_rsq(exec_list *instructions, |
| 128 | ir_variable **declarations, |
| 129 | const glsl_type *type) |
| 130 | { |
| 131 | generate_unop(instructions, declarations, type, ir_unop_rsq); |
| 132 | } |
| 133 | |
| 134 | static void |
Eric Anholt | 44d68fd | 2010-03-27 13:01:51 -0700 | [diff] [blame] | 135 | generate_sqrt(exec_list *instructions, |
| 136 | ir_variable **declarations, |
| 137 | const glsl_type *type) |
| 138 | { |
| 139 | generate_unop(instructions, declarations, type, ir_unop_sqrt); |
| 140 | } |
| 141 | |
| 142 | static void |
Eric Anholt | 2eec73f | 2010-03-27 12:25:20 -0700 | [diff] [blame] | 143 | generate_abs(exec_list *instructions, |
| 144 | ir_variable **declarations, |
| 145 | const glsl_type *type) |
| 146 | { |
| 147 | generate_unop(instructions, declarations, type, ir_unop_abs); |
| 148 | } |
| 149 | |
| 150 | static void |
| 151 | generate_ceil(exec_list *instructions, |
| 152 | ir_variable **declarations, |
| 153 | const glsl_type *type) |
| 154 | { |
| 155 | generate_unop(instructions, declarations, type, ir_unop_ceil); |
| 156 | } |
| 157 | |
| 158 | static void |
| 159 | generate_floor(exec_list *instructions, |
| 160 | ir_variable **declarations, |
| 161 | const glsl_type *type) |
| 162 | { |
| 163 | generate_unop(instructions, declarations, type, ir_unop_floor); |
| 164 | } |
| 165 | |
Eric Anholt | bfe380a | 2010-03-27 12:43:13 -0700 | [diff] [blame] | 166 | static void |
| 167 | generate_mod(exec_list *instructions, |
| 168 | ir_variable **declarations, |
| 169 | const glsl_type *type) |
| 170 | { |
| 171 | generate_binop(instructions, declarations, type, ir_binop_mod); |
| 172 | } |
| 173 | |
| 174 | static void |
| 175 | generate_min(exec_list *instructions, |
| 176 | ir_variable **declarations, |
| 177 | const glsl_type *type) |
| 178 | { |
| 179 | generate_binop(instructions, declarations, type, ir_binop_min); |
| 180 | } |
| 181 | |
| 182 | static void |
| 183 | generate_max(exec_list *instructions, |
| 184 | ir_variable **declarations, |
| 185 | const glsl_type *type) |
| 186 | { |
| 187 | generate_binop(instructions, declarations, type, ir_binop_max); |
| 188 | } |
| 189 | |
Eric Anholt | ddd2e83 | 2010-03-27 12:59:42 -0700 | [diff] [blame] | 190 | |
| 191 | static void |
| 192 | generate_pow(exec_list *instructions, |
| 193 | ir_variable **declarations, |
| 194 | const glsl_type *type) |
| 195 | { |
| 196 | generate_binop(instructions, declarations, type, ir_binop_pow); |
| 197 | } |
| 198 | |
Eric Anholt | c22c400 | 2010-03-26 18:20:30 -0700 | [diff] [blame] | 199 | void |
| 200 | generate_function_instance(ir_function *f, |
| 201 | const char *name, |
| 202 | exec_list *instructions, |
Eric Anholt | bfe380a | 2010-03-27 12:43:13 -0700 | [diff] [blame] | 203 | int n_args, |
Eric Anholt | c22c400 | 2010-03-26 18:20:30 -0700 | [diff] [blame] | 204 | void (*generate)(exec_list *instructions, |
| 205 | ir_variable **declarations, |
| 206 | const glsl_type *type), |
Eric Anholt | 53afc36 | 2010-03-27 13:55:04 -0700 | [diff] [blame] | 207 | const glsl_type *ret_type, |
Eric Anholt | c22c400 | 2010-03-26 18:20:30 -0700 | [diff] [blame] | 208 | const glsl_type *type) |
| 209 | { |
Eric Anholt | 7e78e07 | 2010-04-07 13:34:15 -0700 | [diff] [blame^] | 210 | ir_variable *declarations[16]; |
Eric Anholt | c22c400 | 2010-03-26 18:20:30 -0700 | [diff] [blame] | 211 | |
Eric Anholt | 7e78e07 | 2010-04-07 13:34:15 -0700 | [diff] [blame^] | 212 | ir_function_signature *const sig = new ir_function_signature(ret_type); |
Ian Romanick | 6a15d5b5 | 2010-03-31 16:37:10 -0700 | [diff] [blame] | 213 | f->add_signature(sig); |
Eric Anholt | c22c400 | 2010-03-26 18:20:30 -0700 | [diff] [blame] | 214 | |
Eric Anholt | 894ea97 | 2010-04-07 13:19:11 -0700 | [diff] [blame] | 215 | ir_label *const label = new ir_label(name, sig); |
Eric Anholt | c22c400 | 2010-03-26 18:20:30 -0700 | [diff] [blame] | 216 | instructions->push_tail(label); |
| 217 | sig->definition = label; |
Eric Anholt | bfe380a | 2010-03-27 12:43:13 -0700 | [diff] [blame] | 218 | static const char *arg_names[] = { |
| 219 | "arg0", |
| 220 | "arg1" |
| 221 | }; |
| 222 | int i; |
Eric Anholt | c22c400 | 2010-03-26 18:20:30 -0700 | [diff] [blame] | 223 | |
Eric Anholt | bfe380a | 2010-03-27 12:43:13 -0700 | [diff] [blame] | 224 | for (i = 0; i < n_args; i++) { |
| 225 | ir_variable *var = new ir_variable(type, arg_names[i]); |
Eric Anholt | c22c400 | 2010-03-26 18:20:30 -0700 | [diff] [blame] | 226 | |
Eric Anholt | 3cb4358 | 2010-03-28 00:36:06 -0700 | [diff] [blame] | 227 | var = new ir_variable(type, arg_names[i]); |
Eric Anholt | bfe380a | 2010-03-27 12:43:13 -0700 | [diff] [blame] | 228 | var->mode = ir_var_in; |
| 229 | sig->parameters.push_tail(var); |
Eric Anholt | c22c400 | 2010-03-26 18:20:30 -0700 | [diff] [blame] | 230 | |
Eric Anholt | bfe380a | 2010-03-27 12:43:13 -0700 | [diff] [blame] | 231 | var = new ir_variable(type, arg_names[i]); |
Eric Anholt | 3cb4358 | 2010-03-28 00:36:06 -0700 | [diff] [blame] | 232 | var->mode = ir_var_in; |
Eric Anholt | 894ea97 | 2010-04-07 13:19:11 -0700 | [diff] [blame] | 233 | sig->body.push_tail(var); |
Eric Anholt | bfe380a | 2010-03-27 12:43:13 -0700 | [diff] [blame] | 234 | declarations[i] = var; |
| 235 | } |
Eric Anholt | c22c400 | 2010-03-26 18:20:30 -0700 | [diff] [blame] | 236 | |
Eric Anholt | 894ea97 | 2010-04-07 13:19:11 -0700 | [diff] [blame] | 237 | generate(&sig->body, declarations, type); |
Eric Anholt | c22c400 | 2010-03-26 18:20:30 -0700 | [diff] [blame] | 238 | } |
| 239 | |
| 240 | void |
| 241 | make_gentype_function(glsl_symbol_table *symtab, exec_list *instructions, |
| 242 | const char *name, |
Eric Anholt | bfe380a | 2010-03-27 12:43:13 -0700 | [diff] [blame] | 243 | int n_args, |
Eric Anholt | c22c400 | 2010-03-26 18:20:30 -0700 | [diff] [blame] | 244 | void (*generate)(exec_list *instructions, |
| 245 | ir_variable **declarations, |
| 246 | const glsl_type *type)) |
| 247 | { |
| 248 | ir_function *const f = new ir_function(name); |
Eric Anholt | 53afc36 | 2010-03-27 13:55:04 -0700 | [diff] [blame] | 249 | const glsl_type *float_type = glsl_type::float_type; |
Eric Anholt | c22c400 | 2010-03-26 18:20:30 -0700 | [diff] [blame] | 250 | const glsl_type *vec2_type = glsl_type::get_instance(GLSL_TYPE_FLOAT, 2, 1); |
| 251 | const glsl_type *vec3_type = glsl_type::get_instance(GLSL_TYPE_FLOAT, 3, 1); |
| 252 | const glsl_type *vec4_type = glsl_type::get_instance(GLSL_TYPE_FLOAT, 4, 1); |
| 253 | |
| 254 | bool added = symtab->add_function(name, f); |
| 255 | assert(added); |
| 256 | |
Eric Anholt | bfe380a | 2010-03-27 12:43:13 -0700 | [diff] [blame] | 257 | generate_function_instance(f, name, instructions, n_args, generate, |
Eric Anholt | 53afc36 | 2010-03-27 13:55:04 -0700 | [diff] [blame] | 258 | float_type, float_type); |
Eric Anholt | bfe380a | 2010-03-27 12:43:13 -0700 | [diff] [blame] | 259 | generate_function_instance(f, name, instructions, n_args, generate, |
Eric Anholt | 53afc36 | 2010-03-27 13:55:04 -0700 | [diff] [blame] | 260 | vec2_type, vec2_type); |
Eric Anholt | bfe380a | 2010-03-27 12:43:13 -0700 | [diff] [blame] | 261 | generate_function_instance(f, name, instructions, n_args, generate, |
Eric Anholt | 53afc36 | 2010-03-27 13:55:04 -0700 | [diff] [blame] | 262 | vec3_type, vec3_type); |
Eric Anholt | bfe380a | 2010-03-27 12:43:13 -0700 | [diff] [blame] | 263 | generate_function_instance(f, name, instructions, n_args, generate, |
Eric Anholt | 53afc36 | 2010-03-27 13:55:04 -0700 | [diff] [blame] | 264 | vec4_type, vec4_type); |
| 265 | } |
| 266 | |
| 267 | static void |
| 268 | generate_length(exec_list *instructions, |
| 269 | ir_variable **declarations, |
| 270 | const glsl_type *type) |
| 271 | { |
Eric Anholt | 53afc36 | 2010-03-27 13:55:04 -0700 | [diff] [blame] | 272 | ir_dereference *const arg = new ir_dereference(declarations[0]); |
| 273 | ir_rvalue *result, *temp; |
| 274 | |
| 275 | (void)type; |
| 276 | |
| 277 | /* FINISHME: implement the abs(arg) variant for length(float f) */ |
| 278 | |
| 279 | temp = new ir_expression(ir_binop_dot, glsl_type::float_type, arg, arg); |
| 280 | result = new ir_expression(ir_unop_sqrt, glsl_type::float_type, temp, NULL); |
| 281 | |
Eric Anholt | 7e78e07 | 2010-04-07 13:34:15 -0700 | [diff] [blame^] | 282 | ir_instruction *inst = new ir_return(result); |
Eric Anholt | 53afc36 | 2010-03-27 13:55:04 -0700 | [diff] [blame] | 283 | instructions->push_tail(inst); |
| 284 | } |
| 285 | |
| 286 | void |
| 287 | generate_length_functions(glsl_symbol_table *symtab, exec_list *instructions) |
| 288 | { |
| 289 | const char *name = "length"; |
| 290 | ir_function *const f = new ir_function(name); |
| 291 | const glsl_type *float_type = glsl_type::float_type; |
| 292 | const glsl_type *vec2_type = glsl_type::get_instance(GLSL_TYPE_FLOAT, 2, 1); |
| 293 | const glsl_type *vec3_type = glsl_type::get_instance(GLSL_TYPE_FLOAT, 3, 1); |
| 294 | const glsl_type *vec4_type = glsl_type::get_instance(GLSL_TYPE_FLOAT, 4, 1); |
| 295 | |
| 296 | bool added = symtab->add_function(name, f); |
| 297 | assert(added); |
| 298 | |
| 299 | generate_function_instance(f, name, instructions, 1, generate_length, |
| 300 | float_type, float_type); |
| 301 | generate_function_instance(f, name, instructions, 1, generate_length, |
| 302 | float_type, vec2_type); |
| 303 | generate_function_instance(f, name, instructions, 1, generate_length, |
| 304 | float_type, vec3_type); |
| 305 | generate_function_instance(f, name, instructions, 1, generate_length, |
| 306 | float_type, vec4_type); |
Eric Anholt | c22c400 | 2010-03-26 18:20:30 -0700 | [diff] [blame] | 307 | } |
| 308 | |
Eric Anholt | 76a91e1 | 2010-03-27 14:04:43 -0700 | [diff] [blame] | 309 | static void |
| 310 | generate_dot(exec_list *instructions, |
| 311 | ir_variable **declarations, |
| 312 | const glsl_type *type) |
| 313 | { |
Eric Anholt | 76a91e1 | 2010-03-27 14:04:43 -0700 | [diff] [blame] | 314 | ir_dereference *const arg = new ir_dereference(declarations[0]); |
| 315 | ir_rvalue *result; |
| 316 | |
| 317 | (void)type; |
| 318 | |
| 319 | result = new ir_expression(ir_binop_dot, glsl_type::float_type, arg, arg); |
| 320 | |
Eric Anholt | 7e78e07 | 2010-04-07 13:34:15 -0700 | [diff] [blame^] | 321 | ir_instruction *inst = new ir_return(result); |
Eric Anholt | 76a91e1 | 2010-03-27 14:04:43 -0700 | [diff] [blame] | 322 | instructions->push_tail(inst); |
| 323 | } |
| 324 | |
| 325 | void |
| 326 | generate_dot_functions(glsl_symbol_table *symtab, exec_list *instructions) |
| 327 | { |
| 328 | const char *name = "dot"; |
| 329 | ir_function *const f = new ir_function(name); |
| 330 | const glsl_type *float_type = glsl_type::float_type; |
| 331 | const glsl_type *vec2_type = glsl_type::get_instance(GLSL_TYPE_FLOAT, 2, 1); |
| 332 | const glsl_type *vec3_type = glsl_type::get_instance(GLSL_TYPE_FLOAT, 3, 1); |
| 333 | const glsl_type *vec4_type = glsl_type::get_instance(GLSL_TYPE_FLOAT, 4, 1); |
| 334 | |
| 335 | bool added = symtab->add_function(name, f); |
| 336 | assert(added); |
| 337 | |
| 338 | generate_function_instance(f, name, instructions, 1, generate_dot, |
| 339 | float_type, float_type); |
| 340 | generate_function_instance(f, name, instructions, 1, generate_dot, |
| 341 | float_type, vec2_type); |
| 342 | generate_function_instance(f, name, instructions, 1, generate_dot, |
| 343 | float_type, vec3_type); |
| 344 | generate_function_instance(f, name, instructions, 1, generate_dot, |
| 345 | float_type, vec4_type); |
| 346 | } |
| 347 | |
Eric Anholt | c22c400 | 2010-03-26 18:20:30 -0700 | [diff] [blame] | 348 | void |
| 349 | generate_110_functions(glsl_symbol_table *symtab, exec_list *instructions) |
| 350 | { |
Eric Anholt | d1e3195 | 2010-03-28 01:55:38 -0700 | [diff] [blame] | 351 | make_gentype_function(symtab, instructions, "radians", 1, generate_radians); |
| 352 | make_gentype_function(symtab, instructions, "degrees", 1, generate_degrees); |
Eric Anholt | c22c400 | 2010-03-26 18:20:30 -0700 | [diff] [blame] | 353 | /* FINISHME: sin() */ |
| 354 | /* FINISHME: cos() */ |
| 355 | /* FINISHME: tan() */ |
| 356 | /* FINISHME: asin() */ |
| 357 | /* FINISHME: acos() */ |
| 358 | /* FINISHME: atan(y,x) */ |
| 359 | /* FINISHME: atan(y/x) */ |
Eric Anholt | ddd2e83 | 2010-03-27 12:59:42 -0700 | [diff] [blame] | 360 | make_gentype_function(symtab, instructions, "pow", 2, generate_pow); |
Eric Anholt | bfe380a | 2010-03-27 12:43:13 -0700 | [diff] [blame] | 361 | make_gentype_function(symtab, instructions, "exp", 1, generate_exp); |
| 362 | make_gentype_function(symtab, instructions, "log", 1, generate_log); |
Eric Anholt | 0166526 | 2010-03-27 13:56:35 -0700 | [diff] [blame] | 363 | make_gentype_function(symtab, instructions, "exp2", 1, generate_exp2); |
| 364 | make_gentype_function(symtab, instructions, "log2", 1, generate_log2); |
Eric Anholt | 44d68fd | 2010-03-27 13:01:51 -0700 | [diff] [blame] | 365 | make_gentype_function(symtab, instructions, "sqrt", 1, generate_sqrt); |
Eric Anholt | bfe380a | 2010-03-27 12:43:13 -0700 | [diff] [blame] | 366 | make_gentype_function(symtab, instructions, "inversesqrt", 1, generate_rsq); |
| 367 | make_gentype_function(symtab, instructions, "abs", 1, generate_abs); |
Eric Anholt | c22c400 | 2010-03-26 18:20:30 -0700 | [diff] [blame] | 368 | /* FINISHME: sign() */ |
Eric Anholt | bfe380a | 2010-03-27 12:43:13 -0700 | [diff] [blame] | 369 | make_gentype_function(symtab, instructions, "floor", 1, generate_floor); |
| 370 | make_gentype_function(symtab, instructions, "ceil", 1, generate_ceil); |
Eric Anholt | c22c400 | 2010-03-26 18:20:30 -0700 | [diff] [blame] | 371 | /* FINISHME: fract() */ |
| 372 | /* FINISHME: mod(x, float y) */ |
Eric Anholt | bfe380a | 2010-03-27 12:43:13 -0700 | [diff] [blame] | 373 | make_gentype_function(symtab, instructions, "mod", 2, generate_mod); |
| 374 | make_gentype_function(symtab, instructions, "min", 2, generate_min); |
| 375 | /* FINISHME: min(x, float y) */ |
| 376 | make_gentype_function(symtab, instructions, "max", 2, generate_max); |
| 377 | /* FINISHME: max(x, float y) */ |
Eric Anholt | c22c400 | 2010-03-26 18:20:30 -0700 | [diff] [blame] | 378 | /* FINISHME: clamp() */ |
| 379 | /* FINISHME: clamp() */ |
| 380 | /* FINISHME: mix() */ |
| 381 | /* FINISHME: mix() */ |
| 382 | /* FINISHME: step() */ |
| 383 | /* FINISHME: step() */ |
| 384 | /* FINISHME: smoothstep() */ |
| 385 | /* FINISHME: smoothstep() */ |
| 386 | /* FINISHME: floor() */ |
| 387 | /* FINISHME: step() */ |
Eric Anholt | 53afc36 | 2010-03-27 13:55:04 -0700 | [diff] [blame] | 388 | generate_length_functions(symtab, instructions); |
Eric Anholt | c22c400 | 2010-03-26 18:20:30 -0700 | [diff] [blame] | 389 | /* FINISHME: distance() */ |
Eric Anholt | 76a91e1 | 2010-03-27 14:04:43 -0700 | [diff] [blame] | 390 | generate_dot_functions(symtab, instructions); |
Eric Anholt | c22c400 | 2010-03-26 18:20:30 -0700 | [diff] [blame] | 391 | /* FINISHME: cross() */ |
| 392 | /* FINISHME: normalize() */ |
| 393 | /* FINISHME: ftransform() */ |
| 394 | /* FINISHME: faceforward() */ |
| 395 | /* FINISHME: reflect() */ |
| 396 | /* FINISHME: refract() */ |
| 397 | /* FINISHME: matrixCompMult() */ |
| 398 | /* FINISHME: lessThan() */ |
| 399 | /* FINISHME: lessThanEqual() */ |
| 400 | /* FINISHME: greaterThan() */ |
| 401 | /* FINISHME: greaterThanEqual() */ |
| 402 | /* FINISHME: equal() */ |
| 403 | /* FINISHME: notEqual() */ |
| 404 | /* FINISHME: any() */ |
| 405 | /* FINISHME: all() */ |
| 406 | /* FINISHME: not() */ |
| 407 | /* FINISHME: texture*() */ |
| 408 | /* FINISHME: shadow*() */ |
| 409 | /* FINISHME: dFd[xy]() */ |
| 410 | /* FINISHME: fwidth() */ |
| 411 | } |
| 412 | |
| 413 | void |
| 414 | _mesa_glsl_initialize_functions(exec_list *instructions, |
| 415 | struct _mesa_glsl_parse_state *state) |
| 416 | { |
| 417 | generate_110_functions(state->symbols, instructions); |
| 418 | } |