@@ -84,6 +84,7 @@ static const struct debug_control debug_control[] = {
{ "nohiz", DEBUG_NO_HIZ },
{ "color", DEBUG_COLOR },
{ "reemit", DEBUG_REEMIT },
+ { "check_scratch", DEBUG_CHECK_SCRATH },
{ NULL, 0 }
};
@@ -83,6 +83,7 @@ extern uint64_t INTEL_DEBUG;
#define DEBUG_NO_HIZ (1ull << 39)
#define DEBUG_COLOR (1ull << 40)
#define DEBUG_REEMIT (1ull << 41)
+#define DEBUG_CHECK_SCRATH (1ull << 42)
#ifdef HAVE_ANDROID_PLATFORM
#define LOG_TAG "INTEL-MESA"
@@ -1557,6 +1557,12 @@ intelDestroyScreen(__DRIscreen * sPriv)
brw_bufmgr_destroy(screen->bufmgr);
driDestroyOptionInfo(&screen->optionCache);
+ if (screen->debug_batchbuffer.enabled) {
+ simple_mtx_destroy(&screen->debug_batchbuffer.mutex);
+ free(screen->debug_batchbuffer.noise_values);
+ free(screen->debug_batchbuffer.tmp);
+ }
+
ralloc_free(screen);
sPriv->driverPrivate = NULL;
}
@@ -2610,6 +2616,26 @@ __DRIconfig **intelInitScreen2(__DRIscreen *dri_screen)
}
}
+ screen->debug_batchbuffer.enabled = false;
+ if (INTEL_DEBUG & DEBUG_CHECK_SCRATH) {
+ struct drm_i915_scratch_page sc;
+ int err;
+
+ sc.buffer_size = 0;
+ sc.buffer_ptr = 0;
+ err = drmIoctl(dri_screen->fd, DRM_IOCTL_I915_READ_SCRATCH_PAGE, &sc);
+ if (err == 0) {
+ screen->debug_batchbuffer.enabled = true;
+ simple_mtx_init(&screen->debug_batchbuffer.mutex, mtx_plain);
+ screen->debug_batchbuffer.buffer_size = sc.buffer_size;
+ screen->debug_batchbuffer.noise_values = calloc(screen->debug_batchbuffer.buffer_size, 1);
+ screen->debug_batchbuffer.tmp = calloc(screen->debug_batchbuffer.buffer_size, 1);
+ for (uint64_t i = 0; i < screen->debug_batchbuffer.buffer_size; ++i) {
+ screen->debug_batchbuffer.noise_values[i] = rand() & 0xFF;
+ }
+ }
+ }
+
return (const __DRIconfig**) intel_screen_make_configs(dri_screen);
}
@@ -37,6 +37,7 @@
#include "common/gen_device_info.h"
#include "i915_drm.h"
#include "util/xmlconfig.h"
+#include "util/simple_mtx.h"
#include "isl/isl.h"
@@ -114,6 +115,17 @@ struct intel_screen
*/
int eu_total;
+ /**
+ * Struct to perform out-of-bound GEM BO write checking
+ */
+ struct {
+ bool enabled;
+ simple_mtx_t mutex;
+ uint32_t buffer_size;
+ uint8_t *noise_values;
+ uint8_t *tmp;
+ } debug_batchbuffer;
+
bool mesa_format_supports_texture[MESA_FORMAT_COUNT];
bool mesa_format_supports_render[MESA_FORMAT_COUNT];
enum isl_format mesa_to_isl_render_format[MESA_FORMAT_COUNT];
From: Kevin Rogovin <kevin.rogovin@intel.com> --- src/intel/common/gen_debug.c | 1 + src/intel/common/gen_debug.h | 1 + src/mesa/drivers/dri/i965/intel_screen.c | 26 ++++++++++++++++++++++++++ src/mesa/drivers/dri/i965/intel_screen.h | 12 ++++++++++++ 4 files changed, 40 insertions(+)