summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBrian Paul <brianp@vmware.com>2015-08-07 14:54:24 -0600
committerBrian Paul <brianp@vmware.com>2015-08-26 17:06:13 -0600
commit683b52ea2c5a7f024fa20ad8adaf60f488adb170 (patch)
treec2495569ae3c7b2867ee5fc59b1f166adadc1431
parent37dbb0615c0b64cb5351f2999c6b65c4a217f943 (diff)
gallium/st: add pipe_context::get_timestamp()
The VMware svga driver doesn't directly support pipe_screen::get_timestamp() but we can do a work-around. However, we need a gallium context to do so. This patch adds a new pipe_context::get_timestamp() function that will only be called if the pipe_screen::get_timestamp() function is NULL. Signed-off-by: Brian Paul <brianp@vmware.com>
-rw-r--r--src/gallium/include/pipe/p_context.h7
-rw-r--r--src/mesa/state_tracker/st_cb_queryobj.c13
2 files changed, 18 insertions, 2 deletions
diff --git a/src/gallium/include/pipe/p_context.h b/src/gallium/include/pipe/p_context.h
index 9d8f5bdc8d..6f9fe76740 100644
--- a/src/gallium/include/pipe/p_context.h
+++ b/src/gallium/include/pipe/p_context.h
@@ -592,6 +592,13 @@ struct pipe_context {
float *out_value);
/**
+ * Query a timestamp in nanoseconds. This is completely equivalent to
+ * pipe_screen::get_timestamp() but takes a context handle for drivers
+ * that require a context.
+ */
+ uint64_t (*get_timestamp)(struct pipe_context *);
+
+ /**
* Flush the resource cache, so that the resource can be used
* by an external client. Possible usage:
* - flushing a resource before presenting it on the screen
diff --git a/src/mesa/state_tracker/st_cb_queryobj.c b/src/mesa/state_tracker/st_cb_queryobj.c
index 71222e80b6..aafae16b2d 100644
--- a/src/mesa/state_tracker/st_cb_queryobj.c
+++ b/src/mesa/state_tracker/st_cb_queryobj.c
@@ -289,9 +289,18 @@ st_CheckQuery(struct gl_context *ctx, struct gl_query_object *q)
static uint64_t
st_GetTimestamp(struct gl_context *ctx)
{
- struct pipe_screen *screen = st_context(ctx)->pipe->screen;
+ struct pipe_context *pipe = st_context(ctx)->pipe;
+ struct pipe_screen *screen = pipe->screen;
- return screen->get_timestamp(screen);
+ /* Prefer the per-screen function */
+ if (screen->get_timestamp) {
+ return screen->get_timestamp(screen);
+ }
+ else {
+ /* Fall back to the per-context function */
+ assert(pipe->get_timestamp);
+ return pipe->get_timestamp(pipe);
+ }
}