summaryrefslogtreecommitdiffstats
path: root/src/mesa
diff options
context:
space:
mode:
authorLuca Barbieri <[email protected]>2010-09-05 22:29:58 +0200
committerIan Romanick <[email protected]>2010-09-08 20:36:37 -0700
commite591c4625cae63660c5000fbab366e40fe154ab0 (patch)
tree06b65ce727933c9bc7be208085c7400ed5b37f6f /src/mesa
parent6d3a2c97f4a78e85545286e0e126cd3a27bd1cbd (diff)
glsl: add several EmitNo* options, and MaxUnrollIterations
This increases the chance that GLSL programs will actually work. Note that continues and returns are not yet lowered, so linking will just fail if not supported. Signed-off-by: Ian Romanick <[email protected]>
Diffstat (limited to 'src/mesa')
-rw-r--r--src/mesa/drivers/dri/i965/brw_fs.cpp2
-rw-r--r--src/mesa/main/mtypes.h7
-rw-r--r--src/mesa/main/shaderapi.c6
-rw-r--r--src/mesa/program/ir_to_mesa.cpp4
-rw-r--r--src/mesa/state_tracker/st_extensions.c5
5 files changed, 15 insertions, 9 deletions
diff --git a/src/mesa/drivers/dri/i965/brw_fs.cpp b/src/mesa/drivers/dri/i965/brw_fs.cpp
index 25a20e76042..c23e7ce78a5 100644
--- a/src/mesa/drivers/dri/i965/brw_fs.cpp
+++ b/src/mesa/drivers/dri/i965/brw_fs.cpp
@@ -141,7 +141,7 @@ brw_link_shader(GLcontext *ctx, struct gl_shader_program *prog)
do {
progress = false;
- progress = do_common_optimization(shader->ir, true) || progress;
+ progress = do_common_optimization(shader->ir, true, 32) || progress;
} while (progress);
validate_ir_tree(shader->ir);
diff --git a/src/mesa/main/mtypes.h b/src/mesa/main/mtypes.h
index 61cd93c364c..3e54656981d 100644
--- a/src/mesa/main/mtypes.h
+++ b/src/mesa/main/mtypes.h
@@ -2187,7 +2187,6 @@ struct gl_shader_compiler_options
{
/** Driver-selectable options: */
GLboolean EmitHighLevelInstructions; /**< IF/ELSE/ENDIF vs. BRA, etc. */
- GLboolean EmitContReturn; /**< Emit CONT/RET opcodes? */
GLboolean EmitCondCodes; /**< Use condition codes? */
GLboolean EmitComments; /**< Annotated instructions */
GLboolean EmitNVTempInitialization; /**< 0-fill NV temp registers */
@@ -2196,6 +2195,12 @@ struct gl_shader_compiler_options
* support control flow.
*/
GLboolean EmitNoIfs;
+ GLboolean EmitNoLoops;
+ GLboolean EmitNoFunctions;
+ GLboolean EmitNoCont; /**< Emit CONT opcode? */
+ GLboolean EmitNoMainReturn; /**< Emit CONT/RET opcodes? */
+
+ GLuint MaxUnrollIterations;
struct gl_sl_pragmas DefaultPragmas; /**< Default #pragma settings */
};
diff --git a/src/mesa/main/shaderapi.c b/src/mesa/main/shaderapi.c
index 2977a29ab74..c32c09f8d4b 100644
--- a/src/mesa/main/shaderapi.c
+++ b/src/mesa/main/shaderapi.c
@@ -97,10 +97,14 @@ _mesa_init_shader_state(GLcontext *ctx)
struct gl_shader_compiler_options options;
GLuint i;
options.EmitHighLevelInstructions = GL_TRUE;
- options.EmitContReturn = GL_TRUE;
options.EmitCondCodes = GL_FALSE;
options.EmitComments = GL_FALSE;
options.EmitNoIfs = GL_FALSE;
+ options.EmitNoLoops = GL_FALSE;
+ options.EmitNoFunctions = GL_FALSE;
+ options.EmitNoCont = GL_FALSE;
+ options.EmitNoMainReturn = GL_FALSE;
+ options.MaxUnrollIterations = 32;
/* Default pragma settings */
options.DefaultPragmas.IgnoreOptimize = GL_FALSE;
diff --git a/src/mesa/program/ir_to_mesa.cpp b/src/mesa/program/ir_to_mesa.cpp
index b3641032fb0..caa906abfad 100644
--- a/src/mesa/program/ir_to_mesa.cpp
+++ b/src/mesa/program/ir_to_mesa.cpp
@@ -2719,7 +2719,7 @@ _mesa_ir_link_shader(GLcontext *ctx, struct gl_shader_program *prog)
do_div_to_mul_rcp(ir);
do_explog_to_explog2(ir);
- progress = do_common_optimization(ir, true) || progress;
+ progress = do_common_optimization(ir, true, options->MaxUnrollIterations) || progress;
if (options->EmitNoIfs)
progress = do_if_to_cond_assign(ir) || progress;
@@ -2799,7 +2799,7 @@ _mesa_glsl_compile_shader(GLcontext *ctx, struct gl_shader *shader)
/* Do some optimization at compile time to reduce shader IR size
* and reduce later work if the same shader is linked multiple times
*/
- while (do_common_optimization(shader->ir, false))
+ while (do_common_optimization(shader->ir, false, 32))
;
validate_ir_tree(shader->ir);
diff --git a/src/mesa/state_tracker/st_extensions.c b/src/mesa/state_tracker/st_extensions.c
index 82be1494338..91bd5a92c92 100644
--- a/src/mesa/state_tracker/st_extensions.c
+++ b/src/mesa/state_tracker/st_extensions.c
@@ -135,11 +135,8 @@ void st_init_limits(struct st_context *st)
= CLAMP(screen->get_param(screen, PIPE_CAP_MAX_RENDER_TARGETS),
1, MAX_DRAW_BUFFERS);
- /* Is TGSI_OPCODE_CONT supported? */
- /* XXX separate query for early function return? */
for(i = 0; i < MESA_SHADER_TYPES; ++i)
- st->ctx->ShaderCompilerOptions[i].EmitContReturn =
- screen->get_param(screen, PIPE_CAP_TGSI_CONT_SUPPORTED);
+ st->ctx->ShaderCompilerOptions[i].EmitNoCont = !screen->get_param(screen, PIPE_CAP_TGSI_CONT_SUPPORTED);
/* Quads always follow GL provoking rules. */
c->QuadsFollowProvokingVertexConvention = GL_FALSE;