summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorBrian Paul <[email protected]>2016-08-02 14:27:33 -0600
committerBrian Paul <[email protected]>2016-08-16 08:24:53 -0600
commitf934117bbb9d58f0f5d9cfb4397fec9c6371ed64 (patch)
treebd4a5be0cbfbf7ff58cd26e3bd7db271a8ea1771 /src
parentdcf2126f90a1daf226417bde71a62ccf0305adea (diff)
svga: don't call os_get_time() when not needed by Gallium HUD
The calls to os_get_time() were showing up higher than expected in profiles. Reviewed-by: Charmaine Lee <[email protected]>
Diffstat (limited to 'src')
-rw-r--r--src/gallium/drivers/svga/svga_context.c5
-rw-r--r--src/gallium/drivers/svga/svga_context.h15
-rw-r--r--src/gallium/drivers/svga/svga_pipe_query.c7
-rw-r--r--src/gallium/drivers/svga/svga_resource_buffer.c5
-rw-r--r--src/gallium/drivers/svga/svga_resource_texture.c5
5 files changed, 26 insertions, 11 deletions
diff --git a/src/gallium/drivers/svga/svga_context.c b/src/gallium/drivers/svga/svga_context.c
index f623caf9401..52956fab297 100644
--- a/src/gallium/drivers/svga/svga_context.c
+++ b/src/gallium/drivers/svga/svga_context.c
@@ -31,7 +31,6 @@
#include "util/u_memory.h"
#include "util/u_bitmask.h"
#include "util/u_upload_mgr.h"
-#include "os/os_time.h"
#include "svga_context.h"
#include "svga_screen.h"
@@ -320,9 +319,9 @@ void svga_context_flush( struct svga_context *svga,
/* Flush pending commands to hardware:
*/
- t0 = os_time_get();
+ t0 = svga_get_time(svga);
svga->swc->flush(svga->swc, &fence);
- svga->hud.flush_time += (os_time_get() - t0);
+ svga->hud.flush_time += (svga_get_time(svga) - t0);
svga->hud.num_flushes++;
diff --git a/src/gallium/drivers/svga/svga_context.h b/src/gallium/drivers/svga/svga_context.h
index 4eb8a190879..1e62e715c3e 100644
--- a/src/gallium/drivers/svga/svga_context.h
+++ b/src/gallium/drivers/svga/svga_context.h
@@ -31,6 +31,8 @@
#include "pipe/p_defines.h"
#include "pipe/p_state.h"
+#include "os/os_time.h"
+
#include "util/u_blitter.h"
#include "util/list.h"
@@ -544,6 +546,8 @@ struct svga_context
uint64_t num_surface_views; /**< SVGA_QUERY_NUM_SURFACE_VIEWS */
uint64_t num_bytes_uploaded; /**< SVGA_QUERY_NUM_BYTES_UPLOADED */
uint64_t num_generate_mipmap; /**< SVGA_QUERY_NUM_GENERATE_MIPMAP */
+
+ boolean uses_time; /**< os_time_get() calls needed? */
} hud;
/** The currently bound stream output targets */
@@ -703,4 +707,15 @@ svga_rects_equal(const SVGA3dRect *r1, const SVGA3dRect *r2)
return memcmp(r1, r2, sizeof(*r1)) == 0;
}
+/**
+ * If the Gallium HUD is enabled, this will return the current time.
+ * Otherwise, just return zero.
+ */
+static inline int64_t
+svga_get_time(struct svga_context *svga)
+{
+ return svga->hud.uses_time ? os_time_get() : 0;
+}
+
+
#endif
diff --git a/src/gallium/drivers/svga/svga_pipe_query.c b/src/gallium/drivers/svga/svga_pipe_query.c
index 65e58fe0e68..bf074b6095c 100644
--- a/src/gallium/drivers/svga/svga_pipe_query.c
+++ b/src/gallium/drivers/svga/svga_pipe_query.c
@@ -731,11 +731,9 @@ svga_create_query(struct pipe_context *pipe,
case SVGA_QUERY_NUM_FALLBACKS:
case SVGA_QUERY_NUM_FLUSHES:
case SVGA_QUERY_NUM_VALIDATIONS:
- case SVGA_QUERY_MAP_BUFFER_TIME:
case SVGA_QUERY_NUM_RESOURCES_MAPPED:
case SVGA_QUERY_NUM_BYTES_UPLOADED:
case SVGA_QUERY_COMMAND_BUFFER_SIZE:
- case SVGA_QUERY_FLUSH_TIME:
case SVGA_QUERY_SURFACE_WRITE_FLUSHES:
case SVGA_QUERY_MEMORY_USED:
case SVGA_QUERY_NUM_SHADERS:
@@ -749,6 +747,11 @@ svga_create_query(struct pipe_context *pipe,
case SVGA_QUERY_NUM_CONST_BUF_UPDATES:
case SVGA_QUERY_NUM_CONST_UPDATES:
break;
+ case SVGA_QUERY_FLUSH_TIME:
+ case SVGA_QUERY_MAP_BUFFER_TIME:
+ /* These queries need os_time_get() */
+ svga->hud.uses_time = TRUE;
+ break;
default:
assert(!"unexpected query type in svga_create_query()");
}
diff --git a/src/gallium/drivers/svga/svga_resource_buffer.c b/src/gallium/drivers/svga/svga_resource_buffer.c
index 68ce103f750..c126ff91c90 100644
--- a/src/gallium/drivers/svga/svga_resource_buffer.c
+++ b/src/gallium/drivers/svga/svga_resource_buffer.c
@@ -29,7 +29,6 @@
#include "pipe/p_defines.h"
#include "util/u_inlines.h"
#include "os/os_thread.h"
-#include "os/os_time.h"
#include "util/u_math.h"
#include "util/u_memory.h"
#include "util/u_resource.h"
@@ -78,7 +77,7 @@ svga_buffer_transfer_map(struct pipe_context *pipe,
struct svga_buffer *sbuf = svga_buffer(resource);
struct pipe_transfer *transfer;
uint8_t *map;
- int64_t begin = os_time_get();
+ int64_t begin = svga_get_time(svga);
assert(box->y == 0);
assert(box->z == 0);
@@ -264,7 +263,7 @@ svga_buffer_transfer_map(struct pipe_context *pipe,
FREE(transfer);
}
- svga->hud.map_buffer_time += (os_time_get() - begin);
+ svga->hud.map_buffer_time += (svga_get_time(svga) - begin);
return map;
}
diff --git a/src/gallium/drivers/svga/svga_resource_texture.c b/src/gallium/drivers/svga/svga_resource_texture.c
index 230221a3867..30dc4d9a082 100644
--- a/src/gallium/drivers/svga/svga_resource_texture.c
+++ b/src/gallium/drivers/svga/svga_resource_texture.c
@@ -29,7 +29,6 @@
#include "pipe/p_state.h"
#include "pipe/p_defines.h"
#include "os/os_thread.h"
-#include "os/os_time.h"
#include "util/u_format.h"
#include "util/u_inlines.h"
#include "util/u_math.h"
@@ -336,7 +335,7 @@ svga_texture_transfer_map(struct pipe_context *pipe,
!svga_have_gb_dma(svga);
unsigned d;
void *returnVal;
- int64_t begin = os_time_get();
+ int64_t begin = svga_get_time(svga);
/* We can't map texture storage directly unless we have GB objects */
if (usage & PIPE_TRANSFER_MAP_DIRECTLY) {
@@ -579,7 +578,7 @@ svga_texture_transfer_map(struct pipe_context *pipe,
returnVal = (void *) (map + offset);
}
- svga->hud.map_buffer_time += (os_time_get() - begin);
+ svga->hud.map_buffer_time += (svga_get_time(svga) - begin);
svga->hud.num_resources_mapped++;
return returnVal;