memset(&cmd_buffer->state, 0, sizeof(cmd_buffer->state));
cmd_buffer->usage_flags = pBeginInfo->flags;
- result = tu_cs_begin(cmd_buffer->device, &cmd_buffer->cs, 4096);
- if (result != VK_SUCCESS)
- return result;
+ tu_cs_begin(&cmd_buffer->cs);
cmd_buffer->marker_seqno = 0;
cmd_buffer->scratch_seqno = 0;
MSM_SUBMIT_BO_WRITE);
}
- VkResult result = tu_cs_end(&cmd_buffer->cs);
- if (result != VK_SUCCESS)
- cmd_buffer->record_result = result;
+ tu_cs_end(&cmd_buffer->cs);
assert(!cmd_buffer->state.attachments);
static VkResult
tu_cs_add_bo(struct tu_device *dev, struct tu_cs *cs, uint32_t size)
{
+ /* no dangling command packet */
+ assert(tu_cs_is_empty(cs));
+
/* grow cs->bos if needed */
if (cs->bo_count == cs->bo_capacity) {
uint32_t new_capacity = MAX2(4, 2 * cs->bo_capacity);
* Reserve an IB entry.
*/
static VkResult
-tu_cs_reserve_entry(struct tu_cs *cs)
+tu_cs_reserve_entry(struct tu_device *dev, struct tu_cs *cs)
{
/* grow cs->entries if needed */
if (cs->entry_count == cs->entry_capacity) {
}
/**
- * Begin (or continue) command packet emission. This will reserve space from
- * the command stream for at least \a reserve_size uint32_t values.
+ * Begin (or continue) command packet emission. This does nothing but sanity
+ * checks currently.
*/
-VkResult
-tu_cs_begin(struct tu_device *dev, struct tu_cs *cs, uint32_t reserve_size)
+void
+tu_cs_begin(struct tu_cs *cs)
{
- /* no dangling command packet */
assert(tu_cs_is_empty(cs));
+}
- if (tu_cs_get_space(cs) < reserve_size) {
- uint32_t new_size = MAX2(cs->next_bo_size, reserve_size);
- VkResult result = tu_cs_add_bo(dev, cs, new_size);
- if (result != VK_SUCCESS)
- return result;
-
- cs->next_bo_size = new_size * 2;
- }
-
- assert(tu_cs_get_space(cs) >= reserve_size);
-
- return VK_SUCCESS;
+/**
+ * End command packet emission and add an IB entry.
+ */
+void
+tu_cs_end(struct tu_cs *cs)
+{
+ if (!tu_cs_is_empty(cs))
+ tu_cs_add_entry(cs);
}
/**
- * End command packet emission by adding an IB entry for the command packets
- * emitted since the last call to tu_cs_begin.
+ * Reserve space from a command stream for \a reserved_size uint32_t values.
*/
VkResult
-tu_cs_end(struct tu_cs *cs)
+tu_cs_reserve_space(struct tu_device *dev,
+ struct tu_cs *cs,
+ uint32_t reserved_size)
{
- /* no command packet at all */
- if (tu_cs_is_empty(cs))
- return VK_SUCCESS;
+ if (tu_cs_get_space(cs) < reserved_size) {
+ /* add an entry for the exiting command packets */
+ if (!tu_cs_is_empty(cs))
+ tu_cs_add_entry(cs);
- VkResult result = tu_cs_reserve_entry(cs);
- if (result != VK_SUCCESS)
- return result;
+ /* switch to a new BO */
+ uint32_t new_size = MAX2(cs->next_bo_size, reserved_size);
+ VkResult result = tu_cs_add_bo(dev, cs, new_size);
+ if (result != VK_SUCCESS)
+ return result;
+ cs->next_bo_size = new_size * 2;
+ }
- tu_cs_add_entry(cs);
+ assert(tu_cs_get_space(cs) >= reserved_size);
+ cs->reserved_end = cs->cur + reserved_size;
- return VK_SUCCESS;
+ /* reserve an entry for the next call to this function or tu_cs_end */
+ return tu_cs_reserve_entry(dev, cs);
}
/**
void
tu_cs_init(struct tu_cs *cs, uint32_t initial_size);
+
void
tu_cs_finish(struct tu_device *dev, struct tu_cs *cs);
-VkResult
-tu_cs_begin(struct tu_device *dev, struct tu_cs *cs, uint32_t reserve_size);
-VkResult
-tu_cs_end(struct tu_cs *cs);
-void
-tu_cs_reset(struct tu_device *dev, struct tu_cs *cs);
-
-/**
- * Reserve space from a command stream for \a size uint32_t values.
- */
-static inline VkResult
-tu_cs_reserve_space(struct tu_device *dev, struct tu_cs *cs, size_t size)
-{
- if (cs->end - cs->cur >= size) {
- cs->reserved_end = cs->cur + size;
- return VK_SUCCESS;
- }
- VkResult result = tu_cs_end(cs);
- if (result != VK_SUCCESS)
- return result;
+void
+tu_cs_begin(struct tu_cs *cs);
- result = tu_cs_begin(dev, cs, size);
- if (result != VK_SUCCESS)
- return result;
+void
+tu_cs_end(struct tu_cs *cs);
- cs->reserved_end = cs->cur + size;
- assert(cs->reserved_end <= cs->end);
+VkResult
+tu_cs_reserve_space(struct tu_device *dev,
+ struct tu_cs *cs,
+ uint32_t reserved_size);
- return VK_SUCCESS;
-}
+void
+tu_cs_reset(struct tu_device *dev, struct tu_cs *cs);
/**
* Assert that we did not exceed the reserved space.