aboutsummaryrefslogtreecommitdiffstats
path: root/src/freedreno/vulkan/tu_cs.c
diff options
context:
space:
mode:
authorChia-I Wu <[email protected]>2019-01-16 14:00:43 -0800
committerChia-I Wu <[email protected]>2019-03-11 10:01:41 -0700
commitb01d1618a4d5d3802dce9cfafee072353566a9a8 (patch)
treee445cae5aa99b6589af928a7304e4a6808ddb5fe /src/freedreno/vulkan/tu_cs.c
parentaf4eb208916d0fc2aecf1a0a44bc29cf49441a84 (diff)
turnip: minor cleanup to tu_cs_end
Add comments and error checking.
Diffstat (limited to 'src/freedreno/vulkan/tu_cs.c')
-rw-r--r--src/freedreno/vulkan/tu_cs.c20
1 files changed, 11 insertions, 9 deletions
diff --git a/src/freedreno/vulkan/tu_cs.c b/src/freedreno/vulkan/tu_cs.c
index 155a5df7512..e85925f3a15 100644
--- a/src/freedreno/vulkan/tu_cs.c
+++ b/src/freedreno/vulkan/tu_cs.c
@@ -127,29 +127,31 @@ tu_cs_begin(struct tu_device *dev, struct tu_cs *cs, uint32_t reserve_size)
VkResult
tu_cs_end(struct tu_cs *cs)
{
+ /* no command packet at all */
if (cs->start == cs->cur)
return VK_SUCCESS;
+ /* grow cs->entries if needed */
if (cs->entry_capacity == cs->entry_count) {
uint32_t new_capacity = MAX2(cs->entry_capacity * 2, 4);
struct tu_cs_entry *new_entries =
realloc(cs->entries, new_capacity * sizeof(struct tu_cs_entry));
if (!new_entries)
- abort(); /* TODO */
+ return VK_ERROR_OUT_OF_HOST_MEMORY;
cs->entries = new_entries;
cs->entry_capacity = new_capacity;
}
assert(cs->bo_count);
-
- struct tu_cs_entry entry;
- entry.bo = cs->bos[cs->bo_count - 1];
- entry.size = (cs->cur - cs->start) * sizeof(uint32_t);
- entry.offset = (cs->start - (uint32_t *) entry.bo->map) * sizeof(uint32_t);
-
- cs->entries[cs->entry_count] = entry;
- ++cs->entry_count;
+ const struct tu_bo *bo = cs->bos[cs->bo_count - 1];
+
+ /* add an entry for [cs->start, cs->cur] */
+ cs->entries[cs->entry_count++] = (struct tu_cs_entry) {
+ .bo = bo,
+ .size = (cs->cur - cs->start) * sizeof(uint32_t),
+ .offset = (cs->start - (uint32_t *) bo->map) * sizeof(uint32_t),
+ };
return VK_SUCCESS;
}