if ((flags & __DRI_CTX_FLAG_FORWARD_COMPATIBLE) != 0)
ctx->Const.ContextFlags |= GL_CONTEXT_FLAG_FORWARD_COMPATIBLE_BIT;
- if ((flags & __DRI_CTX_FLAG_DEBUG) != 0)
+ if ((flags & __DRI_CTX_FLAG_DEBUG) != 0) {
ctx->Const.ContextFlags |= GL_CONTEXT_FLAG_DEBUG_BIT;
+ /* Turn on some extra GL_ARB_debug_output generation. */
+ intel->perf_debug = true;
+ }
+
brw_fs_alloc_reg_sets(brw);
if (INTEL_DEBUG & DEBUG_SHADER_TIME)
GLuint max_index,
struct gl_transform_feedback_object *tfb_vertcount )
{
+ struct intel_context *intel = intel_context(ctx);
const struct gl_client_array **arrays = ctx->Array._DrawArrays;
if (!_mesa_check_conditional_render(ctx))
bool start_busy = false;
float start_time = 0;
- if (unlikely(INTEL_DEBUG & DEBUG_PERF)) {
+ if (unlikely(intel->perf_debug)) {
start_busy = (intel->batch.last_bo &&
drm_intel_bo_busy(intel->batch.last_bo));
start_time = get_time();
simd16_instructions,
final_assembly_size);
- if (unlikely(INTEL_DEBUG & DEBUG_PERF) && shader) {
+ if (unlikely(intel->perf_debug) && shader) {
if (shader->compiled_once)
brw_wm_debug_recompile(brw, prog, &c->key);
shader->compiled_once = true;
void brw_populate_sampler_prog_key_data(struct gl_context *ctx,
const struct gl_program *prog,
struct brw_sampler_prog_key_data *key);
-bool brw_debug_recompile_sampler_key(const struct brw_sampler_prog_key_data *old_key,
+bool brw_debug_recompile_sampler_key(struct intel_context *intel,
+ const struct brw_sampler_prog_key_data *old_key,
const struct brw_sampler_prog_key_data *key);
void brw_add_texrect_params(struct gl_program *prog);
if (drm_intel_bo_references(intel->batch.bo, query->bo))
intel_batchbuffer_flush(intel);
- if (unlikely(INTEL_DEBUG & DEBUG_PERF)) {
+ if (unlikely(intel->perf_debug)) {
if (drm_intel_bo_busy(query->bo)) {
perf_debug("Stalling on the GPU waiting for a query object.\n");
}
lower_variable_index_to_cond_assign(shader->ir,
input, output, temp, uniform);
- if (unlikely((INTEL_DEBUG & DEBUG_PERF) && lowered_variable_indexing)) {
+ if (unlikely((intel->perf_debug) && lowered_variable_indexing)) {
perf_debug("Unsupported form of variable indexing in FS; falling "
"back to very inefficient code generation\n");
}
void
brw_state_cache_check_size(struct brw_context *brw)
{
+ struct intel_context *intel = &brw->intel;
+
/* un-tuned guess. Each object is generally a page, so 2000 of them is 8 MB of
* state cache.
*/
bool start_busy = false;
float start_time = 0;
- if (unlikely(INTEL_DEBUG & DEBUG_PERF)) {
+ if (unlikely(intel->perf_debug)) {
start_busy = (intel->batch.last_bo &&
drm_intel_bo_busy(intel->batch.last_bo));
start_time = get_time();
const unsigned *generated =g.generate_assembly(&v.instructions,
final_assembly_size);
- if (unlikely(INTEL_DEBUG & DEBUG_PERF) && shader) {
+ if (unlikely(intel->perf_debug) && shader) {
if (shader->compiled_once) {
brw_vs_debug_recompile(brw, prog, &c->key);
}
}
static bool
-key_debug(const char *name, int a, int b)
+key_debug(struct intel_context *intel, const char *name, int a, int b)
{
if (a != b) {
perf_debug(" %s %d->%d\n", name, a, b);
struct gl_shader_program *prog,
const struct brw_vs_prog_key *key)
{
+ struct intel_context *intel = &brw->intel;
struct brw_cache_item *c = NULL;
const struct brw_vs_prog_key *old_key = NULL;
bool found = false;
}
for (unsigned int i = 0; i < VERT_ATTRIB_MAX; i++) {
- found |= key_debug("Vertex attrib w/a flags",
+ found |= key_debug(intel, "Vertex attrib w/a flags",
old_key->gl_attrib_wa_flags[i],
key->gl_attrib_wa_flags[i]);
}
- found |= key_debug("user clip flags",
+ found |= key_debug(intel, "user clip flags",
old_key->userclip_active, key->userclip_active);
- found |= key_debug("user clipping planes as push constants",
+ found |= key_debug(intel, "user clipping planes as push constants",
old_key->nr_userclip_plane_consts,
key->nr_userclip_plane_consts);
- found |= key_debug("clip distance enable",
+ found |= key_debug(intel, "clip distance enable",
old_key->uses_clip_distance, key->uses_clip_distance);
- found |= key_debug("clip plane enable bitfield",
+ found |= key_debug(intel, "clip plane enable bitfield",
old_key->userclip_planes_enabled_gen_4_5,
key->userclip_planes_enabled_gen_4_5);
- found |= key_debug("copy edgeflag",
+ found |= key_debug(intel, "copy edgeflag",
old_key->copy_edgeflag, key->copy_edgeflag);
- found |= key_debug("PointCoord replace",
+ found |= key_debug(intel, "PointCoord replace",
old_key->point_coord_replace, key->point_coord_replace);
- found |= key_debug("vertex color clamping",
+ found |= key_debug(intel, "vertex color clamping",
old_key->clamp_vertex_color, key->clamp_vertex_color);
- found |= brw_debug_recompile_sampler_key(&old_key->tex, &key->tex);
+ found |= brw_debug_recompile_sampler_key(intel, &old_key->tex, &key->tex);
if (!found) {
perf_debug(" Something else\n");
}
static bool
-key_debug(const char *name, int a, int b)
+key_debug(struct intel_context *intel, const char *name, int a, int b)
{
if (a != b) {
perf_debug(" %s %d->%d\n", name, a, b);
}
bool
-brw_debug_recompile_sampler_key(const struct brw_sampler_prog_key_data *old_key,
+brw_debug_recompile_sampler_key(struct intel_context *intel,
+ const struct brw_sampler_prog_key_data *old_key,
const struct brw_sampler_prog_key_data *key)
{
bool found = false;
for (unsigned int i = 0; i < MAX_SAMPLERS; i++) {
- found |= key_debug("EXT_texture_swizzle or DEPTH_TEXTURE_MODE",
+ found |= key_debug(intel, "EXT_texture_swizzle or DEPTH_TEXTURE_MODE",
old_key->swizzles[i], key->swizzles[i]);
}
- found |= key_debug("GL_CLAMP enabled on any texture unit's 1st coordinate",
+ found |= key_debug(intel, "GL_CLAMP enabled on any texture unit's 1st coordinate",
old_key->gl_clamp_mask[0], key->gl_clamp_mask[0]);
- found |= key_debug("GL_CLAMP enabled on any texture unit's 2nd coordinate",
+ found |= key_debug(intel, "GL_CLAMP enabled on any texture unit's 2nd coordinate",
old_key->gl_clamp_mask[1], key->gl_clamp_mask[1]);
- found |= key_debug("GL_CLAMP enabled on any texture unit's 3rd coordinate",
+ found |= key_debug(intel, "GL_CLAMP enabled on any texture unit's 3rd coordinate",
old_key->gl_clamp_mask[2], key->gl_clamp_mask[2]);
- found |= key_debug("GL_MESA_ycbcr texturing\n",
+ found |= key_debug(intel, "GL_MESA_ycbcr texturing\n",
old_key->yuvtex_mask, key->yuvtex_mask);
- found |= key_debug("GL_MESA_ycbcr UV swapping\n",
+ found |= key_debug(intel, "GL_MESA_ycbcr UV swapping\n",
old_key->yuvtex_swap_mask, key->yuvtex_swap_mask);
return found;
struct gl_shader_program *prog,
const struct brw_wm_prog_key *key)
{
+ struct intel_context *intel = &brw->intel;
struct brw_cache_item *c = NULL;
const struct brw_wm_prog_key *old_key = NULL;
bool found = false;
}
if (!c) {
- perf_debug(" Didn't find previous compile in the shader cache for "
- "debug\n");
+ perf_debug(" Didn't find previous compile in the shader cache for debug\n");
return;
}
- found |= key_debug("alphatest, computed depth, depth test, or depth write",
+ found |= key_debug(intel, "alphatest, computed depth, depth test, or "
+ "depth write",
old_key->iz_lookup, key->iz_lookup);
- found |= key_debug("depth statistics", old_key->stats_wm, key->stats_wm);
- found |= key_debug("flat shading", old_key->flat_shade, key->flat_shade);
- found |= key_debug("number of color buffers", old_key->nr_color_regions, key->nr_color_regions);
- found |= key_debug("sample alpha to coverage", old_key->sample_alpha_to_coverage, key->sample_alpha_to_coverage);
- found |= key_debug("rendering to FBO", old_key->render_to_fbo, key->render_to_fbo);
- found |= key_debug("fragment color clamping", old_key->clamp_fragment_color, key->clamp_fragment_color);
- found |= key_debug("line smoothing", old_key->line_aa, key->line_aa);
- found |= key_debug("proj_attrib_mask", old_key->proj_attrib_mask, key->proj_attrib_mask);
- found |= key_debug("renderbuffer height", old_key->drawable_height, key->drawable_height);
- found |= key_debug("vertex shader outputs", old_key->vp_outputs_written, key->vp_outputs_written);
-
- found |= brw_debug_recompile_sampler_key(&old_key->tex, &key->tex);
+ found |= key_debug(intel, "depth statistics",
+ old_key->stats_wm, key->stats_wm);
+ found |= key_debug(intel, "flat shading",
+ old_key->flat_shade, key->flat_shade);
+ found |= key_debug(intel, "number of color buffers",
+ old_key->nr_color_regions, key->nr_color_regions);
+ found |= key_debug(intel, "sample alpha to coverage",
+ old_key->sample_alpha_to_coverage, key->sample_alpha_to_coverage);
+ found |= key_debug(intel, "rendering to FBO",
+ old_key->render_to_fbo, key->render_to_fbo);
+ found |= key_debug(intel, "fragment color clamping",
+ old_key->clamp_fragment_color, key->clamp_fragment_color);
+ found |= key_debug(intel, "line smoothing",
+ old_key->line_aa, key->line_aa);
+ found |= key_debug(intel, "proj_attrib_mask",
+ old_key->proj_attrib_mask, key->proj_attrib_mask);
+ found |= key_debug(intel, "renderbuffer height",
+ old_key->drawable_height, key->drawable_height);
+ found |= key_debug(intel, "vertex shader outputs",
+ old_key->vp_outputs_written, key->vp_outputs_written);
+
+ found |= brw_debug_recompile_sampler_key(intel, &old_key->tex, &key->tex);
if (!found) {
perf_debug(" Something else\n");
drm_intel_bo_unreference(temp_bo);
}
} else {
- if (unlikely(INTEL_DEBUG & DEBUG_PERF)) {
+ if (unlikely(intel->perf_debug)) {
if (drm_intel_bo_busy(intel_obj->buffer)) {
perf_debug("Stalling on the GPU in glBufferSubData().\n");
}
"shader_time debugging requires gen7 (Ivybridge) or better.\n");
INTEL_DEBUG &= ~DEBUG_SHADER_TIME;
}
+ if (INTEL_DEBUG & DEBUG_PERF)
+ intel->perf_debug = true;
if (INTEL_DEBUG & DEBUG_AUB)
drm_intel_bufmgr_gem_set_aub_dump(intel->bufmgr, true);
bool no_batch_wrap;
bool tnl_pipeline_running; /**< Set while i915's _tnl_run_pipeline. */
+ /**
+ * Set if we're either a debug context or the INTEL_DEBUG=perf environment
+ * variable is set, this is the flag indicating to do expensive work that
+ * might lead to a perf_debug() call.
+ */
+ bool perf_debug;
+
struct
{
GLuint id;
} while(0)
#define perf_debug(...) do { \
- if (unlikely(INTEL_DEBUG & DEBUG_PERF)) \
- dbg_printf(__VA_ARGS__); \
+ static GLuint msg_id = 0; \
+ if (unlikely(INTEL_DEBUG & DEBUG_PERF)) \
+ dbg_printf(__VA_ARGS__); \
+ if (intel->perf_debug) \
+ _mesa_gl_debug(&intel->ctx, &msg_id, \
+ MESA_DEBUG_TYPE_PERFORMANCE, \
+ MESA_DEBUG_SEVERITY_MEDIUM, \
+ __VA_ARGS__); \
} while(0)
#define WARN_ONCE(cond, fmt...) do { \
* flush is only needed on first map of the buffer.
*/
- if (unlikely(INTEL_DEBUG & DEBUG_PERF)) {
+ if (unlikely(intel->perf_debug)) {
if (drm_intel_bo_busy(region->bo)) {
perf_debug("Mapping a busy BO, causing a stall on the GPU.\n");
}
}
if (!copy_supported && !copy_supported_with_alpha_override) {
- if (unlikely(INTEL_DEBUG & DEBUG_PERF))
- fprintf(stderr, "%s mismatched formats %s, %s\n",
+ perf_debug("%s mismatched formats %s, %s\n",
__FUNCTION__,
_mesa_get_format_name(intelImage->base.Base.TexFormat),
_mesa_get_format_name(intel_rb_format(irb)));
intel_batchbuffer_flush(intel);
}
- if (unlikely(INTEL_DEBUG & DEBUG_PERF)) {
+ if (unlikely(intel->perf_debug)) {
if (drm_intel_bo_busy(bo)) {
perf_debug("Mapping a busy BO, causing a stall on the GPU.\n");
}