mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2025-12-22 09:10:11 +01:00
glsl_to_tgsi: do fewer optimizations with GLSLOptimizeConservatively
Reviewed-by: Eric Anholt <eric@anholt.net>
This commit is contained in:
parent
0a5018c1a4
commit
96fe8834f5
1 changed files with 67 additions and 9 deletions
|
|
@ -6768,6 +6768,55 @@ get_mesa_program(struct gl_context *ctx,
|
||||||
return prog;
|
return prog;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* See if there are unsupported control flow statements. */
|
||||||
|
class ir_control_flow_info_visitor : public ir_hierarchical_visitor {
|
||||||
|
private:
|
||||||
|
const struct gl_shader_compiler_options *options;
|
||||||
|
public:
|
||||||
|
ir_control_flow_info_visitor(const struct gl_shader_compiler_options *options)
|
||||||
|
: options(options),
|
||||||
|
unsupported(false)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
virtual ir_visitor_status visit_enter(ir_function *ir)
|
||||||
|
{
|
||||||
|
/* Other functions are skipped (same as glsl_to_tgsi). */
|
||||||
|
if (strcmp(ir->name, "main") == 0)
|
||||||
|
return visit_continue;
|
||||||
|
|
||||||
|
return visit_continue_with_parent;
|
||||||
|
}
|
||||||
|
|
||||||
|
virtual ir_visitor_status visit_enter(ir_call *ir)
|
||||||
|
{
|
||||||
|
if (!ir->callee->is_intrinsic()) {
|
||||||
|
unsupported = true; /* it's a function call */
|
||||||
|
return visit_stop;
|
||||||
|
}
|
||||||
|
return visit_continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
virtual ir_visitor_status visit_enter(ir_return *ir)
|
||||||
|
{
|
||||||
|
if (options->EmitNoMainReturn) {
|
||||||
|
unsupported = true;
|
||||||
|
return visit_stop;
|
||||||
|
}
|
||||||
|
return visit_continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool unsupported;
|
||||||
|
};
|
||||||
|
|
||||||
|
static bool
|
||||||
|
has_unsupported_control_flow(exec_list *ir,
|
||||||
|
const struct gl_shader_compiler_options *options)
|
||||||
|
{
|
||||||
|
ir_control_flow_info_visitor visitor(options);
|
||||||
|
visit_list_elements(&visitor, ir);
|
||||||
|
return visitor.unsupported;
|
||||||
|
}
|
||||||
|
|
||||||
extern "C" {
|
extern "C" {
|
||||||
|
|
||||||
|
|
@ -6787,7 +6836,6 @@ st_link_shader(struct gl_context *ctx, struct gl_shader_program *prog)
|
||||||
if (prog->_LinkedShaders[i] == NULL)
|
if (prog->_LinkedShaders[i] == NULL)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
bool progress;
|
|
||||||
exec_list *ir = prog->_LinkedShaders[i]->ir;
|
exec_list *ir = prog->_LinkedShaders[i]->ir;
|
||||||
gl_shader_stage stage = prog->_LinkedShaders[i]->Stage;
|
gl_shader_stage stage = prog->_LinkedShaders[i]->Stage;
|
||||||
const struct gl_shader_compiler_options *options =
|
const struct gl_shader_compiler_options *options =
|
||||||
|
|
@ -6871,14 +6919,24 @@ st_link_shader(struct gl_context *ctx, struct gl_shader_program *prog)
|
||||||
lower_discard(ir);
|
lower_discard(ir);
|
||||||
}
|
}
|
||||||
|
|
||||||
do {
|
if (ctx->Const.GLSLOptimizeConservatively) {
|
||||||
progress = do_common_optimization(ir, true, true, options,
|
/* Do it once and repeat only if there's unsupported control flow. */
|
||||||
ctx->Const.NativeIntegers);
|
do {
|
||||||
progress = lower_if_to_cond_assign((gl_shader_stage)i, ir,
|
do_common_optimization(ir, true, true, options,
|
||||||
options->MaxIfDepth, if_threshold) ||
|
ctx->Const.NativeIntegers);
|
||||||
progress;
|
lower_if_to_cond_assign((gl_shader_stage)i, ir,
|
||||||
|
options->MaxIfDepth, if_threshold);
|
||||||
} while (progress);
|
} while (has_unsupported_control_flow(ir, options));
|
||||||
|
} else {
|
||||||
|
/* Repeat it until it stops making changes. */
|
||||||
|
bool progress;
|
||||||
|
do {
|
||||||
|
progress = do_common_optimization(ir, true, true, options,
|
||||||
|
ctx->Const.NativeIntegers);
|
||||||
|
progress |= lower_if_to_cond_assign((gl_shader_stage)i, ir,
|
||||||
|
options->MaxIfDepth, if_threshold);
|
||||||
|
} while (progress);
|
||||||
|
}
|
||||||
|
|
||||||
validate_ir_tree(ir);
|
validate_ir_tree(ir);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue