Mesa (master): glsl/lower_if: don' t lower branches touching tess control outputs
Marek Olšák
mareko at kemper.freedesktop.org
Tue Nov 15 19:39:39 UTC 2016
Module: Mesa
Branch: master
Commit: 83d9b8a6f6365bc1569cdc847672478ac643670d
URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=83d9b8a6f6365bc1569cdc847672478ac643670d
Author: Marek Olšák <marek.olsak at amd.com>
Date: Sun Jul 3 17:01:09 2016 +0200
glsl/lower_if: don't lower branches touching tess control outputs
Reviewed-by: Nicolai Hähnle <nicolai.haehnle at amd.com>
---
src/compiler/glsl/ir_optimization.h | 3 ++-
src/compiler/glsl/lower_if_to_cond_assign.cpp | 23 ++++++++++++++++++++---
src/compiler/glsl/test_optpass.cpp | 2 +-
src/mesa/drivers/dri/i965/brw_link.cpp | 2 +-
src/mesa/program/ir_to_mesa.cpp | 3 ++-
src/mesa/state_tracker/st_glsl_to_tgsi.cpp | 3 ++-
6 files changed, 28 insertions(+), 8 deletions(-)
diff --git a/src/compiler/glsl/ir_optimization.h b/src/compiler/glsl/ir_optimization.h
index 8cee418..e6e8318 100644
--- a/src/compiler/glsl/ir_optimization.h
+++ b/src/compiler/glsl/ir_optimization.h
@@ -108,7 +108,8 @@ bool do_lower_texture_projection(exec_list *instructions);
bool do_if_simplification(exec_list *instructions);
bool opt_flatten_nested_if_blocks(exec_list *instructions);
bool do_discard_simplification(exec_list *instructions);
-bool lower_if_to_cond_assign(exec_list *instructions, unsigned max_depth = 0);
+bool lower_if_to_cond_assign(gl_shader_stage stage, exec_list *instructions,
+ unsigned max_depth = 0);
bool do_mat_op_to_vec(exec_list *instructions);
bool do_minmax_prune(exec_list *instructions);
bool do_noop_swizzle(exec_list *instructions);
diff --git a/src/compiler/glsl/lower_if_to_cond_assign.cpp b/src/compiler/glsl/lower_if_to_cond_assign.cpp
index 01a7335..e8db7aa 100644
--- a/src/compiler/glsl/lower_if_to_cond_assign.cpp
+++ b/src/compiler/glsl/lower_if_to_cond_assign.cpp
@@ -54,9 +54,11 @@ namespace {
class ir_if_to_cond_assign_visitor : public ir_hierarchical_visitor {
public:
- ir_if_to_cond_assign_visitor(unsigned max_depth)
+ ir_if_to_cond_assign_visitor(gl_shader_stage stage,
+ unsigned max_depth)
{
this->progress = false;
+ this->stage = stage;
this->max_depth = max_depth;
this->depth = 0;
@@ -75,6 +77,7 @@ public:
bool found_unsupported_op;
bool progress;
+ gl_shader_stage stage;
unsigned max_depth;
unsigned depth;
@@ -84,12 +87,13 @@ public:
} /* anonymous namespace */
bool
-lower_if_to_cond_assign(exec_list *instructions, unsigned max_depth)
+lower_if_to_cond_assign(gl_shader_stage stage, exec_list *instructions,
+ unsigned max_depth)
{
if (max_depth == UINT_MAX)
return false;
- ir_if_to_cond_assign_visitor v(max_depth);
+ ir_if_to_cond_assign_visitor v(stage, max_depth);
visit_list_elements(&v, instructions);
@@ -112,6 +116,19 @@ check_ir_node(ir_instruction *ir, void *data)
case ir_type_barrier:
v->found_unsupported_op = true;
break;
+
+ case ir_type_dereference_variable: {
+ ir_variable *var = ir->as_dereference_variable()->variable_referenced();
+
+ /* Lowering branches with TCS output accesses breaks many piglit tests,
+ * so don't touch them for now.
+ */
+ if (v->stage == MESA_SHADER_TESS_CTRL &&
+ var->data.mode == ir_var_shader_out)
+ v->found_unsupported_op = true;
+ break;
+ }
+
default:
break;
}
diff --git a/src/compiler/glsl/test_optpass.cpp b/src/compiler/glsl/test_optpass.cpp
index 852af19..4d0bcc2 100644
--- a/src/compiler/glsl/test_optpass.cpp
+++ b/src/compiler/glsl/test_optpass.cpp
@@ -99,7 +99,7 @@ do_optimization(struct exec_list *ir, const char *optimization,
return do_if_simplification(ir);
} else if (sscanf(optimization, "lower_if_to_cond_assign ( %d ) ",
&int_0) == 1) {
- return lower_if_to_cond_assign(ir, int_0);
+ return lower_if_to_cond_assign(MESA_SHADER_VERTEX, ir, int_0);
} else if (strcmp(optimization, "do_mat_op_to_vec") == 0) {
return do_mat_op_to_vec(ir);
} else if (strcmp(optimization, "do_noop_swizzle") == 0) {
diff --git a/src/mesa/drivers/dri/i965/brw_link.cpp b/src/mesa/drivers/dri/i965/brw_link.cpp
index 12db8d4..57baea3 100644
--- a/src/mesa/drivers/dri/i965/brw_link.cpp
+++ b/src/mesa/drivers/dri/i965/brw_link.cpp
@@ -125,7 +125,7 @@ process_glsl_ir(struct brw_context *brw,
* if-statements need to be flattened.
*/
if (brw->gen < 6)
- lower_if_to_cond_assign(shader->ir, 16);
+ lower_if_to_cond_assign(shader->Stage, shader->ir, 16);
do_lower_texture_projection(shader->ir);
brw_lower_texture_gradients(brw, shader->ir);
diff --git a/src/mesa/program/ir_to_mesa.cpp b/src/mesa/program/ir_to_mesa.cpp
index 6a1a977..c22eb0a 100644
--- a/src/mesa/program/ir_to_mesa.cpp
+++ b/src/mesa/program/ir_to_mesa.cpp
@@ -2995,7 +2995,8 @@ _mesa_ir_link_shader(struct gl_context *ctx, struct gl_shader_program *prog)
if (options->MaxIfDepth == 0)
progress = lower_discard(ir) || progress;
- progress = lower_if_to_cond_assign(ir, options->MaxIfDepth) || progress;
+ progress = lower_if_to_cond_assign((gl_shader_stage)i, ir,
+ options->MaxIfDepth) || progress;
progress = lower_noise(ir) || progress;
diff --git a/src/mesa/state_tracker/st_glsl_to_tgsi.cpp b/src/mesa/state_tracker/st_glsl_to_tgsi.cpp
index a4679e5..64a68e0 100644
--- a/src/mesa/state_tracker/st_glsl_to_tgsi.cpp
+++ b/src/mesa/state_tracker/st_glsl_to_tgsi.cpp
@@ -6864,7 +6864,8 @@ st_link_shader(struct gl_context *ctx, struct gl_shader_program *prog)
ctx->Const.NativeIntegers)
|| progress;
- progress = lower_if_to_cond_assign(ir, options->MaxIfDepth) || progress;
+ progress = lower_if_to_cond_assign((gl_shader_stage)i, ir,
+ options->MaxIfDepth) || progress;
} while (progress);
More information about the mesa-commit
mailing list