}
/**
- * End command packet emission and add an IB entry.
+ * End command packet emission. This adds an IB entry when \a cs is in
+ * TU_CS_MODE_GROW mode.
*/
void
tu_cs_end(struct tu_cs *cs)
* Begin command packet emission to a sub-stream. \a cs must be in
* TU_CS_MODE_SUB_STREAM mode.
*
- * Return \a sub_cs which is in TU_CS_MODE_EXTERNAL mode.
+ * Return \a sub_cs which is in TU_CS_MODE_EXTERNAL mode. tu_cs_begin and
+ * tu_cs_reserve_space are implied and \a sub_cs is ready for command packet
+ * emission.
*/
VkResult
tu_cs_begin_sub_stream(struct tu_device *dev,
return result;
tu_cs_init_external(sub_cs, cs->cur, cs->reserved_end);
+ tu_cs_begin(sub_cs);
+ result = tu_cs_reserve_space(dev, sub_cs, size);
+ assert(result == VK_SUCCESS);
return VK_SUCCESS;
}
{
assert(cs->mode == TU_CS_MODE_SUB_STREAM);
assert(cs->bo_count);
- assert(sub_cs->cur >= cs->start && sub_cs->cur <= cs->reserved_end);
+ assert(sub_cs->start == cs->cur && sub_cs->end == cs->reserved_end);
+ tu_cs_sanity_check(sub_cs);
+
+ tu_cs_end(sub_cs);
cs->cur = sub_cs->cur;
- return (struct tu_cs_entry) {
+ struct tu_cs_entry entry = {
.bo = cs->bos[cs->bo_count - 1],
.size = tu_cs_get_size(cs) * sizeof(uint32_t),
.offset = tu_cs_get_offset(cs) * sizeof(uint32_t),
};
+
+ cs->start = cs->cur;
+
+ return entry;
}
/**
VkResult result = tu_cs_add_bo(dev, cs, new_size);
if (result != VK_SUCCESS)
return result;
- cs->next_bo_size = new_size * 2;
+
+ /* double the size for the next bo */
+ new_size <<= 1;
+ if (cs->next_bo_size < new_size)
+ cs->next_bo_size = new_size;
}
assert(tu_cs_get_space(cs) >= reserved_size);