1bf215546Sopenharmony_ci/*
2bf215546Sopenharmony_ci * Mesa 3-D graphics library
3bf215546Sopenharmony_ci *
4bf215546Sopenharmony_ci * Copyright (C) 1999-2004  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/**
27bf215546Sopenharmony_ci * \file glapi_dispatch.c
28bf215546Sopenharmony_ci *
29bf215546Sopenharmony_ci * This file generates all the gl* function entrypoints.  This code is not
30bf215546Sopenharmony_ci * used if optimized assembly stubs are available (e.g., using
31bf215546Sopenharmony_ci * glapi/glapi_x86.S on IA32 or glapi/glapi_sparc.S on SPARC).
32bf215546Sopenharmony_ci *
33bf215546Sopenharmony_ci * \note
34bf215546Sopenharmony_ci * This file is also used to build the client-side libGL that loads DRI-based
35bf215546Sopenharmony_ci * device drivers.  At build-time it is symlinked to src/glx.
36bf215546Sopenharmony_ci *
37bf215546Sopenharmony_ci * \author Brian Paul <brian@precisioninsight.com>
38bf215546Sopenharmony_ci */
39bf215546Sopenharmony_ci
40bf215546Sopenharmony_ci#include "glapi/glapi_priv.h"
41bf215546Sopenharmony_ci#include "glapitable.h"
42bf215546Sopenharmony_ci
43bf215546Sopenharmony_ci
44bf215546Sopenharmony_ci#if !(defined(USE_X86_ASM) || defined(USE_X86_64_ASM) || defined(USE_SPARC_ASM))
45bf215546Sopenharmony_ci
46bf215546Sopenharmony_ci#if defined(_WIN32)
47bf215546Sopenharmony_ci#define KEYWORD1 GLAPI
48bf215546Sopenharmony_ci#else
49bf215546Sopenharmony_ci#define KEYWORD1 PUBLIC
50bf215546Sopenharmony_ci#endif
51bf215546Sopenharmony_ci
52bf215546Sopenharmony_ci#define KEYWORD2 GLAPIENTRY
53bf215546Sopenharmony_ci
54bf215546Sopenharmony_ci#define NAME(func)  gl##func
55bf215546Sopenharmony_ci
56bf215546Sopenharmony_ci#if 0  /* Use this to log GL calls to stdout (for DEBUG only!) */
57bf215546Sopenharmony_ci
58bf215546Sopenharmony_ci#define F stdout
59bf215546Sopenharmony_ci#define DISPATCH(FUNC, ARGS, MESSAGE)		\
60bf215546Sopenharmony_ci   fprintf MESSAGE;				\
61bf215546Sopenharmony_ci   GET_DISPATCH()->FUNC ARGS
62bf215546Sopenharmony_ci
63bf215546Sopenharmony_ci#define RETURN_DISPATCH(FUNC, ARGS, MESSAGE) 	\
64bf215546Sopenharmony_ci   fprintf MESSAGE;				\
65bf215546Sopenharmony_ci   return GET_DISPATCH()->FUNC ARGS
66bf215546Sopenharmony_ci
67bf215546Sopenharmony_ci#else
68bf215546Sopenharmony_ci
69bf215546Sopenharmony_ci#define DISPATCH(FUNC, ARGS, MESSAGE)		\
70bf215546Sopenharmony_ci   GET_DISPATCH()->FUNC ARGS
71bf215546Sopenharmony_ci
72bf215546Sopenharmony_ci#define RETURN_DISPATCH(FUNC, ARGS, MESSAGE) 	\
73bf215546Sopenharmony_ci   return GET_DISPATCH()->FUNC ARGS
74bf215546Sopenharmony_ci
75bf215546Sopenharmony_ci#endif /* logging */
76bf215546Sopenharmony_ci
77bf215546Sopenharmony_ci
78bf215546Sopenharmony_ci#ifndef GLAPIENTRY
79bf215546Sopenharmony_ci#define GLAPIENTRY
80bf215546Sopenharmony_ci#endif
81bf215546Sopenharmony_ci
82bf215546Sopenharmony_ci#ifdef GLX_INDIRECT_RENDERING
83bf215546Sopenharmony_ci/* those link to libglapi.a should provide the entry points */
84bf215546Sopenharmony_ci#define _GLAPI_SKIP_PROTO_ENTRY_POINTS
85bf215546Sopenharmony_ci#endif
86bf215546Sopenharmony_ci
87bf215546Sopenharmony_ci/* These prototypes are necessary because GLES1 library builds will create
88bf215546Sopenharmony_ci * dispatch functions for them.  We can't directly include GLES/gl.h because
89bf215546Sopenharmony_ci * it would conflict the previously-included GL/gl.h.  Since GLES1 ABI is not
90bf215546Sopenharmony_ci * expected to every add more functions, the path of least resistance is to
91bf215546Sopenharmony_ci * just duplicate the prototypes for the functions that aren't already in
92bf215546Sopenharmony_ci * desktop OpenGL.
93bf215546Sopenharmony_ci */
94bf215546Sopenharmony_ci#include <GLES/glplatform.h>
95bf215546Sopenharmony_ci
96bf215546Sopenharmony_ci
97bf215546Sopenharmony_ci/* Redefine GL_API to avoid MSVC/MinGW warnings about different dllimport
98bf215546Sopenharmony_ci * attributes for these prototypes vs those in the GLES/gl.h header.
99bf215546Sopenharmony_ci */
100bf215546Sopenharmony_ci#undef GL_API
101bf215546Sopenharmony_ci#define GL_API KEYWORD1
102bf215546Sopenharmony_ci
103bf215546Sopenharmony_ciGL_API void GL_APIENTRY glClearDepthf (GLclampf depth);
104bf215546Sopenharmony_ciGL_API void GL_APIENTRY glClipPlanef (GLenum plane, const GLfloat *equation);
105bf215546Sopenharmony_ciGL_API void GL_APIENTRY glFrustumf (GLfloat left, GLfloat right, GLfloat bottom, GLfloat top, GLfloat zNear, GLfloat zFar);
106bf215546Sopenharmony_ciGL_API void GL_APIENTRY glGetClipPlanef (GLenum pname, GLfloat *equation);
107bf215546Sopenharmony_ciGL_API void GL_APIENTRY glOrthof (GLfloat left, GLfloat right, GLfloat bottom, GLfloat top, GLfloat zNear, GLfloat zFar);
108bf215546Sopenharmony_ci
109bf215546Sopenharmony_ciGL_API void GL_APIENTRY glAlphaFuncx (GLenum func, GLclampx ref);
110bf215546Sopenharmony_ciGL_API void GL_APIENTRY glClearColorx (GLclampx red, GLclampx green, GLclampx blue, GLclampx alpha);
111bf215546Sopenharmony_ciGL_API void GL_APIENTRY glClearDepthx (GLclampx depth);
112bf215546Sopenharmony_ciGL_API void GL_APIENTRY glClipPlanex (GLenum plane, const GLfixed *equation);
113bf215546Sopenharmony_ciGL_API void GL_APIENTRY glColor4x (GLfixed red, GLfixed green, GLfixed blue, GLfixed alpha);
114bf215546Sopenharmony_ciGL_API void GL_APIENTRY glDepthRangex (GLclampx zNear, GLclampx zFar);
115bf215546Sopenharmony_ciGL_API void GL_APIENTRY glFogx (GLenum pname, GLfixed param);
116bf215546Sopenharmony_ciGL_API void GL_APIENTRY glFogxv (GLenum pname, const GLfixed *params);
117bf215546Sopenharmony_ciGL_API void GL_APIENTRY glFrustumx (GLfixed left, GLfixed right, GLfixed bottom, GLfixed top, GLfixed zNear, GLfixed zFar);
118bf215546Sopenharmony_ciGL_API void GL_APIENTRY glGetClipPlanex (GLenum pname, GLfixed *equation);
119bf215546Sopenharmony_ciGL_API void GL_APIENTRY glGetFixedv (GLenum pname, GLfixed *params);
120bf215546Sopenharmony_ciGL_API void GL_APIENTRY glGetLightxv (GLenum light, GLenum pname, GLfixed *params);
121bf215546Sopenharmony_ciGL_API void GL_APIENTRY glGetMaterialxv (GLenum face, GLenum pname, GLfixed *params);
122bf215546Sopenharmony_ciGL_API void GL_APIENTRY glGetTexEnvxv (GLenum env, GLenum pname, GLfixed *params);
123bf215546Sopenharmony_ciGL_API void GL_APIENTRY glGetTexParameterxv (GLenum target, GLenum pname, GLfixed *params);
124bf215546Sopenharmony_ciGL_API void GL_APIENTRY glLightModelx (GLenum pname, GLfixed param);
125bf215546Sopenharmony_ciGL_API void GL_APIENTRY glLightModelxv (GLenum pname, const GLfixed *params);
126bf215546Sopenharmony_ciGL_API void GL_APIENTRY glLightx (GLenum light, GLenum pname, GLfixed param);
127bf215546Sopenharmony_ciGL_API void GL_APIENTRY glLightxv (GLenum light, GLenum pname, const GLfixed *params);
128bf215546Sopenharmony_ciGL_API void GL_APIENTRY glLineWidthx (GLfixed width);
129bf215546Sopenharmony_ciGL_API void GL_APIENTRY glLoadMatrixx (const GLfixed *m);
130bf215546Sopenharmony_ciGL_API void GL_APIENTRY glMaterialx (GLenum face, GLenum pname, GLfixed param);
131bf215546Sopenharmony_ciGL_API void GL_APIENTRY glMaterialxv (GLenum face, GLenum pname, const GLfixed *params);
132bf215546Sopenharmony_ciGL_API void GL_APIENTRY glMultMatrixx (const GLfixed *m);
133bf215546Sopenharmony_ciGL_API void GL_APIENTRY glMultiTexCoord4x (GLenum target, GLfixed s, GLfixed t, GLfixed r, GLfixed q);
134bf215546Sopenharmony_ciGL_API void GL_APIENTRY glNormal3x (GLfixed nx, GLfixed ny, GLfixed nz);
135bf215546Sopenharmony_ciGL_API void GL_APIENTRY glOrthox (GLfixed left, GLfixed right, GLfixed bottom, GLfixed top, GLfixed zNear, GLfixed zFar);
136bf215546Sopenharmony_ciGL_API void GL_APIENTRY glPointParameterx (GLenum pname, GLfixed param);
137bf215546Sopenharmony_ciGL_API void GL_APIENTRY glPointParameterxv (GLenum pname, const GLfixed *params);
138bf215546Sopenharmony_ciGL_API void GL_APIENTRY glPointSizex (GLfixed size);
139bf215546Sopenharmony_ciGL_API void GL_APIENTRY glPolygonOffsetx (GLfixed factor, GLfixed units);
140bf215546Sopenharmony_ciGL_API void GL_APIENTRY glRotatex (GLfixed angle, GLfixed x, GLfixed y, GLfixed z);
141bf215546Sopenharmony_ciGL_API void GL_APIENTRY glSampleCoveragex (GLclampx value, GLboolean invert);
142bf215546Sopenharmony_ciGL_API void GL_APIENTRY glScalex (GLfixed x, GLfixed y, GLfixed z);
143bf215546Sopenharmony_ciGL_API void GL_APIENTRY glTexEnvx (GLenum target, GLenum pname, GLfixed param);
144bf215546Sopenharmony_ciGL_API void GL_APIENTRY glTexEnvxv (GLenum target, GLenum pname, const GLfixed *params);
145bf215546Sopenharmony_ciGL_API void GL_APIENTRY glTexParameterx (GLenum target, GLenum pname, GLfixed param);
146bf215546Sopenharmony_ciGL_API void GL_APIENTRY glTexParameterxv (GLenum target, GLenum pname, const GLfixed *params);
147bf215546Sopenharmony_ciGL_API void GL_APIENTRY glTranslatex (GLfixed x, GLfixed y, GLfixed z);
148bf215546Sopenharmony_ciGL_API void GL_APIENTRY glPointSizePointerOES (GLenum type, GLsizei stride, const GLvoid *pointer);
149bf215546Sopenharmony_ciGL_API void GL_APIENTRY glBlendBarrier (void);
150bf215546Sopenharmony_ciGL_API void GL_APIENTRY glPrimitiveBoundingBox (GLfloat minX, GLfloat minY, GLfloat minZ, GLfloat minW, GLfloat maxX, GLfloat maxY, GLfloat maxZ, GLfloat maxW);
151bf215546Sopenharmony_ci
152bf215546Sopenharmony_ci/* Enable frame pointer elimination on Windows, otherwise forgetting to add
153bf215546Sopenharmony_ci * APIENTRY to _mesa_* entrypoints will not cause crashes on debug builds, as
154bf215546Sopenharmony_ci * the initial ESP value is saved in the EBP in the function prologue, then
155bf215546Sopenharmony_ci * restored on the epilogue, clobbering any corruption in the ESP pointer due
156bf215546Sopenharmony_ci * to mismatch in the callee calling convention.
157bf215546Sopenharmony_ci *
158bf215546Sopenharmony_ci * On MSVC it's not sufficient to enable /Oy -- other optimizations must be
159bf215546Sopenharmony_ci * enabled or frame pointer will be used regardless.
160bf215546Sopenharmony_ci *
161bf215546Sopenharmony_ci * We don't do this when NDEBUG is defined since, frame pointer omission
162bf215546Sopenharmony_ci * optimization compiler flag are already specified on release builds, and
163bf215546Sopenharmony_ci * because on profile builds we must have frame pointers or certain profilers
164bf215546Sopenharmony_ci * might fail to unwind the stack.
165bf215546Sopenharmony_ci */
166bf215546Sopenharmony_ci#if defined(_WIN32) && !defined(NDEBUG)
167bf215546Sopenharmony_ci#  if defined(_MSC_VER)
168bf215546Sopenharmony_ci#    pragma optimize( "gty", on )
169bf215546Sopenharmony_ci#  elif defined(__GNUC__)
170bf215546Sopenharmony_ci#    pragma GCC optimize ("omit-frame-pointer")
171bf215546Sopenharmony_ci#  endif
172bf215546Sopenharmony_ci#endif
173bf215546Sopenharmony_ci
174bf215546Sopenharmony_ci#include "glapitemp.h"
175bf215546Sopenharmony_ci
176bf215546Sopenharmony_ci#endif /* USE_X86_ASM */
177