1/* 2 * Copyright © 2020 Advanced Micro Devices, Inc. 3 * 4 * Permission is hereby granted, free of charge, to any person obtaining a 5 * copy of this software and associated documentation files (the "Software"), 6 * to deal in the Software without restriction, including without limitation 7 * the rights to use, copy, modify, merge, publish, distribute, sublicense, 8 * and/or sell copies of the Software, and to permit persons to whom the 9 * Software is furnished to do so, subject to the following conditions: 10 * 11 * The above copyright notice and this permission notice (including the next 12 * paragraph) shall be included in all copies or substantial portions of the 13 * Software. 14 * 15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 18 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 20 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS 21 * IN THE SOFTWARE. 22 */ 23 24#include "main/glthread_marshal.h" 25#include "main/dispatch.h" 26 27uint32_t 28_mesa_unmarshal_GetIntegerv(struct gl_context *ctx, 29 const struct marshal_cmd_GetIntegerv *cmd, 30 const uint64_t *last) 31{ 32 unreachable("never executed"); 33 return 0; 34} 35 36void GLAPIENTRY 37_mesa_marshal_GetIntegerv(GLenum pname, GLint *p) 38{ 39 GET_CURRENT_CONTEXT(ctx); 40 41 /* TODO: Use get_hash_params.py to return values for items containing: 42 * - CONST( 43 * - CONTEXT_[A-Z]*(Const 44 */ 45 46 if (ctx->API != API_OPENGL_COMPAT) { 47 /* glthread only tracks these states for the compatibility profile. */ 48 _mesa_glthread_finish_before(ctx, "GetIntegerv"); 49 CALL_GetIntegerv(ctx->CurrentServerDispatch, (pname, p)); 50 return; 51 } 52 53 switch (pname) { 54 case GL_ACTIVE_TEXTURE: 55 *p = GL_TEXTURE0 + ctx->GLThread.ActiveTexture; 56 return; 57 case GL_ARRAY_BUFFER_BINDING: 58 *p = ctx->GLThread.CurrentArrayBufferName; 59 return; 60 case GL_ATTRIB_STACK_DEPTH: 61 *p = ctx->GLThread.AttribStackDepth; 62 return; 63 case GL_CLIENT_ACTIVE_TEXTURE: 64 *p = ctx->GLThread.ClientActiveTexture; 65 return; 66 case GL_CLIENT_ATTRIB_STACK_DEPTH: 67 *p = ctx->GLThread.ClientAttribStackTop; 68 return; 69 case GL_DRAW_INDIRECT_BUFFER_BINDING: 70 *p = ctx->GLThread.CurrentDrawIndirectBufferName; 71 return; 72 73 case GL_MATRIX_MODE: 74 *p = ctx->GLThread.MatrixMode; 75 return; 76 case GL_CURRENT_MATRIX_STACK_DEPTH_ARB: 77 *p = ctx->GLThread.MatrixStackDepth[ctx->GLThread.MatrixIndex] + 1; 78 return; 79 case GL_MODELVIEW_STACK_DEPTH: 80 *p = ctx->GLThread.MatrixStackDepth[M_MODELVIEW] + 1; 81 return; 82 case GL_PROJECTION_STACK_DEPTH: 83 *p = ctx->GLThread.MatrixStackDepth[M_PROJECTION] + 1; 84 return; 85 case GL_TEXTURE_STACK_DEPTH: 86 *p = ctx->GLThread.MatrixStackDepth[M_TEXTURE0 + ctx->GLThread.ActiveTexture] + 1; 87 return; 88 89 case GL_VERTEX_ARRAY: 90 *p = (ctx->GLThread.CurrentVAO->UserEnabled & (1 << VERT_ATTRIB_POS)) != 0; 91 return; 92 case GL_NORMAL_ARRAY: 93 *p = (ctx->GLThread.CurrentVAO->UserEnabled & (1 << VERT_ATTRIB_NORMAL)) != 0; 94 return; 95 case GL_COLOR_ARRAY: 96 *p = (ctx->GLThread.CurrentVAO->UserEnabled & (1 << VERT_ATTRIB_COLOR0)) != 0; 97 return; 98 case GL_SECONDARY_COLOR_ARRAY: 99 *p = (ctx->GLThread.CurrentVAO->UserEnabled & (1 << VERT_ATTRIB_COLOR1)) != 0; 100 return; 101 case GL_FOG_COORD_ARRAY: 102 *p = (ctx->GLThread.CurrentVAO->UserEnabled & (1 << VERT_ATTRIB_FOG)) != 0; 103 return; 104 case GL_INDEX_ARRAY: 105 *p = (ctx->GLThread.CurrentVAO->UserEnabled & (1 << VERT_ATTRIB_COLOR_INDEX)) != 0; 106 return; 107 case GL_EDGE_FLAG_ARRAY: 108 *p = (ctx->GLThread.CurrentVAO->UserEnabled & (1 << VERT_ATTRIB_EDGEFLAG)) != 0; 109 return; 110 case GL_TEXTURE_COORD_ARRAY: 111 *p = (ctx->GLThread.CurrentVAO->UserEnabled & 112 (1 << (VERT_ATTRIB_TEX0 + ctx->GLThread.ClientActiveTexture))) != 0; 113 return; 114 case GL_POINT_SIZE_ARRAY_OES: 115 *p = (ctx->GLThread.CurrentVAO->UserEnabled & (1 << VERT_ATTRIB_POINT_SIZE)) != 0; 116 return; 117 } 118 119 _mesa_glthread_finish_before(ctx, "GetIntegerv"); 120 CALL_GetIntegerv(ctx->CurrentServerDispatch, (pname, p)); 121} 122 123/* TODO: Implement glGetBooleanv, glGetFloatv, etc. if needed */ 124