+ /* From GL_EXT_occlusion_query_boolean spec:
+ *
+ * "Accepted by the <pname> parameter of GetQueryObjectivEXT and
+ * GetQueryObjectuivEXT:
+ *
+ * QUERY_RESULT_EXT 0x8866
+ * QUERY_RESULT_AVAILABLE_EXT 0x8867"
+ *
+ * Same rule is present also in ES 3.2 spec.
+ */
+ if (_mesa_is_gles(ctx) &&
+ (pname != GL_QUERY_RESULT && pname != GL_QUERY_RESULT_AVAILABLE)) {
+ _mesa_error(ctx, GL_INVALID_ENUM, "%s(%s)", func,
+ _mesa_enum_to_string(pname));
+ return;
+ }
+
+ if (buf && buf != ctx->Shared->NullBufferObj) {
+ bool is_64bit = ptype == GL_INT64_ARB ||
+ ptype == GL_UNSIGNED_INT64_ARB;
+ if (!ctx->Extensions.ARB_query_buffer_object &&
+ !ctx->Extensions.EXT_disjoint_timer_query) {
+ _mesa_error(ctx, GL_INVALID_OPERATION, "%s(not supported)", func);
+ return;
+ }
+ if (buf->Size < offset + 4 * (is_64bit ? 2 : 1)) {
+ _mesa_error(ctx, GL_INVALID_OPERATION, "%s(out of bounds)", func);
+ return;
+ }
+
+ if (offset < 0) {
+ _mesa_error(ctx, GL_INVALID_VALUE, "%s(offset is negative)", func);
+ return;
+ }
+
+ switch (pname) {
+ case GL_QUERY_RESULT:
+ case GL_QUERY_RESULT_NO_WAIT:
+ case GL_QUERY_RESULT_AVAILABLE:
+ case GL_QUERY_TARGET:
+ ctx->Driver.StoreQueryResult(ctx, q, buf, offset, pname, ptype);
+ return;
+ }
+
+ /* fall through to get error below */
+ }
+