diff options
author | Jason Ekstrand <[email protected]> | 2015-06-10 12:43:02 -0700 |
---|---|---|
committer | Jason Ekstrand <[email protected]> | 2015-06-10 12:43:02 -0700 |
commit | 047ed02723071d7eccbed3210b5be6ae73603a53 (patch) | |
tree | 3047c27496baf81ab11a113a59e74d4ad368aad6 /src | |
parent | 9cae3d18ac44677fb1c1a4d9c01a1630e62fcb7a (diff) |
vk/emit: Use valgrind to validate every packed field
Diffstat (limited to 'src')
-rw-r--r-- | src/vulkan/gen8_pack.h | 7 | ||||
-rw-r--r-- | src/vulkan/private.h | 2 |
2 files changed, 8 insertions, 1 deletions
diff --git a/src/vulkan/gen8_pack.h b/src/vulkan/gen8_pack.h index aeb5dadd020..54ad55ab490 100644 --- a/src/vulkan/gen8_pack.h +++ b/src/vulkan/gen8_pack.h @@ -32,6 +32,10 @@ #include <stdio.h> #include <assert.h> +#ifndef __gen_validate_value +#define __gen_validate_value(x) +#endif + #ifndef __gen_field_functions #define __gen_field_functions @@ -43,6 +47,7 @@ union __gen_value { static inline uint64_t __gen_field(uint64_t v, uint32_t start, uint32_t end) { + __gen_validate_value(v); #if DEBUG if (end - start + 1 < 64) assert(v < 1ul << (end - start + 1)); @@ -54,6 +59,7 @@ __gen_field(uint64_t v, uint32_t start, uint32_t end) static inline uint64_t __gen_offset(uint64_t v, uint32_t start, uint32_t end) { + __gen_validate_value(v); #if DEBUG uint64_t mask = (~0ul >> (64 - (end - start + 1))) << start; @@ -66,6 +72,7 @@ __gen_offset(uint64_t v, uint32_t start, uint32_t end) static inline uint32_t __gen_float(float v) { + __gen_validate_value(v); return ((union __gen_value) { .f = (v) }).dw; } diff --git a/src/vulkan/private.h b/src/vulkan/private.h index 7ffba4f63b6..095f8f0f86e 100644 --- a/src/vulkan/private.h +++ b/src/vulkan/private.h @@ -34,6 +34,7 @@ #include <valgrind.h> #include <memcheck.h> #define VG(x) x +#define __gen_validate_value(x) VALGRIND_CHECK_MEM_IS_DEFINED(&(x), sizeof(x)) #else #define VG(x) #endif @@ -488,7 +489,6 @@ __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, ...) ({ \ |