vk: Add valgrind checks in various emit functions
authorJason Ekstrand <jason.ekstrand@intel.com>
Wed, 10 Jun 2015 04:36:12 +0000 (21:36 -0700)
committerJason Ekstrand <jason.ekstrand@intel.com>
Wed, 10 Jun 2015 04:51:37 +0000 (21:51 -0700)
The check in batch_bo_finish should catch any undefined values in the batch
but isn't that great for debugging.  The checks in the various emit
functions will help get better granularity.

src/vulkan/device.c
src/vulkan/private.h

index 4dc527e9f0f02f2211e1c1a6de93f1ed089fcc17..39d818d2656eb66057c98569f7d332f0c27e57fe 100644 (file)
@@ -659,6 +659,7 @@ anv_batch_bo_finish(struct anv_batch_bo *bbo, struct anv_batch *batch)
 {
    assert(batch->start == bbo->bo.map);
    bbo->length = batch->next - batch->start;
+   VG(VALGRIND_CHECK_MEM_IS_DEFINED(batch->start, bbo->length));
    bbo->num_relocs = batch->relocs.num_relocs - bbo->first_reloc;
 }
 
@@ -3070,6 +3071,8 @@ anv_cmd_buffer_emit_dynamic(struct anv_cmd_buffer *cmd_buffer,
                                   dwords * 4, alignment);
    memcpy(state.map, a, dwords * 4);
 
+   VG(VALGRIND_CHECK_MEM_IS_DEFINED(state.map, dwords * 4));
+
    return state;
 }
 
@@ -3087,6 +3090,8 @@ anv_cmd_buffer_merge_dynamic(struct anv_cmd_buffer *cmd_buffer,
    for (uint32_t i = 0; i < dwords; i++)
       p[i] = a[i] | b[i];
 
+   VG(VALGRIND_CHECK_MEM_IS_DEFINED(p, dwords * 4));
+
    return state;
 }
 
index 84c0524ad3c25222c1666e07f9a0aed1f66572f8..7ffba4f63b62950fbc04f8bc9bee26e4e22810fb 100644 (file)
@@ -488,6 +488,7 @@ __gen_combine_address(struct anv_batch *batch, void *location,
       };                                                                \
       void *__dst = anv_batch_emit_dwords(batch, cmd ## _length);       \
       cmd ## _pack(batch, __dst, &__template);                          \
+      VG(VALGRIND_CHECK_MEM_IS_DEFINED(__dst, (cmd ## _length) * 4));   \
    } while (0)
 
 #define anv_batch_emitn(batch, n, cmd, ...) ({          \
@@ -509,6 +510,7 @@ __gen_combine_address(struct anv_batch *batch, void *location,
       dw = anv_batch_emit_dwords((batch), ARRAY_SIZE(dwords0));         \
       for (uint32_t i = 0; i < ARRAY_SIZE(dwords0); i++)                \
          dw[i] = (dwords0)[i] | (dwords1)[i];                           \
+      VG(VALGRIND_CHECK_MEM_IS_DEFINED(dw, ARRAY_SIZE(dwords0) * 4));\
    } while (0)
 
 #define GEN8_MOCS {                                     \