* Determine if the given shader uses complex features such as flow
* conditionals, loops, subroutines.
*/
-GLboolean brw_wm_has_flow_control(const struct brw_fragment_shader *fp)
+static GLboolean has_flow_control(const struct tgsi_shader_info *info)
{
- return (fp->info.opcode_count[TGSI_OPCODE_ARL] > 0 ||
- fp->info.opcode_count[TGSI_OPCODE_IF] > 0 ||
- fp->info.opcode_count[TGSI_OPCODE_ENDIF] > 0 || /* redundant - IF */
- fp->info.opcode_count[TGSI_OPCODE_CAL] > 0 ||
- fp->info.opcode_count[TGSI_OPCODE_BRK] > 0 || /* redundant - BGNLOOP */
- fp->info.opcode_count[TGSI_OPCODE_RET] > 0 || /* redundant - CAL */
- fp->info.opcode_count[TGSI_OPCODE_BGNLOOP] > 0);
+ return (info->opcode_count[TGSI_OPCODE_ARL] > 0 ||
+ info->opcode_count[TGSI_OPCODE_IF] > 0 ||
+ info->opcode_count[TGSI_OPCODE_ENDIF] > 0 || /* redundant - IF */
+ info->opcode_count[TGSI_OPCODE_CAL] > 0 ||
+ info->opcode_count[TGSI_OPCODE_BRK] > 0 || /* redundant - BGNLOOP */
+ info->opcode_count[TGSI_OPCODE_RET] > 0 || /* redundant - CAL */
+ info->opcode_count[TGSI_OPCODE_BGNLOOP] > 0);
}
/* Duplicate tokens, scan shader
*/
fs->id = brw->program_id++;
- fs->has_flow_control = brw_wm_has_flow_control(fs);
+ fs->has_flow_control = has_flow_control(&fs->info);
fs->tokens = tgsi_dup_tokens(shader->tokens);
if (fs->tokens == NULL)
/* Duplicate tokens, scan shader
*/
vs->id = brw->program_id++;
- //vs->has_flow_control = brw_wm_has_flow_control(vs);
+ vs->has_flow_control = has_flow_control(&vs->info);
vs->tokens = tgsi_dup_tokens(shader->tokens);
if (vs->tokens == NULL)
}
#endif
- c->stack = brw_uw16_reg(BRW_GENERAL_REGISTER_FILE, reg, 0);
- reg += 2;
+ if (c->vp->has_flow_control) {
+ c->stack = brw_uw16_reg(BRW_GENERAL_REGISTER_FILE, reg, 0);
+ reg += 2;
+ }
/* Some opcodes need an internal temporary:
*/
/* Static register allocation
*/
brw_vs_alloc_regs(c);
- brw_MOV(p, get_addr_reg(c->stack_index), brw_address(c->stack));
+
+ if (c->vp->has_flow_control) {
+ brw_MOV(p, get_addr_reg(c->stack_index), brw_address(c->stack));
+ }
/* Instructions
*/