[igt-dev] [PATCH i-g-t 3/5] lib/intel_batchbuffer: Make blitter asserts more useful
Ville Syrjala
ville.syrjala at linux.intel.com
Wed Apr 17 20:35:42 UTC 2019
From: Ville Syrjälä <ville.syrjala at linux.intel.com>
Use igt_assert_lt/lte for the blitter coord/stride asserts
so that we can see what the offending value was. gcc likes
to optimize the values away so gdb often doesn't help as
much as one would like.
Signed-off-by: Ville Syrjälä <ville.syrjala at linux.intel.com>
---
lib/intel_batchbuffer.c | 54 +++++++++++++++++++++++------------------
1 file changed, 30 insertions(+), 24 deletions(-)
diff --git a/lib/intel_batchbuffer.c b/lib/intel_batchbuffer.c
index 712ce1a32da6..422f3b6186aa 100644
--- a/lib/intel_batchbuffer.c
+++ b/lib/intel_batchbuffer.c
@@ -417,16 +417,16 @@ intel_blt_copy(struct intel_batchbuffer *batch,
cmd_bits |= XY_SRC_COPY_BLT_DST_TILED;
}
-#define CHECK_RANGE(x) ((x) >= 0 && (x) < (1 << 15))
- igt_assert(CHECK_RANGE(src_x1) && CHECK_RANGE(src_y1) &&
- CHECK_RANGE(dst_x1) && CHECK_RANGE(dst_y1) &&
- CHECK_RANGE(width) && CHECK_RANGE(height) &&
- CHECK_RANGE(src_x1 + width) &&
- CHECK_RANGE(src_y1 + height) &&
- CHECK_RANGE(dst_x1 + width) &&
- CHECK_RANGE(dst_y1 + height) &&
- CHECK_RANGE(src_pitch) &&
- CHECK_RANGE(dst_pitch));
+#define CHECK_RANGE(x) do { \
+ igt_assert_lte(0, (x)); \
+ igt_assert_lt((x), (1 << 15)); \
+} while (0)
+ CHECK_RANGE(src_x1); CHECK_RANGE(src_y1);
+ CHECK_RANGE(dst_x1); CHECK_RANGE(dst_y1);
+ CHECK_RANGE(width); CHECK_RANGE(height);
+ CHECK_RANGE(src_x1 + width); CHECK_RANGE(src_y1 + height);
+ CHECK_RANGE(dst_x1 + width); CHECK_RANGE(dst_y1 + height);
+ CHECK_RANGE(src_pitch); CHECK_RANGE(dst_pitch);
#undef CHECK_RANGE
br13_bits = 0;
@@ -715,13 +715,16 @@ void igt_blitter_fast_copy__raw(int fd,
dword0 = fast_copy_dword0(src_tiling, dst_tiling);
dword1 = fast_copy_dword1(src_tiling, dst_tiling, bpp);
-#define CHECK_RANGE(x) ((x) >= 0 && (x) < (1 << 15))
- assert(CHECK_RANGE(src_x) && CHECK_RANGE(src_y) &&
- CHECK_RANGE(dst_x) && CHECK_RANGE(dst_y) &&
- CHECK_RANGE(width) && CHECK_RANGE(height) &&
- CHECK_RANGE(src_x + width) && CHECK_RANGE(src_y + height) &&
- CHECK_RANGE(dst_x + width) && CHECK_RANGE(dst_y + height) &&
- CHECK_RANGE(src_pitch) && CHECK_RANGE(dst_pitch));
+#define CHECK_RANGE(x) do { \
+ igt_assert_lte(0, (x)); \
+ igt_assert_lt((x), (1 << 15)); \
+} while (0)
+ CHECK_RANGE(src_x); CHECK_RANGE(src_y);
+ CHECK_RANGE(dst_x); CHECK_RANGE(dst_y);
+ CHECK_RANGE(width); CHECK_RANGE(height);
+ CHECK_RANGE(src_x + width); CHECK_RANGE(src_y + height);
+ CHECK_RANGE(dst_x + width); CHECK_RANGE(dst_y + height);
+ CHECK_RANGE(src_pitch); CHECK_RANGE(dst_pitch);
#undef CHECK_RANGE
batch[i++] = dword0;
@@ -791,13 +794,16 @@ void igt_blitter_fast_copy(struct intel_batchbuffer *batch,
dword0 = fast_copy_dword0(src->tiling, dst->tiling);
dword1 = fast_copy_dword1(src->tiling, dst->tiling, dst->bpp);
-#define CHECK_RANGE(x) ((x) >= 0 && (x) < (1 << 15))
- assert(CHECK_RANGE(src_x) && CHECK_RANGE(src_y) &&
- CHECK_RANGE(dst_x) && CHECK_RANGE(dst_y) &&
- CHECK_RANGE(width) && CHECK_RANGE(height) &&
- CHECK_RANGE(src_x + width) && CHECK_RANGE(src_y + height) &&
- CHECK_RANGE(dst_x + width) && CHECK_RANGE(dst_y + height) &&
- CHECK_RANGE(src_pitch) && CHECK_RANGE(dst_pitch));
+#define CHECK_RANGE(x) do { \
+ igt_assert_lte(0, (x)); \
+ igt_assert_lt((x), (1 << 15)); \
+} while (0)
+ CHECK_RANGE(src_x); CHECK_RANGE(src_y);
+ CHECK_RANGE(dst_x); CHECK_RANGE(dst_y);
+ CHECK_RANGE(width); CHECK_RANGE(height);
+ CHECK_RANGE(src_x + width); CHECK_RANGE(src_y + height);
+ CHECK_RANGE(dst_x + width); CHECK_RANGE(dst_y + height);
+ CHECK_RANGE(src_pitch); CHECK_RANGE(dst_pitch);
#undef CHECK_RANGE
BEGIN_BATCH(10, 2);
--
2.21.0
More information about the igt-dev
mailing list