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