diff options
author | Chia-I Wu <[email protected]> | 2015-05-22 13:49:20 +0800 |
---|---|---|
committer | Chia-I Wu <[email protected]> | 2015-06-14 15:43:20 +0800 |
commit | ab7229b9b6b160e805d14d600a432e76a5e88ef8 (patch) | |
tree | 8519e0bf0128c4c78ceb1fd9e543299672b5bd8a /src | |
parent | 4d35eef326e49cc8da50879d30a1c5088d4775e1 (diff) |
ilo: assert core objects are zero-initialized
Core objects are usually embedded inside calloc()'ed objects and we expect
them to be zero-initialized.
Diffstat (limited to 'src')
-rw-r--r-- | src/gallium/drivers/ilo/core/ilo_buffer.h | 3 | ||||
-rw-r--r-- | src/gallium/drivers/ilo/core/ilo_builder.c | 2 | ||||
-rw-r--r-- | src/gallium/drivers/ilo/core/ilo_debug.h | 17 | ||||
-rw-r--r-- | src/gallium/drivers/ilo/core/ilo_dev.c | 2 | ||||
-rw-r--r-- | src/gallium/drivers/ilo/core/ilo_fence.h | 3 | ||||
-rw-r--r-- | src/gallium/drivers/ilo/core/ilo_image.c | 4 |
6 files changed, 29 insertions, 2 deletions
diff --git a/src/gallium/drivers/ilo/core/ilo_buffer.h b/src/gallium/drivers/ilo/core/ilo_buffer.h index 50f97d10bd7..13e5ce270d6 100644 --- a/src/gallium/drivers/ilo/core/ilo_buffer.h +++ b/src/gallium/drivers/ilo/core/ilo_buffer.h @@ -31,6 +31,7 @@ #include "intel_winsys.h" #include "ilo_core.h" +#include "ilo_debug.h" #include "ilo_dev.h" struct ilo_buffer { @@ -43,6 +44,8 @@ static inline void ilo_buffer_init(struct ilo_buffer *buf, const struct ilo_dev *dev, unsigned size, uint32_t bind, uint32_t flags) { + assert(ilo_is_zeroed(buf, sizeof(*buf))); + buf->bo_size = size; /* diff --git a/src/gallium/drivers/ilo/core/ilo_builder.c b/src/gallium/drivers/ilo/core/ilo_builder.c index 3c5eef9bcbc..4e05a3aca1e 100644 --- a/src/gallium/drivers/ilo/core/ilo_builder.c +++ b/src/gallium/drivers/ilo/core/ilo_builder.c @@ -333,7 +333,7 @@ ilo_builder_init(struct ilo_builder *builder, { int i; - memset(builder, 0, sizeof(*builder)); + assert(ilo_is_zeroed(builder, sizeof(*builder))); builder->dev = dev; builder->winsys = winsys; diff --git a/src/gallium/drivers/ilo/core/ilo_debug.h b/src/gallium/drivers/ilo/core/ilo_debug.h index d9c460498ff..9833233d796 100644 --- a/src/gallium/drivers/ilo/core/ilo_debug.h +++ b/src/gallium/drivers/ilo/core/ilo_debug.h @@ -100,4 +100,21 @@ ilo_warn(const char *format, ...) #endif } +static inline bool +ilo_is_zeroed(const void *ptr, size_t size) +{ +#ifdef DEBUG + size_t i; + + for (i = 0; i < size; i++) { + if (*((const char *) ptr) != 0) + return false; + } + + return true; +#else + return true; +#endif +} + #endif /* ILO_DEBUG_H */ diff --git a/src/gallium/drivers/ilo/core/ilo_dev.c b/src/gallium/drivers/ilo/core/ilo_dev.c index 7a774fa1591..c2cdad72d1a 100644 --- a/src/gallium/drivers/ilo/core/ilo_dev.c +++ b/src/gallium/drivers/ilo/core/ilo_dev.c @@ -40,6 +40,8 @@ ilo_dev_init(struct ilo_dev *dev, struct intel_winsys *winsys) { const struct intel_winsys_info *info; + assert(ilo_is_zeroed(dev, sizeof(*dev))); + info = intel_winsys_get_info(winsys); dev->winsys = winsys; diff --git a/src/gallium/drivers/ilo/core/ilo_fence.h b/src/gallium/drivers/ilo/core/ilo_fence.h index 00d555aa95b..b0b3c061dbc 100644 --- a/src/gallium/drivers/ilo/core/ilo_fence.h +++ b/src/gallium/drivers/ilo/core/ilo_fence.h @@ -31,6 +31,7 @@ #include "intel_winsys.h" #include "ilo_core.h" +#include "ilo_debug.h" #include "ilo_dev.h" struct ilo_fence { @@ -40,7 +41,7 @@ struct ilo_fence { static inline void ilo_fence_init(struct ilo_fence *fence, const struct ilo_dev *dev) { - /* no-op */ + assert(ilo_is_zeroed(fence, sizeof(*fence))); } static inline void diff --git a/src/gallium/drivers/ilo/core/ilo_image.c b/src/gallium/drivers/ilo/core/ilo_image.c index 22c8ef2620a..240595992bf 100644 --- a/src/gallium/drivers/ilo/core/ilo_image.c +++ b/src/gallium/drivers/ilo/core/ilo_image.c @@ -1386,6 +1386,8 @@ void ilo_image_init(struct ilo_image *img, struct ilo_image_params params; bool transfer_only; + assert(ilo_is_zeroed(img, sizeof(*img))); + /* use transfer layout when the texture is never bound to GPU */ transfer_only = !(templ->bind & ~(PIPE_BIND_TRANSFER_WRITE | PIPE_BIND_TRANSFER_READ)); @@ -1411,6 +1413,8 @@ ilo_image_init_for_imported(struct ilo_image *img, { struct ilo_image_params params; + assert(ilo_is_zeroed(img, sizeof(*img))); + if ((tiling == GEN6_TILING_X && bo_stride % 512) || (tiling == GEN6_TILING_Y && bo_stride % 128) || (tiling == GEN8_TILING_W && bo_stride % 64)) |