turnip: add tu_cs_sanity_check
authorChia-I Wu <olvaffe@gmail.com>
Tue, 29 Jan 2019 00:31:54 +0000 (16:31 -0800)
committerChia-I Wu <olvaffe@gmail.com>
Mon, 11 Mar 2019 17:02:13 +0000 (10:02 -0700)
It replaces tu_cs_reserve_space_assert and can be called at any
time to sanity check tu_cs.

src/freedreno/vulkan/tu_cmd_buffer.c
src/freedreno/vulkan/tu_cs.c
src/freedreno/vulkan/tu_cs.h
src/freedreno/vulkan/tu_private.h

index 346f5f29ff56e0b8764d8c7e77782da26a6ce362..541a37b6dde7f4762da1c44e3f307fd34dc7b8b1 100644 (file)
@@ -511,7 +511,7 @@ tu6_init_hw(struct tu_cmd_buffer *cmd)
    tu_cs_emit_pkt4(cs, REG_A6XX_RB_LRZ_CNTL, 1);
    tu_cs_emit(cs, 0x00000000);
 
-   tu_cs_reserve_space_assert(cs);
+   tu_cs_sanity_check(cs);
 }
 
 static void
index 0e3d4e99b42b91af12999d363e9d3a53f4ada76b..f4bec106934a9a9f4b0b5410659e19c0f079ba37 100644 (file)
@@ -130,7 +130,7 @@ tu_cs_add_bo(struct tu_device *dev, struct tu_cs *cs, uint32_t size)
 
    cs->bos[cs->bo_count++] = new_bo;
 
-   cs->start = cs->cur = (uint32_t *) new_bo->map;
+   cs->start = cs->cur = cs->reserved_end = (uint32_t *) new_bo->map;
    cs->end = cs->start + new_bo->size / sizeof(uint32_t);
 
    return VK_SUCCESS;
@@ -248,7 +248,7 @@ tu_cs_reset(struct tu_device *dev, struct tu_cs *cs)
       cs->bos[0] = cs->bos[cs->bo_count - 1];
       cs->bo_count = 1;
 
-      cs->start = cs->cur = (uint32_t *) cs->bos[0]->map;
+      cs->start = cs->cur = cs->reserved_end = (uint32_t *) cs->bos[0]->map;
       cs->end = cs->start + cs->bos[0]->size / sizeof(uint32_t);
    }
 
index 43835d147f640d1e054f21bd89a06fa04863a6cd..c28d8de76c736edb6a4a4db0bfba771adf80c255 100644 (file)
@@ -51,9 +51,11 @@ tu_cs_reset(struct tu_device *dev, struct tu_cs *cs);
  * Assert that we did not exceed the reserved space.
  */
 static inline void
-tu_cs_reserve_space_assert(struct tu_cs *cs)
+tu_cs_sanity_check(const struct tu_cs *cs)
 {
+   assert(cs->start <= cs->cur);
    assert(cs->cur <= cs->reserved_end);
+   assert(cs->reserved_end <= cs->end);
 }
 
 /**
index cd724ea1b9d2ff03667efddfcbd038f83441809b..205d5c0f13f0db9d203c6264ffb91e08ef3c714b 100644 (file)
@@ -781,10 +781,8 @@ struct tu_cs
 {
    uint32_t *start;
    uint32_t *cur;
-   uint32_t *end;
-
-   /* for tu_cs_reserve_space_assert */
    uint32_t *reserved_end;
+   uint32_t *end;
 
    uint32_t next_bo_size;