Home | History | Annotate | Download | only in GLESv2_enc
      1 /*
      2 * Copyright (C) 2011 The Android Open Source Project
      3 *
      4 * Licensed under the Apache License, Version 2.0 (the "License");
      5 * you may not use this file except in compliance with the License.
      6 * You may obtain a copy of the License at
      7 *
      8 * http://www.apache.org/licenses/LICENSE-2.0
      9 *
     10 * Unless required by applicable law or agreed to in writing, software
     11 * distributed under the License is distributed on an "AS IS" BASIS,
     12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     13 * See the License for the specific language governing permissions and
     14 * limitations under the License.
     15 */
     16 #ifndef _GL2_ENCODER_H_
     17 #define _GL2_ENCODER_H_
     18 
     19 #include "gl2_enc.h"
     20 #include "GLClientState.h"
     21 #include "GLSharedGroup.h"
     22 #include "FixedBuffer.h"
     23 
     24 #include <string>
     25 
     26 class GL2Encoder : public gl2_encoder_context_t {
     27 public:
     28     GL2Encoder(IOStream *stream, ChecksumCalculator* protocol);
     29     virtual ~GL2Encoder();
     30     void setClientState(GLClientState *state) {
     31         m_state = state;
     32     }
     33     void setClientStateMakeCurrent(GLClientState *state,
     34                                    int majorVersion,
     35                                    int minorVersion,
     36                                    int deviceMajorVersion,
     37                                    int deviceMinorVersion) {
     38         m_state = state;
     39         m_state->fromMakeCurrent();
     40         m_currMajorVersion = majorVersion;
     41         m_currMinorVersion = minorVersion;
     42         m_deviceMajorVersion = deviceMajorVersion;
     43         m_deviceMinorVersion = deviceMinorVersion;
     44     }
     45     void setSharedGroup(GLSharedGroupPtr shared) {
     46         m_shared = shared;
     47         if (m_state && m_shared.Ptr())
     48             m_state->setTextureData(m_shared->getTextureData());
     49     }
     50     int majorVersion() const { return m_currMajorVersion; }
     51     int minorVersion() const { return m_currMinorVersion; }
     52     void setExtensions(const char* exts) {
     53         m_currExtensions = std::string(exts);
     54     }
     55     bool hasExtension(const char* ext) const {
     56         return m_currExtensions.find(ext) != std::string::npos;
     57     }
     58     const GLClientState *state() { return m_state; }
     59     const GLSharedGroupPtr shared() { return m_shared; }
     60     void flush() { m_stream->flush(); }
     61 
     62     void setInitialized(){ m_initialized = true; };
     63     bool isInitialized(){ return m_initialized; };
     64 
     65     virtual void setError(GLenum error){ m_error = error; };
     66     virtual GLenum getError() { return m_error; };
     67 
     68     void override2DTextureTarget(GLenum target);
     69     void restore2DTextureTarget(GLenum target);
     70     void associateEGLImage(GLenum target, GLeglImageOES eglImage);
     71 
     72     // Convenience functions for buffers
     73     GLuint boundBuffer(GLenum target) const;
     74     BufferData* getBufferData(GLenum target) const;
     75     BufferData* getBufferDataById(GLuint buffer) const;
     76     bool isBufferMapped(GLuint buffer) const;
     77     bool isBufferTargetMapped(GLenum target) const;
     78 
     79 private:
     80 
     81     int m_currMajorVersion;
     82     int m_currMinorVersion;
     83     int m_deviceMajorVersion;
     84     int m_deviceMinorVersion;
     85     std::string m_currExtensions;
     86 
     87     bool    m_initialized;
     88     GLClientState *m_state;
     89     GLSharedGroupPtr m_shared;
     90     GLenum  m_error;
     91 
     92     GLint *m_compressedTextureFormats;
     93     GLint m_num_compressedTextureFormats;
     94     GLint *getCompressedTextureFormats();
     95 
     96     GLint m_max_cubeMapTextureSize;
     97     GLint m_max_renderBufferSize;
     98     GLint m_max_textureSize;
     99     GLint m_max_3d_textureSize;
    100     GLint m_max_vertexAttribStride;
    101 
    102     GLuint m_ssbo_offset_align;
    103     GLuint m_ubo_offset_align;
    104 
    105     FixedBuffer m_fixedBuffer;
    106 
    107     int m_drawCallFlushCount;
    108 
    109     bool m_primitiveRestartEnabled;
    110     GLuint m_primitiveRestartIndex;
    111 
    112     void calcIndexRange(const void* indices,
    113                         GLenum type, GLsizei count,
    114                         int* minIndex, int* maxIndex);
    115     void* recenterIndices(const void* src,
    116                           GLenum type, GLsizei count,
    117                           int minIndex);
    118     void getBufferIndexRange(BufferData* buf, const void* dataWithOffset,
    119                              GLenum type, size_t count, size_t offset,
    120                              int* minIndex_out, int* maxIndex_out);
    121     void getVBOUsage(bool* hasClientArrays, bool* hasVBOs) const;
    122     void sendVertexAttributes(GLint first, GLsizei count, bool hasClientArrays, GLsizei primcount = 0);
    123     void flushDrawCall();
    124 
    125     bool updateHostTexture2DBinding(GLenum texUnit, GLenum newTarget);
    126     void updateHostTexture2DBindingsFromProgramData(GLuint program);
    127     bool texture2DNeedsOverride(GLenum target) const;
    128     bool isCompleteFbo(GLenum target, const GLClientState* state, GLenum attachment) const;
    129     bool checkFramebufferCompleteness(GLenum target, const GLClientState* state) const;
    130 
    131     glGetError_client_proc_t    m_glGetError_enc;
    132     static GLenum s_glGetError(void * self);
    133 
    134     glFlush_client_proc_t m_glFlush_enc;
    135     static void s_glFlush(void * self);
    136 
    137     glPixelStorei_client_proc_t m_glPixelStorei_enc;
    138     static void s_glPixelStorei(void *self, GLenum param, GLint value);
    139 
    140     glGetString_client_proc_t m_glGetString_enc;
    141     static const GLubyte * s_glGetString(void *self, GLenum name);
    142 
    143     glBindBuffer_client_proc_t m_glBindBuffer_enc;
    144     static void s_glBindBuffer(void *self, GLenum target, GLuint id);
    145 
    146 
    147     glBufferData_client_proc_t m_glBufferData_enc;
    148     static void s_glBufferData(void *self, GLenum target, GLsizeiptr size, const GLvoid * data, GLenum usage);
    149     glBufferSubData_client_proc_t m_glBufferSubData_enc;
    150     static void s_glBufferSubData(void *self, GLenum target, GLintptr offset, GLsizeiptr size, const GLvoid * data);
    151 
    152     glGenBuffers_client_proc_t m_glGenBuffers_enc;
    153     static void s_glGenBuffers(void *self, GLsizei n, GLuint * buffers);
    154 
    155     glDeleteBuffers_client_proc_t m_glDeleteBuffers_enc;
    156     static void s_glDeleteBuffers(void *self, GLsizei n, const GLuint * buffers);
    157 
    158     glDrawArrays_client_proc_t m_glDrawArrays_enc;
    159     static void s_glDrawArrays(void *self, GLenum mode, GLint first, GLsizei count);
    160 
    161     glDrawElements_client_proc_t m_glDrawElements_enc;
    162     static void s_glDrawElements(void *self, GLenum mode, GLsizei count, GLenum type, const void *indices);
    163 
    164 
    165     glGetIntegerv_client_proc_t m_glGetIntegerv_enc;
    166     static void s_glGetIntegerv(void *self, GLenum pname, GLint *ptr);
    167 
    168     glGetFloatv_client_proc_t m_glGetFloatv_enc;
    169     static void s_glGetFloatv(void *self, GLenum pname, GLfloat *ptr);
    170 
    171     glGetBooleanv_client_proc_t m_glGetBooleanv_enc;
    172     static void s_glGetBooleanv(void *self, GLenum pname, GLboolean *ptr);
    173 
    174     glVertexAttribPointer_client_proc_t m_glVertexAttribPointer_enc;
    175     static void s_glVertexAttribPointer(void *self, GLuint indx, GLint size, GLenum type,
    176                                         GLboolean normalized, GLsizei stride, const GLvoid * ptr);
    177 
    178     glEnableVertexAttribArray_client_proc_t m_glEnableVertexAttribArray_enc;
    179     static void s_glEnableVertexAttribArray(void *self, GLuint index);
    180 
    181     glDisableVertexAttribArray_client_proc_t m_glDisableVertexAttribArray_enc;
    182     static void s_glDisableVertexAttribArray(void *self, GLuint index);
    183 
    184     glGetVertexAttribiv_client_proc_t m_glGetVertexAttribiv_enc;
    185     static void s_glGetVertexAttribiv(void *self, GLuint index, GLenum pname, GLint *params);
    186 
    187     glGetVertexAttribfv_client_proc_t m_glGetVertexAttribfv_enc;
    188     static void s_glGetVertexAttribfv(void *self, GLuint index, GLenum pname, GLfloat *params);
    189 
    190     glGetVertexAttribPointerv_client_proc_t m_glGetVertexAttribPointerv_enc;
    191     static void s_glGetVertexAttribPointerv(void *self, GLuint index, GLenum pname, GLvoid **pointer);
    192 
    193     static void s_glShaderBinary(void *self, GLsizei n, const GLuint *shaders, GLenum binaryformat, const void* binary, GLsizei length);
    194 
    195     static void s_glShaderSource(void *self, GLuint shader, GLsizei count, const GLchar * const *string, const GLint *length);
    196 
    197     static void s_glFinish(void *self);
    198 
    199     glLinkProgram_client_proc_t m_glLinkProgram_enc;
    200     static void s_glLinkProgram(void *self, GLuint program);
    201 
    202     glDeleteProgram_client_proc_t m_glDeleteProgram_enc;
    203     static void s_glDeleteProgram(void * self, GLuint program);
    204 
    205     glGetUniformiv_client_proc_t m_glGetUniformiv_enc;
    206     static void s_glGetUniformiv(void *self, GLuint program, GLint location , GLint *params);
    207 
    208     glGetUniformfv_client_proc_t m_glGetUniformfv_enc;
    209     static void s_glGetUniformfv(void *self, GLuint program, GLint location , GLfloat *params);
    210 
    211     glCreateProgram_client_proc_t m_glCreateProgram_enc;
    212     static GLuint s_glCreateProgram(void *self);
    213 
    214     glCreateShader_client_proc_t m_glCreateShader_enc;
    215     static GLuint s_glCreateShader(void *self, GLenum shaderType);
    216 
    217     glDeleteShader_client_proc_t m_glDeleteShader_enc;
    218     static void s_glDeleteShader(void *self, GLuint shader);
    219 
    220     glAttachShader_client_proc_t m_glAttachShader_enc;
    221     static void s_glAttachShader(void *self, GLuint program, GLuint shader);
    222 
    223     glDetachShader_client_proc_t m_glDetachShader_enc;
    224     static void s_glDetachShader(void *self, GLuint program, GLuint shader);
    225 
    226     glGetAttachedShaders_client_proc_t m_glGetAttachedShaders_enc;
    227     static void s_glGetAttachedShaders(void *self, GLuint program, GLsizei maxCount,
    228             GLsizei* count, GLuint* shaders);
    229 
    230     glGetShaderSource_client_proc_t m_glGetShaderSource_enc;
    231     static void s_glGetShaderSource(void *self, GLuint shader, GLsizei bufsize,
    232             GLsizei* length, GLchar* source);
    233 
    234     glGetShaderInfoLog_client_proc_t m_glGetShaderInfoLog_enc;
    235     static void s_glGetShaderInfoLog(void *self,GLuint shader,
    236             GLsizei bufsize, GLsizei* length, GLchar* infolog);
    237 
    238     glGetProgramInfoLog_client_proc_t m_glGetProgramInfoLog_enc;
    239     static void s_glGetProgramInfoLog(void *self,GLuint program,
    240             GLsizei bufsize, GLsizei* length, GLchar* infolog);
    241 
    242     glGetUniformLocation_client_proc_t m_glGetUniformLocation_enc;
    243     static int s_glGetUniformLocation(void *self, GLuint program, const GLchar *name);
    244     glUseProgram_client_proc_t m_glUseProgram_enc;
    245 
    246     glUniform1f_client_proc_t m_glUniform1f_enc;
    247     glUniform1fv_client_proc_t m_glUniform1fv_enc;
    248     glUniform1i_client_proc_t m_glUniform1i_enc;
    249     glUniform1iv_client_proc_t m_glUniform1iv_enc;
    250     glUniform2f_client_proc_t m_glUniform2f_enc;
    251     glUniform2fv_client_proc_t m_glUniform2fv_enc;
    252     glUniform2i_client_proc_t m_glUniform2i_enc;
    253     glUniform2iv_client_proc_t m_glUniform2iv_enc;
    254     glUniform3f_client_proc_t m_glUniform3f_enc;
    255     glUniform3fv_client_proc_t m_glUniform3fv_enc;
    256     glUniform3i_client_proc_t m_glUniform3i_enc;
    257     glUniform3iv_client_proc_t m_glUniform3iv_enc;
    258     glUniform4f_client_proc_t m_glUniform4f_enc;
    259     glUniform4fv_client_proc_t m_glUniform4fv_enc;
    260     glUniform4i_client_proc_t m_glUniform4i_enc;
    261     glUniform4iv_client_proc_t m_glUniform4iv_enc;
    262     glUniformMatrix2fv_client_proc_t m_glUniformMatrix2fv_enc;
    263     glUniformMatrix3fv_client_proc_t m_glUniformMatrix3fv_enc;
    264     glUniformMatrix4fv_client_proc_t m_glUniformMatrix4fv_enc;
    265 
    266     static void s_glUseProgram(void *self, GLuint program);
    267 	static void s_glUniform1f(void *self , GLint location, GLfloat x);
    268 	static void s_glUniform1fv(void *self , GLint location, GLsizei count, const GLfloat* v);
    269 	static void s_glUniform1i(void *self , GLint location, GLint x);
    270 	static void s_glUniform1iv(void *self , GLint location, GLsizei count, const GLint* v);
    271 	static void s_glUniform2f(void *self , GLint location, GLfloat x, GLfloat y);
    272 	static void s_glUniform2fv(void *self , GLint location, GLsizei count, const GLfloat* v);
    273 	static void s_glUniform2i(void *self , GLint location, GLint x, GLint y);
    274 	static void s_glUniform2iv(void *self , GLint location, GLsizei count, const GLint* v);
    275 	static void s_glUniform3f(void *self , GLint location, GLfloat x, GLfloat y, GLfloat z);
    276 	static void s_glUniform3fv(void *self , GLint location, GLsizei count, const GLfloat* v);
    277 	static void s_glUniform3i(void *self , GLint location, GLint x, GLint y, GLint z);
    278 	static void s_glUniform3iv(void *self , GLint location, GLsizei count, const GLint* v);
    279 	static void s_glUniform4f(void *self , GLint location, GLfloat x, GLfloat y, GLfloat z, GLfloat w);
    280 	static void s_glUniform4fv(void *self , GLint location, GLsizei count, const GLfloat* v);
    281 	static void s_glUniform4i(void *self , GLint location, GLint x, GLint y, GLint z, GLint w);
    282 	static void s_glUniform4iv(void *self , GLint location, GLsizei count, const GLint* v);
    283 	static void s_glUniformMatrix2fv(void *self , GLint location, GLsizei count, GLboolean transpose, const GLfloat* value);
    284 	static void s_glUniformMatrix3fv(void *self , GLint location, GLsizei count, GLboolean transpose, const GLfloat* value);
    285 	static void s_glUniformMatrix4fv(void *self , GLint location, GLsizei count, GLboolean transpose, const GLfloat* value);
    286 
    287     glActiveTexture_client_proc_t m_glActiveTexture_enc;
    288     glBindTexture_client_proc_t m_glBindTexture_enc;
    289     glDeleteTextures_client_proc_t m_glDeleteTextures_enc;
    290     glGetTexParameterfv_client_proc_t m_glGetTexParameterfv_enc;
    291     glGetTexParameteriv_client_proc_t m_glGetTexParameteriv_enc;
    292     glTexParameterf_client_proc_t m_glTexParameterf_enc;
    293     glTexParameterfv_client_proc_t m_glTexParameterfv_enc;
    294     glTexParameteri_client_proc_t m_glTexParameteri_enc;
    295     glTexParameteriv_client_proc_t m_glTexParameteriv_enc;
    296     glTexImage2D_client_proc_t m_glTexImage2D_enc;
    297     glTexSubImage2D_client_proc_t m_glTexSubImage2D_enc;
    298     glCopyTexImage2D_client_proc_t m_glCopyTexImage2D_enc;
    299 
    300     static void s_glActiveTexture(void* self, GLenum texture);
    301     static void s_glBindTexture(void* self, GLenum target, GLuint texture);
    302     static void s_glDeleteTextures(void* self, GLsizei n, const GLuint* textures);
    303     static void s_glGetTexParameterfv(void* self, GLenum target, GLenum pname, GLfloat* params);
    304     static void s_glGetTexParameteriv(void* self, GLenum target, GLenum pname, GLint* params);
    305     static void s_glTexParameterf(void* self, GLenum target, GLenum pname, GLfloat param);
    306     static void s_glTexParameterfv(void* self, GLenum target, GLenum pname, const GLfloat* params);
    307     static void s_glTexParameteri(void* self, GLenum target, GLenum pname, GLint param);
    308     static void s_glTexParameteriv(void* self, GLenum target, GLenum pname, const GLint* params);
    309     static void s_glTexImage2D(void* self, GLenum target, GLint level, GLint internalformat,
    310             GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type,
    311             const GLvoid* pixels);
    312     static void s_glTexSubImage2D(void* self, GLenum target, GLint level, GLint xoffset,
    313             GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type,
    314             const GLvoid* pixels);
    315     static void s_glCopyTexImage2D(void* self, GLenum target, GLint level, GLenum internalformat,
    316             GLint x, GLint y, GLsizei width, GLsizei height, GLint border);
    317 
    318     glGenRenderbuffers_client_proc_t m_glGenRenderbuffers_enc;
    319     static void s_glGenRenderbuffers(void* self, GLsizei n, GLuint* renderbuffers);
    320     glDeleteRenderbuffers_client_proc_t m_glDeleteRenderbuffers_enc;
    321     static void s_glDeleteRenderbuffers(void* self, GLsizei n, const GLuint* renderbuffers);
    322 
    323     glBindRenderbuffer_client_proc_t m_glBindRenderbuffer_enc;
    324     static void s_glBindRenderbuffer(void* self, GLenum target, GLuint renderbuffer);
    325 
    326     glRenderbufferStorage_client_proc_t m_glRenderbufferStorage_enc;
    327     static void s_glRenderbufferStorage(void* self, GLenum target, GLenum internalformat, GLsizei width, GLsizei height);
    328 
    329     glFramebufferRenderbuffer_client_proc_t m_glFramebufferRenderbuffer_enc;
    330     static void s_glFramebufferRenderbuffer(void* self, GLenum target, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer);
    331 
    332     glGenFramebuffers_client_proc_t m_glGenFramebuffers_enc;
    333     static void s_glGenFramebuffers(void* self, GLsizei n, GLuint* framebuffers);
    334     glDeleteFramebuffers_client_proc_t m_glDeleteFramebuffers_enc;
    335     static void s_glDeleteFramebuffers(void* self, GLsizei n, const GLuint* framebuffers);
    336 
    337     glBindFramebuffer_client_proc_t m_glBindFramebuffer_enc;
    338     static void s_glBindFramebuffer(void* self, GLenum target, GLuint framebuffer);
    339 
    340     glFramebufferTexture2D_client_proc_t m_glFramebufferTexture2D_enc;
    341     static void s_glFramebufferTexture2D(void* self, GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level);
    342 
    343     glFramebufferTexture3DOES_client_proc_t m_glFramebufferTexture3DOES_enc;
    344     static void s_glFramebufferTexture3DOES(void*self, GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level, GLint zoffset);
    345 
    346     glGetFramebufferAttachmentParameteriv_client_proc_t m_glGetFramebufferAttachmentParameteriv_enc;
    347     static void s_glGetFramebufferAttachmentParameteriv(void* self, GLenum target, GLenum attachment, GLenum pname, GLint* params);
    348 
    349     glCheckFramebufferStatus_client_proc_t m_glCheckFramebufferStatus_enc;
    350     static GLenum s_glCheckFramebufferStatus(void* self,
    351             GLenum target);
    352 
    353     // GLES 3.0-specific custom encoders
    354 
    355     // VAO (+ ES 2 extension)
    356     glGenVertexArrays_client_proc_t m_glGenVertexArrays_enc;
    357     glDeleteVertexArrays_client_proc_t m_glDeleteVertexArrays_enc;
    358     glBindVertexArray_client_proc_t m_glBindVertexArray_enc;
    359     glGenVertexArraysOES_client_proc_t m_glGenVertexArraysOES_enc;
    360     glDeleteVertexArraysOES_client_proc_t m_glDeleteVertexArraysOES_enc;
    361     glBindVertexArrayOES_client_proc_t m_glBindVertexArrayOES_enc;
    362     static void s_glGenVertexArrays(void *self, GLsizei n, GLuint* arrays);
    363     static void s_glDeleteVertexArrays(void *self , GLsizei n, const GLuint* arrays);
    364     static void s_glBindVertexArray(void *self , GLuint array);
    365 
    366     // Mapped buffers
    367     static void* s_glMapBufferRange(void* self, GLenum target, GLintptr offset, GLsizeiptr length, GLbitfield access);
    368     static GLboolean s_glUnmapBuffer(void* self, GLenum target);
    369     static void s_glFlushMappedBufferRange(void* self, GLenum target, GLintptr offset, GLsizeiptr length);
    370 
    371     // Custom encodes for 2D compressed textures b/c we need to account for
    372     // nonzero GL_PIXEL_UNPACK_BUFFER
    373     glCompressedTexImage2D_client_proc_t m_glCompressedTexImage2D_enc;
    374     static void s_glCompressedTexImage2D(void* self, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const GLvoid* data);
    375     glCompressedTexSubImage2D_client_proc_t m_glCompressedTexSubImage2D_enc;
    376     static void s_glCompressedTexSubImage2D(void* self, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const GLvoid* data);
    377 
    378     // Indexed, range bind
    379     glBindBufferRange_client_proc_t m_glBindBufferRange_enc;
    380     static void s_glBindBufferRange(void *self , GLenum target, GLuint index, GLuint buffer, GLintptr offset, GLsizeiptr size);
    381 
    382     glBindBufferBase_client_proc_t m_glBindBufferBase_enc;
    383     static void s_glBindBufferBase(void *self , GLenum target, GLuint index, GLuint buffer);
    384 
    385     glCopyBufferSubData_client_proc_t m_glCopyBufferSubData_enc;
    386     static void s_glCopyBufferSubData(void *self , GLenum readtarget, GLenum writetarget, GLintptr readoffset, GLintptr writeoffset, GLsizeiptr size);
    387 
    388     glGetBufferParameteriv_client_proc_t m_glGetBufferParameteriv_enc;
    389     static void s_glGetBufferParameteriv(void* self, GLenum target, GLenum pname, GLint* params);
    390 
    391     glGetBufferParameteri64v_client_proc_t m_glGetBufferParameteri64v_enc;
    392     static void s_glGetBufferParameteri64v(void* self, GLenum target, GLenum pname, GLint64* params);
    393 
    394     glGetBufferPointerv_client_proc_t m_glGetBufferPointerv_enc;
    395     static void s_glGetBufferPointerv(void* self, GLenum target, GLenum pname, GLvoid** params);
    396 
    397     glGetUniformIndices_client_proc_t m_glGetUniformIndices_enc;
    398     static void s_glGetUniformIndices(void* self, GLuint program, GLsizei uniformCount, const GLchar ** uniformNames, GLuint* uniformIndices);
    399 
    400     glUniform1ui_client_proc_t m_glUniform1ui_enc;
    401     glUniform1uiv_client_proc_t m_glUniform1uiv_enc;
    402     glUniform2ui_client_proc_t m_glUniform2ui_enc;
    403     glUniform2uiv_client_proc_t m_glUniform2uiv_enc;
    404     glUniform3ui_client_proc_t m_glUniform3ui_enc;
    405     glUniform3uiv_client_proc_t m_glUniform3uiv_enc;
    406     glUniform4ui_client_proc_t m_glUniform4ui_enc;
    407     glUniform4uiv_client_proc_t m_glUniform4uiv_enc;
    408     glUniformMatrix2x3fv_client_proc_t m_glUniformMatrix2x3fv_enc;
    409     glUniformMatrix2x4fv_client_proc_t m_glUniformMatrix2x4fv_enc;
    410     glUniformMatrix3x2fv_client_proc_t m_glUniformMatrix3x2fv_enc;
    411     glUniformMatrix3x4fv_client_proc_t m_glUniformMatrix3x4fv_enc;
    412     glUniformMatrix4x2fv_client_proc_t m_glUniformMatrix4x2fv_enc;
    413     glUniformMatrix4x3fv_client_proc_t m_glUniformMatrix4x3fv_enc;
    414 
    415     static void s_glUniform1ui(void* self, GLint location, GLuint v0);
    416     static void s_glUniform2ui(void* self, GLint location, GLuint v0, GLuint v1);
    417     static void s_glUniform3ui(void* self, GLint location, GLuint v0, GLuint v1, GLuint v2);
    418     static void s_glUniform4ui(void* self, GLint location, GLint v0, GLuint v1, GLuint v2, GLuint v3);
    419     static void s_glUniform1uiv(void* self, GLint location, GLsizei count, const GLuint *value);
    420     static void s_glUniform2uiv(void* self, GLint location, GLsizei count, const GLuint *value);
    421     static void s_glUniform3uiv(void* self, GLint location, GLsizei count, const GLuint *value);
    422     static void s_glUniform4uiv(void* self, GLint location, GLsizei count, const GLuint *value);
    423     static void s_glUniformMatrix2x3fv(void* self, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value);
    424     static void s_glUniformMatrix3x2fv(void* self, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value);
    425     static void s_glUniformMatrix2x4fv(void* self, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value);
    426     static void s_glUniformMatrix4x2fv(void* self, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value);
    427     static void s_glUniformMatrix3x4fv(void* self, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value);
    428     static void s_glUniformMatrix4x3fv(void* self, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value);
    429 
    430     glGetUniformuiv_client_proc_t m_glGetUniformuiv_enc;
    431     static void s_glGetUniformuiv(void *self, GLuint program, GLint location, GLuint* params);
    432 
    433     glGetActiveUniformBlockiv_client_proc_t m_glGetActiveUniformBlockiv_enc;
    434     static void s_glGetActiveUniformBlockiv(void* self, GLuint program, GLuint uniformBlockIndex, GLenum pname, GLint* params);
    435 
    436     glGetVertexAttribIiv_client_proc_t m_glGetVertexAttribIiv_enc;
    437     static void s_glGetVertexAttribIiv(void* self, GLuint index, GLenum pname, GLint* params);
    438 
    439     glGetVertexAttribIuiv_client_proc_t m_glGetVertexAttribIuiv_enc;
    440     static void s_glGetVertexAttribIuiv(void* self, GLuint index, GLenum pname, GLuint* params);
    441 
    442     static void s_glVertexAttribIPointer(void* self, GLuint index, GLint size, GLenum type, GLsizei stride, const GLvoid* pointer);
    443 
    444     glVertexAttribDivisor_client_proc_t m_glVertexAttribDivisor_enc;
    445     static void s_glVertexAttribDivisor(void* self, GLuint index, GLuint divisor);
    446 
    447     glRenderbufferStorageMultisample_client_proc_t m_glRenderbufferStorageMultisample_enc;
    448     static void s_glRenderbufferStorageMultisample(void* self, GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height);
    449 
    450     glDrawBuffers_client_proc_t m_glDrawBuffers_enc;
    451     static void s_glDrawBuffers(void* self, GLsizei n, const GLenum* bufs);
    452 
    453     glReadBuffer_client_proc_t m_glReadBuffer_enc;
    454     static void s_glReadBuffer(void* self, GLenum src);
    455 
    456     glFramebufferTextureLayer_client_proc_t m_glFramebufferTextureLayer_enc;
    457     static void s_glFramebufferTextureLayer(void* self, GLenum target, GLenum attachment, GLuint texture, GLint level, GLint layer);
    458 
    459     glTexStorage2D_client_proc_t m_glTexStorage2D_enc;
    460     static void s_glTexStorage2D(void* self, GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height);
    461 
    462     static void s_glTransformFeedbackVaryings(void* self, GLuint program, GLsizei count, const char** varyings, GLenum bufferMode);
    463 
    464     glBeginTransformFeedback_client_proc_t m_glBeginTransformFeedback_enc;
    465     static void s_glBeginTransformFeedback(void* self, GLenum primitiveMode);
    466 
    467     glEndTransformFeedback_client_proc_t m_glEndTransformFeedback_enc;
    468     static void s_glEndTransformFeedback(void* self);
    469 
    470     glPauseTransformFeedback_client_proc_t m_glPauseTransformFeedback_enc;
    471     static void s_glPauseTransformFeedback(void* self);
    472 
    473     glResumeTransformFeedback_client_proc_t m_glResumeTransformFeedback_enc;
    474     static void s_glResumeTransformFeedback(void* self);
    475 
    476     glTexImage3D_client_proc_t m_glTexImage3D_enc;
    477     static void s_glTexImage3D(void* self, GLenum target, GLint level, GLint internalFormat,
    478                                GLsizei width, GLsizei height, GLsizei depth,
    479                                GLint border, GLenum format, GLenum type, const GLvoid* data);
    480 
    481     glTexSubImage3D_client_proc_t m_glTexSubImage3D_enc;
    482     static void s_glTexSubImage3D(void* self, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const GLvoid* data);
    483 
    484     glCompressedTexImage3D_client_proc_t m_glCompressedTexImage3D_enc;
    485     static void s_glCompressedTexImage3D(void* self, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLsizei imageSize, const GLvoid* data);
    486     glCompressedTexSubImage3D_client_proc_t m_glCompressedTexSubImage3D_enc;
    487     static void s_glCompressedTexSubImage3D(void* self, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const GLvoid* data);
    488 
    489 
    490     glTexStorage3D_client_proc_t m_glTexStorage3D_enc;
    491     static void s_glTexStorage3D(void* self, GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth);
    492 
    493     glDrawArraysInstanced_client_proc_t m_glDrawArraysInstanced_enc;
    494     static void s_glDrawArraysInstanced(void* self, GLenum mode, GLint first, GLsizei count, GLsizei primcount);
    495 
    496     static void s_glDrawElementsInstanced(void* self, GLenum mode, GLsizei count, GLenum type, const void* indices, GLsizei primcount);
    497 
    498     glDrawRangeElements_client_proc_t m_glDrawRangeElements_enc;
    499     static void s_glDrawRangeElements(void* self, GLenum mode, GLuint start, GLuint end, GLsizei count, GLenum type, const void* indices);
    500 
    501     static const GLubyte* s_glGetStringi(void* self, GLenum name, GLuint index);
    502 
    503     glGetProgramBinary_client_proc_t m_glGetProgramBinary_enc;
    504     static void s_glGetProgramBinary(void* self, GLuint program, GLsizei bufSize, GLsizei* length, GLenum* binaryFormat, void* binary);
    505 
    506     glReadPixels_client_proc_t m_glReadPixels_enc;
    507     static void s_glReadPixels(void* self, GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, GLvoid* pixels);
    508 
    509     glEnable_client_proc_t m_glEnable_enc;
    510     static void s_glEnable(void* self, GLenum what);
    511     glDisable_client_proc_t m_glDisable_enc;
    512     static void s_glDisable(void* self, GLenum what);
    513 
    514     glClearBufferiv_client_proc_t m_glClearBufferiv_enc;
    515     static void s_glClearBufferiv(void* self, GLenum buffer, GLint drawBuffer, const GLint* value);
    516 
    517     glClearBufferuiv_client_proc_t m_glClearBufferuiv_enc;
    518     static void s_glClearBufferuiv(void* self, GLenum buffer, GLint drawBuffer, const GLuint* value);
    519 
    520     glClearBufferfv_client_proc_t m_glClearBufferfv_enc;
    521     static void s_glClearBufferfv(void* self, GLenum buffer, GLint drawBuffer, const GLfloat* value);
    522 
    523     glBlitFramebuffer_client_proc_t m_glBlitFramebuffer_enc;
    524     static void s_glBlitFramebuffer(void* self, GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, GLbitfield mask, GLenum filter);
    525 
    526     static void s_glGetInternalformativ(void* self, GLenum target, GLenum internalformat, GLenum pname, GLsizei bufSize, GLint *params);
    527 
    528     glGenerateMipmap_client_proc_t m_glGenerateMipmap_enc;
    529     static void s_glGenerateMipmap(void* self, GLenum target);
    530 
    531     glBindSampler_client_proc_t m_glBindSampler_enc;
    532     static void s_glBindSampler(void* self, GLuint unit, GLuint sampler);
    533 
    534     static GLsync s_glFenceSync(void* self, GLenum condition, GLbitfield flags);
    535     static GLenum s_glClientWaitSync(void* self, GLsync wait_on, GLbitfield flags, GLuint64 timeout);
    536     static void s_glWaitSync(void* self, GLsync wait_on, GLbitfield flags, GLuint64 timeout);
    537     static void s_glDeleteSync(void* self, GLsync to_delete);
    538     static GLboolean s_glIsSync(void* self, GLsync sync);
    539     static void s_glGetSynciv(void* self, GLsync sync, GLenum pname, GLsizei bufSize, GLsizei *length, GLint *values);
    540 
    541     glGetIntegeri_v_client_proc_t m_glGetIntegeri_v_enc;
    542     static void s_glGetIntegeri_v(void* self, GLenum target, GLuint index, GLint* params);
    543 
    544     glGetInteger64i_v_client_proc_t m_glGetInteger64i_v_enc;
    545     static void s_glGetInteger64i_v(void* self, GLenum target, GLuint index, GLint64* params);
    546 
    547     glGetShaderiv_client_proc_t m_glGetShaderiv_enc;
    548     static void s_glGetShaderiv(void* self, GLuint shader, GLenum pname, GLint* params);
    549 
    550     // 3.1
    551     glActiveShaderProgram_client_proc_t m_glActiveShaderProgram_enc;
    552     static void s_glActiveShaderProgram(void* self, GLuint pipeline, GLuint program);
    553     static GLuint s_glCreateShaderProgramv(void* self, GLenum type, GLsizei count, const char** strings);
    554 
    555     glProgramUniform1f_client_proc_t m_glProgramUniform1f_enc;
    556     glProgramUniform1fv_client_proc_t m_glProgramUniform1fv_enc;
    557     glProgramUniform1i_client_proc_t m_glProgramUniform1i_enc;
    558     glProgramUniform1iv_client_proc_t m_glProgramUniform1iv_enc;
    559     glProgramUniform1ui_client_proc_t m_glProgramUniform1ui_enc;
    560     glProgramUniform1uiv_client_proc_t m_glProgramUniform1uiv_enc;
    561     glProgramUniform2f_client_proc_t m_glProgramUniform2f_enc;
    562     glProgramUniform2fv_client_proc_t m_glProgramUniform2fv_enc;
    563     glProgramUniform2i_client_proc_t m_glProgramUniform2i_enc;
    564     glProgramUniform2iv_client_proc_t m_glProgramUniform2iv_enc;
    565     glProgramUniform2ui_client_proc_t m_glProgramUniform2ui_enc;
    566     glProgramUniform2uiv_client_proc_t m_glProgramUniform2uiv_enc;
    567     glProgramUniform3f_client_proc_t m_glProgramUniform3f_enc;
    568     glProgramUniform3fv_client_proc_t m_glProgramUniform3fv_enc;
    569     glProgramUniform3i_client_proc_t m_glProgramUniform3i_enc;
    570     glProgramUniform3iv_client_proc_t m_glProgramUniform3iv_enc;
    571     glProgramUniform3ui_client_proc_t m_glProgramUniform3ui_enc;
    572     glProgramUniform3uiv_client_proc_t m_glProgramUniform3uiv_enc;
    573     glProgramUniform4f_client_proc_t m_glProgramUniform4f_enc;
    574     glProgramUniform4fv_client_proc_t m_glProgramUniform4fv_enc;
    575     glProgramUniform4i_client_proc_t m_glProgramUniform4i_enc;
    576     glProgramUniform4iv_client_proc_t m_glProgramUniform4iv_enc;
    577     glProgramUniform4ui_client_proc_t m_glProgramUniform4ui_enc;
    578     glProgramUniform4uiv_client_proc_t m_glProgramUniform4uiv_enc;
    579     glProgramUniformMatrix2fv_client_proc_t m_glProgramUniformMatrix2fv_enc;
    580     glProgramUniformMatrix2x3fv_client_proc_t m_glProgramUniformMatrix2x3fv_enc;
    581     glProgramUniformMatrix2x4fv_client_proc_t m_glProgramUniformMatrix2x4fv_enc;
    582     glProgramUniformMatrix3fv_client_proc_t m_glProgramUniformMatrix3fv_enc;
    583     glProgramUniformMatrix3x2fv_client_proc_t m_glProgramUniformMatrix3x2fv_enc;
    584     glProgramUniformMatrix3x4fv_client_proc_t m_glProgramUniformMatrix3x4fv_enc;
    585     glProgramUniformMatrix4fv_client_proc_t m_glProgramUniformMatrix4fv_enc;
    586     glProgramUniformMatrix4x2fv_client_proc_t m_glProgramUniformMatrix4x2fv_enc;
    587     glProgramUniformMatrix4x3fv_client_proc_t m_glProgramUniformMatrix4x3fv_enc;
    588 
    589     static void s_glProgramUniform1f(void* self, GLuint program, GLint location, GLfloat v0);
    590     static void s_glProgramUniform2f(void* self, GLuint program, GLint location, GLfloat v0, GLfloat v1);
    591     static void s_glProgramUniform3f(void* self, GLuint program, GLint location, GLfloat v0, GLfloat v1, GLfloat v2);
    592     static void s_glProgramUniform4f(void* self, GLuint program, GLint location, GLfloat v0, GLfloat v1, GLfloat v2, GLfloat v3);
    593     static void s_glProgramUniform1i(void* self, GLuint program, GLint location, GLint v0);
    594     static void s_glProgramUniform2i(void* self, GLuint program, GLint location, GLint v0, GLint v1);
    595     static void s_glProgramUniform3i(void* self, GLuint program, GLint location, GLint v0, GLint v1, GLint v2);
    596     static void s_glProgramUniform4i(void* self, GLuint program, GLint location, GLint v0, GLint v1, GLint v2, GLint v3);
    597     static void s_glProgramUniform1ui(void* self, GLuint program, GLint location, GLuint v0);
    598     static void s_glProgramUniform2ui(void* self, GLuint program, GLint location, GLint v0, GLuint v1);
    599     static void s_glProgramUniform3ui(void* self, GLuint program, GLint location, GLint v0, GLint v1, GLuint v2);
    600     static void s_glProgramUniform4ui(void* self, GLuint program, GLint location, GLint v0, GLint v1, GLint v2, GLuint v3);
    601     static void s_glProgramUniform1fv(void* self, GLuint program, GLint location, GLsizei count, const GLfloat *value);
    602     static void s_glProgramUniform2fv(void* self, GLuint program, GLint location, GLsizei count, const GLfloat *value);
    603     static void s_glProgramUniform3fv(void* self, GLuint program, GLint location, GLsizei count, const GLfloat *value);
    604     static void s_glProgramUniform4fv(void* self, GLuint program, GLint location, GLsizei count, const GLfloat *value);
    605     static void s_glProgramUniform1iv(void* self, GLuint program, GLint location, GLsizei count, const GLint *value);
    606     static void s_glProgramUniform2iv(void* self, GLuint program, GLint location, GLsizei count, const GLint *value);
    607     static void s_glProgramUniform3iv(void* self, GLuint program, GLint location, GLsizei count, const GLint *value);
    608     static void s_glProgramUniform4iv(void* self, GLuint program, GLint location, GLsizei count, const GLint *value);
    609     static void s_glProgramUniform1uiv(void* self, GLuint program, GLint location, GLsizei count, const GLuint *value);
    610     static void s_glProgramUniform2uiv(void* self, GLuint program, GLint location, GLsizei count, const GLuint *value);
    611     static void s_glProgramUniform3uiv(void* self, GLuint program, GLint location, GLsizei count, const GLuint *value);
    612     static void s_glProgramUniform4uiv(void* self, GLuint program, GLint location, GLsizei count, const GLuint *value);
    613     static void s_glProgramUniformMatrix2fv(void* self, GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value);
    614     static void s_glProgramUniformMatrix3fv(void* self, GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value);
    615     static void s_glProgramUniformMatrix4fv(void* self, GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value);
    616     static void s_glProgramUniformMatrix2x3fv(void* self, GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value);
    617     static void s_glProgramUniformMatrix3x2fv(void* self, GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value);
    618     static void s_glProgramUniformMatrix2x4fv(void* self, GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value);
    619     static void s_glProgramUniformMatrix4x2fv(void* self, GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value);
    620     static void s_glProgramUniformMatrix3x4fv(void* self, GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value);
    621     static void s_glProgramUniformMatrix4x3fv(void* self, GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value);
    622 
    623     glProgramParameteri_client_proc_t m_glProgramParameteri_enc;
    624     glUseProgramStages_client_proc_t m_glUseProgramStages_enc;
    625     glBindProgramPipeline_client_proc_t m_glBindProgramPipeline_enc;
    626 
    627     static void s_glProgramParameteri(void* self, GLuint program, GLenum pname, GLint value);
    628     static void s_glUseProgramStages(void *self, GLuint pipeline, GLbitfield stages, GLuint program);
    629     static void s_glBindProgramPipeline(void *self, GLuint pipeline);
    630 
    631     glGetProgramResourceiv_client_proc_t m_glGetProgramResourceiv_enc;
    632     glGetProgramResourceIndex_client_proc_t m_glGetProgramResourceIndex_enc;
    633     glGetProgramResourceLocation_client_proc_t m_glGetProgramResourceLocation_enc;
    634     glGetProgramResourceName_client_proc_t m_glGetProgramResourceName_enc;
    635     glGetProgramPipelineInfoLog_client_proc_t m_glGetProgramPipelineInfoLog_enc;
    636 
    637     static void s_glGetProgramResourceiv(void* self, GLuint program, GLenum programInterface, GLuint index, GLsizei propCount, const GLenum * props, GLsizei bufSize, GLsizei * length, GLint * params);
    638     static GLuint s_glGetProgramResourceIndex(void* self, GLuint program, GLenum programInterface, const char* name);
    639     static GLint s_glGetProgramResourceLocation(void* self, GLuint program, GLenum programInterface, const char* name);
    640     static void s_glGetProgramResourceName(void* self, GLuint program, GLenum programInterface, GLuint index, GLsizei bufSize, GLsizei* length, char* name);
    641 
    642     static void s_glGetProgramPipelineInfoLog(void* self, GLuint pipeline, GLsizei bufSize, GLsizei* length, GLchar* infoLog);
    643 
    644     // TODO: Compute shaders:
    645     // make sure it's OK to put memory barriers and compute dispatch
    646     // on the default encoding path
    647 
    648     glVertexAttribFormat_client_proc_t m_glVertexAttribFormat_enc;
    649     glVertexAttribIFormat_client_proc_t m_glVertexAttribIFormat_enc;
    650     glVertexBindingDivisor_client_proc_t m_glVertexBindingDivisor_enc;
    651     glVertexAttribBinding_client_proc_t m_glVertexAttribBinding_enc;
    652     glBindVertexBuffer_client_proc_t m_glBindVertexBuffer_enc;
    653 
    654     static void s_glVertexAttribFormat(void* self, GLuint attribindex, GLint size, GLenum type, GLboolean normalized, GLuint relativeoffset);
    655     static void s_glVertexAttribIFormat(void* self, GLuint attribindex, GLint size, GLenum type, GLuint relativeoffset);
    656     static void s_glVertexBindingDivisor(void* self, GLuint bindingindex, GLuint divisor);
    657     static void s_glVertexAttribBinding(void* self, GLuint attribindex, GLuint bindingindex);
    658     static void s_glBindVertexBuffer(void* self, GLuint bindingindex, GLuint buffer, GLintptr offset, GLintptr stride);
    659 
    660     // Indirect draws
    661     static void s_glDrawArraysIndirect(void* self, GLenum mode, const void* indirect);
    662     static void s_glDrawElementsIndirect(void* self, GLenum mode, GLenum type, const void* indirect);
    663 
    664     // Multisampled textures
    665     glTexStorage2DMultisample_client_proc_t m_glTexStorage2DMultisample_enc;
    666     static void s_glTexStorage2DMultisample(void* self, GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height, GLboolean fixedsamplelocations);
    667 
    668 public:
    669     glEGLImageTargetTexture2DOES_client_proc_t m_glEGLImageTargetTexture2DOES_enc;
    670 
    671 };
    672 #endif
    673