GLboolean EmitCondCodes; /**< Use condition codes? */
GLboolean EmitComments; /**< Annotated instructions */
GLboolean EmitNVTempInitialization; /**< 0-fill NV temp registers */
+ /**
+ * Attempts to flatten all ir_if (OPCODE_IF) for GPUs that can't
+ * support control flow.
+ */
+ GLboolean EmitNoIfs;
void *MemPool;
GLbitfield Flags; /**< Mask of GLSL_x flags */
struct gl_sl_pragmas DefaultPragmas; /**< Default #pragma settings */
}
struct gl_program *
-get_mesa_program(GLcontext *ctx, void *mem_ctx, struct gl_shader *shader)
+get_mesa_program(GLcontext *ctx, struct gl_shader_program *shader_program,
+ struct gl_shader *shader)
{
+ void *mem_ctx = shader_program;
ir_to_mesa_visitor v;
struct prog_instruction *mesa_instructions, *mesa_inst;
ir_instruction **mesa_instruction_annotation;
mesa_inst->TexShadow = inst->tex_shadow;
mesa_instruction_annotation[i] = inst->ir;
+ if (ctx->Shader.EmitNoIfs && mesa_inst->Opcode == OPCODE_IF) {
+ shader_program->InfoLog =
+ talloc_asprintf_append(shader_program->InfoLog,
+ "Couldn't flatten if statement\n");
+ shader_program->LinkStatus = false;
+ }
+
if (mesa_inst->Opcode == OPCODE_BGNSUB)
inst->function->inst = i;
else if (mesa_inst->Opcode == OPCODE_CAL)
progress = do_constant_variable_unlinked(shader->ir) || progress;
progress = do_constant_folding(shader->ir) || progress;
progress = do_if_return(shader->ir) || progress;
+ if (ctx->Shader.EmitNoIfs)
+ progress = do_if_to_cond_assign(shader->ir) || progress;
progress = do_vec_index_to_swizzle(shader->ir) || progress;
/* Do this one after the previous to let the easier pass handle
ctx->Shader.EmitContReturn = GL_TRUE;
ctx->Shader.EmitCondCodes = GL_FALSE;
ctx->Shader.EmitComments = GL_FALSE;
+ ctx->Shader.EmitNoIfs = GL_FALSE;
ctx->Shader.Flags = get_shader_flags();
/* Default pragma settings */