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 "gfxstream/guest/GLClientState.h" 21 #include "gfxstream/guest/GLSharedGroup.h" 22 23 #include <string> 24 #include <vector> 25 26 struct Extensions 27 { 28 Extensions() = default; 29 Extensions(const Extensions &other) = default; 30 31 Extensions &operator=(const Extensions &other) = default; 32 textureBufferAnyExtensions33 bool textureBufferAny() const { return textureBufferEXT || textureBufferOES; } 34 // GL_EXT_texture_buffer 35 bool textureBufferEXT = false; 36 37 // GL_OES_texture_buffer 38 bool textureBufferOES = false; 39 40 // GL_EXT_draw_buffers_indexed 41 bool drawBuffersIndexedEXT = false; 42 }; 43 44 class GL2Encoder : public gl2_encoder_context_t { 45 public: 46 GL2Encoder(gfxstream::guest::IOStream* stream, gfxstream::guest::ChecksumCalculator* protocol); 47 virtual ~GL2Encoder(); getExtensions()48 const Extensions& getExtensions() const { return m_extensions; } setDrawCallFlushInterval(uint32_t interval)49 void setDrawCallFlushInterval(uint32_t interval) { m_drawCallFlushInterval = interval; } setHasAsyncUnmapBuffer(int version)50 void setHasAsyncUnmapBuffer(int version) { m_hasAsyncUnmapBuffer = version; } setHasSyncBufferData(bool value)51 void setHasSyncBufferData(bool value) { m_hasSyncBufferData = value; } setNoHostError(bool noHostError)52 void setNoHostError(bool noHostError) { m_noHostError = noHostError; } setClientState(gfxstream::guest::GLClientState * state)53 void setClientState(gfxstream::guest::GLClientState* state) { m_state = state; } setVersion(int major,int minor,int deviceMajor,int deviceMinor)54 void setVersion(int major, int minor, int deviceMajor, int deviceMinor) { 55 m_currMajorVersion = major; 56 m_currMinorVersion = minor; 57 m_deviceMajorVersion = deviceMajor; 58 m_deviceMinorVersion = deviceMinor; 59 } setClientStateMakeCurrent(gfxstream::guest::GLClientState * state,int majorVersion,int minorVersion,int deviceMajorVersion,int deviceMinorVersion)60 void setClientStateMakeCurrent(gfxstream::guest::GLClientState *state, 61 int majorVersion, 62 int minorVersion, 63 int deviceMajorVersion, 64 int deviceMinorVersion) { 65 m_state = state; 66 m_state->fromMakeCurrent(); 67 m_currMajorVersion = majorVersion; 68 m_currMinorVersion = minorVersion; 69 m_deviceMajorVersion = deviceMajorVersion; 70 m_deviceMinorVersion = deviceMinorVersion; 71 } setSharedGroup(gfxstream::guest::GLSharedGroupPtr shared)72 void setSharedGroup(gfxstream::guest::GLSharedGroupPtr shared) { 73 m_shared = shared; 74 if (m_state && m_shared) { 75 m_state->setTextureData(m_shared->getTextureData()); 76 m_state->setRenderbufferInfo(m_shared->getRenderbufferInfo()); 77 m_state->setSamplerInfo(m_shared->getSamplerInfo()); 78 } 79 } es32Plus()80 bool es32Plus() const { return m_currMajorVersion > 3 || (m_currMajorVersion == 3 && m_currMinorVersion >= 2); } majorVersion()81 int majorVersion() const { return m_currMajorVersion; } minorVersion()82 int minorVersion() const { return m_currMinorVersion; } setExtensions(const char * exts,const std::vector<std::string> & extArray)83 void setExtensions(const char* exts, 84 const std::vector<std::string>& extArray) { 85 m_currExtensions = std::string(exts); 86 m_currExtensionsArray = extArray; 87 m_state->setExtensions(m_currExtensions); 88 89 m_extensions.textureBufferEXT = hasExtension("GL_EXT_texture_buffer"); 90 m_extensions.textureBufferOES = hasExtension("GL_OES_texture_buffer"); 91 m_extensions.drawBuffersIndexedEXT = hasExtension("GL_EXT_draw_buffers_indexed"); 92 } hasExtension(const char * ext)93 bool hasExtension(const char* ext) const { 94 return m_currExtensions.find(ext) != std::string::npos; 95 } state()96 const gfxstream::guest::GLClientState *state() { return m_state; } shared()97 const gfxstream::guest::GLSharedGroupPtr shared() { return m_shared; } flush()98 void flush() { m_stream->flush(); } 99 setInitialized()100 void setInitialized(){ m_initialized = true; }; isInitialized()101 bool isInitialized(){ return m_initialized; }; 102 setError(GLenum error)103 virtual void setError(GLenum error){ m_error = error; }; getError()104 virtual GLenum getError() { return m_error; }; 105 getErrorPtr()106 __attribute__((always_inline)) GLenum* getErrorPtr() { return &m_error; } hasError()107 __attribute__((always_inline)) bool hasError() const { return m_error != GL_NO_ERROR; } 108 109 void override2DTextureTarget(GLenum target); 110 void restore2DTextureTarget(GLenum target); 111 void associateEGLImage(GLenum target, GLeglImageOES eglImage, int width, int height); 112 113 // Convenience functions for buffers 114 GLuint boundBuffer(GLenum target) const; 115 gfxstream::guest::BufferData* getBufferData(GLenum target) const; 116 gfxstream::guest::BufferData* getBufferDataById(GLuint buffer) const; 117 bool isBufferMapped(GLuint buffer) const; 118 bool isBufferTargetMapped(GLenum target) const; 119 120 private: 121 122 int m_currMajorVersion; 123 int m_currMinorVersion; 124 int m_deviceMajorVersion; 125 int m_deviceMinorVersion; 126 std::string m_currExtensions; 127 std::vector<std::string> m_currExtensionsArray; 128 129 Extensions m_extensions; 130 131 bool m_hasAsyncUnmapBuffer; 132 bool m_hasSyncBufferData; 133 bool m_initialized; 134 bool m_noHostError; 135 gfxstream::guest::GLClientState *m_state; 136 gfxstream::guest::GLSharedGroupPtr m_shared; 137 GLenum m_error; 138 139 GLint *m_compressedTextureFormats; 140 GLint m_num_compressedTextureFormats; 141 GLint *getCompressedTextureFormats(); 142 143 GLint m_max_combinedTextureImageUnits; 144 GLint m_max_vertexTextureImageUnits; 145 GLint m_max_array_texture_layers;; 146 GLint m_max_textureImageUnits; 147 GLint m_max_cubeMapTextureSize; 148 GLint m_max_renderBufferSize; 149 GLint m_max_textureSize; 150 GLint m_max_3d_textureSize; 151 GLint m_max_vertexAttribStride; 152 153 GLint m_max_transformFeedbackSeparateAttribs; 154 GLint m_max_uniformBufferBindings; 155 GLint m_max_colorAttachments; 156 GLint m_max_drawBuffers; 157 158 GLint m_max_atomicCounterBufferBindings; 159 GLint m_max_shaderStorageBufferBindings; 160 GLint m_max_vertexAttribBindings; 161 GLint m_textureBufferOffsetAlign; 162 163 GLuint m_ssbo_offset_align; 164 GLuint m_ubo_offset_align; 165 166 GLint m_log2MaxTextureSize; 167 168 std::vector<char> m_fixedBuffer; 169 170 uint32_t m_drawCallFlushInterval; 171 uint32_t m_drawCallFlushCount; 172 173 bool m_primitiveRestartEnabled; 174 GLuint m_primitiveRestartIndex; 175 176 void calcIndexRange(const void* indices, 177 GLenum type, GLsizei count, 178 int* minIndex, int* maxIndex); 179 void* recenterIndices(const void* src, 180 GLenum type, GLsizei count, 181 int minIndex); 182 void getBufferIndexRange(gfxstream::guest::BufferData* buf, const void* dataWithOffset, 183 GLenum type, size_t count, size_t offset, 184 int* minIndex_out, int* maxIndex_out); 185 void getVBOUsage(bool* hasClientArrays, bool* hasVBOs) const; 186 void sendVertexAttributes(GLint first, GLsizei count, bool hasClientArrays, GLsizei primcount = 0); 187 void flushDrawCall(); 188 189 bool updateHostTexture2DBinding(GLenum texUnit, GLenum newTarget); 190 void updateHostTexture2DBindingsFromProgramData(GLuint program); 191 bool texture2DNeedsOverride(GLenum target) const; 192 193 void updateProgramInfoAfterLink(GLuint program); 194 195 // Utility classes for safe queries that 196 // need access to private class members 197 class ErrorUpdater; 198 template<class T> class ScopedQueryUpdate; 199 200 // General queries 201 void safe_glGetBooleanv(GLenum param, GLboolean *val); 202 void safe_glGetFloatv(GLenum param, GLfloat *val); 203 void safe_glGetIntegerv(GLenum param, GLint *val); 204 void safe_glGetInteger64v(GLenum param, GLint64 *val); 205 void safe_glGetIntegeri_v(GLenum param, GLuint index, GLint *val); 206 void safe_glGetInteger64i_v(GLenum param, GLuint index, GLint64 *val); 207 void safe_glGetBooleani_v(GLenum param, GLuint index, GLboolean *val); 208 209 // API implementation 210 glGetError_client_proc_t m_glGetError_enc; 211 static GLenum s_glGetError(void * self); 212 213 glFlush_client_proc_t m_glFlush_enc; 214 static void s_glFlush(void * self); 215 216 glPixelStorei_client_proc_t m_glPixelStorei_enc; 217 static void s_glPixelStorei(void *self, GLenum param, GLint value); 218 219 glGetString_client_proc_t m_glGetString_enc; 220 static const GLubyte * s_glGetString(void *self, GLenum name); 221 222 glBindBuffer_client_proc_t m_glBindBuffer_enc; 223 static void s_glBindBuffer(void *self, GLenum target, GLuint id); 224 void doBindBufferEncodeCached(GLenum taret, GLuint id); 225 226 glBufferData_client_proc_t m_glBufferData_enc; 227 static void s_glBufferData(void *self, GLenum target, GLsizeiptr size, const GLvoid * data, GLenum usage); 228 glBufferSubData_client_proc_t m_glBufferSubData_enc; 229 static void s_glBufferSubData(void *self, GLenum target, GLintptr offset, GLsizeiptr size, const GLvoid * data); 230 231 glGenBuffers_client_proc_t m_glGenBuffers_enc; 232 static void s_glGenBuffers(void *self, GLsizei n, GLuint * buffers); 233 234 glDeleteBuffers_client_proc_t m_glDeleteBuffers_enc; 235 static void s_glDeleteBuffers(void *self, GLsizei n, const GLuint * buffers); 236 237 glDrawArrays_client_proc_t m_glDrawArrays_enc; 238 static void s_glDrawArrays(void *self, GLenum mode, GLint first, GLsizei count); 239 240 glDrawElements_client_proc_t m_glDrawElements_enc; 241 static void s_glDrawElements(void *self, GLenum mode, GLsizei count, GLenum type, const void *indices); 242 243 glDrawArraysNullAEMU_client_proc_t m_glDrawArraysNullAEMU_enc; 244 static void s_glDrawArraysNullAEMU(void *self, GLenum mode, GLint first, GLsizei count); 245 246 glDrawElementsNullAEMU_client_proc_t m_glDrawElementsNullAEMU_enc; 247 static void s_glDrawElementsNullAEMU(void *self, GLenum mode, GLsizei count, GLenum type, const void *indices); 248 249 glGetIntegerv_client_proc_t m_glGetIntegerv_enc; 250 static void s_glGetIntegerv(void *self, GLenum pname, GLint *ptr); 251 252 glGetFloatv_client_proc_t m_glGetFloatv_enc; 253 static void s_glGetFloatv(void *self, GLenum pname, GLfloat *ptr); 254 255 glGetBooleanv_client_proc_t m_glGetBooleanv_enc; 256 static void s_glGetBooleanv(void *self, GLenum pname, GLboolean *ptr); 257 258 glGetInteger64v_client_proc_t m_glGetInteger64v_enc; 259 static void s_glGetInteger64v(void* self, GLenum param, GLint64* val); 260 261 glGetBooleani_v_client_proc_t m_glGetBooleani_v_enc; 262 static void s_glGetBooleani_v(void* self, GLenum param, GLuint index, GLboolean* val); 263 264 glVertexAttribPointer_client_proc_t m_glVertexAttribPointer_enc; 265 static void s_glVertexAttribPointer(void *self, GLuint indx, GLint size, GLenum type, 266 GLboolean normalized, GLsizei stride, const GLvoid * ptr); 267 268 glEnableVertexAttribArray_client_proc_t m_glEnableVertexAttribArray_enc; 269 static void s_glEnableVertexAttribArray(void *self, GLuint index); 270 271 glDisableVertexAttribArray_client_proc_t m_glDisableVertexAttribArray_enc; 272 static void s_glDisableVertexAttribArray(void *self, GLuint index); 273 274 glGetVertexAttribiv_client_proc_t m_glGetVertexAttribiv_enc; 275 static void s_glGetVertexAttribiv(void *self, GLuint index, GLenum pname, GLint *params); 276 277 glGetVertexAttribfv_client_proc_t m_glGetVertexAttribfv_enc; 278 static void s_glGetVertexAttribfv(void *self, GLuint index, GLenum pname, GLfloat *params); 279 280 glGetVertexAttribPointerv_client_proc_t m_glGetVertexAttribPointerv_enc; 281 static void s_glGetVertexAttribPointerv(void *self, GLuint index, GLenum pname, GLvoid **pointer); 282 283 static void s_glShaderBinary(void *self, GLsizei n, const GLuint *shaders, GLenum binaryformat, const void* binary, GLsizei length); 284 285 static void s_glShaderSource(void *self, GLuint shader, GLsizei count, const GLchar * const *string, const GLint *length); 286 287 static void s_glFinish(void *self); 288 289 glLinkProgram_client_proc_t m_glLinkProgram_enc; 290 static void s_glLinkProgram(void *self, GLuint program); 291 292 glDeleteProgram_client_proc_t m_glDeleteProgram_enc; 293 static void s_glDeleteProgram(void * self, GLuint program); 294 295 glGetUniformiv_client_proc_t m_glGetUniformiv_enc; 296 static void s_glGetUniformiv(void *self, GLuint program, GLint location , GLint *params); 297 298 glGetUniformfv_client_proc_t m_glGetUniformfv_enc; 299 static void s_glGetUniformfv(void *self, GLuint program, GLint location , GLfloat *params); 300 301 glCreateProgram_client_proc_t m_glCreateProgram_enc; 302 static GLuint s_glCreateProgram(void *self); 303 304 glCreateShader_client_proc_t m_glCreateShader_enc; 305 static GLuint s_glCreateShader(void *self, GLenum shaderType); 306 307 glDeleteShader_client_proc_t m_glDeleteShader_enc; 308 static void s_glDeleteShader(void *self, GLuint shader); 309 310 glAttachShader_client_proc_t m_glAttachShader_enc; 311 static void s_glAttachShader(void *self, GLuint program, GLuint shader); 312 313 glDetachShader_client_proc_t m_glDetachShader_enc; 314 static void s_glDetachShader(void *self, GLuint program, GLuint shader); 315 316 glGetAttachedShaders_client_proc_t m_glGetAttachedShaders_enc; 317 static void s_glGetAttachedShaders(void *self, GLuint program, GLsizei maxCount, 318 GLsizei* count, GLuint* shaders); 319 320 glGetShaderSource_client_proc_t m_glGetShaderSource_enc; 321 static void s_glGetShaderSource(void *self, GLuint shader, GLsizei bufsize, 322 GLsizei* length, GLchar* source); 323 324 glGetShaderInfoLog_client_proc_t m_glGetShaderInfoLog_enc; 325 static void s_glGetShaderInfoLog(void *self,GLuint shader, 326 GLsizei bufsize, GLsizei* length, GLchar* infolog); 327 328 glGetProgramInfoLog_client_proc_t m_glGetProgramInfoLog_enc; 329 static void s_glGetProgramInfoLog(void *self,GLuint program, 330 GLsizei bufsize, GLsizei* length, GLchar* infolog); 331 332 glGetUniformLocation_client_proc_t m_glGetUniformLocation_enc; 333 static int s_glGetUniformLocation(void *self, GLuint program, const GLchar *name); 334 glUseProgram_client_proc_t m_glUseProgram_enc; 335 336 glUniform1f_client_proc_t m_glUniform1f_enc; 337 glUniform1fv_client_proc_t m_glUniform1fv_enc; 338 glUniform1i_client_proc_t m_glUniform1i_enc; 339 glUniform1iv_client_proc_t m_glUniform1iv_enc; 340 glUniform2f_client_proc_t m_glUniform2f_enc; 341 glUniform2fv_client_proc_t m_glUniform2fv_enc; 342 glUniform2i_client_proc_t m_glUniform2i_enc; 343 glUniform2iv_client_proc_t m_glUniform2iv_enc; 344 glUniform3f_client_proc_t m_glUniform3f_enc; 345 glUniform3fv_client_proc_t m_glUniform3fv_enc; 346 glUniform3i_client_proc_t m_glUniform3i_enc; 347 glUniform3iv_client_proc_t m_glUniform3iv_enc; 348 glUniform4f_client_proc_t m_glUniform4f_enc; 349 glUniform4fv_client_proc_t m_glUniform4fv_enc; 350 glUniform4i_client_proc_t m_glUniform4i_enc; 351 glUniform4iv_client_proc_t m_glUniform4iv_enc; 352 glUniformMatrix2fv_client_proc_t m_glUniformMatrix2fv_enc; 353 glUniformMatrix3fv_client_proc_t m_glUniformMatrix3fv_enc; 354 glUniformMatrix4fv_client_proc_t m_glUniformMatrix4fv_enc; 355 356 static void s_glUseProgram(void *self, GLuint program); 357 static void s_glUniform1f(void *self , GLint location, GLfloat x); 358 static void s_glUniform1fv(void *self , GLint location, GLsizei count, const GLfloat* v); 359 static void s_glUniform1i(void *self , GLint location, GLint x); 360 static void s_glUniform1iv(void *self , GLint location, GLsizei count, const GLint* v); 361 static void s_glUniform2f(void *self , GLint location, GLfloat x, GLfloat y); 362 static void s_glUniform2fv(void *self , GLint location, GLsizei count, const GLfloat* v); 363 static void s_glUniform2i(void *self , GLint location, GLint x, GLint y); 364 static void s_glUniform2iv(void *self , GLint location, GLsizei count, const GLint* v); 365 static void s_glUniform3f(void *self , GLint location, GLfloat x, GLfloat y, GLfloat z); 366 static void s_glUniform3fv(void *self , GLint location, GLsizei count, const GLfloat* v); 367 static void s_glUniform3i(void *self , GLint location, GLint x, GLint y, GLint z); 368 static void s_glUniform3iv(void *self , GLint location, GLsizei count, const GLint* v); 369 static void s_glUniform4f(void *self , GLint location, GLfloat x, GLfloat y, GLfloat z, GLfloat w); 370 static void s_glUniform4fv(void *self , GLint location, GLsizei count, const GLfloat* v); 371 static void s_glUniform4i(void *self , GLint location, GLint x, GLint y, GLint z, GLint w); 372 static void s_glUniform4iv(void *self , GLint location, GLsizei count, const GLint* v); 373 static void s_glUniformMatrix2fv(void *self , GLint location, GLsizei count, GLboolean transpose, const GLfloat* value); 374 static void s_glUniformMatrix3fv(void *self , GLint location, GLsizei count, GLboolean transpose, const GLfloat* value); 375 static void s_glUniformMatrix4fv(void *self , GLint location, GLsizei count, GLboolean transpose, const GLfloat* value); 376 377 glActiveTexture_client_proc_t m_glActiveTexture_enc; 378 glBindTexture_client_proc_t m_glBindTexture_enc; 379 glDeleteTextures_client_proc_t m_glDeleteTextures_enc; 380 glGetTexParameterfv_client_proc_t m_glGetTexParameterfv_enc; 381 glGetTexParameteriv_client_proc_t m_glGetTexParameteriv_enc; 382 glTexParameterf_client_proc_t m_glTexParameterf_enc; 383 glTexParameterfv_client_proc_t m_glTexParameterfv_enc; 384 glTexParameteri_client_proc_t m_glTexParameteri_enc; 385 glTexParameteriv_client_proc_t m_glTexParameteriv_enc; 386 glTexImage2D_client_proc_t m_glTexImage2D_enc; 387 glTexSubImage2D_client_proc_t m_glTexSubImage2D_enc; 388 glCopyTexImage2D_client_proc_t m_glCopyTexImage2D_enc; 389 glTexBufferOES_client_proc_t m_glTexBufferOES_enc; 390 glTexBufferRangeOES_client_proc_t m_glTexBufferRangeOES_enc; 391 glTexBufferEXT_client_proc_t m_glTexBufferEXT_enc; 392 glTexBufferRangeEXT_client_proc_t m_glTexBufferRangeEXT_enc; 393 394 glEnableiEXT_client_proc_t m_glEnableiEXT_enc; 395 glDisableiEXT_client_proc_t m_glDisableiEXT_enc; 396 glBlendEquationiEXT_client_proc_t m_glBlendEquationiEXT_enc; 397 glBlendEquationSeparateiEXT_client_proc_t m_glBlendEquationSeparateiEXT_enc; 398 glBlendFunciEXT_client_proc_t m_glBlendFunciEXT_enc; 399 glBlendFuncSeparateiEXT_client_proc_t m_glBlendFuncSeparateiEXT_enc; 400 glColorMaskiEXT_client_proc_t m_glColorMaskiEXT_enc; 401 glIsEnablediEXT_client_proc_t m_glIsEnablediEXT_enc; 402 403 404 static void s_glActiveTexture(void* self, GLenum texture); 405 static void s_glBindTexture(void* self, GLenum target, GLuint texture); 406 static void s_glDeleteTextures(void* self, GLsizei n, const GLuint* textures); 407 static void s_glGetTexParameterfv(void* self, GLenum target, GLenum pname, GLfloat* params); 408 static void s_glGetTexParameteriv(void* self, GLenum target, GLenum pname, GLint* params); 409 static void s_glTexParameterf(void* self, GLenum target, GLenum pname, GLfloat param); 410 static void s_glTexParameterfv(void* self, GLenum target, GLenum pname, const GLfloat* params); 411 static void s_glTexParameteri(void* self, GLenum target, GLenum pname, GLint param); 412 static void s_glTexParameteriv(void* self, GLenum target, GLenum pname, const GLint* params); 413 static void s_glTexImage2D(void* self, GLenum target, GLint level, GLint internalformat, 414 GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, 415 const GLvoid* pixels); 416 static void s_glTexSubImage2D(void* self, GLenum target, GLint level, GLint xoffset, 417 GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, 418 const GLvoid* pixels); 419 static void s_glCopyTexImage2D(void* self, GLenum target, GLint level, GLenum internalformat, 420 GLint x, GLint y, GLsizei width, GLsizei height, GLint border); 421 422 static bool validateTexBuffer(void* self, GLenum target, GLenum internalFormat, GLuint buffer); 423 static bool validateTexBufferRange(void* self, GLenum target, GLenum internalFormat, GLuint buffer, GLintptr offset, GLsizeiptr size); 424 425 static void s_glTexBufferOES(void* self, GLenum target, GLenum internalFormat, GLuint buffer); 426 static void s_glTexBufferRangeOES(void* self, GLenum target, GLenum internalFormat, GLuint buffer, GLintptr offset, GLsizeiptr size); 427 428 static void s_glTexBufferEXT(void* self, GLenum target, GLenum internalFormat, GLuint buffer); 429 static void s_glTexBufferRangeEXT(void* self, GLenum target, GLenum internalFormat, GLuint buffer, GLintptr offset, GLsizeiptr size); 430 431 432 static bool validateAllowedEnablei(void* self, GLenum cap, GLuint index); 433 static void s_glEnableiEXT(void* self, GLenum cap, GLuint index); 434 static void s_glDisableiEXT(void* self, GLenum cap, GLuint index); 435 static void s_glBlendEquationiEXT(void* self, GLuint buf, GLenum mode); 436 static void s_glBlendEquationSeparateiEXT(void* self, GLuint buf, GLenum modeRGB, GLenum modeAlpha); 437 static void s_glBlendFunciEXT(void* self, GLuint buf, GLenum sfactor, GLenum dfactor); 438 static void s_glBlendFuncSeparateiEXT(void* self, GLuint buf, GLenum srcRGB, GLenum dstRGB, GLenum srcAlpha, GLenum dstAlpha); 439 static void s_glColorMaskiEXT(void* self, GLuint buf, GLboolean red, GLboolean green, GLboolean blue, GLboolean alpha); 440 static GLboolean s_glIsEnablediEXT(void* self, GLenum cap, GLuint index); 441 442 glGenRenderbuffers_client_proc_t m_glGenRenderbuffers_enc; 443 static void s_glGenRenderbuffers(void* self, GLsizei n, GLuint* renderbuffers); 444 glDeleteRenderbuffers_client_proc_t m_glDeleteRenderbuffers_enc; 445 static void s_glDeleteRenderbuffers(void* self, GLsizei n, const GLuint* renderbuffers); 446 447 glBindRenderbuffer_client_proc_t m_glBindRenderbuffer_enc; 448 static void s_glBindRenderbuffer(void* self, GLenum target, GLuint renderbuffer); 449 450 glRenderbufferStorage_client_proc_t m_glRenderbufferStorage_enc; 451 static void s_glRenderbufferStorage(void* self, GLenum target, GLenum internalformat, GLsizei width, GLsizei height); 452 453 glFramebufferRenderbuffer_client_proc_t m_glFramebufferRenderbuffer_enc; 454 static void s_glFramebufferRenderbuffer(void* self, GLenum target, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer); 455 456 glGenFramebuffers_client_proc_t m_glGenFramebuffers_enc; 457 static void s_glGenFramebuffers(void* self, GLsizei n, GLuint* framebuffers); 458 glDeleteFramebuffers_client_proc_t m_glDeleteFramebuffers_enc; 459 static void s_glDeleteFramebuffers(void* self, GLsizei n, const GLuint* framebuffers); 460 461 glBindFramebuffer_client_proc_t m_glBindFramebuffer_enc; 462 static void s_glBindFramebuffer(void* self, GLenum target, GLuint framebuffer); 463 464 glFramebufferParameteri_client_proc_t m_glFramebufferParameteri_enc; 465 static void s_glFramebufferParameteri(void *self, GLenum target, GLenum pname, GLint param); 466 467 glFramebufferTexture2D_client_proc_t m_glFramebufferTexture2D_enc; 468 static void s_glFramebufferTexture2D(void* self, GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level); 469 470 glFramebufferTexture3DOES_client_proc_t m_glFramebufferTexture3DOES_enc; 471 static void s_glFramebufferTexture3DOES(void*self, GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level, GLint zoffset); 472 473 glGetFramebufferAttachmentParameteriv_client_proc_t m_glGetFramebufferAttachmentParameteriv_enc; 474 static void s_glGetFramebufferAttachmentParameteriv(void* self, GLenum target, GLenum attachment, GLenum pname, GLint* params); 475 476 glCheckFramebufferStatus_client_proc_t m_glCheckFramebufferStatus_enc; 477 static GLenum s_glCheckFramebufferStatus(void* self, 478 GLenum target); 479 480 // GLES 3.0-specific custom encoders 481 482 // VAO (+ ES 2 extension) 483 glGenVertexArrays_client_proc_t m_glGenVertexArrays_enc; 484 glDeleteVertexArrays_client_proc_t m_glDeleteVertexArrays_enc; 485 glBindVertexArray_client_proc_t m_glBindVertexArray_enc; 486 glGenVertexArraysOES_client_proc_t m_glGenVertexArraysOES_enc; 487 glDeleteVertexArraysOES_client_proc_t m_glDeleteVertexArraysOES_enc; 488 glBindVertexArrayOES_client_proc_t m_glBindVertexArrayOES_enc; 489 static void s_glGenVertexArrays(void *self, GLsizei n, GLuint* arrays); 490 static void s_glDeleteVertexArrays(void *self , GLsizei n, const GLuint* arrays); 491 static void s_glBindVertexArray(void *self , GLuint array); 492 493 // Mapped buffers 494 static void* s_glMapBufferOES(void* self, GLenum target, GLenum access); 495 static GLboolean s_glUnmapBufferOES(void* self, GLenum target); 496 static void* s_glMapBufferRange(void* self, GLenum target, GLintptr offset, GLsizeiptr length, GLbitfield access); 497 static void* s_glMapBufferRangeAEMUImpl(GL2Encoder* ctx, GLenum target, 498 GLintptr offset, GLsizeiptr length, 499 GLbitfield access, gfxstream::guest::BufferData* buf); 500 static GLboolean s_glUnmapBuffer(void* self, GLenum target); 501 static void s_glFlushMappedBufferRange(void* self, GLenum target, GLintptr offset, GLsizeiptr length); 502 503 // Custom encodes for 2D compressed textures b/c we need to account for 504 // nonzero GL_PIXEL_UNPACK_BUFFER 505 glCompressedTexImage2D_client_proc_t m_glCompressedTexImage2D_enc; 506 static void s_glCompressedTexImage2D(void* self, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const GLvoid* data); 507 glCompressedTexSubImage2D_client_proc_t m_glCompressedTexSubImage2D_enc; 508 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); 509 510 // Indexed, range bind 511 glBindBufferRange_client_proc_t m_glBindBufferRange_enc; 512 static void s_glBindBufferRange(void *self , GLenum target, GLuint index, GLuint buffer, GLintptr offset, GLsizeiptr size); 513 514 glBindBufferBase_client_proc_t m_glBindBufferBase_enc; 515 static void s_glBindBufferBase(void *self , GLenum target, GLuint index, GLuint buffer); 516 517 // TODO: 518 // VertexAttrib(I)Pointer 519 // VertexAttribBinding 520 // BindVertexBuffer 521 // depend on other state as well 522 enum IndexedBufferBindOp { 523 BindBufferBase, 524 BindBufferRange, 525 // TODO 526 // VertexAttribPointer, 527 // VertexAttribIPointer, 528 // VertexAttribBinding, 529 // VertexAttribFormat, 530 // BindVertexBuffer, 531 }; 532 void doIndexedBufferBindEncodeCached(IndexedBufferBindOp op, GLenum target, GLuint index, GLuint buffer, GLintptr offset, GLsizeiptr size, GLintptr stride, GLintptr effectiveStride); 533 534 glCopyBufferSubData_client_proc_t m_glCopyBufferSubData_enc; 535 static void s_glCopyBufferSubData(void *self , GLenum readtarget, GLenum writetarget, GLintptr readoffset, GLintptr writeoffset, GLsizeiptr size); 536 537 glGetBufferParameteriv_client_proc_t m_glGetBufferParameteriv_enc; 538 static void s_glGetBufferParameteriv(void* self, GLenum target, GLenum pname, GLint* params); 539 540 glGetBufferParameteri64v_client_proc_t m_glGetBufferParameteri64v_enc; 541 static void s_glGetBufferParameteri64v(void* self, GLenum target, GLenum pname, GLint64* params); 542 543 glGetBufferPointerv_client_proc_t m_glGetBufferPointerv_enc; 544 static void s_glGetBufferPointerv(void* self, GLenum target, GLenum pname, GLvoid** params); 545 546 glGetUniformIndices_client_proc_t m_glGetUniformIndices_enc; 547 static void s_glGetUniformIndices(void* self, GLuint program, GLsizei uniformCount, const GLchar ** uniformNames, GLuint* uniformIndices); 548 549 glUniform1ui_client_proc_t m_glUniform1ui_enc; 550 glUniform1uiv_client_proc_t m_glUniform1uiv_enc; 551 glUniform2ui_client_proc_t m_glUniform2ui_enc; 552 glUniform2uiv_client_proc_t m_glUniform2uiv_enc; 553 glUniform3ui_client_proc_t m_glUniform3ui_enc; 554 glUniform3uiv_client_proc_t m_glUniform3uiv_enc; 555 glUniform4ui_client_proc_t m_glUniform4ui_enc; 556 glUniform4uiv_client_proc_t m_glUniform4uiv_enc; 557 glUniformMatrix2x3fv_client_proc_t m_glUniformMatrix2x3fv_enc; 558 glUniformMatrix2x4fv_client_proc_t m_glUniformMatrix2x4fv_enc; 559 glUniformMatrix3x2fv_client_proc_t m_glUniformMatrix3x2fv_enc; 560 glUniformMatrix3x4fv_client_proc_t m_glUniformMatrix3x4fv_enc; 561 glUniformMatrix4x2fv_client_proc_t m_glUniformMatrix4x2fv_enc; 562 glUniformMatrix4x3fv_client_proc_t m_glUniformMatrix4x3fv_enc; 563 564 static void s_glUniform1ui(void* self, GLint location, GLuint v0); 565 static void s_glUniform2ui(void* self, GLint location, GLuint v0, GLuint v1); 566 static void s_glUniform3ui(void* self, GLint location, GLuint v0, GLuint v1, GLuint v2); 567 static void s_glUniform4ui(void* self, GLint location, GLint v0, GLuint v1, GLuint v2, GLuint v3); 568 static void s_glUniform1uiv(void* self, GLint location, GLsizei count, const GLuint *value); 569 static void s_glUniform2uiv(void* self, GLint location, GLsizei count, const GLuint *value); 570 static void s_glUniform3uiv(void* self, GLint location, GLsizei count, const GLuint *value); 571 static void s_glUniform4uiv(void* self, GLint location, GLsizei count, const GLuint *value); 572 static void s_glUniformMatrix2x3fv(void* self, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); 573 static void s_glUniformMatrix3x2fv(void* self, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); 574 static void s_glUniformMatrix2x4fv(void* self, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); 575 static void s_glUniformMatrix4x2fv(void* self, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); 576 static void s_glUniformMatrix3x4fv(void* self, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); 577 static void s_glUniformMatrix4x3fv(void* self, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); 578 579 glGetUniformuiv_client_proc_t m_glGetUniformuiv_enc; 580 static void s_glGetUniformuiv(void *self, GLuint program, GLint location, GLuint* params); 581 582 glGetActiveUniformBlockiv_client_proc_t m_glGetActiveUniformBlockiv_enc; 583 static void s_glGetActiveUniformBlockiv(void* self, GLuint program, GLuint uniformBlockIndex, GLenum pname, GLint* params); 584 585 glGetVertexAttribIiv_client_proc_t m_glGetVertexAttribIiv_enc; 586 static void s_glGetVertexAttribIiv(void* self, GLuint index, GLenum pname, GLint* params); 587 588 glGetVertexAttribIuiv_client_proc_t m_glGetVertexAttribIuiv_enc; 589 static void s_glGetVertexAttribIuiv(void* self, GLuint index, GLenum pname, GLuint* params); 590 591 static void s_glVertexAttribIPointer(void* self, GLuint index, GLint size, GLenum type, GLsizei stride, const GLvoid* pointer); 592 593 glVertexAttribDivisor_client_proc_t m_glVertexAttribDivisor_enc; 594 static void s_glVertexAttribDivisor(void* self, GLuint index, GLuint divisor); 595 596 glRenderbufferStorageMultisample_client_proc_t m_glRenderbufferStorageMultisample_enc; 597 static void s_glRenderbufferStorageMultisample(void* self, GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height); 598 599 glDrawBuffers_client_proc_t m_glDrawBuffers_enc; 600 static void s_glDrawBuffers(void* self, GLsizei n, const GLenum* bufs); 601 602 glReadBuffer_client_proc_t m_glReadBuffer_enc; 603 static void s_glReadBuffer(void* self, GLenum src); 604 605 glFramebufferTextureLayer_client_proc_t m_glFramebufferTextureLayer_enc; 606 static void s_glFramebufferTextureLayer(void* self, GLenum target, GLenum attachment, GLuint texture, GLint level, GLint layer); 607 608 glTexStorage2D_client_proc_t m_glTexStorage2D_enc; 609 static void s_glTexStorage2D(void* self, GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height); 610 611 static void s_glTransformFeedbackVaryings(void* self, GLuint program, GLsizei count, const char** varyings, GLenum bufferMode); 612 613 glBeginTransformFeedback_client_proc_t m_glBeginTransformFeedback_enc; 614 static void s_glBeginTransformFeedback(void* self, GLenum primitiveMode); 615 616 glEndTransformFeedback_client_proc_t m_glEndTransformFeedback_enc; 617 static void s_glEndTransformFeedback(void* self); 618 619 glPauseTransformFeedback_client_proc_t m_glPauseTransformFeedback_enc; 620 static void s_glPauseTransformFeedback(void* self); 621 622 glResumeTransformFeedback_client_proc_t m_glResumeTransformFeedback_enc; 623 static void s_glResumeTransformFeedback(void* self); 624 625 glTexImage3D_client_proc_t m_glTexImage3D_enc; 626 static void s_glTexImage3D(void* self, GLenum target, GLint level, GLint internalFormat, 627 GLsizei width, GLsizei height, GLsizei depth, 628 GLint border, GLenum format, GLenum type, const GLvoid* data); 629 630 glTexSubImage3D_client_proc_t m_glTexSubImage3D_enc; 631 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); 632 633 glCompressedTexImage3D_client_proc_t m_glCompressedTexImage3D_enc; 634 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); 635 glCompressedTexSubImage3D_client_proc_t m_glCompressedTexSubImage3D_enc; 636 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); 637 638 639 glTexStorage3D_client_proc_t m_glTexStorage3D_enc; 640 static void s_glTexStorage3D(void* self, GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth); 641 642 glDrawArraysInstanced_client_proc_t m_glDrawArraysInstanced_enc; 643 static void s_glDrawArraysInstanced(void* self, GLenum mode, GLint first, GLsizei count, GLsizei primcount); 644 645 static void s_glDrawElementsInstanced(void* self, GLenum mode, GLsizei count, GLenum type, const void* indices, GLsizei primcount); 646 647 glDrawRangeElements_client_proc_t m_glDrawRangeElements_enc; 648 static void s_glDrawRangeElements(void* self, GLenum mode, GLuint start, GLuint end, GLsizei count, GLenum type, const void* indices); 649 650 static const GLubyte* s_glGetStringi(void* self, GLenum name, GLuint index); 651 652 glGetProgramBinary_client_proc_t m_glGetProgramBinary_enc; 653 static void s_glGetProgramBinary(void* self, GLuint program, GLsizei bufSize, GLsizei* length, GLenum* binaryFormat, void* binary); 654 655 glReadPixels_client_proc_t m_glReadPixels_enc; 656 static void s_glReadPixels(void* self, GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, GLvoid* pixels); 657 658 glEnable_client_proc_t m_glEnable_enc; 659 static void s_glEnable(void* self, GLenum what); 660 glDisable_client_proc_t m_glDisable_enc; 661 static void s_glDisable(void* self, GLenum what); 662 663 glClearBufferiv_client_proc_t m_glClearBufferiv_enc; 664 static void s_glClearBufferiv(void* self, GLenum buffer, GLint drawBuffer, const GLint* value); 665 666 glClearBufferuiv_client_proc_t m_glClearBufferuiv_enc; 667 static void s_glClearBufferuiv(void* self, GLenum buffer, GLint drawBuffer, const GLuint* value); 668 669 glClearBufferfv_client_proc_t m_glClearBufferfv_enc; 670 static void s_glClearBufferfv(void* self, GLenum buffer, GLint drawBuffer, const GLfloat* value); 671 672 glBlitFramebuffer_client_proc_t m_glBlitFramebuffer_enc; 673 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); 674 675 static void s_glGetInternalformativ(void* self, GLenum target, GLenum internalformat, GLenum pname, GLsizei bufSize, GLint *params); 676 677 glGenerateMipmap_client_proc_t m_glGenerateMipmap_enc; 678 static void s_glGenerateMipmap(void* self, GLenum target); 679 680 glBindSampler_client_proc_t m_glBindSampler_enc; 681 static void s_glBindSampler(void* self, GLuint unit, GLuint sampler); 682 683 glDeleteSamplers_client_proc_t m_glDeleteSamplers_enc; 684 static void s_glDeleteSamplers(void* self, GLsizei n, const GLuint* samplers); 685 686 static GLsync s_glFenceSync(void* self, GLenum condition, GLbitfield flags); 687 static GLenum s_glClientWaitSync(void* self, GLsync wait_on, GLbitfield flags, GLuint64 timeout); 688 static void s_glWaitSync(void* self, GLsync wait_on, GLbitfield flags, GLuint64 timeout); 689 static void s_glDeleteSync(void* self, GLsync to_delete); 690 static GLboolean s_glIsSync(void* self, GLsync sync); 691 static void s_glGetSynciv(void* self, GLsync sync, GLenum pname, GLsizei bufSize, GLsizei *length, GLint *values); 692 693 glGetIntegeri_v_client_proc_t m_glGetIntegeri_v_enc; 694 static void s_glGetIntegeri_v(void* self, GLenum target, GLuint index, GLint* params); 695 696 glGetInteger64i_v_client_proc_t m_glGetInteger64i_v_enc; 697 static void s_glGetInteger64i_v(void* self, GLenum target, GLuint index, GLint64* params); 698 699 glGetShaderiv_client_proc_t m_glGetShaderiv_enc; 700 static void s_glGetShaderiv(void* self, GLuint shader, GLenum pname, GLint* params); 701 702 // 3.1 703 glActiveShaderProgram_client_proc_t m_glActiveShaderProgram_enc; 704 static void s_glActiveShaderProgram(void* self, GLuint pipeline, GLuint program); 705 static GLuint s_glCreateShaderProgramv(void* self, GLenum type, GLsizei count, const char** strings); 706 707 glProgramUniform1f_client_proc_t m_glProgramUniform1f_enc; 708 glProgramUniform1fv_client_proc_t m_glProgramUniform1fv_enc; 709 glProgramUniform1i_client_proc_t m_glProgramUniform1i_enc; 710 glProgramUniform1iv_client_proc_t m_glProgramUniform1iv_enc; 711 glProgramUniform1ui_client_proc_t m_glProgramUniform1ui_enc; 712 glProgramUniform1uiv_client_proc_t m_glProgramUniform1uiv_enc; 713 glProgramUniform2f_client_proc_t m_glProgramUniform2f_enc; 714 glProgramUniform2fv_client_proc_t m_glProgramUniform2fv_enc; 715 glProgramUniform2i_client_proc_t m_glProgramUniform2i_enc; 716 glProgramUniform2iv_client_proc_t m_glProgramUniform2iv_enc; 717 glProgramUniform2ui_client_proc_t m_glProgramUniform2ui_enc; 718 glProgramUniform2uiv_client_proc_t m_glProgramUniform2uiv_enc; 719 glProgramUniform3f_client_proc_t m_glProgramUniform3f_enc; 720 glProgramUniform3fv_client_proc_t m_glProgramUniform3fv_enc; 721 glProgramUniform3i_client_proc_t m_glProgramUniform3i_enc; 722 glProgramUniform3iv_client_proc_t m_glProgramUniform3iv_enc; 723 glProgramUniform3ui_client_proc_t m_glProgramUniform3ui_enc; 724 glProgramUniform3uiv_client_proc_t m_glProgramUniform3uiv_enc; 725 glProgramUniform4f_client_proc_t m_glProgramUniform4f_enc; 726 glProgramUniform4fv_client_proc_t m_glProgramUniform4fv_enc; 727 glProgramUniform4i_client_proc_t m_glProgramUniform4i_enc; 728 glProgramUniform4iv_client_proc_t m_glProgramUniform4iv_enc; 729 glProgramUniform4ui_client_proc_t m_glProgramUniform4ui_enc; 730 glProgramUniform4uiv_client_proc_t m_glProgramUniform4uiv_enc; 731 glProgramUniformMatrix2fv_client_proc_t m_glProgramUniformMatrix2fv_enc; 732 glProgramUniformMatrix2x3fv_client_proc_t m_glProgramUniformMatrix2x3fv_enc; 733 glProgramUniformMatrix2x4fv_client_proc_t m_glProgramUniformMatrix2x4fv_enc; 734 glProgramUniformMatrix3fv_client_proc_t m_glProgramUniformMatrix3fv_enc; 735 glProgramUniformMatrix3x2fv_client_proc_t m_glProgramUniformMatrix3x2fv_enc; 736 glProgramUniformMatrix3x4fv_client_proc_t m_glProgramUniformMatrix3x4fv_enc; 737 glProgramUniformMatrix4fv_client_proc_t m_glProgramUniformMatrix4fv_enc; 738 glProgramUniformMatrix4x2fv_client_proc_t m_glProgramUniformMatrix4x2fv_enc; 739 glProgramUniformMatrix4x3fv_client_proc_t m_glProgramUniformMatrix4x3fv_enc; 740 741 static void s_glProgramUniform1f(void* self, GLuint program, GLint location, GLfloat v0); 742 static void s_glProgramUniform2f(void* self, GLuint program, GLint location, GLfloat v0, GLfloat v1); 743 static void s_glProgramUniform3f(void* self, GLuint program, GLint location, GLfloat v0, GLfloat v1, GLfloat v2); 744 static void s_glProgramUniform4f(void* self, GLuint program, GLint location, GLfloat v0, GLfloat v1, GLfloat v2, GLfloat v3); 745 static void s_glProgramUniform1i(void* self, GLuint program, GLint location, GLint v0); 746 static void s_glProgramUniform2i(void* self, GLuint program, GLint location, GLint v0, GLint v1); 747 static void s_glProgramUniform3i(void* self, GLuint program, GLint location, GLint v0, GLint v1, GLint v2); 748 static void s_glProgramUniform4i(void* self, GLuint program, GLint location, GLint v0, GLint v1, GLint v2, GLint v3); 749 static void s_glProgramUniform1ui(void* self, GLuint program, GLint location, GLuint v0); 750 static void s_glProgramUniform2ui(void* self, GLuint program, GLint location, GLint v0, GLuint v1); 751 static void s_glProgramUniform3ui(void* self, GLuint program, GLint location, GLint v0, GLint v1, GLuint v2); 752 static void s_glProgramUniform4ui(void* self, GLuint program, GLint location, GLint v0, GLint v1, GLint v2, GLuint v3); 753 static void s_glProgramUniform1fv(void* self, GLuint program, GLint location, GLsizei count, const GLfloat *value); 754 static void s_glProgramUniform2fv(void* self, GLuint program, GLint location, GLsizei count, const GLfloat *value); 755 static void s_glProgramUniform3fv(void* self, GLuint program, GLint location, GLsizei count, const GLfloat *value); 756 static void s_glProgramUniform4fv(void* self, GLuint program, GLint location, GLsizei count, const GLfloat *value); 757 static void s_glProgramUniform1iv(void* self, GLuint program, GLint location, GLsizei count, const GLint *value); 758 static void s_glProgramUniform2iv(void* self, GLuint program, GLint location, GLsizei count, const GLint *value); 759 static void s_glProgramUniform3iv(void* self, GLuint program, GLint location, GLsizei count, const GLint *value); 760 static void s_glProgramUniform4iv(void* self, GLuint program, GLint location, GLsizei count, const GLint *value); 761 static void s_glProgramUniform1uiv(void* self, GLuint program, GLint location, GLsizei count, const GLuint *value); 762 static void s_glProgramUniform2uiv(void* self, GLuint program, GLint location, GLsizei count, const GLuint *value); 763 static void s_glProgramUniform3uiv(void* self, GLuint program, GLint location, GLsizei count, const GLuint *value); 764 static void s_glProgramUniform4uiv(void* self, GLuint program, GLint location, GLsizei count, const GLuint *value); 765 static void s_glProgramUniformMatrix2fv(void* self, GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); 766 static void s_glProgramUniformMatrix3fv(void* self, GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); 767 static void s_glProgramUniformMatrix4fv(void* self, GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); 768 static void s_glProgramUniformMatrix2x3fv(void* self, GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); 769 static void s_glProgramUniformMatrix3x2fv(void* self, GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); 770 static void s_glProgramUniformMatrix2x4fv(void* self, GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); 771 static void s_glProgramUniformMatrix4x2fv(void* self, GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); 772 static void s_glProgramUniformMatrix3x4fv(void* self, GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); 773 static void s_glProgramUniformMatrix4x3fv(void* self, GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); 774 775 glProgramParameteri_client_proc_t m_glProgramParameteri_enc; 776 glUseProgramStages_client_proc_t m_glUseProgramStages_enc; 777 glBindProgramPipeline_client_proc_t m_glBindProgramPipeline_enc; 778 779 static void s_glProgramParameteri(void* self, GLuint program, GLenum pname, GLint value); 780 static void s_glUseProgramStages(void *self, GLuint pipeline, GLbitfield stages, GLuint program); 781 static void s_glBindProgramPipeline(void *self, GLuint pipeline); 782 783 glGetProgramResourceiv_client_proc_t m_glGetProgramResourceiv_enc; 784 glGetProgramResourceIndex_client_proc_t m_glGetProgramResourceIndex_enc; 785 glGetProgramResourceLocation_client_proc_t m_glGetProgramResourceLocation_enc; 786 glGetProgramResourceName_client_proc_t m_glGetProgramResourceName_enc; 787 glGetProgramPipelineInfoLog_client_proc_t m_glGetProgramPipelineInfoLog_enc; 788 789 static void s_glGetProgramResourceiv(void* self, GLuint program, GLenum programInterface, GLuint index, GLsizei propCount, const GLenum * props, GLsizei bufSize, GLsizei * length, GLint * params); 790 static GLuint s_glGetProgramResourceIndex(void* self, GLuint program, GLenum programInterface, const char* name); 791 static GLint s_glGetProgramResourceLocation(void* self, GLuint program, GLenum programInterface, const char* name); 792 static void s_glGetProgramResourceName(void* self, GLuint program, GLenum programInterface, GLuint index, GLsizei bufSize, GLsizei* length, char* name); 793 794 static void s_glGetProgramPipelineInfoLog(void* self, GLuint pipeline, GLsizei bufSize, GLsizei* length, GLchar* infoLog); 795 796 // TODO: Compute shaders: 797 // make sure it's OK to put memory barriers and compute dispatch 798 // on the default encoding path 799 800 glVertexAttribFormat_client_proc_t m_glVertexAttribFormat_enc; 801 glVertexAttribIFormat_client_proc_t m_glVertexAttribIFormat_enc; 802 glVertexBindingDivisor_client_proc_t m_glVertexBindingDivisor_enc; 803 glVertexAttribBinding_client_proc_t m_glVertexAttribBinding_enc; 804 glBindVertexBuffer_client_proc_t m_glBindVertexBuffer_enc; 805 806 static void s_glVertexAttribFormat(void* self, GLuint attribindex, GLint size, GLenum type, GLboolean normalized, GLuint relativeoffset); 807 static void s_glVertexAttribIFormat(void* self, GLuint attribindex, GLint size, GLenum type, GLuint relativeoffset); 808 static void s_glVertexBindingDivisor(void* self, GLuint bindingindex, GLuint divisor); 809 static void s_glVertexAttribBinding(void* self, GLuint attribindex, GLuint bindingindex); 810 static void s_glBindVertexBuffer(void* self, GLuint bindingindex, GLuint buffer, GLintptr offset, GLintptr stride); 811 812 // Indirect draws 813 static void s_glDrawArraysIndirect(void* self, GLenum mode, const void* indirect); 814 static void s_glDrawElementsIndirect(void* self, GLenum mode, GLenum type, const void* indirect); 815 816 // Multisampled textures 817 glTexStorage2DMultisample_client_proc_t m_glTexStorage2DMultisample_enc; 818 static void s_glTexStorage2DMultisample(void* self, GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height, GLboolean fixedsamplelocations); 819 820 static GLenum s_glGetGraphicsResetStatusEXT(void* self); 821 static void s_glReadnPixelsEXT(void* self, GLint x, GLint y, GLsizei width, 822 GLsizei height, GLenum format, GLenum type, GLsizei bufSize, 823 GLvoid* pixels); 824 static void s_glGetnUniformfvEXT(void *self, GLuint program, GLint location, 825 GLsizei bufSize, GLfloat* params); 826 static void s_glGetnUniformivEXT(void *self, GLuint program, GLint location, 827 GLsizei bufSize, GLint* params); 828 829 // Invalidate framebuffer 830 static void s_glInvalidateFramebuffer(void* self, GLenum target, GLsizei numAttachments, const GLenum *attachments); 831 static void s_glInvalidateSubFramebuffer(void* self, GLenum target, GLsizei numAttachments, const GLenum *attachments, GLint x, GLint y, GLsizei width, GLsizei height); 832 833 glInvalidateFramebuffer_client_proc_t m_glInvalidateFramebuffer_enc; 834 glInvalidateSubFramebuffer_client_proc_t m_glInvalidateSubFramebuffer_enc;; 835 836 // Dispatch compute 837 static void s_glDispatchCompute(void* self, GLuint num_groups_x, GLuint num_groups_y, GLuint num_groups_z); 838 static void s_glDispatchComputeIndirect(void* self, GLintptr indirect); 839 840 glDispatchCompute_client_proc_t m_glDispatchCompute_enc; 841 glDispatchComputeIndirect_client_proc_t m_glDispatchComputeIndirect_enc; 842 843 // State tracking for transform feedbacks, samplers, and query objects 844 static void s_glGenTransformFeedbacks(void* self, GLsizei n, GLuint* ids); 845 static void s_glDeleteTransformFeedbacks(void* self, GLsizei n, const GLuint* ids); 846 static void s_glGenSamplers(void* self, GLsizei n, GLuint* ids); 847 static void s_glGenQueries(void* self, GLsizei n, GLuint* ids); 848 static void s_glDeleteQueries(void* self, GLsizei n, const GLuint* ids); 849 850 glGenTransformFeedbacks_client_proc_t m_glGenTransformFeedbacks_enc; 851 glDeleteTransformFeedbacks_client_proc_t m_glDeleteTransformFeedbacks_enc; 852 glGenSamplers_client_proc_t m_glGenSamplers_enc; 853 glGenQueries_client_proc_t m_glGenQueries_enc; 854 glDeleteQueries_client_proc_t m_glDeleteQueries_enc; 855 856 static void s_glBindTransformFeedback(void* self, GLenum target, GLuint id); 857 static void s_glBeginQuery(void* self, GLenum target, GLuint query); 858 static void s_glEndQuery(void* self, GLenum target); 859 860 glBindTransformFeedback_client_proc_t m_glBindTransformFeedback_enc; 861 glBeginQuery_client_proc_t m_glBeginQuery_enc; 862 glEndQuery_client_proc_t m_glEndQuery_enc; 863 864 static void s_glClear(void* self, GLbitfield mask); 865 glClear_client_proc_t m_glClear_enc; 866 867 static void s_glClearBufferfi(void* self, GLenum buffer, GLint drawBuffer, float depth, int stencil); 868 glClearBufferfi_client_proc_t m_glClearBufferfi_enc; 869 870 static void s_glCopyTexSubImage2D(void *self , GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height); 871 glCopyTexSubImage2D_client_proc_t m_glCopyTexSubImage2D_enc; 872 873 static void s_glCopyTexSubImage3D(void *self , GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height); 874 glCopyTexSubImage3D_client_proc_t m_glCopyTexSubImage3D_enc; 875 876 static void s_glCompileShader(void* self, GLuint shader); 877 glCompileShader_client_proc_t m_glCompileShader_enc; 878 879 static void s_glValidateProgram(void* self, GLuint program); 880 glValidateProgram_client_proc_t m_glValidateProgram_enc; 881 882 static void s_glProgramBinary(void *self , GLuint program, GLenum binaryFormat, const void* binary, GLsizei length); 883 glProgramBinary_client_proc_t m_glProgramBinary_enc; 884 885 static void s_glGetSamplerParameterfv(void *self, GLuint sampler, GLenum pname, GLfloat* params); 886 static void s_glGetSamplerParameteriv(void *self, GLuint sampler, GLenum pname, GLint* params); 887 glGetSamplerParameterfv_client_proc_t m_glGetSamplerParameterfv_enc; 888 glGetSamplerParameteriv_client_proc_t m_glGetSamplerParameteriv_enc; 889 890 static void s_glSamplerParameterf(void *self , GLuint sampler, GLenum pname, GLfloat param); 891 static void s_glSamplerParameteri(void *self , GLuint sampler, GLenum pname, GLint param); 892 static void s_glSamplerParameterfv(void *self , GLuint sampler, GLenum pname, const GLfloat* params); 893 static void s_glSamplerParameteriv(void *self , GLuint sampler, GLenum pname, const GLint* params); 894 895 glSamplerParameterf_client_proc_t m_glSamplerParameterf_enc; 896 glSamplerParameteri_client_proc_t m_glSamplerParameteri_enc; 897 glSamplerParameterfv_client_proc_t m_glSamplerParameterfv_enc; 898 glSamplerParameteriv_client_proc_t m_glSamplerParameteriv_enc; 899 900 static int s_glGetAttribLocation(void *self , GLuint program, const GLchar* name); 901 glGetAttribLocation_client_proc_t m_glGetAttribLocation_enc; 902 903 static void s_glBindAttribLocation(void *self , GLuint program, GLuint index, const GLchar* name); 904 static void s_glUniformBlockBinding(void *self , GLuint program, GLuint uniformBlockIndex, GLuint uniformBlockBinding); 905 static void s_glGetTransformFeedbackVarying(void *self , GLuint program, GLuint index, GLsizei bufSize, GLsizei* length, GLsizei* size, GLenum* type, char* name); 906 static void s_glScissor(void *self , GLint x, GLint y, GLsizei width, GLsizei height); 907 static void s_glDepthFunc(void *self , GLenum func); 908 static void s_glViewport(void *self , GLint x, GLint y, GLsizei width, GLsizei height); 909 static void s_glStencilFunc(void *self , GLenum func, GLint ref, GLuint mask); 910 static void s_glStencilFuncSeparate(void *self , GLenum face, GLenum func, GLint ref, GLuint mask); 911 static void s_glStencilOp(void *self , GLenum fail, GLenum zfail, GLenum zpass); 912 static void s_glStencilOpSeparate(void *self , GLenum face, GLenum fail, GLenum zfail, GLenum zpass); 913 static void s_glStencilMaskSeparate(void *self , GLenum face, GLuint mask); 914 static void s_glBlendEquation(void *self , GLenum mode); 915 static void s_glBlendEquationSeparate(void *self , GLenum modeRGB, GLenum modeAlpha); 916 static void s_glBlendFunc(void *self , GLenum sfactor, GLenum dfactor); 917 static void s_glBlendFuncSeparate(void *self , GLenum srcRGB, GLenum dstRGB, GLenum srcAlpha, GLenum dstAlpha); 918 static void s_glCullFace(void *self , GLenum mode); 919 static void s_glFrontFace(void *self , GLenum mode); 920 static void s_glLineWidth(void *self , GLfloat width); 921 static void s_glVertexAttrib1f(void *self , GLuint indx, GLfloat x); 922 static void s_glVertexAttrib2f(void *self , GLuint indx, GLfloat x, GLfloat y); 923 static void s_glVertexAttrib3f(void *self , GLuint indx, GLfloat x, GLfloat y, GLfloat z); 924 static void s_glVertexAttrib4f(void *self , GLuint indx, GLfloat x, GLfloat y, GLfloat z, GLfloat w); 925 static void s_glVertexAttrib1fv(void *self , GLuint indx, const GLfloat* values); 926 static void s_glVertexAttrib2fv(void *self , GLuint indx, const GLfloat* values); 927 static void s_glVertexAttrib3fv(void *self , GLuint indx, const GLfloat* values); 928 static void s_glVertexAttrib4fv(void *self , GLuint indx, const GLfloat* values); 929 static void s_glVertexAttribI4i(void *self , GLuint index, GLint v0, GLint v1, GLint v2, GLint v3); 930 static void s_glVertexAttribI4ui(void *self , GLuint index, GLuint v0, GLuint v1, GLuint v2, GLuint v3); 931 static void s_glVertexAttribI4iv(void *self , GLuint index, const GLint* v); 932 static void s_glVertexAttribI4uiv(void *self , GLuint index, const GLuint* v); 933 934 static void s_glGetShaderPrecisionFormat(void *self , GLenum shadertype, GLenum precisiontype, GLint* range, GLint* precision); 935 static void s_glGetProgramiv(void *self , GLuint program, GLenum pname, GLint* params); 936 static void s_glGetActiveUniform(void *self , GLuint program, GLuint index, GLsizei bufsize, GLsizei* length, GLint* size, GLenum* type, GLchar* name); 937 static void s_glGetActiveUniformsiv(void *self , GLuint program, GLsizei uniformCount, const GLuint* uniformIndices, GLenum pname, GLint* params); 938 static void s_glGetActiveUniformBlockName(void *self , GLuint program, GLuint uniformBlockIndex, GLsizei bufSize, GLsizei* length, GLchar* uniformBlockName); 939 static void s_glGetActiveAttrib(void *self , GLuint program, GLuint index, GLsizei bufsize, GLsizei* length, GLint* size, GLenum* type, GLchar* name); 940 static void s_glGetRenderbufferParameteriv(void *self , GLenum target, GLenum pname, GLint* params); 941 static void s_glGetQueryiv(void *self , GLenum target, GLenum pname, GLint* params); 942 static void s_glGetQueryObjectuiv(void *self , GLuint query, GLenum pname, GLuint* params); 943 static GLboolean s_glIsEnabled(void *self , GLenum cap); 944 static void s_glHint(void *self , GLenum target, GLenum mode); 945 static GLint s_glGetFragDataLocation (void *self , GLuint program, const char* name); 946 947 static void s_glStencilMask(void* self, GLuint mask); 948 static void s_glClearStencil(void* self, int v); 949 950 #define LIST_REMAINING_FUNCTIONS_FOR_VALIDATION(f) \ 951 f(glBindAttribLocation) \ 952 f(glUniformBlockBinding) \ 953 f(glGetTransformFeedbackVarying) \ 954 f(glScissor) \ 955 f(glDepthFunc) \ 956 f(glViewport) \ 957 f(glStencilFunc) \ 958 f(glStencilFuncSeparate) \ 959 f(glStencilOp) \ 960 f(glStencilOpSeparate) \ 961 f(glStencilMaskSeparate) \ 962 f(glBlendEquation) \ 963 f(glBlendEquationSeparate) \ 964 f(glBlendFunc) \ 965 f(glBlendFuncSeparate) \ 966 f(glCullFace) \ 967 f(glFrontFace) \ 968 f(glLineWidth) \ 969 f(glVertexAttrib1f) \ 970 f(glVertexAttrib2f) \ 971 f(glVertexAttrib3f) \ 972 f(glVertexAttrib4f) \ 973 f(glVertexAttrib1fv) \ 974 f(glVertexAttrib2fv) \ 975 f(glVertexAttrib3fv) \ 976 f(glVertexAttrib4fv) \ 977 f(glVertexAttribI4i) \ 978 f(glVertexAttribI4ui) \ 979 f(glVertexAttribI4iv) \ 980 f(glVertexAttribI4uiv) \ 981 f(glGetShaderPrecisionFormat) \ 982 f(glGetProgramiv) \ 983 f(glGetActiveUniform) \ 984 f(glGetActiveUniformsiv) \ 985 f(glGetActiveUniformBlockName) \ 986 f(glGetActiveAttrib) \ 987 f(glGetRenderbufferParameteriv) \ 988 f(glGetQueryiv) \ 989 f(glGetQueryObjectuiv) \ 990 f(glIsEnabled) \ 991 f(glHint) \ 992 f(glGetFragDataLocation) \ 993 f(glStencilMask) \ 994 f(glClearStencil) \ 995 996 #define DECLARE_CLIENT_ENCODER_PROC(n) \ 997 n##_client_proc_t m_##n##_enc; 998 999 LIST_REMAINING_FUNCTIONS_FOR_VALIDATION(DECLARE_CLIENT_ENCODER_PROC) 1000 1001 1002 public: 1003 glEGLImageTargetTexture2DOES_client_proc_t m_glEGLImageTargetTexture2DOES_enc; 1004 1005 }; 1006 #endif 1007