mesa: implement glGet(GL_TIMESTAMP) v2
authorMarek Olšák <maraeo@gmail.com>
Thu, 5 Jul 2012 18:21:29 +0000 (20:21 +0200)
committerMarek Olšák <maraeo@gmail.com>
Tue, 10 Jul 2012 17:04:12 +0000 (19:04 +0200)
This is adds a new driver function to retrieve the timestamp.

Reviewed-by: Eric Anholt <eric@anholt.net>
src/mesa/main/dd.h
src/mesa/main/get.c

index 687a38f44873ed858cc0ff1712cd31cfa4f8c29f..c8a765f47aa70fb5bd5a64df9d4d057b3669da53 100644 (file)
@@ -820,6 +820,12 @@ struct dd_function_table {
                                                   GLuint name);
    void (*DeleteSamplerObject)(struct gl_context *ctx,
                                struct gl_sampler_object *samp);
+
+   /**
+    * \name Return a timestamp in nanoseconds as defined by GL_ARB_timer_query.
+    * This should be equivalent to glGetInteger64v(GL_TIMESTAMP);
+    */
+   uint64_t (*GetTimestamp)(struct gl_context *ctx);
 };
 
 
index a83d367212149615bab662b730c87c476aeb1ecf..cff4cf394555ebbf9ac5813d562f4d8763c7bb91 100644 (file)
@@ -342,6 +342,7 @@ EXTRA_EXT(ARB_texture_buffer_object);
 EXTRA_EXT(OES_EGL_image_external);
 EXTRA_EXT(ARB_blend_func_extended);
 EXTRA_EXT(ARB_uniform_buffer_object);
+EXTRA_EXT(ARB_timer_query);
 
 static const int
 extra_ARB_vertex_program_ARB_fragment_program_NV_vertex_program[] = {
@@ -1353,6 +1354,9 @@ static const struct value_desc values[] = {
 
    { GL_UNIFORM_BUFFER_BINDING, LOC_CUSTOM, TYPE_INT, 0, extra_ARB_uniform_buffer_object },
 
+   /* GL_ARB_timer_query */
+   { GL_TIMESTAMP, LOC_CUSTOM, TYPE_INT64, 0, extra_ARB_timer_query }
+
 #endif /* FEATURE_GL */
 };
 
@@ -1807,7 +1811,16 @@ find_custom_value(struct gl_context *ctx, const struct value_desc *d, union valu
    case GL_UNIFORM_BUFFER_BINDING:
       v->value_int = ctx->UniformBuffer->Name;
       break;
-   }   
+   /* GL_ARB_timer_query */
+   case GL_TIMESTAMP:
+      if (ctx->Driver.GetTimestamp) {
+         v->value_int64 = ctx->Driver.GetTimestamp(ctx);
+      }
+      else {
+         _mesa_problem(ctx, "driver doesn't implement GetTimestamp");
+      }
+      break;
+   }
 }
 
 /**