Mesa (master): glthread: implement glGetIntegerv for states that glthread tracks
GitLab Mirror
gitlab-mirror at kemper.freedesktop.org
Thu Jan 21 00:30:49 UTC 2021
Module: Mesa
Branch: master
Commit: d8ad570b3ee7803db5862108aa5ac66ef5beaffb
URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=d8ad570b3ee7803db5862108aa5ac66ef5beaffb
Author: Marek Olšák <marek.olsak at amd.com>
Date: Fri Oct 2 23:14:13 2020 -0400
glthread: implement glGetIntegerv for states that glthread tracks
for viewperf
Acked-by: Pierre-Eric Pelloux-Prayer <pierre-eric.pelloux-prayer at amd.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/8297>
---
src/mapi/glapi/gen/gl_API.xml | 2 +-
src/mesa/Makefile.sources | 1 +
src/mesa/main/glthread_get.c | 121 ++++++++++++++++++++++++++++++++++++++++++
src/mesa/meson.build | 1 +
4 files changed, 124 insertions(+), 1 deletion(-)
diff --git a/src/mapi/glapi/gen/gl_API.xml b/src/mapi/glapi/gen/gl_API.xml
index bd39ce3e20d..7c754b8671e 100644
--- a/src/mapi/glapi/gen/gl_API.xml
+++ b/src/mapi/glapi/gen/gl_API.xml
@@ -2712,7 +2712,7 @@
<glx sop="116" handcode="client"/>
</function>
- <function name="GetIntegerv" es1="1.0" es2="2.0">
+ <function name="GetIntegerv" es1="1.0" es2="2.0" marshal="custom">
<param name="pname" type="GLenum"/>
<param name="params" type="GLint *" output="true" variable_param="pname"/>
<glx sop="117" handcode="client"/>
diff --git a/src/mesa/Makefile.sources b/src/mesa/Makefile.sources
index 83addd8ac14..23aa945fa47 100644
--- a/src/mesa/Makefile.sources
+++ b/src/mesa/Makefile.sources
@@ -123,6 +123,7 @@ MAIN_FILES = \
main/glthread.h \
main/glthread_bufferobj.c \
main/glthread_draw.c \
+ main/glthread_get.c \
main/glthread_marshal.h \
main/glthread_shaderobj.c \
main/glthread_varray.c \
diff --git a/src/mesa/main/glthread_get.c b/src/mesa/main/glthread_get.c
index e69de29bb2d..34627395173 100644
--- a/src/mesa/main/glthread_get.c
+++ b/src/mesa/main/glthread_get.c
@@ -0,0 +1,121 @@
+/*
+ * Copyright © 2020 Advanced Micro Devices, Inc.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the next
+ * paragraph) shall be included in all copies or substantial portions of the
+ * Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
+ * IN THE SOFTWARE.
+ */
+
+#include "main/glthread_marshal.h"
+#include "main/dispatch.h"
+
+void
+_mesa_unmarshal_GetIntegerv(struct gl_context *ctx,
+ const struct marshal_cmd_GetIntegerv *cmd)
+{
+ unreachable("never executed");
+}
+
+void GLAPIENTRY
+_mesa_marshal_GetIntegerv(GLenum pname, GLint *p)
+{
+ GET_CURRENT_CONTEXT(ctx);
+
+ /* TODO: Use get_hash_params.py to return values for items containing:
+ * - CONST(
+ * - CONTEXT_[A-Z]*(Const
+ */
+
+ if (ctx->API != API_OPENGL_COMPAT) {
+ /* glthread only tracks these states for the compatibility profile. */
+ _mesa_glthread_finish_before(ctx, "GetIntegerv");
+ CALL_GetIntegerv(ctx->CurrentServerDispatch, (pname, p));
+ return;
+ }
+
+ switch (pname) {
+ case GL_ACTIVE_TEXTURE:
+ *p = GL_TEXTURE0 + ctx->GLThread.ActiveTexture;
+ return;
+ case GL_ARRAY_BUFFER_BINDING:
+ *p = ctx->GLThread.CurrentArrayBufferName;
+ return;
+ case GL_ATTRIB_STACK_DEPTH:
+ *p = ctx->GLThread.AttribStackDepth;
+ return;
+ case GL_CLIENT_ACTIVE_TEXTURE:
+ *p = ctx->GLThread.ClientActiveTexture;
+ return;
+ case GL_CLIENT_ATTRIB_STACK_DEPTH:
+ *p = ctx->GLThread.ClientAttribStackTop;
+ return;
+ case GL_DRAW_INDIRECT_BUFFER_BINDING:
+ *p = ctx->GLThread.CurrentDrawIndirectBufferName;
+ return;
+
+ case GL_MATRIX_MODE:
+ *p = ctx->GLThread.MatrixMode;
+ return;
+ case GL_CURRENT_MATRIX_STACK_DEPTH_ARB:
+ *p = ctx->GLThread.MatrixStackDepth[ctx->GLThread.MatrixIndex] + 1;
+ return;
+ case GL_MODELVIEW_STACK_DEPTH:
+ *p = ctx->GLThread.MatrixStackDepth[M_MODELVIEW] + 1;
+ return;
+ case GL_PROJECTION_STACK_DEPTH:
+ *p = ctx->GLThread.MatrixStackDepth[M_PROJECTION] + 1;
+ return;
+ case GL_TEXTURE_STACK_DEPTH:
+ *p = ctx->GLThread.MatrixStackDepth[M_TEXTURE0 + ctx->GLThread.ActiveTexture] + 1;
+ return;
+
+ case GL_VERTEX_ARRAY:
+ *p = (ctx->GLThread.CurrentVAO->UserEnabled & (1 << VERT_ATTRIB_POS)) != 0;
+ return;
+ case GL_NORMAL_ARRAY:
+ *p = (ctx->GLThread.CurrentVAO->UserEnabled & (1 << VERT_ATTRIB_NORMAL)) != 0;
+ return;
+ case GL_COLOR_ARRAY:
+ *p = (ctx->GLThread.CurrentVAO->UserEnabled & (1 << VERT_ATTRIB_COLOR0)) != 0;
+ return;
+ case GL_SECONDARY_COLOR_ARRAY:
+ *p = (ctx->GLThread.CurrentVAO->UserEnabled & (1 << VERT_ATTRIB_COLOR1)) != 0;
+ return;
+ case GL_FOG_COORD_ARRAY:
+ *p = (ctx->GLThread.CurrentVAO->UserEnabled & (1 << VERT_ATTRIB_FOG)) != 0;
+ return;
+ case GL_INDEX_ARRAY:
+ *p = (ctx->GLThread.CurrentVAO->UserEnabled & (1 << VERT_ATTRIB_COLOR_INDEX)) != 0;
+ return;
+ case GL_EDGE_FLAG_ARRAY:
+ *p = (ctx->GLThread.CurrentVAO->UserEnabled & (1 << VERT_ATTRIB_EDGEFLAG)) != 0;
+ return;
+ case GL_TEXTURE_COORD_ARRAY:
+ *p = (ctx->GLThread.CurrentVAO->UserEnabled &
+ (1 << (VERT_ATTRIB_TEX0 + ctx->GLThread.ClientActiveTexture))) != 0;
+ return;
+ case GL_POINT_SIZE_ARRAY_OES:
+ *p = (ctx->GLThread.CurrentVAO->UserEnabled & (1 << VERT_ATTRIB_POINT_SIZE)) != 0;
+ return;
+ }
+
+ _mesa_glthread_finish_before(ctx, "GetIntegerv");
+ CALL_GetIntegerv(ctx->CurrentServerDispatch, (pname, p));
+}
+
+/* TODO: Implement glGetBooleanv, glGetFloatv, etc. if needed */
diff --git a/src/mesa/meson.build b/src/mesa/meson.build
index d986a0a17a0..fc7e09f5fe1 100644
--- a/src/mesa/meson.build
+++ b/src/mesa/meson.build
@@ -166,6 +166,7 @@ files_libmesa_common = files(
'main/glthread.h',
'main/glthread_bufferobj.c',
'main/glthread_draw.c',
+ 'main/glthread_get.c',
'main/glthread_marshal.h',
'main/glthread_shaderobj.c',
'main/glthread_varray.c',
More information about the mesa-commit
mailing list