panfrost/midgard: Use unsigned blend patch offset
[mesa.git] / src / gallium / auxiliary / tgsi / tgsi_scan.c
index d776fc7bef10538df509b95146b55bfe4ec833d9..4cb1a3152c3b8faeb9d784a8d3bba647e4d80b00 100644 (file)
@@ -683,6 +683,9 @@ scan_declaration(struct tgsi_shader_info *info,
          case TGSI_SEMANTIC_BASEVERTEX:
             info->uses_basevertex = TRUE;
             break;
+         case TGSI_SEMANTIC_DRAWID:
+            info->uses_drawid = TRUE;
+            break;
          case TGSI_SEMANTIC_PRIMID:
             info->uses_primid = TRUE;
             break;
@@ -1029,11 +1032,12 @@ get_block_tessfactor_writemask(const struct tgsi_shader_info *info,
    struct tgsi_full_instruction *inst;
    unsigned writemask = 0;
 
-   do {
-      tgsi_parse_token(parse);
-      assert(parse->FullToken.Token.Type == TGSI_TOKEN_TYPE_INSTRUCTION);
-      inst = &parse->FullToken.FullInstruction;
-      check_no_subroutines(inst);
+   tgsi_parse_token(parse);
+   assert(parse->FullToken.Token.Type == TGSI_TOKEN_TYPE_INSTRUCTION);
+   inst = &parse->FullToken.FullInstruction;
+   check_no_subroutines(inst);
+
+   while (inst->Instruction.Opcode != end_opcode) {
 
       /* Recursively process nested blocks. */
       switch (inst->Instruction.Opcode) {
@@ -1041,20 +1045,26 @@ get_block_tessfactor_writemask(const struct tgsi_shader_info *info,
       case TGSI_OPCODE_UIF:
          writemask |=
             get_block_tessfactor_writemask(info, parse, TGSI_OPCODE_ENDIF);
-         continue;
+         break;
 
       case TGSI_OPCODE_BGNLOOP:
          writemask |=
             get_block_tessfactor_writemask(info, parse, TGSI_OPCODE_ENDLOOP);
-         continue;
+         break;
 
       case TGSI_OPCODE_BARRIER:
          unreachable("nested BARRIER is illegal");
-         continue;
+         break;
+
+      default:
+         writemask |= get_inst_tessfactor_writemask(info, inst);
       }
 
-      writemask |= get_inst_tessfactor_writemask(info, inst);
-   } while (inst->Instruction.Opcode != end_opcode);
+      tgsi_parse_token(parse);
+      assert(parse->FullToken.Token.Type == TGSI_TOKEN_TYPE_INSTRUCTION);
+      inst = &parse->FullToken.FullInstruction;
+      check_no_subroutines(inst);
+   }
 
    return writemask;
 }
@@ -1068,18 +1078,20 @@ get_if_block_tessfactor_writemask(const struct tgsi_shader_info *info,
    struct tgsi_full_instruction *inst;
    unsigned then_tessfactor_writemask = 0;
    unsigned else_tessfactor_writemask = 0;
+   unsigned writemask;
    bool is_then = true;
 
-   do {
-      tgsi_parse_token(parse);
-      assert(parse->FullToken.Token.Type == TGSI_TOKEN_TYPE_INSTRUCTION);
-      inst = &parse->FullToken.FullInstruction;
-      check_no_subroutines(inst);
+   tgsi_parse_token(parse);
+   assert(parse->FullToken.Token.Type == TGSI_TOKEN_TYPE_INSTRUCTION);
+   inst = &parse->FullToken.FullInstruction;
+   check_no_subroutines(inst);
+
+   while (inst->Instruction.Opcode != TGSI_OPCODE_ENDIF) {
 
       switch (inst->Instruction.Opcode) {
       case TGSI_OPCODE_ELSE:
          is_then = false;
-         continue;
+         break;
 
       /* Recursively process nested blocks. */
       case TGSI_OPCODE_IF:
@@ -1088,28 +1100,33 @@ get_if_block_tessfactor_writemask(const struct tgsi_shader_info *info,
                                            is_then ? &then_tessfactor_writemask :
                                                      &else_tessfactor_writemask,
                                            cond_block_tf_writemask);
-         continue;
+         break;
 
       case TGSI_OPCODE_BGNLOOP:
          *cond_block_tf_writemask |=
             get_block_tessfactor_writemask(info, parse, TGSI_OPCODE_ENDLOOP);
-         continue;
+         break;
 
       case TGSI_OPCODE_BARRIER:
          unreachable("nested BARRIER is illegal");
-         continue;
-      }
-
-      /* Process an instruction in the current block. */
-      unsigned writemask = get_inst_tessfactor_writemask(info, inst);
+         break;
+      default:
+         /* Process an instruction in the current block. */
+         writemask = get_inst_tessfactor_writemask(info, inst);
 
-      if (writemask) {
-         if (is_then)
-            then_tessfactor_writemask |= writemask;
-         else
-            else_tessfactor_writemask |= writemask;
+         if (writemask) {
+            if (is_then)
+               then_tessfactor_writemask |= writemask;
+            else
+               else_tessfactor_writemask |= writemask;
+         }
       }
-   } while (inst->Instruction.Opcode != TGSI_OPCODE_ENDIF);
+
+      tgsi_parse_token(parse);
+      assert(parse->FullToken.Token.Type == TGSI_TOKEN_TYPE_INSTRUCTION);
+      inst = &parse->FullToken.FullInstruction;
+      check_no_subroutines(inst);
+   }
 
    if (then_tessfactor_writemask || else_tessfactor_writemask) {
       /* If both statements write the same tess factor channels,
@@ -1172,7 +1189,7 @@ tgsi_scan_tess_ctrl(const struct tgsi_token *tokens,
 
       case TGSI_OPCODE_BGNLOOP:
          cond_block_tf_writemask |=
-            get_block_tessfactor_writemask(info, &parse, TGSI_OPCODE_ENDIF);
+            get_block_tessfactor_writemask(info, &parse, TGSI_OPCODE_ENDLOOP);
          continue;
 
       case TGSI_OPCODE_BARRIER: