summaryrefslogtreecommitdiffstats
path: root/src/mesa/drivers
diff options
context:
space:
mode:
authorBrian Paul <[email protected]>2005-12-07 14:48:19 +0000
committerBrian Paul <[email protected]>2005-12-07 14:48:19 +0000
commit0fa8c59e646b214ea61c077f723e8ffe1cc06733 (patch)
treec55b85a279eba315344d5954452bfda0705c7c1d /src/mesa/drivers
parent98bebc7212a47f97ef6d15d4fca45a0fa608aea2 (diff)
Updates for GL_EXT_timer_query:
New GLint64EXT and GLuint64EXT types (use C99's long long types). New glGetQueryObject[u]i64vEXT() functions.
Diffstat (limited to 'src/mesa/drivers')
-rw-r--r--src/mesa/drivers/dri/common/extension_helper.h22
-rw-r--r--src/mesa/drivers/x11/xm_dd.c21
-rw-r--r--src/mesa/drivers/x11/xmesaP.h4
3 files changed, 33 insertions, 14 deletions
diff --git a/src/mesa/drivers/dri/common/extension_helper.h b/src/mesa/drivers/dri/common/extension_helper.h
index 4a6606819cf..a1f3fa3f29f 100644
--- a/src/mesa/drivers/dri/common/extension_helper.h
+++ b/src/mesa/drivers/dri/common/extension_helper.h
@@ -1421,6 +1421,13 @@ static const char VertexAttribs2dvNV_names[] =
"";
#endif
+#if defined(need_GL_EXT_timer_query)
+static const char GetQueryObjectui64vEXT_names[] =
+ "iip\0" /* Parameter signature */
+ "glGetQueryObjectui64vEXT\0"
+ "";
+#endif
+
#if defined(need_GL_VERSION_1_3)
static const char MultiTexCoord3fvARB_names[] =
"ip\0" /* Parameter signature */
@@ -1957,6 +1964,13 @@ static const char WindowPos3dvMESA_names[] =
"";
#endif
+#if defined(need_GL_EXT_timer_query)
+static const char GetQueryObjecti64vEXT_names[] =
+ "iip\0" /* Parameter signature */
+ "glGetQueryObjecti64vEXT\0"
+ "";
+#endif
+
#if defined(need_GL_VERSION_1_3)
static const char MultiTexCoord1dARB_names[] =
"id\0" /* Parameter signature */
@@ -5179,6 +5193,14 @@ static const struct dri_extension_function GL_EXT_texture_perturb_normal_functio
};
#endif
+#if defined(need_GL_EXT_timer_query)
+static const struct dri_extension_function GL_EXT_timer_query_functions[] = {
+ { GetQueryObjectui64vEXT_names, GetQueryObjectui64vEXT_remap_index, 817 },
+ { GetQueryObjecti64vEXT_names, GetQueryObjecti64vEXT_remap_index, 816 },
+ { NULL, 0, 0 }
+};
+#endif
+
#if defined(need_GL_EXT_vertex_array)
static const struct dri_extension_function GL_EXT_vertex_array_functions[] = {
{ IndexPointerEXT_names, IndexPointerEXT_remap_index, 450 },
diff --git a/src/mesa/drivers/x11/xm_dd.c b/src/mesa/drivers/x11/xm_dd.c
index d0016b86927..50382602a1b 100644
--- a/src/mesa/drivers/x11/xm_dd.c
+++ b/src/mesa/drivers/x11/xm_dd.c
@@ -1183,14 +1183,14 @@ xmesa_begin_query(GLcontext *ctx, GLenum target, struct gl_query_object *q)
#ifdef __VMS
#define suseconds_t unsigned int
#endif
-static unsigned int
+static GLuint64EXT
time_diff(const struct timeval *t0, const struct timeval *t1)
{
- time_t seconds0 = t0->tv_sec & 0xff; /* 0 .. 255 seconds */
- time_t seconds1 = t1->tv_sec & 0xff; /* 0 .. 255 seconds */
- suseconds_t useconds0 = seconds0 * 1000000 + t0->tv_usec;
- suseconds_t useconds1 = seconds1 * 1000000 + t1->tv_usec;
- return useconds1 - useconds0;
+ GLuint64EXT seconds0 = t0->tv_sec & 0xff; /* 0 .. 255 seconds */
+ GLuint64EXT seconds1 = t1->tv_sec & 0xff; /* 0 .. 255 seconds */
+ GLuint64EXT nanosec0 = (seconds0 * 1000000 + t0->tv_usec) * 1000;
+ GLuint64EXT nanosec1 = (seconds1 * 1000000 + t1->tv_usec) * 1000;
+ return nanosec1 - nanosec0;
}
@@ -1200,14 +1200,9 @@ xmesa_end_query(GLcontext *ctx, GLenum target, struct gl_query_object *q)
if (target == GL_TIME_ELAPSED_EXT) {
struct xmesa_query_object *xq = (struct xmesa_query_object *) q;
struct timeval endTime;
- unsigned int dt;
(void) gettimeofday(&endTime, NULL);
- dt = time_diff(&xq->StartTime, &endTime);
- /* clamp if we'd overflow a 32-bit unsigned int */
- if (dt >= 0xffffffffU / 1000U)
- q->Result = 0xffffffffU;
- else
- q->Result = dt * 1000; /* result is in nanoseconds! */
+ /* result is in nanoseconds! */
+ q->Result = time_diff(&xq->StartTime, &endTime);
}
q->Ready = GL_TRUE;
}
diff --git a/src/mesa/drivers/x11/xmesaP.h b/src/mesa/drivers/x11/xmesaP.h
index efe88a00442..5b9311ff873 100644
--- a/src/mesa/drivers/x11/xmesaP.h
+++ b/src/mesa/drivers/x11/xmesaP.h
@@ -551,8 +551,10 @@ extern void XMesaReset( void );
#ifdef XFree86Server
#define ENABLE_EXT_timer_query 0
+#elif defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
+#define ENABLE_EXT_timer_query 1 /* should have 64-bit GLuint64EXT */
#else
-#define ENABLE_EXT_timer_query 1
+#define ENABLE_EXT_timer_query 0 /* may not have 64-bit GLuint64EXT */
#endif
#endif