vulkan/wsi: Use the interface from the real modifiers extension
[mesa.git] / src / freedreno / vulkan / tu_cs.h
index 05e077185042dbdd7d4dd3e6a44d594bb3d69d9c..e5c47d005bead3e102e8cc61bc1528aedd273ece 100644 (file)
@@ -48,6 +48,13 @@ tu_cs_begin_sub_stream(struct tu_device *dev,
                        uint32_t size,
                        struct tu_cs *sub_cs);
 
+VkResult
+tu_cs_alloc(struct tu_device *dev,
+            struct tu_cs *cs,
+            uint32_t count,
+            uint32_t size,
+            struct ts_cs_memory *memory);
+
 struct tu_cs_entry
 tu_cs_end_sub_stream(struct tu_cs *cs, struct tu_cs *sub_cs);
 
@@ -59,6 +66,20 @@ tu_cs_reserve_space(struct tu_device *dev,
 void
 tu_cs_reset(struct tu_device *dev, struct tu_cs *cs);
 
+VkResult
+tu_cs_add_entries(struct tu_cs *cs, struct tu_cs *target);
+
+/**
+ * Discard all entries.  This allows \a cs to be reused while keeping the
+ * existing BOs and command packets intact.
+ */
+static inline void
+tu_cs_discard_entries(struct tu_cs *cs)
+{
+   assert(cs->mode == TU_CS_MODE_GROW);
+   cs->entry_count = 0;
+}
+
 /**
  * Get the size needed for tu_cs_emit_call.
  */
@@ -87,11 +108,22 @@ tu_cs_sanity_check(const struct tu_cs *cs)
 static inline void
 tu_cs_emit(struct tu_cs *cs, uint32_t value)
 {
-   assert(cs->cur < cs->end);
+   assert(cs->cur < cs->reserved_end);
    *cs->cur = value;
    ++cs->cur;
 }
 
+/**
+ * Emit an array of uint32_t into a command stream, without boundary checking.
+ */
+static inline void
+tu_cs_emit_array(struct tu_cs *cs, const uint32_t *values, uint32_t length)
+{
+   assert(cs->cur + length <= cs->reserved_end);
+   memcpy(cs->cur, values, sizeof(uint32_t) * length);
+   cs->cur += length;
+}
+
 static inline unsigned
 tu_odd_parity_bit(unsigned val)
 {
@@ -153,8 +185,10 @@ tu_cs_emit_write_reg(struct tu_cs *cs, uint16_t reg, uint32_t value)
 static inline void
 tu_cs_emit_ib(struct tu_cs *cs, const struct tu_cs_entry *entry)
 {
-   assert(entry->offset % sizeof(uint32_t) == 0);
+   assert(entry->bo);
+   assert(entry->size && entry->offset + entry->size <= entry->bo->size);
    assert(entry->size % sizeof(uint32_t) == 0);
+   assert(entry->offset % sizeof(uint32_t) == 0);
 
    tu_cs_emit_pkt7(cs, CP_INDIRECT_BUFFER, 3);
    tu_cs_emit_qw(cs, entry->bo->iova + entry->offset);