glthread: implement glGetIntegerv for states that glthread tracks

for viewperf

Acked-by: Pierre-Eric Pelloux-Prayer <pierre-eric.pelloux-prayer@amd.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/8297>
This commit is contained in:
Marek Olšák 2020-10-02 23:14:13 -04:00 committed by Marge Bot
parent 6febe2b880
commit d8ad570b3e
4 changed files with 124 additions and 1 deletions

View file

@ -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"/>

View file

@ -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 \

View file

@ -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 */

View file

@ -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',