From 10c50134422ae166fccfe4fbf4961407b63d20f5 Mon Sep 17 00:00:00 2001 From: Chia-I Wu Date: Mon, 25 Feb 2019 14:55:06 -0800 Subject: [PATCH] turnip: more/better asserts for tu_cs Asserting (cur < end) in tu_cs_emit catches much less programming errors comparing to asserting (cur < reserved_end). We should never write more commands than what we have reserved. Assert IB is non-empty and sane in tu_cs_emit_ib. --- src/freedreno/vulkan/tu_cs.h | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/freedreno/vulkan/tu_cs.h b/src/freedreno/vulkan/tu_cs.h index 05e07718504..24053c0af88 100644 --- a/src/freedreno/vulkan/tu_cs.h +++ b/src/freedreno/vulkan/tu_cs.h @@ -87,7 +87,7 @@ 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; } @@ -153,8 +153,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); -- 2.30.2