turnip: enable 420_UNORM formats
[mesa.git] / src / freedreno / vulkan / tu_cs.c
index 072a52cbd3c1a75e8a86f1b263c5cdf74ad32e62..809d511fa2bed356084fbdea139d6a422382cf86 100644 (file)
@@ -80,26 +80,6 @@ tu_cs_get_offset(const struct tu_cs *cs)
    return cs->start - (uint32_t *) cs->bos[cs->bo_count - 1]->map;
 }
 
-/**
- * Get the size of the command packets emitted since the last call to
- * tu_cs_add_entry.
- */
-static uint32_t
-tu_cs_get_size(const struct tu_cs *cs)
-{
-   return cs->cur - cs->start;
-}
-
-/**
- * Return true if there is no command packet emitted since the last call to
- * tu_cs_add_entry.
- */
-static uint32_t
-tu_cs_is_empty(const struct tu_cs *cs)
-{
-   return tu_cs_get_size(cs) == 0;
-}
-
 /*
  * Allocate and add a BO to a command stream.  Following command packets will
  * be emitted to the new BO.
@@ -288,7 +268,7 @@ VkResult
 tu_cs_alloc(struct tu_cs *cs,
             uint32_t count,
             uint32_t size,
-            struct ts_cs_memory *memory)
+            struct tu_cs_memory *memory)
 {
    assert(cs->mode == TU_CS_MODE_SUB_STREAM);
    assert(size && size <= 1024);
@@ -364,12 +344,33 @@ tu_cs_reserve_space(struct tu_cs *cs, uint32_t reserved_size)
          tu_cs_add_entry(cs);
       }
 
+      if (cs->cond_flags) {
+         /* Subtract one here to account for the DWORD field itself. */
+         *cs->cond_dwords = cs->cur - cs->cond_dwords - 1;
+
+         /* space for CP_COND_REG_EXEC in next bo */
+         reserved_size += 3;
+      }
+
       /* switch to a new BO */
       uint32_t new_size = MAX2(cs->next_bo_size, reserved_size);
       VkResult result = tu_cs_add_bo(cs, new_size);
       if (result != VK_SUCCESS)
          return result;
 
+      /* if inside a condition, emit a new CP_COND_REG_EXEC */
+      if (cs->cond_flags) {
+         cs->reserved_end = cs->cur + reserved_size;
+
+         tu_cs_emit_pkt7(cs, CP_COND_REG_EXEC, 2);
+         tu_cs_emit(cs, cs->cond_flags);
+
+         cs->cond_dwords = cs->cur;
+
+         /* Emit dummy DWORD field here */
+         tu_cs_emit(cs, CP_COND_REG_EXEC_1_DWORDS(0));
+      }
+
       /* double the size for the next bo */
       new_size <<= 1;
       if (cs->next_bo_size < new_size)