summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/freedreno/vulkan/tu_cmd_buffer.c8
-rw-r--r--src/freedreno/vulkan/tu_cs.c65
-rw-r--r--src/freedreno/vulkan/tu_cs.h38
3 files changed, 49 insertions, 62 deletions
diff --git a/src/freedreno/vulkan/tu_cmd_buffer.c b/src/freedreno/vulkan/tu_cmd_buffer.c
index 0544313bf66..346f5f29ff5 100644
--- a/src/freedreno/vulkan/tu_cmd_buffer.c
+++ b/src/freedreno/vulkan/tu_cmd_buffer.c
@@ -945,9 +945,7 @@ tu_BeginCommandBuffer(VkCommandBuffer commandBuffer,
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;
@@ -1019,9 +1017,7 @@ tu_EndCommandBuffer(VkCommandBuffer commandBuffer)
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);
diff --git a/src/freedreno/vulkan/tu_cs.c b/src/freedreno/vulkan/tu_cs.c
index 81bf36e9a87..0e3d4e99b42 100644
--- a/src/freedreno/vulkan/tu_cs.c
+++ b/src/freedreno/vulkan/tu_cs.c
@@ -96,6 +96,9 @@ tu_cs_is_empty(const struct tu_cs *cs)
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);
@@ -137,7 +140,7 @@ tu_cs_add_bo(struct tu_device *dev, struct tu_cs *cs, uint32_t size)
* 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) {
@@ -182,47 +185,51 @@ tu_cs_add_entry(struct tu_cs *cs)
}
/**
- * 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);
}
/**
diff --git a/src/freedreno/vulkan/tu_cs.h b/src/freedreno/vulkan/tu_cs.h
index 4c184dac8f9..43835d147f6 100644
--- a/src/freedreno/vulkan/tu_cs.h
+++ b/src/freedreno/vulkan/tu_cs.h
@@ -29,39 +29,23 @@
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.