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