<div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote">On Mon, Feb 16, 2015 at 6:14 AM, Martin Peres <span dir="ltr"><<a href="mailto:martin.peres@linux.intel.com" target="_blank">martin.peres@linux.intel.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Signed-off-by: Martin Peres <<a href="mailto:martin.peres@linux.intel.com">martin.peres@linux.intel.com</a>><br>
---<br>
src/mapi/glapi/gen/ARB_direct_state_access.xml | 8 +++<br>
src/mesa/main/queryobj.c | 76 +++++++++++++++++++++++---<br>
src/mesa/main/queryobj.h | 2 +<br>
src/mesa/main/tests/dispatch_sanity.cpp | 1 +<br>
4 files changed, 80 insertions(+), 7 deletions(-)<br>
<br>
diff --git a/src/mapi/glapi/gen/ARB_direct_state_access.xml b/src/mapi/glapi/gen/ARB_direct_state_access.xml<br>
index 340dbba..652e8bc 100644<br>
--- a/src/mapi/glapi/gen/ARB_direct_state_access.xml<br>
+++ b/src/mapi/glapi/gen/ARB_direct_state_access.xml<br>
@@ -308,5 +308,13 @@<br>
<param name="params" type="GLint *" /><br>
</function><br>
<br>
+ <!-- Query object functions --><br>
+<br>
+ <function name="CreateQueries" offset="assign"><br>
+ <param name="target" type="GLenum" /><br>
+ <param name="n" type="GLsizei" /><br>
+ <param name="ids" type="GLuint *" /><br>
+ </function><br>
+<br>
</category><br>
</OpenGLAPI><br>
diff --git a/src/mesa/main/queryobj.c b/src/mesa/main/queryobj.c<br>
index 17eaaac..1bb74c9 100644<br>
--- a/src/mesa/main/queryobj.c<br>
+++ b/src/mesa/main/queryobj.c<br>
@@ -188,18 +188,22 @@ get_query_binding_point(struct gl_context *ctx, GLenum target, GLuint index)<br>
}<br>
}<br>
<br>
-<br>
-void GLAPIENTRY<br>
-_mesa_GenQueries(GLsizei n, GLuint *ids)<br>
+/**<br>
+ * Create $n query objects and store them in *ids. Make them of type $target<br>
+ * if dsa is set. Called from _mesa_GenQueries() and _mesa_CreateQueries().<br>
+ */<br>
+static void<br>
+create_queries(struct gl_context *ctx, GLenum target, GLsizei n, GLuint *ids,<br>
+ bool dsa)<br>
{<br>
+ const char *func = dsa ? "glGenQueries" : "glCreateQueries";<br>
GLuint first;<br>
- GET_CURRENT_CONTEXT(ctx);<br>
<br>
if (MESA_VERBOSE & VERBOSE_API)<br>
- _mesa_debug(ctx, "glGenQueries(%d)\n", n);<br>
+ _mesa_debug(ctx, "%s(%d)\n", func, n);<br>
<br>
if (n < 0) {<br>
- _mesa_error(ctx, GL_INVALID_VALUE, "glGenQueriesARB(n < 0)");<br>
+ _mesa_error(ctx, GL_INVALID_VALUE, "%s(n < 0)", func);<br>
return;<br>
}<br>
<br>
@@ -210,8 +214,12 @@ _mesa_GenQueries(GLsizei n, GLuint *ids)<br>
struct gl_query_object *q<br>
= ctx->Driver.NewQueryObject(ctx, first + i);<br>
if (!q) {<br>
- _mesa_error(ctx, GL_OUT_OF_MEMORY, "glGenQueriesARB");<br>
+ _mesa_error(ctx, GL_OUT_OF_MEMORY, "%s", func);<br>
return;<br>
+ } else if (dsa) {<br>
+ /* Do the equivalent of binding the buffer with a target */<br>
+ q->Target = target;<br>
+ q->EverBound = GL_TRUE;<br>
}<br>
ids[i] = first + i;<br>
_mesa_HashInsert(ctx->Query.QueryObjects, first + i, q);<br>
@@ -219,6 +227,36 @@ _mesa_GenQueries(GLsizei n, GLuint *ids)<br>
}<br>
}<br>
<br>
+void GLAPIENTRY<br>
+_mesa_GenQueries(GLsizei n, GLuint *ids)<br>
+{<br>
+ GET_CURRENT_CONTEXT(ctx);<br>
+ create_queries(ctx, 0, n, ids, false);<br>
+}<br>
+<br>
+void GLAPIENTRY<br>
+_mesa_CreateQueries(GLenum target, GLsizei n, GLuint *ids)<br>
+{<br>
+ GET_CURRENT_CONTEXT(ctx);<br>
+<br>
+ switch (target) {<br>
+ case GL_SAMPLES_PASSED:<br>
+ case GL_ANY_SAMPLES_PASSED:<br>
+ case GL_ANY_SAMPLES_PASSED_CONSERVATIVE:<br>
+ case GL_TIME_ELAPSED:<br>
+ case GL_TIMESTAMP:<br>
+ case GL_PRIMITIVES_GENERATED:<br>
+ case GL_TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN:<br>
+ break;<br>
+ default:<br>
+ _mesa_error(ctx, GL_INVALID_ENUM, "glCreateQueries(invalid target = %i)",<br>
+ target);<br></blockquote><div>I think it would be nicer to have "invalid target = %s", _mesa_lookup_enum_by_nr(target) in your error message, because otherwise the user might have to go looking through Mesa to find out which incorrect target they passed. For example, not everyone knows that 3553 = GL_TEXTURE_2D. (Although I do, for some sick reason :))<br> <br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
+ return;<br>
+ }<br>
+<br>
+ create_queries(ctx, target, n, ids, true);<br>
+}<br>
+<br>
<br>
void GLAPIENTRY<br>
_mesa_DeleteQueries(GLsizei n, const GLuint *ids)<br>
@@ -363,6 +401,18 @@ _mesa_BeginQueryIndexed(GLenum target, GLuint index, GLuint id)<br>
}<br>
}<br>
<br>
+ /* This possibly changes the target of a buffer allocated by<br>
+ * CreateQueries. Issue 39) in the ARB_direct_state_access extension states<br>
+ * the following:<br>
+ *<br>
+ * "CreateQueries adds a <target>, so strictly speaking the <target><br>
+ * command isn't needed for BeginQuery/EndQuery, but in the end, this also<br>
+ * isn't a selector, so we decided not to change it."<br>
+ *<br>
+ * Updating the target of the query object should be acceptable, so let's<br>
+ * do that.<br>
+ */<br>
+<br>
q->Target = target;<br>
q->Active = GL_TRUE;<br>
q->Result = 0;<br>
@@ -480,6 +530,18 @@ _mesa_QueryCounter(GLuint id, GLenum target)<br>
return;<br>
}<br>
<br>
+ /* This possibly changes the target of a buffer allocated by<br>
+ * CreateQueries. Issue 39) in the ARB_direct_state_access extension states<br>
+ * the following:<br>
+ *<br>
+ * "CreateQueries adds a <target>, so strictly speaking the <target><br>
+ * command isn't needed for BeginQuery/EndQuery, but in the end, this also<br>
+ * isn't a selector, so we decided not to change it."<br>
+ *<br>
+ * Updating the target of the query object should be acceptable, so let's<br>
+ * do that.<br>
+ */<br>
+<br>
q->Target = target;<br>
q->Result = 0;<br>
q->Ready = GL_FALSE;<br>
diff --git a/src/mesa/main/queryobj.h b/src/mesa/main/queryobj.h<br>
index 6cbcabd..431d420 100644<br>
--- a/src/mesa/main/queryobj.h<br>
+++ b/src/mesa/main/queryobj.h<br>
@@ -51,6 +51,8 @@ _mesa_free_queryobj_data(struct gl_context *ctx);<br>
void GLAPIENTRY<br>
_mesa_GenQueries(GLsizei n, GLuint *ids);<br>
void GLAPIENTRY<br>
+_mesa_CreateQueries(GLenum target, GLsizei n, GLuint *ids);<br>
+void GLAPIENTRY<br>
_mesa_DeleteQueries(GLsizei n, const GLuint *ids);<br>
GLboolean GLAPIENTRY<br>
_mesa_IsQuery(GLuint id);<br>
diff --git a/src/mesa/main/tests/dispatch_sanity.cpp b/src/mesa/main/tests/dispatch_sanity.cpp<br>
index ad5da83..ee448f1 100644<br>
--- a/src/mesa/main/tests/dispatch_sanity.cpp<br>
+++ b/src/mesa/main/tests/dispatch_sanity.cpp<br>
@@ -993,6 +993,7 @@ const struct function gl_core_functions_possible[] = {<br>
{ "glTextureStorage2DMultisample", 45, -1 },<br>
{ "glTextureStorage3DMultisample", 45, -1 },<br>
{ "glTextureBuffer", 45, -1 },<br>
+ { "glCreateQueries", 45, -1 },<br>
<br>
/* GL_EXT_polygon_offset_clamp */<br>
{ "glPolygonOffsetClampEXT", 11, -1 },<br>
<span class="HOEnZb"><font color="#888888">--<br>
2.3.0<br>
<br>
_______________________________________________<br>
mesa-dev mailing list<br>
<a href="mailto:mesa-dev@lists.freedesktop.org">mesa-dev@lists.freedesktop.org</a><br>
<a href="http://lists.freedesktop.org/mailman/listinfo/mesa-dev" target="_blank">http://lists.freedesktop.org/mailman/listinfo/mesa-dev</a><br></font></span></blockquote><div><br></div><div>Otherwise, looks good to me.<br><br></div><div>Reviewed-by: Laura Ekstrand <<a href="mailto:laura@jlekstrand.net">laura@jlekstrand.net</a>> <br></div></div><br></div></div>