Replace vulnerable function 'sprintf' to 'snprintf'
[platform/core/uifw/coregl.git] / src / modules / fastpath / coregl_fastpath_gl.c
1 #include "coregl_fastpath.h"
2
3 #include <stdlib.h>
4 #include <string.h>
5 #include <execinfo.h>
6
7 #include <sys/types.h>
8 #include <unistd.h>
9 #include <signal.h>
10
11 #include <sys/syscall.h>
12
13 #define CURR_STATE_COMPARE(curr_state, state ) \
14    if ((current_ctx->curr_state[0]) != (state))
15
16 #define STATE_PROC_WITH_CHECK(gl_state, flagid, flagbit) \
17         if (current_ctx->gl_state##_used == 1) \
18         { \
19                 STATE_PROC(gl_state, flagid, flagbit) \
20         } \
21         else \
22                 _set_gl_error(GL_INVALID_ENUM);
23
24 #define IF_GL_SUCCESS(orig_gl_func) \
25         _get_gl_error(); \
26         orig_gl_func; \
27         if (_get_gl_error() == GL_NO_ERROR)
28
29 #define DEFINE_FASTPAH_GL_FUNC() \
30    MY_MODULE_TSTATE *tstate = NULL; \
31    GLGlueContext *current_ctx = NULL;
32
33 #define INIT_FASTPATH_GL_FUNC() \
34    GET_MY_TSTATE(tstate, get_current_thread_state()); \
35    if (tstate == NULL || tstate->cstate == NULL) \
36    { \
37                 COREGL_WRN("\E[40;31;1m'%s' called when GLES context is not binded (Check MakeCurrent)!\E[0m\n", __func__); \
38                 goto finish; \
39    } \
40    current_ctx = (GLGlueContext *)tstate->cstate->data; \
41    AST(current_ctx != NULL);
42
43 #define GET_REAL_OBJ(type, glue_handle, real_handle) \
44         _get_real_obj(&current_ctx->ostate, type, glue_handle, real_handle)
45 #define GET_GLUE_OBJ(type, real_handle, glue_handle) \
46         _get_glue_obj(&current_ctx->ostate, type, real_handle, glue_handle)
47
48 static inline int
49 _get_real_obj(GL_Object_State *ostate, GL_Object_Type type, GLuint glue_handle,
50               GLuint *real_handle)
51 {
52         if (glue_handle == 0) {
53                 *real_handle = 0;
54         } else {
55                 AST(ostate != NULL);
56                 *real_handle = fastpath_ostate_get_object(ostate, type, glue_handle);
57                 if (*real_handle == 0)
58                         return 0;
59         }
60         return 1;
61 }
62
63 static inline int
64 _get_glue_obj(GL_Object_State *ostate, GL_Object_Type type, GLuint real_handle,
65               GLuint *glue_handle)
66 {
67         if (real_handle == 0) {
68                 *glue_handle = 0;
69         } else {
70                 AST(ostate != NULL);
71                 *glue_handle = fastpath_ostate_find_object(ostate, type, real_handle);
72                 if (*glue_handle == 0)
73                         return 0;
74         }
75         return 1;
76 }
77
78 static inline GLenum
79 _get_gl_error()
80 {
81         GLenum glerror = GL_NONE;
82         DEFINE_FASTPAH_GL_FUNC();
83         INIT_FASTPATH_GL_FUNC();
84
85         glerror = _orig_fastpath_glGetError();
86
87         if (current_ctx->gl_error == GL_NO_ERROR && glerror != GL_NO_ERROR) {
88                 current_ctx->gl_error = glerror;
89         }
90         goto finish;
91
92 finish:
93         return glerror;
94 }
95
96 static inline void
97 _set_gl_error(GLenum error)
98 {
99         DEFINE_FASTPAH_GL_FUNC();
100         INIT_FASTPATH_GL_FUNC();
101
102         _get_gl_error();
103
104         if (current_ctx->gl_error == GL_NO_ERROR && error != GL_NO_ERROR) {
105                 current_ctx->gl_error = error;
106         }
107         goto finish;
108
109 finish:
110         return;
111 }
112
113 typedef struct {
114         GLsizei shader_count;
115         GLuint shaders[10];
116         GLuint is_deleting;
117 } Program_object_attached_tag;
118
119 GLuint
120 _create_program_object(GL_Object_State *ostate, int is_program,
121                        GLenum shader_type)
122 {
123         GLuint ret = 0;
124         GLuint real_obj = 0;
125
126         if (is_program == 1)
127                 real_obj = _orig_fastpath_glCreateProgram();
128         else
129                 real_obj = _orig_fastpath_glCreateShader(shader_type);
130
131         if (real_obj != 0) {
132                 ret = fastpath_ostate_create_object(ostate, GL_OBJECT_TYPE_PROGRAM, real_obj);
133                 Program_object_attached_tag *poat = NULL;
134
135                 if (ret != _COREGL_INT_INIT_VALUE) {
136                         poat = (Program_object_attached_tag *)calloc(1,
137                                         sizeof(Program_object_attached_tag));
138                         if (poat == NULL) {
139                                 AST(poat != NULL);
140                                 fastpath_ostate_remove_object(ostate, GL_OBJECT_TYPE_PROGRAM, ret);
141                         }
142                         poat->is_deleting = 0;
143                         poat->shader_count = 0;
144
145                         fastpath_ostate_set_object_tag(ostate, GL_OBJECT_TYPE_PROGRAM, ret, poat);
146                 }
147         }
148
149         return ret;
150 }
151
152 static void
153 _update_program_attach_info(GL_Object_State *ostate, GLuint program)
154 {
155         Program_object_attached_tag *poat = NULL;
156         GLuint real_program = _COREGL_INT_INIT_VALUE;
157
158         poat = (Program_object_attached_tag *)fastpath_ostate_get_object_tag(ostate,
159                         GL_OBJECT_TYPE_PROGRAM, program);
160         AST(poat != NULL);
161
162         real_program = fastpath_ostate_get_object(ostate, GL_OBJECT_TYPE_PROGRAM,
163                         program);
164         AST(real_program > 0);
165
166         _orig_fastpath_glGetAttachedShaders(real_program, 10, &poat->shader_count,
167                                             poat->shaders);
168 }
169
170 static void
171 _attach_program_object(GL_Object_State *ostate, GLuint object)
172 {
173         if (object != 0) {
174                 fastpath_ostate_use_object(ostate, GL_OBJECT_TYPE_PROGRAM, object);
175         }
176 }
177
178 static int
179 _is_deleted_program_object(GL_Object_State *ostate, GLuint glue_object)
180 {
181         Program_object_attached_tag *poat = NULL;
182         poat = (Program_object_attached_tag *)fastpath_ostate_get_object_tag(ostate,
183                         GL_OBJECT_TYPE_PROGRAM, glue_object);
184         AST(poat != NULL);
185         return poat->is_deleting;
186 }
187
188 static void
189 _detach_program_object(GL_Object_State *ostate, GLuint real_object,
190                        int is_program, int is_deleting)
191 {
192         if (real_object != 0) {
193                 GLuint object = _COREGL_INT_INIT_VALUE;
194                 Program_object_attached_tag *poat = NULL;
195
196                 object = fastpath_ostate_find_object(ostate, GL_OBJECT_TYPE_PROGRAM,
197                                                      real_object);
198                 AST(object != 0);
199
200                 poat = (Program_object_attached_tag *)fastpath_ostate_get_object_tag(ostate,
201                                 GL_OBJECT_TYPE_PROGRAM, object);
202                 AST(poat != NULL);
203
204                 if (is_deleting == 1) {
205                         if (poat->is_deleting == 0) {
206                                 poat->is_deleting = 1;
207                                 /* Ref count increased when glCreateProgram/initial attach */
208                                 fastpath_ostate_remove_object(ostate, GL_OBJECT_TYPE_PROGRAM, object);
209                                 /* Ref count increased when glCreateProgram/create object */
210                                 /* So, we have to call the under function twice.*/
211                                 fastpath_ostate_remove_object(ostate, GL_OBJECT_TYPE_PROGRAM, object);
212                         }
213                 } else {
214                         fastpath_ostate_remove_object(ostate, GL_OBJECT_TYPE_PROGRAM, object);
215                 }
216
217                 if (fastpath_ostate_get_object(ostate, GL_OBJECT_TYPE_PROGRAM, object) == 0) {
218                         // Is completely removed. De-referencing attached shader objects
219                         int i;
220                         for (i = 0; i < poat->shader_count; i++) {
221                                 AST(is_program == 1);
222                                 _detach_program_object(ostate, poat->shaders[i], 0, 0);
223                         }
224
225                         free(poat);
226                         poat = NULL;
227
228                         if (is_program == 1)
229                                 _orig_fastpath_glDeleteProgram(real_object);
230                         else
231                                 _orig_fastpath_glDeleteShader(real_object);
232                 }
233         }
234 }
235
236
237 void
238 fastpath_release_gl_context(GLGlueContext *gctx)
239 {
240         // Release program
241         if (gctx->gl_current_program[0] != 0) {
242                 _detach_program_object(&gctx->ostate, gctx->gl_current_program[0], 1, 0);
243                 gctx->gl_current_program[0] = 0;
244         }
245 }
246
247
248 static float
249 _get_gl_version()
250 {
251         float GLver = 0.0;
252         const char *vret;
253         int vlen = _COREGL_INT_INIT_VALUE;
254         int i = _COREGL_INT_INIT_VALUE;
255         char vret_tmp[80 + 1] = { 0 };
256         IF_GL_SUCCESS(vret = (const char *)_orig_fastpath_glGetString(GL_VERSION)) {
257                 vlen = (int)strlen(vret);
258                 if (!strncmp(vret, "OpenGL ES", 9) && vlen >= 11) {
259                         int stp = 10;
260                         if (vret[9] == '-') {
261                                 if (vlen < 14) return 0.0f;
262                                 stp = 13;
263                         }
264
265                         for (i = stp; ; i++) {
266                                 if (vret[i] == ' ' || vret[i] == 0x00 || i >= 80) {
267                                         strncpy(vret_tmp, &vret[stp], i - stp);
268                                         vret_tmp[i - stp] = 0x00;
269                                         break;
270                                 }
271                         }
272                         if (vret_tmp[0] != 0x00)
273                                 GLver = atof(vret_tmp);
274                 }
275         }
276         return GLver;
277 }
278
279
280 Mutex extension_check_mutex = MUTEX_INITIALIZER;
281 char string_extensions[16384] = { 0x00 };
282 char string_each_extensions[128][64];
283 int gl_extension_count = 0;
284
285
286 static void
287 _valid_extension_string()
288 {
289         char string_tmpbuf[2048];
290         const char *res = NULL;
291
292         AST(mutex_lock(&extension_check_mutex) == 1);
293
294         if (gl_extension_count == 0) {
295                 IF_GL_SUCCESS(res = (const char *)_orig_fastpath_glGetString(GL_EXTENSIONS)) {
296                         if (string_extensions[0] == 0x00) {
297                                 double GLver = _get_gl_version();
298
299                                 strcpy(string_tmpbuf, res);
300                                 char *fstr = &string_tmpbuf[0], *estr = NULL;
301                                 for (estr = fstr; ; estr++) {
302                                         if (*estr == 0x00) break;
303                                         if (*estr == ' ') {
304                                                 *estr = 0x00;
305
306 #define _COREGL_SYMBOL(RET_TYPE, FUNC_NAME, PARAM_LIST)
307 #define _COREGL_FASTPATH_SUPPORTED_EXTENSION(NAME, MINVER, MAXVER) \
308                                                 if (!strcmp(fstr, NAME) && (MINVER < 0 || GLver >= MINVER) && (MAXVER < 0 || GLver <= MAXVER)) \
309                                                 { \
310                                                         strcpy(string_each_extensions[gl_extension_count], fstr); \
311                                                         strcat(string_extensions, fstr); \
312                                                         strcat(string_extensions, " "); \
313                                                         gl_extension_count++; \
314                                                 }
315
316 # include "../../headers/sym_gl.h"
317
318 #undef _COREGL_FASTPATH_SUPPORTED_EXTENSION
319 #undef _COREGL_SYMBOL
320
321                                                 fstr = estr + 1;
322                                         }
323                                 }
324                         }
325                 }
326         }
327
328         AST(mutex_unlock(&extension_check_mutex) == 1);
329 }
330
331
332 GLenum
333 fastpath_glGetError(void)
334 {
335         GLenum ret = GL_NONE;
336
337         DEFINE_FASTPAH_GL_FUNC();
338         _COREGL_FASTPATH_FUNC_BEGIN();
339         INIT_FASTPATH_GL_FUNC();
340
341         if (current_ctx->gl_error != GL_NO_ERROR) {
342                 ret = current_ctx->gl_error;
343                 current_ctx->gl_error = GL_NO_ERROR;
344                 _orig_fastpath_glGetError();
345         } else {
346                 ret = _orig_fastpath_glGetError();
347         }
348         goto finish;
349
350 finish:
351         _COREGL_FASTPATH_FUNC_END();
352         return ret;
353 }
354
355
356 const GLubyte *
357 fastpath_glGetString(GLenum name)
358 {
359         const char *ret = NULL;
360         static const char *string_gles20 = "OpenGL ES 2.0";
361         static const char *string_gles30 = "OpenGL ES 3.0";
362
363         DEFINE_FASTPAH_GL_FUNC();
364         _COREGL_FASTPATH_FUNC_BEGIN();
365         INIT_FASTPATH_GL_FUNC();
366
367         switch (name) {
368         case GL_VERSION:
369                 IF_GL_SUCCESS(ret = (const char *)_orig_fastpath_glGetString(name)) {
370                         double GLver = _get_gl_version();
371                         if (GLver > 3.1) {
372                                 COREGL_WRN("\E[40;31;1mFastpath can't support %s (Fixed to %s)\E[0m\n", ret,
373                                            string_gles30);
374                                 ret = string_gles30;
375                         }
376                         if (GLver < 2.0) {
377                                 COREGL_WRN("\E[40;31;1mFastpath can't support %s (Fixed to %s)\E[0m\n", ret,
378                                            string_gles20);
379                                 ret = string_gles20;
380                         }
381                 }
382                 break;
383         case GL_EXTENSIONS:
384                 _valid_extension_string();
385                 ret = string_extensions;
386                 break;
387         default:
388                 IF_GL_SUCCESS(ret = (const char *)_orig_fastpath_glGetString(name)) {
389                 }
390                 else {
391                         ret = NULL;
392                 }
393                 break;
394         }
395
396         goto finish;
397
398 finish:
399         _COREGL_FASTPATH_FUNC_END();
400         return (const GLubyte *)ret;
401 }
402
403 ////////////////////////////////////////////////////////////////////////
404
405 void
406 fastpath_glActiveTexture(GLenum texture)
407 {
408         DEFINE_FASTPAH_GL_FUNC();
409         _COREGL_FASTPATH_FUNC_BEGIN();
410         INIT_FASTPATH_GL_FUNC();
411
412         CURR_STATE_COMPARE(gl_active_texture, texture) {
413                 IF_GL_SUCCESS(_orig_fastpath_glActiveTexture(texture)) {
414                         current_ctx->_tex_flag1 |= _TEX_FLAG1_BIT_gl_active_texture;
415                         current_ctx->gl_active_texture[0] = texture;
416                 }
417         }
418         goto finish;
419
420 finish:
421         _COREGL_FASTPATH_FUNC_END();
422 }
423
424
425 void
426 fastpath_glGenTextures(GLsizei n, GLuint *textures)
427 {
428         int i;
429         GLuint *objid_array = NULL;
430
431         DEFINE_FASTPAH_GL_FUNC();
432         _COREGL_FASTPATH_FUNC_BEGIN();
433         INIT_FASTPATH_GL_FUNC();
434
435         if (n < 0) {
436                 _set_gl_error(GL_INVALID_VALUE);
437                 goto finish;
438         }
439         if (n == 0) goto finish;
440         if (textures == NULL) goto finish;
441
442         AST(current_ctx->ostate.shared != NULL);
443
444         objid_array = (GLuint *)calloc(1, sizeof(GLuint) * n);
445
446         IF_GL_SUCCESS(_orig_fastpath_glGenTextures(n, objid_array)) {
447                 for (i = 0; i < n; i++) {
448                         textures[i] = fastpath_ostate_create_object(&current_ctx->ostate,
449                                         GL_OBJECT_TYPE_TEXTURE, objid_array[i]);
450                 }
451         }
452
453         goto finish;
454
455 finish:
456         if (objid_array != NULL) {
457                 free(objid_array);
458                 objid_array = NULL;
459         }
460         _COREGL_FASTPATH_FUNC_END();
461 }
462
463
464 void
465 fastpath_glBindTexture(GLenum target, GLuint texture)
466 {
467         int active_idx;
468         GLuint real_obj;
469
470         DEFINE_FASTPAH_GL_FUNC();
471         _COREGL_FASTPATH_FUNC_BEGIN();
472         INIT_FASTPATH_GL_FUNC();
473
474         active_idx = current_ctx->gl_active_texture[0] - GL_TEXTURE0;
475
476         if (GET_REAL_OBJ(GL_OBJECT_TYPE_TEXTURE, texture, &real_obj) != 1) {
477                 _set_gl_error(GL_OUT_OF_MEMORY);
478                 goto finish;
479         }
480
481
482 #define STATE_PROC(gl_state, flagid, flagbit) \
483         if (current_ctx->gl_state[active_idx] != real_obj) \
484         { \
485                 IF_GL_SUCCESS(_orig_fastpath_glBindTexture(target, real_obj)) \
486                 { \
487                         current_ctx->flagid |= flagbit##_##gl_state; \
488                         current_ctx->gl_state[active_idx] = real_obj; \
489                 } \
490         }
491
492         switch (target) {
493         case GL_TEXTURE_2D:
494                 STATE_PROC(gl_tex_2d_state, _tex_flag1, _TEX_FLAG1_BIT);
495                 break;
496         case GL_TEXTURE_3D:
497                 STATE_PROC_WITH_CHECK(gl_tex_3d_state, _tex_flag1, _TEX_FLAG1_BIT);
498                 break;
499         case GL_TEXTURE_2D_ARRAY:
500                 STATE_PROC_WITH_CHECK(gl_tex_2d_array_state, _tex_flag1, _TEX_FLAG1_BIT);
501                 break;
502         case GL_TEXTURE_CUBE_MAP:
503                 STATE_PROC(gl_tex_cube_state, _tex_flag1, _TEX_FLAG1_BIT);
504                 break;
505         case GL_TEXTURE_EXTERNAL_OES:
506                 STATE_PROC(gl_tex_external_oes_state, _tex_flag1, _TEX_FLAG1_BIT);
507                 break;
508         default:
509                 _set_gl_error(GL_INVALID_ENUM);
510                 break;
511         }
512
513
514 #undef STATE_PROC
515
516         goto finish;
517
518 finish:
519         _COREGL_FASTPATH_FUNC_END();
520 }
521
522
523 void
524 fastpath_glFramebufferTexture2D(GLenum target, GLenum attachment,
525                                 GLenum textarget, GLuint texture, GLint level)
526 {
527         GLuint real_obj;
528
529         DEFINE_FASTPAH_GL_FUNC();
530         _COREGL_FASTPATH_FUNC_BEGIN();
531         INIT_FASTPATH_GL_FUNC();
532
533         if (GET_REAL_OBJ(GL_OBJECT_TYPE_TEXTURE, texture, &real_obj) != 1) {
534                 _set_gl_error(GL_OUT_OF_MEMORY);
535                 goto finish;
536         }
537
538         _orig_fastpath_glFramebufferTexture2D(target, attachment, textarget, real_obj,
539                                               level);
540
541         goto finish;
542
543 finish:
544         _COREGL_FASTPATH_FUNC_END();
545 }
546
547
548 void
549 fastpath_glFramebufferTexture3DOES(GLenum target, GLenum attachment,
550                                    GLenum textarget, GLuint texture, GLint level, GLint zoffset)
551 {
552         GLuint real_obj;
553
554         DEFINE_FASTPAH_GL_FUNC();
555         _COREGL_FASTPATH_FUNC_BEGIN();
556         INIT_FASTPATH_GL_FUNC();
557
558         if (GET_REAL_OBJ(GL_OBJECT_TYPE_TEXTURE, texture, &real_obj) != 1) {
559                 _set_gl_error(GL_OUT_OF_MEMORY);
560                 goto finish;
561         }
562
563         _orig_fastpath_glFramebufferTexture3DOES(target, attachment, textarget,
564                         real_obj, level, zoffset);
565
566         goto finish;
567
568 finish:
569         _COREGL_FASTPATH_FUNC_END();
570 }
571
572
573 void
574 fastpath_glFramebufferTexture2DMultisampleEXT(GLenum target, GLenum attachment,
575                 GLenum textarget, GLuint texture, GLint level, GLsizei samples)
576 {
577         GLuint real_obj;
578
579         DEFINE_FASTPAH_GL_FUNC();
580         _COREGL_FASTPATH_FUNC_BEGIN();
581         INIT_FASTPATH_GL_FUNC();
582
583         if (GET_REAL_OBJ(GL_OBJECT_TYPE_TEXTURE, texture, &real_obj) != 1) {
584                 _set_gl_error(GL_OUT_OF_MEMORY);
585                 goto finish;
586         }
587
588         _orig_fastpath_glFramebufferTexture2DMultisampleEXT(target, attachment,
589                         textarget, real_obj, level, samples);
590
591         goto finish;
592
593 finish:
594         _COREGL_FASTPATH_FUNC_END();
595 }
596
597
598 void
599 fastpath_glGetFramebufferAttachmentParameteriv(GLenum target, GLenum attachment,
600                 GLenum pname, GLint *params)
601 {
602         GLint real_obj, fa_type;
603
604         DEFINE_FASTPAH_GL_FUNC();
605         _COREGL_FASTPATH_FUNC_BEGIN();
606         INIT_FASTPATH_GL_FUNC();
607
608         switch (pname) {
609         case GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME:
610                 params[0] = 0;
611                 _orig_fastpath_glGetFramebufferAttachmentParameteriv(target, attachment, pname,
612                                 &real_obj);
613                 _orig_fastpath_glGetFramebufferAttachmentParameteriv(target, attachment,
614                                 GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE, &fa_type);
615                 switch (fa_type) {
616                 case GL_TEXTURE:
617                         if (GET_GLUE_OBJ(GL_OBJECT_TYPE_TEXTURE, real_obj, (GLuint *)params) != 1) {
618                                 params[0] = 0;
619                                 goto finish;
620                         }
621                         break;
622                 case GL_RENDERBUFFER:
623                         if (GET_GLUE_OBJ(GL_OBJECT_TYPE_RENDERBUFFER, real_obj,
624                                          (GLuint *)params) != 1) {
625                                 params[0] = 0;
626                                 goto finish;
627                         }
628                         break;
629                 }
630                 break;
631         default:
632                 _orig_fastpath_glGetFramebufferAttachmentParameteriv(target, attachment, pname,
633                                 params);
634                 break;
635         }
636
637         goto finish;
638
639 finish:
640         _COREGL_FASTPATH_FUNC_END();
641 }
642
643
644 GLboolean
645 fastpath_glIsTexture(GLuint texture)
646 {
647         GLboolean ret = GL_FALSE;
648         GLuint real_obj;
649
650         DEFINE_FASTPAH_GL_FUNC();
651         _COREGL_FASTPATH_FUNC_BEGIN();
652         INIT_FASTPATH_GL_FUNC();
653
654         if (GET_REAL_OBJ(GL_OBJECT_TYPE_TEXTURE, texture, &real_obj) != 1) {
655                 ret = GL_FALSE;
656                 goto finish;
657         }
658
659         ret = _orig_fastpath_glIsTexture(real_obj);
660
661         goto finish;
662
663 finish:
664         _COREGL_FASTPATH_FUNC_END();
665         return ret;
666 }
667
668
669 void
670 fastpath_glDeleteTextures(GLsizei n, const GLuint *textures)
671 {
672         int i, j;
673         GLuint *objid_array = NULL;
674
675         DEFINE_FASTPAH_GL_FUNC();
676         _COREGL_FASTPATH_FUNC_BEGIN();
677         INIT_FASTPATH_GL_FUNC();
678
679         if (n < 0) {
680                 _set_gl_error(GL_INVALID_VALUE);
681                 goto finish;
682         }
683         if (n == 0) goto finish;
684         if (textures == NULL) goto finish;
685
686         AST(current_ctx->ostate.shared != NULL);
687
688         objid_array = (GLuint *)calloc(1, sizeof(GLuint) * n);
689         {
690                 int real_n = 0;
691
692                 for (i = 0; i < n; i++) {
693                         int real_objid = _COREGL_INT_INIT_VALUE;
694                         if (textures[i] == 0) continue;
695
696                         real_objid = fastpath_ostate_get_object(&current_ctx->ostate,
697                                                                 GL_OBJECT_TYPE_TEXTURE, textures[i]);
698                         if (real_objid == 0) continue;
699
700                         AST(fastpath_ostate_remove_object(&current_ctx->ostate, GL_OBJECT_TYPE_TEXTURE,
701                                                           textures[i]) == 1);
702                         objid_array[real_n++] = real_objid;
703                 }
704
705                 IF_GL_SUCCESS(_orig_fastpath_glDeleteTextures(real_n, objid_array)) {
706                         for (i = 0; i < real_n; i++) {
707                                 General_Trace_List *current = NULL;
708                                 current = current_ctx->ostate.shared->using_gctxs;
709
710                                 while (current != NULL) {
711                                         GLGlueContext *cur_gctx = (GLGlueContext *)current->value;
712
713                                         for (j = 0; j < cur_gctx->gl_num_tex_units[0]; j++) {
714                                                 if (cur_gctx->gl_tex_2d_state[j] == objid_array[i])
715                                                         cur_gctx->gl_tex_2d_state[j] = 0;
716                                                 if (cur_gctx->gl_tex_3d_state[j] == objid_array[i])
717                                                         cur_gctx->gl_tex_3d_state[j] = 0;
718                                                 if (cur_gctx->gl_tex_2d_array_state[j] == objid_array[i])
719                                                         cur_gctx->gl_tex_2d_array_state[j] = 0;
720                                                 if (cur_gctx->gl_tex_cube_state[j] == objid_array[i])
721                                                         cur_gctx->gl_tex_cube_state[j] = 0;
722                                                 if (cur_gctx->gl_tex_external_oes_state[j] == objid_array[i])
723                                                         cur_gctx->gl_tex_external_oes_state[j] = 0;
724                                         }
725
726                                         current = current->next;
727                                 }
728                         }
729                 }
730         }
731
732         goto finish;
733
734 finish:
735         if (objid_array != NULL) {
736                 free(objid_array);
737                 objid_array = NULL;
738         }
739         _COREGL_FASTPATH_FUNC_END();
740 }
741
742 ////////////////////////////////////////////////////////////////////////
743
744 void
745 fastpath_glGenBuffers(GLsizei n, GLuint *buffers)
746 {
747         int i;
748         GLuint *objid_array = NULL;
749
750         DEFINE_FASTPAH_GL_FUNC();
751         _COREGL_FASTPATH_FUNC_BEGIN();
752         INIT_FASTPATH_GL_FUNC();
753
754         if (n < 0) {
755                 _set_gl_error(GL_INVALID_VALUE);
756                 goto finish;
757         }
758         if (n == 0) goto finish;
759         if (buffers == NULL) goto finish;
760
761         AST(current_ctx->ostate.shared != NULL);
762
763         objid_array = (GLuint *)calloc(1, sizeof(GLuint) * n);
764
765         IF_GL_SUCCESS(_orig_fastpath_glGenBuffers(n, objid_array)) {
766                 for (i = 0; i < n; i++) {
767                         buffers[i] = fastpath_ostate_create_object(&current_ctx->ostate,
768                                         GL_OBJECT_TYPE_BUFFER, objid_array[i]);
769                 }
770         }
771
772         goto finish;
773
774 finish:
775         if (objid_array != NULL) {
776                 free(objid_array);
777                 objid_array = NULL;
778         }
779         _COREGL_FASTPATH_FUNC_END();
780 }
781
782
783 void
784 fastpath_glBindBuffer(GLenum target, GLuint buffer)
785 {
786         GLuint real_obj;
787
788         DEFINE_FASTPAH_GL_FUNC();
789         _COREGL_FASTPATH_FUNC_BEGIN();
790         INIT_FASTPATH_GL_FUNC();
791
792         if (GET_REAL_OBJ(GL_OBJECT_TYPE_BUFFER, buffer, &real_obj) != 1) {
793                 _set_gl_error(GL_OUT_OF_MEMORY);
794                 goto finish;
795         }
796
797
798 #define STATE_PROC(gl_state, flagid, flagbit) \
799         CURR_STATE_COMPARE(gl_state, real_obj) \
800         { \
801                 IF_GL_SUCCESS(_orig_fastpath_glBindBuffer(target, real_obj)) \
802                 { \
803                         if (real_obj == 0) \
804                                 current_ctx->flagid &= (~flagbit##_##gl_state); \
805                         else \
806                                 current_ctx->flagid |= flagbit##_##gl_state; \
807  \
808                         current_ctx->gl_state[0] = real_obj; \
809                 } \
810         }
811
812
813         switch (target) {
814         case GL_ARRAY_BUFFER:
815                 STATE_PROC(gl_array_buffer_binding, _bind_flag1, _BIND_FLAG1_BIT);
816                 break;
817         case GL_COPY_READ_BUFFER:
818                 STATE_PROC_WITH_CHECK(gl_copy_read_buffer_binding, _bind_flag2,
819                                       _BIND_FLAG2_BIT);
820                 break;
821         case GL_COPY_WRITE_BUFFER:
822                 STATE_PROC_WITH_CHECK(gl_copy_write_buffer_binding, _bind_flag2,
823                                       _BIND_FLAG2_BIT);
824                 break;
825         case GL_ELEMENT_ARRAY_BUFFER:
826                 STATE_PROC(gl_element_array_buffer_binding, _bind_flag1, _BIND_FLAG1_BIT);
827                 break;
828         case GL_PIXEL_PACK_BUFFER:
829                 STATE_PROC_WITH_CHECK(gl_pixel_pack_buffer_binding, _bind_flag2,
830                                       _BIND_FLAG2_BIT);
831                 break;
832         case GL_PIXEL_UNPACK_BUFFER:
833                 STATE_PROC_WITH_CHECK(gl_pixel_unpack_buffer_binding, _bind_flag2,
834                                       _BIND_FLAG2_BIT);
835                 break;
836         case GL_TRANSFORM_FEEDBACK_BUFFER:
837                 STATE_PROC_WITH_CHECK(gl_transform_feedback_buffer_binding, _bind_flag2,
838                                       _BIND_FLAG2_BIT);
839                 break;
840         case GL_UNIFORM_BUFFER:
841                 STATE_PROC_WITH_CHECK(gl_uniform_buffer_binding, _bind_flag2, _BIND_FLAG2_BIT);
842                 break;
843         default:
844                 _set_gl_error(GL_INVALID_ENUM);
845                 break;
846         }
847
848
849 #undef STATE_PROC
850
851         goto finish;
852
853 finish:
854         _COREGL_FASTPATH_FUNC_END();
855 }
856
857
858 GLboolean
859 fastpath_glIsBuffer(GLuint buffer)
860 {
861         GLboolean ret = GL_FALSE;
862         GLuint real_obj;
863
864         DEFINE_FASTPAH_GL_FUNC();
865         _COREGL_FASTPATH_FUNC_BEGIN();
866         INIT_FASTPATH_GL_FUNC();
867
868         if (GET_REAL_OBJ(GL_OBJECT_TYPE_BUFFER, buffer, &real_obj) != 1) {
869                 ret = GL_FALSE;
870                 goto finish;
871         }
872
873         ret = _orig_fastpath_glIsBuffer(real_obj);
874
875         goto finish;
876
877 finish:
878         _COREGL_FASTPATH_FUNC_END();
879         return ret;
880 }
881
882
883 void
884 fastpath_glDeleteBuffers(GLsizei n, const GLuint *buffers)
885 {
886         int i;
887         GLuint *objid_array = NULL;
888
889         DEFINE_FASTPAH_GL_FUNC();
890         _COREGL_FASTPATH_FUNC_BEGIN();
891         INIT_FASTPATH_GL_FUNC();
892
893         if (n < 0) {
894                 _set_gl_error(GL_INVALID_VALUE);
895                 goto finish;
896         }
897         if (n == 0) goto finish;
898         if (buffers == NULL) goto finish;
899
900         AST(current_ctx->ostate.shared != NULL);
901
902         objid_array = (GLuint *)calloc(1, sizeof(GLuint) * n);
903         {
904                 int real_n = 0;
905
906                 for (i = 0; i < n; i++) {
907                         int real_objid = _COREGL_INT_INIT_VALUE;
908                         if (buffers[i] == 0) continue;
909
910                         real_objid = fastpath_ostate_get_object(&current_ctx->ostate,
911                                                                 GL_OBJECT_TYPE_BUFFER, buffers[i]);
912                         if (real_objid == 0) continue;
913
914                         AST(fastpath_ostate_remove_object(&current_ctx->ostate, GL_OBJECT_TYPE_BUFFER,
915                                                           buffers[i]) == 1);
916                         objid_array[real_n++] = real_objid;
917                 }
918
919                 IF_GL_SUCCESS(_orig_fastpath_glDeleteBuffers(real_n, objid_array)) {
920                         for (i = 0; i < real_n; i++) {
921                                 General_Trace_List *current = NULL;
922                                 current = current_ctx->ostate.shared->using_gctxs;
923
924                                 while (current != NULL) {
925                                         GLGlueContext *cur_gctx = (GLGlueContext *)current->value;
926
927                                         if (cur_gctx->gl_array_buffer_binding[0] == objid_array[i]) {
928                                                 cur_gctx->_bind_flag1 &= (~_BIND_FLAG1_BIT_gl_array_buffer_binding);
929                                                 cur_gctx->gl_array_buffer_binding[0] = 0;
930                                         }
931                                         if (cur_gctx->gl_copy_read_buffer_binding[0] == objid_array[i]) {
932                                                 cur_gctx->_bind_flag2 &= (~_BIND_FLAG2_BIT_gl_copy_read_buffer_binding);
933                                                 cur_gctx->gl_copy_read_buffer_binding[0] = 0;
934                                         }
935                                         if (cur_gctx->gl_copy_write_buffer_binding[0] == objid_array[i]) {
936                                                 cur_gctx->_bind_flag2 &= (~_BIND_FLAG2_BIT_gl_copy_write_buffer_binding);
937                                                 cur_gctx->gl_copy_write_buffer_binding[0] = 0;
938                                         }
939                                         if (cur_gctx->gl_element_array_buffer_binding[0] == objid_array[i]) {
940                                                 cur_gctx->_bind_flag1 &= (~_BIND_FLAG1_BIT_gl_element_array_buffer_binding);
941                                                 cur_gctx->gl_element_array_buffer_binding[0] = 0;
942                                         }
943                                         if (cur_gctx->gl_pixel_pack_buffer_binding[0] == objid_array[i]) {
944                                                 cur_gctx->_bind_flag2 &= (~_BIND_FLAG2_BIT_gl_pixel_pack_buffer_binding);
945                                                 cur_gctx->gl_pixel_pack_buffer_binding[0] = 0;
946                                         }
947                                         if (cur_gctx->gl_pixel_unpack_buffer_binding[0] == objid_array[i]) {
948                                                 cur_gctx->_bind_flag2 &= (~_BIND_FLAG2_BIT_gl_pixel_unpack_buffer_binding);
949                                                 cur_gctx->gl_pixel_unpack_buffer_binding[0] = 0;
950                                         }
951                                         if (cur_gctx->gl_transform_feedback_buffer_binding[0] == objid_array[i]) {
952                                                 cur_gctx->_bind_flag2 &=
953                                                         (~_BIND_FLAG2_BIT_gl_transform_feedback_buffer_binding);
954                                                 cur_gctx->gl_transform_feedback_buffer_binding[0] = 0;
955                                         }
956                                         if (cur_gctx->gl_uniform_buffer_binding[0] == objid_array[i]) {
957                                                 cur_gctx->_bind_flag2 &= (~_BIND_FLAG2_BIT_gl_uniform_buffer_binding);
958                                                 cur_gctx->gl_uniform_buffer_binding[0] = 0;
959                                         }
960
961                                         current = current->next;
962                                 }
963                         }
964                 }
965         }
966
967         goto finish;
968
969 finish:
970         if (objid_array != NULL) {
971                 free(objid_array);
972                 objid_array = NULL;
973         }
974         _COREGL_FASTPATH_FUNC_END();
975 }
976
977 //////////////////////////////////////////////////////////////////////////////////
978
979 void
980 fastpath_glGenFramebuffers(GLsizei n, GLuint *framebuffers)
981 {
982         int i;
983         GLuint *objid_array = NULL;
984
985         DEFINE_FASTPAH_GL_FUNC();
986         _COREGL_FASTPATH_FUNC_BEGIN();
987         INIT_FASTPATH_GL_FUNC();
988
989         if (n < 0) {
990                 _set_gl_error(GL_INVALID_VALUE);
991                 goto finish;
992         }
993         if (n == 0) goto finish;
994         if (framebuffers == NULL) goto finish;
995
996         AST(current_ctx->ostate.shared != NULL);
997
998         objid_array = (GLuint *)calloc(1, sizeof(GLuint) * n);
999
1000         IF_GL_SUCCESS(_orig_fastpath_glGenFramebuffers(n, objid_array)) {
1001                 for (i = 0; i < n; i++) {
1002                         framebuffers[i] = fastpath_ostate_create_object(&current_ctx->ostate,
1003                                           GL_OBJECT_TYPE_FRAMEBUFFER, objid_array[i]);
1004                 }
1005         }
1006
1007         goto finish;
1008
1009 finish:
1010         if (objid_array != NULL) {
1011                 free(objid_array);
1012                 objid_array = NULL;
1013         }
1014         _COREGL_FASTPATH_FUNC_END();
1015 }
1016
1017
1018 void
1019 fastpath_glBindFramebuffer(GLenum target, GLuint framebuffer)
1020 {
1021         GLuint real_obj;
1022
1023         DEFINE_FASTPAH_GL_FUNC();
1024         _COREGL_FASTPATH_FUNC_BEGIN();
1025         INIT_FASTPATH_GL_FUNC();
1026
1027         if (GET_REAL_OBJ(GL_OBJECT_TYPE_FRAMEBUFFER, framebuffer, &real_obj) != 1) {
1028                 _set_gl_error(GL_OUT_OF_MEMORY);
1029                 goto finish;
1030         }
1031
1032         if (target == GL_FRAMEBUFFER) {
1033                 if (current_ctx->gl_framebuffer_binding_read_used == 1) {
1034                         CURR_STATE_COMPARE(gl_framebuffer_binding_read, real_obj) {
1035                                 IF_GL_SUCCESS(_orig_fastpath_glBindFramebuffer(target, real_obj)) {
1036                                         if (real_obj == 0)
1037                                                 current_ctx->_bind_flag1 &= (~_BIND_FLAG1_BIT_gl_framebuffer_binding_read);
1038                                         else
1039                                                 current_ctx->_bind_flag1 |= _BIND_FLAG1_BIT_gl_framebuffer_binding_read;
1040                                         current_ctx->gl_framebuffer_binding_read[0] = real_obj;
1041                                 }
1042                         }
1043                         CURR_STATE_COMPARE(gl_framebuffer_binding_draw, real_obj) {
1044                                 IF_GL_SUCCESS(_orig_fastpath_glBindFramebuffer(target, real_obj)) {
1045                                         if (real_obj == 0)
1046                                                 current_ctx->_bind_flag1 &= (~_BIND_FLAG1_BIT_gl_framebuffer_binding_draw);
1047                                         else
1048                                                 current_ctx->_bind_flag1 |= _BIND_FLAG1_BIT_gl_framebuffer_binding_draw;
1049                                         current_ctx->gl_framebuffer_binding_draw[0] = real_obj;
1050                                 }
1051                         }
1052                 } else {
1053                         CURR_STATE_COMPARE(gl_framebuffer_binding, real_obj) {
1054                                 IF_GL_SUCCESS(_orig_fastpath_glBindFramebuffer(target, real_obj)) {
1055                                         if (real_obj == 0)
1056                                                 current_ctx->_bind_flag1 &= (~_BIND_FLAG1_BIT_gl_framebuffer_binding);
1057                                         else
1058                                                 current_ctx->_bind_flag1 |= _BIND_FLAG1_BIT_gl_framebuffer_binding;
1059                                         current_ctx->gl_framebuffer_binding[0] = real_obj;
1060                                 }
1061                         }
1062                 }
1063         } else if (target == GL_READ_FRAMEBUFFER &&
1064                    current_ctx->gl_framebuffer_binding_read_used) {
1065                 CURR_STATE_COMPARE(gl_framebuffer_binding_read, real_obj) {
1066                         IF_GL_SUCCESS(_orig_fastpath_glBindFramebuffer(target, real_obj)) {
1067                                 if (real_obj == 0)
1068                                         current_ctx->_bind_flag1 &= (~_BIND_FLAG1_BIT_gl_framebuffer_binding_read);
1069                                 else
1070                                         current_ctx->_bind_flag1 |= _BIND_FLAG1_BIT_gl_framebuffer_binding_read;
1071                                 current_ctx->gl_framebuffer_binding_read[0] = real_obj;
1072                         }
1073                 }
1074         } else if (target == GL_DRAW_FRAMEBUFFER &&
1075                    current_ctx->gl_framebuffer_binding_draw_used) {
1076                 CURR_STATE_COMPARE(gl_framebuffer_binding_draw, real_obj) {
1077                         IF_GL_SUCCESS(_orig_fastpath_glBindFramebuffer(target, real_obj)) {
1078                                 if (real_obj == 0)
1079                                         current_ctx->_bind_flag1 &= (~_BIND_FLAG1_BIT_gl_framebuffer_binding_draw);
1080                                 else
1081                                         current_ctx->_bind_flag1 |= _BIND_FLAG1_BIT_gl_framebuffer_binding_draw;
1082                                 current_ctx->gl_framebuffer_binding_draw[0] = real_obj;
1083                         }
1084                 }
1085         } else {
1086                 _set_gl_error(GL_INVALID_ENUM);
1087                 goto finish;
1088         }
1089         goto finish;
1090
1091 finish:
1092         _COREGL_FASTPATH_FUNC_END();
1093 }
1094
1095
1096 GLboolean
1097 fastpath_glIsFramebuffer(GLuint framebuffer)
1098 {
1099         GLboolean ret = GL_FALSE;
1100         GLuint real_obj;
1101
1102         DEFINE_FASTPAH_GL_FUNC();
1103         _COREGL_FASTPATH_FUNC_BEGIN();
1104         INIT_FASTPATH_GL_FUNC();
1105
1106         if (GET_REAL_OBJ(GL_OBJECT_TYPE_FRAMEBUFFER, framebuffer, &real_obj) != 1) {
1107                 ret = GL_FALSE;
1108                 goto finish;
1109         }
1110
1111         ret = _orig_fastpath_glIsFramebuffer(real_obj);
1112
1113         goto finish;
1114
1115 finish:
1116         _COREGL_FASTPATH_FUNC_END();
1117         return ret;
1118 }
1119
1120
1121 void
1122 fastpath_glDeleteFramebuffers(GLsizei n, const GLuint *framebuffers)
1123 {
1124         int i;
1125         GLuint *objid_array = NULL;
1126
1127         DEFINE_FASTPAH_GL_FUNC();
1128         _COREGL_FASTPATH_FUNC_BEGIN();
1129         INIT_FASTPATH_GL_FUNC();
1130
1131         if (n < 0) {
1132                 _set_gl_error(GL_INVALID_VALUE);
1133                 goto finish;
1134         }
1135         if (n == 0) goto finish;
1136         if (framebuffers == NULL) goto finish;
1137
1138         AST(current_ctx->ostate.shared != NULL);
1139
1140         objid_array = (GLuint *)calloc(1, sizeof(GLuint) * n);
1141         {
1142                 int real_n = 0;
1143
1144                 for (i = 0; i < n; i++) {
1145                         int real_objid = _COREGL_INT_INIT_VALUE;
1146                         if (framebuffers[i] == 0) continue;
1147
1148                         real_objid = fastpath_ostate_get_object(&current_ctx->ostate,
1149                                                                 GL_OBJECT_TYPE_FRAMEBUFFER, framebuffers[i]);
1150                         if (real_objid == 0) continue;
1151
1152                         AST(fastpath_ostate_remove_object(&current_ctx->ostate,
1153                                                           GL_OBJECT_TYPE_FRAMEBUFFER, framebuffers[i]) == 1);
1154                         objid_array[real_n++] = real_objid;
1155                 }
1156
1157                 IF_GL_SUCCESS(_orig_fastpath_glDeleteFramebuffers(real_n, objid_array)) {
1158                         for (i = 0; i < real_n; i++) {
1159                                 General_Trace_List *current = NULL;
1160                                 current = current_ctx->ostate.shared->using_gctxs;
1161
1162                                 while (current != NULL) {
1163                                         GLGlueContext *cur_gctx = (GLGlueContext *)current->value;
1164
1165                                         if (cur_gctx->gl_framebuffer_binding[0] == objid_array[i]) {
1166                                                 cur_gctx->_bind_flag1 &= (~_BIND_FLAG1_BIT_gl_framebuffer_binding);
1167                                                 cur_gctx->gl_framebuffer_binding[0] = 0;
1168                                         }
1169                                         if (cur_gctx->gl_framebuffer_binding_read[0] == objid_array[i]) {
1170                                                 cur_gctx->_bind_flag1 &= (~_BIND_FLAG1_BIT_gl_framebuffer_binding_read);
1171                                                 cur_gctx->gl_framebuffer_binding_read[0] = 0;
1172                                         }
1173                                         if (cur_gctx->gl_framebuffer_binding_draw[0] == objid_array[i]) {
1174                                                 cur_gctx->_bind_flag1 &= (~_BIND_FLAG1_BIT_gl_framebuffer_binding_draw);
1175                                                 cur_gctx->gl_framebuffer_binding_draw[0] = 0;
1176                                         }
1177
1178                                         current = current->next;
1179                                 }
1180                         }
1181                 }
1182         }
1183
1184         goto finish;
1185
1186 finish:
1187         if (objid_array != NULL) {
1188                 free(objid_array);
1189                 objid_array = NULL;
1190         }
1191         _COREGL_FASTPATH_FUNC_END();
1192 }
1193
1194 //////////////////////////////////////////////////////////////////////////////////
1195
1196 void
1197 fastpath_glGenRenderbuffers(GLsizei n, GLuint *renderbuffers)
1198 {
1199         int i;
1200         GLuint *objid_array = NULL;
1201
1202         DEFINE_FASTPAH_GL_FUNC();
1203         _COREGL_FASTPATH_FUNC_BEGIN();
1204         INIT_FASTPATH_GL_FUNC();
1205
1206         if (n < 0) {
1207                 _set_gl_error(GL_INVALID_VALUE);
1208                 goto finish;
1209         }
1210         if (n == 0) goto finish;
1211         if (renderbuffers == NULL) goto finish;
1212
1213         AST(current_ctx->ostate.shared != NULL);
1214
1215         objid_array = (GLuint *)calloc(1, sizeof(GLuint) * n);
1216
1217         IF_GL_SUCCESS(_orig_fastpath_glGenRenderbuffers(n, objid_array)) {
1218                 for (i = 0; i < n; i++) {
1219                         renderbuffers[i] = fastpath_ostate_create_object(&current_ctx->ostate,
1220                                            GL_OBJECT_TYPE_RENDERBUFFER, objid_array[i]);
1221                 }
1222         }
1223
1224         goto finish;
1225
1226 finish:
1227         if (objid_array != NULL) {
1228                 free(objid_array);
1229                 objid_array = NULL;
1230         }
1231         _COREGL_FASTPATH_FUNC_END();
1232 }
1233
1234
1235 void
1236 fastpath_glBindRenderbuffer(GLenum target, GLuint renderbuffer)
1237 {
1238         GLuint real_obj;
1239
1240         DEFINE_FASTPAH_GL_FUNC();
1241         _COREGL_FASTPATH_FUNC_BEGIN();
1242         INIT_FASTPATH_GL_FUNC();
1243
1244         if (GET_REAL_OBJ(GL_OBJECT_TYPE_RENDERBUFFER, renderbuffer, &real_obj) != 1) {
1245                 _set_gl_error(GL_OUT_OF_MEMORY);
1246                 goto finish;
1247         }
1248
1249         if (target == GL_RENDERBUFFER) {
1250                 CURR_STATE_COMPARE(gl_renderbuffer_binding, real_obj) {
1251                         IF_GL_SUCCESS(_orig_fastpath_glBindRenderbuffer(target, real_obj)) {
1252                                 if (real_obj == 0)
1253                                         current_ctx->_bind_flag1 &= (~_BIND_FLAG1_BIT_gl_renderbuffer_binding);
1254                                 else
1255                                         current_ctx->_bind_flag1 |= _BIND_FLAG1_BIT_gl_renderbuffer_binding;
1256                                 current_ctx->gl_renderbuffer_binding[0] = real_obj;
1257                         }
1258                 }
1259         } else {
1260                 _set_gl_error(GL_INVALID_ENUM);
1261                 goto finish;
1262         }
1263
1264         goto finish;
1265
1266 finish:
1267         _COREGL_FASTPATH_FUNC_END();
1268 }
1269
1270
1271 void
1272 fastpath_glFramebufferRenderbuffer(GLenum target, GLenum attachment,
1273                                    GLenum renderbuffertarget, GLuint renderbuffer)
1274 {
1275         GLuint real_obj;
1276
1277         DEFINE_FASTPAH_GL_FUNC();
1278         _COREGL_FASTPATH_FUNC_BEGIN();
1279         INIT_FASTPATH_GL_FUNC();
1280
1281         if (GET_REAL_OBJ(GL_OBJECT_TYPE_RENDERBUFFER, renderbuffer, &real_obj) != 1) {
1282                 _set_gl_error(GL_OUT_OF_MEMORY);
1283                 goto finish;
1284         }
1285
1286         _orig_fastpath_glFramebufferRenderbuffer(target, attachment, renderbuffertarget,
1287                         real_obj);
1288
1289         goto finish;
1290
1291 finish:
1292         _COREGL_FASTPATH_FUNC_END();
1293 }
1294
1295
1296 GLboolean
1297 fastpath_glIsRenderbuffer(GLuint renderbuffer)
1298 {
1299         GLboolean ret = GL_FALSE;
1300         GLuint real_obj;
1301
1302         DEFINE_FASTPAH_GL_FUNC();
1303         _COREGL_FASTPATH_FUNC_BEGIN();
1304         INIT_FASTPATH_GL_FUNC();
1305
1306         if (GET_REAL_OBJ(GL_OBJECT_TYPE_RENDERBUFFER, renderbuffer, &real_obj) != 1) {
1307                 ret = GL_FALSE;
1308                 goto finish;
1309         }
1310
1311         ret = _orig_fastpath_glIsRenderbuffer(real_obj);
1312
1313         goto finish;
1314
1315 finish:
1316         _COREGL_FASTPATH_FUNC_END();
1317         return ret;
1318 }
1319
1320
1321 void
1322 fastpath_glDeleteRenderbuffers(GLsizei n, const GLuint *renderbuffers)
1323 {
1324         int i;
1325         GLuint *objid_array = NULL;
1326
1327         DEFINE_FASTPAH_GL_FUNC();
1328         _COREGL_FASTPATH_FUNC_BEGIN();
1329         INIT_FASTPATH_GL_FUNC();
1330
1331         if (n < 0) {
1332                 _set_gl_error(GL_INVALID_VALUE);
1333                 goto finish;
1334         }
1335         if (n == 0) goto finish;
1336         if (renderbuffers == NULL) goto finish;
1337
1338         AST(current_ctx->ostate.shared != NULL);
1339
1340         objid_array = (GLuint *)calloc(1, sizeof(GLuint) * n);
1341         {
1342                 int real_n = 0;
1343
1344                 for (i = 0; i < n; i++) {
1345                         int real_objid = _COREGL_INT_INIT_VALUE;
1346                         if (renderbuffers[i] == 0) continue;
1347
1348                         real_objid = fastpath_ostate_get_object(&current_ctx->ostate,
1349                                                                 GL_OBJECT_TYPE_RENDERBUFFER, renderbuffers[i]);
1350                         if (real_objid == 0) continue;
1351
1352                         AST(fastpath_ostate_remove_object(&current_ctx->ostate,
1353                                                           GL_OBJECT_TYPE_RENDERBUFFER, renderbuffers[i]) == 1);
1354                         objid_array[real_n++] = real_objid;
1355                 }
1356
1357                 IF_GL_SUCCESS(_orig_fastpath_glDeleteRenderbuffers(real_n, objid_array)) {
1358                         for (i = 0; i < real_n; i++) {
1359                                 General_Trace_List *current = NULL;
1360                                 current = current_ctx->ostate.shared->using_gctxs;
1361
1362                                 while (current != NULL) {
1363                                         GLGlueContext *cur_gctx = (GLGlueContext *)current->value;
1364
1365                                         if (cur_gctx->gl_renderbuffer_binding[0] == objid_array[i]) {
1366                                                 cur_gctx->_bind_flag1 &= (~_BIND_FLAG1_BIT_gl_renderbuffer_binding);
1367                                                 cur_gctx->gl_renderbuffer_binding[0] = 0;
1368                                         }
1369
1370                                         current = current->next;
1371                                 }
1372                         }
1373                 }
1374         }
1375
1376         goto finish;
1377
1378 finish:
1379         if (objid_array != NULL) {
1380                 free(objid_array);
1381                 objid_array = NULL;
1382         }
1383         _COREGL_FASTPATH_FUNC_END();
1384 }
1385
1386
1387 //////////////////////////////////////////////////////////////////////////////////
1388
1389 GLuint
1390 fastpath_glCreateProgram(void)
1391 {
1392         GLuint ret = 0;
1393
1394         DEFINE_FASTPAH_GL_FUNC();
1395         _COREGL_FASTPATH_FUNC_BEGIN();
1396         INIT_FASTPATH_GL_FUNC();
1397
1398         AST(current_ctx->ostate.shared != NULL);
1399
1400         ret = _create_program_object(&current_ctx->ostate, 1, GL_NONE);
1401
1402         _attach_program_object(&current_ctx->ostate, ret);
1403
1404         goto finish;
1405
1406 finish:
1407         _COREGL_FASTPATH_FUNC_END();
1408         return ret;
1409 }
1410
1411
1412 GLuint
1413 fastpath_glCreateShader(GLenum type)
1414 {
1415         GLuint ret = 0;
1416
1417         DEFINE_FASTPAH_GL_FUNC();
1418         _COREGL_FASTPATH_FUNC_BEGIN();
1419         INIT_FASTPATH_GL_FUNC();
1420
1421         AST(current_ctx->ostate.shared != NULL);
1422
1423         ret = _create_program_object(&current_ctx->ostate, 0, type);
1424
1425         _attach_program_object(&current_ctx->ostate, ret);
1426
1427         goto finish;
1428
1429 finish:
1430         _COREGL_FASTPATH_FUNC_END();
1431         return ret;
1432 }
1433
1434
1435 void
1436 fastpath_glShaderSource(GLuint shader, GLsizei count, const char **string,
1437                         const GLint *length)
1438 {
1439         GLuint real_obj;
1440
1441         DEFINE_FASTPAH_GL_FUNC();
1442         _COREGL_FASTPATH_FUNC_BEGIN();
1443         INIT_FASTPATH_GL_FUNC();
1444
1445         if (GET_REAL_OBJ(GL_OBJECT_TYPE_PROGRAM, shader, &real_obj) != 1) {
1446                 _set_gl_error(GL_INVALID_VALUE);
1447                 goto finish;
1448         }
1449         _orig_fastpath_glShaderSource(real_obj, count, string, length);
1450
1451         goto finish;
1452
1453 finish:
1454         _COREGL_FASTPATH_FUNC_END();
1455 }
1456
1457
1458 void
1459 fastpath_glShaderBinary(GLsizei n, const GLuint *shaders, GLenum binaryformat,
1460                         const void *binary, GLsizei length)
1461 {
1462         int i;
1463         GLuint *objid_array = NULL;
1464
1465         DEFINE_FASTPAH_GL_FUNC();
1466         _COREGL_FASTPATH_FUNC_BEGIN();
1467         INIT_FASTPATH_GL_FUNC();
1468
1469         if (n < 0) {
1470                 _set_gl_error(GL_INVALID_VALUE);
1471                 goto finish;
1472         }
1473         if (n == 0) goto finish;
1474         if (shaders == NULL) goto finish;
1475
1476         AST(current_ctx->ostate.shared != NULL);
1477
1478         objid_array = (GLuint *)calloc(1, sizeof(GLuint) * n);
1479
1480         for (i = 0; i < n; i++) {
1481                 if (shaders[i] == 0) continue;
1482                 objid_array[i] = fastpath_ostate_get_object(&current_ctx->ostate,
1483                                  GL_OBJECT_TYPE_PROGRAM, shaders[i]);
1484         }
1485
1486         _orig_fastpath_glShaderBinary(n, objid_array, binaryformat, binary, length);
1487
1488         goto finish;
1489
1490 finish:
1491         if (objid_array != NULL) {
1492                 free(objid_array);
1493                 objid_array = NULL;
1494         }
1495
1496         _COREGL_FASTPATH_FUNC_END();
1497 }
1498
1499
1500 void
1501 fastpath_glCompileShader(GLuint shader)
1502 {
1503         GLuint real_obj;
1504
1505         DEFINE_FASTPAH_GL_FUNC();
1506         _COREGL_FASTPATH_FUNC_BEGIN();
1507         INIT_FASTPATH_GL_FUNC();
1508
1509         if (GET_REAL_OBJ(GL_OBJECT_TYPE_PROGRAM, shader, &real_obj) != 1) {
1510                 _set_gl_error(GL_INVALID_VALUE);
1511                 goto finish;
1512         }
1513
1514         _orig_fastpath_glCompileShader(real_obj);
1515
1516         goto finish;
1517
1518 finish:
1519         _COREGL_FASTPATH_FUNC_END();
1520 }
1521
1522
1523 void
1524 fastpath_glBindAttribLocation(GLuint program, GLuint index, const char *name)
1525 {
1526         GLuint real_obj;
1527
1528         DEFINE_FASTPAH_GL_FUNC();
1529         _COREGL_FASTPATH_FUNC_BEGIN();
1530         INIT_FASTPATH_GL_FUNC();
1531
1532         if (GET_REAL_OBJ(GL_OBJECT_TYPE_PROGRAM, program, &real_obj) != 1) {
1533                 _set_gl_error(GL_INVALID_VALUE);
1534                 goto finish;
1535         }
1536
1537         _orig_fastpath_glBindAttribLocation(real_obj, index, name);
1538
1539         goto finish;
1540
1541 finish:
1542         _COREGL_FASTPATH_FUNC_END();
1543 }
1544
1545
1546 void
1547 fastpath_glAttachShader(GLuint program, GLuint shader)
1548 {
1549         GLuint real_obj_program;
1550         GLuint real_obj_shader;
1551
1552         DEFINE_FASTPAH_GL_FUNC();
1553         _COREGL_FASTPATH_FUNC_BEGIN();
1554         INIT_FASTPATH_GL_FUNC();
1555
1556         if (GET_REAL_OBJ(GL_OBJECT_TYPE_PROGRAM, program, &real_obj_program) != 1 ||
1557             GET_REAL_OBJ(GL_OBJECT_TYPE_PROGRAM, shader, &real_obj_shader) != 1) {
1558                 _set_gl_error(GL_INVALID_VALUE);
1559                 goto finish;
1560         }
1561
1562         IF_GL_SUCCESS(_orig_fastpath_glAttachShader(real_obj_program,
1563                         real_obj_shader)) {
1564                 _update_program_attach_info(&current_ctx->ostate, program);
1565                 _attach_program_object(&current_ctx->ostate, shader);
1566         }
1567
1568         goto finish;
1569
1570 finish:
1571         _COREGL_FASTPATH_FUNC_END();
1572 }
1573
1574
1575 void
1576 fastpath_glDetachShader(GLuint program, GLuint shader)
1577 {
1578         GLuint real_obj_program;
1579         GLuint real_obj_shader;
1580
1581         DEFINE_FASTPAH_GL_FUNC();
1582         _COREGL_FASTPATH_FUNC_BEGIN();
1583         INIT_FASTPATH_GL_FUNC();
1584
1585         if (GET_REAL_OBJ(GL_OBJECT_TYPE_PROGRAM, program, &real_obj_program) != 1 ||
1586             GET_REAL_OBJ(GL_OBJECT_TYPE_PROGRAM, shader, &real_obj_shader) != 1) {
1587                 _set_gl_error(GL_INVALID_VALUE);
1588                 goto finish;
1589         }
1590
1591         IF_GL_SUCCESS(_orig_fastpath_glDetachShader(real_obj_program,
1592                         real_obj_shader)) {
1593                 _update_program_attach_info(&current_ctx->ostate, program);
1594                 _detach_program_object(&current_ctx->ostate, real_obj_shader, 0, 0);
1595         }
1596
1597         goto finish;
1598
1599 finish:
1600         _COREGL_FASTPATH_FUNC_END();
1601 }
1602
1603
1604 GLboolean
1605 fastpath_glIsShader(GLuint shader)
1606 {
1607         GLboolean ret = GL_FALSE;
1608         GLuint real_obj;
1609
1610         DEFINE_FASTPAH_GL_FUNC();
1611         _COREGL_FASTPATH_FUNC_BEGIN();
1612         INIT_FASTPATH_GL_FUNC();
1613
1614         if (GET_REAL_OBJ(GL_OBJECT_TYPE_PROGRAM, shader, &real_obj) != 1) {
1615                 ret = GL_FALSE;
1616                 goto finish;
1617         }
1618
1619         ret = _orig_fastpath_glIsShader(real_obj);
1620
1621         goto finish;
1622
1623 finish:
1624         _COREGL_FASTPATH_FUNC_END();
1625         return ret;
1626 }
1627
1628
1629 GLboolean
1630 fastpath_glIsProgram(GLuint program)
1631 {
1632         GLboolean ret = GL_FALSE;
1633         GLuint real_obj;
1634
1635         DEFINE_FASTPAH_GL_FUNC();
1636         _COREGL_FASTPATH_FUNC_BEGIN();
1637         INIT_FASTPATH_GL_FUNC();
1638
1639         if (GET_REAL_OBJ(GL_OBJECT_TYPE_PROGRAM, program, &real_obj) != 1) {
1640                 ret = GL_FALSE;
1641                 goto finish;
1642         }
1643
1644         ret = _orig_fastpath_glIsProgram(real_obj);
1645
1646         goto finish;
1647
1648 finish:
1649         _COREGL_FASTPATH_FUNC_END();
1650         return ret;
1651 }
1652
1653
1654 void
1655 fastpath_glLinkProgram(GLuint program)
1656 {
1657         GLuint real_obj;
1658
1659         DEFINE_FASTPAH_GL_FUNC();
1660         _COREGL_FASTPATH_FUNC_BEGIN();
1661         INIT_FASTPATH_GL_FUNC();
1662
1663         if (GET_REAL_OBJ(GL_OBJECT_TYPE_PROGRAM, program, &real_obj) != 1) {
1664                 _set_gl_error(GL_INVALID_VALUE);
1665                 goto finish;
1666         }
1667
1668         _orig_fastpath_glLinkProgram(real_obj);
1669
1670         goto finish;
1671
1672 finish:
1673         _COREGL_FASTPATH_FUNC_END();
1674 }
1675
1676
1677 void
1678 fastpath_glValidateProgram(GLuint program)
1679 {
1680         GLuint real_obj;
1681
1682         DEFINE_FASTPAH_GL_FUNC();
1683         _COREGL_FASTPATH_FUNC_BEGIN();
1684         INIT_FASTPATH_GL_FUNC();
1685
1686         if (GET_REAL_OBJ(GL_OBJECT_TYPE_PROGRAM, program, &real_obj) != 1) {
1687                 _set_gl_error(GL_INVALID_VALUE);
1688                 goto finish;
1689         }
1690
1691         _orig_fastpath_glValidateProgram(real_obj);
1692
1693         goto finish;
1694
1695 finish:
1696         _COREGL_FASTPATH_FUNC_END();
1697 }
1698
1699
1700 void
1701 fastpath_glUseProgram(GLuint program)
1702 {
1703         GLuint real_obj;
1704
1705         DEFINE_FASTPAH_GL_FUNC();
1706         _COREGL_FASTPATH_FUNC_BEGIN();
1707         INIT_FASTPATH_GL_FUNC();
1708
1709         if (GET_REAL_OBJ(GL_OBJECT_TYPE_PROGRAM, program, &real_obj) != 1) {
1710                 _set_gl_error(GL_INVALID_VALUE);
1711                 goto finish;
1712         }
1713
1714         CURR_STATE_COMPARE(gl_current_program, real_obj) {
1715                 IF_GL_SUCCESS(_orig_fastpath_glUseProgram(real_obj)) {
1716                         _attach_program_object(&current_ctx->ostate, program);
1717                         _detach_program_object(&current_ctx->ostate, current_ctx->gl_current_program[0],
1718                                                1, 0);
1719
1720                         current_ctx->_clear_flag1 |= _CLEAR_FLAG1_BIT_gl_current_program;
1721                         current_ctx->gl_current_program[0] = real_obj;
1722                 }
1723         }
1724         goto finish;
1725
1726 finish:
1727         _COREGL_FASTPATH_FUNC_END();
1728 }
1729
1730
1731 void
1732 fastpath_glGetActiveAttrib(GLuint program, GLuint index, GLsizei bufsize,
1733                            GLsizei *length, GLint *size, GLenum *type, char *name)
1734 {
1735         GLuint real_obj;
1736
1737         DEFINE_FASTPAH_GL_FUNC();
1738         _COREGL_FASTPATH_FUNC_BEGIN();
1739         INIT_FASTPATH_GL_FUNC();
1740
1741         if (GET_REAL_OBJ(GL_OBJECT_TYPE_PROGRAM, program, &real_obj) != 1) {
1742                 _set_gl_error(GL_INVALID_VALUE);
1743                 goto finish;
1744         }
1745
1746         _orig_fastpath_glGetActiveAttrib(real_obj, index, bufsize, length, size, type,
1747                                          name);
1748
1749         goto finish;
1750
1751 finish:
1752         _COREGL_FASTPATH_FUNC_END();
1753 }
1754
1755
1756 void
1757 fastpath_glGetActiveUniform(GLuint program, GLuint index, GLsizei bufsize,
1758                             GLsizei *length, GLint *size, GLenum *type, char *name)
1759 {
1760         GLuint real_obj;
1761
1762         DEFINE_FASTPAH_GL_FUNC();
1763         _COREGL_FASTPATH_FUNC_BEGIN();
1764         INIT_FASTPATH_GL_FUNC();
1765
1766         if (GET_REAL_OBJ(GL_OBJECT_TYPE_PROGRAM, program, &real_obj) != 1) {
1767                 _set_gl_error(GL_INVALID_VALUE);
1768                 goto finish;
1769         }
1770
1771         _orig_fastpath_glGetActiveUniform(real_obj, index, bufsize, length, size, type,
1772                                           name);
1773
1774         goto finish;
1775
1776 finish:
1777         _COREGL_FASTPATH_FUNC_END();
1778 }
1779
1780
1781 void
1782 fastpath_glGetAttachedShaders(GLuint program, GLsizei maxcount, GLsizei *count,
1783                               GLuint *shaders)
1784 {
1785         int i;
1786         GLsizei real_count = _COREGL_INT_INIT_VALUE;
1787         GLuint real_obj;
1788
1789         DEFINE_FASTPAH_GL_FUNC();
1790         _COREGL_FASTPATH_FUNC_BEGIN();
1791         INIT_FASTPATH_GL_FUNC();
1792
1793         if (GET_REAL_OBJ(GL_OBJECT_TYPE_PROGRAM, program, &real_obj) != 1) {
1794                 _set_gl_error(GL_INVALID_VALUE);
1795                 goto finish;
1796         }
1797
1798         IF_GL_SUCCESS(_orig_fastpath_glGetAttachedShaders(real_obj, maxcount,
1799                         &real_count, shaders)) {
1800                 for (i = 0; i < real_count; i++) {
1801                         if (shaders[i] != 0)
1802                                 shaders[i] = fastpath_ostate_find_object(&current_ctx->ostate,
1803                                                 GL_OBJECT_TYPE_PROGRAM, shaders[i]);
1804                 }
1805                 if (count != NULL) *count = real_count;
1806         }
1807
1808         goto finish;
1809
1810 finish:
1811         _COREGL_FASTPATH_FUNC_END();
1812 }
1813
1814
1815 int
1816 fastpath_glGetAttribLocation(GLuint program, const char *name)
1817 {
1818         int ret = _COREGL_INT_INIT_VALUE;
1819         GLuint real_obj;
1820
1821         DEFINE_FASTPAH_GL_FUNC();
1822         _COREGL_FASTPATH_FUNC_BEGIN();
1823         INIT_FASTPATH_GL_FUNC();
1824
1825         if (GET_REAL_OBJ(GL_OBJECT_TYPE_PROGRAM, program, &real_obj) != 1) {
1826                 _set_gl_error(GL_INVALID_VALUE);
1827                 goto finish;
1828         }
1829
1830         ret = _orig_fastpath_glGetAttribLocation(real_obj, name);
1831
1832         goto finish;
1833
1834 finish:
1835         _COREGL_FASTPATH_FUNC_END();
1836         return ret;
1837 }
1838
1839
1840 void
1841 fastpath_glGetShaderiv(GLuint shader, GLenum pname, GLint *params)
1842 {
1843         GLuint real_obj;
1844
1845         DEFINE_FASTPAH_GL_FUNC();
1846         _COREGL_FASTPATH_FUNC_BEGIN();
1847         INIT_FASTPATH_GL_FUNC();
1848
1849         if (GET_REAL_OBJ(GL_OBJECT_TYPE_PROGRAM, shader, &real_obj) != 1) {
1850                 _set_gl_error(GL_INVALID_VALUE);
1851                 goto finish;
1852         }
1853
1854         switch (pname) {
1855         case GL_DELETE_STATUS:
1856                 *params = GL_FALSE;
1857                 if (_is_deleted_program_object(&current_ctx->ostate, shader) == 1)
1858                         *params = GL_TRUE;
1859                 break;
1860         default:
1861                 _orig_fastpath_glGetShaderiv(real_obj, pname, params);
1862                 break;
1863         }
1864
1865         goto finish;
1866
1867 finish:
1868         _COREGL_FASTPATH_FUNC_END();
1869 }
1870
1871
1872 void
1873 fastpath_glGetShaderInfoLog(GLuint shader, GLsizei bufsize, GLsizei *length,
1874                             char *infolog)
1875 {
1876         GLuint real_obj;
1877
1878         DEFINE_FASTPAH_GL_FUNC();
1879         _COREGL_FASTPATH_FUNC_BEGIN();
1880         INIT_FASTPATH_GL_FUNC();
1881
1882         if (GET_REAL_OBJ(GL_OBJECT_TYPE_PROGRAM, shader, &real_obj) != 1) {
1883                 _set_gl_error(GL_INVALID_VALUE);
1884                 goto finish;
1885         }
1886
1887         _orig_fastpath_glGetShaderInfoLog(real_obj, bufsize, length, infolog);
1888
1889         goto finish;
1890
1891 finish:
1892         _COREGL_FASTPATH_FUNC_END();
1893 }
1894
1895
1896 void
1897 fastpath_glGetProgramiv(GLuint program, GLenum pname, GLint *params)
1898 {
1899         GLuint real_obj;
1900
1901         DEFINE_FASTPAH_GL_FUNC();
1902         _COREGL_FASTPATH_FUNC_BEGIN();
1903         INIT_FASTPATH_GL_FUNC();
1904
1905         if (GET_REAL_OBJ(GL_OBJECT_TYPE_PROGRAM, program, &real_obj) != 1) {
1906                 _set_gl_error(GL_INVALID_VALUE);
1907                 goto finish;
1908         }
1909
1910         switch (pname) {
1911         case GL_DELETE_STATUS:
1912                 *params = GL_FALSE;
1913                 if (_is_deleted_program_object(&current_ctx->ostate, program) == 1)
1914                         *params = GL_TRUE;
1915                 break;
1916         default:
1917                 _orig_fastpath_glGetProgramiv(real_obj, pname, params);
1918                 break;
1919         }
1920
1921         goto finish;
1922
1923 finish:
1924         _COREGL_FASTPATH_FUNC_END();
1925 }
1926
1927
1928 void
1929 fastpath_glGetProgramInfoLog(GLuint program, GLsizei bufsize, GLsizei *length,
1930                              char *infolog)
1931 {
1932         GLuint real_obj;
1933
1934         DEFINE_FASTPAH_GL_FUNC();
1935         _COREGL_FASTPATH_FUNC_BEGIN();
1936         INIT_FASTPATH_GL_FUNC();
1937
1938         if (GET_REAL_OBJ(GL_OBJECT_TYPE_PROGRAM, program, &real_obj) != 1) {
1939                 _set_gl_error(GL_INVALID_VALUE);
1940                 goto finish;
1941         }
1942
1943         _orig_fastpath_glGetProgramInfoLog(real_obj, bufsize, length, infolog);
1944
1945         goto finish;
1946
1947 finish:
1948         _COREGL_FASTPATH_FUNC_END();
1949 }
1950
1951
1952 void
1953 fastpath_glGetShaderSource(GLuint shader, GLsizei bufsize, GLsizei *length,
1954                            char *source)
1955 {
1956         GLuint real_obj;
1957
1958         DEFINE_FASTPAH_GL_FUNC();
1959         _COREGL_FASTPATH_FUNC_BEGIN();
1960         INIT_FASTPATH_GL_FUNC();
1961
1962         if (GET_REAL_OBJ(GL_OBJECT_TYPE_PROGRAM, shader, &real_obj) != 1) {
1963                 _set_gl_error(GL_INVALID_VALUE);
1964                 goto finish;
1965         }
1966
1967         _orig_fastpath_glGetShaderSource(real_obj, bufsize, length, source);
1968
1969         goto finish;
1970
1971 finish:
1972         _COREGL_FASTPATH_FUNC_END();
1973 }
1974
1975
1976 void
1977 fastpath_glGetUniformfv(GLuint program, GLint location, GLfloat *params)
1978 {
1979         GLuint real_obj;
1980
1981         DEFINE_FASTPAH_GL_FUNC();
1982         _COREGL_FASTPATH_FUNC_BEGIN();
1983         INIT_FASTPATH_GL_FUNC();
1984
1985         if (GET_REAL_OBJ(GL_OBJECT_TYPE_PROGRAM, program, &real_obj) != 1) {
1986                 _set_gl_error(GL_INVALID_VALUE);
1987                 goto finish;
1988         }
1989
1990         _orig_fastpath_glGetUniformfv(real_obj, location, params);
1991
1992         goto finish;
1993
1994 finish:
1995         _COREGL_FASTPATH_FUNC_END();
1996 }
1997
1998
1999 void
2000 fastpath_glGetUniformiv(GLuint program, GLint location, GLint *params)
2001 {
2002         GLuint real_obj;
2003
2004         DEFINE_FASTPAH_GL_FUNC();
2005         _COREGL_FASTPATH_FUNC_BEGIN();
2006         INIT_FASTPATH_GL_FUNC();
2007
2008         if (GET_REAL_OBJ(GL_OBJECT_TYPE_PROGRAM, program, &real_obj) != 1) {
2009                 _set_gl_error(GL_INVALID_VALUE);
2010                 goto finish;
2011         }
2012
2013         _orig_fastpath_glGetUniformiv(real_obj, location, params);
2014
2015         goto finish;
2016
2017 finish:
2018         _COREGL_FASTPATH_FUNC_END();
2019 }
2020
2021
2022 void
2023 fastpath_glUseProgramStagesEXT(GLuint pipeline, GLbitfield stages,
2024                                GLuint program)
2025 {
2026         GLuint real_obj;
2027
2028         DEFINE_FASTPAH_GL_FUNC();
2029         _COREGL_FASTPATH_FUNC_BEGIN();
2030         INIT_FASTPATH_GL_FUNC();
2031
2032         if (GET_REAL_OBJ(GL_OBJECT_TYPE_PROGRAM, program, &real_obj) != 1) {
2033                 _set_gl_error(GL_INVALID_VALUE);
2034                 goto finish;
2035         }
2036
2037         _orig_fastpath_glUseProgramStagesEXT(pipeline, stages, real_obj);
2038
2039         goto finish;
2040
2041 finish:
2042         _COREGL_FASTPATH_FUNC_END();
2043 }
2044
2045
2046 void
2047 fastpath_glActiveShaderProgramEXT(GLuint pipeline, GLuint program)
2048 {
2049         GLuint real_obj;
2050
2051         DEFINE_FASTPAH_GL_FUNC();
2052         _COREGL_FASTPATH_FUNC_BEGIN();
2053         INIT_FASTPATH_GL_FUNC();
2054
2055         if (GET_REAL_OBJ(GL_OBJECT_TYPE_PROGRAM, program, &real_obj) != 1) {
2056                 _set_gl_error(GL_INVALID_VALUE);
2057                 goto finish;
2058         }
2059
2060         _orig_fastpath_glActiveShaderProgramEXT(pipeline, real_obj);
2061
2062         goto finish;
2063
2064 finish:
2065         _COREGL_FASTPATH_FUNC_END();
2066 }
2067
2068
2069 void
2070 fastpath_glProgramParameteriEXT(GLuint program, GLenum pname, GLint value)
2071 {
2072         GLuint real_obj;
2073
2074         DEFINE_FASTPAH_GL_FUNC();
2075         _COREGL_FASTPATH_FUNC_BEGIN();
2076         INIT_FASTPATH_GL_FUNC();
2077
2078         if (GET_REAL_OBJ(GL_OBJECT_TYPE_PROGRAM, program, &real_obj) != 1) {
2079                 _set_gl_error(GL_INVALID_VALUE);
2080                 goto finish;
2081         }
2082
2083         _orig_fastpath_glProgramParameteriEXT(real_obj, pname, value);
2084
2085         goto finish;
2086
2087 finish:
2088         _COREGL_FASTPATH_FUNC_END();
2089 }
2090
2091
2092 void
2093 fastpath_glProgramUniform1iEXT(GLuint program, GLint location, GLint x)
2094 {
2095         GLuint real_obj;
2096
2097         DEFINE_FASTPAH_GL_FUNC();
2098         _COREGL_FASTPATH_FUNC_BEGIN();
2099         INIT_FASTPATH_GL_FUNC();
2100
2101         if (GET_REAL_OBJ(GL_OBJECT_TYPE_PROGRAM, program, &real_obj) != 1) {
2102                 _set_gl_error(GL_INVALID_VALUE);
2103                 goto finish;
2104         }
2105
2106         _orig_fastpath_glProgramUniform1iEXT(real_obj, location, x);
2107
2108         goto finish;
2109
2110 finish:
2111         _COREGL_FASTPATH_FUNC_END();
2112 }
2113
2114
2115 void
2116 fastpath_glProgramUniform2iEXT(GLuint program, GLint location, GLint x, GLint y)
2117 {
2118         GLuint real_obj;
2119
2120         DEFINE_FASTPAH_GL_FUNC();
2121         _COREGL_FASTPATH_FUNC_BEGIN();
2122         INIT_FASTPATH_GL_FUNC();
2123
2124         if (GET_REAL_OBJ(GL_OBJECT_TYPE_PROGRAM, program, &real_obj) != 1) {
2125                 _set_gl_error(GL_INVALID_VALUE);
2126                 goto finish;
2127         }
2128
2129         _orig_fastpath_glProgramUniform2iEXT(real_obj, location, x, y);
2130
2131         goto finish;
2132
2133 finish:
2134         _COREGL_FASTPATH_FUNC_END();
2135 }
2136
2137
2138 void
2139 fastpath_glProgramUniform3iEXT(GLuint program, GLint location, GLint x, GLint y,
2140                                GLint z)
2141 {
2142         GLuint real_obj;
2143
2144         DEFINE_FASTPAH_GL_FUNC();
2145         _COREGL_FASTPATH_FUNC_BEGIN();
2146         INIT_FASTPATH_GL_FUNC();
2147
2148         if (GET_REAL_OBJ(GL_OBJECT_TYPE_PROGRAM, program, &real_obj) != 1) {
2149                 _set_gl_error(GL_INVALID_VALUE);
2150                 goto finish;
2151         }
2152
2153         _orig_fastpath_glProgramUniform3iEXT(real_obj, location, x, y, z);
2154
2155         goto finish;
2156
2157 finish:
2158         _COREGL_FASTPATH_FUNC_END();
2159 }
2160
2161
2162 void
2163 fastpath_glProgramUniform4iEXT(GLuint program, GLint location, GLint x, GLint y,
2164                                GLint z, GLint w)
2165 {
2166         GLuint real_obj;
2167
2168         DEFINE_FASTPAH_GL_FUNC();
2169         _COREGL_FASTPATH_FUNC_BEGIN();
2170         INIT_FASTPATH_GL_FUNC();
2171
2172         if (GET_REAL_OBJ(GL_OBJECT_TYPE_PROGRAM, program, &real_obj) != 1) {
2173                 _set_gl_error(GL_INVALID_VALUE);
2174                 goto finish;
2175         }
2176
2177         _orig_fastpath_glProgramUniform4iEXT(real_obj, location, x, y, z, w);
2178
2179         goto finish;
2180
2181 finish:
2182         _COREGL_FASTPATH_FUNC_END();
2183 }
2184
2185
2186 void
2187 fastpath_glProgramUniform1fEXT(GLuint program, GLint location, GLfloat x)
2188 {
2189         GLuint real_obj;
2190
2191         DEFINE_FASTPAH_GL_FUNC();
2192         _COREGL_FASTPATH_FUNC_BEGIN();
2193         INIT_FASTPATH_GL_FUNC();
2194
2195         if (GET_REAL_OBJ(GL_OBJECT_TYPE_PROGRAM, program, &real_obj) != 1) {
2196                 _set_gl_error(GL_INVALID_VALUE);
2197                 goto finish;
2198         }
2199
2200         _orig_fastpath_glProgramUniform1fEXT(real_obj, location, x);
2201
2202         goto finish;
2203
2204 finish:
2205         _COREGL_FASTPATH_FUNC_END();
2206 }
2207
2208
2209 void
2210 fastpath_glProgramUniform2fEXT(GLuint program, GLint location, GLfloat x,
2211                                GLfloat y)
2212 {
2213         GLuint real_obj;
2214
2215         DEFINE_FASTPAH_GL_FUNC();
2216         _COREGL_FASTPATH_FUNC_BEGIN();
2217         INIT_FASTPATH_GL_FUNC();
2218
2219         if (GET_REAL_OBJ(GL_OBJECT_TYPE_PROGRAM, program, &real_obj) != 1) {
2220                 _set_gl_error(GL_INVALID_VALUE);
2221                 goto finish;
2222         }
2223
2224         _orig_fastpath_glProgramUniform2fEXT(real_obj, location, x, y);
2225
2226         goto finish;
2227
2228 finish:
2229         _COREGL_FASTPATH_FUNC_END();
2230 }
2231
2232
2233 void
2234 fastpath_glProgramUniform3fEXT(GLuint program, GLint location, GLfloat x,
2235                                GLfloat y, GLfloat z)
2236 {
2237         GLuint real_obj;
2238
2239         DEFINE_FASTPAH_GL_FUNC();
2240         _COREGL_FASTPATH_FUNC_BEGIN();
2241         INIT_FASTPATH_GL_FUNC();
2242
2243         if (GET_REAL_OBJ(GL_OBJECT_TYPE_PROGRAM, program, &real_obj) != 1) {
2244                 _set_gl_error(GL_INVALID_VALUE);
2245                 goto finish;
2246         }
2247
2248         _orig_fastpath_glProgramUniform3fEXT(real_obj, location, x, y, z);
2249
2250         goto finish;
2251
2252 finish:
2253         _COREGL_FASTPATH_FUNC_END();
2254 }
2255
2256
2257 void
2258 fastpath_glProgramUniform4fEXT(GLuint program, GLint location, GLfloat x,
2259                                GLfloat y, GLfloat z, GLfloat w)
2260 {
2261         GLuint real_obj;
2262
2263         DEFINE_FASTPAH_GL_FUNC();
2264         _COREGL_FASTPATH_FUNC_BEGIN();
2265         INIT_FASTPATH_GL_FUNC();
2266
2267         if (GET_REAL_OBJ(GL_OBJECT_TYPE_PROGRAM, program, &real_obj) != 1) {
2268                 _set_gl_error(GL_INVALID_VALUE);
2269                 goto finish;
2270         }
2271
2272         _orig_fastpath_glProgramUniform4fEXT(real_obj, location, x, y, z, w);
2273
2274         goto finish;
2275
2276 finish:
2277         _COREGL_FASTPATH_FUNC_END();
2278 }
2279
2280
2281 void
2282 fastpath_glProgramUniform1ivEXT(GLuint program, GLint location, GLsizei count,
2283                                 const GLint *value)
2284 {
2285         GLuint real_obj;
2286
2287         DEFINE_FASTPAH_GL_FUNC();
2288         _COREGL_FASTPATH_FUNC_BEGIN();
2289         INIT_FASTPATH_GL_FUNC();
2290
2291         if (GET_REAL_OBJ(GL_OBJECT_TYPE_PROGRAM, program, &real_obj) != 1) {
2292                 _set_gl_error(GL_INVALID_VALUE);
2293                 goto finish;
2294         }
2295
2296         _orig_fastpath_glProgramUniform1ivEXT(real_obj, location, count, value);
2297
2298         goto finish;
2299
2300 finish:
2301         _COREGL_FASTPATH_FUNC_END();
2302 }
2303
2304
2305 void
2306 fastpath_glProgramUniform2ivEXT(GLuint program, GLint location, GLsizei count,
2307                                 const GLint *value)
2308 {
2309         GLuint real_obj;
2310
2311         DEFINE_FASTPAH_GL_FUNC();
2312         _COREGL_FASTPATH_FUNC_BEGIN();
2313         INIT_FASTPATH_GL_FUNC();
2314
2315         if (GET_REAL_OBJ(GL_OBJECT_TYPE_PROGRAM, program, &real_obj) != 1) {
2316                 _set_gl_error(GL_INVALID_VALUE);
2317                 goto finish;
2318         }
2319
2320         _orig_fastpath_glProgramUniform2ivEXT(real_obj, location, count, value);
2321
2322         goto finish;
2323
2324 finish:
2325         _COREGL_FASTPATH_FUNC_END();
2326 }
2327
2328
2329 void
2330 fastpath_glProgramUniform3ivEXT(GLuint program, GLint location, GLsizei count,
2331                                 const GLint *value)
2332 {
2333         GLuint real_obj;
2334
2335         DEFINE_FASTPAH_GL_FUNC();
2336         _COREGL_FASTPATH_FUNC_BEGIN();
2337         INIT_FASTPATH_GL_FUNC();
2338
2339         if (GET_REAL_OBJ(GL_OBJECT_TYPE_PROGRAM, program, &real_obj) != 1) {
2340                 _set_gl_error(GL_INVALID_VALUE);
2341                 goto finish;
2342         }
2343
2344         _orig_fastpath_glProgramUniform3ivEXT(real_obj, location, count, value);
2345
2346         goto finish;
2347
2348 finish:
2349         _COREGL_FASTPATH_FUNC_END();
2350 }
2351
2352
2353 void
2354 fastpath_glProgramUniform4ivEXT(GLuint program, GLint location, GLsizei count,
2355                                 const GLint *value)
2356 {
2357         GLuint real_obj;
2358
2359         DEFINE_FASTPAH_GL_FUNC();
2360         _COREGL_FASTPATH_FUNC_BEGIN();
2361         INIT_FASTPATH_GL_FUNC();
2362
2363         if (GET_REAL_OBJ(GL_OBJECT_TYPE_PROGRAM, program, &real_obj) != 1) {
2364                 _set_gl_error(GL_INVALID_VALUE);
2365                 goto finish;
2366         }
2367
2368         _orig_fastpath_glProgramUniform4ivEXT(real_obj, location, count, value);
2369
2370         goto finish;
2371
2372 finish:
2373         _COREGL_FASTPATH_FUNC_END();
2374 }
2375
2376
2377 void
2378 fastpath_glProgramUniform1fvEXT(GLuint program, GLint location, GLsizei count,
2379                                 const GLfloat *value)
2380 {
2381         GLuint real_obj;
2382
2383         DEFINE_FASTPAH_GL_FUNC();
2384         _COREGL_FASTPATH_FUNC_BEGIN();
2385         INIT_FASTPATH_GL_FUNC();
2386
2387         if (GET_REAL_OBJ(GL_OBJECT_TYPE_PROGRAM, program, &real_obj) != 1) {
2388                 _set_gl_error(GL_INVALID_VALUE);
2389                 goto finish;
2390         }
2391
2392         _orig_fastpath_glProgramUniform1fvEXT(real_obj, location, count, value);
2393
2394         goto finish;
2395
2396 finish:
2397         _COREGL_FASTPATH_FUNC_END();
2398 }
2399
2400
2401 void
2402 fastpath_glProgramUniform2fvEXT(GLuint program, GLint location, GLsizei count,
2403                                 const GLfloat *value)
2404 {
2405         GLuint real_obj;
2406
2407         DEFINE_FASTPAH_GL_FUNC();
2408         _COREGL_FASTPATH_FUNC_BEGIN();
2409         INIT_FASTPATH_GL_FUNC();
2410
2411         if (GET_REAL_OBJ(GL_OBJECT_TYPE_PROGRAM, program, &real_obj) != 1) {
2412                 _set_gl_error(GL_INVALID_VALUE);
2413                 goto finish;
2414         }
2415
2416         _orig_fastpath_glProgramUniform2fvEXT(real_obj, location, count, value);
2417
2418         goto finish;
2419
2420 finish:
2421         _COREGL_FASTPATH_FUNC_END();
2422 }
2423
2424
2425 void
2426 fastpath_glProgramUniform3fvEXT(GLuint program, GLint location, GLsizei count,
2427                                 const GLfloat *value)
2428 {
2429         GLuint real_obj;
2430
2431         DEFINE_FASTPAH_GL_FUNC();
2432         _COREGL_FASTPATH_FUNC_BEGIN();
2433         INIT_FASTPATH_GL_FUNC();
2434
2435         if (GET_REAL_OBJ(GL_OBJECT_TYPE_PROGRAM, program, &real_obj) != 1) {
2436                 _set_gl_error(GL_INVALID_VALUE);
2437                 goto finish;
2438         }
2439
2440         _orig_fastpath_glProgramUniform3fvEXT(real_obj, location, count, value);
2441
2442         goto finish;
2443
2444 finish:
2445         _COREGL_FASTPATH_FUNC_END();
2446 }
2447
2448
2449 void
2450 fastpath_glProgramUniform4fvEXT(GLuint program, GLint location, GLsizei count,
2451                                 const GLfloat *value)
2452 {
2453         GLuint real_obj;
2454
2455         DEFINE_FASTPAH_GL_FUNC();
2456         _COREGL_FASTPATH_FUNC_BEGIN();
2457         INIT_FASTPATH_GL_FUNC();
2458
2459         if (GET_REAL_OBJ(GL_OBJECT_TYPE_PROGRAM, program, &real_obj) != 1) {
2460                 _set_gl_error(GL_INVALID_VALUE);
2461                 goto finish;
2462         }
2463
2464         _orig_fastpath_glProgramUniform4fvEXT(real_obj, location, count, value);
2465
2466         goto finish;
2467
2468 finish:
2469         _COREGL_FASTPATH_FUNC_END();
2470 }
2471
2472
2473 void
2474 fastpath_glProgramUniformMatrix2fvEXT(GLuint program, GLint location,
2475                                       GLsizei count, GLboolean transpose, const GLfloat *value)
2476 {
2477         GLuint real_obj;
2478
2479         DEFINE_FASTPAH_GL_FUNC();
2480         _COREGL_FASTPATH_FUNC_BEGIN();
2481         INIT_FASTPATH_GL_FUNC();
2482
2483         if (GET_REAL_OBJ(GL_OBJECT_TYPE_PROGRAM, program, &real_obj) != 1) {
2484                 _set_gl_error(GL_INVALID_VALUE);
2485                 goto finish;
2486         }
2487
2488         _orig_fastpath_glProgramUniformMatrix2fvEXT(real_obj, location, count,
2489                         transpose, value);
2490
2491         goto finish;
2492
2493 finish:
2494         _COREGL_FASTPATH_FUNC_END();
2495 }
2496
2497
2498 void
2499 fastpath_glProgramUniformMatrix3fvEXT(GLuint program, GLint location,
2500                                       GLsizei count, GLboolean transpose, const GLfloat *value)
2501 {
2502         GLuint real_obj;
2503
2504         DEFINE_FASTPAH_GL_FUNC();
2505         _COREGL_FASTPATH_FUNC_BEGIN();
2506         INIT_FASTPATH_GL_FUNC();
2507
2508         if (GET_REAL_OBJ(GL_OBJECT_TYPE_PROGRAM, program, &real_obj) != 1) {
2509                 _set_gl_error(GL_INVALID_VALUE);
2510                 goto finish;
2511         }
2512
2513         _orig_fastpath_glProgramUniformMatrix3fvEXT(real_obj, location, count,
2514                         transpose, value);
2515
2516         goto finish;
2517
2518 finish:
2519         _COREGL_FASTPATH_FUNC_END();
2520 }
2521
2522
2523 void
2524 fastpath_glProgramUniformMatrix4fvEXT(GLuint program, GLint location,
2525                                       GLsizei count, GLboolean transpose, const GLfloat *value)
2526 {
2527         GLuint real_obj;
2528
2529         DEFINE_FASTPAH_GL_FUNC();
2530         _COREGL_FASTPATH_FUNC_BEGIN();
2531         INIT_FASTPATH_GL_FUNC();
2532
2533         if (GET_REAL_OBJ(GL_OBJECT_TYPE_PROGRAM, program, &real_obj) != 1) {
2534                 _set_gl_error(GL_INVALID_VALUE);
2535                 goto finish;
2536         }
2537
2538         _orig_fastpath_glProgramUniformMatrix4fvEXT(real_obj, location, count,
2539                         transpose, value);
2540
2541         goto finish;
2542
2543 finish:
2544         _COREGL_FASTPATH_FUNC_END();
2545 }
2546
2547
2548 int
2549 fastpath_glGetUniformLocation(GLuint program, const char *name)
2550 {
2551         int ret = _COREGL_INT_INIT_VALUE;
2552         GLuint real_obj;
2553
2554         DEFINE_FASTPAH_GL_FUNC();
2555         _COREGL_FASTPATH_FUNC_BEGIN();
2556         INIT_FASTPATH_GL_FUNC();
2557
2558         if (GET_REAL_OBJ(GL_OBJECT_TYPE_PROGRAM, program, &real_obj) != 1) {
2559                 _set_gl_error(GL_INVALID_VALUE);
2560                 ret = -1;
2561                 goto finish;
2562         }
2563
2564         ret = _orig_fastpath_glGetUniformLocation(real_obj, name);
2565
2566         goto finish;
2567
2568 finish:
2569         _COREGL_FASTPATH_FUNC_END();
2570         return ret;
2571 }
2572
2573 void
2574 fastpath_glDeleteShader(GLuint shader)
2575 {
2576         GLuint real_obj;
2577
2578         DEFINE_FASTPAH_GL_FUNC();
2579         _COREGL_FASTPATH_FUNC_BEGIN();
2580         INIT_FASTPATH_GL_FUNC();
2581
2582         if (GET_REAL_OBJ(GL_OBJECT_TYPE_PROGRAM, shader, &real_obj) != 1) {
2583                 _set_gl_error(GL_INVALID_VALUE);
2584                 goto finish;
2585         }
2586
2587         _detach_program_object(&current_ctx->ostate, real_obj, 0, 1);
2588
2589         goto finish;
2590
2591 finish:
2592         _COREGL_FASTPATH_FUNC_END();
2593 }
2594
2595 void
2596 fastpath_glDeleteProgram(GLuint program)
2597 {
2598         GLuint real_obj;
2599
2600         DEFINE_FASTPAH_GL_FUNC();
2601         _COREGL_FASTPATH_FUNC_BEGIN();
2602         INIT_FASTPATH_GL_FUNC();
2603
2604         if (GET_REAL_OBJ(GL_OBJECT_TYPE_PROGRAM, program, &real_obj) != 1) {
2605                 _set_gl_error(GL_INVALID_VALUE);
2606                 goto finish;
2607         }
2608
2609         _detach_program_object(&current_ctx->ostate, real_obj, 1, 1);
2610
2611         goto finish;
2612
2613 finish:
2614         _COREGL_FASTPATH_FUNC_END();
2615 }
2616
2617
2618
2619 //////////////////////////////////////////////////////////////////////////////////
2620
2621 void
2622 fastpath_glBlendColor(GLclampf red, GLclampf green, GLclampf blue,
2623                       GLclampf alpha)
2624 {
2625         DEFINE_FASTPAH_GL_FUNC();
2626         _COREGL_FASTPATH_FUNC_BEGIN();
2627         INIT_FASTPATH_GL_FUNC();
2628
2629         if ((current_ctx->gl_blend_color[0] != red) ||
2630             (current_ctx->gl_blend_color[1] != green) ||
2631             (current_ctx->gl_blend_color[2] != blue) ||
2632             (current_ctx->gl_blend_color[3] != alpha)) {
2633                 IF_GL_SUCCESS(_orig_fastpath_glBlendColor(red, green, blue, alpha)) {
2634                         current_ctx->_blend_flag |= _BLEND_FLAG_BIT_gl_blend_color;
2635                         current_ctx->gl_blend_color[0] = red;
2636                         current_ctx->gl_blend_color[1] = green;
2637                         current_ctx->gl_blend_color[2] = blue;
2638                         current_ctx->gl_blend_color[3] = alpha;
2639                 }
2640         }
2641         goto finish;
2642
2643 finish:
2644         _COREGL_FASTPATH_FUNC_END();
2645 }
2646
2647
2648 void
2649 fastpath_glBlendEquation(GLenum mode)
2650 {
2651         DEFINE_FASTPAH_GL_FUNC();
2652         _COREGL_FASTPATH_FUNC_BEGIN();
2653         INIT_FASTPATH_GL_FUNC();
2654
2655         IF_GL_SUCCESS(_orig_fastpath_glBlendEquation(mode)) {
2656                 current_ctx->_blend_flag |=
2657                         _BLEND_FLAG_BIT_gl_blend_equation_rgb |
2658                         _BLEND_FLAG_BIT_gl_blend_equation_alpha;
2659
2660                 _orig_fastpath_glGetIntegerv(GL_BLEND_EQUATION_RGB,
2661                                              (GLint *) & (current_ctx->gl_blend_equation_rgb));
2662                 _orig_fastpath_glGetIntegerv(GL_BLEND_EQUATION_ALPHA,
2663                                              (GLint *) & (current_ctx->gl_blend_equation_alpha));
2664         }
2665         goto finish;
2666
2667 finish:
2668         _COREGL_FASTPATH_FUNC_END();
2669 }
2670
2671
2672 void
2673 fastpath_glBlendEquationSeparate(GLenum modeRGB, GLenum modeAlpha)
2674 {
2675         DEFINE_FASTPAH_GL_FUNC();
2676         _COREGL_FASTPATH_FUNC_BEGIN();
2677         INIT_FASTPATH_GL_FUNC();
2678
2679         if ((current_ctx->gl_blend_equation_rgb[0] != modeRGB) ||
2680             (current_ctx->gl_blend_equation_alpha[0] != modeAlpha)) {
2681                 IF_GL_SUCCESS(_orig_fastpath_glBlendEquationSeparate(modeRGB, modeAlpha)) {
2682                         current_ctx->_blend_flag |=
2683                                 _BLEND_FLAG_BIT_gl_blend_equation_rgb |
2684                                 _BLEND_FLAG_BIT_gl_blend_equation_alpha;
2685
2686                         current_ctx->gl_blend_equation_rgb[0]    = modeRGB;
2687                         current_ctx->gl_blend_equation_alpha[0]  = modeAlpha;
2688                 }
2689         }
2690         goto finish;
2691
2692 finish:
2693         _COREGL_FASTPATH_FUNC_END();
2694 }
2695
2696
2697 void
2698 fastpath_glBlendFunc(GLenum sfactor, GLenum dfactor)
2699 {
2700         DEFINE_FASTPAH_GL_FUNC();
2701         _COREGL_FASTPATH_FUNC_BEGIN();
2702         INIT_FASTPATH_GL_FUNC();
2703
2704         IF_GL_SUCCESS(_orig_fastpath_glBlendFunc(sfactor, dfactor)) {
2705                 current_ctx->_blend_flag |=
2706                         _BLEND_FLAG_BIT_gl_blend_src_rgb |
2707                         _BLEND_FLAG_BIT_gl_blend_src_alpha |
2708                         _BLEND_FLAG_BIT_gl_blend_dst_rgb |
2709                         _BLEND_FLAG_BIT_gl_blend_dst_alpha;
2710
2711                 _orig_fastpath_glGetIntegerv(GL_BLEND_SRC_RGB,
2712                                              (GLint *) & (current_ctx->gl_blend_src_rgb));
2713                 _orig_fastpath_glGetIntegerv(GL_BLEND_SRC_ALPHA,
2714                                              (GLint *) & (current_ctx->gl_blend_src_alpha));
2715                 _orig_fastpath_glGetIntegerv(GL_BLEND_DST_RGB,
2716                                              (GLint *) & (current_ctx->gl_blend_dst_rgb));
2717                 _orig_fastpath_glGetIntegerv(GL_BLEND_DST_ALPHA,
2718                                              (GLint *) & (current_ctx->gl_blend_dst_alpha));
2719         }
2720         goto finish;
2721
2722 finish:
2723         _COREGL_FASTPATH_FUNC_END();
2724 }
2725
2726
2727 void
2728 fastpath_glBlendFuncSeparate(GLenum srcRGB, GLenum dstRGB, GLenum srcAlpha,
2729                              GLenum dstAlpha)
2730 {
2731         DEFINE_FASTPAH_GL_FUNC();
2732         _COREGL_FASTPATH_FUNC_BEGIN();
2733         INIT_FASTPATH_GL_FUNC();
2734
2735         if ((current_ctx->gl_blend_src_rgb[0] != srcRGB) ||
2736             (current_ctx->gl_blend_dst_rgb[0] != dstRGB) ||
2737             (current_ctx->gl_blend_src_alpha[0] != srcAlpha) ||
2738             (current_ctx->gl_blend_dst_alpha[0] != dstAlpha)) {
2739                 IF_GL_SUCCESS(_orig_fastpath_glBlendFuncSeparate(srcRGB, dstRGB, srcAlpha,
2740                                 dstAlpha)) {
2741                         current_ctx->_blend_flag |=
2742                                 _BLEND_FLAG_BIT_gl_blend_src_rgb |
2743                                 _BLEND_FLAG_BIT_gl_blend_src_alpha |
2744                                 _BLEND_FLAG_BIT_gl_blend_dst_rgb |
2745                                 _BLEND_FLAG_BIT_gl_blend_dst_alpha;
2746
2747                         current_ctx->gl_blend_src_rgb[0]   = srcRGB;
2748                         current_ctx->gl_blend_dst_rgb[0]   = dstRGB;
2749                         current_ctx->gl_blend_src_alpha[0] = srcAlpha;
2750                         current_ctx->gl_blend_dst_alpha[0] = dstAlpha;
2751                 }
2752         }
2753         goto finish;
2754
2755 finish:
2756         _COREGL_FASTPATH_FUNC_END();
2757 }
2758
2759
2760 void
2761 fastpath_glClearColor(GLclampf red, GLclampf green, GLclampf blue,
2762                       GLclampf alpha)
2763 {
2764         DEFINE_FASTPAH_GL_FUNC();
2765         _COREGL_FASTPATH_FUNC_BEGIN();
2766         INIT_FASTPATH_GL_FUNC();
2767
2768         if ((current_ctx->gl_color_clear_value[0] != red) ||
2769             (current_ctx->gl_color_clear_value[1] != green) ||
2770             (current_ctx->gl_color_clear_value[2] != blue) ||
2771             (current_ctx->gl_color_clear_value[3] != alpha)) {
2772                 IF_GL_SUCCESS(_orig_fastpath_glClearColor(red, green, blue, alpha)) {
2773                         current_ctx->_clear_flag1 |= _CLEAR_FLAG1_BIT_gl_color_clear_value;
2774                         current_ctx->gl_color_clear_value[0] = red;
2775                         current_ctx->gl_color_clear_value[1] = green;
2776                         current_ctx->gl_color_clear_value[2] = blue;
2777                         current_ctx->gl_color_clear_value[3] = alpha;
2778                 }
2779         }
2780         goto finish;
2781
2782 finish:
2783         _COREGL_FASTPATH_FUNC_END();
2784 }
2785
2786
2787 void
2788 fastpath_glClearDepthf(GLclampf depth)
2789 {
2790         DEFINE_FASTPAH_GL_FUNC();
2791         _COREGL_FASTPATH_FUNC_BEGIN();
2792         INIT_FASTPATH_GL_FUNC();
2793
2794         CURR_STATE_COMPARE(gl_depth_clear_value, depth) {
2795                 IF_GL_SUCCESS(_orig_fastpath_glClearDepthf(depth)) {
2796                         current_ctx->_clear_flag2 |= _CLEAR_FLAG2_BIT_gl_depth_clear_value;
2797                         current_ctx->gl_depth_clear_value[0] = depth;
2798                 }
2799         }
2800         goto finish;
2801
2802 finish:
2803         _COREGL_FASTPATH_FUNC_END();
2804 }
2805
2806
2807 void
2808 fastpath_glClearStencil(GLint s)
2809 {
2810         DEFINE_FASTPAH_GL_FUNC();
2811         _COREGL_FASTPATH_FUNC_BEGIN();
2812         INIT_FASTPATH_GL_FUNC();
2813
2814         CURR_STATE_COMPARE(gl_stencil_clear_value, s) {
2815                 IF_GL_SUCCESS(_orig_fastpath_glClearStencil(s)) {
2816                         current_ctx->_stencil_flag2 |= _STENCIL_FLAG2_BIT_gl_stencil_clear_value;
2817                         current_ctx->gl_stencil_clear_value[0] = s;
2818                 }
2819         }
2820         goto finish;
2821
2822 finish:
2823         _COREGL_FASTPATH_FUNC_END();
2824 }
2825
2826
2827 void
2828 fastpath_glColorMask(GLboolean red, GLboolean green, GLboolean blue,
2829                      GLboolean alpha)
2830 {
2831         DEFINE_FASTPAH_GL_FUNC();
2832         _COREGL_FASTPATH_FUNC_BEGIN();
2833         INIT_FASTPATH_GL_FUNC();
2834
2835         if ((current_ctx->gl_color_writemask[0] != red) ||
2836             (current_ctx->gl_color_writemask[1] != green) ||
2837             (current_ctx->gl_color_writemask[2] != blue) ||
2838             (current_ctx->gl_color_writemask[3] != alpha)) {
2839                 IF_GL_SUCCESS(_orig_fastpath_glColorMask(red, green, blue, alpha)) {
2840                         current_ctx->_clear_flag2 |= _CLEAR_FLAG2_BIT_gl_color_writemask;
2841                         current_ctx->gl_color_writemask[0] = red;
2842                         current_ctx->gl_color_writemask[1] = green;
2843                         current_ctx->gl_color_writemask[2] = blue;
2844                         current_ctx->gl_color_writemask[3] = alpha;
2845                 }
2846         }
2847         goto finish;
2848
2849 finish:
2850         _COREGL_FASTPATH_FUNC_END();
2851 }
2852
2853
2854 void
2855 fastpath_glCullFace(GLenum mode)
2856 {
2857         DEFINE_FASTPAH_GL_FUNC();
2858         _COREGL_FASTPATH_FUNC_BEGIN();
2859         INIT_FASTPATH_GL_FUNC();
2860
2861         CURR_STATE_COMPARE(gl_cull_face_mode, mode) {
2862                 IF_GL_SUCCESS(_orig_fastpath_glCullFace(mode)) {
2863                         current_ctx->_clear_flag2 |= _CLEAR_FLAG2_BIT_gl_cull_face_mode;
2864                         current_ctx->gl_cull_face_mode[0] = mode;
2865                 }
2866         }
2867         goto finish;
2868
2869 finish:
2870         _COREGL_FASTPATH_FUNC_END();
2871 }
2872
2873
2874 void
2875 fastpath_glDepthFunc(GLenum func)
2876 {
2877         DEFINE_FASTPAH_GL_FUNC();
2878         _COREGL_FASTPATH_FUNC_BEGIN();
2879         INIT_FASTPATH_GL_FUNC();
2880
2881         CURR_STATE_COMPARE(gl_depth_func, func) {
2882                 IF_GL_SUCCESS(_orig_fastpath_glDepthFunc(func)) {
2883                         current_ctx->_clear_flag2 |= _CLEAR_FLAG2_BIT_gl_depth_func;
2884                         current_ctx->gl_depth_func[0] = func;
2885                 }
2886         }
2887         goto finish;
2888
2889 finish:
2890         _COREGL_FASTPATH_FUNC_END();
2891 }
2892
2893
2894 void
2895 fastpath_glDepthMask(GLboolean flag)
2896 {
2897         DEFINE_FASTPAH_GL_FUNC();
2898         _COREGL_FASTPATH_FUNC_BEGIN();
2899         INIT_FASTPATH_GL_FUNC();
2900
2901         CURR_STATE_COMPARE(gl_depth_writemask, flag) {
2902                 IF_GL_SUCCESS(_orig_fastpath_glDepthMask(flag)) {
2903                         current_ctx->_clear_flag2 |= _CLEAR_FLAG2_BIT_gl_depth_writemask;
2904                         current_ctx->gl_depth_writemask[0] = flag;
2905                 }
2906         }
2907         goto finish;
2908
2909 finish:
2910         _COREGL_FASTPATH_FUNC_END();
2911 }
2912
2913
2914 void
2915 fastpath_glDepthRangef(GLclampf zNear, GLclampf zFar)
2916 {
2917         DEFINE_FASTPAH_GL_FUNC();
2918         _COREGL_FASTPATH_FUNC_BEGIN();
2919         INIT_FASTPATH_GL_FUNC();
2920
2921         if ((current_ctx->gl_depth_range[0] != zNear) ||
2922             (current_ctx->gl_depth_range[1] != zFar)) {
2923                 IF_GL_SUCCESS(_orig_fastpath_glDepthRangef(zNear, zFar)) {
2924                         current_ctx->_clear_flag2 |= _CLEAR_FLAG2_BIT_gl_depth_range;
2925                         current_ctx->gl_depth_range[0] = zNear;
2926                         current_ctx->gl_depth_range[1] = zFar;
2927                 }
2928         }
2929         goto finish;
2930
2931 finish:
2932         _COREGL_FASTPATH_FUNC_END();
2933 }
2934
2935
2936 void
2937 fastpath_glDisable(GLenum cap)
2938 {
2939         DEFINE_FASTPAH_GL_FUNC();
2940         _COREGL_FASTPATH_FUNC_BEGIN();
2941         INIT_FASTPATH_GL_FUNC();
2942
2943 #define STATE_PROC(gl_state, flagid, flagbit) \
2944         CURR_STATE_COMPARE(gl_state, GL_FALSE) \
2945         { \
2946                 _orig_fastpath_glDisable(cap); \
2947                 current_ctx->flagid &= (~flagbit##_##gl_state); \
2948                 current_ctx->gl_state[0] = GL_FALSE; \
2949         }
2950
2951
2952         switch (cap) {
2953         case GL_BLEND:
2954                 STATE_PROC(gl_blend, _enable_flag1, _ENABLE_FLAG1_BIT);
2955                 break;
2956         case GL_CULL_FACE:
2957                 STATE_PROC(gl_cull_face, _enable_flag1, _ENABLE_FLAG1_BIT);
2958                 break;
2959         case GL_DEPTH_TEST:
2960                 STATE_PROC(gl_depth_test, _enable_flag1, _ENABLE_FLAG1_BIT);
2961                 break;
2962         case GL_DITHER:
2963                 STATE_PROC(gl_dither, _enable_flag1, _ENABLE_FLAG1_BIT);
2964                 break;
2965         case GL_POLYGON_OFFSET_FILL:
2966                 STATE_PROC(gl_polygon_offset_fill, _enable_flag2, _ENABLE_FLAG2_BIT);
2967                 break;
2968         case GL_PRIMITIVE_RESTART_FIXED_INDEX:
2969                 STATE_PROC_WITH_CHECK(gl_primitive_restart_fixed_index, _enable_flag3,
2970                                       _ENABLE_FLAG3_BIT);
2971                 break;
2972         case GL_RASTERIZER_DISCARD:
2973                 STATE_PROC_WITH_CHECK(gl_rasterizer_discard, _enable_flag3, _ENABLE_FLAG3_BIT);
2974                 break;
2975         case GL_SAMPLE_ALPHA_TO_COVERAGE:
2976                 STATE_PROC(gl_sample_alpha_to_coverage, _enable_flag2, _ENABLE_FLAG2_BIT);
2977                 break;
2978         case GL_SAMPLE_COVERAGE:
2979                 STATE_PROC(gl_sample_coverage, _enable_flag2, _ENABLE_FLAG2_BIT);
2980                 break;
2981         case GL_SCISSOR_TEST:
2982                 STATE_PROC(gl_scissor_test, _enable_flag2, _ENABLE_FLAG2_BIT);
2983                 break;
2984         case GL_STENCIL_TEST:
2985                 STATE_PROC(gl_stencil_test, _enable_flag2, _ENABLE_FLAG2_BIT);
2986                 break;
2987         default:
2988                 _set_gl_error(GL_INVALID_ENUM);
2989                 break;
2990         }
2991         goto finish;
2992
2993
2994 #undef STATE_PROC
2995
2996         goto finish;
2997
2998 finish:
2999         _COREGL_FASTPATH_FUNC_END();
3000 }
3001
3002
3003 void
3004 fastpath_glDisableVertexAttribArray(GLuint index)
3005 {
3006         DEFINE_FASTPAH_GL_FUNC();
3007         _COREGL_FASTPATH_FUNC_BEGIN();
3008         INIT_FASTPATH_GL_FUNC();
3009
3010         IF_GL_SUCCESS(_orig_fastpath_glDisableVertexAttribArray(index)) {
3011                 if (current_ctx->gl_vertex_array_binding[0] == 0) {
3012                         current_ctx->_vattrib_flag |= _VATTRIB_FLAG_BIT_gl_vertex_array;
3013                         current_ctx->gl_vertex_array_enabled[index] = GL_FALSE;
3014                 }
3015         }
3016
3017         goto finish;
3018
3019 finish:
3020         _COREGL_FASTPATH_FUNC_END();
3021 }
3022
3023 void
3024 fastpath_glEnable(GLenum cap)
3025 {
3026         DEFINE_FASTPAH_GL_FUNC();
3027         _COREGL_FASTPATH_FUNC_BEGIN();
3028         INIT_FASTPATH_GL_FUNC();
3029
3030 #define STATE_PROC(gl_state, flagid, flagbit) \
3031         CURR_STATE_COMPARE(gl_state, GL_TRUE) \
3032         { \
3033                 _orig_fastpath_glEnable(cap); \
3034                 current_ctx->flagid |= flagbit##_##gl_state; \
3035                 current_ctx->gl_state[0] = GL_TRUE; \
3036         }
3037
3038
3039         switch (cap) {
3040         case GL_BLEND:
3041                 STATE_PROC(gl_blend, _enable_flag1, _ENABLE_FLAG1_BIT);
3042                 break;
3043         case GL_CULL_FACE:
3044                 STATE_PROC(gl_cull_face, _enable_flag1, _ENABLE_FLAG1_BIT);
3045                 break;
3046         case GL_DEPTH_TEST:
3047                 STATE_PROC(gl_depth_test, _enable_flag1, _ENABLE_FLAG1_BIT);
3048                 break;
3049         case GL_DITHER:
3050                 STATE_PROC(gl_dither, _enable_flag1, _ENABLE_FLAG1_BIT);
3051                 break;
3052         case GL_POLYGON_OFFSET_FILL:
3053                 STATE_PROC(gl_polygon_offset_fill, _enable_flag2, _ENABLE_FLAG2_BIT);
3054                 break;
3055         case GL_PRIMITIVE_RESTART_FIXED_INDEX:
3056                 STATE_PROC_WITH_CHECK(gl_primitive_restart_fixed_index, _enable_flag3,
3057                                       _ENABLE_FLAG3_BIT);
3058                 break;
3059         case GL_RASTERIZER_DISCARD:
3060                 STATE_PROC_WITH_CHECK(gl_rasterizer_discard, _enable_flag3, _ENABLE_FLAG3_BIT);
3061                 break;
3062         case GL_SAMPLE_ALPHA_TO_COVERAGE:
3063                 STATE_PROC(gl_sample_alpha_to_coverage, _enable_flag2, _ENABLE_FLAG2_BIT);
3064                 break;
3065         case GL_SAMPLE_COVERAGE:
3066                 STATE_PROC(gl_sample_coverage, _enable_flag2, _ENABLE_FLAG2_BIT);
3067                 break;
3068         case GL_SCISSOR_TEST:
3069                 STATE_PROC(gl_scissor_test, _enable_flag2, _ENABLE_FLAG2_BIT);
3070                 break;
3071         case GL_STENCIL_TEST:
3072                 STATE_PROC(gl_stencil_test, _enable_flag2, _ENABLE_FLAG2_BIT);
3073                 break;
3074         default:
3075                 _set_gl_error(GL_INVALID_ENUM);
3076                 break;
3077         }
3078         goto finish;
3079
3080
3081 #undef STATE_PROC
3082
3083 finish:
3084         _COREGL_FASTPATH_FUNC_END();
3085 }
3086
3087
3088 void
3089 fastpath_glEnableVertexAttribArray(GLuint index)
3090 {
3091         DEFINE_FASTPAH_GL_FUNC();
3092         _COREGL_FASTPATH_FUNC_BEGIN();
3093         INIT_FASTPATH_GL_FUNC();
3094
3095         IF_GL_SUCCESS(_orig_fastpath_glEnableVertexAttribArray(index)) {
3096                 if (current_ctx->gl_vertex_array_binding[0] == 0) {
3097                         current_ctx->_vattrib_flag |= _VATTRIB_FLAG_BIT_gl_vertex_array;
3098                         current_ctx->gl_vertex_array_enabled[index] = GL_TRUE;
3099                 }
3100         }
3101
3102         goto finish;
3103
3104 finish:
3105         _COREGL_FASTPATH_FUNC_END();
3106 }
3107
3108
3109 void
3110 fastpath_glFrontFace(GLenum mode)
3111 {
3112         DEFINE_FASTPAH_GL_FUNC();
3113         _COREGL_FASTPATH_FUNC_BEGIN();
3114         INIT_FASTPATH_GL_FUNC();
3115
3116         CURR_STATE_COMPARE(gl_front_face, mode) {
3117                 IF_GL_SUCCESS(_orig_fastpath_glFrontFace(mode)) {
3118                         current_ctx->_misc_flag1 |= _MISC_FLAG1_BIT_gl_front_face;
3119                         current_ctx->gl_front_face[0] = mode;
3120                 }
3121         }
3122         goto finish;
3123
3124 finish:
3125         _COREGL_FASTPATH_FUNC_END();
3126 }
3127
3128 void
3129 fastpath_glHint(GLenum target, GLenum mode)
3130 {
3131         DEFINE_FASTPAH_GL_FUNC();
3132         _COREGL_FASTPATH_FUNC_BEGIN();
3133         INIT_FASTPATH_GL_FUNC();
3134
3135
3136 #define STATE_PROC(gl_state, flagid, flagbit) \
3137         CURR_STATE_COMPARE(gl_state, mode) \
3138         { \
3139                 IF_GL_SUCCESS(_orig_fastpath_glHint(target, mode)) \
3140                 { \
3141                         current_ctx->flagid |= flagbit##_##gl_state; \
3142                         current_ctx->gl_state[0] = mode; \
3143                 } \
3144         }
3145
3146
3147         switch (target) {
3148         case GL_FRAGMENT_SHADER_DERIVATIVE_HINT:
3149                 STATE_PROC_WITH_CHECK(gl_fragment_shader_derivative_hint, _misc_flag1,
3150                                       _MISC_FLAG1_BIT);
3151                 break;
3152         case GL_GENERATE_MIPMAP_HINT:
3153                 STATE_PROC(gl_generate_mipmap_hint, _tex_flag1, _TEX_FLAG1_BIT);
3154                 break;
3155         default:
3156                 _set_gl_error(GL_INVALID_ENUM);
3157                 break;
3158         }
3159         goto finish;
3160
3161
3162 #undef STATE_PROC
3163
3164 finish:
3165         _COREGL_FASTPATH_FUNC_END();
3166 }
3167
3168
3169 void
3170 fastpath_glLineWidth(GLfloat width)
3171 {
3172         DEFINE_FASTPAH_GL_FUNC();
3173         _COREGL_FASTPATH_FUNC_BEGIN();
3174         INIT_FASTPATH_GL_FUNC();
3175
3176         CURR_STATE_COMPARE(gl_line_width, width) {
3177                 IF_GL_SUCCESS(_orig_fastpath_glLineWidth(width)) {
3178                         current_ctx->_misc_flag1 |= _MISC_FLAG1_BIT_gl_line_width;
3179                         current_ctx->gl_line_width[0] = width;
3180                 }
3181         }
3182         goto finish;
3183
3184 finish:
3185         _COREGL_FASTPATH_FUNC_END();
3186 }
3187
3188
3189 void
3190 fastpath_glPixelStorei(GLenum pname, GLint param)
3191 {
3192         DEFINE_FASTPAH_GL_FUNC();
3193         _COREGL_FASTPATH_FUNC_BEGIN();
3194         INIT_FASTPATH_GL_FUNC();
3195
3196 #define STATE_PROC(gl_state, flagid, flagbit) \
3197         CURR_STATE_COMPARE(gl_state, param) \
3198         { \
3199                 IF_GL_SUCCESS(_orig_fastpath_glPixelStorei(pname, param)) \
3200                 { \
3201                         current_ctx->flagid |= flagbit##_##gl_state; \
3202                         current_ctx->gl_state[0] = param; \
3203                 } \
3204         }
3205
3206
3207         switch (pname) {
3208         case GL_PACK_ROW_LENGTH:
3209                 STATE_PROC_WITH_CHECK(gl_pack_row_length, _pixel_flag1, _PIXEL_FLAG1_BIT);
3210                 break;
3211         case GL_PACK_SKIP_PIXELS:
3212                 STATE_PROC_WITH_CHECK(gl_pack_skip_pixels, _pixel_flag1, _PIXEL_FLAG1_BIT);
3213                 break;
3214         case GL_PACK_SKIP_ROWS:
3215                 STATE_PROC_WITH_CHECK(gl_pack_skip_rows, _pixel_flag1, _PIXEL_FLAG1_BIT);
3216                 break;
3217         case GL_PACK_ALIGNMENT:
3218                 STATE_PROC(gl_pack_alignment, _pixel_flag1, _PIXEL_FLAG1_BIT);
3219                 break;
3220         case GL_UNPACK_ROW_LENGTH:
3221                 STATE_PROC_WITH_CHECK(gl_unpack_row_length, _pixel_flag2, _PIXEL_FLAG2_BIT);
3222                 break;
3223         case GL_UNPACK_IMAGE_HEIGHT:
3224                 STATE_PROC_WITH_CHECK(gl_unpack_image_height, _pixel_flag2, _PIXEL_FLAG2_BIT);
3225                 break;
3226         case GL_UNPACK_SKIP_PIXELS:
3227                 STATE_PROC_WITH_CHECK(gl_unpack_skip_pixels, _pixel_flag2, _PIXEL_FLAG2_BIT);
3228                 break;
3229         case GL_UNPACK_SKIP_IMAGES:
3230                 STATE_PROC_WITH_CHECK(gl_unpack_skip_images, _pixel_flag2, _PIXEL_FLAG2_BIT);
3231                 break;
3232         case GL_UNPACK_ALIGNMENT:
3233                 STATE_PROC(gl_unpack_alignment, _pixel_flag2, _PIXEL_FLAG2_BIT);
3234                 break;
3235         default:
3236                 _set_gl_error(GL_INVALID_ENUM);
3237                 break;
3238         }
3239
3240
3241 #undef STATE_PROC
3242
3243         goto finish;
3244
3245 finish:
3246         _COREGL_FASTPATH_FUNC_END();
3247 }
3248
3249
3250 void
3251 fastpath_glPolygonOffset(GLfloat factor, GLfloat units)
3252 {
3253         DEFINE_FASTPAH_GL_FUNC();
3254         _COREGL_FASTPATH_FUNC_BEGIN();
3255         INIT_FASTPATH_GL_FUNC();
3256
3257         if ((current_ctx->gl_polygon_offset_factor[0] != factor) ||
3258             (current_ctx->gl_polygon_offset_units[0] != units)) {
3259                 IF_GL_SUCCESS(_orig_fastpath_glPolygonOffset(factor, units)) {
3260                         current_ctx->_misc_flag1 |=
3261                                 _MISC_FLAG1_BIT_gl_polygon_offset_factor |
3262                                 _MISC_FLAG1_BIT_gl_polygon_offset_units;
3263
3264                         current_ctx->gl_polygon_offset_factor[0] = factor;
3265                         current_ctx->gl_polygon_offset_units[0]  = units;
3266                 }
3267         }
3268         goto finish;
3269
3270 finish:
3271         _COREGL_FASTPATH_FUNC_END();
3272 }
3273
3274
3275 void
3276 fastpath_glSampleCoverage(GLclampf value, GLboolean invert)
3277 {
3278         DEFINE_FASTPAH_GL_FUNC();
3279         _COREGL_FASTPATH_FUNC_BEGIN();
3280         INIT_FASTPATH_GL_FUNC();
3281
3282         if ((current_ctx->gl_sample_coverage_value[0] != value) ||
3283             (current_ctx->gl_sample_coverage_invert[0] != invert)) {
3284                 IF_GL_SUCCESS(_orig_fastpath_glSampleCoverage(value, invert)) {
3285                         current_ctx->_misc_flag1 |=
3286                                 _MISC_FLAG1_BIT_gl_sample_coverage_value |
3287                                 _MISC_FLAG1_BIT_gl_sample_coverage_invert;
3288
3289                         current_ctx->gl_sample_coverage_value[0]  = value;
3290                         current_ctx->gl_sample_coverage_invert[0] = invert;
3291                 }
3292         }
3293         goto finish;
3294
3295 finish:
3296         _COREGL_FASTPATH_FUNC_END();
3297 }
3298
3299
3300 void
3301 fastpath_glScissor(GLint x, GLint y, GLsizei width, GLsizei height)
3302 {
3303         DEFINE_FASTPAH_GL_FUNC();
3304         _COREGL_FASTPATH_FUNC_BEGIN();
3305         INIT_FASTPATH_GL_FUNC();
3306
3307         if ((current_ctx->gl_scissor_box[0] != x) ||
3308             (current_ctx->gl_scissor_box[1] != y) ||
3309             (current_ctx->gl_scissor_box[2] != width) ||
3310             (current_ctx->gl_scissor_box[3] != height)) {
3311                 IF_GL_SUCCESS(_orig_fastpath_glScissor(x, y, width, height)) {
3312                         current_ctx->_misc_flag2 |= _MISC_FLAG2_BIT_gl_scissor_box;
3313                         current_ctx->gl_scissor_box[0] = x;
3314                         current_ctx->gl_scissor_box[1] = y;
3315                         current_ctx->gl_scissor_box[2] = width;
3316                         current_ctx->gl_scissor_box[3] = height;
3317                 }
3318         }
3319         goto finish;
3320
3321 finish:
3322         _COREGL_FASTPATH_FUNC_END();
3323 }
3324
3325
3326 void
3327 fastpath_glStencilFunc(GLenum func, GLint ref, GLuint mask)
3328 {
3329         DEFINE_FASTPAH_GL_FUNC();
3330         _COREGL_FASTPATH_FUNC_BEGIN();
3331         INIT_FASTPATH_GL_FUNC();
3332
3333         if ((current_ctx->gl_stencil_func[0] != func) ||
3334             (current_ctx->gl_stencil_ref[0] != ref) ||
3335             (current_ctx->gl_stencil_value_mask[0] != mask) ||
3336             (current_ctx->gl_stencil_back_func[0] != func) ||
3337             (current_ctx->gl_stencil_back_ref[0] != ref) ||
3338             (current_ctx->gl_stencil_back_value_mask[0] != mask)) {
3339                 IF_GL_SUCCESS(_orig_fastpath_glStencilFunc(func, ref, mask)) {
3340                         current_ctx->_stencil_flag1 |=
3341                                 _STENCIL_FLAG1_BIT_gl_stencil_func |
3342                                 _STENCIL_FLAG1_BIT_gl_stencil_ref |
3343                                 _STENCIL_FLAG1_BIT_gl_stencil_value_mask;
3344
3345                         current_ctx->gl_stencil_func[0]             = func;
3346                         current_ctx->gl_stencil_ref[0]              = ref;
3347                         current_ctx->gl_stencil_value_mask[0]       = mask;
3348
3349                         current_ctx->_stencil_flag2 |=
3350                                 _STENCIL_FLAG2_BIT_gl_stencil_back_func |
3351                                 _STENCIL_FLAG2_BIT_gl_stencil_back_ref |
3352                                 _STENCIL_FLAG2_BIT_gl_stencil_back_value_mask;
3353
3354                         current_ctx->gl_stencil_back_func[0]        = func;
3355                         current_ctx->gl_stencil_back_ref[0]         = ref;
3356                         current_ctx->gl_stencil_back_value_mask[0]  = mask;
3357                 }
3358         }
3359         goto finish;
3360
3361 finish:
3362         _COREGL_FASTPATH_FUNC_END();
3363 }
3364
3365
3366 void
3367 fastpath_glStencilFuncSeparate(GLenum face, GLenum func, GLint ref, GLuint mask)
3368 {
3369         DEFINE_FASTPAH_GL_FUNC();
3370         _COREGL_FASTPATH_FUNC_BEGIN();
3371         INIT_FASTPATH_GL_FUNC();
3372
3373         if ((face == GL_FRONT) || (face == GL_FRONT_AND_BACK)) {
3374                 if ((current_ctx->gl_stencil_func[0] != func) ||
3375                     (current_ctx->gl_stencil_ref[0] != ref) ||
3376                     (current_ctx->gl_stencil_value_mask[0] != mask)) {
3377                         IF_GL_SUCCESS(_orig_fastpath_glStencilFuncSeparate(face, func, ref, mask)) {
3378                                 current_ctx->_stencil_flag1 |=
3379                                         _STENCIL_FLAG1_BIT_gl_stencil_func |
3380                                         _STENCIL_FLAG1_BIT_gl_stencil_ref |
3381                                         _STENCIL_FLAG1_BIT_gl_stencil_value_mask;
3382
3383                                 current_ctx->gl_stencil_func[0]             = func;
3384                                 current_ctx->gl_stencil_ref[0]              = ref;
3385                                 current_ctx->gl_stencil_value_mask[0]       = mask;
3386                         }
3387                 }
3388         } else if ((face == GL_BACK) || (face == GL_FRONT_AND_BACK)) {
3389                 if ((current_ctx->gl_stencil_back_func[0] != func) ||
3390                     (current_ctx->gl_stencil_back_ref[0] != ref) ||
3391                     (current_ctx->gl_stencil_back_value_mask[0] != mask)) {
3392                         IF_GL_SUCCESS(_orig_fastpath_glStencilFuncSeparate(face, func, ref, mask)) {
3393                                 current_ctx->_stencil_flag2 |=
3394                                         _STENCIL_FLAG2_BIT_gl_stencil_back_func |
3395                                         _STENCIL_FLAG2_BIT_gl_stencil_back_ref |
3396                                         _STENCIL_FLAG2_BIT_gl_stencil_back_value_mask;
3397
3398                                 current_ctx->gl_stencil_back_func[0]        = func;
3399                                 current_ctx->gl_stencil_back_ref[0]         = ref;
3400                                 current_ctx->gl_stencil_back_value_mask[0]  = mask;
3401                         }
3402                 }
3403         } else {
3404                 _set_gl_error(GL_INVALID_ENUM);
3405                 goto finish;
3406         }
3407         goto finish;
3408
3409 finish:
3410         _COREGL_FASTPATH_FUNC_END();
3411 }
3412
3413
3414 void
3415 fastpath_glStencilMask(GLuint mask)
3416 {
3417         DEFINE_FASTPAH_GL_FUNC();
3418         _COREGL_FASTPATH_FUNC_BEGIN();
3419         INIT_FASTPATH_GL_FUNC();
3420
3421         if ((current_ctx->gl_stencil_writemask[0] != mask) ||
3422             (current_ctx->gl_stencil_back_writemask[0] != mask)) {
3423                 IF_GL_SUCCESS(_orig_fastpath_glStencilMask(mask)) {
3424                         current_ctx->_stencil_flag1 |= _STENCIL_FLAG1_BIT_gl_stencil_writemask;
3425                         current_ctx->_stencil_flag2 |= _STENCIL_FLAG2_BIT_gl_stencil_back_writemask;
3426
3427                         current_ctx->gl_stencil_writemask[0]        = mask;
3428                         current_ctx->gl_stencil_back_writemask[0]   = mask;
3429                 }
3430         }
3431         goto finish;
3432
3433 finish:
3434         _COREGL_FASTPATH_FUNC_END();
3435 }
3436
3437
3438 void
3439 fastpath_glStencilMaskSeparate(GLenum face, GLuint mask)
3440 {
3441         DEFINE_FASTPAH_GL_FUNC();
3442         _COREGL_FASTPATH_FUNC_BEGIN();
3443         INIT_FASTPATH_GL_FUNC();
3444
3445         if ((face == GL_FRONT) || (face == GL_FRONT_AND_BACK)) {
3446                 if (current_ctx->gl_stencil_writemask[0] != mask) {
3447                         IF_GL_SUCCESS(_orig_fastpath_glStencilMaskSeparate(face, mask)) {
3448                                 current_ctx->_stencil_flag1 |= _STENCIL_FLAG1_BIT_gl_stencil_writemask;
3449                                 current_ctx->gl_stencil_writemask[0] = mask;
3450                         }
3451                 }
3452         } else if ((face == GL_BACK) || (face == GL_FRONT_AND_BACK)) {
3453                 if (current_ctx->gl_stencil_back_writemask[0] != mask) {
3454                         IF_GL_SUCCESS(_orig_fastpath_glStencilMaskSeparate(face, mask)) {
3455                                 current_ctx->_stencil_flag2 |= _STENCIL_FLAG2_BIT_gl_stencil_back_writemask;
3456                                 current_ctx->gl_stencil_back_writemask[0]   = mask;
3457                         }
3458                 }
3459         } else {
3460                 _set_gl_error(GL_INVALID_ENUM);
3461                 goto finish;
3462         }
3463         goto finish;
3464
3465 finish:
3466         _COREGL_FASTPATH_FUNC_END();
3467 }
3468
3469
3470 void
3471 fastpath_glStencilOp(GLenum fail, GLenum zfail, GLenum zpass)
3472 {
3473         DEFINE_FASTPAH_GL_FUNC();
3474         _COREGL_FASTPATH_FUNC_BEGIN();
3475         INIT_FASTPATH_GL_FUNC();
3476
3477         if ((current_ctx->gl_stencil_fail[0] != fail) ||
3478             (current_ctx->gl_stencil_pass_depth_fail[0] != zfail) ||
3479             (current_ctx->gl_stencil_pass_depth_pass[0] != zpass) ||
3480             (current_ctx->gl_stencil_back_fail[0] != fail) ||
3481             (current_ctx->gl_stencil_back_pass_depth_fail[0] != zfail) ||
3482             (current_ctx->gl_stencil_back_pass_depth_pass[0] != zpass)) {
3483                 IF_GL_SUCCESS(_orig_fastpath_glStencilOp(fail, zfail, zpass)) {
3484                         current_ctx->_stencil_flag1 |=
3485                                 _STENCIL_FLAG1_BIT_gl_stencil_fail |
3486                                 _STENCIL_FLAG1_BIT_gl_stencil_pass_depth_fail |
3487                                 _STENCIL_FLAG1_BIT_gl_stencil_pass_depth_pass;
3488
3489                         current_ctx->gl_stencil_fail[0]              = fail;
3490                         current_ctx->gl_stencil_pass_depth_fail[0]   = zfail;
3491                         current_ctx->gl_stencil_pass_depth_pass[0]   = zpass;
3492
3493                         current_ctx->_stencil_flag2 |=
3494                                 _STENCIL_FLAG2_BIT_gl_stencil_back_fail |
3495                                 _STENCIL_FLAG2_BIT_gl_stencil_back_pass_depth_fail |
3496                                 _STENCIL_FLAG2_BIT_gl_stencil_back_pass_depth_pass;
3497
3498                         current_ctx->gl_stencil_back_fail[0]         = fail;
3499                         current_ctx->gl_stencil_back_pass_depth_fail[0]   = zfail;
3500                         current_ctx->gl_stencil_back_pass_depth_pass[0]   = zpass;
3501                 }
3502         }
3503         goto finish;
3504
3505 finish:
3506         _COREGL_FASTPATH_FUNC_END();
3507 }
3508
3509
3510 void
3511 fastpath_glStencilOpSeparate(GLenum face, GLenum fail, GLenum zfail,
3512                              GLenum zpass)
3513 {
3514         DEFINE_FASTPAH_GL_FUNC();
3515         _COREGL_FASTPATH_FUNC_BEGIN();
3516         INIT_FASTPATH_GL_FUNC();
3517
3518         if ((face == GL_FRONT) || (face == GL_FRONT_AND_BACK)) {
3519                 if ((current_ctx->gl_stencil_fail[0] != fail) ||
3520                     (current_ctx->gl_stencil_pass_depth_fail[0] != zfail) ||
3521                     (current_ctx->gl_stencil_pass_depth_pass[0] != zpass)) {
3522                         IF_GL_SUCCESS(_orig_fastpath_glStencilOpSeparate(face, fail, zfail, zpass)) {
3523                                 current_ctx->_stencil_flag1 |=
3524                                         _STENCIL_FLAG1_BIT_gl_stencil_fail |
3525                                         _STENCIL_FLAG1_BIT_gl_stencil_pass_depth_fail |
3526                                         _STENCIL_FLAG1_BIT_gl_stencil_pass_depth_pass;
3527
3528                                 current_ctx->gl_stencil_fail[0]              = fail;
3529                                 current_ctx->gl_stencil_pass_depth_fail[0]   = zfail;
3530                                 current_ctx->gl_stencil_pass_depth_pass[0]   = zpass;
3531                         }
3532                 }
3533         } else if ((face == GL_BACK) || (face == GL_FRONT_AND_BACK)) {
3534                 if ((current_ctx->gl_stencil_back_fail[0] != fail) ||
3535                     (current_ctx->gl_stencil_back_pass_depth_fail[0] != zfail) ||
3536                     (current_ctx->gl_stencil_back_pass_depth_pass[0] != zpass)) {
3537                         IF_GL_SUCCESS(_orig_fastpath_glStencilOpSeparate(face, fail, zfail, zpass)) {
3538                                 current_ctx->_stencil_flag2 |=
3539                                         _STENCIL_FLAG2_BIT_gl_stencil_back_fail |
3540                                         _STENCIL_FLAG2_BIT_gl_stencil_back_pass_depth_fail |
3541                                         _STENCIL_FLAG2_BIT_gl_stencil_back_pass_depth_pass;
3542
3543                                 current_ctx->gl_stencil_back_fail[0]              = fail;
3544                                 current_ctx->gl_stencil_back_pass_depth_fail[0]   = zfail;
3545                                 current_ctx->gl_stencil_back_pass_depth_pass[0]   = zpass;
3546                         }
3547                 }
3548         } else {
3549                 _set_gl_error(GL_INVALID_ENUM);
3550                 goto finish;
3551         }
3552         goto finish;
3553
3554 finish:
3555         _COREGL_FASTPATH_FUNC_END();
3556 }
3557
3558
3559 void
3560 fastpath_glVertexAttrib1f(GLuint index, GLfloat x)
3561 {
3562         DEFINE_FASTPAH_GL_FUNC();
3563         _COREGL_FASTPATH_FUNC_BEGIN();
3564         INIT_FASTPATH_GL_FUNC();
3565
3566         IF_GL_SUCCESS(_orig_fastpath_glVertexAttrib1f(index, x)) {
3567                 if (current_ctx->gl_vertex_array_binding[0] == 0) {
3568                         current_ctx->_vattrib_flag |= _VATTRIB_FLAG_BIT_gl_vertex_attrib_value;
3569                         current_ctx->gl_vertex_array_size[index] = 0;
3570                         current_ctx->gl_vertex_array_integer[index] = GL_FALSE;
3571
3572                         current_ctx->gl_vertex_attrib_value[index * 4 + 0] = x;
3573                         current_ctx->gl_vertex_attrib_value[index * 4 + 1] = 0;
3574                         current_ctx->gl_vertex_attrib_value[index * 4 + 2] = 0;
3575                         current_ctx->gl_vertex_attrib_value[index * 4 + 3] = 1;
3576                 }
3577         }
3578         goto finish;
3579
3580 finish:
3581         _COREGL_FASTPATH_FUNC_END();
3582 }
3583
3584
3585 void
3586 fastpath_glVertexAttrib1fv(GLuint index, const GLfloat *values)
3587 {
3588         DEFINE_FASTPAH_GL_FUNC();
3589         _COREGL_FASTPATH_FUNC_BEGIN();
3590         INIT_FASTPATH_GL_FUNC();
3591
3592         IF_GL_SUCCESS(_orig_fastpath_glVertexAttrib1fv(index, values)) {
3593                 if (current_ctx->gl_vertex_array_binding[0] == 0) {
3594                         current_ctx->_vattrib_flag |= _VATTRIB_FLAG_BIT_gl_vertex_attrib_value;
3595                         current_ctx->gl_vertex_array_size[index] = 0;
3596                         current_ctx->gl_vertex_array_integer[index] = GL_FALSE;
3597
3598                         current_ctx->gl_vertex_attrib_value[index * 4 + 0] = values[0];
3599                         current_ctx->gl_vertex_attrib_value[index * 4 + 1] = 0;
3600                         current_ctx->gl_vertex_attrib_value[index * 4 + 2] = 0;
3601                         current_ctx->gl_vertex_attrib_value[index * 4 + 3] = 1;
3602                 }
3603         }
3604         goto finish;
3605
3606 finish:
3607         _COREGL_FASTPATH_FUNC_END();
3608 }
3609
3610
3611 void
3612 fastpath_glVertexAttrib2f(GLuint index, GLfloat x, GLfloat y)
3613 {
3614         DEFINE_FASTPAH_GL_FUNC();
3615         _COREGL_FASTPATH_FUNC_BEGIN();
3616         INIT_FASTPATH_GL_FUNC();
3617
3618         IF_GL_SUCCESS(_orig_fastpath_glVertexAttrib2f(index, x, y)) {
3619                 if (current_ctx->gl_vertex_array_binding[0] == 0) {
3620                         current_ctx->_vattrib_flag |= _VATTRIB_FLAG_BIT_gl_vertex_attrib_value;
3621                         current_ctx->gl_vertex_array_size[index] = 0;
3622                         current_ctx->gl_vertex_array_integer[index] = GL_FALSE;
3623
3624                         current_ctx->gl_vertex_attrib_value[index * 4 + 0] = x;
3625                         current_ctx->gl_vertex_attrib_value[index * 4 + 1] = y;
3626                         current_ctx->gl_vertex_attrib_value[index * 4 + 2] = 0;
3627                         current_ctx->gl_vertex_attrib_value[index * 4 + 3] = 1;
3628                 }
3629         }
3630         goto finish;
3631
3632 finish:
3633         _COREGL_FASTPATH_FUNC_END();
3634 }
3635
3636
3637 void
3638 fastpath_glVertexAttrib2fv(GLuint index, const GLfloat *values)
3639 {
3640         DEFINE_FASTPAH_GL_FUNC();
3641         _COREGL_FASTPATH_FUNC_BEGIN();
3642         INIT_FASTPATH_GL_FUNC();
3643
3644         IF_GL_SUCCESS(_orig_fastpath_glVertexAttrib2fv(index, values)) {
3645                 if (current_ctx->gl_vertex_array_binding[0] == 0) {
3646                         current_ctx->_vattrib_flag |= _VATTRIB_FLAG_BIT_gl_vertex_attrib_value;
3647                         current_ctx->gl_vertex_array_size[index] = 0;
3648                         current_ctx->gl_vertex_array_integer[index] = GL_FALSE;
3649
3650                         current_ctx->gl_vertex_attrib_value[index * 4 + 0] = values[0];
3651                         current_ctx->gl_vertex_attrib_value[index * 4 + 1] = values[1];
3652                         current_ctx->gl_vertex_attrib_value[index * 4 + 2] = 0;
3653                         current_ctx->gl_vertex_attrib_value[index * 4 + 3] = 1;
3654                 }
3655         }
3656         goto finish;
3657
3658 finish:
3659         _COREGL_FASTPATH_FUNC_END();
3660 }
3661
3662
3663 void
3664 fastpath_glVertexAttrib3f(GLuint index, GLfloat x, GLfloat y, GLfloat z)
3665 {
3666         DEFINE_FASTPAH_GL_FUNC();
3667         _COREGL_FASTPATH_FUNC_BEGIN();
3668         INIT_FASTPATH_GL_FUNC();
3669
3670         IF_GL_SUCCESS(_orig_fastpath_glVertexAttrib3f(index, x, y, z)) {
3671                 if (current_ctx->gl_vertex_array_binding[0] == 0) {
3672                         current_ctx->_vattrib_flag |= _VATTRIB_FLAG_BIT_gl_vertex_attrib_value;
3673                         current_ctx->gl_vertex_array_size[index] = 0;
3674                         current_ctx->gl_vertex_array_integer[index] = GL_FALSE;
3675
3676                         current_ctx->gl_vertex_attrib_value[index * 4 + 0] = x;
3677                         current_ctx->gl_vertex_attrib_value[index * 4 + 1] = y;
3678                         current_ctx->gl_vertex_attrib_value[index * 4 + 2] = z;
3679                         current_ctx->gl_vertex_attrib_value[index * 4 + 3] = 1;
3680                 }
3681         }
3682         goto finish;
3683
3684 finish:
3685         _COREGL_FASTPATH_FUNC_END();
3686 }
3687
3688
3689 void
3690 fastpath_glVertexAttrib3fv(GLuint index, const GLfloat *values)
3691 {
3692         DEFINE_FASTPAH_GL_FUNC();
3693         _COREGL_FASTPATH_FUNC_BEGIN();
3694         INIT_FASTPATH_GL_FUNC();
3695
3696         IF_GL_SUCCESS(_orig_fastpath_glVertexAttrib3fv(index, values)) {
3697                 if (current_ctx->gl_vertex_array_binding[0] == 0) {
3698                         current_ctx->_vattrib_flag |= _VATTRIB_FLAG_BIT_gl_vertex_attrib_value;
3699                         current_ctx->gl_vertex_array_size[index] = 0;
3700                         current_ctx->gl_vertex_array_integer[index] = GL_FALSE;
3701
3702                         current_ctx->gl_vertex_attrib_value[index * 4 + 0] = values[0];
3703                         current_ctx->gl_vertex_attrib_value[index * 4 + 1] = values[1];
3704                         current_ctx->gl_vertex_attrib_value[index * 4 + 2] = values[2];
3705                         current_ctx->gl_vertex_attrib_value[index * 4 + 3] = 1;
3706                 }
3707         }
3708         goto finish;
3709
3710 finish:
3711         _COREGL_FASTPATH_FUNC_END();
3712 }
3713
3714
3715 void
3716 fastpath_glVertexAttrib4f(GLuint index, GLfloat x, GLfloat y, GLfloat z,
3717                           GLfloat w)
3718 {
3719         DEFINE_FASTPAH_GL_FUNC();
3720         _COREGL_FASTPATH_FUNC_BEGIN();
3721         INIT_FASTPATH_GL_FUNC();
3722
3723         IF_GL_SUCCESS(_orig_fastpath_glVertexAttrib4f(index, x, y, z, w)) {
3724                 if (current_ctx->gl_vertex_array_binding[0] == 0) {
3725                         current_ctx->_vattrib_flag |= _VATTRIB_FLAG_BIT_gl_vertex_attrib_value;
3726                         current_ctx->gl_vertex_array_size[index] = 0;
3727                         current_ctx->gl_vertex_array_integer[index] = GL_FALSE;
3728
3729                         current_ctx->gl_vertex_attrib_value[index * 4 + 0] = x;
3730                         current_ctx->gl_vertex_attrib_value[index * 4 + 1] = y;
3731                         current_ctx->gl_vertex_attrib_value[index * 4 + 2] = z;
3732                         current_ctx->gl_vertex_attrib_value[index * 4 + 3] = w;
3733                 }
3734         }
3735         goto finish;
3736
3737 finish:
3738         _COREGL_FASTPATH_FUNC_END();
3739 }
3740
3741
3742 void
3743 fastpath_glVertexAttrib4fv(GLuint index, const GLfloat *values)
3744 {
3745         DEFINE_FASTPAH_GL_FUNC();
3746         _COREGL_FASTPATH_FUNC_BEGIN();
3747         INIT_FASTPATH_GL_FUNC();
3748
3749         IF_GL_SUCCESS(_orig_fastpath_glVertexAttrib4fv(index, values)) {
3750                 if (current_ctx->gl_vertex_array_binding[0] == 0) {
3751                         current_ctx->_vattrib_flag |= _VATTRIB_FLAG_BIT_gl_vertex_attrib_value;
3752                         current_ctx->gl_vertex_array_size[index] = 0;
3753                         current_ctx->gl_vertex_array_integer[index] = GL_FALSE;
3754
3755                         current_ctx->gl_vertex_attrib_value[index * 4 + 0] = values[0];
3756                         current_ctx->gl_vertex_attrib_value[index * 4 + 1] = values[1];
3757                         current_ctx->gl_vertex_attrib_value[index * 4 + 2] = values[2];
3758                         current_ctx->gl_vertex_attrib_value[index * 4 + 3] = values[3];
3759                 }
3760         }
3761         goto finish;
3762
3763 finish:
3764         _COREGL_FASTPATH_FUNC_END();
3765 }
3766
3767
3768 void
3769 fastpath_glVertexAttribPointer(GLuint index, GLint size, GLenum type,
3770                                GLboolean normalized, GLsizei stride, const void *pointer)
3771 {
3772         DEFINE_FASTPAH_GL_FUNC();
3773         _COREGL_FASTPATH_FUNC_BEGIN();
3774         INIT_FASTPATH_GL_FUNC();
3775
3776         IF_GL_SUCCESS(_orig_fastpath_glVertexAttribPointer(index, size, type,
3777                         normalized, stride, pointer)) {
3778                 if (current_ctx->gl_vertex_array_binding[0] == 0) {
3779                         current_ctx->_vattrib_flag |= _VATTRIB_FLAG_BIT_gl_vertex_array;
3780
3781                         current_ctx->gl_vertex_array_buf_id[index]       =
3782                                 current_ctx->gl_array_buffer_binding[0];
3783                         current_ctx->gl_vertex_array_size[index]         = size;
3784                         current_ctx->gl_vertex_array_type[index]         = type;
3785                         current_ctx->gl_vertex_array_normalized[index]   = normalized;
3786                         current_ctx->gl_vertex_array_integer[index]      = GL_FALSE;
3787                         current_ctx->gl_vertex_array_stride[index]       = stride;
3788                         current_ctx->gl_vertex_array_pointer[index]      = (GLvoid *)pointer;
3789                 }
3790         }
3791         goto finish;
3792
3793 finish:
3794         _COREGL_FASTPATH_FUNC_END();
3795 }
3796
3797
3798 void
3799 fastpath_glViewport(GLint x, GLint y, GLsizei width, GLsizei height)
3800 {
3801         DEFINE_FASTPAH_GL_FUNC();
3802         _COREGL_FASTPATH_FUNC_BEGIN();
3803         INIT_FASTPATH_GL_FUNC();
3804
3805         if ((current_ctx->gl_viewport[0] != x) ||
3806             (current_ctx->gl_viewport[1] != y) ||
3807             (current_ctx->gl_viewport[2] != width) ||
3808             (current_ctx->gl_viewport[3] != height)) {
3809                 IF_GL_SUCCESS(_orig_fastpath_glViewport(x, y, width, height)) {
3810                         current_ctx->_clear_flag1 |= _CLEAR_FLAG1_BIT_gl_viewport;
3811                         current_ctx->gl_viewport[0] = x;
3812                         current_ctx->gl_viewport[1] = y;
3813                         current_ctx->gl_viewport[2] = width;
3814                         current_ctx->gl_viewport[3] = height;
3815                 }
3816         }
3817
3818         goto finish;
3819
3820 finish:
3821         _COREGL_FASTPATH_FUNC_END();
3822 }
3823
3824 #define TRANS_VALUE(index, value) \
3825 { \
3826         switch (get_type) \
3827         { \
3828                 case GL_INT: if (!is64) ((GLint *)ptr)[index] = value; else ((GLint64 *)ptr)[index] = value; break; \
3829                 case GL_FLOAT: ((GLfloat *)ptr)[index] = (GLfloat)value; break; \
3830                 case GL_BOOL: ((GLboolean *)ptr)[index] = (value == 0) ? GL_FALSE : GL_TRUE; break; \
3831         } \
3832 }
3833
3834 #define EXTRACT_VALUE(index, value) \
3835 { \
3836         switch (get_type) \
3837         { \
3838                 case GL_INT: if (!is64) value = ((GLint *)ptr)[index]; else value = ((GLint64 *)ptr)[index]; break; \
3839                 case GL_FLOAT: value = ((GLfloat *)ptr)[index]; break; \
3840                 case GL_BOOL: value = ((GLboolean *)ptr)[index]; break; \
3841         } \
3842 }
3843
3844 static GLboolean
3845 _modify_get_value(GLenum pname, GLvoid *ptr, GLenum get_type, GLboolean is64)
3846 {
3847         GLboolean ret = GL_FALSE;
3848
3849         DEFINE_FASTPAH_GL_FUNC();
3850         INIT_FASTPATH_GL_FUNC();
3851
3852         switch (pname) {
3853         case GL_NUM_EXTENSIONS:
3854                 _valid_extension_string();
3855                 TRANS_VALUE(0, gl_extension_count);
3856                 break;
3857
3858         case GL_TEXTURE_BINDING_2D:
3859         case GL_TEXTURE_BINDING_CUBE_MAP:
3860         case GL_ARRAY_BUFFER_BINDING:
3861         case GL_ELEMENT_ARRAY_BUFFER_BINDING:
3862         case GL_COPY_READ_BUFFER_BINDING:
3863         case GL_COPY_WRITE_BUFFER_BINDING:
3864         case GL_PIXEL_PACK_BUFFER_BINDING:
3865         case GL_PIXEL_UNPACK_BUFFER_BINDING:
3866         case GL_TRANSFORM_FEEDBACK_BUFFER_BINDING:
3867         case GL_UNIFORM_BUFFER_BINDING:
3868         case GL_DRAW_FRAMEBUFFER_BINDING:
3869         case GL_READ_FRAMEBUFFER_BINDING:
3870         case GL_RENDERBUFFER_BINDING:
3871         case GL_CURRENT_PROGRAM:
3872         case GL_VERTEX_ARRAY_BINDING:
3873         case GL_SAMPLER_BINDING:
3874         case GL_TRANSFORM_FEEDBACK_BINDING:
3875         case GL_PROGRAM_PIPELINE_BINDING: {
3876                 GLint real_obj_id = _COREGL_INT_INIT_VALUE;
3877                 GLuint glue_obj_id = _COREGL_INT_INIT_VALUE;
3878                 GL_Object_Type obj_type = GL_OBJECT_TYPE_UNKNOWN;
3879                 EXTRACT_VALUE(0, real_obj_id);
3880
3881                 switch (pname) {
3882                 case GL_TEXTURE_BINDING_2D:
3883                 case GL_TEXTURE_BINDING_CUBE_MAP:
3884                         obj_type = GL_OBJECT_TYPE_TEXTURE;
3885                         break;
3886                 case GL_ARRAY_BUFFER_BINDING:
3887                 case GL_ELEMENT_ARRAY_BUFFER_BINDING:
3888                 case GL_COPY_READ_BUFFER_BINDING:
3889                 case GL_COPY_WRITE_BUFFER_BINDING:
3890                 case GL_PIXEL_PACK_BUFFER_BINDING:
3891                 case GL_PIXEL_UNPACK_BUFFER_BINDING:
3892                 case GL_TRANSFORM_FEEDBACK_BUFFER_BINDING:
3893                 case GL_UNIFORM_BUFFER_BINDING:
3894                         obj_type = GL_OBJECT_TYPE_BUFFER;
3895                         break;
3896                 case GL_DRAW_FRAMEBUFFER_BINDING:
3897                 case GL_READ_FRAMEBUFFER_BINDING:
3898                         obj_type = GL_OBJECT_TYPE_FRAMEBUFFER;
3899                         break;
3900                 case GL_RENDERBUFFER_BINDING:
3901                         obj_type = GL_OBJECT_TYPE_RENDERBUFFER;
3902                         break;
3903                 case GL_CURRENT_PROGRAM:
3904                         obj_type = GL_OBJECT_TYPE_PROGRAM;
3905                         break;
3906                 case GL_VERTEX_ARRAY_BINDING:
3907                         obj_type = GL_OBJECT_TYPE_VERTEXARRAY;
3908                         break;
3909                 case GL_SAMPLER_BINDING:
3910                         obj_type = GL_OBJECT_TYPE_SAMPLER;
3911                         break;
3912                 case GL_TRANSFORM_FEEDBACK_BINDING:
3913                         obj_type = GL_OBJECT_TYPE_TRANSFORMFEEDBACK;
3914                         break;
3915                 case GL_PROGRAM_PIPELINE_BINDING:
3916                         obj_type = GL_OBJECT_TYPE_PROGRAMPIPELINE;
3917                 }
3918                 AST(obj_type != GL_OBJECT_TYPE_UNKNOWN);
3919                 AST(GET_GLUE_OBJ(obj_type, real_obj_id, &glue_obj_id) == 1);
3920                 TRANS_VALUE(0, glue_obj_id);
3921
3922                 ret = GL_TRUE;
3923                 break;
3924         }
3925         }
3926         goto finish;
3927
3928 finish:
3929         return ret;
3930 }
3931
3932 void
3933 fastpath_glGetBooleanv(GLenum pname, GLboolean *params)
3934 {
3935         DEFINE_FASTPAH_GL_FUNC();
3936         _COREGL_FASTPATH_FUNC_BEGIN();
3937         INIT_FASTPATH_GL_FUNC();
3938
3939         IF_GL_SUCCESS(_orig_fastpath_glGetBooleanv(pname, params)) {
3940                 _modify_get_value(pname, params, GL_BOOL, GL_FALSE);
3941         }
3942         goto finish;
3943
3944 finish:
3945         _COREGL_FASTPATH_FUNC_END();
3946 }
3947
3948 void
3949 fastpath_glGetFloatv(GLenum pname, GLfloat *params)
3950 {
3951         DEFINE_FASTPAH_GL_FUNC();
3952         _COREGL_FASTPATH_FUNC_BEGIN();
3953         INIT_FASTPATH_GL_FUNC();
3954
3955         IF_GL_SUCCESS(_orig_fastpath_glGetFloatv(pname, params)) {
3956                 _modify_get_value(pname, params, GL_FLOAT, GL_FALSE);
3957         }
3958         goto finish;
3959
3960 finish:
3961         _COREGL_FASTPATH_FUNC_END();
3962 }
3963
3964 void
3965 fastpath_glGetIntegerv(GLenum pname, GLint *params)
3966 {
3967         DEFINE_FASTPAH_GL_FUNC();
3968         _COREGL_FASTPATH_FUNC_BEGIN();
3969         INIT_FASTPATH_GL_FUNC();
3970
3971         IF_GL_SUCCESS(_orig_fastpath_glGetIntegerv(pname, params)) {
3972                 _modify_get_value(pname, params, GL_INT, GL_FALSE);
3973         }
3974         goto finish;
3975
3976 finish:
3977         _COREGL_FASTPATH_FUNC_END();
3978 }
3979
3980
3981
3982 /* ES 3.0 PASS (SUPPORT) */
3983 void
3984 fastpath_glGetProgramBinary(GLuint program, GLsizei bufsize, GLsizei *length,
3985                             GLenum *binaryFormat, void *binary)
3986 {
3987         GLuint real_obj;
3988
3989         DEFINE_FASTPAH_GL_FUNC();
3990         _COREGL_FASTPATH_FUNC_BEGIN();
3991         INIT_FASTPATH_GL_FUNC();
3992
3993         if (GET_REAL_OBJ(GL_OBJECT_TYPE_PROGRAM, program, &real_obj) != 1) {
3994                 _set_gl_error(GL_INVALID_VALUE);
3995                 goto finish;
3996         }
3997
3998         _orig_fastpath_glGetProgramBinary(real_obj, bufsize, length, binaryFormat,
3999                                           binary);
4000
4001         goto finish;
4002
4003 finish:
4004         _COREGL_FASTPATH_FUNC_END();
4005 }
4006
4007
4008 void
4009 fastpath_glGetProgramBinaryOES(GLuint program, GLsizei bufsize, GLsizei *length,
4010                                GLenum *binaryFormat, void *binary)
4011 {
4012         GLuint real_obj;
4013
4014         DEFINE_FASTPAH_GL_FUNC();
4015         _COREGL_FASTPATH_FUNC_BEGIN();
4016         INIT_FASTPATH_GL_FUNC();
4017
4018         if (GET_REAL_OBJ(GL_OBJECT_TYPE_PROGRAM, program, &real_obj) != 1) {
4019                 _set_gl_error(GL_INVALID_VALUE);
4020                 goto finish;
4021         }
4022
4023         _orig_fastpath_glGetProgramBinaryOES(real_obj, bufsize, length, binaryFormat,
4024                                              binary);
4025
4026         goto finish;
4027
4028 finish:
4029         _COREGL_FASTPATH_FUNC_END();
4030 }
4031
4032
4033 void
4034 fastpath_glProgramBinary(GLuint program, GLenum binaryFormat,
4035                          const void *binary, GLint length)
4036 {
4037         GLuint real_obj;
4038
4039         DEFINE_FASTPAH_GL_FUNC();
4040         _COREGL_FASTPATH_FUNC_BEGIN();
4041         INIT_FASTPATH_GL_FUNC();
4042
4043         if (GET_REAL_OBJ(GL_OBJECT_TYPE_PROGRAM, program, &real_obj) != 1) {
4044                 _set_gl_error(GL_INVALID_VALUE);
4045                 goto finish;
4046         }
4047
4048         _orig_fastpath_glProgramBinary(real_obj, binaryFormat, binary, length);
4049
4050         goto finish;
4051
4052 finish:
4053         _COREGL_FASTPATH_FUNC_END();
4054 }
4055
4056
4057 void
4058 fastpath_glProgramBinaryOES(GLuint program, GLenum binaryFormat,
4059                             const void *binary, GLint length)
4060 {
4061         GLuint real_obj;
4062
4063         DEFINE_FASTPAH_GL_FUNC();
4064         _COREGL_FASTPATH_FUNC_BEGIN();
4065         INIT_FASTPATH_GL_FUNC();
4066
4067         if (GET_REAL_OBJ(GL_OBJECT_TYPE_PROGRAM, program, &real_obj) != 1) {
4068                 _set_gl_error(GL_INVALID_VALUE);
4069                 goto finish;
4070         }
4071
4072         _orig_fastpath_glProgramBinaryOES(real_obj, binaryFormat, binary, length);
4073
4074         goto finish;
4075
4076 finish:
4077         _COREGL_FASTPATH_FUNC_END();
4078 }
4079
4080
4081 void
4082 fastpath_glReadBuffer(GLenum mode)
4083 {
4084         DEFINE_FASTPAH_GL_FUNC();
4085         _COREGL_FASTPATH_FUNC_BEGIN();
4086         INIT_FASTPATH_GL_FUNC();
4087
4088         CURR_STATE_COMPARE(gl_read_buffer, mode) {
4089                 IF_GL_SUCCESS(_orig_fastpath_glReadBuffer(mode)) {
4090                         current_ctx->_misc_flag3 |= _MISC_FLAG3_BIT_gl_read_buffer;
4091                         current_ctx->gl_read_buffer[0] = mode;
4092                 }
4093         }
4094
4095         goto finish;
4096
4097 finish:
4098         _COREGL_FASTPATH_FUNC_END();
4099 }
4100
4101
4102 void
4103 fastpath_glGenQueries(GLsizei n, GLuint *ids)
4104 {
4105         int i;
4106         GLuint *objid_array = NULL;
4107
4108         DEFINE_FASTPAH_GL_FUNC();
4109         _COREGL_FASTPATH_FUNC_BEGIN();
4110         INIT_FASTPATH_GL_FUNC();
4111
4112         if (n < 0) {
4113                 _set_gl_error(GL_INVALID_VALUE);
4114                 goto finish;
4115         }
4116         if (n == 0) goto finish;
4117         if (ids == NULL) goto finish;
4118
4119         AST(current_ctx->ostate.shared != NULL);
4120
4121         objid_array = (GLuint *)calloc(1, sizeof(GLuint) * n);
4122
4123         IF_GL_SUCCESS(_orig_fastpath_glGenQueries(n, objid_array)) {
4124                 for (i = 0; i < n; i++) {
4125                         ids[i] = fastpath_ostate_create_object(&current_ctx->ostate,
4126                                                                GL_OBJECT_TYPE_QUERY, objid_array[i]);
4127                 }
4128         }
4129
4130         goto finish;
4131
4132 finish:
4133         if (objid_array != NULL) {
4134                 free(objid_array);
4135                 objid_array = NULL;
4136         }
4137         _COREGL_FASTPATH_FUNC_END();
4138 }
4139
4140
4141 void
4142 fastpath_glDeleteQueries(GLsizei n, const GLuint *ids)
4143 {
4144         int i;
4145         GLuint *objid_array = NULL;
4146
4147         DEFINE_FASTPAH_GL_FUNC();
4148         _COREGL_FASTPATH_FUNC_BEGIN();
4149         INIT_FASTPATH_GL_FUNC();
4150
4151         if (n < 0) {
4152                 _set_gl_error(GL_INVALID_VALUE);
4153                 goto finish;
4154         }
4155         if (n == 0) goto finish;
4156         if (ids == NULL) goto finish;
4157
4158         AST(current_ctx->ostate.shared != NULL);
4159
4160         objid_array = (GLuint *)calloc(1, sizeof(GLuint) * n);
4161         {
4162                 int real_n = 0;
4163
4164                 for (i = 0; i < n; i++) {
4165                         int real_objid = _COREGL_INT_INIT_VALUE;
4166                         if (ids[i] == 0) continue;
4167
4168                         real_objid = fastpath_ostate_get_object(&current_ctx->ostate,
4169                                                                 GL_OBJECT_TYPE_QUERY, ids[i]);
4170                         if (real_objid == 0) continue;
4171
4172                         AST(fastpath_ostate_remove_object(&current_ctx->ostate, GL_OBJECT_TYPE_QUERY,
4173                                                           ids[i]) == 1);
4174                         objid_array[real_n++] = real_objid;
4175                 }
4176
4177                 _orig_fastpath_glDeleteQueries(real_n, objid_array);
4178         }
4179
4180         goto finish;
4181
4182 finish:
4183         if (objid_array != NULL) {
4184                 free(objid_array);
4185                 objid_array = NULL;
4186         }
4187         _COREGL_FASTPATH_FUNC_END();
4188 }
4189
4190
4191 GLboolean
4192 fastpath_glIsQuery(GLuint id)
4193 {
4194         GLboolean ret = GL_FALSE;
4195         GLuint real_obj;
4196
4197         DEFINE_FASTPAH_GL_FUNC();
4198         _COREGL_FASTPATH_FUNC_BEGIN();
4199         INIT_FASTPATH_GL_FUNC();
4200
4201         if (GET_REAL_OBJ(GL_OBJECT_TYPE_QUERY, id, &real_obj) != 1) {
4202                 ret = GL_FALSE;
4203                 goto finish;
4204         }
4205
4206         ret = _orig_fastpath_glIsQuery(real_obj);
4207
4208         goto finish;
4209
4210 finish:
4211         _COREGL_FASTPATH_FUNC_END();
4212         return ret;
4213 }
4214
4215
4216 void
4217 fastpath_glBeginQuery(GLenum target, GLuint id)
4218 {
4219         GLuint real_obj;
4220
4221         DEFINE_FASTPAH_GL_FUNC();
4222         _COREGL_FASTPATH_FUNC_BEGIN();
4223         INIT_FASTPATH_GL_FUNC();
4224
4225         if (GET_REAL_OBJ(GL_OBJECT_TYPE_QUERY, id, &real_obj) != 1) {
4226                 // TODO : Begin - Context Switch
4227                 _set_gl_error(GL_INVALID_OPERATION);
4228                 goto finish;
4229         }
4230
4231         _orig_fastpath_glBeginQuery(target, real_obj);
4232
4233         goto finish;
4234
4235 finish:
4236         _COREGL_FASTPATH_FUNC_END();
4237 }
4238
4239
4240 void
4241 fastpath_glGetQueryiv(GLenum target, GLenum pname, GLint *params)
4242 {
4243         GLuint glue_obj_id = _COREGL_INT_INIT_VALUE;
4244
4245         DEFINE_FASTPAH_GL_FUNC();
4246         _COREGL_FASTPATH_FUNC_BEGIN();
4247         INIT_FASTPATH_GL_FUNC();
4248
4249         _orig_fastpath_glGetQueryiv(target, pname, params);
4250
4251         switch (pname) {
4252         case GL_CURRENT_QUERY:
4253                 if (params[0] != 0) {
4254                         AST(GET_GLUE_OBJ(GL_OBJECT_TYPE_QUERY, params[0], &glue_obj_id) == 1);
4255                         params[0] = glue_obj_id;
4256                 }
4257                 break;
4258         }
4259
4260         goto finish;
4261
4262 finish:
4263         _COREGL_FASTPATH_FUNC_END();
4264 }
4265
4266
4267 void
4268 fastpath_glGetQueryObjectuiv(GLuint id, GLenum pname, GLuint *params)
4269 {
4270         GLuint real_obj;
4271
4272         DEFINE_FASTPAH_GL_FUNC();
4273         _COREGL_FASTPATH_FUNC_BEGIN();
4274         INIT_FASTPATH_GL_FUNC();
4275
4276         if (GET_REAL_OBJ(GL_OBJECT_TYPE_QUERY, id, &real_obj) != 1) {
4277                 _set_gl_error(GL_INVALID_OPERATION);
4278                 goto finish;
4279         }
4280
4281         _orig_fastpath_glGetQueryObjectuiv(real_obj, pname, params);
4282
4283         goto finish;
4284
4285 finish:
4286         _COREGL_FASTPATH_FUNC_END();
4287 }
4288
4289
4290 void
4291 fastpath_glDrawBuffers(GLsizei n, const GLenum *bufs)
4292 {
4293         DEFINE_FASTPAH_GL_FUNC();
4294         _COREGL_FASTPATH_FUNC_BEGIN();
4295         INIT_FASTPATH_GL_FUNC();
4296
4297         IF_GL_SUCCESS(_orig_fastpath_glDrawBuffers(n, bufs)) {
4298                 current_ctx->_misc_flag3 |= _MISC_FLAG3_BIT_gl_draw_buffers;
4299                 fastpath_state_get_draw_buffers(current_ctx->gl_draw_buffers);
4300         }
4301
4302         goto finish;
4303
4304 finish:
4305         _COREGL_FASTPATH_FUNC_END();
4306 }
4307
4308
4309 void
4310 fastpath_glFramebufferTextureLayer(GLenum target, GLenum attachment,
4311                                    GLuint texture, GLint level, GLint layer)
4312 {
4313         GLuint real_obj;
4314
4315         DEFINE_FASTPAH_GL_FUNC();
4316         _COREGL_FASTPATH_FUNC_BEGIN();
4317         INIT_FASTPATH_GL_FUNC();
4318
4319         if (GET_REAL_OBJ(GL_OBJECT_TYPE_TEXTURE, texture, &real_obj) != 1) {
4320                 _set_gl_error(GL_OUT_OF_MEMORY);
4321                 goto finish;
4322         }
4323
4324         _orig_fastpath_glFramebufferTextureLayer(target, attachment, texture, level,
4325                         layer);
4326
4327         goto finish;
4328
4329 finish:
4330         _COREGL_FASTPATH_FUNC_END();
4331 }
4332
4333
4334 ////////////////////////////////////////////////////////////////////////
4335
4336 void
4337 fastpath_glGenVertexArrays(GLsizei n, GLuint *arrays)
4338 {
4339         int i;
4340         GLuint *objid_array = NULL;
4341
4342         DEFINE_FASTPAH_GL_FUNC();
4343         _COREGL_FASTPATH_FUNC_BEGIN();
4344         INIT_FASTPATH_GL_FUNC();
4345
4346         if (n < 0) {
4347                 _set_gl_error(GL_INVALID_VALUE);
4348                 goto finish;
4349         }
4350         if (n == 0) goto finish;
4351         if (arrays == NULL) goto finish;
4352
4353         AST(current_ctx->ostate.shared != NULL);
4354
4355         objid_array = (GLuint *)calloc(1, sizeof(GLuint) * n);
4356
4357         IF_GL_SUCCESS(_orig_fastpath_glGenVertexArrays(n, objid_array)) {
4358                 for (i = 0; i < n; i++) {
4359                         arrays[i] = fastpath_ostate_create_object(&current_ctx->ostate,
4360                                         GL_OBJECT_TYPE_VERTEXARRAY, objid_array[i]);
4361                 }
4362         }
4363
4364         goto finish;
4365
4366 finish:
4367         if (objid_array != NULL) {
4368                 free(objid_array);
4369                 objid_array = NULL;
4370         }
4371         _COREGL_FASTPATH_FUNC_END();
4372 }
4373
4374
4375 void
4376 fastpath_glBindVertexArray(GLuint array)
4377 {
4378         GLuint real_obj;
4379
4380         DEFINE_FASTPAH_GL_FUNC();
4381         _COREGL_FASTPATH_FUNC_BEGIN();
4382         INIT_FASTPATH_GL_FUNC();
4383
4384         if (GET_REAL_OBJ(GL_OBJECT_TYPE_VERTEXARRAY, array, &real_obj) != 1) {
4385                 _set_gl_error(GL_INVALID_OPERATION);
4386                 goto finish;
4387         }
4388
4389         if (current_ctx->gl_vertex_array_binding[0] != real_obj) {
4390                 IF_GL_SUCCESS(_orig_fastpath_glBindVertexArray(real_obj)) {
4391                         current_ctx->_misc_flag3 |= _MISC_FLAG3_BIT_gl_vertex_array_binding;
4392                         current_ctx->gl_vertex_array_binding[0] = real_obj;
4393                 }
4394         }
4395         goto finish;
4396
4397 finish:
4398         _COREGL_FASTPATH_FUNC_END();
4399 }
4400
4401
4402 GLboolean
4403 fastpath_glIsVertexArray(GLuint array)
4404 {
4405         GLboolean ret = GL_FALSE;
4406         GLuint real_obj;
4407
4408         DEFINE_FASTPAH_GL_FUNC();
4409         _COREGL_FASTPATH_FUNC_BEGIN();
4410         INIT_FASTPATH_GL_FUNC();
4411
4412         if (GET_REAL_OBJ(GL_OBJECT_TYPE_VERTEXARRAY, array, &real_obj) != 1) {
4413                 ret = GL_FALSE;
4414                 goto finish;
4415         }
4416
4417         ret = _orig_fastpath_glIsVertexArray(real_obj);
4418
4419         goto finish;
4420
4421 finish:
4422         _COREGL_FASTPATH_FUNC_END();
4423         return ret;
4424 }
4425
4426
4427 void
4428 fastpath_glDeleteVertexArrays(GLsizei n, const GLuint *arrays)
4429 {
4430         int i;
4431         GLuint *objid_array = NULL;
4432
4433         DEFINE_FASTPAH_GL_FUNC();
4434         _COREGL_FASTPATH_FUNC_BEGIN();
4435         INIT_FASTPATH_GL_FUNC();
4436
4437         if (n < 0) {
4438                 _set_gl_error(GL_INVALID_VALUE);
4439                 goto finish;
4440         }
4441         if (n == 0) goto finish;
4442         if (arrays == NULL) goto finish;
4443
4444         AST(current_ctx->ostate.shared != NULL);
4445
4446         objid_array = (GLuint *)calloc(1, sizeof(GLuint) * n);
4447         {
4448                 int real_n = 0;
4449
4450                 for (i = 0; i < n; i++) {
4451                         int real_objid = _COREGL_INT_INIT_VALUE;
4452                         if (arrays[i] == 0) continue;
4453
4454                         real_objid = fastpath_ostate_get_object(&current_ctx->ostate,
4455                                                                 GL_OBJECT_TYPE_VERTEXARRAY, arrays[i]);
4456                         if (real_objid == 0) continue;
4457
4458                         AST(fastpath_ostate_remove_object(&current_ctx->ostate,
4459                                                           GL_OBJECT_TYPE_VERTEXARRAY, arrays[i]) == 1);
4460                         objid_array[real_n++] = real_objid;
4461                 }
4462
4463                 IF_GL_SUCCESS(_orig_fastpath_glDeleteVertexArrays(real_n, objid_array)) {
4464                         for (i = 0; i < real_n; i++) {
4465                                 General_Trace_List *current = NULL;
4466                                 current = current_ctx->ostate.shared->using_gctxs;
4467
4468                                 while (current != NULL) {
4469                                         GLGlueContext *cur_gctx = (GLGlueContext *)current->value;
4470
4471                                         if (cur_gctx->gl_vertex_array_binding[0] == objid_array[i])
4472                                                 cur_gctx->gl_vertex_array_binding[0] = 0;
4473
4474                                         current = current->next;
4475                                 }
4476                         }
4477                 }
4478         }
4479
4480         goto finish;
4481
4482 finish:
4483         if (objid_array != NULL) {
4484                 free(objid_array);
4485                 objid_array = NULL;
4486         }
4487         _COREGL_FASTPATH_FUNC_END();
4488 }
4489
4490 ////////////////////////////////////////////////////////////////////////
4491
4492 void
4493 fastpath_glGetIntegeri_v(GLenum target, GLuint index, GLint *data)
4494 {
4495         DEFINE_FASTPAH_GL_FUNC();
4496         _COREGL_FASTPATH_FUNC_BEGIN();
4497         INIT_FASTPATH_GL_FUNC();
4498
4499         IF_GL_SUCCESS(_orig_fastpath_glGetIntegeri_v(target, index, data)) {
4500                 _modify_get_value(target, data, GL_INT, GL_FALSE);
4501         }
4502         goto finish;
4503
4504 finish:
4505         _COREGL_FASTPATH_FUNC_END();
4506 }
4507
4508 ////////////////////////////////////////////////////////////////////////
4509
4510 void
4511 fastpath_glGenTransformFeedbacks(GLsizei n, GLuint *ids)
4512 {
4513         int i;
4514         GLuint *objid_array = NULL;
4515
4516         DEFINE_FASTPAH_GL_FUNC();
4517         _COREGL_FASTPATH_FUNC_BEGIN();
4518         INIT_FASTPATH_GL_FUNC();
4519
4520         if (n < 0) {
4521                 _set_gl_error(GL_INVALID_VALUE);
4522                 goto finish;
4523         }
4524         if (n == 0) goto finish;
4525         if (ids == NULL) goto finish;
4526
4527         AST(current_ctx->ostate.shared != NULL);
4528
4529         objid_array = (GLuint *)calloc(1, sizeof(GLuint) * n);
4530
4531         IF_GL_SUCCESS(_orig_fastpath_glGenTransformFeedbacks(n, objid_array)) {
4532                 for (i = 0; i < n; i++) {
4533                         ids[i] = fastpath_ostate_create_object(&current_ctx->ostate,
4534                                                                GL_OBJECT_TYPE_TRANSFORMFEEDBACK, objid_array[i]);
4535                 }
4536         }
4537
4538         goto finish;
4539
4540 finish:
4541         if (objid_array != NULL) {
4542                 free(objid_array);
4543                 objid_array = NULL;
4544         }
4545         _COREGL_FASTPATH_FUNC_END();
4546 }
4547
4548
4549 void
4550 fastpath_glBindTransformFeedback(GLenum target, GLuint id)
4551 {
4552         GLuint real_obj;
4553
4554         DEFINE_FASTPAH_GL_FUNC();
4555         _COREGL_FASTPATH_FUNC_BEGIN();
4556         INIT_FASTPATH_GL_FUNC();
4557
4558         if (GET_REAL_OBJ(GL_OBJECT_TYPE_TRANSFORMFEEDBACK, id, &real_obj) != 1) {
4559                 _set_gl_error(GL_OUT_OF_MEMORY);
4560                 goto finish;
4561         }
4562
4563         if (current_ctx->gl_transform_feedback_binding[0] != real_obj) {
4564                 IF_GL_SUCCESS(_orig_fastpath_glBindTransformFeedback(target, real_obj)) {
4565                         current_ctx->_misc_flag3 |= _MISC_FLAG3_BIT_gl_transform_feedback_binding;
4566                         current_ctx->gl_transform_feedback_binding[0] = real_obj;
4567                 }
4568         }
4569         goto finish;
4570
4571 finish:
4572         _COREGL_FASTPATH_FUNC_END();
4573 }
4574
4575
4576 void
4577 fastpath_glBeginTransformFeedback(GLenum primitiveMode)
4578 {
4579         DEFINE_FASTPAH_GL_FUNC();
4580         _COREGL_FASTPATH_FUNC_BEGIN();
4581         INIT_FASTPATH_GL_FUNC();
4582
4583         IF_GL_SUCCESS(_orig_fastpath_glBeginTransformFeedback(primitiveMode)) {
4584                 current_ctx->_misc_flag3 |= _MISC_FLAG3_BIT_gl_transform_feedback;
4585
4586                 current_ctx->gl_transform_feedback_active[0] = GL_TRUE;
4587                 current_ctx->gl_transform_feedback_paused[0] = GL_FALSE;
4588         }
4589
4590         goto finish;
4591
4592 finish:
4593         _COREGL_FASTPATH_FUNC_END();
4594 }
4595
4596
4597 void
4598 fastpath_glEndTransformFeedback()
4599 {
4600         DEFINE_FASTPAH_GL_FUNC();
4601         _COREGL_FASTPATH_FUNC_BEGIN();
4602         INIT_FASTPATH_GL_FUNC();
4603
4604         IF_GL_SUCCESS(_orig_fastpath_glEndTransformFeedback()) {
4605                 current_ctx->_misc_flag3 |= _MISC_FLAG3_BIT_gl_transform_feedback;
4606
4607                 current_ctx->gl_transform_feedback_active[0] = GL_FALSE;
4608                 current_ctx->gl_transform_feedback_paused[0] = GL_FALSE;
4609         }
4610
4611         goto finish;
4612
4613 finish:
4614         _COREGL_FASTPATH_FUNC_END();
4615 }
4616
4617
4618 void
4619 fastpath_glPauseTransformFeedback()
4620 {
4621         DEFINE_FASTPAH_GL_FUNC();
4622         _COREGL_FASTPATH_FUNC_BEGIN();
4623         INIT_FASTPATH_GL_FUNC();
4624
4625         IF_GL_SUCCESS(_orig_fastpath_glPauseTransformFeedback()) {
4626                 current_ctx->_misc_flag3 |= _MISC_FLAG3_BIT_gl_transform_feedback;
4627
4628                 current_ctx->gl_transform_feedback_active[0] = GL_TRUE;
4629                 current_ctx->gl_transform_feedback_paused[0] = GL_TRUE;
4630         }
4631
4632         goto finish;
4633
4634 finish:
4635         _COREGL_FASTPATH_FUNC_END();
4636 }
4637
4638 void
4639 fastpath_glResumeTransformFeedback()
4640 {
4641         DEFINE_FASTPAH_GL_FUNC();
4642         _COREGL_FASTPATH_FUNC_BEGIN();
4643         INIT_FASTPATH_GL_FUNC();
4644
4645         IF_GL_SUCCESS(_orig_fastpath_glResumeTransformFeedback()) {
4646                 current_ctx->_misc_flag3 |= _MISC_FLAG3_BIT_gl_transform_feedback;
4647
4648                 current_ctx->gl_transform_feedback_active[0] = GL_TRUE;
4649                 current_ctx->gl_transform_feedback_paused[0] = GL_FALSE;
4650         }
4651
4652         goto finish;
4653
4654 finish:
4655         _COREGL_FASTPATH_FUNC_END();
4656 }
4657
4658
4659 GLboolean
4660 fastpath_glIsTransformFeedback(GLuint id)
4661 {
4662         GLboolean ret = GL_FALSE;
4663         GLuint real_obj;
4664
4665         DEFINE_FASTPAH_GL_FUNC();
4666         _COREGL_FASTPATH_FUNC_BEGIN();
4667         INIT_FASTPATH_GL_FUNC();
4668
4669         if (GET_REAL_OBJ(GL_OBJECT_TYPE_TRANSFORMFEEDBACK, id, &real_obj) != 1) {
4670                 ret = GL_FALSE;
4671                 goto finish;
4672         }
4673
4674         ret = _orig_fastpath_glIsTransformFeedback(real_obj);
4675
4676         goto finish;
4677
4678 finish:
4679         _COREGL_FASTPATH_FUNC_END();
4680         return ret;
4681 }
4682
4683
4684 void
4685 fastpath_glDeleteTransformFeedbacks(GLsizei n, const GLuint *ids)
4686 {
4687         int i;
4688         GLuint *objid_array = NULL;
4689
4690         DEFINE_FASTPAH_GL_FUNC();
4691         _COREGL_FASTPATH_FUNC_BEGIN();
4692         INIT_FASTPATH_GL_FUNC();
4693
4694         if (n < 0) {
4695                 _set_gl_error(GL_INVALID_VALUE);
4696                 goto finish;
4697         }
4698         if (n == 0) goto finish;
4699         if (ids == NULL) goto finish;
4700
4701         AST(current_ctx->ostate.shared != NULL);
4702
4703         objid_array = (GLuint *)calloc(1, sizeof(GLuint) * n);
4704         {
4705                 int real_n = 0;
4706
4707                 for (i = 0; i < n; i++) {
4708                         int real_objid = _COREGL_INT_INIT_VALUE;
4709                         if (ids[i] == 0) continue;
4710
4711                         real_objid = fastpath_ostate_get_object(&current_ctx->ostate,
4712                                                                 GL_OBJECT_TYPE_TRANSFORMFEEDBACK, ids[i]);
4713                         if (real_objid == 0) continue;
4714
4715                         AST(fastpath_ostate_remove_object(&current_ctx->ostate,
4716                                                           GL_OBJECT_TYPE_TRANSFORMFEEDBACK, ids[i]) == 1);
4717                         objid_array[real_n++] = real_objid;
4718                 }
4719
4720                 IF_GL_SUCCESS(_orig_fastpath_glDeleteTransformFeedbacks(real_n, objid_array)) {
4721                         for (i = 0; i < real_n; i++) {
4722                                 General_Trace_List *current = NULL;
4723                                 current = current_ctx->ostate.shared->using_gctxs;
4724
4725                                 while (current != NULL) {
4726                                         GLGlueContext *cur_gctx = (GLGlueContext *)current->value;
4727
4728                                         if (cur_gctx->gl_transform_feedback_binding[0] == objid_array[i])
4729                                                 cur_gctx->gl_transform_feedback_binding[0] = 0;
4730
4731                                         current = current->next;
4732                                 }
4733                         }
4734                 }
4735         }
4736
4737         goto finish;
4738
4739 finish:
4740         if (objid_array != NULL) {
4741                 free(objid_array);
4742                 objid_array = NULL;
4743         }
4744         _COREGL_FASTPATH_FUNC_END();
4745 }
4746
4747 ////////////////////////////////////////////////////////////////////////
4748
4749
4750 void
4751 fastpath_glBindBufferBase(GLenum target, GLuint index, GLuint buffer)
4752 {
4753         GLuint real_obj;
4754
4755         DEFINE_FASTPAH_GL_FUNC();
4756         _COREGL_FASTPATH_FUNC_BEGIN();
4757         INIT_FASTPATH_GL_FUNC();
4758
4759         if (GET_REAL_OBJ(GL_OBJECT_TYPE_BUFFER, buffer, &real_obj) != 1) {
4760                 _set_gl_error(GL_OUT_OF_MEMORY);
4761                 goto finish;
4762         }
4763
4764 #define STATE_PROC(gl_state, flagid, flagbit) \
4765         { \
4766                 CURR_STATE_COMPARE(gl_state, real_obj) \
4767                 { \
4768                         IF_GL_SUCCESS(_orig_fastpath_glBindBufferBase(target, index, real_obj)) \
4769                         { \
4770                                 current_ctx->flagid |= flagbit##_##gl_state; \
4771                                 current_ctx->gl_state##_array[index] = real_obj; \
4772                                 current_ctx->gl_state##_array_offset[index] = 0; \
4773                                 current_ctx->gl_state##_array_size[index] = 0; \
4774                         } \
4775                 } \
4776                 break; \
4777         }
4778
4779
4780         switch (target) {
4781         case GL_TRANSFORM_FEEDBACK_BUFFER:
4782                 STATE_PROC(gl_transform_feedback_buffer_binding, _bind_flag2, _BIND_FLAG2_BIT);
4783                 break;
4784         case GL_UNIFORM_BUFFER:
4785                 STATE_PROC(gl_uniform_buffer_binding, _bind_flag2, _BIND_FLAG2_BIT);
4786                 break;
4787         default:
4788                 _set_gl_error(GL_INVALID_ENUM);
4789                 break;
4790         }
4791
4792
4793 #undef STATE_PROC
4794
4795         goto finish;
4796
4797 finish:
4798         _COREGL_FASTPATH_FUNC_END();
4799 }
4800
4801
4802
4803 void
4804 fastpath_glBindBufferRange(GLenum target, GLuint index, GLuint buffer,
4805                            GLintptr offset, GLsizeiptr size)
4806 {
4807         GLuint real_obj;
4808
4809         DEFINE_FASTPAH_GL_FUNC();
4810         _COREGL_FASTPATH_FUNC_BEGIN();
4811         INIT_FASTPATH_GL_FUNC();
4812
4813         if (GET_REAL_OBJ(GL_OBJECT_TYPE_BUFFER, buffer, &real_obj) != 1) {
4814                 _set_gl_error(GL_OUT_OF_MEMORY);
4815                 goto finish;
4816         }
4817
4818 #define STATE_PROC(gl_state, flagnum) \
4819         { \
4820                 CURR_STATE_COMPARE(gl_state, real_obj) \
4821                 { \
4822                         IF_GL_SUCCESS(_orig_fastpath_glBindBufferRange(target, index, real_obj, offset, size)) \
4823                         { \
4824                                 current_ctx->_bind_flag2 |= _BIND_FLAG2_BIT_##gl_state; \
4825                                 current_ctx->gl_state##_array[index] = real_obj; \
4826                                 current_ctx->gl_state##_array_offset[index] = offset; \
4827                                 current_ctx->gl_state##_array_size[index] = size; \
4828                         } \
4829                 } \
4830                 break; \
4831         }
4832
4833
4834         switch (target) {
4835         case GL_TRANSFORM_FEEDBACK_BUFFER:
4836                 STATE_PROC(gl_transform_feedback_buffer_binding, 0);
4837                 break;
4838         case GL_UNIFORM_BUFFER:
4839                 STATE_PROC(gl_uniform_buffer_binding, 0);
4840                 break;
4841         default:
4842                 _set_gl_error(GL_INVALID_ENUM);
4843                 break;
4844         }
4845
4846
4847 #undef STATE_PROC
4848
4849         goto finish;
4850
4851 finish:
4852         _COREGL_FASTPATH_FUNC_END();
4853 }
4854
4855
4856 void
4857 fastpath_glTransformFeedbackVaryings(GLuint program, GLsizei count,
4858                                      const GLchar *const *varyings, GLenum bufferMode)
4859 {
4860         GLuint real_obj;
4861
4862         DEFINE_FASTPAH_GL_FUNC();
4863         _COREGL_FASTPATH_FUNC_BEGIN();
4864         INIT_FASTPATH_GL_FUNC();
4865
4866         if (GET_REAL_OBJ(GL_OBJECT_TYPE_PROGRAM, program, &real_obj) != 1) {
4867                 _set_gl_error(GL_INVALID_VALUE);
4868                 goto finish;
4869         }
4870
4871         _orig_fastpath_glTransformFeedbackVaryings(real_obj, count, varyings,
4872                         bufferMode);
4873         goto finish;
4874
4875 finish:
4876         _COREGL_FASTPATH_FUNC_END();
4877 }
4878
4879
4880 void
4881 fastpath_glGetTransformFeedbackVarying(GLuint program, GLuint index,
4882                                        GLsizei bufSize, GLsizei *length, GLsizei *size, GLenum *type, GLchar *name)
4883 {
4884         GLuint real_obj;
4885
4886         DEFINE_FASTPAH_GL_FUNC();
4887         _COREGL_FASTPATH_FUNC_BEGIN();
4888         INIT_FASTPATH_GL_FUNC();
4889
4890         if (GET_REAL_OBJ(GL_OBJECT_TYPE_PROGRAM, program, &real_obj) != 1) {
4891                 _set_gl_error(GL_INVALID_VALUE);
4892                 goto finish;
4893         }
4894
4895         _orig_fastpath_glGetTransformFeedbackVarying(real_obj, index, bufSize, length,
4896                         size, type, name);
4897         goto finish;
4898
4899 finish:
4900         _COREGL_FASTPATH_FUNC_END();
4901 }
4902
4903
4904 void
4905 fastpath_glVertexAttribIPointer(GLuint index, GLint size, GLenum type,
4906                                 GLsizei stride, const GLvoid *pointer)
4907 {
4908         DEFINE_FASTPAH_GL_FUNC();
4909         _COREGL_FASTPATH_FUNC_BEGIN();
4910         INIT_FASTPATH_GL_FUNC();
4911
4912         IF_GL_SUCCESS(_orig_fastpath_glVertexAttribIPointer(index, size, type, stride,
4913                         pointer)) {
4914                 if (current_ctx->gl_vertex_array_binding[0] == 0) {
4915                         current_ctx->_vattrib_flag |= _VATTRIB_FLAG_BIT_gl_vertex_array;
4916
4917                         current_ctx->gl_vertex_array_buf_id[index]      =
4918                                 current_ctx->gl_array_buffer_binding[0];
4919                         current_ctx->gl_vertex_array_size[index]        = size;
4920                         current_ctx->gl_vertex_array_type[index]        = type;
4921                         current_ctx->gl_vertex_array_normalized[index]  = GL_FALSE;
4922                         current_ctx->gl_vertex_array_integer[index]     = GL_TRUE;
4923                         current_ctx->gl_vertex_array_stride[index]      = stride;
4924                         current_ctx->gl_vertex_array_pointer[index]     = (GLvoid *)pointer;
4925                 }
4926         }
4927         goto finish;
4928
4929 finish:
4930         _COREGL_FASTPATH_FUNC_END();
4931 }
4932
4933
4934 void
4935 fastpath_glVertexAttribI4i(GLuint index, GLint x, GLint y, GLint z, GLint w)
4936 {
4937         DEFINE_FASTPAH_GL_FUNC();
4938         _COREGL_FASTPATH_FUNC_BEGIN();
4939         INIT_FASTPATH_GL_FUNC();
4940
4941         IF_GL_SUCCESS(_orig_fastpath_glVertexAttribI4i(index, x, y, z, w)) {
4942                 if (current_ctx->gl_vertex_array_binding[0] == 0) {
4943                         current_ctx->_vattrib_flag |= _VATTRIB_FLAG_BIT_gl_vertex_attrib_value;
4944                         current_ctx->gl_vertex_array_size[index] = 0;
4945                         current_ctx->gl_vertex_array_integer[index] = GL_TRUE;
4946
4947                         current_ctx->gl_vertex_array_type[index] = GL_INT;
4948                         current_ctx->gl_vertex_attrib_value_integer[index * 4 + 0] = x;
4949                         current_ctx->gl_vertex_attrib_value_integer[index * 4 + 1] = y;
4950                         current_ctx->gl_vertex_attrib_value_integer[index * 4 + 2] = z;
4951                         current_ctx->gl_vertex_attrib_value_integer[index * 4 + 3] = w;
4952                 }
4953         }
4954         goto finish;
4955
4956 finish:
4957         _COREGL_FASTPATH_FUNC_END();
4958 }
4959
4960
4961 void
4962 fastpath_glVertexAttribI4ui(GLuint index, GLuint x, GLuint y, GLuint z,
4963                             GLuint w)
4964 {
4965         DEFINE_FASTPAH_GL_FUNC();
4966         _COREGL_FASTPATH_FUNC_BEGIN();
4967         INIT_FASTPATH_GL_FUNC();
4968
4969         IF_GL_SUCCESS(_orig_fastpath_glVertexAttribI4ui(index, x, y, z, w)) {
4970                 if (current_ctx->gl_vertex_array_binding[0] == 0) {
4971                         current_ctx->_vattrib_flag |= _VATTRIB_FLAG_BIT_gl_vertex_attrib_value;
4972                         current_ctx->gl_vertex_array_size[index] = 0;
4973                         current_ctx->gl_vertex_array_integer[index] = GL_TRUE;
4974
4975                         current_ctx->gl_vertex_array_type[index] = GL_UNSIGNED_INT;
4976                         current_ctx->gl_vertex_attrib_value_unsigned_integer[index * 4 + 0] = x;
4977                         current_ctx->gl_vertex_attrib_value_unsigned_integer[index * 4 + 1] = y;
4978                         current_ctx->gl_vertex_attrib_value_unsigned_integer[index * 4 + 2] = z;
4979                         current_ctx->gl_vertex_attrib_value_unsigned_integer[index * 4 + 3] = w;
4980                 }
4981         }
4982         goto finish;
4983
4984 finish:
4985         _COREGL_FASTPATH_FUNC_END();
4986 }
4987
4988
4989 void
4990 fastpath_glVertexAttribI4iv(GLuint index, const GLint *v)
4991 {
4992         DEFINE_FASTPAH_GL_FUNC();
4993         _COREGL_FASTPATH_FUNC_BEGIN();
4994         INIT_FASTPATH_GL_FUNC();
4995
4996         IF_GL_SUCCESS(_orig_fastpath_glVertexAttribI4iv(index, v)) {
4997                 if (current_ctx->gl_vertex_array_binding[0] == 0) {
4998                         current_ctx->_vattrib_flag |= _VATTRIB_FLAG_BIT_gl_vertex_attrib_value;
4999                         current_ctx->gl_vertex_array_size[index] = 0;
5000                         current_ctx->gl_vertex_array_integer[index] = GL_TRUE;
5001
5002                         current_ctx->gl_vertex_array_type[index] = GL_INT;
5003                         current_ctx->gl_vertex_attrib_value_integer[index * 4 + 0] = v[0];
5004                         current_ctx->gl_vertex_attrib_value_integer[index * 4 + 1] = v[1];
5005                         current_ctx->gl_vertex_attrib_value_integer[index * 4 + 2] = v[2];
5006                         current_ctx->gl_vertex_attrib_value_integer[index * 4 + 3] = v[3];
5007                 }
5008         }
5009         goto finish;
5010
5011 finish:
5012         _COREGL_FASTPATH_FUNC_END();
5013 }
5014
5015
5016 void
5017 fastpath_glVertexAttribI4uiv(GLuint index, const GLuint *v)
5018 {
5019         DEFINE_FASTPAH_GL_FUNC();
5020         _COREGL_FASTPATH_FUNC_BEGIN();
5021         INIT_FASTPATH_GL_FUNC();
5022
5023         IF_GL_SUCCESS(_orig_fastpath_glVertexAttribI4uiv(index, v)) {
5024                 if (current_ctx->gl_vertex_array_binding[0] == 0) {
5025                         current_ctx->_vattrib_flag |= _VATTRIB_FLAG_BIT_gl_vertex_attrib_value;
5026                         current_ctx->gl_vertex_array_size[index] = 0;
5027                         current_ctx->gl_vertex_array_integer[index] = GL_TRUE;
5028
5029                         current_ctx->gl_vertex_array_type[index] = GL_UNSIGNED_INT;
5030                         current_ctx->gl_vertex_attrib_value_unsigned_integer[index * 4 + 0] = v[0];
5031                         current_ctx->gl_vertex_attrib_value_unsigned_integer[index * 4 + 1] = v[1];
5032                         current_ctx->gl_vertex_attrib_value_unsigned_integer[index * 4 + 2] = v[2];
5033                         current_ctx->gl_vertex_attrib_value_unsigned_integer[index * 4 + 3] = v[3];
5034                 }
5035         }
5036         goto finish;
5037
5038 finish:
5039         _COREGL_FASTPATH_FUNC_END();
5040 }
5041
5042
5043 void
5044 fastpath_glGetUniformuiv(GLuint program, GLint location, GLuint *params)
5045 {
5046         GLuint real_obj;
5047
5048         DEFINE_FASTPAH_GL_FUNC();
5049         _COREGL_FASTPATH_FUNC_BEGIN();
5050         INIT_FASTPATH_GL_FUNC();
5051
5052         if (GET_REAL_OBJ(GL_OBJECT_TYPE_PROGRAM, program, &real_obj) != 1) {
5053                 _set_gl_error(GL_INVALID_VALUE);
5054                 goto finish;
5055         }
5056
5057         _orig_fastpath_glGetUniformuiv(real_obj, location, params);
5058
5059         goto finish;
5060
5061 finish:
5062         _COREGL_FASTPATH_FUNC_END();
5063 }
5064
5065
5066 GLint
5067 fastpath_glGetFragDataLocation(GLuint program, const GLchar *name)
5068 {
5069         GLint ret = _COREGL_INT_INIT_VALUE;
5070         GLuint real_obj;
5071
5072         DEFINE_FASTPAH_GL_FUNC();
5073         _COREGL_FASTPATH_FUNC_BEGIN();
5074         INIT_FASTPATH_GL_FUNC();
5075
5076         if (GET_REAL_OBJ(GL_OBJECT_TYPE_PROGRAM, program, &real_obj) != 1) {
5077                 _set_gl_error(GL_INVALID_VALUE);
5078                 goto finish;
5079         }
5080
5081         ret = _orig_fastpath_glGetFragDataLocation(real_obj, name);
5082
5083         goto finish;
5084
5085 finish:
5086         _COREGL_FASTPATH_FUNC_END();
5087         return ret;
5088 }
5089
5090
5091 const GLubyte *
5092 fastpath_glGetStringi(GLenum name, GLuint index)
5093 {
5094         const char *ret = NULL;
5095
5096         DEFINE_FASTPAH_GL_FUNC();
5097         _COREGL_FASTPATH_FUNC_BEGIN();
5098         INIT_FASTPATH_GL_FUNC();
5099
5100         switch (name) {
5101         case GL_VERSION:
5102                 _set_gl_error(GL_INVALID_ENUM);
5103                 goto finish;
5104         case GL_EXTENSIONS:
5105                 _valid_extension_string();
5106                 if (index >= gl_extension_count) {
5107                         _set_gl_error(GL_INVALID_VALUE);
5108                         goto finish;
5109                 }
5110                 ret = string_each_extensions[index];
5111                 break;
5112         default:
5113                 IF_GL_SUCCESS(ret = (const char *)_orig_fastpath_glGetStringi(name, index)) {
5114                 }
5115                 else {
5116                         ret = NULL;
5117                 }
5118                 break;
5119         }
5120
5121         goto finish;
5122
5123 finish:
5124         _COREGL_FASTPATH_FUNC_END();
5125         return (const GLubyte *)ret;
5126 }
5127
5128
5129 void
5130 fastpath_glGetUniformIndices(GLuint program, GLsizei uniformCount,
5131                              const GLchar *const *uniformNames, GLuint *uniformIndices)
5132 {
5133         GLuint real_obj;
5134
5135         DEFINE_FASTPAH_GL_FUNC();
5136         _COREGL_FASTPATH_FUNC_BEGIN();
5137         INIT_FASTPATH_GL_FUNC();
5138
5139         if (GET_REAL_OBJ(GL_OBJECT_TYPE_PROGRAM, program, &real_obj) != 1) {
5140                 _set_gl_error(GL_INVALID_VALUE);
5141                 goto finish;
5142         }
5143
5144         _orig_fastpath_glGetUniformIndices(real_obj, uniformCount, uniformNames,
5145                                            uniformIndices);
5146
5147         goto finish;
5148
5149 finish:
5150         _COREGL_FASTPATH_FUNC_END();
5151 }
5152
5153
5154 void
5155 fastpath_glGetActiveUniformsiv(GLuint program, GLsizei uniformCount,
5156                                const GLuint *uniformIndices, GLenum pname, GLint *params)
5157 {
5158         GLuint real_obj;
5159
5160         DEFINE_FASTPAH_GL_FUNC();
5161         _COREGL_FASTPATH_FUNC_BEGIN();
5162         INIT_FASTPATH_GL_FUNC();
5163
5164         if (GET_REAL_OBJ(GL_OBJECT_TYPE_PROGRAM, program, &real_obj) != 1) {
5165                 _set_gl_error(GL_INVALID_VALUE);
5166                 goto finish;
5167         }
5168
5169         _orig_fastpath_glGetActiveUniformsiv(real_obj, uniformCount, uniformIndices,
5170                                              pname, params);
5171
5172         goto finish;
5173
5174 finish:
5175         _COREGL_FASTPATH_FUNC_END();
5176 }
5177
5178
5179 GLuint
5180 fastpath_glGetUniformBlockIndex(GLuint program, const GLchar *uniformBlockName)
5181 {
5182         GLuint ret = _COREGL_INT_INIT_VALUE;
5183         GLuint real_obj;
5184
5185         DEFINE_FASTPAH_GL_FUNC();
5186         _COREGL_FASTPATH_FUNC_BEGIN();
5187         INIT_FASTPATH_GL_FUNC();
5188
5189         if (GET_REAL_OBJ(GL_OBJECT_TYPE_PROGRAM, program, &real_obj) != 1) {
5190                 _set_gl_error(GL_INVALID_VALUE);
5191                 goto finish;
5192         }
5193
5194         ret = _orig_fastpath_glGetUniformBlockIndex(real_obj, uniformBlockName);
5195
5196         goto finish;
5197
5198 finish:
5199         _COREGL_FASTPATH_FUNC_END();
5200         return ret;
5201 }
5202
5203 void
5204 fastpath_glGetActiveUniformBlockiv(GLuint program, GLuint uniformBlockIndex,
5205                                    GLenum pname, GLint *params)
5206 {
5207         GLuint real_obj;
5208
5209         DEFINE_FASTPAH_GL_FUNC();
5210         _COREGL_FASTPATH_FUNC_BEGIN();
5211         INIT_FASTPATH_GL_FUNC();
5212
5213         if (GET_REAL_OBJ(GL_OBJECT_TYPE_PROGRAM, program, &real_obj) != 1) {
5214                 _set_gl_error(GL_INVALID_VALUE);
5215                 goto finish;
5216         }
5217
5218         _orig_fastpath_glGetActiveUniformBlockiv(real_obj, uniformBlockIndex, pname,
5219                         params);
5220
5221         goto finish;
5222
5223 finish:
5224         _COREGL_FASTPATH_FUNC_END();
5225 }
5226
5227 void
5228 fastpath_glGetActiveUniformBlockName(GLuint program, GLuint uniformBlockIndex,
5229                                      GLsizei bufSize, GLsizei *length, GLchar *uniformBlockName)
5230 {
5231         GLuint real_obj;
5232
5233         DEFINE_FASTPAH_GL_FUNC();
5234         _COREGL_FASTPATH_FUNC_BEGIN();
5235         INIT_FASTPATH_GL_FUNC();
5236
5237         if (GET_REAL_OBJ(GL_OBJECT_TYPE_PROGRAM, program, &real_obj) != 1) {
5238                 _set_gl_error(GL_INVALID_VALUE);
5239                 goto finish;
5240         }
5241
5242         _orig_fastpath_glGetActiveUniformBlockName(real_obj, uniformBlockIndex, bufSize,
5243                         length, uniformBlockName);
5244
5245         goto finish;
5246
5247 finish:
5248         _COREGL_FASTPATH_FUNC_END();
5249 }
5250
5251
5252 void
5253 fastpath_glUniformBlockBinding(GLuint program, GLuint uniformBlockIndex,
5254                                GLuint uniformBlockBinding)
5255 {
5256         GLuint real_obj;
5257
5258         DEFINE_FASTPAH_GL_FUNC();
5259         _COREGL_FASTPATH_FUNC_BEGIN();
5260         INIT_FASTPATH_GL_FUNC();
5261
5262         if (GET_REAL_OBJ(GL_OBJECT_TYPE_PROGRAM, program, &real_obj) != 1) {
5263                 _set_gl_error(GL_INVALID_VALUE);
5264                 goto finish;
5265         }
5266
5267         _orig_fastpath_glUniformBlockBinding(real_obj, uniformBlockIndex,
5268                                              uniformBlockBinding);
5269
5270         goto finish;
5271
5272 finish:
5273         _COREGL_FASTPATH_FUNC_END();
5274 }
5275
5276
5277 void
5278 fastpath_glGetInteger64v(GLenum pname, GLint64 *params)
5279 {
5280         DEFINE_FASTPAH_GL_FUNC();
5281         _COREGL_FASTPATH_FUNC_BEGIN();
5282         INIT_FASTPATH_GL_FUNC();
5283
5284         IF_GL_SUCCESS(_orig_fastpath_glGetInteger64v(pname, params)) {
5285                 _modify_get_value(pname, params, GL_INT, GL_TRUE);
5286         }
5287         goto finish;
5288
5289 finish:
5290         _COREGL_FASTPATH_FUNC_END();
5291 }
5292
5293
5294 void
5295 fastpath_glGetInteger64i_v(GLenum target, GLuint index, GLint64 *data)
5296 {
5297         DEFINE_FASTPAH_GL_FUNC();
5298         _COREGL_FASTPATH_FUNC_BEGIN();
5299         INIT_FASTPATH_GL_FUNC();
5300
5301         IF_GL_SUCCESS(_orig_fastpath_glGetInteger64i_v(target, index, data)) {
5302                 _modify_get_value(target, data, GL_INT, GL_TRUE);
5303         }
5304         goto finish;
5305
5306 finish:
5307         _COREGL_FASTPATH_FUNC_END();
5308 }
5309
5310
5311 ////////////////////////////////////////////////////////////////////////
5312
5313 void
5314 fastpath_glGenSamplers(GLsizei n, GLuint *samplers)
5315 {
5316         int i;
5317         GLuint *objid_array = NULL;
5318
5319         DEFINE_FASTPAH_GL_FUNC();
5320         _COREGL_FASTPATH_FUNC_BEGIN();
5321         INIT_FASTPATH_GL_FUNC();
5322
5323         if (n < 0) {
5324                 _set_gl_error(GL_INVALID_VALUE);
5325                 goto finish;
5326         }
5327         if (n == 0) goto finish;
5328         if (samplers == NULL) goto finish;
5329
5330         AST(current_ctx->ostate.shared != NULL);
5331
5332         objid_array = (GLuint *)calloc(1, sizeof(GLuint) * n);
5333
5334         IF_GL_SUCCESS(_orig_fastpath_glGenSamplers(n, objid_array)) {
5335                 for (i = 0; i < n; i++) {
5336                         samplers[i] = fastpath_ostate_create_object(&current_ctx->ostate,
5337                                         GL_OBJECT_TYPE_SAMPLER, objid_array[i]);
5338                 }
5339         }
5340
5341         goto finish;
5342
5343 finish:
5344         if (objid_array != NULL) {
5345                 free(objid_array);
5346                 objid_array = NULL;
5347         }
5348         _COREGL_FASTPATH_FUNC_END();
5349 }
5350
5351
5352 void
5353 fastpath_glBindSampler(GLuint unit, GLuint sampler)
5354 {
5355         GLuint real_obj;
5356
5357         DEFINE_FASTPAH_GL_FUNC();
5358         _COREGL_FASTPATH_FUNC_BEGIN();
5359         INIT_FASTPATH_GL_FUNC();
5360
5361         if (GET_REAL_OBJ(GL_OBJECT_TYPE_SAMPLER, sampler, &real_obj) != 1) {
5362                 _set_gl_error(GL_OUT_OF_MEMORY);
5363                 goto finish;
5364         }
5365
5366         _orig_fastpath_glBindSampler(unit, real_obj);
5367         goto finish;
5368
5369 finish:
5370         _COREGL_FASTPATH_FUNC_END();
5371 }
5372
5373
5374 GLboolean
5375 fastpath_glIsSampler(GLuint sampler)
5376 {
5377         GLboolean ret = GL_FALSE;
5378         GLuint real_obj;
5379
5380         DEFINE_FASTPAH_GL_FUNC();
5381         _COREGL_FASTPATH_FUNC_BEGIN();
5382         INIT_FASTPATH_GL_FUNC();
5383
5384         if (GET_REAL_OBJ(GL_OBJECT_TYPE_SAMPLER, sampler, &real_obj) != 1) {
5385                 ret = GL_FALSE;
5386                 goto finish;
5387         }
5388
5389         ret = _orig_fastpath_glIsSampler(real_obj);
5390
5391         goto finish;
5392
5393 finish:
5394         _COREGL_FASTPATH_FUNC_END();
5395         return ret;
5396 }
5397
5398
5399 void
5400 fastpath_glDeleteSamplers(GLsizei n, const GLuint *samplers)
5401 {
5402         int i;
5403         GLuint *objid_array = NULL;
5404
5405         DEFINE_FASTPAH_GL_FUNC();
5406         _COREGL_FASTPATH_FUNC_BEGIN();
5407         INIT_FASTPATH_GL_FUNC();
5408
5409         if (n < 0) {
5410                 _set_gl_error(GL_INVALID_VALUE);
5411                 goto finish;
5412         }
5413         if (n == 0) goto finish;
5414         if (samplers == NULL) goto finish;
5415
5416         AST(current_ctx->ostate.shared != NULL);
5417
5418         objid_array = (GLuint *)calloc(1, sizeof(GLuint) * n);
5419         {
5420                 int real_n = 0;
5421
5422                 for (i = 0; i < n; i++) {
5423                         int real_objid = _COREGL_INT_INIT_VALUE;
5424                         if (samplers[i] == 0) continue;
5425
5426                         real_objid = fastpath_ostate_get_object(&current_ctx->ostate,
5427                                                                 GL_OBJECT_TYPE_SAMPLER, samplers[i]);
5428                         if (real_objid == 0) continue;
5429
5430                         AST(fastpath_ostate_remove_object(&current_ctx->ostate, GL_OBJECT_TYPE_SAMPLER,
5431                                                           samplers[i]) == 1);
5432                         objid_array[real_n++] = real_objid;
5433                 }
5434
5435                 _orig_fastpath_glDeleteSamplers(real_n, objid_array);
5436         }
5437
5438         goto finish;
5439
5440 finish:
5441         if (objid_array != NULL) {
5442                 free(objid_array);
5443                 objid_array = NULL;
5444         }
5445         _COREGL_FASTPATH_FUNC_END();
5446 }
5447
5448 ////////////////////////////////////////////////////////////////////////
5449
5450
5451 void
5452 fastpath_glSamplerParameteri(GLuint sampler, GLenum pname, GLint param)
5453 {
5454         GLuint real_obj;
5455
5456         DEFINE_FASTPAH_GL_FUNC();
5457         _COREGL_FASTPATH_FUNC_BEGIN();
5458         INIT_FASTPATH_GL_FUNC();
5459
5460         if (GET_REAL_OBJ(GL_OBJECT_TYPE_SAMPLER, sampler, &real_obj) != 1) {
5461                 goto finish;
5462         }
5463
5464         _orig_fastpath_glSamplerParameteri(real_obj, pname, param);
5465
5466         goto finish;
5467
5468 finish:
5469         _COREGL_FASTPATH_FUNC_END();
5470 }
5471
5472 void
5473 fastpath_glSamplerParameteriv(GLuint sampler, GLenum pname, const GLint *param)
5474 {
5475         GLuint real_obj;
5476
5477         DEFINE_FASTPAH_GL_FUNC();
5478         _COREGL_FASTPATH_FUNC_BEGIN();
5479         INIT_FASTPATH_GL_FUNC();
5480
5481         if (GET_REAL_OBJ(GL_OBJECT_TYPE_SAMPLER, sampler, &real_obj) != 1) {
5482                 goto finish;
5483         }
5484
5485         _orig_fastpath_glSamplerParameteriv(real_obj, pname, param);
5486
5487         goto finish;
5488
5489 finish:
5490         _COREGL_FASTPATH_FUNC_END();
5491 }
5492
5493 void
5494 fastpath_glSamplerParameterf(GLuint sampler, GLenum pname, GLfloat param)
5495 {
5496         GLuint real_obj;
5497
5498         DEFINE_FASTPAH_GL_FUNC();
5499         _COREGL_FASTPATH_FUNC_BEGIN();
5500         INIT_FASTPATH_GL_FUNC();
5501
5502         if (GET_REAL_OBJ(GL_OBJECT_TYPE_SAMPLER, sampler, &real_obj) != 1) {
5503                 goto finish;
5504         }
5505
5506         _orig_fastpath_glSamplerParameterf(real_obj, pname, param);
5507
5508         goto finish;
5509
5510 finish:
5511         _COREGL_FASTPATH_FUNC_END();
5512 }
5513
5514 void
5515 fastpath_glSamplerParameterfv(GLuint sampler, GLenum pname,
5516                               const GLfloat *param)
5517 {
5518         GLuint real_obj;
5519
5520         DEFINE_FASTPAH_GL_FUNC();
5521         _COREGL_FASTPATH_FUNC_BEGIN();
5522         INIT_FASTPATH_GL_FUNC();
5523
5524         if (GET_REAL_OBJ(GL_OBJECT_TYPE_SAMPLER, sampler, &real_obj) != 1) {
5525                 goto finish;
5526         }
5527
5528         _orig_fastpath_glSamplerParameterfv(real_obj, pname, param);
5529
5530         goto finish;
5531
5532 finish:
5533         _COREGL_FASTPATH_FUNC_END();
5534 }
5535
5536 void
5537 fastpath_glGetSamplerParameteriv(GLuint sampler, GLenum pname, GLint *params)
5538 {
5539         GLuint real_obj;
5540
5541         DEFINE_FASTPAH_GL_FUNC();
5542         _COREGL_FASTPATH_FUNC_BEGIN();
5543         INIT_FASTPATH_GL_FUNC();
5544
5545         if (GET_REAL_OBJ(GL_OBJECT_TYPE_SAMPLER, sampler, &real_obj) != 1) {
5546                 goto finish;
5547         }
5548
5549         _orig_fastpath_glGetSamplerParameteriv(real_obj, pname, params);
5550
5551         goto finish;
5552
5553 finish:
5554         _COREGL_FASTPATH_FUNC_END();
5555 }
5556
5557 void
5558 fastpath_glGetSamplerParameterfv(GLuint sampler, GLenum pname, GLfloat *params)
5559 {
5560         GLuint real_obj;
5561
5562         DEFINE_FASTPAH_GL_FUNC();
5563         _COREGL_FASTPATH_FUNC_BEGIN();
5564         INIT_FASTPATH_GL_FUNC();
5565
5566         if (GET_REAL_OBJ(GL_OBJECT_TYPE_SAMPLER, sampler, &real_obj) != 1) {
5567                 goto finish;
5568         }
5569
5570         _orig_fastpath_glGetSamplerParameterfv(real_obj, pname, params);
5571
5572         goto finish;
5573
5574 finish:
5575         _COREGL_FASTPATH_FUNC_END();
5576 }
5577
5578
5579 void
5580 fastpath_glVertexAttribDivisor(GLuint index, GLuint divisor)
5581 {
5582         DEFINE_FASTPAH_GL_FUNC();
5583         _COREGL_FASTPATH_FUNC_BEGIN();
5584         INIT_FASTPATH_GL_FUNC();
5585
5586         IF_GL_SUCCESS(_orig_fastpath_glVertexAttribDivisor(index, divisor)) {
5587                 if (current_ctx->gl_vertex_array_binding[0] == 0) {
5588                         current_ctx->_vattrib_flag |= _VATTRIB_FLAG_BIT_gl_vertex_array;
5589                         current_ctx->gl_vertex_array_divisor[index] = divisor;
5590                 }
5591         }
5592         goto finish;
5593
5594 finish:
5595         _COREGL_FASTPATH_FUNC_END();
5596 }
5597
5598
5599 void
5600 fastpath_glProgramParameteri(GLuint program, GLenum pname, GLint value)
5601 {
5602         GLuint real_obj;
5603
5604         DEFINE_FASTPAH_GL_FUNC();
5605         _COREGL_FASTPATH_FUNC_BEGIN();
5606         INIT_FASTPATH_GL_FUNC();
5607
5608         if (GET_REAL_OBJ(GL_OBJECT_TYPE_PROGRAM, program, &real_obj) != 1) {
5609                 _set_gl_error(GL_INVALID_VALUE);
5610                 goto finish;
5611         }
5612
5613         _orig_fastpath_glProgramParameteri(real_obj, pname, value);
5614
5615         goto finish;
5616
5617 finish:
5618         _COREGL_FASTPATH_FUNC_END();
5619 }
5620
5621
5622 /* GLES3.1 API */
5623 GLuint
5624 fastpath_glCreateShaderProgramv(GLenum type,  GLsizei count,
5625                                 const GLchar *const *strings)
5626 {
5627         GLuint ret = 0;
5628         GLuint real_obj = 0;
5629
5630         DEFINE_FASTPAH_GL_FUNC();
5631         _COREGL_FASTPATH_FUNC_BEGIN();
5632         INIT_FASTPATH_GL_FUNC();
5633
5634         AST(current_ctx->ostate.shared != NULL);
5635
5636         real_obj = _orig_fastpath_glCreateShaderProgramv(type,  count,  strings);
5637         if (real_obj != 0) {
5638                 ret = fastpath_ostate_create_object(&current_ctx->ostate,
5639                                                     GL_OBJECT_TYPE_PROGRAM, real_obj);
5640
5641                 Program_object_attached_tag *poat = NULL;
5642                 poat = (Program_object_attached_tag *)calloc(1,
5643                                 sizeof(Program_object_attached_tag));
5644                 AST(poat != NULL);
5645
5646                 poat->is_deleting = 0;
5647                 poat->shader_count = 0;
5648
5649                 fastpath_ostate_set_object_tag(&current_ctx->ostate, GL_OBJECT_TYPE_PROGRAM,
5650                                                ret, poat);
5651         }
5652         _attach_program_object(&current_ctx->ostate, real_obj);
5653
5654         goto finish;
5655
5656 finish:
5657         _COREGL_FASTPATH_FUNC_END();
5658         return ret;
5659 }
5660
5661 void
5662 fastpath_glGenProgramPipelines( GLsizei n,  GLuint *pipelines)
5663 {
5664         int i;
5665         GLuint *objid_array = NULL;
5666
5667         DEFINE_FASTPAH_GL_FUNC();
5668         _COREGL_FASTPATH_FUNC_BEGIN();
5669         INIT_FASTPATH_GL_FUNC();
5670
5671         if (n < 0 || pipelines == NULL) {
5672                 _set_gl_error(GL_INVALID_VALUE);
5673                 goto finish;
5674         }
5675
5676         AST(current_ctx->ostate.shared != NULL);
5677
5678         objid_array = (GLuint *)calloc(1, sizeof(GLuint) * n);
5679
5680         IF_GL_SUCCESS(_orig_fastpath_glGenProgramPipelines(n, objid_array)) {
5681                 for (i = 0; i < n; i++) {
5682                         pipelines[i] = fastpath_ostate_create_object(&current_ctx->ostate,
5683                                         GL_OBJECT_TYPE_PROGRAMPIPELINE, objid_array[i]);
5684                 }
5685         }
5686
5687         goto finish;
5688
5689 finish:
5690         if (objid_array != NULL) {
5691                 free(objid_array);
5692                 objid_array = NULL;
5693         }
5694         _COREGL_FASTPATH_FUNC_END();
5695 }
5696
5697 void
5698 fastpath_glBindProgramPipeline( GLuint pipeline)
5699 {
5700         GLuint real_obj;
5701
5702         DEFINE_FASTPAH_GL_FUNC();
5703         _COREGL_FASTPATH_FUNC_BEGIN();
5704         INIT_FASTPATH_GL_FUNC();
5705
5706         if (GET_REAL_OBJ(GL_OBJECT_TYPE_PROGRAMPIPELINE, pipeline, &real_obj) != 1) {
5707                 _set_gl_error(GL_INVALID_OPERATION);
5708                 goto finish;
5709         }
5710
5711         if (current_ctx->gl_program_pipeline_binding[0] != real_obj) {
5712                 IF_GL_SUCCESS(_orig_fastpath_glBindProgramPipeline(real_obj)) {
5713                         current_ctx->_misc_flag3 |= _MISC_FLAG3_BIT_gl_program_pipeline_binding;
5714                         current_ctx->gl_program_pipeline_binding[0] = real_obj;
5715                 }
5716         }
5717
5718         goto finish;
5719
5720 finish:
5721         _COREGL_FASTPATH_FUNC_END();
5722 }
5723
5724 void
5725 fastpath_glGetProgramPipelineiv(GLuint pipeline, GLenum pname, GLint *params)
5726 {
5727         GLuint real_obj;
5728
5729         DEFINE_FASTPAH_GL_FUNC();
5730         _COREGL_FASTPATH_FUNC_BEGIN();
5731         INIT_FASTPATH_GL_FUNC();
5732
5733         if (params == NULL ||
5734             GET_REAL_OBJ(GL_OBJECT_TYPE_PROGRAMPIPELINE, pipeline, &real_obj) != 1) {
5735                 _set_gl_error(GL_INVALID_VALUE);
5736                 goto finish;
5737         }
5738
5739         switch (pname) {
5740         case GL_ACTIVE_PROGRAM:
5741         case GL_VERTEX_SHADER:
5742         case GL_FRAGMENT_SHADER:
5743         case GL_COMPUTE_SHADER:
5744         case GL_INFO_LOG_LENGTH:
5745         case GL_VALIDATE_STATUS:
5746                 _orig_fastpath_glGetProgramPipelineiv(real_obj, pname, params);
5747                 break;
5748         default:
5749                 _set_gl_error(GL_INVALID_ENUM);
5750                 break;
5751         }
5752
5753         goto finish;
5754
5755 finish:
5756         _COREGL_FASTPATH_FUNC_END();
5757 }
5758
5759 void
5760 fastpath_glDeleteProgramPipelines(GLsizei n, GLuint const *pipelines)
5761 {
5762         int i;
5763         GLuint *objid_array = NULL;
5764
5765         DEFINE_FASTPAH_GL_FUNC();
5766         _COREGL_FASTPATH_FUNC_BEGIN();
5767         INIT_FASTPATH_GL_FUNC();
5768
5769         if (n < 0 || pipelines == NULL) {
5770                 _set_gl_error(GL_INVALID_VALUE);
5771                 goto finish;
5772         }
5773
5774         if (n == 0)
5775                 goto finish;
5776
5777         AST(current_ctx->ostate.shared != NULL);
5778
5779         objid_array = (GLuint *)calloc(1, sizeof(GLuint) * n);
5780         {
5781                 int real_n = 0;
5782
5783                 for (i = 0; i < n; i++) {
5784                         int real_objid = _COREGL_INT_INIT_VALUE;
5785                         if (pipelines[i] == 0) continue;
5786
5787                         real_objid = fastpath_ostate_get_object(&current_ctx->ostate,
5788                                                                 GL_OBJECT_TYPE_PROGRAMPIPELINE, pipelines[i]);
5789                         if (real_objid == 0) continue;
5790
5791                         AST(fastpath_ostate_remove_object(&current_ctx->ostate,
5792                                                           GL_OBJECT_TYPE_PROGRAMPIPELINE, pipelines[i]) == 1);
5793                         objid_array[real_n++] = real_objid;
5794                 }
5795
5796                 IF_GL_SUCCESS(_orig_fastpath_glDeleteProgramPipelines(real_n, objid_array)) {
5797                         for (i = 0; i < real_n; i++) {
5798                                 General_Trace_List *current = NULL;
5799                                 current = current_ctx->ostate.shared->using_gctxs;
5800
5801                                 while (current != NULL) {
5802                                         GLGlueContext *cur_gctx = (GLGlueContext *)current->value;
5803
5804                                         if (cur_gctx->gl_program_pipeline_binding[0] == objid_array[i])
5805                                                 cur_gctx->gl_program_pipeline_binding[0] = 0;
5806
5807                                         current = current->next;
5808                                 }
5809                         }
5810                 }
5811         }
5812
5813         goto finish;
5814
5815 finish:
5816         if (objid_array != NULL) {
5817                 free(objid_array);
5818                 objid_array = NULL;
5819         }
5820         _COREGL_FASTPATH_FUNC_END();
5821 }
5822
5823 GLboolean
5824 fastpath_glIsProgramPipeline( GLuint pipeline)
5825 {
5826         GLboolean ret = GL_FALSE;
5827         GLuint real_obj;
5828
5829         DEFINE_FASTPAH_GL_FUNC();
5830         _COREGL_FASTPATH_FUNC_BEGIN();
5831         INIT_FASTPATH_GL_FUNC();
5832
5833         if (GET_REAL_OBJ(GL_OBJECT_TYPE_PROGRAMPIPELINE, pipeline, &real_obj) != 1) {
5834                 ret = GL_FALSE;
5835                 goto finish;
5836         }
5837
5838         ret = _orig_fastpath_glIsProgramPipeline(real_obj);
5839
5840         goto finish;
5841
5842 finish:
5843         _COREGL_FASTPATH_FUNC_END();
5844         return ret;
5845 }
5846
5847 void
5848 fastpath_glValidateProgramPipeline(GLuint pipeline)
5849 {
5850         GLuint real_obj;
5851
5852         DEFINE_FASTPAH_GL_FUNC();
5853         _COREGL_FASTPATH_FUNC_BEGIN();
5854         INIT_FASTPATH_GL_FUNC();
5855
5856         if (GET_REAL_OBJ(GL_OBJECT_TYPE_PROGRAMPIPELINE, pipeline, &real_obj) != 1) {
5857                 _set_gl_error(GL_INVALID_VALUE);
5858                 goto finish;
5859         }
5860
5861         _orig_fastpath_glValidateProgramPipeline(real_obj);
5862
5863         goto finish;
5864
5865 finish:
5866         _COREGL_FASTPATH_FUNC_END();
5867 }
5868
5869 void
5870 fastpath_glGetProgramPipelineInfoLog(GLuint pipeline, GLsizei bufSize,
5871                                      GLsizei *length, GLchar *infoLog)
5872 {
5873         GLuint real_obj;
5874
5875         DEFINE_FASTPAH_GL_FUNC();
5876         _COREGL_FASTPATH_FUNC_BEGIN();
5877         INIT_FASTPATH_GL_FUNC();
5878
5879         if (NULL == infoLog || bufSize < 0 ||
5880             GET_REAL_OBJ(GL_OBJECT_TYPE_PROGRAMPIPELINE, pipeline, &real_obj) != 1) {
5881                 _set_gl_error(GL_INVALID_VALUE);
5882                 goto finish;
5883         }
5884
5885         _orig_fastpath_glGetProgramPipelineInfoLog(real_obj, bufSize, length, infoLog);
5886
5887         goto finish;
5888
5889 finish:
5890         _COREGL_FASTPATH_FUNC_END();
5891 }
5892
5893 void
5894 fastpath_glDispatchCompute(GLuint num_groups_x, GLuint num_groups_y,
5895                            GLuint num_groups_z)
5896 {
5897         DEFINE_FASTPAH_GL_FUNC();
5898         _COREGL_FASTPATH_FUNC_BEGIN();
5899         INIT_FASTPATH_GL_FUNC();
5900
5901         if (num_groups_x > GL_MAX_COMPUTE_WORK_GROUP_COUNT ||
5902             num_groups_y > GL_MAX_COMPUTE_WORK_GROUP_COUNT ||
5903             num_groups_z > GL_MAX_COMPUTE_WORK_GROUP_COUNT) {
5904                 _set_gl_error(GL_INVALID_VALUE);
5905                 goto finish;
5906         }
5907
5908         if (num_groups_x == 0 || num_groups_y == 0 || num_groups_z == 0) {
5909                 goto finish;
5910         }
5911
5912         _orig_fastpath_glDispatchCompute(num_groups_x, num_groups_y, num_groups_z);
5913
5914 finish:
5915         _COREGL_FASTPATH_FUNC_END();
5916 }
5917
5918 void
5919 fastpath_glDispatchComputeIndirect( GLintptr indirect)
5920 {
5921         DEFINE_FASTPAH_GL_FUNC();
5922         _COREGL_FASTPATH_FUNC_BEGIN();
5923         INIT_FASTPATH_GL_FUNC();
5924
5925         if (indirect < 0 || (indirect % sizeof(GLuint)) != 0) {
5926                 _set_gl_error(GL_INVALID_VALUE);
5927                 goto finish;
5928         }
5929
5930         _orig_fastpath_glDispatchComputeIndirect(indirect);
5931
5932 finish:
5933         _COREGL_FASTPATH_FUNC_END();
5934 }
5935
5936 void
5937 fastpath_glGetProgramInterfaceiv(GLuint program,  GLenum programInterface,
5938                                  GLenum pname,  GLint *params)
5939 {
5940         GLuint real_obj;
5941
5942         DEFINE_FASTPAH_GL_FUNC();
5943         _COREGL_FASTPATH_FUNC_BEGIN();
5944         INIT_FASTPATH_GL_FUNC();
5945
5946         if (params == NULL ||
5947             GET_REAL_OBJ(GL_OBJECT_TYPE_PROGRAM, program, &real_obj) != 1) {
5948                 _set_gl_error(GL_INVALID_VALUE);
5949                 goto finish;
5950         }
5951
5952         _orig_fastpath_glGetProgramInterfaceiv(real_obj, programInterface, pname,
5953                                                params);
5954
5955         goto finish;
5956
5957 finish:
5958         _COREGL_FASTPATH_FUNC_END();
5959 }
5960
5961 GLuint
5962 fastpath_glGetProgramResourceIndex( GLuint program,  GLenum programInterface,
5963                                     const char *name)
5964 {
5965         GLuint real_obj;
5966         GLuint ret = GL_INVALID_INDEX;
5967
5968         DEFINE_FASTPAH_GL_FUNC();
5969         _COREGL_FASTPATH_FUNC_BEGIN();
5970         INIT_FASTPATH_GL_FUNC();
5971
5972         if (name == NULL ||
5973             GET_REAL_OBJ(GL_OBJECT_TYPE_PROGRAM, program, &real_obj) != 1) {
5974                 _set_gl_error(GL_INVALID_VALUE);
5975                 goto finish;
5976         }
5977
5978         ret = _orig_fastpath_glGetProgramResourceIndex(real_obj,  programInterface,
5979                         name);
5980
5981         goto finish;
5982
5983 finish:
5984         _COREGL_FASTPATH_FUNC_END();
5985         return ret;
5986 }
5987
5988 void
5989 fastpath_glGetProgramResourceName(GLuint program, GLenum programInterface,
5990                                   GLuint index, GLsizei bufSize, GLsizei *length, GLchar *name)
5991 {
5992         GLuint real_obj;
5993
5994         DEFINE_FASTPAH_GL_FUNC();
5995         _COREGL_FASTPATH_FUNC_BEGIN();
5996         INIT_FASTPATH_GL_FUNC();
5997
5998         if ((NULL == name && 0 != bufSize) || 0 > bufSize ||
5999             GET_REAL_OBJ(GL_OBJECT_TYPE_PROGRAM, program, &real_obj) != 1) {
6000                 _set_gl_error(GL_INVALID_VALUE);
6001                 goto finish;
6002         }
6003
6004         _orig_fastpath_glGetProgramResourceName(real_obj, programInterface, index,
6005                                                 bufSize, length, name);
6006
6007         goto finish;
6008
6009 finish:
6010         _COREGL_FASTPATH_FUNC_END();
6011 }
6012
6013 void
6014 fastpath_glGetProgramResourceiv( GLuint program,  GLenum programInterface,
6015                                  GLuint index,  GLsizei propCount,  const GLenum *props,  GLsizei bufSize,
6016                                  GLsizei *length,  GLint *params)
6017 {
6018         GLuint real_obj;
6019
6020         DEFINE_FASTPAH_GL_FUNC();
6021         _COREGL_FASTPATH_FUNC_BEGIN();
6022         INIT_FASTPATH_GL_FUNC();
6023
6024         if (0 > bufSize || 0 >= propCount || NULL == props || ((NULL == params &&
6025                         0 < bufSize)) ||
6026             GET_REAL_OBJ(GL_OBJECT_TYPE_PROGRAM, program, &real_obj) != 1) {
6027                 _set_gl_error(GL_INVALID_VALUE);
6028                 goto finish;
6029         }
6030
6031         _orig_fastpath_glGetProgramResourceiv(real_obj,  programInterface,  index,
6032                                               propCount,  props,  bufSize,  length,  params);
6033
6034         goto finish;
6035
6036 finish:
6037         _COREGL_FASTPATH_FUNC_END();
6038 }
6039
6040 GLint
6041 fastpath_glGetProgramResourceLocation(GLuint program, GLenum programInterface,
6042                                       GLchar const *name)
6043 {
6044         GLuint real_obj;
6045         GLuint ret = -1;
6046
6047         DEFINE_FASTPAH_GL_FUNC();
6048         _COREGL_FASTPATH_FUNC_BEGIN();
6049         INIT_FASTPATH_GL_FUNC();
6050
6051         if (name == NULL ||
6052             GET_REAL_OBJ(GL_OBJECT_TYPE_PROGRAM, program, &real_obj) != 1) {
6053                 _set_gl_error(GL_INVALID_VALUE);
6054                 goto finish;
6055         }
6056
6057         ret = _orig_fastpath_glGetProgramResourceLocation(real_obj, programInterface,
6058                         name);
6059
6060         goto finish;
6061
6062 finish:
6063         _COREGL_FASTPATH_FUNC_END();
6064         return ret;
6065 }
6066
6067 void
6068 fastpath_glUseProgramStages(GLuint pipeline, GLbitfield stages, GLuint program)
6069 {
6070         GLuint real_obj;
6071
6072         DEFINE_FASTPAH_GL_FUNC();
6073         _COREGL_FASTPATH_FUNC_BEGIN();
6074         INIT_FASTPATH_GL_FUNC();
6075
6076         if (GET_REAL_OBJ(GL_OBJECT_TYPE_PROGRAM, program, &real_obj) != 1) {
6077                 _set_gl_error(GL_INVALID_VALUE);
6078                 goto finish;
6079         }
6080
6081         _orig_fastpath_glUseProgramStages(pipeline, stages, real_obj);
6082
6083         goto finish;
6084
6085 finish:
6086         _COREGL_FASTPATH_FUNC_END();
6087 }
6088
6089 void
6090 fastpath_glActiveShaderProgram(GLuint pipeline, GLuint program)
6091 {
6092         GLuint real_obj;
6093
6094         DEFINE_FASTPAH_GL_FUNC();
6095         _COREGL_FASTPATH_FUNC_BEGIN();
6096         INIT_FASTPATH_GL_FUNC();
6097
6098         if (GET_REAL_OBJ(GL_OBJECT_TYPE_PROGRAM, program, &real_obj) != 1) {
6099                 _set_gl_error(GL_INVALID_VALUE);
6100                 goto finish;
6101         }
6102
6103         _orig_fastpath_glActiveShaderProgram(pipeline, real_obj);
6104
6105         goto finish;
6106
6107 finish:
6108         _COREGL_FASTPATH_FUNC_END();
6109 }
6110
6111 void
6112 fastpath_glProgramUniform1iv(GLuint program, GLint location, GLsizei count,
6113                              const GLint *value)
6114 {
6115         GLuint real_obj;
6116
6117         DEFINE_FASTPAH_GL_FUNC();
6118         _COREGL_FASTPATH_FUNC_BEGIN();
6119         INIT_FASTPATH_GL_FUNC();
6120
6121         if (GET_REAL_OBJ(GL_OBJECT_TYPE_PROGRAM, program, &real_obj) != 1) {
6122                 _set_gl_error(GL_INVALID_VALUE);
6123                 goto finish;
6124         }
6125
6126         _orig_fastpath_glProgramUniform1iv(real_obj, location, count, value);
6127
6128         goto finish;
6129
6130 finish:
6131         _COREGL_FASTPATH_FUNC_END();
6132 }
6133
6134
6135 void
6136 fastpath_glProgramUniform2iv(GLuint program, GLint location, GLsizei count,
6137                              const GLint *value)
6138 {
6139         GLuint real_obj;
6140
6141         DEFINE_FASTPAH_GL_FUNC();
6142         _COREGL_FASTPATH_FUNC_BEGIN();
6143         INIT_FASTPATH_GL_FUNC();
6144
6145         if (GET_REAL_OBJ(GL_OBJECT_TYPE_PROGRAM, program, &real_obj) != 1) {
6146                 _set_gl_error(GL_INVALID_VALUE);
6147                 goto finish;
6148         }
6149
6150         _orig_fastpath_glProgramUniform2iv(real_obj, location, count, value);
6151
6152         goto finish;
6153
6154 finish:
6155         _COREGL_FASTPATH_FUNC_END();
6156 }
6157
6158
6159 void
6160 fastpath_glProgramUniform3iv(GLuint program, GLint location, GLsizei count,
6161                              const GLint *value)
6162 {
6163         GLuint real_obj;
6164
6165         DEFINE_FASTPAH_GL_FUNC();
6166         _COREGL_FASTPATH_FUNC_BEGIN();
6167         INIT_FASTPATH_GL_FUNC();
6168
6169         if (GET_REAL_OBJ(GL_OBJECT_TYPE_PROGRAM, program, &real_obj) != 1) {
6170                 _set_gl_error(GL_INVALID_VALUE);
6171                 goto finish;
6172         }
6173
6174         _orig_fastpath_glProgramUniform3iv(real_obj, location, count, value);
6175
6176         goto finish;
6177
6178 finish:
6179         _COREGL_FASTPATH_FUNC_END();
6180 }
6181
6182
6183 void
6184 fastpath_glProgramUniform4iv(GLuint program, GLint location, GLsizei count,
6185                              const GLint *value)
6186 {
6187         GLuint real_obj;
6188
6189         DEFINE_FASTPAH_GL_FUNC();
6190         _COREGL_FASTPATH_FUNC_BEGIN();
6191         INIT_FASTPATH_GL_FUNC();
6192
6193         if (GET_REAL_OBJ(GL_OBJECT_TYPE_PROGRAM, program, &real_obj) != 1) {
6194                 _set_gl_error(GL_INVALID_VALUE);
6195                 goto finish;
6196         }
6197
6198         _orig_fastpath_glProgramUniform4iv(real_obj, location, count, value);
6199
6200         goto finish;
6201
6202 finish:
6203         _COREGL_FASTPATH_FUNC_END();
6204 }
6205
6206
6207
6208 void
6209 fastpath_glProgramUniform1fv(GLuint program, GLint location, GLsizei count,
6210                              const GLfloat *value)
6211 {
6212         GLuint real_obj;
6213
6214         DEFINE_FASTPAH_GL_FUNC();
6215         _COREGL_FASTPATH_FUNC_BEGIN();
6216         INIT_FASTPATH_GL_FUNC();
6217
6218         if (GET_REAL_OBJ(GL_OBJECT_TYPE_PROGRAM, program, &real_obj) != 1) {
6219                 _set_gl_error(GL_INVALID_VALUE);
6220                 goto finish;
6221         }
6222
6223         _orig_fastpath_glProgramUniform1fv(real_obj, location, count, value);
6224
6225         goto finish;
6226
6227 finish:
6228         _COREGL_FASTPATH_FUNC_END();
6229 }
6230
6231
6232 void
6233 fastpath_glProgramUniform2fv(GLuint program, GLint location, GLsizei count,
6234                              const GLfloat *value)
6235 {
6236         GLuint real_obj;
6237
6238         DEFINE_FASTPAH_GL_FUNC();
6239         _COREGL_FASTPATH_FUNC_BEGIN();
6240         INIT_FASTPATH_GL_FUNC();
6241
6242         if (GET_REAL_OBJ(GL_OBJECT_TYPE_PROGRAM, program, &real_obj) != 1) {
6243                 _set_gl_error(GL_INVALID_VALUE);
6244                 goto finish;
6245         }
6246
6247         _orig_fastpath_glProgramUniform2fv(real_obj, location, count, value);
6248
6249         goto finish;
6250
6251 finish:
6252         _COREGL_FASTPATH_FUNC_END();
6253 }
6254
6255
6256 void
6257 fastpath_glProgramUniform3fv(GLuint program, GLint location, GLsizei count,
6258                              const GLfloat *value)
6259 {
6260         GLuint real_obj;
6261
6262         DEFINE_FASTPAH_GL_FUNC();
6263         _COREGL_FASTPATH_FUNC_BEGIN();
6264         INIT_FASTPATH_GL_FUNC();
6265
6266         if (GET_REAL_OBJ(GL_OBJECT_TYPE_PROGRAM, program, &real_obj) != 1) {
6267                 _set_gl_error(GL_INVALID_VALUE);
6268                 goto finish;
6269         }
6270
6271         _orig_fastpath_glProgramUniform3fv(real_obj, location, count, value);
6272
6273         goto finish;
6274
6275 finish:
6276         _COREGL_FASTPATH_FUNC_END();
6277 }
6278
6279
6280 void
6281 fastpath_glProgramUniform4fv(GLuint program, GLint location, GLsizei count,
6282                              const GLfloat *value)
6283 {
6284         GLuint real_obj;
6285
6286         DEFINE_FASTPAH_GL_FUNC();
6287         _COREGL_FASTPATH_FUNC_BEGIN();
6288         INIT_FASTPATH_GL_FUNC();
6289
6290         if (GET_REAL_OBJ(GL_OBJECT_TYPE_PROGRAM, program, &real_obj) != 1) {
6291                 _set_gl_error(GL_INVALID_VALUE);
6292                 goto finish;
6293         }
6294
6295         _orig_fastpath_glProgramUniform4fv(real_obj, location, count, value);
6296
6297         goto finish;
6298
6299 finish:
6300         _COREGL_FASTPATH_FUNC_END();
6301 }
6302
6303 void
6304 fastpath_glProgramUniformMatrix2fv(GLuint program, GLint location,
6305                                    GLsizei count, GLboolean transpose, const GLfloat *value)
6306 {
6307         GLuint real_obj;
6308
6309         DEFINE_FASTPAH_GL_FUNC();
6310         _COREGL_FASTPATH_FUNC_BEGIN();
6311         INIT_FASTPATH_GL_FUNC();
6312
6313         if (GET_REAL_OBJ(GL_OBJECT_TYPE_PROGRAM, program, &real_obj) != 1) {
6314                 _set_gl_error(GL_INVALID_VALUE);
6315                 goto finish;
6316         }
6317
6318         _orig_fastpath_glProgramUniformMatrix2fv(real_obj, location, count, transpose,
6319                         value);
6320
6321         goto finish;
6322
6323 finish:
6324         _COREGL_FASTPATH_FUNC_END();
6325 }
6326
6327
6328 void
6329 fastpath_glProgramUniformMatrix3fv(GLuint program, GLint location,
6330                                    GLsizei count, GLboolean transpose, const GLfloat *value)
6331 {
6332         GLuint real_obj;
6333
6334         DEFINE_FASTPAH_GL_FUNC();
6335         _COREGL_FASTPATH_FUNC_BEGIN();
6336         INIT_FASTPATH_GL_FUNC();
6337
6338         if (GET_REAL_OBJ(GL_OBJECT_TYPE_PROGRAM, program, &real_obj) != 1) {
6339                 _set_gl_error(GL_INVALID_VALUE);
6340                 goto finish;
6341         }
6342
6343         _orig_fastpath_glProgramUniformMatrix3fv(real_obj, location, count, transpose,
6344                         value);
6345
6346         goto finish;
6347
6348 finish:
6349         _COREGL_FASTPATH_FUNC_END();
6350 }
6351
6352
6353 void
6354 fastpath_glProgramUniformMatrix4fv(GLuint program, GLint location,
6355                                    GLsizei count, GLboolean transpose, const GLfloat *value)
6356 {
6357         GLuint real_obj;
6358
6359         DEFINE_FASTPAH_GL_FUNC();
6360         _COREGL_FASTPATH_FUNC_BEGIN();
6361         INIT_FASTPATH_GL_FUNC();
6362
6363         if (GET_REAL_OBJ(GL_OBJECT_TYPE_PROGRAM, program, &real_obj) != 1) {
6364                 _set_gl_error(GL_INVALID_VALUE);
6365                 goto finish;
6366         }
6367
6368         _orig_fastpath_glProgramUniformMatrix4fv(real_obj, location, count, transpose,
6369                         value);
6370
6371         goto finish;
6372
6373 finish:
6374         _COREGL_FASTPATH_FUNC_END();
6375 }
6376
6377
6378 void
6379 fastpath_glProgramUniform1i(GLuint program, GLint location, GLint x)
6380 {
6381         GLuint real_obj;
6382
6383         DEFINE_FASTPAH_GL_FUNC();
6384         _COREGL_FASTPATH_FUNC_BEGIN();
6385         INIT_FASTPATH_GL_FUNC();
6386
6387         if (GET_REAL_OBJ(GL_OBJECT_TYPE_PROGRAM, program, &real_obj) != 1) {
6388                 _set_gl_error(GL_INVALID_VALUE);
6389                 goto finish;
6390         }
6391
6392         _orig_fastpath_glProgramUniform1i(real_obj, location, x);
6393
6394         goto finish;
6395
6396 finish:
6397         _COREGL_FASTPATH_FUNC_END();
6398 }
6399
6400
6401 void
6402 fastpath_glProgramUniform2i(GLuint program, GLint location, GLint x, GLint y)
6403 {
6404         GLuint real_obj;
6405
6406         DEFINE_FASTPAH_GL_FUNC();
6407         _COREGL_FASTPATH_FUNC_BEGIN();
6408         INIT_FASTPATH_GL_FUNC();
6409
6410         if (GET_REAL_OBJ(GL_OBJECT_TYPE_PROGRAM, program, &real_obj) != 1) {
6411                 _set_gl_error(GL_INVALID_VALUE);
6412                 goto finish;
6413         }
6414
6415         _orig_fastpath_glProgramUniform2i(real_obj, location, x, y);
6416
6417         goto finish;
6418
6419 finish:
6420         _COREGL_FASTPATH_FUNC_END();
6421 }
6422
6423
6424 void
6425 fastpath_glProgramUniform3i(GLuint program, GLint location, GLint x, GLint y,
6426                             GLint z)
6427 {
6428         GLuint real_obj;
6429
6430         DEFINE_FASTPAH_GL_FUNC();
6431         _COREGL_FASTPATH_FUNC_BEGIN();
6432         INIT_FASTPATH_GL_FUNC();
6433
6434         if (GET_REAL_OBJ(GL_OBJECT_TYPE_PROGRAM, program, &real_obj) != 1) {
6435                 _set_gl_error(GL_INVALID_VALUE);
6436                 goto finish;
6437         }
6438
6439         _orig_fastpath_glProgramUniform3i(real_obj, location, x, y, z);
6440
6441         goto finish;
6442
6443 finish:
6444         _COREGL_FASTPATH_FUNC_END();
6445 }
6446
6447
6448 void
6449 fastpath_glProgramUniform4i(GLuint program, GLint location, GLint x, GLint y,
6450                             GLint z, GLint w)
6451 {
6452         GLuint real_obj;
6453
6454         DEFINE_FASTPAH_GL_FUNC();
6455         _COREGL_FASTPATH_FUNC_BEGIN();
6456         INIT_FASTPATH_GL_FUNC();
6457
6458         if (GET_REAL_OBJ(GL_OBJECT_TYPE_PROGRAM, program, &real_obj) != 1) {
6459                 _set_gl_error(GL_INVALID_VALUE);
6460                 goto finish;
6461         }
6462
6463         _orig_fastpath_glProgramUniform4i(real_obj, location, x, y, z, w);
6464
6465         goto finish;
6466
6467 finish:
6468         _COREGL_FASTPATH_FUNC_END();
6469 }
6470
6471
6472 void
6473 fastpath_glProgramUniform1f(GLuint program, GLint location, GLfloat x)
6474 {
6475         GLuint real_obj;
6476
6477         DEFINE_FASTPAH_GL_FUNC();
6478         _COREGL_FASTPATH_FUNC_BEGIN();
6479         INIT_FASTPATH_GL_FUNC();
6480
6481         if (GET_REAL_OBJ(GL_OBJECT_TYPE_PROGRAM, program, &real_obj) != 1) {
6482                 _set_gl_error(GL_INVALID_VALUE);
6483                 goto finish;
6484         }
6485
6486         _orig_fastpath_glProgramUniform1f(real_obj, location, x);
6487
6488         goto finish;
6489
6490 finish:
6491         _COREGL_FASTPATH_FUNC_END();
6492 }
6493
6494
6495 void
6496 fastpath_glProgramUniform2f(GLuint program, GLint location, GLfloat x,
6497                             GLfloat y)
6498 {
6499         GLuint real_obj;
6500
6501         DEFINE_FASTPAH_GL_FUNC();
6502         _COREGL_FASTPATH_FUNC_BEGIN();
6503         INIT_FASTPATH_GL_FUNC();
6504
6505         if (GET_REAL_OBJ(GL_OBJECT_TYPE_PROGRAM, program, &real_obj) != 1) {
6506                 _set_gl_error(GL_INVALID_VALUE);
6507                 goto finish;
6508         }
6509
6510         _orig_fastpath_glProgramUniform2f(real_obj, location, x, y);
6511
6512         goto finish;
6513
6514 finish:
6515         _COREGL_FASTPATH_FUNC_END();
6516 }
6517
6518
6519 void
6520 fastpath_glProgramUniform3f(GLuint program, GLint location, GLfloat x,
6521                             GLfloat y, GLfloat z)
6522 {
6523         GLuint real_obj;
6524
6525         DEFINE_FASTPAH_GL_FUNC();
6526         _COREGL_FASTPATH_FUNC_BEGIN();
6527         INIT_FASTPATH_GL_FUNC();
6528
6529         if (GET_REAL_OBJ(GL_OBJECT_TYPE_PROGRAM, program, &real_obj) != 1) {
6530                 _set_gl_error(GL_INVALID_VALUE);
6531                 goto finish;
6532         }
6533
6534         _orig_fastpath_glProgramUniform3f(real_obj, location, x, y, z);
6535
6536         goto finish;
6537
6538 finish:
6539         _COREGL_FASTPATH_FUNC_END();
6540 }
6541
6542
6543 void
6544 fastpath_glProgramUniform4f(GLuint program, GLint location, GLfloat x,
6545                             GLfloat y, GLfloat z, GLfloat w)
6546 {
6547         GLuint real_obj;
6548
6549         DEFINE_FASTPAH_GL_FUNC();
6550         _COREGL_FASTPATH_FUNC_BEGIN();
6551         INIT_FASTPATH_GL_FUNC();
6552
6553         if (GET_REAL_OBJ(GL_OBJECT_TYPE_PROGRAM, program, &real_obj) != 1) {
6554                 _set_gl_error(GL_INVALID_VALUE);
6555                 goto finish;
6556         }
6557
6558         _orig_fastpath_glProgramUniform4f(real_obj, location, x, y, z, w);
6559
6560         goto finish;
6561
6562 finish:
6563         _COREGL_FASTPATH_FUNC_END();
6564 }
6565
6566 void
6567 fastpath_glProgramUniform1ui(GLuint program, GLint location, GLuint x)
6568 {
6569         GLuint real_obj;
6570
6571         DEFINE_FASTPAH_GL_FUNC();
6572         _COREGL_FASTPATH_FUNC_BEGIN();
6573         INIT_FASTPATH_GL_FUNC();
6574
6575         if (GET_REAL_OBJ(GL_OBJECT_TYPE_PROGRAM, program, &real_obj) != 1) {
6576                 _set_gl_error(GL_INVALID_VALUE);
6577                 goto finish;
6578         }
6579
6580         _orig_fastpath_glProgramUniform1ui(real_obj, location, x);
6581
6582         goto finish;
6583
6584 finish:
6585         _COREGL_FASTPATH_FUNC_END();
6586 }
6587
6588
6589 void
6590 fastpath_glProgramUniform2ui(GLuint program, GLint location, GLuint x, GLuint y)
6591 {
6592         GLuint real_obj;
6593
6594         DEFINE_FASTPAH_GL_FUNC();
6595         _COREGL_FASTPATH_FUNC_BEGIN();
6596         INIT_FASTPATH_GL_FUNC();
6597
6598         if (GET_REAL_OBJ(GL_OBJECT_TYPE_PROGRAM, program, &real_obj) != 1) {
6599                 _set_gl_error(GL_INVALID_VALUE);
6600                 goto finish;
6601         }
6602
6603         _orig_fastpath_glProgramUniform2ui(real_obj, location, x, y);
6604
6605         goto finish;
6606
6607 finish:
6608         _COREGL_FASTPATH_FUNC_END();
6609 }
6610
6611
6612 void
6613 fastpath_glProgramUniform3ui(GLuint program, GLint location, GLuint x, GLuint y,
6614                              GLuint z)
6615 {
6616         GLuint real_obj;
6617
6618         DEFINE_FASTPAH_GL_FUNC();
6619         _COREGL_FASTPATH_FUNC_BEGIN();
6620         INIT_FASTPATH_GL_FUNC();
6621
6622         if (GET_REAL_OBJ(GL_OBJECT_TYPE_PROGRAM, program, &real_obj) != 1) {
6623                 _set_gl_error(GL_INVALID_VALUE);
6624                 goto finish;
6625         }
6626
6627         _orig_fastpath_glProgramUniform3ui(real_obj, location, x, y, z);
6628
6629         goto finish;
6630
6631 finish:
6632         _COREGL_FASTPATH_FUNC_END();
6633 }
6634
6635
6636 void
6637 fastpath_glProgramUniform4ui(GLuint program, GLint location, GLuint x, GLuint y,
6638                              GLuint z, GLuint w)
6639 {
6640         GLuint real_obj;
6641
6642         DEFINE_FASTPAH_GL_FUNC();
6643         _COREGL_FASTPATH_FUNC_BEGIN();
6644         INIT_FASTPATH_GL_FUNC();
6645
6646         if (GET_REAL_OBJ(GL_OBJECT_TYPE_PROGRAM, program, &real_obj) != 1) {
6647                 _set_gl_error(GL_INVALID_VALUE);
6648                 goto finish;
6649         }
6650
6651         _orig_fastpath_glProgramUniform4ui(real_obj, location, x, y, z, w);
6652
6653         goto finish;
6654
6655 finish:
6656         _COREGL_FASTPATH_FUNC_END();
6657 }
6658
6659 void
6660 fastpath_glProgramUniform1uiv(GLuint program, GLint location, GLsizei count,
6661                               const GLuint *value)
6662 {
6663         GLuint real_obj;
6664
6665         DEFINE_FASTPAH_GL_FUNC();
6666         _COREGL_FASTPATH_FUNC_BEGIN();
6667         INIT_FASTPATH_GL_FUNC();
6668
6669         if (GET_REAL_OBJ(GL_OBJECT_TYPE_PROGRAM, program, &real_obj) != 1) {
6670                 _set_gl_error(GL_INVALID_VALUE);
6671                 goto finish;
6672         }
6673
6674         _orig_fastpath_glProgramUniform1uiv(real_obj, location, count, value);
6675
6676         goto finish;
6677
6678 finish:
6679         _COREGL_FASTPATH_FUNC_END();
6680 }
6681
6682
6683 void
6684 fastpath_glProgramUniform2uiv(GLuint program, GLint location, GLsizei count,
6685                               const GLuint *value)
6686 {
6687         GLuint real_obj;
6688
6689         DEFINE_FASTPAH_GL_FUNC();
6690         _COREGL_FASTPATH_FUNC_BEGIN();
6691         INIT_FASTPATH_GL_FUNC();
6692
6693         if (GET_REAL_OBJ(GL_OBJECT_TYPE_PROGRAM, program, &real_obj) != 1) {
6694                 _set_gl_error(GL_INVALID_VALUE);
6695                 goto finish;
6696         }
6697
6698         _orig_fastpath_glProgramUniform2uiv(real_obj, location, count, value);
6699
6700         goto finish;
6701
6702 finish:
6703         _COREGL_FASTPATH_FUNC_END();
6704 }
6705
6706
6707 void
6708 fastpath_glProgramUniform3uiv(GLuint program, GLint location, GLsizei count,
6709                               const GLuint *value)
6710 {
6711         GLuint real_obj;
6712
6713         DEFINE_FASTPAH_GL_FUNC();
6714         _COREGL_FASTPATH_FUNC_BEGIN();
6715         INIT_FASTPATH_GL_FUNC();
6716
6717         if (GET_REAL_OBJ(GL_OBJECT_TYPE_PROGRAM, program, &real_obj) != 1) {
6718                 _set_gl_error(GL_INVALID_VALUE);
6719                 goto finish;
6720         }
6721
6722         _orig_fastpath_glProgramUniform3uiv(real_obj, location, count, value);
6723
6724         goto finish;
6725
6726 finish:
6727         _COREGL_FASTPATH_FUNC_END();
6728 }
6729
6730
6731 void
6732 fastpath_glProgramUniform4uiv(GLuint program, GLint location, GLsizei count,
6733                               const GLuint *value)
6734 {
6735         GLuint real_obj;
6736
6737         DEFINE_FASTPAH_GL_FUNC();
6738         _COREGL_FASTPATH_FUNC_BEGIN();
6739         INIT_FASTPATH_GL_FUNC();
6740
6741         if (GET_REAL_OBJ(GL_OBJECT_TYPE_PROGRAM, program, &real_obj) != 1) {
6742                 _set_gl_error(GL_INVALID_VALUE);
6743                 goto finish;
6744         }
6745
6746         _orig_fastpath_glProgramUniform4uiv(real_obj, location, count, value);
6747
6748         goto finish;
6749
6750 finish:
6751         _COREGL_FASTPATH_FUNC_END();
6752 }
6753
6754 void
6755 fastpath_glProgramUniformMatrix2x3fv(GLuint program, GLint location,
6756                                      GLsizei count, GLboolean transpose, const GLfloat *value)
6757 {
6758         GLuint real_obj;
6759
6760         DEFINE_FASTPAH_GL_FUNC();
6761         _COREGL_FASTPATH_FUNC_BEGIN();
6762         INIT_FASTPATH_GL_FUNC();
6763
6764         if (GET_REAL_OBJ(GL_OBJECT_TYPE_PROGRAM, program, &real_obj) != 1) {
6765                 _set_gl_error(GL_INVALID_VALUE);
6766                 goto finish;
6767         }
6768
6769         _orig_fastpath_glProgramUniformMatrix2x3fv(real_obj, location, count, transpose,
6770                         value);
6771
6772         goto finish;
6773
6774 finish:
6775         _COREGL_FASTPATH_FUNC_END();
6776 }
6777
6778
6779 void
6780 fastpath_glProgramUniformMatrix3x2fv(GLuint program, GLint location,
6781                                      GLsizei count, GLboolean transpose, const GLfloat *value)
6782 {
6783         GLuint real_obj;
6784
6785         DEFINE_FASTPAH_GL_FUNC();
6786         _COREGL_FASTPATH_FUNC_BEGIN();
6787         INIT_FASTPATH_GL_FUNC();
6788
6789         if (GET_REAL_OBJ(GL_OBJECT_TYPE_PROGRAM, program, &real_obj) != 1) {
6790                 _set_gl_error(GL_INVALID_VALUE);
6791                 goto finish;
6792         }
6793
6794         _orig_fastpath_glProgramUniformMatrix3x2fv(real_obj, location, count, transpose,
6795                         value);
6796
6797         goto finish;
6798
6799 finish:
6800         _COREGL_FASTPATH_FUNC_END();
6801 }
6802
6803
6804 void
6805 fastpath_glProgramUniformMatrix4x2fv(GLuint program, GLint location,
6806                                      GLsizei count, GLboolean transpose, const GLfloat *value)
6807 {
6808         GLuint real_obj;
6809
6810         DEFINE_FASTPAH_GL_FUNC();
6811         _COREGL_FASTPATH_FUNC_BEGIN();
6812         INIT_FASTPATH_GL_FUNC();
6813
6814         if (GET_REAL_OBJ(GL_OBJECT_TYPE_PROGRAM, program, &real_obj) != 1) {
6815                 _set_gl_error(GL_INVALID_VALUE);
6816                 goto finish;
6817         }
6818
6819         _orig_fastpath_glProgramUniformMatrix4x2fv(real_obj, location, count, transpose,
6820                         value);
6821
6822         goto finish;
6823
6824 finish:
6825         _COREGL_FASTPATH_FUNC_END();
6826 }
6827
6828 void
6829 fastpath_glProgramUniformMatrix2x4fv(GLuint program, GLint location,
6830                                      GLsizei count, GLboolean transpose, const GLfloat *value)
6831 {
6832         GLuint real_obj;
6833
6834         DEFINE_FASTPAH_GL_FUNC();
6835         _COREGL_FASTPATH_FUNC_BEGIN();
6836         INIT_FASTPATH_GL_FUNC();
6837
6838         if (GET_REAL_OBJ(GL_OBJECT_TYPE_PROGRAM, program, &real_obj) != 1) {
6839                 _set_gl_error(GL_INVALID_VALUE);
6840                 goto finish;
6841         }
6842
6843         _orig_fastpath_glProgramUniformMatrix2x4fv(real_obj, location, count, transpose,
6844                         value);
6845
6846         goto finish;
6847
6848 finish:
6849         _COREGL_FASTPATH_FUNC_END();
6850 }
6851
6852
6853 void
6854 fastpath_glProgramUniformMatrix3x4fv(GLuint program, GLint location,
6855                                      GLsizei count, GLboolean transpose, const GLfloat *value)
6856 {
6857         GLuint real_obj;
6858
6859         DEFINE_FASTPAH_GL_FUNC();
6860         _COREGL_FASTPATH_FUNC_BEGIN();
6861         INIT_FASTPATH_GL_FUNC();
6862
6863         if (GET_REAL_OBJ(GL_OBJECT_TYPE_PROGRAM, program, &real_obj) != 1) {
6864                 _set_gl_error(GL_INVALID_VALUE);
6865                 goto finish;
6866         }
6867
6868         _orig_fastpath_glProgramUniformMatrix3x4fv(real_obj, location, count, transpose,
6869                         value);
6870
6871         goto finish;
6872
6873 finish:
6874         _COREGL_FASTPATH_FUNC_END();
6875 }
6876
6877
6878 void
6879 fastpath_glProgramUniformMatrix4x3fv(GLuint program, GLint location,
6880                                      GLsizei count, GLboolean transpose, const GLfloat *value)
6881 {
6882         GLuint real_obj;
6883
6884         DEFINE_FASTPAH_GL_FUNC();
6885         _COREGL_FASTPATH_FUNC_BEGIN();
6886         INIT_FASTPATH_GL_FUNC();
6887
6888         if (GET_REAL_OBJ(GL_OBJECT_TYPE_PROGRAM, program, &real_obj) != 1) {
6889                 _set_gl_error(GL_INVALID_VALUE);
6890                 goto finish;
6891         }
6892
6893         _orig_fastpath_glProgramUniformMatrix4x3fv(real_obj, location, count, transpose,
6894                         value);
6895
6896         goto finish;
6897
6898 finish:
6899         _COREGL_FASTPATH_FUNC_END();
6900 }
6901
6902 void
6903 fastpath_glBindImageTexture(GLuint unit, GLuint texture, GLint level,
6904                             GLboolean layered, GLint layer, GLenum access, GLenum format)
6905 {
6906         DEFINE_FASTPAH_GL_FUNC();
6907         _COREGL_FASTPATH_FUNC_BEGIN();
6908         INIT_FASTPATH_GL_FUNC();
6909
6910         _orig_fastpath_glBindImageTexture(unit, texture, level, layered, layer, access,
6911                                           format);
6912
6913         goto finish;
6914
6915 finish:
6916         _COREGL_FASTPATH_FUNC_END();
6917 }
6918
6919 void
6920 fastpath_glGetBooleani_v (GLenum target, GLuint index, GLboolean *data)
6921 {
6922         DEFINE_FASTPAH_GL_FUNC();
6923         _COREGL_FASTPATH_FUNC_BEGIN();
6924         INIT_FASTPATH_GL_FUNC();
6925
6926         IF_GL_SUCCESS(_orig_fastpath_glGetBooleani_v(target, index, data)) {
6927                 _modify_get_value(target, data, GL_BOOL, GL_FALSE);
6928         }
6929
6930         goto finish;
6931
6932 finish:
6933         _COREGL_FASTPATH_FUNC_END();
6934 }
6935
6936 void
6937 fastpath_glMemoryBarrier (GLbitfield barriers)
6938 {
6939         DEFINE_FASTPAH_GL_FUNC();
6940         _COREGL_FASTPATH_FUNC_BEGIN();
6941         INIT_FASTPATH_GL_FUNC();
6942
6943         _orig_fastpath_glMemoryBarrier(barriers);
6944
6945         goto finish;
6946
6947 finish:
6948         _COREGL_FASTPATH_FUNC_END();
6949 }
6950
6951 void
6952 fastpath_glMemoryBarrierByRegion (GLbitfield barriers)
6953 {
6954         DEFINE_FASTPAH_GL_FUNC();
6955         _COREGL_FASTPATH_FUNC_BEGIN();
6956         INIT_FASTPATH_GL_FUNC();
6957
6958         _orig_fastpath_glMemoryBarrierByRegion(barriers);
6959
6960         goto finish;
6961
6962 finish:
6963         _COREGL_FASTPATH_FUNC_END();
6964 }
6965
6966 void
6967 fastpath_glTexStorage2DMultisample (GLenum target, GLsizei samples,
6968                                     GLenum internalformat, GLsizei width, GLsizei height,
6969                                     GLboolean fixedsamplelocations)
6970 {
6971         DEFINE_FASTPAH_GL_FUNC();
6972         _COREGL_FASTPATH_FUNC_BEGIN();
6973         INIT_FASTPATH_GL_FUNC();
6974
6975         _orig_fastpath_glTexStorage2DMultisample (target, samples, internalformat,
6976                         width, height, fixedsamplelocations);
6977
6978         goto finish;
6979
6980 finish:
6981         _COREGL_FASTPATH_FUNC_END();
6982 }
6983
6984 void
6985 fastpath_glGetMultisamplefv (GLenum pname, GLuint index, GLfloat *val)
6986 {
6987         DEFINE_FASTPAH_GL_FUNC();
6988         _COREGL_FASTPATH_FUNC_BEGIN();
6989         INIT_FASTPATH_GL_FUNC();
6990
6991         _orig_fastpath_glGetMultisamplefv (pname, index, val);
6992
6993         goto finish;
6994
6995 finish:
6996         _COREGL_FASTPATH_FUNC_END();
6997 }
6998
6999 void
7000 fastpath_glSampleMaski (GLuint maskNumber, GLbitfield mask)
7001 {
7002         DEFINE_FASTPAH_GL_FUNC();
7003         _COREGL_FASTPATH_FUNC_BEGIN();
7004         INIT_FASTPATH_GL_FUNC();
7005
7006         _orig_fastpath_glSampleMaski(maskNumber, mask);
7007
7008         goto finish;
7009
7010 finish:
7011         _COREGL_FASTPATH_FUNC_END();
7012 }
7013
7014 void
7015 fastpath_glGetTexLevelParameteriv (GLenum target, GLint level, GLenum pname,
7016                                    GLint *params)
7017 {
7018         DEFINE_FASTPAH_GL_FUNC();
7019         _COREGL_FASTPATH_FUNC_BEGIN();
7020         INIT_FASTPATH_GL_FUNC();
7021
7022         _orig_fastpath_glGetTexLevelParameteriv (target, level, pname, params);
7023
7024         goto finish;
7025
7026 finish:
7027         _COREGL_FASTPATH_FUNC_END();
7028 }
7029
7030 void
7031 fastpath_glGetTexLevelParameterfv (GLenum target, GLint level, GLenum pname,
7032                                    GLfloat *params)
7033 {
7034         DEFINE_FASTPAH_GL_FUNC();
7035         _COREGL_FASTPATH_FUNC_BEGIN();
7036         INIT_FASTPATH_GL_FUNC();
7037
7038         _orig_fastpath_glGetTexLevelParameterfv (target, level, pname, params);
7039
7040         goto finish;
7041
7042 finish:
7043         _COREGL_FASTPATH_FUNC_END();
7044 }
7045
7046 void
7047 fastpath_glBindVertexBuffer (GLuint bindingindex, GLuint buffer,
7048                              GLintptr offset, GLsizei stride)
7049 {
7050         DEFINE_FASTPAH_GL_FUNC();
7051         _COREGL_FASTPATH_FUNC_BEGIN();
7052         INIT_FASTPATH_GL_FUNC();
7053
7054         _orig_fastpath_glBindVertexBuffer(bindingindex, buffer, offset, stride);
7055
7056         goto finish;
7057
7058 finish:
7059         _COREGL_FASTPATH_FUNC_END();
7060
7061 }
7062
7063 void
7064 fastpath_glVertexAttribFormat (GLuint attribindex, GLint size, GLenum type,
7065                                GLboolean normalized, GLuint relativeoffset)
7066 {
7067         DEFINE_FASTPAH_GL_FUNC();
7068         _COREGL_FASTPATH_FUNC_BEGIN();
7069         INIT_FASTPATH_GL_FUNC();
7070
7071         _orig_fastpath_glVertexAttribFormat (attribindex, size, type, normalized,
7072                                              relativeoffset);
7073
7074         goto finish;
7075
7076 finish:
7077         _COREGL_FASTPATH_FUNC_END();
7078 }
7079
7080 void
7081 fastpath_glVertexAttribIFormat (GLuint attribindex, GLint size, GLenum type,
7082                                 GLuint relativeoffset)
7083 {
7084         DEFINE_FASTPAH_GL_FUNC();
7085         _COREGL_FASTPATH_FUNC_BEGIN();
7086         INIT_FASTPATH_GL_FUNC();
7087
7088         _orig_fastpath_glVertexAttribIFormat (attribindex, size, type, relativeoffset);
7089
7090         goto finish;
7091
7092 finish:
7093         _COREGL_FASTPATH_FUNC_END();
7094 }
7095
7096 void
7097 fastpath_glVertexAttribBinding (GLuint attribindex, GLuint bindingindex)
7098 {
7099         DEFINE_FASTPAH_GL_FUNC();
7100         _COREGL_FASTPATH_FUNC_BEGIN();
7101         INIT_FASTPATH_GL_FUNC();
7102
7103         _orig_fastpath_glVertexAttribBinding (attribindex, bindingindex);
7104
7105         goto finish;
7106
7107 finish:
7108         _COREGL_FASTPATH_FUNC_END();
7109 }
7110
7111 void
7112 fastpath_glVertexBindingDivisor(GLuint bindingindex, GLuint divisor)
7113 {
7114         DEFINE_FASTPAH_GL_FUNC();
7115         _COREGL_FASTPATH_FUNC_BEGIN();
7116         INIT_FASTPATH_GL_FUNC();
7117
7118         _orig_fastpath_glVertexBindingDivisor (bindingindex, divisor);
7119
7120         goto finish;
7121
7122 finish:
7123         _COREGL_FASTPATH_FUNC_END();
7124 }
7125 void
7126 fastpath_glBindFramebufferOES(GLenum target, GLuint framebuffer)
7127 {
7128         GLuint real_obj;
7129
7130         DEFINE_FASTPAH_GL_FUNC();
7131         _COREGL_FASTPATH_FUNC_BEGIN();
7132         INIT_FASTPATH_GL_FUNC();
7133
7134         if (GET_REAL_OBJ(GL_OBJECT_TYPE_FRAMEBUFFER, framebuffer, &real_obj) != 1) {
7135                 _set_gl_error(GL_OUT_OF_MEMORY);
7136                 goto finish;
7137         }
7138
7139         if (target == GL_FRAMEBUFFER) {
7140                 if (current_ctx->gl_framebuffer_binding_read_used == 1) {
7141                         CURR_STATE_COMPARE(gl_framebuffer_binding_read, real_obj) {
7142                                 IF_GL_SUCCESS(_orig_fastpath_glBindFramebufferOES(target, real_obj)) {
7143                                         if (real_obj == 0)
7144                                                 current_ctx->_bind_flag1 &= (~_BIND_FLAG1_BIT_gl_framebuffer_binding_read);
7145                                         else
7146                                                 current_ctx->_bind_flag1 |= _BIND_FLAG1_BIT_gl_framebuffer_binding_read;
7147                                         current_ctx->gl_framebuffer_binding_read[0] = real_obj;
7148                                 }
7149                         }
7150                         CURR_STATE_COMPARE(gl_framebuffer_binding_draw, real_obj) {
7151                                 IF_GL_SUCCESS(_orig_fastpath_glBindFramebufferOES(target, real_obj)) {
7152                                         if (real_obj == 0)
7153                                                 current_ctx->_bind_flag1 &= (~_BIND_FLAG1_BIT_gl_framebuffer_binding_draw);
7154                                         else
7155                                                 current_ctx->_bind_flag1 |= _BIND_FLAG1_BIT_gl_framebuffer_binding_draw;
7156                                         current_ctx->gl_framebuffer_binding_draw[0] = real_obj;
7157                                 }
7158                         }
7159                 } else {
7160                         CURR_STATE_COMPARE(gl_framebuffer_binding, real_obj) {
7161                                 IF_GL_SUCCESS(_orig_fastpath_glBindFramebufferOES(target, real_obj)) {
7162                                         if (real_obj == 0)
7163                                                 current_ctx->_bind_flag1 &= (~_BIND_FLAG1_BIT_gl_framebuffer_binding);
7164                                         else
7165                                                 current_ctx->_bind_flag1 |= _BIND_FLAG1_BIT_gl_framebuffer_binding;
7166                                         current_ctx->gl_framebuffer_binding[0] = real_obj;
7167                                 }
7168                         }
7169                 }
7170         } else if (target == GL_READ_FRAMEBUFFER &&
7171                    current_ctx->gl_framebuffer_binding_read_used) {
7172                 CURR_STATE_COMPARE(gl_framebuffer_binding_read, real_obj) {
7173                         IF_GL_SUCCESS(_orig_fastpath_glBindFramebufferOES(target, real_obj)) {
7174                                 if (real_obj == 0)
7175                                         current_ctx->_bind_flag1 &= (~_BIND_FLAG1_BIT_gl_framebuffer_binding_read);
7176                                 else
7177                                         current_ctx->_bind_flag1 |= _BIND_FLAG1_BIT_gl_framebuffer_binding_read;
7178                                 current_ctx->gl_framebuffer_binding_read[0] = real_obj;
7179                         }
7180                 }
7181         } else if (target == GL_DRAW_FRAMEBUFFER &&
7182                    current_ctx->gl_framebuffer_binding_draw_used) {
7183                 CURR_STATE_COMPARE(gl_framebuffer_binding_draw, real_obj) {
7184                         IF_GL_SUCCESS(_orig_fastpath_glBindFramebufferOES(target, real_obj)) {
7185                                 if (real_obj == 0)
7186                                         current_ctx->_bind_flag1 &= (~_BIND_FLAG1_BIT_gl_framebuffer_binding_draw);
7187                                 else
7188                                         current_ctx->_bind_flag1 |= _BIND_FLAG1_BIT_gl_framebuffer_binding_draw;
7189                                 current_ctx->gl_framebuffer_binding_draw[0] = real_obj;
7190                         }
7191                 }
7192         } else {
7193                 _set_gl_error(GL_INVALID_ENUM);
7194                 goto finish;
7195         }
7196         goto finish;
7197
7198 finish:
7199         _COREGL_FASTPATH_FUNC_END();
7200 }
7201
7202 void
7203 fastpath_glBindRenderbufferOES(GLenum target, GLuint renderbuffer)
7204 {
7205         GLuint real_obj;
7206
7207         DEFINE_FASTPAH_GL_FUNC();
7208         _COREGL_FASTPATH_FUNC_BEGIN();
7209         INIT_FASTPATH_GL_FUNC();
7210
7211         if (GET_REAL_OBJ(GL_OBJECT_TYPE_RENDERBUFFER, renderbuffer, &real_obj) != 1) {
7212                 _set_gl_error(GL_OUT_OF_MEMORY);
7213                 goto finish;
7214         }
7215
7216         if (target == GL_RENDERBUFFER) {
7217                 CURR_STATE_COMPARE(gl_renderbuffer_binding, real_obj) {
7218                         IF_GL_SUCCESS(_orig_fastpath_glBindRenderbufferOES(target, real_obj)) {
7219                                 if (real_obj == 0)
7220                                         current_ctx->_bind_flag1 &= (~_BIND_FLAG1_BIT_gl_renderbuffer_binding);
7221                                 else
7222                                         current_ctx->_bind_flag1 |= _BIND_FLAG1_BIT_gl_renderbuffer_binding;
7223                                 current_ctx->gl_renderbuffer_binding[0] = real_obj;
7224                         }
7225                 }
7226         } else {
7227                 _set_gl_error(GL_INVALID_ENUM);
7228                 goto finish;
7229         }
7230
7231         goto finish;
7232
7233 finish:
7234         _COREGL_FASTPATH_FUNC_END();
7235 }
7236
7237
7238 void
7239 fastpath_glClearBufferfi(GLenum buffer, GLint drawbuffer, GLfloat depth,
7240                          GLint stencil)
7241 {
7242         GLuint real_obj;
7243
7244         DEFINE_FASTPAH_GL_FUNC();
7245         _COREGL_FASTPATH_FUNC_BEGIN();
7246         INIT_FASTPATH_GL_FUNC();
7247
7248         if (GET_REAL_OBJ(GL_OBJECT_TYPE_BUFFER, buffer, &real_obj) != 1) {
7249                 goto finish;
7250         }
7251
7252         _orig_fastpath_glClearBufferfi(real_obj, drawbuffer, depth, stencil);
7253
7254         goto finish;
7255
7256 finish:
7257         _COREGL_FASTPATH_FUNC_END();
7258 }
7259
7260 void
7261 fastpath_glClearBufferfv(GLenum buffer, GLint drawbuffer, GLfloat const *value)
7262 {
7263         GLuint real_obj;
7264
7265         DEFINE_FASTPAH_GL_FUNC();
7266         _COREGL_FASTPATH_FUNC_BEGIN();
7267         INIT_FASTPATH_GL_FUNC();
7268
7269         if (GET_REAL_OBJ(GL_OBJECT_TYPE_BUFFER, buffer, &real_obj) != 1) {
7270                 goto finish;
7271         }
7272
7273         _orig_fastpath_glClearBufferfv(buffer, drawbuffer, value);
7274
7275         goto finish;
7276
7277 finish:
7278         _COREGL_FASTPATH_FUNC_END();
7279 }
7280
7281 void
7282 fastpath_glClearBufferiv(GLenum buffer, GLint drawbuffer, GLint const *value)
7283 {
7284         GLuint real_obj;
7285
7286         DEFINE_FASTPAH_GL_FUNC();
7287         _COREGL_FASTPATH_FUNC_BEGIN();
7288         INIT_FASTPATH_GL_FUNC();
7289
7290         if (GET_REAL_OBJ(GL_OBJECT_TYPE_BUFFER, buffer, &real_obj) != 1) {
7291                 goto finish;
7292         }
7293
7294         _orig_fastpath_glClearBufferiv(buffer, drawbuffer, value);
7295
7296         goto finish;
7297
7298 finish:
7299         _COREGL_FASTPATH_FUNC_END();
7300 }
7301
7302 void
7303 fastpath_glClearBufferuiv(GLenum buffer, GLint drawbuffer, GLuint const *value)
7304 {
7305         GLuint real_obj;
7306
7307         DEFINE_FASTPAH_GL_FUNC();
7308         _COREGL_FASTPATH_FUNC_BEGIN();
7309         INIT_FASTPATH_GL_FUNC();
7310
7311         if (GET_REAL_OBJ(GL_OBJECT_TYPE_BUFFER, buffer, &real_obj) != 1) {
7312                 goto finish;
7313         }
7314
7315         _orig_fastpath_glClearBufferuiv(buffer, drawbuffer, value);
7316
7317         goto finish;
7318
7319 finish:
7320         _COREGL_FASTPATH_FUNC_END();
7321 }
7322
7323 void
7324 fastpath_glDeleteFramebuffersOES(GLsizei n, const GLuint *framebuffers)
7325 {
7326         int i;
7327         GLuint *objid_array = NULL;
7328
7329         DEFINE_FASTPAH_GL_FUNC();
7330         _COREGL_FASTPATH_FUNC_BEGIN();
7331         INIT_FASTPATH_GL_FUNC();
7332
7333         if (n < 0) {
7334                 _set_gl_error(GL_INVALID_VALUE);
7335                 goto finish;
7336         }
7337         if (n == 0) goto finish;
7338         if (framebuffers == NULL) goto finish;
7339
7340         AST(current_ctx->ostate.shared != NULL);
7341
7342         objid_array = (GLuint *)calloc(1, sizeof(GLuint) * n);
7343         {
7344                 int real_n = 0;
7345
7346                 for (i = 0; i < n; i++) {
7347                         int real_objid = _COREGL_INT_INIT_VALUE;
7348                         if (framebuffers[i] == 0) continue;
7349
7350                         real_objid = fastpath_ostate_get_object(&current_ctx->ostate,
7351                                                                 GL_OBJECT_TYPE_FRAMEBUFFER, framebuffers[i]);
7352                         if (real_objid == 0) continue;
7353
7354                         AST(fastpath_ostate_remove_object(&current_ctx->ostate,
7355                                                           GL_OBJECT_TYPE_FRAMEBUFFER, framebuffers[i]) == 1);
7356                         objid_array[real_n++] = real_objid;
7357                 }
7358
7359                 IF_GL_SUCCESS(_orig_fastpath_glDeleteFramebuffersOES(real_n, objid_array)) {
7360                         for (i = 0; i < real_n; i++) {
7361                                 General_Trace_List *current = NULL;
7362                                 current = current_ctx->ostate.shared->using_gctxs;
7363
7364                                 while (current != NULL) {
7365                                         GLGlueContext *cur_gctx = (GLGlueContext *)current->value;
7366
7367                                         if (cur_gctx->gl_framebuffer_binding[0] == objid_array[i]) {
7368                                                 cur_gctx->_bind_flag1 &= (~_BIND_FLAG1_BIT_gl_framebuffer_binding);
7369                                                 cur_gctx->gl_framebuffer_binding[0] = 0;
7370                                         }
7371                                         if (cur_gctx->gl_framebuffer_binding_read[0] == objid_array[i]) {
7372                                                 cur_gctx->_bind_flag1 &= (~_BIND_FLAG1_BIT_gl_framebuffer_binding_read);
7373                                                 cur_gctx->gl_framebuffer_binding_read[0] = 0;
7374                                         }
7375                                         if (cur_gctx->gl_framebuffer_binding_draw[0] == objid_array[i]) {
7376                                                 cur_gctx->_bind_flag1 &= (~_BIND_FLAG1_BIT_gl_framebuffer_binding_draw);
7377                                                 cur_gctx->gl_framebuffer_binding_draw[0] = 0;
7378                                         }
7379
7380                                         current = current->next;
7381                                 }
7382                         }
7383                 }
7384         }
7385
7386         goto finish;
7387
7388 finish:
7389         if (objid_array != NULL) {
7390                 free(objid_array);
7391                 objid_array = NULL;
7392         }
7393         _COREGL_FASTPATH_FUNC_END();
7394 }
7395
7396 void
7397 fastpath_glDeleteRenderbuffersOES(GLsizei n, const GLuint *renderbuffers)
7398 {
7399         int i;
7400         GLuint *objid_array = NULL;
7401
7402         DEFINE_FASTPAH_GL_FUNC();
7403         _COREGL_FASTPATH_FUNC_BEGIN();
7404         INIT_FASTPATH_GL_FUNC();
7405
7406         if (n < 0) {
7407                 _set_gl_error(GL_INVALID_VALUE);
7408                 goto finish;
7409         }
7410         if (n == 0) goto finish;
7411         if (renderbuffers == NULL) goto finish;
7412
7413         AST(current_ctx->ostate.shared != NULL);
7414
7415         objid_array = (GLuint *)calloc(1, sizeof(GLuint) * n);
7416         {
7417                 int real_n = 0;
7418
7419                 for (i = 0; i < n; i++) {
7420                         int real_objid = _COREGL_INT_INIT_VALUE;
7421                         if (renderbuffers[i] == 0) continue;
7422
7423                         real_objid = fastpath_ostate_get_object(&current_ctx->ostate,
7424                                                                 GL_OBJECT_TYPE_RENDERBUFFER, renderbuffers[i]);
7425                         if (real_objid == 0) continue;
7426
7427                         AST(fastpath_ostate_remove_object(&current_ctx->ostate,
7428                                                           GL_OBJECT_TYPE_RENDERBUFFER, renderbuffers[i]) == 1);
7429                         objid_array[real_n++] = real_objid;
7430                 }
7431
7432                 IF_GL_SUCCESS(_orig_fastpath_glDeleteRenderbuffersOES(real_n, objid_array)) {
7433                         for (i = 0; i < real_n; i++) {
7434                                 General_Trace_List *current = NULL;
7435                                 current = current_ctx->ostate.shared->using_gctxs;
7436
7437                                 while (current != NULL) {
7438                                         GLGlueContext *cur_gctx = (GLGlueContext *)current->value;
7439
7440                                         if (cur_gctx->gl_renderbuffer_binding[0] == objid_array[i]) {
7441                                                 cur_gctx->_bind_flag1 &= (~_BIND_FLAG1_BIT_gl_renderbuffer_binding);
7442                                                 cur_gctx->gl_renderbuffer_binding[0] = 0;
7443                                         }
7444
7445                                         current = current->next;
7446                                 }
7447                         }
7448                 }
7449         }
7450
7451         goto finish;
7452
7453 finish:
7454         if (objid_array != NULL) {
7455                 free(objid_array);
7456                 objid_array = NULL;
7457         }
7458         _COREGL_FASTPATH_FUNC_END();
7459 }
7460
7461 void
7462 fastpath_glDepthRangefOES(GLclampf zNear, GLclampf zFar)
7463 {
7464         DEFINE_FASTPAH_GL_FUNC();
7465         _COREGL_FASTPATH_FUNC_BEGIN();
7466         INIT_FASTPATH_GL_FUNC();
7467
7468         if ((current_ctx->gl_depth_range[0] != zNear) ||
7469             (current_ctx->gl_depth_range[1] != zFar)) {
7470                 IF_GL_SUCCESS(_orig_fastpath_glDepthRangefOES(zNear, zFar)) {
7471                         current_ctx->_clear_flag2 |= _CLEAR_FLAG2_BIT_gl_depth_range;
7472                         current_ctx->gl_depth_range[0] = zNear;
7473                         current_ctx->gl_depth_range[1] = zFar;
7474                 }
7475         }
7476         goto finish;
7477
7478 finish:
7479         _COREGL_FASTPATH_FUNC_END();
7480 }
7481
7482 void
7483 fastpath_glDepthRangexOES(GLclampx zNear, GLclampx zFar)
7484 {
7485         DEFINE_FASTPAH_GL_FUNC();
7486         _COREGL_FASTPATH_FUNC_BEGIN();
7487         INIT_FASTPATH_GL_FUNC();
7488
7489         if ((current_ctx->gl_depth_range[0] != zNear) ||
7490             (current_ctx->gl_depth_range[1] != zFar)) {
7491                 IF_GL_SUCCESS(_orig_fastpath_glDepthRangexOES(zNear, zFar)) {
7492                         current_ctx->_clear_flag2 |= _CLEAR_FLAG2_BIT_gl_depth_range;
7493                         current_ctx->gl_depth_range[0] = zNear;
7494                         current_ctx->gl_depth_range[1] = zFar;
7495                 }
7496         }
7497         goto finish;
7498
7499 finish:
7500         _COREGL_FASTPATH_FUNC_END();
7501 }
7502
7503 void
7504 fastpath_glFramebufferParameteri(GLenum target, GLenum pname, GLint param)
7505 {
7506         GLint real_obj = 0, fa_type = 0;
7507
7508         DEFINE_FASTPAH_GL_FUNC();
7509         _COREGL_FASTPATH_FUNC_BEGIN();
7510         INIT_FASTPATH_GL_FUNC();
7511
7512         switch (pname) {
7513         case GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME:
7514                 param = 0;
7515                 _orig_fastpath_glFramebufferParameteri(target, pname, real_obj);
7516                 _orig_fastpath_glFramebufferParameteri(target,
7517                                                        GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE, fa_type);
7518                 switch (fa_type) {
7519                 case GL_TEXTURE:
7520                         if (GET_GLUE_OBJ(GL_OBJECT_TYPE_TEXTURE, real_obj, (GLuint *)&param) != 1) {
7521                                 param = 0;
7522                                 goto finish;
7523                         }
7524                         break;
7525                 case GL_RENDERBUFFER:
7526                         if (GET_GLUE_OBJ(GL_OBJECT_TYPE_RENDERBUFFER, real_obj,
7527                                          (GLuint *)&param) != 1) {
7528                                 param = 0;
7529                                 goto finish;
7530                         }
7531                         break;
7532                 }
7533                 break;
7534         default:
7535                 _orig_fastpath_glFramebufferParameteri(target, pname, param);
7536                 break;
7537         }
7538
7539         goto finish;
7540
7541 finish:
7542         _COREGL_FASTPATH_FUNC_END();
7543 }
7544
7545 void
7546 fastpath_glGetFramebufferParameteriv(GLenum target, GLenum pname, GLint *params)
7547 {
7548         GLint real_obj = 0, fa_type = 0;;
7549
7550         DEFINE_FASTPAH_GL_FUNC();
7551         _COREGL_FASTPATH_FUNC_BEGIN();
7552         INIT_FASTPATH_GL_FUNC();
7553
7554         switch (pname) {
7555         case GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME:
7556                 params[0] = 0;
7557                 _orig_fastpath_glGetFramebufferParameteriv(target, pname, &real_obj);
7558                 _orig_fastpath_glGetFramebufferParameteriv(target,
7559                                 GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE, &fa_type);
7560                 switch (fa_type) {
7561                 case GL_TEXTURE:
7562                         if (GET_GLUE_OBJ(GL_OBJECT_TYPE_TEXTURE, real_obj, (GLuint *)params) != 1) {
7563                                 params[0] = 0;
7564                                 goto finish;
7565                         }
7566                         break;
7567                 case GL_RENDERBUFFER:
7568                         if (GET_GLUE_OBJ(GL_OBJECT_TYPE_RENDERBUFFER, real_obj,
7569                                          (GLuint *)params) != 1) {
7570                                 params[0] = 0;
7571                                 goto finish;
7572                         }
7573                         break;
7574                 }
7575                 break;
7576         default:
7577                 _orig_fastpath_glGetFramebufferParameteriv(target, pname, params);
7578                 break;
7579         }
7580
7581         goto finish;
7582
7583 finish:
7584         _COREGL_FASTPATH_FUNC_END();
7585 }
7586
7587 void
7588 fastpath_glFramebufferRenderbufferOES(GLenum target, GLenum attachment,
7589                                       GLenum renderbuffertarget, GLuint renderbuffer)
7590 {
7591         GLuint real_obj;
7592
7593         DEFINE_FASTPAH_GL_FUNC();
7594         _COREGL_FASTPATH_FUNC_BEGIN();
7595         INIT_FASTPATH_GL_FUNC();
7596
7597         if (GET_REAL_OBJ(GL_OBJECT_TYPE_RENDERBUFFER, renderbuffer, &real_obj) != 1) {
7598                 _set_gl_error(GL_OUT_OF_MEMORY);
7599                 goto finish;
7600         }
7601
7602         _orig_fastpath_glFramebufferRenderbufferOES(target, attachment,
7603                         renderbuffertarget, real_obj);
7604
7605         goto finish;
7606
7607 finish:
7608         _COREGL_FASTPATH_FUNC_END();
7609 }
7610
7611 void
7612 fastpath_glFramebufferTexture2DOES(GLenum target, GLenum attachment,
7613                                    GLenum textarget, GLuint texture, GLint level)
7614 {
7615         GLuint real_obj;
7616
7617         DEFINE_FASTPAH_GL_FUNC();
7618         _COREGL_FASTPATH_FUNC_BEGIN();
7619         INIT_FASTPATH_GL_FUNC();
7620
7621         if (GET_REAL_OBJ(GL_OBJECT_TYPE_TEXTURE, texture, &real_obj) != 1) {
7622                 _set_gl_error(GL_OUT_OF_MEMORY);
7623                 goto finish;
7624         }
7625
7626         _orig_fastpath_glFramebufferTexture2DOES(target, attachment, textarget,
7627                         real_obj, level);
7628
7629         goto finish;
7630
7631 finish:
7632         _COREGL_FASTPATH_FUNC_END();
7633 }
7634
7635 void
7636 fastpath_glGenFramebuffersOES(GLsizei n, GLuint *framebuffers)
7637 {
7638         int i;
7639         GLuint *objid_array = NULL;
7640
7641         DEFINE_FASTPAH_GL_FUNC();
7642         _COREGL_FASTPATH_FUNC_BEGIN();
7643         INIT_FASTPATH_GL_FUNC();
7644
7645         if (n < 0) {
7646                 _set_gl_error(GL_INVALID_VALUE);
7647                 goto finish;
7648         }
7649         if (n == 0) goto finish;
7650         if (framebuffers == NULL) goto finish;
7651
7652         AST(current_ctx->ostate.shared != NULL);
7653
7654         objid_array = (GLuint *)calloc(1, sizeof(GLuint) * n);
7655
7656         IF_GL_SUCCESS(_orig_fastpath_glGenFramebuffersOES(n, objid_array)) {
7657                 for (i = 0; i < n; i++) {
7658                         framebuffers[i] = fastpath_ostate_create_object(&current_ctx->ostate,
7659                                           GL_OBJECT_TYPE_FRAMEBUFFER, objid_array[i]);
7660                 }
7661         }
7662
7663         goto finish;
7664
7665 finish:
7666         if (objid_array != NULL) {
7667                 free(objid_array);
7668                 objid_array = NULL;
7669         }
7670         _COREGL_FASTPATH_FUNC_END();
7671 }
7672
7673 void
7674 fastpath_glGenRenderbuffersOES(GLsizei n, GLuint *renderbuffers)
7675 {
7676         int i;
7677         GLuint *objid_array = NULL;
7678
7679         DEFINE_FASTPAH_GL_FUNC();
7680         _COREGL_FASTPATH_FUNC_BEGIN();
7681         INIT_FASTPATH_GL_FUNC();
7682
7683         if (n < 0) {
7684                 _set_gl_error(GL_INVALID_VALUE);
7685                 goto finish;
7686         }
7687         if (n == 0) goto finish;
7688         if (renderbuffers == NULL) goto finish;
7689
7690         AST(current_ctx->ostate.shared != NULL);
7691
7692         objid_array = (GLuint *)calloc(1, sizeof(GLuint) * n);
7693
7694         IF_GL_SUCCESS(_orig_fastpath_glGenRenderbuffersOES(n, objid_array)) {
7695                 for (i = 0; i < n; i++) {
7696                         renderbuffers[i] = fastpath_ostate_create_object(&current_ctx->ostate,
7697                                            GL_OBJECT_TYPE_RENDERBUFFER, objid_array[i]);
7698                 }
7699         }
7700
7701         goto finish;
7702
7703 finish:
7704         if (objid_array != NULL) {
7705                 free(objid_array);
7706                 objid_array = NULL;
7707         }
7708         _COREGL_FASTPATH_FUNC_END();
7709 }
7710
7711 void
7712 fastpath_glGetFramebufferAttachmentParameterivOES(GLenum target,
7713                 GLenum attachment, GLenum pname, GLint *params)
7714 {
7715         GLint real_obj, fa_type;
7716
7717         DEFINE_FASTPAH_GL_FUNC();
7718         _COREGL_FASTPATH_FUNC_BEGIN();
7719         INIT_FASTPATH_GL_FUNC();
7720
7721         switch (pname) {
7722         case GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME:
7723                 params[0] = 0;
7724                 _orig_fastpath_glGetFramebufferAttachmentParameterivOES(target, attachment,
7725                                 pname, &real_obj);
7726                 _orig_fastpath_glGetFramebufferAttachmentParameterivOES(target, attachment,
7727                                 GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE, &fa_type);
7728                 switch (fa_type) {
7729                 case GL_TEXTURE:
7730                         if (GET_GLUE_OBJ(GL_OBJECT_TYPE_TEXTURE, real_obj, (GLuint *)params) != 1) {
7731                                 params[0] = 0;
7732                                 goto finish;
7733                         }
7734                         break;
7735                 case GL_RENDERBUFFER:
7736                         if (GET_GLUE_OBJ(GL_OBJECT_TYPE_RENDERBUFFER, real_obj,
7737                                          (GLuint *)params) != 1) {
7738                                 params[0] = 0;
7739                                 goto finish;
7740                         }
7741                         break;
7742                 }
7743                 break;
7744         default:
7745                 _orig_fastpath_glGetFramebufferAttachmentParameterivOES(target, attachment,
7746                                 pname, params);
7747                 break;
7748         }
7749
7750         goto finish;
7751
7752 finish:
7753         _COREGL_FASTPATH_FUNC_END();
7754 }
7755
7756 void
7757 fastpath_glGetQueryObjecti64vEXT(GLuint id, GLenum pname, GLint64 *params)
7758 {
7759         GLuint real_obj;
7760
7761         DEFINE_FASTPAH_GL_FUNC();
7762         _COREGL_FASTPATH_FUNC_BEGIN();
7763         INIT_FASTPATH_GL_FUNC();
7764
7765         if (GET_REAL_OBJ(GL_OBJECT_TYPE_QUERY, id, &real_obj) != 1) {
7766                 _set_gl_error(GL_INVALID_OPERATION);
7767                 goto finish;
7768         }
7769
7770         _orig_fastpath_glGetQueryObjecti64vEXT(real_obj, pname, params);
7771
7772         goto finish;
7773
7774 finish:
7775         _COREGL_FASTPATH_FUNC_END();
7776 }
7777
7778 void
7779 fastpath_glGetQueryObjectivEXT(GLuint id, GLenum pname, GLint *params)
7780 {
7781         GLuint real_obj;
7782
7783         DEFINE_FASTPAH_GL_FUNC();
7784         _COREGL_FASTPATH_FUNC_BEGIN();
7785         INIT_FASTPATH_GL_FUNC();
7786
7787         if (GET_REAL_OBJ(GL_OBJECT_TYPE_QUERY, id, &real_obj) != 1) {
7788                 _set_gl_error(GL_INVALID_OPERATION);
7789                 goto finish;
7790         }
7791
7792         _orig_fastpath_glGetQueryObjectivEXT(real_obj, pname, params);
7793
7794         goto finish;
7795
7796 finish:
7797         _COREGL_FASTPATH_FUNC_END();
7798 }
7799
7800 void
7801 fastpath_glGetQueryObjectui64vEXT(GLuint id, GLenum pname, GLuint64 *params)
7802 {
7803         GLuint real_obj;
7804
7805         DEFINE_FASTPAH_GL_FUNC();
7806         _COREGL_FASTPATH_FUNC_BEGIN();
7807         INIT_FASTPATH_GL_FUNC();
7808
7809         if (GET_REAL_OBJ(GL_OBJECT_TYPE_QUERY, id, &real_obj) != 1) {
7810                 _set_gl_error(GL_INVALID_OPERATION);
7811                 goto finish;
7812         }
7813
7814         _orig_fastpath_glGetQueryObjectui64vEXT(real_obj, pname, params);
7815
7816         goto finish;
7817
7818 finish:
7819         _COREGL_FASTPATH_FUNC_END();
7820 }
7821
7822 void
7823 fastpath_glGetQueryObjectuivEXT(GLuint id, GLenum pname, GLuint *params)
7824 {
7825         GLuint real_obj;
7826
7827         DEFINE_FASTPAH_GL_FUNC();
7828         _COREGL_FASTPATH_FUNC_BEGIN();
7829         INIT_FASTPATH_GL_FUNC();
7830
7831         if (GET_REAL_OBJ(GL_OBJECT_TYPE_QUERY, id, &real_obj) != 1) {
7832                 _set_gl_error(GL_INVALID_OPERATION);
7833                 goto finish;
7834         }
7835
7836         _orig_fastpath_glGetQueryObjectuivEXT(real_obj, pname, params);
7837
7838         goto finish;
7839
7840 finish:
7841         _COREGL_FASTPATH_FUNC_END();
7842 }
7843
7844 void
7845 fastpath_glGetQueryivEXT(GLenum target, GLenum pname, GLint *params)
7846 {
7847         GLuint glue_obj_id = _COREGL_INT_INIT_VALUE;
7848
7849         DEFINE_FASTPAH_GL_FUNC();
7850         _COREGL_FASTPATH_FUNC_BEGIN();
7851         INIT_FASTPATH_GL_FUNC();
7852
7853         _orig_fastpath_glGetQueryivEXT(target, pname, params);
7854
7855         switch (pname) {
7856         case GL_CURRENT_QUERY:
7857                 if (params[0] != 0) {
7858                         AST(GET_GLUE_OBJ(GL_OBJECT_TYPE_QUERY, params[0], &glue_obj_id) == 1);
7859                         params[0] = glue_obj_id;
7860                 }
7861                 break;
7862         }
7863
7864         goto finish;
7865
7866 finish:
7867         _COREGL_FASTPATH_FUNC_END();
7868 }
7869
7870 void
7871 fastpath_glBeginQueryEXT(GLenum target, GLuint id)
7872 {
7873         GLuint real_obj;
7874
7875         DEFINE_FASTPAH_GL_FUNC();
7876         _COREGL_FASTPATH_FUNC_BEGIN();
7877         INIT_FASTPATH_GL_FUNC();
7878
7879         if (GET_REAL_OBJ(GL_OBJECT_TYPE_QUERY, id, &real_obj) != 1) {
7880                 // TODO : Begin - Context Switch
7881                 _set_gl_error(GL_INVALID_OPERATION);
7882                 goto finish;
7883         }
7884
7885         _orig_fastpath_glBeginQueryEXT(target, real_obj);
7886
7887         goto finish;
7888
7889 finish:
7890         _COREGL_FASTPATH_FUNC_END();
7891 }
7892
7893 void
7894 fastpath_glDeleteQueriesEXT(GLsizei n, const GLuint *ids)
7895 {
7896         int i;
7897         GLuint *objid_array = NULL;
7898
7899         DEFINE_FASTPAH_GL_FUNC();
7900         _COREGL_FASTPATH_FUNC_BEGIN();
7901         INIT_FASTPATH_GL_FUNC();
7902
7903         if (n < 0) {
7904                 _set_gl_error(GL_INVALID_VALUE);
7905                 goto finish;
7906         }
7907         if (n == 0) goto finish;
7908         if (ids == NULL) goto finish;
7909
7910         AST(current_ctx->ostate.shared != NULL);
7911
7912         objid_array = (GLuint *)calloc(1, sizeof(GLuint) * n);
7913         {
7914                 int real_n = 0;
7915
7916                 for (i = 0; i < n; i++) {
7917                         int real_objid = _COREGL_INT_INIT_VALUE;
7918                         if (ids[i] == 0) continue;
7919
7920                         real_objid = fastpath_ostate_get_object(&current_ctx->ostate,
7921                                                                 GL_OBJECT_TYPE_QUERY, ids[i]);
7922                         if (real_objid == 0) continue;
7923
7924                         AST(fastpath_ostate_remove_object(&current_ctx->ostate, GL_OBJECT_TYPE_QUERY,
7925                                                           ids[i]) == 1);
7926                         objid_array[real_n++] = real_objid;
7927                 }
7928
7929                 _orig_fastpath_glDeleteQueriesEXT(real_n, objid_array);
7930         }
7931
7932         goto finish;
7933
7934 finish:
7935         if (objid_array != NULL) {
7936                 free(objid_array);
7937                 objid_array = NULL;
7938         }
7939         _COREGL_FASTPATH_FUNC_END();
7940 }
7941
7942 void
7943 fastpath_glGenQueriesEXT(GLsizei n, GLuint *ids)
7944 {
7945         int i;
7946         GLuint *objid_array = NULL;
7947
7948         DEFINE_FASTPAH_GL_FUNC();
7949         _COREGL_FASTPATH_FUNC_BEGIN();
7950         INIT_FASTPATH_GL_FUNC();
7951
7952         if (n < 0) {
7953                 _set_gl_error(GL_INVALID_VALUE);
7954                 goto finish;
7955         }
7956         if (n == 0) goto finish;
7957         if (ids == NULL) goto finish;
7958
7959         AST(current_ctx->ostate.shared != NULL);
7960
7961         objid_array = (GLuint *)calloc(1, sizeof(GLuint) * n);
7962
7963         IF_GL_SUCCESS(_orig_fastpath_glGenQueriesEXT(n, objid_array)) {
7964                 for (i = 0; i < n; i++) {
7965                         ids[i] = fastpath_ostate_create_object(&current_ctx->ostate,
7966                                                                GL_OBJECT_TYPE_QUERY, objid_array[i]);
7967                 }
7968         }
7969
7970         goto finish;
7971
7972 finish:
7973         if (objid_array != NULL) {
7974                 free(objid_array);
7975                 objid_array = NULL;
7976         }
7977         _COREGL_FASTPATH_FUNC_END();
7978 }
7979
7980 GLboolean
7981 fastpath_glIsFramebufferOES(GLuint framebuffer)
7982 {
7983         GLboolean ret = GL_FALSE;
7984         GLuint real_obj;
7985
7986         DEFINE_FASTPAH_GL_FUNC();
7987         _COREGL_FASTPATH_FUNC_BEGIN();
7988         INIT_FASTPATH_GL_FUNC();
7989
7990         if (GET_REAL_OBJ(GL_OBJECT_TYPE_FRAMEBUFFER, framebuffer, &real_obj) != 1) {
7991                 ret = GL_FALSE;
7992                 goto finish;
7993         }
7994
7995         ret = _orig_fastpath_glIsFramebufferOES(real_obj);
7996
7997         goto finish;
7998
7999 finish:
8000         _COREGL_FASTPATH_FUNC_END();
8001         return ret;
8002 }
8003
8004 GLboolean
8005 fastpath_glIsQueryEXT(GLuint id)
8006 {
8007         GLboolean ret = GL_FALSE;
8008         GLuint real_obj;
8009
8010         DEFINE_FASTPAH_GL_FUNC();
8011         _COREGL_FASTPATH_FUNC_BEGIN();
8012         INIT_FASTPATH_GL_FUNC();
8013
8014         if (GET_REAL_OBJ(GL_OBJECT_TYPE_QUERY, id, &real_obj) != 1) {
8015                 ret = GL_FALSE;
8016                 goto finish;
8017         }
8018
8019         ret = _orig_fastpath_glIsQueryEXT(real_obj);
8020
8021         goto finish;
8022
8023 finish:
8024         _COREGL_FASTPATH_FUNC_END();
8025         return ret;
8026 }
8027
8028 GLboolean
8029 fastpath_glIsRenderbufferOES(GLuint renderbuffer)
8030 {
8031         GLboolean ret = GL_FALSE;
8032         GLuint real_obj;
8033
8034         DEFINE_FASTPAH_GL_FUNC();
8035         _COREGL_FASTPATH_FUNC_BEGIN();
8036         INIT_FASTPATH_GL_FUNC();
8037
8038         if (GET_REAL_OBJ(GL_OBJECT_TYPE_RENDERBUFFER, renderbuffer, &real_obj) != 1) {
8039                 ret = GL_FALSE;
8040                 goto finish;
8041         }
8042
8043         ret = _orig_fastpath_glIsRenderbufferOES(real_obj);
8044
8045         goto finish;
8046
8047 finish:
8048         _COREGL_FASTPATH_FUNC_END();
8049         return ret;
8050 }
8051
8052 void
8053 fastpath_glBlendEquationOES(GLenum mode)
8054 {
8055         DEFINE_FASTPAH_GL_FUNC();
8056         _COREGL_FASTPATH_FUNC_BEGIN();
8057         INIT_FASTPATH_GL_FUNC();
8058
8059         IF_GL_SUCCESS(_orig_fastpath_glBlendEquationOES(mode)) {
8060                 current_ctx->_blend_flag |=
8061                         _BLEND_FLAG_BIT_gl_blend_equation_rgb |
8062                         _BLEND_FLAG_BIT_gl_blend_equation_alpha;
8063
8064                 _orig_fastpath_glGetIntegerv(GL_BLEND_EQUATION_RGB,
8065                                              (GLint *) & (current_ctx->gl_blend_equation_rgb));
8066                 _orig_fastpath_glGetIntegerv(GL_BLEND_EQUATION_ALPHA,
8067                                              (GLint *) & (current_ctx->gl_blend_equation_alpha));
8068         }
8069         goto finish;
8070
8071 finish:
8072         _COREGL_FASTPATH_FUNC_END();
8073 }
8074
8075
8076 void
8077 fastpath_glBlendEquationSeparateOES(GLenum modeRGB, GLenum modeAlpha)
8078 {
8079         DEFINE_FASTPAH_GL_FUNC();
8080         _COREGL_FASTPATH_FUNC_BEGIN();
8081         INIT_FASTPATH_GL_FUNC();
8082
8083         if ((current_ctx->gl_blend_equation_rgb[0] != modeRGB) ||
8084             (current_ctx->gl_blend_equation_alpha[0] != modeAlpha)) {
8085                 IF_GL_SUCCESS(_orig_fastpath_glBlendEquationSeparateOES(modeRGB, modeAlpha)) {
8086                         current_ctx->_blend_flag |=
8087                                 _BLEND_FLAG_BIT_gl_blend_equation_rgb |
8088                                 _BLEND_FLAG_BIT_gl_blend_equation_alpha;
8089
8090                         current_ctx->gl_blend_equation_rgb[0]    = modeRGB;
8091                         current_ctx->gl_blend_equation_alpha[0]  = modeAlpha;
8092                 }
8093         }
8094         goto finish;
8095
8096 finish:
8097         _COREGL_FASTPATH_FUNC_END();
8098 }
8099
8100 void
8101 fastpath_glBlendFuncSeparateOES(GLenum srcRGB, GLenum dstRGB, GLenum srcAlpha,
8102                                 GLenum dstAlpha)
8103 {
8104         DEFINE_FASTPAH_GL_FUNC();
8105         _COREGL_FASTPATH_FUNC_BEGIN();
8106         INIT_FASTPATH_GL_FUNC();
8107
8108         if ((current_ctx->gl_blend_src_rgb[0] != srcRGB) ||
8109             (current_ctx->gl_blend_dst_rgb[0] != dstRGB) ||
8110             (current_ctx->gl_blend_src_alpha[0] != srcAlpha) ||
8111             (current_ctx->gl_blend_dst_alpha[0] != dstAlpha)) {
8112                 IF_GL_SUCCESS(_orig_fastpath_glBlendFuncSeparateOES(srcRGB, dstRGB, srcAlpha,
8113                                 dstAlpha)) {
8114                         current_ctx->_blend_flag |=
8115                                 _BLEND_FLAG_BIT_gl_blend_src_rgb |
8116                                 _BLEND_FLAG_BIT_gl_blend_src_alpha |
8117                                 _BLEND_FLAG_BIT_gl_blend_dst_rgb |
8118                                 _BLEND_FLAG_BIT_gl_blend_dst_alpha;
8119
8120                         current_ctx->gl_blend_src_rgb[0]   = srcRGB;
8121                         current_ctx->gl_blend_dst_rgb[0]   = dstRGB;
8122                         current_ctx->gl_blend_src_alpha[0] = srcAlpha;
8123                         current_ctx->gl_blend_dst_alpha[0] = dstAlpha;
8124                 }
8125         }
8126         goto finish;
8127
8128 finish:
8129         _COREGL_FASTPATH_FUNC_END();
8130 }
8131
8132 void
8133 fastpath_glPolygonOffsetxOES(GLfixed factor, GLfixed units)
8134 {
8135         DEFINE_FASTPAH_GL_FUNC();
8136         _COREGL_FASTPATH_FUNC_BEGIN();
8137         INIT_FASTPATH_GL_FUNC();
8138
8139         if ((current_ctx->gl_polygon_offset_factor[0] != factor) ||
8140             (current_ctx->gl_polygon_offset_units[0] != units)) {
8141                 IF_GL_SUCCESS(_orig_fastpath_glPolygonOffsetxOES(factor, units)) {
8142                         current_ctx->_misc_flag1 |=
8143                                 _MISC_FLAG1_BIT_gl_polygon_offset_factor |
8144                                 _MISC_FLAG1_BIT_gl_polygon_offset_units;
8145
8146                         current_ctx->gl_polygon_offset_factor[0] = factor;
8147                         current_ctx->gl_polygon_offset_units[0]  = units;
8148                 }
8149         }
8150         goto finish;
8151
8152 finish:
8153         _COREGL_FASTPATH_FUNC_END();
8154 }
8155
8156 void
8157 fastpath_glLineWidthxOES(GLfixed width)
8158 {
8159         DEFINE_FASTPAH_GL_FUNC();
8160         _COREGL_FASTPATH_FUNC_BEGIN();
8161         INIT_FASTPATH_GL_FUNC();
8162
8163         CURR_STATE_COMPARE(gl_line_width, width) {
8164                 IF_GL_SUCCESS(_orig_fastpath_glLineWidthxOES(width)) {
8165                         current_ctx->_misc_flag1 |= _MISC_FLAG1_BIT_gl_line_width;
8166                         current_ctx->gl_line_width[0] = width;
8167                 }
8168         }
8169         goto finish;
8170
8171 finish:
8172         _COREGL_FASTPATH_FUNC_END();
8173 }
8174
8175 void
8176 fastpath_glSampleCoveragexOES(GLclampx value, GLboolean invert)
8177 {
8178         DEFINE_FASTPAH_GL_FUNC();
8179         _COREGL_FASTPATH_FUNC_BEGIN();
8180         INIT_FASTPATH_GL_FUNC();
8181
8182         if ((current_ctx->gl_sample_coverage_value[0] != value) ||
8183             (current_ctx->gl_sample_coverage_invert[0] != invert)) {
8184                 IF_GL_SUCCESS(_orig_fastpath_glSampleCoveragexOES(value, invert)) {
8185                         current_ctx->_misc_flag1 |=
8186                                 _MISC_FLAG1_BIT_gl_sample_coverage_value |
8187                                 _MISC_FLAG1_BIT_gl_sample_coverage_invert;
8188
8189                         current_ctx->gl_sample_coverage_value[0] = value;
8190                         current_ctx->gl_sample_coverage_invert[0] = invert;
8191                 }
8192         }
8193         goto finish;
8194
8195 finish:
8196         _COREGL_FASTPATH_FUNC_END();
8197 }
8198
8199 void
8200 fastpath_glQueryCounterEXT(GLuint id, GLenum target)
8201 {
8202         GLuint real_obj;
8203
8204         DEFINE_FASTPAH_GL_FUNC();
8205         _COREGL_FASTPATH_FUNC_BEGIN();
8206         INIT_FASTPATH_GL_FUNC();
8207
8208         if (GET_REAL_OBJ(GL_OBJECT_TYPE_QUERY, id, &real_obj) != 1) {
8209                 // TODO : Begin - Context Switch
8210                 _set_gl_error(GL_INVALID_OPERATION);
8211                 goto finish;
8212         }
8213
8214         _orig_fastpath_glQueryCounterEXT(real_obj, target);
8215
8216         goto finish;
8217
8218 finish:
8219         _COREGL_FASTPATH_FUNC_END();
8220 }
8221
8222 void
8223 fastpath_glGenVertexArraysOES(GLsizei n, GLuint *arrays)
8224 {
8225         int i;
8226         GLuint *objid_array = NULL;
8227
8228         DEFINE_FASTPAH_GL_FUNC();
8229         _COREGL_FASTPATH_FUNC_BEGIN();
8230         INIT_FASTPATH_GL_FUNC();
8231
8232         if (n < 0) {
8233                 _set_gl_error(GL_INVALID_VALUE);
8234                 goto finish;
8235         }
8236         if (n == 0) goto finish;
8237         if (arrays == NULL) goto finish;
8238
8239         AST(current_ctx->ostate.shared != NULL);
8240
8241         objid_array = (GLuint *)calloc(1, sizeof(GLuint) * n);
8242
8243         IF_GL_SUCCESS(_orig_fastpath_glGenVertexArraysOES(n, objid_array)) {
8244                 for (i = 0; i < n; i++) {
8245                         arrays[i] = fastpath_ostate_create_object(&current_ctx->ostate,
8246                                         GL_OBJECT_TYPE_VERTEXARRAY, objid_array[i]);
8247                 }
8248         }
8249
8250         goto finish;
8251
8252 finish:
8253         if (objid_array != NULL) {
8254                 free(objid_array);
8255                 objid_array = NULL;
8256         }
8257         _COREGL_FASTPATH_FUNC_END();
8258 }
8259
8260
8261 void
8262 fastpath_glBindVertexArrayOES(GLuint array)
8263 {
8264         GLuint real_obj;
8265
8266         DEFINE_FASTPAH_GL_FUNC();
8267         _COREGL_FASTPATH_FUNC_BEGIN();
8268         INIT_FASTPATH_GL_FUNC();
8269
8270         if (GET_REAL_OBJ(GL_OBJECT_TYPE_VERTEXARRAY, array, &real_obj) != 1) {
8271                 _set_gl_error(GL_INVALID_OPERATION);
8272                 goto finish;
8273         }
8274         if (current_ctx->gl_vertex_array_binding[0] != real_obj) {
8275                 IF_GL_SUCCESS(_orig_fastpath_glBindVertexArrayOES(real_obj)) {
8276                         current_ctx->_misc_flag3 |= _MISC_FLAG3_BIT_gl_vertex_array_binding;
8277                         current_ctx->gl_vertex_array_binding[0] = real_obj;
8278                 }
8279         }
8280         goto finish;
8281
8282 finish:
8283         _COREGL_FASTPATH_FUNC_END();
8284 }
8285
8286
8287 GLboolean
8288 fastpath_glIsVertexArrayOES(GLuint array)
8289 {
8290         GLboolean ret = GL_FALSE;
8291         GLuint real_obj;
8292
8293         DEFINE_FASTPAH_GL_FUNC();
8294         _COREGL_FASTPATH_FUNC_BEGIN();
8295         INIT_FASTPATH_GL_FUNC();
8296
8297         if (GET_REAL_OBJ(GL_OBJECT_TYPE_VERTEXARRAY, array, &real_obj) != 1) {
8298                 ret = GL_FALSE;
8299                 goto finish;
8300         }
8301
8302         ret = _orig_fastpath_glIsVertexArrayOES(real_obj);
8303
8304         goto finish;
8305
8306 finish:
8307         _COREGL_FASTPATH_FUNC_END();
8308         return ret;
8309 }
8310
8311
8312 void
8313 fastpath_glDeleteVertexArraysOES(GLsizei n, const GLuint *arrays)
8314 {
8315         int i;
8316         GLuint *objid_array = NULL;
8317
8318         DEFINE_FASTPAH_GL_FUNC();
8319         _COREGL_FASTPATH_FUNC_BEGIN();
8320         INIT_FASTPATH_GL_FUNC();
8321
8322         if (n < 0) {
8323                 _set_gl_error(GL_INVALID_VALUE);
8324                 goto finish;
8325         }
8326         if (n == 0) goto finish;
8327         if (arrays == NULL) goto finish;
8328
8329         AST(current_ctx->ostate.shared != NULL);
8330
8331         objid_array = (GLuint *)calloc(1, sizeof(GLuint) * n);
8332         {
8333                 int real_n = 0;
8334
8335                 for (i = 0; i < n; i++) {
8336                         int real_objid = _COREGL_INT_INIT_VALUE;
8337                         if (arrays[i] == 0) continue;
8338
8339                         real_objid = fastpath_ostate_get_object(&current_ctx->ostate,
8340                                                                 GL_OBJECT_TYPE_VERTEXARRAY, arrays[i]);
8341                         if (real_objid == 0) continue;
8342
8343                         AST(fastpath_ostate_remove_object(&current_ctx->ostate,
8344                                                           GL_OBJECT_TYPE_VERTEXARRAY, arrays[i]) == 1);
8345                         objid_array[real_n++] = real_objid;
8346                 }
8347
8348                 IF_GL_SUCCESS(_orig_fastpath_glDeleteVertexArraysOES(real_n, objid_array)) {
8349                         for (i = 0; i < real_n; i++) {
8350                                 General_Trace_List *current = NULL;
8351                                 current = current_ctx->ostate.shared->using_gctxs;
8352
8353                                 while (current != NULL) {
8354                                         GLGlueContext *cur_gctx = (GLGlueContext *)current->value;
8355
8356                                         if (cur_gctx->gl_vertex_array_binding[0] == objid_array[i])
8357                                                 cur_gctx->gl_vertex_array_binding[0] = 0;
8358
8359                                         current = current->next;
8360                                 }
8361                         }
8362                 }
8363         }
8364
8365         goto finish;
8366
8367 finish:
8368         if (objid_array != NULL) {
8369                 free(objid_array);
8370                 objid_array = NULL;
8371         }
8372         _COREGL_FASTPATH_FUNC_END();
8373 }
8374
8375 void
8376 fastpath_glClearDepthfOES(GLclampf depth)
8377 {
8378         DEFINE_FASTPAH_GL_FUNC();
8379         _COREGL_FASTPATH_FUNC_BEGIN();
8380         INIT_FASTPATH_GL_FUNC();
8381
8382         CURR_STATE_COMPARE(gl_depth_clear_value, depth) {
8383                 IF_GL_SUCCESS(_orig_fastpath_glClearDepthfOES(depth)) {
8384                         current_ctx->_clear_flag2 |= _CLEAR_FLAG2_BIT_gl_depth_clear_value;
8385                         current_ctx->gl_depth_clear_value[0] = depth;
8386                 }
8387         }
8388         goto finish;
8389
8390 finish:
8391         _COREGL_FASTPATH_FUNC_END();
8392 }
8393
8394 void
8395 fastpath_glClearDepthxOES(GLclampx depth)
8396 {
8397         DEFINE_FASTPAH_GL_FUNC();
8398         _COREGL_FASTPATH_FUNC_BEGIN();
8399         INIT_FASTPATH_GL_FUNC();
8400
8401         CURR_STATE_COMPARE(gl_depth_clear_value, depth) {
8402                 IF_GL_SUCCESS(_orig_fastpath_glClearDepthxOES(depth)) {
8403                         current_ctx->_clear_flag2 |= _CLEAR_FLAG2_BIT_gl_depth_clear_value;
8404                         current_ctx->gl_depth_clear_value[0] = depth;
8405                 }
8406         }
8407         goto finish;
8408
8409 finish:
8410         _COREGL_FASTPATH_FUNC_END();
8411 }