[Mesa-dev] [PATCH 1/4] r600g: add a query returning the amount of time spent during bo_map sync.

Marek Olšák maraeo at gmail.com
Thu Apr 11 03:43:26 PDT 2013


---
 src/gallium/drivers/r600/r600_pipe.c              |    1 +
 src/gallium/drivers/r600/r600_pipe.h              |    1 +
 src/gallium/drivers/r600/r600_query.c             |    9 +++++++++
 src/gallium/winsys/radeon/drm/radeon_drm_bo.c     |    5 +++++
 src/gallium/winsys/radeon/drm/radeon_drm_winsys.c |    2 ++
 src/gallium/winsys/radeon/drm/radeon_drm_winsys.h |    1 +
 src/gallium/winsys/radeon/drm/radeon_winsys.h     |    5 +++--
 7 files changed, 22 insertions(+), 2 deletions(-)

diff --git a/src/gallium/drivers/r600/r600_pipe.c b/src/gallium/drivers/r600/r600_pipe.c
index 7f308f7..a8c91ff 100644
--- a/src/gallium/drivers/r600/r600_pipe.c
+++ b/src/gallium/drivers/r600/r600_pipe.c
@@ -1153,6 +1153,7 @@ static int r600_get_driver_query_info(struct pipe_screen *screen,
 		{"draw-calls", R600_QUERY_DRAW_CALLS, 0},
 		{"requested-VRAM", R600_QUERY_REQUESTED_VRAM, rscreen->info.vram_size, TRUE},
 		{"requested-GTT", R600_QUERY_REQUESTED_GTT, rscreen->info.gart_size, TRUE},
+		{"buffer-wait-time", R600_QUERY_BUFFER_WAIT_TIME, 0, FALSE}
 	};
 
 	if (!info)
diff --git a/src/gallium/drivers/r600/r600_pipe.h b/src/gallium/drivers/r600/r600_pipe.h
index de1545e..f3933af 100644
--- a/src/gallium/drivers/r600/r600_pipe.h
+++ b/src/gallium/drivers/r600/r600_pipe.h
@@ -78,6 +78,7 @@
 #define R600_QUERY_DRAW_CALLS		(PIPE_QUERY_DRIVER_SPECIFIC + 0)
 #define R600_QUERY_REQUESTED_VRAM	(PIPE_QUERY_DRIVER_SPECIFIC + 1)
 #define R600_QUERY_REQUESTED_GTT	(PIPE_QUERY_DRIVER_SPECIFIC + 2)
+#define R600_QUERY_BUFFER_WAIT_TIME	(PIPE_QUERY_DRIVER_SPECIFIC + 3)
 
 struct r600_context;
 struct r600_bytecode;
diff --git a/src/gallium/drivers/r600/r600_query.c b/src/gallium/drivers/r600/r600_query.c
index e2072ca..80528cc 100644
--- a/src/gallium/drivers/r600/r600_query.c
+++ b/src/gallium/drivers/r600/r600_query.c
@@ -47,6 +47,7 @@ static struct r600_resource *r600_new_query_buffer(struct r600_context *ctx, uns
 	case R600_QUERY_DRAW_CALLS:
 	case R600_QUERY_REQUESTED_VRAM:
 	case R600_QUERY_REQUESTED_GTT:
+	case R600_QUERY_BUFFER_WAIT_TIME:
 		return NULL;
 	}
 
@@ -314,6 +315,7 @@ static struct pipe_query *r600_create_query(struct pipe_context *ctx, unsigned q
 	case R600_QUERY_DRAW_CALLS:
 	case R600_QUERY_REQUESTED_VRAM:
 	case R600_QUERY_REQUESTED_GTT:
+	case R600_QUERY_BUFFER_WAIT_TIME:
 		skip_allocation = true;
 		break;
 	default:
@@ -369,6 +371,9 @@ static void r600_begin_query(struct pipe_context *ctx, struct pipe_query *query)
 	case R600_QUERY_REQUESTED_GTT:
 		rquery->begin_result = 0;
 		return;
+	case R600_QUERY_BUFFER_WAIT_TIME:
+		rquery->begin_result = rctx->ws->query_value(rctx->ws, RADEON_BUFFER_WAIT_TIME_NS);
+		return;
 	}
 
 	/* Discard the old query buffers. */
@@ -412,6 +417,9 @@ static void r600_end_query(struct pipe_context *ctx, struct pipe_query *query)
 	case R600_QUERY_REQUESTED_GTT:
 		rquery->end_result = rctx->ws->query_value(rctx->ws, RADEON_REQUESTED_GTT_MEMORY);
 		return;
+	case R600_QUERY_BUFFER_WAIT_TIME:
+		rquery->end_result = rctx->ws->query_value(rctx->ws, RADEON_BUFFER_WAIT_TIME_NS);
+		return;
 	}
 
 	r600_emit_query_end(rctx, rquery);
@@ -453,6 +461,7 @@ static boolean r600_get_query_buffer_result(struct r600_context *ctx,
 	case R600_QUERY_DRAW_CALLS:
 	case R600_QUERY_REQUESTED_VRAM:
 	case R600_QUERY_REQUESTED_GTT:
+	case R600_QUERY_BUFFER_WAIT_TIME:
 		result->u64 = query->end_result - query->begin_result;
 		return TRUE;
 	}
diff --git a/src/gallium/winsys/radeon/drm/radeon_drm_bo.c b/src/gallium/winsys/radeon/drm/radeon_drm_bo.c
index 9e45dcc..6ec1713 100644
--- a/src/gallium/winsys/radeon/drm/radeon_drm_bo.c
+++ b/src/gallium/winsys/radeon/drm/radeon_drm_bo.c
@@ -33,6 +33,7 @@
 #include "util/u_double_list.h"
 #include "os/os_thread.h"
 #include "os/os_mman.h"
+#include "os/os_time.h"
 
 #include "state_tracker/drm_driver.h"
 
@@ -478,6 +479,8 @@ static void *radeon_bo_map(struct radeon_winsys_cs_handle *buf,
                 }
             }
         } else {
+            uint64_t time = os_time_get_nano();
+
             if (!(usage & PIPE_TRANSFER_WRITE)) {
                 /* Mapping for read.
                  *
@@ -503,6 +506,8 @@ static void *radeon_bo_map(struct radeon_winsys_cs_handle *buf,
 
                 radeon_bo_wait((struct pb_buffer*)bo, RADEON_USAGE_READWRITE);
             }
+
+            bo->mgr->rws->buffer_wait_time += os_time_get_nano() - time;
         }
     }
 
diff --git a/src/gallium/winsys/radeon/drm/radeon_drm_winsys.c b/src/gallium/winsys/radeon/drm/radeon_drm_winsys.c
index d1f7643..96374ea 100644
--- a/src/gallium/winsys/radeon/drm/radeon_drm_winsys.c
+++ b/src/gallium/winsys/radeon/drm/radeon_drm_winsys.c
@@ -493,6 +493,8 @@ static uint64_t radeon_query_value(struct radeon_winsys *rws,
         return ws->allocated_vram;
     case RADEON_REQUESTED_GTT_MEMORY:
         return ws->allocated_gtt;
+    case RADEON_BUFFER_WAIT_TIME_NS:
+        return ws->buffer_wait_time;
     }
     return 0;
 }
diff --git a/src/gallium/winsys/radeon/drm/radeon_drm_winsys.h b/src/gallium/winsys/radeon/drm/radeon_drm_winsys.h
index 842579c..682479e 100644
--- a/src/gallium/winsys/radeon/drm/radeon_drm_winsys.h
+++ b/src/gallium/winsys/radeon/drm/radeon_drm_winsys.h
@@ -48,6 +48,7 @@ struct radeon_drm_winsys {
     int num_cs; /* The number of command streams created. */
     uint64_t allocated_vram;
     uint64_t allocated_gtt;
+    uint64_t buffer_wait_time; /* time spent in buffer_wait in ns */
 
     enum radeon_generation gen;
     struct radeon_info info;
diff --git a/src/gallium/winsys/radeon/drm/radeon_winsys.h b/src/gallium/winsys/radeon/drm/radeon_winsys.h
index 36f1f8e..a825b43 100644
--- a/src/gallium/winsys/radeon/drm/radeon_winsys.h
+++ b/src/gallium/winsys/radeon/drm/radeon_winsys.h
@@ -146,8 +146,9 @@ enum ring_type {
 };
 
 enum radeon_value_id {
-   RADEON_REQUESTED_VRAM_MEMORY,
-   RADEON_REQUESTED_GTT_MEMORY,
+    RADEON_REQUESTED_VRAM_MEMORY,
+    RADEON_REQUESTED_GTT_MEMORY,
+    RADEON_BUFFER_WAIT_TIME_NS
 };
 
 struct winsys_handle;
-- 
1.7.10.4



More information about the mesa-dev mailing list