diff options
author | Chia-I Wu <[email protected]> | 2019-02-25 14:55:06 -0800 |
---|---|---|
committer | Chia-I Wu <[email protected]> | 2019-03-11 10:02:13 -0700 |
commit | 10c50134422ae166fccfe4fbf4961407b63d20f5 (patch) | |
tree | fa2a84addfa722eb70d9f61e2debc498da992383 /src | |
parent | aa7dd6cb7f54180af91e40e38bf8890c5cc12197 (diff) |
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.
Diffstat (limited to 'src')
-rw-r--r-- | src/freedreno/vulkan/tu_cs.h | 6 |
1 files 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); |