diff options
Diffstat (limited to 'mesalib/src/glsl')
-rw-r--r-- | mesalib/src/glsl/ast.h | 2 | ||||
-rw-r--r-- | mesalib/src/glsl/ast_to_hir.cpp | 6 | ||||
-rw-r--r-- | mesalib/src/glsl/builtin_stubs.cpp | 77 | ||||
-rw-r--r-- | mesalib/src/glsl/glcpp/glcpp.c | 259 | ||||
-rw-r--r-- | mesalib/src/glsl/ir_function_detect_recursion.cpp | 4 | ||||
-rw-r--r-- | mesalib/src/glsl/lower_jumps.cpp | 1 | ||||
-rw-r--r-- | mesalib/src/glsl/opt_discard_simplification.cpp | 1 | ||||
-rw-r--r-- | mesalib/src/glsl/opt_if_simplification.cpp | 189 | ||||
-rw-r--r-- | mesalib/src/glsl/standalone_scaffolding.cpp | 1 |
9 files changed, 278 insertions, 262 deletions
diff --git a/mesalib/src/glsl/ast.h b/mesalib/src/glsl/ast.h index 850fb2971..0cd19dc30 100644 --- a/mesalib/src/glsl/ast.h +++ b/mesalib/src/glsl/ast.h @@ -376,7 +376,7 @@ struct ast_type_qualifier { * \note * This field is only valid if \c explicit_location is set. */ - unsigned location; + int location; /** * Return true if and only if an interpolation qualifier is present. diff --git a/mesalib/src/glsl/ast_to_hir.cpp b/mesalib/src/glsl/ast_to_hir.cpp index 5ddda824d..f9fd1d68a 100644 --- a/mesalib/src/glsl/ast_to_hir.cpp +++ b/mesalib/src/glsl/ast_to_hir.cpp @@ -3014,6 +3014,12 @@ ast_function::hir(exec_list *instructions, const char *const name = identifier;
+ /* New functions are always added to the top-level IR instruction stream,
+ * so this instruction list pointer is ignored. See also emit_function
+ * (called below).
+ */
+ (void) instructions;
+
/* From page 21 (page 27 of the PDF) of the GLSL 1.20 spec,
*
* "Function declarations (prototypes) cannot occur inside of functions;
diff --git a/mesalib/src/glsl/builtin_stubs.cpp b/mesalib/src/glsl/builtin_stubs.cpp index 4c360b832..dfa5d324e 100644 --- a/mesalib/src/glsl/builtin_stubs.cpp +++ b/mesalib/src/glsl/builtin_stubs.cpp @@ -1,38 +1,39 @@ -/*
- * Copyright © 2010 Intel Corporation
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the "Software"),
- * to deal in the Software without restriction, including without limitation
- * the rights to use, copy, modify, merge, publish, distribute, sublicense,
- * and/or sell copies of the Software, and to permit persons to whom the
- * Software is furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice (including the next
- * paragraph) shall be included in all copies or substantial portions of the
- * Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
- * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
- * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
- * DEALINGS IN THE SOFTWARE.
- */
-
-#include <stdio.h>
-#include "glsl_parser_extras.h"
-
-/* A dummy file. When compiling prototypes, we don't care about builtins.
- * We really don't want to half-compile builtin_functions.cpp and fail, though.
- */
-void
-_mesa_glsl_release_functions(void)
-{
-}
-
-void
-_mesa_glsl_initialize_functions(_mesa_glsl_parse_state *state)
-{
-}
+/* + * Copyright © 2010 Intel Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice (including the next + * paragraph) shall be included in all copies or substantial portions of the + * Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ + +#include <stdio.h> +#include "glsl_parser_extras.h" + +/* A dummy file. When compiling prototypes, we don't care about builtins. + * We really don't want to half-compile builtin_functions.cpp and fail, though. + */ +void +_mesa_glsl_release_functions(void) +{ +} + +void +_mesa_glsl_initialize_functions(_mesa_glsl_parse_state *state) +{ + (void) state; +} diff --git a/mesalib/src/glsl/glcpp/glcpp.c b/mesalib/src/glsl/glcpp/glcpp.c index fd602c1fb..106c9916b 100644 --- a/mesalib/src/glsl/glcpp/glcpp.c +++ b/mesalib/src/glsl/glcpp/glcpp.c @@ -1,129 +1,130 @@ -/*
- * Copyright © 2010 Intel Corporation
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the "Software"),
- * to deal in the Software without restriction, including without limitation
- * the rights to use, copy, modify, merge, publish, distribute, sublicense,
- * and/or sell copies of the Software, and to permit persons to whom the
- * Software is furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice (including the next
- * paragraph) shall be included in all copies or substantial portions of the
- * Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
- * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
- * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
- * DEALINGS IN THE SOFTWARE.
- */
-
-#include <stdio.h>
-#include <string.h>
-#include <errno.h>
-#include "glcpp.h"
-#include "main/mtypes.h"
-#include "main/shaderobj.h"
-
-#ifdef _MSC_VER
-#include <io.h>
-#define STDIN_FILENO 0
-#define read _read
-#define open _open
-#define close _close
-#endif
-
-extern int yydebug;
-
-void
-_mesa_reference_shader(struct gl_context *ctx, struct gl_shader **ptr,
- struct gl_shader *sh)
-{
- *ptr = sh;
-}
-
-/* Read from fp until EOF and return a string of everything read.
- */
-static char *
-load_text_fp (void *ctx, FILE *fp)
-{
-#define CHUNK 4096
- char *text = NULL;
- size_t text_size = 0;
- size_t total_read = 0;
- size_t bytes;
-
- while (1) {
- if (total_read + CHUNK + 1 > text_size) {
- text_size = text_size ? text_size * 2 : CHUNK + 1;
- text = reralloc_size (ctx, text, text_size);
- if (text == NULL) {
- fprintf (stderr, "Out of memory\n");
- return NULL;
- }
- }
- bytes = fread (text + total_read, 1, CHUNK, fp);
- total_read += bytes;
-
- if (bytes < CHUNK) {
- break;
- }
- }
-
- text[total_read] = '\0';
-
- return text;
-}
-
-static char *
-load_text_file(void *ctx, const char *filename)
-{
- char *text;
- FILE *fp;
-
- if (filename == NULL || strcmp (filename, "-") == 0)
- return load_text_fp (ctx, stdin);
-
- fp = fopen (filename, "r");
- if (fp == NULL) {
- fprintf (stderr, "Failed to open file %s: %s\n",
- filename, strerror (errno));
- return NULL;
- }
-
- text = load_text_fp (ctx, fp);
-
- fclose(fp);
-
- return text;
-}
-
-int
-main (int argc, char *argv[])
-{
- char *filename = NULL;
- void *ctx = ralloc(NULL, void*);
- char *info_log = ralloc_strdup(ctx, "");
- const char *shader;
- int ret;
-
- if (argc) {
- filename = argv[1];
- }
-
- shader = load_text_file (ctx, filename);
- if (shader == NULL)
- return 1;
-
- ret = preprocess(ctx, &shader, &info_log, NULL, API_OPENGL);
-
- printf("%s", shader);
- fprintf(stderr, "%s", info_log);
-
- ralloc_free(ctx);
-
- return ret;
-}
+/* + * Copyright © 2010 Intel Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice (including the next + * paragraph) shall be included in all copies or substantial portions of the + * Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ + +#include <stdio.h> +#include <string.h> +#include <errno.h> +#include "glcpp.h" +#include "main/mtypes.h" +#include "main/shaderobj.h" + +#ifdef _MSC_VER +#include <io.h> +#define STDIN_FILENO 0 +#define read _read +#define open _open +#define close _close +#endif + +extern int yydebug; + +void +_mesa_reference_shader(struct gl_context *ctx, struct gl_shader **ptr, + struct gl_shader *sh) +{ + (void) ctx; + *ptr = sh; +} + +/* Read from fp until EOF and return a string of everything read. + */ +static char * +load_text_fp (void *ctx, FILE *fp) +{ +#define CHUNK 4096 + char *text = NULL; + size_t text_size = 0; + size_t total_read = 0; + size_t bytes; + + while (1) { + if (total_read + CHUNK + 1 > text_size) { + text_size = text_size ? text_size * 2 : CHUNK + 1; + text = reralloc_size (ctx, text, text_size); + if (text == NULL) { + fprintf (stderr, "Out of memory\n"); + return NULL; + } + } + bytes = fread (text + total_read, 1, CHUNK, fp); + total_read += bytes; + + if (bytes < CHUNK) { + break; + } + } + + text[total_read] = '\0'; + + return text; +} + +static char * +load_text_file(void *ctx, const char *filename) +{ + char *text; + FILE *fp; + + if (filename == NULL || strcmp (filename, "-") == 0) + return load_text_fp (ctx, stdin); + + fp = fopen (filename, "r"); + if (fp == NULL) { + fprintf (stderr, "Failed to open file %s: %s\n", + filename, strerror (errno)); + return NULL; + } + + text = load_text_fp (ctx, fp); + + fclose(fp); + + return text; +} + +int +main (int argc, char *argv[]) +{ + char *filename = NULL; + void *ctx = ralloc(NULL, void*); + char *info_log = ralloc_strdup(ctx, ""); + const char *shader; + int ret; + + if (argc) { + filename = argv[1]; + } + + shader = load_text_file (ctx, filename); + if (shader == NULL) + return 1; + + ret = preprocess(ctx, &shader, &info_log, NULL, API_OPENGL); + + printf("%s", shader); + fprintf(stderr, "%s", info_log); + + ralloc_free(ctx); + + return ret; +} diff --git a/mesalib/src/glsl/ir_function_detect_recursion.cpp b/mesalib/src/glsl/ir_function_detect_recursion.cpp index 8f805bf1b..890bc455f 100644 --- a/mesalib/src/glsl/ir_function_detect_recursion.cpp +++ b/mesalib/src/glsl/ir_function_detect_recursion.cpp @@ -289,6 +289,8 @@ emit_errors_unlinked(const void *key, void *data, void *closure) function *f = (function *) data; YYLTYPE loc; + (void) key; + char *proto = prototype_string(f->sig->return_type, f->sig->function_name(), &f->sig->parameters); @@ -308,6 +310,8 @@ emit_errors_linked(const void *key, void *data, void *closure) (struct gl_shader_program *) closure; function *f = (function *) data; + (void) key; + char *proto = prototype_string(f->sig->return_type, f->sig->function_name(), &f->sig->parameters); diff --git a/mesalib/src/glsl/lower_jumps.cpp b/mesalib/src/glsl/lower_jumps.cpp index 61874990a..92813f567 100644 --- a/mesalib/src/glsl/lower_jumps.cpp +++ b/mesalib/src/glsl/lower_jumps.cpp @@ -438,6 +438,7 @@ struct ir_lower_jumps_visitor : public ir_control_flow_visitor { * satisfied, because discard statements can't contain other * statements. */ + (void) ir; } enum jump_strength get_jump_strength(ir_instruction* ir) diff --git a/mesalib/src/glsl/opt_discard_simplification.cpp b/mesalib/src/glsl/opt_discard_simplification.cpp index a19947ddd..ba4981bae 100644 --- a/mesalib/src/glsl/opt_discard_simplification.cpp +++ b/mesalib/src/glsl/opt_discard_simplification.cpp @@ -138,6 +138,7 @@ is_only_instruction(ir_discard *discard) ir_visitor_status discard_simplifier::visit_enter(ir_assignment *ir) { + (void) ir; return visit_continue_with_parent; } diff --git a/mesalib/src/glsl/opt_if_simplification.cpp b/mesalib/src/glsl/opt_if_simplification.cpp index 2d8858e49..940dd08d5 100644 --- a/mesalib/src/glsl/opt_if_simplification.cpp +++ b/mesalib/src/glsl/opt_if_simplification.cpp @@ -1,94 +1,95 @@ -/*
- * Copyright © 2010 Intel Corporation
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the "Software"),
- * to deal in the Software without restriction, including without limitation
- * the rights to use, copy, modify, merge, publish, distribute, sublicense,
- * and/or sell copies of the Software, and to permit persons to whom the
- * Software is furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice (including the next
- * paragraph) shall be included in all copies or substantial portions of the
- * Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
- * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
- * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
- * DEALINGS IN THE SOFTWARE.
- */
-
-/**
- * \file opt_if_simplification.cpp
- *
- * Moves constant branches of if statements out to the surrounding
- * instruction stream.
- */
-
-#include "ir.h"
-
-class ir_if_simplification_visitor : public ir_hierarchical_visitor {
-public:
- ir_if_simplification_visitor()
- {
- this->made_progress = false;
- }
-
- ir_visitor_status visit_leave(ir_if *);
- ir_visitor_status visit_enter(ir_assignment *);
-
- bool made_progress;
-};
-
-/* We only care about the top level "if" instructions, so don't
- * descend into expressions.
- */
-ir_visitor_status
-ir_if_simplification_visitor::visit_enter(ir_assignment *ir)
-{
- return visit_continue_with_parent;
-}
-
-bool
-do_if_simplification(exec_list *instructions)
-{
- ir_if_simplification_visitor v;
-
- v.run(instructions);
- return v.made_progress;
-}
-
-
-ir_visitor_status
-ir_if_simplification_visitor::visit_leave(ir_if *ir)
-{
- /* FINISHME: Ideally there would be a way to note that the condition results
- * FINISHME: in a constant before processing both of the other subtrees.
- * FINISHME: This can probably be done with some flags, but it would take
- * FINISHME: some work to get right.
- */
- ir_constant *condition_constant = ir->condition->constant_expression_value();
- if (condition_constant) {
- /* Move the contents of the one branch of the conditional
- * that matters out.
- */
- if (condition_constant->value.b[0]) {
- foreach_iter(exec_list_iterator, then_iter, ir->then_instructions) {
- ir_instruction *then_ir = (ir_instruction *)then_iter.get();
- ir->insert_before(then_ir);
- }
- } else {
- foreach_iter(exec_list_iterator, else_iter, ir->else_instructions) {
- ir_instruction *else_ir = (ir_instruction *)else_iter.get();
- ir->insert_before(else_ir);
- }
- }
- ir->remove();
- this->made_progress = true;
- }
-
- return visit_continue;
-}
+/* + * Copyright © 2010 Intel Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice (including the next + * paragraph) shall be included in all copies or substantial portions of the + * Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ + +/** + * \file opt_if_simplification.cpp + * + * Moves constant branches of if statements out to the surrounding + * instruction stream. + */ + +#include "ir.h" + +class ir_if_simplification_visitor : public ir_hierarchical_visitor { +public: + ir_if_simplification_visitor() + { + this->made_progress = false; + } + + ir_visitor_status visit_leave(ir_if *); + ir_visitor_status visit_enter(ir_assignment *); + + bool made_progress; +}; + +/* We only care about the top level "if" instructions, so don't + * descend into expressions. + */ +ir_visitor_status +ir_if_simplification_visitor::visit_enter(ir_assignment *ir) +{ + (void) ir; + return visit_continue_with_parent; +} + +bool +do_if_simplification(exec_list *instructions) +{ + ir_if_simplification_visitor v; + + v.run(instructions); + return v.made_progress; +} + + +ir_visitor_status +ir_if_simplification_visitor::visit_leave(ir_if *ir) +{ + /* FINISHME: Ideally there would be a way to note that the condition results + * FINISHME: in a constant before processing both of the other subtrees. + * FINISHME: This can probably be done with some flags, but it would take + * FINISHME: some work to get right. + */ + ir_constant *condition_constant = ir->condition->constant_expression_value(); + if (condition_constant) { + /* Move the contents of the one branch of the conditional + * that matters out. + */ + if (condition_constant->value.b[0]) { + foreach_iter(exec_list_iterator, then_iter, ir->then_instructions) { + ir_instruction *then_ir = (ir_instruction *)then_iter.get(); + ir->insert_before(then_ir); + } + } else { + foreach_iter(exec_list_iterator, else_iter, ir->else_instructions) { + ir_instruction *else_ir = (ir_instruction *)else_iter.get(); + ir->insert_before(else_ir); + } + } + ir->remove(); + this->made_progress = true; + } + + return visit_continue; +} diff --git a/mesalib/src/glsl/standalone_scaffolding.cpp b/mesalib/src/glsl/standalone_scaffolding.cpp index bbd7bb913..72aa1e428 100644 --- a/mesalib/src/glsl/standalone_scaffolding.cpp +++ b/mesalib/src/glsl/standalone_scaffolding.cpp @@ -37,6 +37,7 @@ void _mesa_reference_shader(struct gl_context *ctx, struct gl_shader **ptr, struct gl_shader *sh) { + (void) ctx; *ptr = sh; } |