aboutsummaryrefslogtreecommitdiff
path: root/mesalib/src/glsl
diff options
context:
space:
mode:
authormarha <marha@users.sourceforge.net>2011-09-26 17:04:30 +0200
committermarha <marha@users.sourceforge.net>2011-09-26 17:04:30 +0200
commit873965b49f283ad028dd4e0e5b7e93a758c84993 (patch)
tree84122d76cb641b54ea85cee9b631fb51c25052b5 /mesalib/src/glsl
parentc1e6c7428a8d2c1b60ffac7df7a3f56c300fa983 (diff)
downloadvcxsrv-873965b49f283ad028dd4e0e5b7e93a758c84993.tar.gz
vcxsrv-873965b49f283ad028dd4e0e5b7e93a758c84993.tar.bz2
vcxsrv-873965b49f283ad028dd4e0e5b7e93a758c84993.zip
fontconfig libX11 libXext libXft libXmu mesa git update 26 sep 2011
Diffstat (limited to 'mesalib/src/glsl')
-rw-r--r--mesalib/src/glsl/Android.mk1
-rw-r--r--mesalib/src/glsl/Makefile1
-rw-r--r--mesalib/src/glsl/SConscript1
-rw-r--r--mesalib/src/glsl/ast_function.cpp1
-rw-r--r--mesalib/src/glsl/ast_to_hir.cpp1
-rw-r--r--mesalib/src/glsl/glsl_parser_extras.cpp2
-rw-r--r--mesalib/src/glsl/ir_hierarchical_visitor.h3
-rw-r--r--mesalib/src/glsl/ir_hv_accept.cpp21
-rw-r--r--mesalib/src/glsl/ir_optimization.h1
-rw-r--r--mesalib/src/glsl/ir_reader.cpp5
-rw-r--r--mesalib/src/glsl/ir_variable.cpp8
-rw-r--r--mesalib/src/glsl/linker.cpp8
12 files changed, 38 insertions, 15 deletions
diff --git a/mesalib/src/glsl/Android.mk b/mesalib/src/glsl/Android.mk
index d0b3ff3be..9bf4ff782 100644
--- a/mesalib/src/glsl/Android.mk
+++ b/mesalib/src/glsl/Android.mk
@@ -70,6 +70,7 @@ CXX_SOURCES = \
loop_analysis.cpp \
loop_controls.cpp \
loop_unroll.cpp \
+ lower_clip_distance.cpp \
lower_discard.cpp \
lower_if_to_cond_assign.cpp \
lower_instructions.cpp \
diff --git a/mesalib/src/glsl/Makefile b/mesalib/src/glsl/Makefile
index 00b7b9164..b2efb2abc 100644
--- a/mesalib/src/glsl/Makefile
+++ b/mesalib/src/glsl/Makefile
@@ -56,6 +56,7 @@ CXX_SOURCES = \
loop_analysis.cpp \
loop_controls.cpp \
loop_unroll.cpp \
+ lower_clip_distance.cpp \
lower_discard.cpp \
lower_if_to_cond_assign.cpp \
lower_instructions.cpp \
diff --git a/mesalib/src/glsl/SConscript b/mesalib/src/glsl/SConscript
index 1da58a91f..b4786c5e5 100644
--- a/mesalib/src/glsl/SConscript
+++ b/mesalib/src/glsl/SConscript
@@ -67,6 +67,7 @@ glsl_sources = [
'loop_analysis.cpp',
'loop_controls.cpp',
'loop_unroll.cpp',
+ 'lower_clip_distance.cpp',
'lower_discard.cpp',
'lower_if_to_cond_assign.cpp',
'lower_instructions.cpp',
diff --git a/mesalib/src/glsl/ast_function.cpp b/mesalib/src/glsl/ast_function.cpp
index ca45934a4..fc0d7497d 100644
--- a/mesalib/src/glsl/ast_function.cpp
+++ b/mesalib/src/glsl/ast_function.cpp
@@ -117,6 +117,7 @@ match_function_by_name(exec_list *instructions, const char *name,
/* The current shader doesn't contain a matching function or signature.
* Before giving up, look for the prototype in the built-in functions.
*/
+ _mesa_glsl_initialize_functions(state);
for (unsigned i = 0; i < state->num_builtins_to_link; i++) {
ir_function *builtin;
builtin = state->builtins_to_link[i]->symbols->get_function(name);
diff --git a/mesalib/src/glsl/ast_to_hir.cpp b/mesalib/src/glsl/ast_to_hir.cpp
index ce29d5a87..91a223160 100644
--- a/mesalib/src/glsl/ast_to_hir.cpp
+++ b/mesalib/src/glsl/ast_to_hir.cpp
@@ -60,7 +60,6 @@ void
_mesa_ast_to_hir(exec_list *instructions, struct _mesa_glsl_parse_state *state)
{
_mesa_glsl_initialize_variables(instructions, state);
- _mesa_glsl_initialize_functions(state);
state->symbols->language_version = state->language_version;
diff --git a/mesalib/src/glsl/glsl_parser_extras.cpp b/mesalib/src/glsl/glsl_parser_extras.cpp
index 8faddc578..a9075b2b1 100644
--- a/mesalib/src/glsl/glsl_parser_extras.cpp
+++ b/mesalib/src/glsl/glsl_parser_extras.cpp
@@ -52,6 +52,8 @@ _mesa_glsl_parse_state::_mesa_glsl_parse_state(struct gl_context *ctx,
this->error = false;
this->loop_or_switch_nesting = NULL;
+ this->num_builtins_to_link = 0;
+
/* Set default language version and extensions */
this->language_version = 110;
this->es_shader = false;
diff --git a/mesalib/src/glsl/ir_hierarchical_visitor.h b/mesalib/src/glsl/ir_hierarchical_visitor.h
index dc177f5eb..bba046db4 100644
--- a/mesalib/src/glsl/ir_hierarchical_visitor.h
+++ b/mesalib/src/glsl/ir_hierarchical_visitor.h
@@ -178,6 +178,7 @@ void visit_tree(ir_instruction *ir,
void (*callback)(class ir_instruction *ir, void *data),
void *data);
-ir_visitor_status visit_list_elements(ir_hierarchical_visitor *v, exec_list *l);
+ir_visitor_status visit_list_elements(ir_hierarchical_visitor *v, exec_list *l,
+ bool statement_list = true);
#endif /* IR_HIERARCHICAL_VISITOR_H */
diff --git a/mesalib/src/glsl/ir_hv_accept.cpp b/mesalib/src/glsl/ir_hv_accept.cpp
index d33fc85bf..0e78fda81 100644
--- a/mesalib/src/glsl/ir_hv_accept.cpp
+++ b/mesalib/src/glsl/ir_hv_accept.cpp
@@ -30,7 +30,13 @@
*/
/**
- * Process a list of nodes using a hierarchical vistor
+ * Process a list of nodes using a hierarchical vistor.
+ *
+ * If statement_list is true (the default), this is a list of statements, so
+ * v->base_ir will be set to point to each statement just before iterating
+ * over it, and restored after iteration is complete. If statement_list is
+ * false, this is a list that appears inside a statement (e.g. a parameter
+ * list), so v->base_ir will be left alone.
*
* \warning
* This function will operate correctly if a node being processed is removed
@@ -38,19 +44,22 @@
* processed, some of the added nodes may not be processed.
*/
ir_visitor_status
-visit_list_elements(ir_hierarchical_visitor *v, exec_list *l)
+visit_list_elements(ir_hierarchical_visitor *v, exec_list *l,
+ bool statement_list)
{
ir_instruction *prev_base_ir = v->base_ir;
foreach_list_safe(n, l) {
ir_instruction *const ir = (ir_instruction *) n;
- v->base_ir = ir;
+ if (statement_list)
+ v->base_ir = ir;
ir_visitor_status s = ir->accept(v);
if (s != visit_continue)
return s;
}
- v->base_ir = prev_base_ir;
+ if (statement_list)
+ v->base_ir = prev_base_ir;
return visit_continue;
}
@@ -129,7 +138,7 @@ ir_function::accept(ir_hierarchical_visitor *v)
if (s != visit_continue)
return (s == visit_continue_with_parent) ? visit_continue : s;
- s = visit_list_elements(v, &this->signatures);
+ s = visit_list_elements(v, &this->signatures, false);
return (s == visit_stop) ? s : v->visit_leave(this);
}
@@ -317,7 +326,7 @@ ir_call::accept(ir_hierarchical_visitor *v)
if (s != visit_continue)
return (s == visit_continue_with_parent) ? visit_continue : s;
- s = visit_list_elements(v, &this->actual_parameters);
+ s = visit_list_elements(v, &this->actual_parameters, false);
if (s == visit_stop)
return s;
diff --git a/mesalib/src/glsl/ir_optimization.h b/mesalib/src/glsl/ir_optimization.h
index 48448d4a1..af80e26b9 100644
--- a/mesalib/src/glsl/ir_optimization.h
+++ b/mesalib/src/glsl/ir_optimization.h
@@ -69,6 +69,7 @@ bool lower_noise(exec_list *instructions);
bool lower_variable_index_to_cond_assign(exec_list *instructions,
bool lower_input, bool lower_output, bool lower_temp, bool lower_uniform);
bool lower_quadop_vector(exec_list *instructions, bool dont_lower_swz);
+bool lower_clip_distance(exec_list *instructions);
bool optimize_redundant_jumps(exec_list *instructions);
ir_rvalue *
diff --git a/mesalib/src/glsl/ir_reader.cpp b/mesalib/src/glsl/ir_reader.cpp
index 2d0bccb78..afb06b3be 100644
--- a/mesalib/src/glsl/ir_reader.cpp
+++ b/mesalib/src/glsl/ir_reader.cpp
@@ -79,7 +79,8 @@ _mesa_glsl_read_ir(_mesa_glsl_parse_state *state, exec_list *instructions,
void
ir_reader::read(exec_list *instructions, const char *src, bool scan_for_protos)
{
- s_expression *expr = s_expression::read_expression(mem_ctx, src);
+ void *sx_mem_ctx = ralloc_context(NULL);
+ s_expression *expr = s_expression::read_expression(sx_mem_ctx, src);
if (expr == NULL) {
ir_read_error(NULL, "couldn't parse S-Expression.");
return;
@@ -92,7 +93,7 @@ ir_reader::read(exec_list *instructions, const char *src, bool scan_for_protos)
}
read_instructions(instructions, expr, NULL);
- ralloc_free(expr);
+ ralloc_free(sx_mem_ctx);
if (debug)
validate_ir_tree(instructions);
diff --git a/mesalib/src/glsl/ir_variable.cpp b/mesalib/src/glsl/ir_variable.cpp
index e0b6f38f1..58be64bfa 100644
--- a/mesalib/src/glsl/ir_variable.cpp
+++ b/mesalib/src/glsl/ir_variable.cpp
@@ -621,9 +621,9 @@ generate_130_vs_variables(exec_list *instructions,
const glsl_type *const clip_distance_array_type =
glsl_type::get_array_instance(glsl_type::float_type, 0);
- /* FINISHME: gl_ClipDistance needs a real location assigned. */
add_variable(instructions, state->symbols,
- "gl_ClipDistance", clip_distance_array_type, ir_var_out, -1);
+ "gl_ClipDistance", clip_distance_array_type, ir_var_out,
+ VERT_RESULT_CLIP_DIST0);
}
@@ -841,9 +841,9 @@ generate_130_fs_variables(exec_list *instructions,
const glsl_type *const clip_distance_array_type =
glsl_type::get_array_instance(glsl_type::float_type, 0);
- /* FINISHME: gl_ClipDistance needs a real location assigned. */
add_variable(instructions, state->symbols,
- "gl_ClipDistance", clip_distance_array_type, ir_var_in, -1);
+ "gl_ClipDistance", clip_distance_array_type, ir_var_in,
+ FRAG_ATTRIB_CLIP_DIST0);
}
static void
diff --git a/mesalib/src/glsl/linker.cpp b/mesalib/src/glsl/linker.cpp
index 195f58f29..d802a0a9b 100644
--- a/mesalib/src/glsl/linker.cpp
+++ b/mesalib/src/glsl/linker.cpp
@@ -244,7 +244,9 @@ count_attribute_slots(const glsl_type *t)
/**
- * Verify that a vertex shader executable meets all semantic requirements
+ * Verify that a vertex shader executable meets all semantic requirements.
+ *
+ * Also sets prog->Vert.UsesClipDistance as a side effect.
*
* \param shader Vertex shader executable to be verified
*/
@@ -279,6 +281,7 @@ validate_vertex_shader_executable(struct gl_shader_program *prog,
"and `gl_ClipDistance'\n");
return false;
}
+ prog->Vert.UsesClipDistance = clip_distance.variable_found();
}
return true;
@@ -1743,6 +1746,9 @@ link_shaders(struct gl_context *ctx, struct gl_shader_program *prog)
if (!prog->LinkStatus)
goto done;
+ if (ctx->ShaderCompilerOptions[i].LowerClipDistance)
+ lower_clip_distance(prog->_LinkedShaders[i]->ir);
+
while (do_common_optimization(prog->_LinkedShaders[i]->ir, true, 32))
;
}