1 /* Copyright (c) 2009-2010 Nokia Corporation
3 * This program is free software; you can redistribute it and/or
4 * modify it under the terms of the GNU General Public License as
5 * (at your option) any later version of the License.
7 * You should have received a copy of the GNU General Public License along
8 * with this program; if not, see <http://www.gnu.org/licenses/>.
10 #ifndef GLES2_CALLS_H__
11 #define GLES2_CALLS_H__
13 // Automatically create the prototype and function definition.
16 #define CB(FUNC, API) \
20 // Sizes of primitive types in the ABI.
21 #define GLES2_HTYPE_byte uint8_t
22 #define GLES2_HTYPE_word uint16_t
23 #define GLES2_HTYPE_dword uint32_t
24 #define GLES2_HTYPE_sdword int32_t
25 #define GLES2_HTYPE_float float
26 #define GLES2_HTYPE_handle uint32_t
28 // Defines shorthands for handling types.
29 #define GLES2_TYPE(TYPE, SIZE) \
30 typedef GLES2_HTYPE_##SIZE TYPE; \
31 static inline void gles2_ret_##TYPE(gles2_State *s, TYPE value); \
32 static inline void gles2_put_##TYPE(gles2_State *s, target_ulong va, TYPE value); \
33 static inline TYPE gles2_get_##TYPE(gles2_State *s, target_ulong va); \
34 static inline TYPE gles2_arg_##TYPE(gles2_State *s, gles2_decode_t *d); \
36 // Bunch of expansions of previous macro to ease things up.
37 GLES2_TYPE(Tptr, dword)
38 GLES2_TYPE(TEGLBoolean, dword)
39 GLES2_TYPE(TEGLenum, dword)
40 GLES2_TYPE(TEGLint, dword)
41 GLES2_TYPE(TEGLDisplay, handle)
42 GLES2_TYPE(TEGLConfig, handle)
43 GLES2_TYPE(TEGLContext, handle)
44 GLES2_TYPE(TEGLSurface, handle)
46 GLES2_TYPE(TGLclampf, float)
47 GLES2_TYPE(TGLbitfield, dword)
48 GLES2_TYPE(TGLboolean, byte)
49 GLES2_TYPE(TGLint, sdword)
50 GLES2_TYPE(TGLuint, dword)
51 GLES2_TYPE(TGLushort, word)
52 GLES2_TYPE(TGLubyte, byte)
53 GLES2_TYPE(TGLenum, dword)
54 GLES2_TYPE(TGLsizei, sdword)
55 GLES2_TYPE(TGLfloat, float)
56 GLES2_TYPE(TGLfixed, dword)
57 GLES2_TYPE(TGLclampx, dword)
59 // Just one more macro for even less typing.
60 #define GLES2_ARG(TYPE, NAME) \
61 TYPE NAME = gles2_arg_##TYPE(s, d)
63 // Host to guest vertex array copy.
66 TGLuint indx; // Parameter of the call.
67 TGLint size; // --''--
68 TGLenum type; // --''--
69 TGLboolean normalized; // --''--
70 TGLsizei stride; // --''--
71 TGLsizei real_stride; // --''--
72 Tptr tptr; // Pointer in the guest memory.
73 void* ptr; // Pointer in the host memory.
74 intptr_t delta; // Delta from 0 to first index in host memory.
75 TGLint buffer; // Buffer data
77 void (*apply) (struct gles2_Array *va);
78 TGLboolean enabled; // State.
81 // Defines shorthands for handling types.
82 #define GLES2_TYPE_DEF(TYPE, SIZE) \
83 static inline void gles2_ret_##TYPE(gles2_State *s, TYPE value) \
84 { gles2_ret_##SIZE(s, value); } \
85 static inline void gles2_put_##TYPE(gles2_State *s, target_ulong va, TYPE value) \
86 { gles2_put_##SIZE(s, va, value); } \
87 static inline TYPE gles2_get_##TYPE(gles2_State *s, target_ulong va) \
88 { return (TYPE)gles2_get_##SIZE(s, va); } \
89 static inline TYPE gles2_arg_##TYPE(gles2_State *s, gles2_decode_t *d) \
90 { return (TYPE)gles2_arg_##SIZE(s, d); }
92 // Bunch of expansions of previous macro to ease things up.
93 GLES2_TYPE_DEF(Tptr, dword)
94 GLES2_TYPE_DEF(TEGLBoolean, dword)
95 GLES2_TYPE_DEF(TEGLenum, dword)
96 GLES2_TYPE_DEF(TEGLint, dword)
97 GLES2_TYPE_DEF(TEGLDisplay, handle)
98 GLES2_TYPE_DEF(TEGLConfig, handle)
99 GLES2_TYPE_DEF(TEGLContext, handle)
100 GLES2_TYPE_DEF(TEGLSurface, handle)
102 GLES2_TYPE_DEF(TGLclampf, float)
103 GLES2_TYPE_DEF(TGLbitfield, dword)
104 GLES2_TYPE_DEF(TGLboolean, byte)
105 GLES2_TYPE_DEF(TGLint, sdword)
106 GLES2_TYPE_DEF(TGLuint, dword)
107 GLES2_TYPE_DEF(TGLushort, word)
108 GLES2_TYPE_DEF(TGLubyte, byte)
109 GLES2_TYPE_DEF(TGLenum, dword)
110 GLES2_TYPE_DEF(TGLsizei, sdword)
111 GLES2_TYPE_DEF(TGLfloat, float)
112 GLES2_TYPE_DEF(TGLfixed, dword)
113 GLES2_TYPE_DEF(TGLclampx, dword)
115 #define GL_BYTE 0x1400
116 #define GL_UNSIGNED_BYTE 0x1401
117 #define GL_SHORT 0x1402
118 #define GL_UNSIGNED_SHORT 0x1403
119 #define GL_FLOAT 0x1406
120 #define GL_FIXED 0x140C
122 #endif // GLES2_CALLS_H__