r600g,radeonsi: consolidate get_timestamp, get_driver_query_info
authorMarek Olšák <marek.olsak@amd.com>
Wed, 22 Jan 2014 00:29:18 +0000 (01:29 +0100)
committerMarek Olšák <marek.olsak@amd.com>
Tue, 28 Jan 2014 00:39:39 +0000 (01:39 +0100)
This enables more queries for the Gallium HUD with radeonsi.

Reviewed-by: Michel Dänzer <michel.daenzer@amd.com>
Reviewed-by: Tom Stellard <thomas.stellard@amd.com>
src/gallium/drivers/r600/r600_pipe.c
src/gallium/drivers/radeon/r600_pipe_common.c
src/gallium/drivers/radeonsi/si_pipe.c
src/gallium/drivers/radeonsi/si_state_draw.c

index caed49ccc05eb84309d554848b462b7d458d89fc..a7138969d96d957fc8aff439016a110c63f3cd8f 100644 (file)
@@ -752,36 +752,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)
 {
@@ -809,13 +779,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;
index cabc6ef32593ac61a439e527bbf93b2d4500cb8f..ccd27fdff318a4e84cc70c19cc946253d40f163d 100644 (file)
@@ -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;
index aeccab1dd669aeb62c3d623b24a3d9f6b466cb35..8666b5b071c682c9896e079c201bf5a30ca4f174 100644 (file)
@@ -574,14 +574,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);
@@ -598,7 +590,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;
index 90f9703cfd3e30bda7401ecf5c3dfb037b235c81..5c2ff8a249e6b6f1acb8dca09faf89674a31603b 100644 (file)
@@ -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++;
 }