nv50: don't segfault on OPCODE_END for empty programs
authorChristoph Bumiller <e0425955@student.tuwien.ac.at>
Thu, 29 Apr 2010 20:48:00 +0000 (22:48 +0200)
committerChristoph Bumiller <e0425955@student.tuwien.ac.at>
Fri, 30 Apr 2010 20:50:31 +0000 (22:50 +0200)
src/gallium/drivers/nv50/nv50_program.c

index b8b6b12120ba23c23ab8ca7bdacbfe773473133a..98f60821fc6de1220ae87ff5f786c353cad1f27f 100644 (file)
@@ -3169,15 +3169,16 @@ nv50_program_tx_insn(struct nv50_pc *pc,
                if (pc->p->type == PIPE_SHADER_FRAGMENT)
                        nv50_fp_move_results(pc);
 
-               /* last insn must be long so it can have the exit bit set */
-               if (!is_long(pc->p->exec_tail))
-                       convert_to_long(pc, pc->p->exec_tail);
-               else
-               if (is_immd(pc->p->exec_tail) ||
+               if (!pc->p->exec_tail ||
+                   is_immd(pc->p->exec_tail) ||
                    is_join(pc->p->exec_tail) ||
                    is_control_flow(pc->p->exec_tail))
                        emit_nop(pc);
 
+               /* last insn must be long so it can have the exit bit set */
+               if (!is_long(pc->p->exec_tail))
+                       convert_to_long(pc, pc->p->exec_tail);
+
                pc->p->exec_tail->inst[1] |= 1; /* set exit bit */
 
                terminate_mbb(pc);