summaryrefslogtreecommitdiff
path: root/src/intel
diff options
context:
space:
mode:
authorMark Janes <markjanes@swizzler.org>2021-01-29 15:45:44 -0800
committerMark Janes <markjanes@swizzler.org>2021-02-01 17:24:57 -0800
commit2edfb279137e8f0f8be0f8ce710056591a670a19 (patch)
tree296a8061a9e7789bad66303548ce286d58935296 /src/intel
parentd6fc72e286d57ff2770d7540a9eead7e1d3e2aed (diff)
intel: combine common gather routines in INTEL_MEASURE
Anv and iris had separate, similar routines to gather intel_measure timestamps. Timestamps are now managed within intel_measure, allowing those routines to be consolidated. Acked-by: Kenneth Graunke <kenneth@whitecape.org> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/7354>
Diffstat (limited to 'src/intel')
-rw-r--r--src/intel/common/intel_measure.c52
-rw-r--r--src/intel/common/intel_measure.h8
-rw-r--r--src/intel/vulkan/anv_measure.c57
3 files changed, 57 insertions, 60 deletions
diff --git a/src/intel/common/intel_measure.c b/src/intel/common/intel_measure.c
index 242d7a28f22..51c2145ff18 100644
--- a/src/intel/common/intel_measure.c
+++ b/src/intel/common/intel_measure.c
@@ -56,10 +56,10 @@ void
intel_measure_init(struct intel_measure_device *device)
{
static bool once = false;
+ const char *env = getenv("INTEL_MEASURE");
if (unlikely(!once)) {
once = true;
memset(&config, 0, sizeof(struct intel_measure_config));
- const char *env = getenv("INTEL_MEASURE");
if (!env)
return;
@@ -209,7 +209,11 @@ intel_measure_init(struct intel_measure_device *device)
}
device->config = NULL;
- if (getenv("INTEL_MEASURE"))
+ device->frame = 0;
+ pthread_mutex_init(&device->mutex, NULL);
+ list_inithead(&device->queued_snapshots);
+
+ if (env)
device->config = &config;
}
@@ -389,7 +393,7 @@ intel_measure_ready(struct intel_measure_batch *batch)
* Depending on configuration, snapshot data may need to be collated before
* writing to the output file.
*/
-void
+static void
intel_measure_push_result(struct intel_measure_device *device,
struct intel_measure_batch *batch)
{
@@ -447,7 +451,6 @@ intel_measure_push_result(struct intel_measure_device *device,
}
}
-
static unsigned
ringbuffer_size(const struct intel_measure_ringbuffer *rb)
{
@@ -604,7 +607,7 @@ print_combined_results(struct intel_measure_device *measure_device,
/**
* Empty the ringbuffer of events that can be printed.
*/
-void
+static void
intel_measure_print(struct intel_measure_device *device,
struct gen_device_info *info)
{
@@ -616,3 +619,42 @@ intel_measure_print(struct intel_measure_device *device,
}
}
+/**
+ * Collect snapshots from completed command buffers and submit them to
+ * intel_measure for printing.
+ */
+void
+intel_measure_gather(struct intel_measure_device *measure_device,
+ struct gen_device_info *info)
+{
+ pthread_mutex_lock(&measure_device->mutex);
+
+ /* Iterate snapshots and collect if ready. Each snapshot queue will be
+ * in-order, but we must determine which queue has the oldest batch.
+ */
+ /* iterate snapshots and collect if ready */
+ while (!list_is_empty(&measure_device->queued_snapshots)) {
+ struct intel_measure_batch *batch =
+ list_first_entry(&measure_device->queued_snapshots,
+ struct intel_measure_batch, link);
+
+ if (!intel_measure_ready(batch)) {
+ /* command buffer has begun execution on the gpu, but has not
+ * completed.
+ */
+ break;
+ }
+
+ list_del(&batch->link);
+ assert(batch->index % 2 == 0);
+
+ intel_measure_push_result(measure_device, batch);
+
+ batch->index = 0;
+ batch->frame = 0;
+ }
+
+ intel_measure_print(measure_device, info);
+ pthread_mutex_unlock(&measure_device->mutex);
+}
+
diff --git a/src/intel/common/intel_measure.h b/src/intel/common/intel_measure.h
index 2bf7d6b8387..e78e69e2fb3 100644
--- a/src/intel/common/intel_measure.h
+++ b/src/intel/common/intel_measure.h
@@ -141,6 +141,7 @@ struct intel_measure_device {
};
struct intel_measure_batch {
+ struct list_head link;
unsigned index;
unsigned frame, batch_count, event_count;
uintptr_t framebuffer;
@@ -157,11 +158,8 @@ void intel_measure_frame_transition(unsigned frame);
bool intel_measure_ready(struct intel_measure_batch *batch);
-void intel_measure_push_result(struct intel_measure_device *device,
- struct intel_measure_batch *batch);
-
struct gen_device_info;
-void intel_measure_print(struct intel_measure_device *device,
- struct gen_device_info *info);
+void intel_measure_gather(struct intel_measure_device *device,
+ struct gen_device_info *info);
#endif /* INTEL_MEASURE_H */
diff --git a/src/intel/vulkan/anv_measure.c b/src/intel/vulkan/anv_measure.c
index 0213f219bbd..933cf29fa70 100644
--- a/src/intel/vulkan/anv_measure.c
+++ b/src/intel/vulkan/anv_measure.c
@@ -32,7 +32,6 @@
struct anv_measure_batch {
struct anv_bo *bo;
- struct list_head link;
struct intel_measure_batch base;
};
@@ -67,11 +66,6 @@ anv_measure_device_init(struct anv_physical_device *device)
/* initialise list of measure structures that await rendering */
struct intel_measure_device *measure_device = &device->measure_device;
- pthread_mutex_init(&measure_device->mutex, NULL);
- list_inithead(&measure_device->queued_snapshots);
-
- measure_device->frame = 0;
-
intel_measure_init(measure_device);
struct intel_measure_config *config = measure_device->config;
if (config == NULL)
@@ -128,48 +122,9 @@ anv_measure_init(struct anv_cmd_buffer *cmd_buffer)
measure->base.timestamps = measure->bo->map;
assert(result == VK_SUCCESS);
- list_inithead(&measure->link);
-
cmd_buffer->measure = measure;
}
-/**
- * Collect snapshots from completed command buffers and submit them to
- * intel_measure for printing.
- */
-static void
-anv_measure_gather(struct anv_device *device)
-{
- struct intel_measure_device *measure_device = &device->physical->measure_device;
-
- pthread_mutex_lock(&measure_device->mutex);
-
- /* iterate snapshots and collect if ready */
- while (!list_is_empty(&measure_device->queued_snapshots)) {
- struct anv_measure_batch *measure =
- list_first_entry(&measure_device->queued_snapshots,
- struct anv_measure_batch, link);
-
- if (!intel_measure_ready(&measure->base)) {
- /* command buffer has begun execution on the gpu, but has not
- * completed.
- */
- break;
- }
-
- list_del(&measure->link);
- assert(measure->base.index % 2 == 0);
-
- intel_measure_push_result(measure_device, &measure->base);
-
- measure->base.index = 0;
- measure->base.frame = 0;
- }
-
- intel_measure_print(measure_device, &device->info);
- pthread_mutex_unlock(&measure_device->mutex);
-}
-
static void
anv_measure_start_snapshot(struct anv_cmd_buffer *cmd_buffer,
enum intel_measure_snapshot_type type,
@@ -359,7 +314,8 @@ anv_measure_reset(struct anv_cmd_buffer *cmd_buffer)
/* it is possible that the command buffer contains snapshots that have not
* yet been processed
*/
- anv_measure_gather(device);
+ intel_measure_gather(&device->physical->measure_device,
+ &device->info);
assert(cmd_buffer->device != NULL);
@@ -367,7 +323,7 @@ anv_measure_reset(struct anv_cmd_buffer *cmd_buffer)
measure->base.framebuffer = 0;
measure->base.frame = 0;
measure->base.event_count = 0;
- list_inithead(&measure->link);
+ list_inithead(&measure->base.link);
anv_device_release_bo(device, measure->bo);
VkResult result =
@@ -386,6 +342,7 @@ anv_measure_destroy(struct anv_cmd_buffer *cmd_buffer)
struct intel_measure_config *config = config_from_command_buffer(cmd_buffer);
struct anv_measure_batch *measure = cmd_buffer->measure;
struct anv_device *device = cmd_buffer->device;
+ struct anv_physical_device *physical = device->physical;
if (!config)
return;
@@ -395,7 +352,7 @@ anv_measure_destroy(struct anv_cmd_buffer *cmd_buffer)
/* it is possible that the command buffer contains snapshots that have not
* yet been processed
*/
- anv_measure_gather(device);
+ intel_measure_gather(&physical->measure_device, &physical->info);
anv_device_release_bo(device, measure->bo);
vk_free(&cmd_buffer->pool->alloc, measure);
@@ -453,7 +410,7 @@ _anv_measure_submit(struct anv_cmd_buffer *cmd_buffer)
/* add to the list of submitted snapshots */
pthread_mutex_lock(&measure_device->mutex);
- list_addtail(&measure->link, &measure_device->queued_snapshots);
+ list_addtail(&measure->base.link, &measure_device->queued_snapshots);
pthread_mutex_unlock(&measure_device->mutex);
}
@@ -474,7 +431,7 @@ anv_measure_acquire(struct anv_device *device)
intel_measure_frame_transition(p_atomic_inc_return(&measure_device->frame));
/* iterate the queued snapshots and publish those that finished */
- anv_measure_gather(device);
+ intel_measure_gather(measure_device, &device->physical->info);
}
void