/* brw_performance_monitor.c */
void brw_init_performance_monitors(struct brw_context *brw);
void brw_dump_perf_monitors(struct brw_context *brw);
+void brw_perf_monitor_new_batch(struct brw_context *brw);
+void brw_perf_monitor_finish_batch(struct brw_context *brw);
/* intel_extensions.c */
extern void intelInitExtensions(struct gl_context *ctx);
drm_intel_bo_unmap(monitor->oa_bo);
#endif
+ /* If the OA counters aren't already on, enable them. */
+ if (brw->perfmon.oa_users == 0) {
+ /* Ensure the OACONTROL enable and snapshot land in the same batch. */
+ int space = (MI_REPORT_PERF_COUNT_BATCH_DWORDS + 3) * 4;
+ intel_batchbuffer_require_space(brw, space, RENDER_RING);
+ start_oa_counters(brw);
+ }
+
/* Take a starting OA counter snapshot. */
emit_mi_report_perf_count(brw, monitor->oa_bo, 0, REPORT_ID);
SECOND_SNAPSHOT_OFFSET_IN_BYTES, REPORT_ID);
--brw->perfmon.oa_users;
+
+ if (brw->perfmon.oa_users == 0)
+ stop_oa_counters(brw);
}
if (monitor_needs_statistics_registers(brw, m)) {
/******************************************************************************/
+/**
+ * Called at the start of every render ring batch.
+ *
+ * Enable the OA counters if required.
+ */
+void
+brw_perf_monitor_new_batch(struct brw_context *brw)
+{
+ assert(brw->batch.ring == RENDER_RING);
+ assert(brw->gen < 6 || brw->batch.used == 0);
+
+ if (brw->perfmon.oa_users == 0)
+ return;
+
+ if (brw->gen >= 6)
+ start_oa_counters(brw);
+}
+
+/**
+ * Called at the end of every render ring batch.
+ *
+ * Disable the OA counters.
+ *
+ * This relies on there being enough space in BATCH_RESERVED.
+ */
+void
+brw_perf_monitor_finish_batch(struct brw_context *brw)
+{
+ assert(brw->batch.ring == RENDER_RING);
+
+ if (brw->perfmon.oa_users == 0)
+ return;
+
+ if (brw->gen >= 6)
+ stop_oa_counters(brw);
+}
+
+/******************************************************************************/
+
void
brw_init_performance_monitors(struct brw_context *brw)
{
* what that batch contributed. Emit state packets to write them to a BO.
*/
brw_emit_query_begin(brw);
+
+ /* We may also need to enable OA counters. */
+ brw_perf_monitor_new_batch(brw);
}
/**
*/
brw_emit_query_end(brw);
+ /* We may also need to disable OA counters. */
+ if (brw->batch.ring == RENDER_RING)
+ brw_perf_monitor_finish_batch(brw);
+
if (brw->curbe.curbe_bo) {
drm_intel_gem_bo_unmap_gtt(brw->curbe.curbe_bo);
drm_intel_bo_unreference(brw->curbe.curbe_bo);
* - Optional MI_NOOP for ensuring the batch length is qword aligned (4 bytes)
* - Any state emitted by vtbl->finish_batch():
* - Gen4-5 record ending occlusion query values (4 * 4 = 16 bytes)
+ * - Disabling OA counters on Gen6+ (3 DWords = 12 bytes)
*/
-#define BATCH_RESERVED 24
+#define BATCH_RESERVED 36
struct intel_batchbuffer;