gallium: EXT_timer_query support.
authorMathias Fröhlich <Mathias.Froehlich@web.de>
Mon, 17 May 2010 18:48:56 +0000 (11:48 -0700)
committerCorbin Simpson <MostAwesomeDude@gmail.com>
Mon, 17 May 2010 19:05:18 +0000 (12:05 -0700)
Signed-off-by: Corbin Simpson <MostAwesomeDude@gmail.com>
13 files changed:
src/gallium/drivers/cell/ppu/cell_screen.c
src/gallium/drivers/i915/i915_screen.c
src/gallium/drivers/i965/brw_screen.c
src/gallium/drivers/llvmpipe/lp_screen.c
src/gallium/drivers/nv50/nv50_screen.c
src/gallium/drivers/nvfx/nvfx_screen.c
src/gallium/drivers/r300/r300_screen.c
src/gallium/drivers/softpipe/sp_query.c
src/gallium/drivers/softpipe/sp_screen.c
src/gallium/drivers/svga/svga_screen.c
src/gallium/include/pipe/p_defines.h
src/mesa/state_tracker/st_cb_queryobj.c
src/mesa/state_tracker/st_extensions.c

index 5af4eaa88b114d0998719ffd57aacf02ef4f1fd7..750f0aa98ab1add428d876fc9b2e8e4218bf24cd 100644 (file)
@@ -76,6 +76,8 @@ cell_get_param(struct pipe_screen *screen, enum pipe_cap param)
       return 1;
    case PIPE_CAP_OCCLUSION_QUERY:
       return 1;
+   case PIPE_CAP_TIMER_QUERY:
+      return 0;
    case PIPE_CAP_TEXTURE_SHADOW_MAP:
       return 10;
    case PIPE_CAP_MAX_TEXTURE_2D_LEVELS:
index d196c779e43d391dc0d1540739914d021b8e145f..7cf627d975bfa15bd713604844e0796cd837397e 100644 (file)
@@ -113,6 +113,8 @@ i915_get_param(struct pipe_screen *screen, enum pipe_cap param)
       return 1;
    case PIPE_CAP_OCCLUSION_QUERY:
       return 0;
+   case PIPE_CAP_TIMER_QUERY:
+      return 0;
    case PIPE_CAP_TEXTURE_SHADOW_MAP:
       return 1;
    case PIPE_CAP_MAX_TEXTURE_2D_LEVELS:
index d242691f2d2c884919d9be92e08dedc14a556cf0..1890b640e908469b47d108a71657e3217229e58a 100644 (file)
@@ -172,6 +172,8 @@ brw_get_param(struct pipe_screen *screen, enum pipe_cap param)
       return 1;
    case PIPE_CAP_OCCLUSION_QUERY:
       return 0;
+   case PIPE_CAP_TIMER_QUERY:
+      return 0;
    case PIPE_CAP_TEXTURE_SHADOW_MAP:
       return 1;
    case PIPE_CAP_MAX_TEXTURE_2D_LEVELS:
index 6ab09709988a725cc93bed74c760a9ec329d297c..22fbf381ae0da8af5e2286fb095617523c8549b7 100644 (file)
@@ -105,6 +105,8 @@ llvmpipe_get_param(struct pipe_screen *screen, enum pipe_cap param)
       return PIPE_MAX_COLOR_BUFS;
    case PIPE_CAP_OCCLUSION_QUERY:
       return 1;
+   case PIPE_CAP_TIMER_QUERY:
+      return 0;
    case PIPE_CAP_TEXTURE_MIRROR_CLAMP:
       return 1;
    case PIPE_CAP_TEXTURE_MIRROR_REPEAT:
index ff3a7b2843dbee8cb4b51c8baef0b0117e0bf180..a0eed8c2e2d3850b7afe3234c257c642fefc4ad5 100644 (file)
@@ -125,6 +125,8 @@ nv50_screen_get_param(struct pipe_screen *pscreen, enum pipe_cap param)
                return 8;
        case PIPE_CAP_OCCLUSION_QUERY:
                return 1;
+        case PIPE_CAP_TIMER_QUERY:
+               return 0;
        case PIPE_CAP_TEXTURE_SHADOW_MAP:
                return 1;
        case PIPE_CAP_MAX_TEXTURE_2D_LEVELS:
index 6b01d868e2f2d1a05756bd33cbb8dbd985e845cf..a44f9e94d7089ba78bb85a17116d92ed3928317d 100644 (file)
@@ -52,6 +52,8 @@ nvfx_screen_get_param(struct pipe_screen *pscreen, enum pipe_cap param)
                return screen->is_nv4x ? 4 : 2;
        case PIPE_CAP_OCCLUSION_QUERY:
                return 1;
+        case PIPE_CAP_TIMER_QUERY:
+               return 0;
        case PIPE_CAP_TEXTURE_SHADOW_MAP:
                return 1;
        case PIPE_CAP_MAX_TEXTURE_2D_LEVELS:
index 8399f5df8e43f379d3bcc9a7e1da8db1ccc7a76b..640b3d346887fbd6f70d5d69cb87e46b025ca74c 100644 (file)
@@ -115,6 +115,7 @@ static int r300_get_param(struct pipe_screen* pscreen, enum pipe_cap param)
             return 1;
 
         /* Unsupported features (boolean caps). */
+        case PIPE_CAP_TIMER_QUERY:
         case PIPE_CAP_DUAL_SOURCE_BLEND:
         case PIPE_CAP_TGSI_CONT_SUPPORTED:
         case PIPE_CAP_INDEP_BLEND_ENABLE:
index 4ef5d9f7b1db3e3172bd272d72b5ce4e5647722d..b959af63aff59e6ebe8a24d4b18bb39a85664bd2 100644 (file)
@@ -30,6 +30,7 @@
  */
 
 #include "draw/draw_context.h"
+#include "os/os_time.h"
 #include "pipe/p_defines.h"
 #include "util/u_memory.h"
 #include "sp_context.h"
@@ -37,6 +38,7 @@
 #include "sp_state.h"
 
 struct softpipe_query {
+   unsigned type;
    uint64_t start;
    uint64_t end;
 };
@@ -51,8 +53,13 @@ static struct pipe_query *
 softpipe_create_query(struct pipe_context *pipe, 
                      unsigned type)
 {
-   assert(type == PIPE_QUERY_OCCLUSION_COUNTER);
-   return (struct pipe_query *)CALLOC_STRUCT( softpipe_query );
+   struct softpipe_query* sq;
+
+   assert(type == PIPE_QUERY_OCCLUSION_COUNTER || type == PIPE_QUERY_TIME_ELAPSED);
+   sq = CALLOC_STRUCT( softpipe_query );
+   sq->type = type;
+
+   return (struct pipe_query *)sq;
 }
 
 
@@ -69,7 +76,17 @@ softpipe_begin_query(struct pipe_context *pipe, struct pipe_query *q)
    struct softpipe_context *softpipe = softpipe_context( pipe );
    struct softpipe_query *sq = softpipe_query(q);
    
-   sq->start = softpipe->occlusion_count;
+   switch (sq->type) {
+   case PIPE_QUERY_OCCLUSION_COUNTER:
+      sq->start = softpipe->occlusion_count;
+      break;
+   case PIPE_QUERY_TIME_ELAPSED:
+      sq->start = 1000*os_time_get();
+      break;
+   default:
+      assert(0);
+      break;
+   }
    softpipe->active_query_count++;
    softpipe->dirty |= SP_NEW_QUERY;
 }
@@ -82,7 +99,17 @@ softpipe_end_query(struct pipe_context *pipe, struct pipe_query *q)
    struct softpipe_query *sq = softpipe_query(q);
 
    softpipe->active_query_count--;
-   sq->end = softpipe->occlusion_count;
+   switch (sq->type) {
+   case PIPE_QUERY_OCCLUSION_COUNTER:
+      sq->end = softpipe->occlusion_count;
+      break;
+   case PIPE_QUERY_TIME_ELAPSED:
+      sq->end = 1000*os_time_get();
+      break;
+   default:
+      assert(0);
+      break;
+   }
    softpipe->dirty |= SP_NEW_QUERY;
 }
 
index f874c3e60c029a410c3f02fee617150e1b91f319..8c33efa1987104bad3c69d9f7723f68bca0b2000 100644 (file)
@@ -82,6 +82,8 @@ softpipe_get_param(struct pipe_screen *screen, enum pipe_cap param)
       return PIPE_MAX_COLOR_BUFS;
    case PIPE_CAP_OCCLUSION_QUERY:
       return 1;
+   case PIPE_CAP_TIMER_QUERY:
+      return 1;
    case PIPE_CAP_TEXTURE_MIRROR_CLAMP:
       return 1;
    case PIPE_CAP_TEXTURE_MIRROR_REPEAT:
index 2c3c3f522020901b492b55e2442cb1f2c9cbe76f..bef22f41ae5d2bdf5d44014c3c93bbec28bf3938 100644 (file)
@@ -134,6 +134,8 @@ svga_get_paramf(struct pipe_screen *screen, enum pipe_cap param)
       return MIN2(result.u, PIPE_MAX_COLOR_BUFS);
    case PIPE_CAP_OCCLUSION_QUERY:
       return 1;
+   case PIPE_CAP_TIMER_QUERY:
+      return 0;
    case PIPE_CAP_TEXTURE_SHADOW_MAP:
       return 1;
 
index 2d363dd47b61c4bfad30c5bdc29a4546127d26e7..29c55ff094cf27d09634a2a91867d9a315778938 100644 (file)
@@ -379,7 +379,8 @@ enum pipe_transfer_usage {
 #define PIPE_QUERY_OCCLUSION_COUNTER     0
 #define PIPE_QUERY_PRIMITIVES_GENERATED  1
 #define PIPE_QUERY_PRIMITIVES_EMITTED    2
-#define PIPE_QUERY_TYPES                 3
+#define PIPE_QUERY_TIME_ELAPSED          3
+#define PIPE_QUERY_TYPES                 4
 
 
 /**
@@ -423,6 +424,7 @@ enum pipe_cap {
    PIPE_CAP_POINT_SPRITE,
    PIPE_CAP_MAX_RENDER_TARGETS,
    PIPE_CAP_OCCLUSION_QUERY,
+   PIPE_CAP_TIMER_QUERY,
    PIPE_CAP_TEXTURE_SHADOW_MAP,
    PIPE_CAP_MAX_TEXTURE_2D_LEVELS,
    PIPE_CAP_MAX_TEXTURE_3D_LEVELS,
index a8bd5db630431bcb945cfb0be5aa0aa19ee3ddc4..e423d9d8a51dbb9e9340ed98f1696d9a2dc54ced 100644 (file)
@@ -94,6 +94,9 @@ st_BeginQuery(GLcontext *ctx, struct gl_query_object *q)
    case GL_TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN:
       type = PIPE_QUERY_PRIMITIVES_EMITTED;
       break;
+   case GL_TIME_ELAPSED_EXT:
+      type = PIPE_QUERY_TIME_ELAPSED;
+      break;
    default:
       assert(0 && "unexpected query target in st_BeginQuery()");
       return;
index 0cd80fa59f7503dfc4f7ec291234755488c76f60..459e924cca39ddd919a52c4b9c004a6c78dc1082 100644 (file)
@@ -296,6 +296,9 @@ void st_init_extensions(struct st_context *st)
    if (screen->get_param(screen, PIPE_CAP_OCCLUSION_QUERY)) {
       ctx->Extensions.ARB_occlusion_query = GL_TRUE;
    }
+   if (screen->get_param(screen, PIPE_CAP_TIMER_QUERY)) {
+     ctx->Extensions.EXT_timer_query = GL_TRUE;
+   }
 
    if (screen->get_param(screen, PIPE_CAP_TEXTURE_SHADOW_MAP)) {
       ctx->Extensions.ARB_depth_texture = GL_TRUE;