[Mesa-dev] [PATCH 10/22] r600g, radeonsi: consolidate get_timestamp, get_driver_query_info

Marek Olšák maraeo at gmail.com
Wed Jan 22 12:13:02 PST 2014


From: Marek Olšák <marek.olsak at amd.com>

This enables more queries for the Gallium HUD with radeonsi.
---
 src/gallium/drivers/r600/r600_pipe.c          | 32 --------------------------
 src/gallium/drivers/radeon/r600_pipe_common.c | 33 +++++++++++++++++++++++++++
 src/gallium/drivers/radeonsi/si_pipe.c        |  9 --------
 src/gallium/drivers/radeonsi/si_state_draw.c  |  1 +
 4 files changed, 34 insertions(+), 41 deletions(-)

diff --git a/src/gallium/drivers/r600/r600_pipe.c b/src/gallium/drivers/r600/r600_pipe.c
index 30cf8c4..182a122 100644
--- a/src/gallium/drivers/r600/r600_pipe.c
+++ b/src/gallium/drivers/r600/r600_pipe.c
@@ -750,36 +750,6 @@ static void r600_destroy_screen(struct pipe_screen* pscreen)
 	FREE(rscreen);
 }
 
-static uint64_t r600_get_timestamp(struct pipe_screen *screen)
-{
-	struct r600_screen *rscreen = (struct r600_screen*)screen;
-
-	return 1000000 * rscreen->b.ws->query_value(rscreen->b.ws, RADEON_TIMESTAMP) /
-			rscreen->b.info.r600_clock_crystal_freq;
-}
-
-static int r600_get_driver_query_info(struct pipe_screen *screen,
-				      unsigned index,
-				      struct pipe_driver_query_info *info)
-{
-	struct r600_screen *rscreen = (struct r600_screen*)screen;
-	struct pipe_driver_query_info list[] = {
-		{"draw-calls", R600_QUERY_DRAW_CALLS, 0},
-		{"requested-VRAM", R600_QUERY_REQUESTED_VRAM, rscreen->b.info.vram_size, TRUE},
-		{"requested-GTT", R600_QUERY_REQUESTED_GTT, rscreen->b.info.gart_size, TRUE},
-		{"buffer-wait-time", R600_QUERY_BUFFER_WAIT_TIME, 0, FALSE}
-	};
-
-	if (!info)
-		return Elements(list);
-
-	if (index >= Elements(list))
-		return 0;
-
-	*info = list[index];
-	return 1;
-}
-
 static struct pipe_resource *r600_resource_create(struct pipe_screen *screen,
 						  const struct pipe_resource *templ)
 {
@@ -807,13 +777,11 @@ struct pipe_screen *r600_screen_create(struct radeon_winsys *ws)
 	rscreen->b.b.get_shader_param = r600_get_shader_param;
 	rscreen->b.b.get_paramf = r600_get_paramf;
 	rscreen->b.b.get_compute_param = r600_get_compute_param;
-	rscreen->b.b.get_timestamp = r600_get_timestamp;
 	if (rscreen->b.info.chip_class >= EVERGREEN) {
 		rscreen->b.b.is_format_supported = evergreen_is_format_supported;
 	} else {
 		rscreen->b.b.is_format_supported = r600_is_format_supported;
 	}
-	rscreen->b.b.get_driver_query_info = r600_get_driver_query_info;
 	if (rscreen->b.info.has_uvd) {
 		rscreen->b.b.get_video_param = ruvd_get_video_param;
 		rscreen->b.b.is_video_format_supported = ruvd_is_format_supported;
diff --git a/src/gallium/drivers/radeon/r600_pipe_common.c b/src/gallium/drivers/radeon/r600_pipe_common.c
index cabc6ef..ccd27fd 100644
--- a/src/gallium/drivers/radeon/r600_pipe_common.c
+++ b/src/gallium/drivers/radeon/r600_pipe_common.c
@@ -27,6 +27,7 @@
 #include "r600_pipe_common.h"
 #include "r600_cs.h"
 #include "tgsi/tgsi_parse.h"
+#include "util/u_memory.h"
 #include "util/u_format_s3tc.h"
 #include "util/u_upload_mgr.h"
 #include <inttypes.h>
@@ -188,6 +189,36 @@ static const char* r600_get_name(struct pipe_screen* pscreen)
 	}
 }
 
+static uint64_t r600_get_timestamp(struct pipe_screen *screen)
+{
+	struct r600_common_screen *rscreen = (struct r600_common_screen*)screen;
+
+	return 1000000 * rscreen->ws->query_value(rscreen->ws, RADEON_TIMESTAMP) /
+			rscreen->info.r600_clock_crystal_freq;
+}
+
+static int r600_get_driver_query_info(struct pipe_screen *screen,
+				      unsigned index,
+				      struct pipe_driver_query_info *info)
+{
+	struct r600_common_screen *rscreen = (struct r600_common_screen*)screen;
+	struct pipe_driver_query_info list[] = {
+		{"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)
+		return Elements(list);
+
+	if (index >= Elements(list))
+		return 0;
+
+	*info = list[index];
+	return 1;
+}
+
 static void r600_fence_reference(struct pipe_screen *screen,
 				 struct pipe_fence_handle **ptr,
 				 struct pipe_fence_handle *fence)
@@ -343,6 +374,8 @@ bool r600_common_screen_init(struct r600_common_screen *rscreen,
 
 	rscreen->b.get_name = r600_get_name;
 	rscreen->b.get_vendor = r600_get_vendor;
+	rscreen->b.get_driver_query_info = r600_get_driver_query_info;
+	rscreen->b.get_timestamp = r600_get_timestamp;
 	rscreen->b.fence_finish = r600_fence_finish;
 	rscreen->b.fence_reference = r600_fence_reference;
 	rscreen->b.fence_signalled = r600_fence_signalled;
diff --git a/src/gallium/drivers/radeonsi/si_pipe.c b/src/gallium/drivers/radeonsi/si_pipe.c
index bd3be48..b068180 100644
--- a/src/gallium/drivers/radeonsi/si_pipe.c
+++ b/src/gallium/drivers/radeonsi/si_pipe.c
@@ -572,14 +572,6 @@ static void si_destroy_screen(struct pipe_screen* pscreen)
 	FREE(sscreen);
 }
 
-static uint64_t si_get_timestamp(struct pipe_screen *screen)
-{
-	struct si_screen *sscreen = (struct si_screen*)screen;
-
-	return 1000000 * sscreen->b.ws->query_value(sscreen->b.ws, RADEON_TIMESTAMP) /
-		sscreen->b.info.r600_clock_crystal_freq;
-}
-
 struct pipe_screen *radeonsi_screen_create(struct radeon_winsys *ws)
 {
 	struct si_screen *sscreen = CALLOC_STRUCT(si_screen);
@@ -596,7 +588,6 @@ struct pipe_screen *radeonsi_screen_create(struct radeon_winsys *ws)
 	sscreen->b.b.get_shader_param = si_get_shader_param;
 	sscreen->b.b.get_paramf = si_get_paramf;
 	sscreen->b.b.get_compute_param = si_get_compute_param;
-	sscreen->b.b.get_timestamp = si_get_timestamp;
 	sscreen->b.b.is_format_supported = si_is_format_supported;
 	if (sscreen->b.info.has_uvd) {
 		sscreen->b.b.get_video_param = ruvd_get_video_param;
diff --git a/src/gallium/drivers/radeonsi/si_state_draw.c b/src/gallium/drivers/radeonsi/si_state_draw.c
index 90f9703..5c2ff8a 100644
--- a/src/gallium/drivers/radeonsi/si_state_draw.c
+++ b/src/gallium/drivers/radeonsi/si_state_draw.c
@@ -777,4 +777,5 @@ void si_draw_vbo(struct pipe_context *ctx, const struct pipe_draw_info *info)
 	}
 
 	pipe_resource_reference(&ib.buffer, NULL);
+	sctx->b.num_draw_calls++;
 }
-- 
1.8.3.2



More information about the mesa-dev mailing list