1bf215546Sopenharmony_ci/*
2bf215546Sopenharmony_ci * Mesa 3-D graphics library
3bf215546Sopenharmony_ci *
4bf215546Sopenharmony_ci * Copyright (C) 1999-2008  Brian Paul   All Rights Reserved.
5bf215546Sopenharmony_ci *
6bf215546Sopenharmony_ci * Permission is hereby granted, free of charge, to any person obtaining a
7bf215546Sopenharmony_ci * copy of this software and associated documentation files (the "Software"),
8bf215546Sopenharmony_ci * to deal in the Software without restriction, including without limitation
9bf215546Sopenharmony_ci * the rights to use, copy, modify, merge, publish, distribute, sublicense,
10bf215546Sopenharmony_ci * and/or sell copies of the Software, and to permit persons to whom the
11bf215546Sopenharmony_ci * Software is furnished to do so, subject to the following conditions:
12bf215546Sopenharmony_ci *
13bf215546Sopenharmony_ci * The above copyright notice and this permission notice shall be included
14bf215546Sopenharmony_ci * in all copies or substantial portions of the Software.
15bf215546Sopenharmony_ci *
16bf215546Sopenharmony_ci * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
17bf215546Sopenharmony_ci * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18bf215546Sopenharmony_ci * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
19bf215546Sopenharmony_ci * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
20bf215546Sopenharmony_ci * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
21bf215546Sopenharmony_ci * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
22bf215546Sopenharmony_ci * OTHER DEALINGS IN THE SOFTWARE.
23bf215546Sopenharmony_ci */
24bf215546Sopenharmony_ci
25bf215546Sopenharmony_ci
26bf215546Sopenharmony_ci#include <stdbool.h>
27bf215546Sopenharmony_ci#include "glheader.h"
28bf215546Sopenharmony_ci#include "context.h"
29bf215546Sopenharmony_ci#include "debug_output.h"
30bf215546Sopenharmony_ci#include "get.h"
31bf215546Sopenharmony_ci#include "enums.h"
32bf215546Sopenharmony_ci#include "extensions.h"
33bf215546Sopenharmony_ci#include "mtypes.h"
34bf215546Sopenharmony_ci#include "macros.h"
35bf215546Sopenharmony_ci#include "version.h"
36bf215546Sopenharmony_ci#include "spirv_extensions.h"
37bf215546Sopenharmony_ci#include "api_exec_decl.h"
38bf215546Sopenharmony_ci
39bf215546Sopenharmony_ci#include "pipe/p_context.h"
40bf215546Sopenharmony_ci#include "pipe/p_screen.h"
41bf215546Sopenharmony_ci
42bf215546Sopenharmony_ci/**
43bf215546Sopenharmony_ci * Return the string for a glGetString(GL_SHADING_LANGUAGE_VERSION) query.
44bf215546Sopenharmony_ci */
45bf215546Sopenharmony_cistatic const GLubyte *
46bf215546Sopenharmony_cishading_language_version(struct gl_context *ctx)
47bf215546Sopenharmony_ci{
48bf215546Sopenharmony_ci   switch (ctx->API) {
49bf215546Sopenharmony_ci   case API_OPENGL_COMPAT:
50bf215546Sopenharmony_ci   case API_OPENGL_CORE:
51bf215546Sopenharmony_ci      switch (ctx->Const.GLSLVersion) {
52bf215546Sopenharmony_ci      case 120:
53bf215546Sopenharmony_ci         return (const GLubyte *) "1.20";
54bf215546Sopenharmony_ci      case 130:
55bf215546Sopenharmony_ci         return (const GLubyte *) "1.30";
56bf215546Sopenharmony_ci      case 140:
57bf215546Sopenharmony_ci         return (const GLubyte *) "1.40";
58bf215546Sopenharmony_ci      case 150:
59bf215546Sopenharmony_ci         return (const GLubyte *) "1.50";
60bf215546Sopenharmony_ci      case 330:
61bf215546Sopenharmony_ci         return (const GLubyte *) "3.30";
62bf215546Sopenharmony_ci      case 400:
63bf215546Sopenharmony_ci         return (const GLubyte *) "4.00";
64bf215546Sopenharmony_ci      case 410:
65bf215546Sopenharmony_ci         return (const GLubyte *) "4.10";
66bf215546Sopenharmony_ci      case 420:
67bf215546Sopenharmony_ci         return (const GLubyte *) "4.20";
68bf215546Sopenharmony_ci      case 430:
69bf215546Sopenharmony_ci         return (const GLubyte *) "4.30";
70bf215546Sopenharmony_ci      case 440:
71bf215546Sopenharmony_ci         return (const GLubyte *) "4.40";
72bf215546Sopenharmony_ci      case 450:
73bf215546Sopenharmony_ci         return (const GLubyte *) "4.50";
74bf215546Sopenharmony_ci      case 460:
75bf215546Sopenharmony_ci         return (const GLubyte *) "4.60";
76bf215546Sopenharmony_ci      default:
77bf215546Sopenharmony_ci         _mesa_problem(ctx,
78bf215546Sopenharmony_ci                       "Invalid GLSL version in shading_language_version()");
79bf215546Sopenharmony_ci         return (const GLubyte *) 0;
80bf215546Sopenharmony_ci      }
81bf215546Sopenharmony_ci      break;
82bf215546Sopenharmony_ci
83bf215546Sopenharmony_ci   case API_OPENGLES2:
84bf215546Sopenharmony_ci      switch (ctx->Version) {
85bf215546Sopenharmony_ci      case 20:
86bf215546Sopenharmony_ci         return (const GLubyte *) "OpenGL ES GLSL ES 1.0.16";
87bf215546Sopenharmony_ci      case 30:
88bf215546Sopenharmony_ci         return (const GLubyte *) "OpenGL ES GLSL ES 3.00";
89bf215546Sopenharmony_ci      case 31:
90bf215546Sopenharmony_ci         return (const GLubyte *) "OpenGL ES GLSL ES 3.10";
91bf215546Sopenharmony_ci      case 32:
92bf215546Sopenharmony_ci         return (const GLubyte *) "OpenGL ES GLSL ES 3.20";
93bf215546Sopenharmony_ci      default:
94bf215546Sopenharmony_ci         _mesa_problem(ctx,
95bf215546Sopenharmony_ci                       "Invalid OpenGL ES version in shading_language_version()");
96bf215546Sopenharmony_ci         return (const GLubyte *) 0;
97bf215546Sopenharmony_ci      }
98bf215546Sopenharmony_ci   case API_OPENGLES:
99bf215546Sopenharmony_ci      FALLTHROUGH;
100bf215546Sopenharmony_ci
101bf215546Sopenharmony_ci   default:
102bf215546Sopenharmony_ci      _mesa_problem(ctx, "Unexpected API value in shading_language_version()");
103bf215546Sopenharmony_ci      return (const GLubyte *) 0;
104bf215546Sopenharmony_ci   }
105bf215546Sopenharmony_ci}
106bf215546Sopenharmony_ci
107bf215546Sopenharmony_ci
108bf215546Sopenharmony_ci/**
109bf215546Sopenharmony_ci * Query string-valued state.  The return value should _not_ be freed by
110bf215546Sopenharmony_ci * the caller.
111bf215546Sopenharmony_ci *
112bf215546Sopenharmony_ci * \param name  the state variable to query.
113bf215546Sopenharmony_ci *
114bf215546Sopenharmony_ci * \sa glGetString().
115bf215546Sopenharmony_ci *
116bf215546Sopenharmony_ci * Tries to get the string from dd_function_table::GetString, otherwise returns
117bf215546Sopenharmony_ci * the hardcoded strings.
118bf215546Sopenharmony_ci */
119bf215546Sopenharmony_ciconst GLubyte * GLAPIENTRY
120bf215546Sopenharmony_ci_mesa_GetString( GLenum name )
121bf215546Sopenharmony_ci{
122bf215546Sopenharmony_ci   GET_CURRENT_CONTEXT(ctx);
123bf215546Sopenharmony_ci   static const char *vendor = "Brian Paul";
124bf215546Sopenharmony_ci   static const char *renderer = "Mesa";
125bf215546Sopenharmony_ci
126bf215546Sopenharmony_ci   if (!ctx)
127bf215546Sopenharmony_ci      return NULL;
128bf215546Sopenharmony_ci
129bf215546Sopenharmony_ci   ASSERT_OUTSIDE_BEGIN_END_WITH_RETVAL(ctx, NULL);
130bf215546Sopenharmony_ci
131bf215546Sopenharmony_ci   if (ctx->Const.VendorOverride && name == GL_VENDOR) {
132bf215546Sopenharmony_ci      return (const GLubyte *) ctx->Const.VendorOverride;
133bf215546Sopenharmony_ci   }
134bf215546Sopenharmony_ci
135bf215546Sopenharmony_ci   if (ctx->Const.RendererOverride && name == GL_RENDERER) {
136bf215546Sopenharmony_ci      return (const GLubyte *) ctx->Const.RendererOverride;
137bf215546Sopenharmony_ci   }
138bf215546Sopenharmony_ci
139bf215546Sopenharmony_ci   struct pipe_screen *screen = ctx->pipe->screen;
140bf215546Sopenharmony_ci
141bf215546Sopenharmony_ci   switch (name) {
142bf215546Sopenharmony_ci      case GL_VENDOR: {
143bf215546Sopenharmony_ci         const GLubyte *str = (const GLubyte *)screen->get_vendor(screen);
144bf215546Sopenharmony_ci         if (str)
145bf215546Sopenharmony_ci            return str;
146bf215546Sopenharmony_ci         return (const GLubyte *) vendor;
147bf215546Sopenharmony_ci      }
148bf215546Sopenharmony_ci      case GL_RENDERER: {
149bf215546Sopenharmony_ci         const GLubyte *str = (const GLubyte *)screen->get_name(screen);
150bf215546Sopenharmony_ci         if (str)
151bf215546Sopenharmony_ci            return str;
152bf215546Sopenharmony_ci         return (const GLubyte *) renderer;
153bf215546Sopenharmony_ci      }
154bf215546Sopenharmony_ci      case GL_VERSION:
155bf215546Sopenharmony_ci         return (const GLubyte *) ctx->VersionString;
156bf215546Sopenharmony_ci      case GL_EXTENSIONS:
157bf215546Sopenharmony_ci         if (ctx->API == API_OPENGL_CORE) {
158bf215546Sopenharmony_ci            _mesa_error(ctx, GL_INVALID_ENUM, "glGetString(GL_EXTENSIONS)");
159bf215546Sopenharmony_ci            return (const GLubyte *) 0;
160bf215546Sopenharmony_ci         }
161bf215546Sopenharmony_ci         if (!ctx->Extensions.String)
162bf215546Sopenharmony_ci            ctx->Extensions.String = _mesa_make_extension_string(ctx);
163bf215546Sopenharmony_ci         return (const GLubyte *) ctx->Extensions.String;
164bf215546Sopenharmony_ci      case GL_SHADING_LANGUAGE_VERSION:
165bf215546Sopenharmony_ci         if (ctx->API == API_OPENGLES)
166bf215546Sopenharmony_ci            break;
167bf215546Sopenharmony_ci	 return shading_language_version(ctx);
168bf215546Sopenharmony_ci      case GL_PROGRAM_ERROR_STRING_ARB:
169bf215546Sopenharmony_ci         if (ctx->API == API_OPENGL_COMPAT &&
170bf215546Sopenharmony_ci             (ctx->Extensions.ARB_fragment_program ||
171bf215546Sopenharmony_ci              ctx->Extensions.ARB_vertex_program)) {
172bf215546Sopenharmony_ci            return (const GLubyte *) ctx->Program.ErrorString;
173bf215546Sopenharmony_ci         }
174bf215546Sopenharmony_ci         break;
175bf215546Sopenharmony_ci      default:
176bf215546Sopenharmony_ci         break;
177bf215546Sopenharmony_ci   }
178bf215546Sopenharmony_ci
179bf215546Sopenharmony_ci   _mesa_error( ctx, GL_INVALID_ENUM, "glGetString" );
180bf215546Sopenharmony_ci   return (const GLubyte *) 0;
181bf215546Sopenharmony_ci}
182bf215546Sopenharmony_ci
183bf215546Sopenharmony_ci
184bf215546Sopenharmony_ci/**
185bf215546Sopenharmony_ci * GL3
186bf215546Sopenharmony_ci */
187bf215546Sopenharmony_ciconst GLubyte * GLAPIENTRY
188bf215546Sopenharmony_ci_mesa_GetStringi(GLenum name, GLuint index)
189bf215546Sopenharmony_ci{
190bf215546Sopenharmony_ci   GET_CURRENT_CONTEXT(ctx);
191bf215546Sopenharmony_ci
192bf215546Sopenharmony_ci   if (!ctx)
193bf215546Sopenharmony_ci      return NULL;
194bf215546Sopenharmony_ci
195bf215546Sopenharmony_ci   ASSERT_OUTSIDE_BEGIN_END_WITH_RETVAL(ctx, NULL);
196bf215546Sopenharmony_ci
197bf215546Sopenharmony_ci   switch (name) {
198bf215546Sopenharmony_ci   case GL_EXTENSIONS:
199bf215546Sopenharmony_ci      if (index >= _mesa_get_extension_count(ctx)) {
200bf215546Sopenharmony_ci         _mesa_error(ctx, GL_INVALID_VALUE, "glGetStringi(index=%u)", index);
201bf215546Sopenharmony_ci         return (const GLubyte *) 0;
202bf215546Sopenharmony_ci      }
203bf215546Sopenharmony_ci      return _mesa_get_enabled_extension(ctx, index);
204bf215546Sopenharmony_ci   case GL_SHADING_LANGUAGE_VERSION:
205bf215546Sopenharmony_ci      {
206bf215546Sopenharmony_ci         char *version;
207bf215546Sopenharmony_ci         int num;
208bf215546Sopenharmony_ci         if (!_mesa_is_desktop_gl(ctx) || ctx->Version < 43) {
209bf215546Sopenharmony_ci            _mesa_error(ctx, GL_INVALID_ENUM,
210bf215546Sopenharmony_ci                        "glGetStringi(GL_SHADING_LANGUAGE_VERSION): "
211bf215546Sopenharmony_ci                        "supported only in GL4.3 and later");
212bf215546Sopenharmony_ci            return (const GLubyte *) 0;
213bf215546Sopenharmony_ci         }
214bf215546Sopenharmony_ci         num = _mesa_get_shading_language_version(ctx, index, &version);
215bf215546Sopenharmony_ci         if (index >= num) {
216bf215546Sopenharmony_ci            _mesa_error(ctx, GL_INVALID_VALUE,
217bf215546Sopenharmony_ci                        "glGetStringi(GL_SHADING_LANGUAGE_VERSION, index=%d)",
218bf215546Sopenharmony_ci                        index);
219bf215546Sopenharmony_ci            return (const GLubyte *) 0;
220bf215546Sopenharmony_ci         }
221bf215546Sopenharmony_ci         return (const GLubyte *) version;
222bf215546Sopenharmony_ci      }
223bf215546Sopenharmony_ci   case GL_SPIR_V_EXTENSIONS:
224bf215546Sopenharmony_ci      if (!ctx->Extensions.ARB_spirv_extensions) {
225bf215546Sopenharmony_ci         _mesa_error(ctx, GL_INVALID_ENUM, "glGetStringi");
226bf215546Sopenharmony_ci         return (const GLubyte *) 0;
227bf215546Sopenharmony_ci      }
228bf215546Sopenharmony_ci
229bf215546Sopenharmony_ci      if (index >= _mesa_get_spirv_extension_count(ctx)) {
230bf215546Sopenharmony_ci         _mesa_error(ctx, GL_INVALID_VALUE, "glGetStringi(index=%u)", index);
231bf215546Sopenharmony_ci         return (const GLubyte *) 0;
232bf215546Sopenharmony_ci      }
233bf215546Sopenharmony_ci      return _mesa_get_enabled_spirv_extension(ctx, index);
234bf215546Sopenharmony_ci
235bf215546Sopenharmony_ci   default:
236bf215546Sopenharmony_ci      _mesa_error(ctx, GL_INVALID_ENUM, "glGetStringi");
237bf215546Sopenharmony_ci      return (const GLubyte *) 0;
238bf215546Sopenharmony_ci   }
239bf215546Sopenharmony_ci}
240bf215546Sopenharmony_ci
241bf215546Sopenharmony_ci
242bf215546Sopenharmony_civoid
243bf215546Sopenharmony_ci_get_vao_pointerv(GLenum pname, struct gl_vertex_array_object* vao,
244bf215546Sopenharmony_ci                  GLvoid **params, const char* callerstr )
245bf215546Sopenharmony_ci{
246bf215546Sopenharmony_ci   GET_CURRENT_CONTEXT(ctx);
247bf215546Sopenharmony_ci   const GLuint clientUnit = ctx->Array.ActiveTexture;
248bf215546Sopenharmony_ci
249bf215546Sopenharmony_ci   if (!params)
250bf215546Sopenharmony_ci      return;
251bf215546Sopenharmony_ci
252bf215546Sopenharmony_ci   if (MESA_VERBOSE & VERBOSE_API)
253bf215546Sopenharmony_ci      _mesa_debug(ctx, "%s %s\n", callerstr, _mesa_enum_to_string(pname));
254bf215546Sopenharmony_ci
255bf215546Sopenharmony_ci   switch (pname) {
256bf215546Sopenharmony_ci      case GL_VERTEX_ARRAY_POINTER:
257bf215546Sopenharmony_ci         if (ctx->API != API_OPENGL_COMPAT && ctx->API != API_OPENGLES)
258bf215546Sopenharmony_ci            goto invalid_pname;
259bf215546Sopenharmony_ci         *params = (GLvoid *) vao->VertexAttrib[VERT_ATTRIB_POS].Ptr;
260bf215546Sopenharmony_ci         break;
261bf215546Sopenharmony_ci      case GL_NORMAL_ARRAY_POINTER:
262bf215546Sopenharmony_ci         if (ctx->API != API_OPENGL_COMPAT && ctx->API != API_OPENGLES)
263bf215546Sopenharmony_ci            goto invalid_pname;
264bf215546Sopenharmony_ci         *params = (GLvoid *) vao->VertexAttrib[VERT_ATTRIB_NORMAL].Ptr;
265bf215546Sopenharmony_ci         break;
266bf215546Sopenharmony_ci      case GL_COLOR_ARRAY_POINTER:
267bf215546Sopenharmony_ci         if (ctx->API != API_OPENGL_COMPAT && ctx->API != API_OPENGLES)
268bf215546Sopenharmony_ci            goto invalid_pname;
269bf215546Sopenharmony_ci         *params = (GLvoid *) vao->VertexAttrib[VERT_ATTRIB_COLOR0].Ptr;
270bf215546Sopenharmony_ci         break;
271bf215546Sopenharmony_ci      case GL_SECONDARY_COLOR_ARRAY_POINTER_EXT:
272bf215546Sopenharmony_ci         if (ctx->API != API_OPENGL_COMPAT)
273bf215546Sopenharmony_ci            goto invalid_pname;
274bf215546Sopenharmony_ci         *params = (GLvoid *) vao->VertexAttrib[VERT_ATTRIB_COLOR1].Ptr;
275bf215546Sopenharmony_ci         break;
276bf215546Sopenharmony_ci      case GL_FOG_COORDINATE_ARRAY_POINTER_EXT:
277bf215546Sopenharmony_ci         if (ctx->API != API_OPENGL_COMPAT)
278bf215546Sopenharmony_ci            goto invalid_pname;
279bf215546Sopenharmony_ci         *params = (GLvoid *) vao->VertexAttrib[VERT_ATTRIB_FOG].Ptr;
280bf215546Sopenharmony_ci         break;
281bf215546Sopenharmony_ci      case GL_INDEX_ARRAY_POINTER:
282bf215546Sopenharmony_ci         if (ctx->API != API_OPENGL_COMPAT)
283bf215546Sopenharmony_ci            goto invalid_pname;
284bf215546Sopenharmony_ci         *params = (GLvoid *) vao->VertexAttrib[VERT_ATTRIB_COLOR_INDEX].Ptr;
285bf215546Sopenharmony_ci         break;
286bf215546Sopenharmony_ci      case GL_TEXTURE_COORD_ARRAY_POINTER:
287bf215546Sopenharmony_ci         if (ctx->API != API_OPENGL_COMPAT && ctx->API != API_OPENGLES)
288bf215546Sopenharmony_ci            goto invalid_pname;
289bf215546Sopenharmony_ci         *params = (GLvoid *) vao->VertexAttrib[VERT_ATTRIB_TEX(clientUnit)].Ptr;
290bf215546Sopenharmony_ci         break;
291bf215546Sopenharmony_ci      case GL_EDGE_FLAG_ARRAY_POINTER:
292bf215546Sopenharmony_ci         if (ctx->API != API_OPENGL_COMPAT)
293bf215546Sopenharmony_ci            goto invalid_pname;
294bf215546Sopenharmony_ci         *params = (GLvoid *) vao->VertexAttrib[VERT_ATTRIB_EDGEFLAG].Ptr;
295bf215546Sopenharmony_ci         break;
296bf215546Sopenharmony_ci      case GL_FEEDBACK_BUFFER_POINTER:
297bf215546Sopenharmony_ci         if (ctx->API != API_OPENGL_COMPAT)
298bf215546Sopenharmony_ci            goto invalid_pname;
299bf215546Sopenharmony_ci         *params = ctx->Feedback.Buffer;
300bf215546Sopenharmony_ci         break;
301bf215546Sopenharmony_ci      case GL_SELECTION_BUFFER_POINTER:
302bf215546Sopenharmony_ci         if (ctx->API != API_OPENGL_COMPAT)
303bf215546Sopenharmony_ci            goto invalid_pname;
304bf215546Sopenharmony_ci         *params = ctx->Select.Buffer;
305bf215546Sopenharmony_ci         break;
306bf215546Sopenharmony_ci      case GL_POINT_SIZE_ARRAY_POINTER_OES:
307bf215546Sopenharmony_ci         if (ctx->API != API_OPENGLES)
308bf215546Sopenharmony_ci            goto invalid_pname;
309bf215546Sopenharmony_ci         *params = (GLvoid *) vao->VertexAttrib[VERT_ATTRIB_POINT_SIZE].Ptr;
310bf215546Sopenharmony_ci         break;
311bf215546Sopenharmony_ci      case GL_DEBUG_CALLBACK_FUNCTION_ARB:
312bf215546Sopenharmony_ci      case GL_DEBUG_CALLBACK_USER_PARAM_ARB:
313bf215546Sopenharmony_ci         *params = _mesa_get_debug_state_ptr(ctx, pname);
314bf215546Sopenharmony_ci         break;
315bf215546Sopenharmony_ci      default:
316bf215546Sopenharmony_ci         goto invalid_pname;
317bf215546Sopenharmony_ci   }
318bf215546Sopenharmony_ci
319bf215546Sopenharmony_ci   return;
320bf215546Sopenharmony_ci
321bf215546Sopenharmony_ciinvalid_pname:
322bf215546Sopenharmony_ci   _mesa_error( ctx, GL_INVALID_ENUM, "%s", callerstr);
323bf215546Sopenharmony_ci   return;
324bf215546Sopenharmony_ci}
325bf215546Sopenharmony_ci
326bf215546Sopenharmony_ci
327bf215546Sopenharmony_ci/**
328bf215546Sopenharmony_ci * Return pointer-valued state, such as a vertex array pointer.
329bf215546Sopenharmony_ci *
330bf215546Sopenharmony_ci * \param pname  names state to be queried
331bf215546Sopenharmony_ci * \param params  returns the pointer value
332bf215546Sopenharmony_ci *
333bf215546Sopenharmony_ci * \sa glGetPointerv().
334bf215546Sopenharmony_ci *
335bf215546Sopenharmony_ci * Tries to get the specified pointer via dd_function_table::GetPointerv,
336bf215546Sopenharmony_ci * otherwise gets the specified pointer from the current context.
337bf215546Sopenharmony_ci */
338bf215546Sopenharmony_civoid GLAPIENTRY
339bf215546Sopenharmony_ci_mesa_GetPointerv( GLenum pname, GLvoid **params )
340bf215546Sopenharmony_ci{
341bf215546Sopenharmony_ci   GET_CURRENT_CONTEXT(ctx);
342bf215546Sopenharmony_ci   const char *callerstr;
343bf215546Sopenharmony_ci
344bf215546Sopenharmony_ci   if (_mesa_is_desktop_gl(ctx))
345bf215546Sopenharmony_ci      callerstr = "glGetPointerv";
346bf215546Sopenharmony_ci   else
347bf215546Sopenharmony_ci      callerstr = "glGetPointervKHR";
348bf215546Sopenharmony_ci
349bf215546Sopenharmony_ci   if (!params)
350bf215546Sopenharmony_ci      return;
351bf215546Sopenharmony_ci
352bf215546Sopenharmony_ci   _get_vao_pointerv(pname, ctx->Array.VAO, params, callerstr);
353bf215546Sopenharmony_ci}
354bf215546Sopenharmony_ci
355bf215546Sopenharmony_ci
356bf215546Sopenharmony_civoid GLAPIENTRY
357bf215546Sopenharmony_ci_mesa_GetPointerIndexedvEXT( GLenum pname, GLuint index, GLvoid **params )
358bf215546Sopenharmony_ci{
359bf215546Sopenharmony_ci   GET_CURRENT_CONTEXT(ctx);
360bf215546Sopenharmony_ci
361bf215546Sopenharmony_ci   if (!params)
362bf215546Sopenharmony_ci      return;
363bf215546Sopenharmony_ci
364bf215546Sopenharmony_ci   if (MESA_VERBOSE & VERBOSE_API)
365bf215546Sopenharmony_ci      _mesa_debug(ctx, "%s %s\n", "glGetPointerIndexedvEXT", _mesa_enum_to_string(pname));
366bf215546Sopenharmony_ci
367bf215546Sopenharmony_ci   switch (pname) {
368bf215546Sopenharmony_ci      case GL_TEXTURE_COORD_ARRAY_POINTER:
369bf215546Sopenharmony_ci         *params = (GLvoid *) ctx->Array.VAO->VertexAttrib[VERT_ATTRIB_TEX(index)].Ptr;
370bf215546Sopenharmony_ci         break;
371bf215546Sopenharmony_ci      default:
372bf215546Sopenharmony_ci         goto invalid_pname;
373bf215546Sopenharmony_ci   }
374bf215546Sopenharmony_ci
375bf215546Sopenharmony_ci   return;
376bf215546Sopenharmony_ci
377bf215546Sopenharmony_ciinvalid_pname:
378bf215546Sopenharmony_ci   _mesa_error( ctx, GL_INVALID_ENUM, "glGetPointerIndexedvEXT");
379bf215546Sopenharmony_ci   return;
380bf215546Sopenharmony_ci}
381bf215546Sopenharmony_ci
382bf215546Sopenharmony_ci/**
383bf215546Sopenharmony_ci * Returns the current GL error code, or GL_NO_ERROR.
384bf215546Sopenharmony_ci * \return current error code
385bf215546Sopenharmony_ci *
386bf215546Sopenharmony_ci * Returns __struct gl_contextRec::ErrorValue.
387bf215546Sopenharmony_ci */
388bf215546Sopenharmony_ciGLenum GLAPIENTRY
389bf215546Sopenharmony_ci_mesa_GetError( void )
390bf215546Sopenharmony_ci{
391bf215546Sopenharmony_ci   GET_CURRENT_CONTEXT(ctx);
392bf215546Sopenharmony_ci   GLenum e = ctx->ErrorValue;
393bf215546Sopenharmony_ci   ASSERT_OUTSIDE_BEGIN_END_WITH_RETVAL(ctx, 0);
394bf215546Sopenharmony_ci
395bf215546Sopenharmony_ci   /* From Issue (3) of the KHR_no_error spec:
396bf215546Sopenharmony_ci    *
397bf215546Sopenharmony_ci    *    "Should glGetError() always return NO_ERROR or have undefined
398bf215546Sopenharmony_ci    *    results?
399bf215546Sopenharmony_ci    *
400bf215546Sopenharmony_ci    *    RESOLVED: It should for all errors except OUT_OF_MEMORY."
401bf215546Sopenharmony_ci    */
402bf215546Sopenharmony_ci   if (_mesa_is_no_error_enabled(ctx) && e != GL_OUT_OF_MEMORY) {
403bf215546Sopenharmony_ci      e = GL_NO_ERROR;
404bf215546Sopenharmony_ci   }
405bf215546Sopenharmony_ci
406bf215546Sopenharmony_ci   if (MESA_VERBOSE & VERBOSE_API)
407bf215546Sopenharmony_ci      _mesa_debug(ctx, "glGetError <-- %s\n", _mesa_enum_to_string(e));
408bf215546Sopenharmony_ci
409bf215546Sopenharmony_ci   ctx->ErrorValue = (GLenum) GL_NO_ERROR;
410bf215546Sopenharmony_ci   ctx->ErrorDebugCount = 0;
411bf215546Sopenharmony_ci   return e;
412bf215546Sopenharmony_ci}
413