glGetStringi(GLenum name,GLint index)1 EXTERN_PART GL_APICALL GLconstubyteptr GL_APIENTRY glGetStringi(GLenum name, GLint index) {
2     GET_CTX_V2_RET(0);
3     GLconstubyteptr glGetStringiRET = ctx->dispatcher().glGetStringi(name, index);
4     return glGetStringiRET;
5 }
6 
glGenVertexArrays(GLsizei n,GLuint * arrays)7 GL_APICALL void GL_APIENTRY glGenVertexArrays(GLsizei n, GLuint* arrays) {
8     glGenVertexArraysOES(n, arrays);
9 }
10 
glBindVertexArray(GLuint array)11 GL_APICALL void GL_APIENTRY glBindVertexArray(GLuint array) {
12     glBindVertexArrayOES(array);
13 }
14 
glDeleteVertexArrays(GLsizei n,const GLuint * arrays)15 GL_APICALL void GL_APIENTRY glDeleteVertexArrays(GLsizei n, const GLuint * arrays) {
16     glDeleteVertexArraysOES(n, arrays);
17 }
18 
glIsVertexArray(GLuint array)19 GL_APICALL GLboolean GL_APIENTRY glIsVertexArray(GLuint array) {
20     return glIsVertexArrayOES(array);
21 }
22 
glMapBufferRange(GLenum target,GLintptr offset,GLsizeiptr length,GLbitfield access)23 GL_APICALL void * GL_APIENTRY glMapBufferRange(GLenum target, GLintptr offset, GLsizeiptr length, GLbitfield access) {
24     GET_CTX_V2_RET(0);
25     RET_AND_SET_ERROR_IF(!GLESv2Validate::bufferTarget(ctx, target),GL_INVALID_ENUM,0);
26     void * glMapBufferRangeRET = ctx->dispatcher().glMapBufferRange(target, offset, length, access);
27     return glMapBufferRangeRET;
28 }
29 
glUnmapBuffer(GLenum target)30 GL_APICALL GLboolean GL_APIENTRY glUnmapBuffer(GLenum target) {
31     GET_CTX_V2_RET(0);
32     RET_AND_SET_ERROR_IF(!GLESv2Validate::bufferTarget(ctx, target),GL_INVALID_ENUM,0);
33     GLboolean glUnmapBufferRET = ctx->dispatcher().glUnmapBuffer(target);
34     return glUnmapBufferRET;
35 }
36 
glFlushMappedBufferRange(GLenum target,GLintptr offset,GLsizeiptr length)37 GL_APICALL void GL_APIENTRY glFlushMappedBufferRange(GLenum target, GLintptr offset, GLsizeiptr length) {
38     GET_CTX_V2();
39     SET_ERROR_IF(!GLESv2Validate::bufferTarget(ctx, target),GL_INVALID_ENUM);
40     ctx->dispatcher().glFlushMappedBufferRange(target, offset, length);
41 }
42 
glBindBufferRange(GLenum target,GLuint index,GLuint buffer,GLintptr offset,GLsizeiptr size)43 GL_APICALL void GL_APIENTRY glBindBufferRange(GLenum target, GLuint index, GLuint buffer, GLintptr offset, GLsizeiptr size) {
44     GET_CTX_V2();
45     SET_ERROR_IF(!GLESv2Validate::bufferTarget(ctx, target),GL_INVALID_ENUM);
46     ctx->bindBuffer(target, buffer);
47     ctx->bindIndexedBuffer(target, index, buffer, offset, size);
48     if (ctx->shareGroup().get()) {
49         const GLuint globalBufferName = ctx->shareGroup()->getGlobalName(NamedObjectType::VERTEXBUFFER, buffer);
50         ctx->dispatcher().glBindBufferRange(target, index, globalBufferName, offset, size);
51     }
52 }
53 
glBindBufferBase(GLenum target,GLuint index,GLuint buffer)54 GL_APICALL void GL_APIENTRY glBindBufferBase(GLenum target, GLuint index, GLuint buffer) {
55     GET_CTX_V2();
56     SET_ERROR_IF(!GLESv2Validate::bufferTarget(ctx, target),GL_INVALID_ENUM);
57     ctx->bindBuffer(target, buffer);
58     ctx->bindIndexedBuffer(target, index, buffer);
59     if (ctx->shareGroup().get()) {
60         const GLuint globalBufferName = ctx->shareGroup()->getGlobalName(NamedObjectType::VERTEXBUFFER, buffer);
61         ctx->dispatcher().glBindBufferBase(target, index, globalBufferName);
62     }
63 }
64 
glCopyBufferSubData(GLenum readtarget,GLenum writetarget,GLintptr readoffset,GLintptr writeoffset,GLsizeiptr size)65 GL_APICALL void GL_APIENTRY glCopyBufferSubData(GLenum readtarget, GLenum writetarget, GLintptr readoffset, GLintptr writeoffset, GLsizeiptr size) {
66     GET_CTX_V2();
67     ctx->dispatcher().glCopyBufferSubData(readtarget, writetarget, readoffset, writeoffset, size);
68 }
69 
glClearBufferiv(GLenum buffer,GLint drawBuffer,const GLint * value)70 GL_APICALL void GL_APIENTRY glClearBufferiv(GLenum buffer, GLint drawBuffer, const GLint * value) {
71     GET_CTX_V2();
72     ctx->dispatcher().glClearBufferiv(buffer, drawBuffer, value);
73 }
74 
glClearBufferuiv(GLenum buffer,GLint drawBuffer,const GLuint * value)75 GL_APICALL void GL_APIENTRY glClearBufferuiv(GLenum buffer, GLint drawBuffer, const GLuint * value) {
76     GET_CTX_V2();
77     ctx->dispatcher().glClearBufferuiv(buffer, drawBuffer, value);
78 }
79 
glClearBufferfv(GLenum buffer,GLint drawBuffer,const GLfloat * value)80 GL_APICALL void GL_APIENTRY glClearBufferfv(GLenum buffer, GLint drawBuffer, const GLfloat * value) {
81     GET_CTX_V2();
82     ctx->dispatcher().glClearBufferfv(buffer, drawBuffer, value);
83 }
84 
glClearBufferfi(GLenum buffer,GLint drawBuffer,GLfloat depth,GLint stencil)85 GL_APICALL void GL_APIENTRY glClearBufferfi(GLenum buffer, GLint drawBuffer, GLfloat depth, GLint stencil) {
86     GET_CTX_V2();
87     ctx->dispatcher().glClearBufferfi(buffer, drawBuffer, depth, stencil);
88 }
89 
glGetBufferParameteri64v(GLenum target,GLenum value,GLint64 * data)90 GL_APICALL void GL_APIENTRY glGetBufferParameteri64v(GLenum target, GLenum value, GLint64 * data) {
91     GET_CTX_V2();
92     SET_ERROR_IF(!GLESv2Validate::bufferTarget(ctx, target),GL_INVALID_ENUM);
93     ctx->dispatcher().glGetBufferParameteri64v(target, value, data);
94 }
95 
glGetBufferPointerv(GLenum target,GLenum pname,GLvoid ** params)96 GL_APICALL void GL_APIENTRY glGetBufferPointerv(GLenum target, GLenum pname, GLvoid ** params) {
97     GET_CTX_V2();
98     SET_ERROR_IF(!GLESv2Validate::bufferTarget(ctx, target),GL_INVALID_ENUM);
99     ctx->dispatcher().glGetBufferPointerv(target, pname, params);
100 }
101 
glUniformBlockBinding(GLuint program,GLuint uniformBlockIndex,GLuint uniformBlockBinding)102 GL_APICALL void GL_APIENTRY glUniformBlockBinding(GLuint program, GLuint uniformBlockIndex, GLuint uniformBlockBinding) {
103     GET_CTX_V2();
104     if (ctx->shareGroup().get()) {
105         const GLuint globalProgramName = ctx->shareGroup()->getGlobalName(NamedObjectType::SHADER_OR_PROGRAM, program);
106         ctx->dispatcher().glUniformBlockBinding(globalProgramName, uniformBlockIndex, uniformBlockBinding);
107     }
108 }
109 
glGetUniformBlockIndex(GLuint program,const GLchar * uniformBlockName)110 GL_APICALL GLuint GL_APIENTRY glGetUniformBlockIndex(GLuint program, const GLchar * uniformBlockName) {
111     GET_CTX_V2_RET(0);
112     if (ctx->shareGroup().get()) {
113         const GLuint globalProgramName = ctx->shareGroup()->getGlobalName(NamedObjectType::SHADER_OR_PROGRAM, program);
114         GLuint glGetUniformBlockIndexRET = ctx->dispatcher().glGetUniformBlockIndex(globalProgramName, uniformBlockName);
115     return glGetUniformBlockIndexRET;
116     } else return 0;
117 }
118 
glGetUniformIndices(GLuint program,GLsizei uniformCount,const GLchar ** uniformNames,GLuint * uniformIndices)119 EXTERN_PART GL_APICALL void GL_APIENTRY glGetUniformIndices(GLuint program, GLsizei uniformCount, const GLchar ** uniformNames, GLuint * uniformIndices) {
120     GET_CTX_V2();
121     if (ctx->shareGroup().get()) {
122         const GLuint globalProgramName = ctx->shareGroup()->getGlobalName(NamedObjectType::SHADER_OR_PROGRAM, program);
123         ctx->dispatcher().glGetUniformIndices(globalProgramName, uniformCount, uniformNames, uniformIndices);
124     }
125 }
126 
glGetActiveUniformBlockiv(GLuint program,GLuint uniformBlockIndex,GLenum pname,GLint * params)127 GL_APICALL void GL_APIENTRY glGetActiveUniformBlockiv(GLuint program, GLuint uniformBlockIndex, GLenum pname, GLint * params) {
128     GET_CTX_V2();
129     if (ctx->shareGroup().get()) {
130         const GLuint globalProgramName = ctx->shareGroup()->getGlobalName(NamedObjectType::SHADER_OR_PROGRAM, program);
131         ctx->dispatcher().glGetActiveUniformBlockiv(globalProgramName, uniformBlockIndex, pname, params);
132     }
133 }
134 
glGetActiveUniformBlockName(GLuint program,GLuint uniformBlockIndex,GLsizei bufSize,GLsizei * length,GLchar * uniformBlockName)135 GL_APICALL void GL_APIENTRY glGetActiveUniformBlockName(GLuint program, GLuint uniformBlockIndex, GLsizei bufSize, GLsizei * length, GLchar * uniformBlockName) {
136     GET_CTX_V2();
137     if (ctx->shareGroup().get()) {
138         const GLuint globalProgramName = ctx->shareGroup()->getGlobalName(NamedObjectType::SHADER_OR_PROGRAM, program);
139         ctx->dispatcher().glGetActiveUniformBlockName(globalProgramName, uniformBlockIndex, bufSize, length, uniformBlockName);
140     }
141 }
142 
glUniform1ui(GLint location,GLuint v0)143 GL_APICALL void GL_APIENTRY glUniform1ui(GLint location, GLuint v0) {
144     GET_CTX_V2();
145     int hostLoc = s_getHostLocOrSetError(ctx, location);
146     SET_ERROR_IF(hostLoc < -1, GL_INVALID_OPERATION);
147     ctx->dispatcher().glUniform1ui(hostLoc, v0);
148 }
149 
glUniform2ui(GLint location,GLuint v0,GLuint v1)150 GL_APICALL void GL_APIENTRY glUniform2ui(GLint location, GLuint v0, GLuint v1) {
151     GET_CTX_V2();
152     int hostLoc = s_getHostLocOrSetError(ctx, location);
153     SET_ERROR_IF(hostLoc < -1, GL_INVALID_OPERATION);
154     ctx->dispatcher().glUniform2ui(hostLoc, v0, v1);
155 }
156 
glUniform3ui(GLint location,GLuint v0,GLuint v1,GLuint v2)157 GL_APICALL void GL_APIENTRY glUniform3ui(GLint location, GLuint v0, GLuint v1, GLuint v2) {
158     GET_CTX_V2();
159     int hostLoc = s_getHostLocOrSetError(ctx, location);
160     SET_ERROR_IF(hostLoc < -1, GL_INVALID_OPERATION);
161     ctx->dispatcher().glUniform3ui(hostLoc, v0, v1, v2);
162 }
163 
glUniform4ui(GLint location,GLint v0,GLuint v1,GLuint v2,GLuint v3)164 EXTERN_PART GL_APICALL void GL_APIENTRY glUniform4ui(GLint location, GLint v0, GLuint v1, GLuint v2, GLuint v3) {
165     GET_CTX_V2();
166     int hostLoc = s_getHostLocOrSetError(ctx, location);
167     SET_ERROR_IF(hostLoc < -1, GL_INVALID_OPERATION);
168     ctx->dispatcher().glUniform4ui(hostLoc, v0, v1, v2, v3);
169 }
170 
glUniform1uiv(GLint location,GLsizei count,const GLuint * value)171 GL_APICALL void GL_APIENTRY glUniform1uiv(GLint location, GLsizei count, const GLuint * value) {
172     GET_CTX_V2();
173     int hostLoc = s_getHostLocOrSetError(ctx, location);
174     SET_ERROR_IF(hostLoc < -1, GL_INVALID_OPERATION);
175     ctx->dispatcher().glUniform1uiv(hostLoc, count, value);
176 }
177 
glUniform2uiv(GLint location,GLsizei count,const GLuint * value)178 GL_APICALL void GL_APIENTRY glUniform2uiv(GLint location, GLsizei count, const GLuint * value) {
179     GET_CTX_V2();
180     int hostLoc = s_getHostLocOrSetError(ctx, location);
181     SET_ERROR_IF(hostLoc < -1, GL_INVALID_OPERATION);
182     ctx->dispatcher().glUniform2uiv(hostLoc, count, value);
183 }
184 
glUniform3uiv(GLint location,GLsizei count,const GLuint * value)185 GL_APICALL void GL_APIENTRY glUniform3uiv(GLint location, GLsizei count, const GLuint * value) {
186     GET_CTX_V2();
187     int hostLoc = s_getHostLocOrSetError(ctx, location);
188     SET_ERROR_IF(hostLoc < -1, GL_INVALID_OPERATION);
189     ctx->dispatcher().glUniform3uiv(hostLoc, count, value);
190 }
191 
glUniform4uiv(GLint location,GLsizei count,const GLuint * value)192 GL_APICALL void GL_APIENTRY glUniform4uiv(GLint location, GLsizei count, const GLuint * value) {
193     GET_CTX_V2();
194     int hostLoc = s_getHostLocOrSetError(ctx, location);
195     SET_ERROR_IF(hostLoc < -1, GL_INVALID_OPERATION);
196     ctx->dispatcher().glUniform4uiv(hostLoc, count, value);
197 }
198 
glUniformMatrix2x3fv(GLint location,GLsizei count,GLboolean transpose,const GLfloat * value)199 GL_APICALL void GL_APIENTRY glUniformMatrix2x3fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat * value) {
200     GET_CTX_V2();
201     int hostLoc = s_getHostLocOrSetError(ctx, location);
202     SET_ERROR_IF(hostLoc < -1, GL_INVALID_OPERATION);
203     ctx->dispatcher().glUniformMatrix2x3fv(hostLoc, count, transpose, value);
204 }
205 
glUniformMatrix3x2fv(GLint location,GLsizei count,GLboolean transpose,const GLfloat * value)206 GL_APICALL void GL_APIENTRY glUniformMatrix3x2fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat * value) {
207     GET_CTX_V2();
208     int hostLoc = s_getHostLocOrSetError(ctx, location);
209     SET_ERROR_IF(hostLoc < -1, GL_INVALID_OPERATION);
210     ctx->dispatcher().glUniformMatrix3x2fv(hostLoc, count, transpose, value);
211 }
212 
glUniformMatrix2x4fv(GLint location,GLsizei count,GLboolean transpose,const GLfloat * value)213 GL_APICALL void GL_APIENTRY glUniformMatrix2x4fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat * value) {
214     GET_CTX_V2();
215     int hostLoc = s_getHostLocOrSetError(ctx, location);
216     SET_ERROR_IF(hostLoc < -1, GL_INVALID_OPERATION);
217     ctx->dispatcher().glUniformMatrix2x4fv(hostLoc, count, transpose, value);
218 }
219 
glUniformMatrix4x2fv(GLint location,GLsizei count,GLboolean transpose,const GLfloat * value)220 GL_APICALL void GL_APIENTRY glUniformMatrix4x2fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat * value) {
221     GET_CTX_V2();
222     int hostLoc = s_getHostLocOrSetError(ctx, location);
223     SET_ERROR_IF(hostLoc < -1, GL_INVALID_OPERATION);
224     ctx->dispatcher().glUniformMatrix4x2fv(hostLoc, count, transpose, value);
225 }
226 
glUniformMatrix3x4fv(GLint location,GLsizei count,GLboolean transpose,const GLfloat * value)227 GL_APICALL void GL_APIENTRY glUniformMatrix3x4fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat * value) {
228     GET_CTX_V2();
229     int hostLoc = s_getHostLocOrSetError(ctx, location);
230     SET_ERROR_IF(hostLoc < -1, GL_INVALID_OPERATION);
231     ctx->dispatcher().glUniformMatrix3x4fv(hostLoc, count, transpose, value);
232 }
233 
glUniformMatrix4x3fv(GLint location,GLsizei count,GLboolean transpose,const GLfloat * value)234 GL_APICALL void GL_APIENTRY glUniformMatrix4x3fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat * value) {
235     GET_CTX_V2();
236     int hostLoc = s_getHostLocOrSetError(ctx, location);
237     SET_ERROR_IF(hostLoc < -1, GL_INVALID_OPERATION);
238     ctx->dispatcher().glUniformMatrix4x3fv(hostLoc, count, transpose, value);
239 }
240 
glGetUniformuiv(GLuint program,GLint location,GLuint * params)241 GL_APICALL void GL_APIENTRY glGetUniformuiv(GLuint program, GLint location, GLuint * params) {
242     GET_CTX_V2();
243 
244     SET_ERROR_IF(location < 0,GL_INVALID_OPERATION);
245     if (ctx->shareGroup().get()) {
246         const GLuint globalProgramName = ctx->shareGroup()->getGlobalName(NamedObjectType::SHADER_OR_PROGRAM, program);
247 
248         SET_ERROR_IF(globalProgramName==0, GL_INVALID_VALUE);
249         auto objData = ctx->shareGroup()->getObjectData(
250                 NamedObjectType::SHADER_OR_PROGRAM, program);
251         SET_ERROR_IF(objData->getDataType()!=PROGRAM_DATA,GL_INVALID_OPERATION);
252         ProgramData* pData = (ProgramData *)objData;
253         (void)pData;
254 #if !defined(TOLERATE_PROGRAM_LINK_ERROR) || !TOLERATE_PROGRAM_LINK_ERROR
255         SET_ERROR_IF(!pData->getLinkStatus(), GL_INVALID_OPERATION);
256 #endif
257         int hostLoc = s_getHostLocOrSetError(ctx, location);
258         SET_ERROR_IF(hostLoc < -1, GL_INVALID_OPERATION);
259         ctx->dispatcher().glGetUniformuiv(globalProgramName, hostLoc, params);
260     }
261 }
262 
glGetActiveUniformsiv(GLuint program,GLsizei uniformCount,const GLuint * uniformIndices,GLenum pname,GLint * params)263 GL_APICALL void GL_APIENTRY glGetActiveUniformsiv(GLuint program, GLsizei uniformCount, const GLuint * uniformIndices, GLenum pname, GLint * params) {
264     GET_CTX_V2();
265     if (ctx->shareGroup().get()) {
266         const GLuint globalProgramName = ctx->shareGroup()->getGlobalName(NamedObjectType::SHADER_OR_PROGRAM, program);
267         ctx->dispatcher().glGetActiveUniformsiv(globalProgramName, uniformCount, uniformIndices, pname, params);
268     }
269 }
270 
glVertexAttribI4i(GLuint index,GLint v0,GLint v1,GLint v2,GLint v3)271 GL_APICALL void GL_APIENTRY glVertexAttribI4i(GLuint index, GLint v0, GLint v1, GLint v2, GLint v3) {
272     GET_CTX_V2();
273     ctx->dispatcher().glVertexAttribI4i(index, v0, v1, v2, v3);
274 }
275 
glVertexAttribI4ui(GLuint index,GLuint v0,GLuint v1,GLuint v2,GLuint v3)276 GL_APICALL void GL_APIENTRY glVertexAttribI4ui(GLuint index, GLuint v0, GLuint v1, GLuint v2, GLuint v3) {
277     GET_CTX_V2();
278     ctx->dispatcher().glVertexAttribI4ui(index, v0, v1, v2, v3);
279 }
280 
glVertexAttribI4iv(GLuint index,const GLint * v)281 GL_APICALL void GL_APIENTRY glVertexAttribI4iv(GLuint index, const GLint * v) {
282     GET_CTX_V2();
283     ctx->dispatcher().glVertexAttribI4iv(index, v);
284 }
285 
glVertexAttribI4uiv(GLuint index,const GLuint * v)286 GL_APICALL void GL_APIENTRY glVertexAttribI4uiv(GLuint index, const GLuint * v) {
287     GET_CTX_V2();
288     ctx->dispatcher().glVertexAttribI4uiv(index, v);
289 }
290 
glVertexAttribIPointerWithDataSize(GLuint index,GLint size,GLenum type,GLsizei stride,const GLvoid * ptr,GLsizei dataSize)291 GL_APICALL void  GL_APIENTRY glVertexAttribIPointerWithDataSize(GLuint index, GLint size, GLenum type, GLsizei stride, const GLvoid* ptr, GLsizei dataSize) {
292     GET_CTX_V2();
293     SET_ERROR_IF((!GLESv2Validate::arrayIndex(ctx,index)),GL_INVALID_VALUE);
294 
295     s_glPrepareVertexAttribPointer(ctx, index, size, type, false, stride, ptr, dataSize, true);
296     if (ctx->isBindedBuffer(GL_ARRAY_BUFFER)) {
297         ctx->dispatcher().glVertexAttribIPointer(index, size, type, stride, ptr);
298     }
299 }
300 
glVertexAttribIPointer(GLuint index,GLint size,GLenum type,GLsizei stride,const GLvoid * pointer)301 GL_APICALL void GL_APIENTRY glVertexAttribIPointer(GLuint index, GLint size, GLenum type, GLsizei stride, const GLvoid * pointer) {
302     GET_CTX_V2();
303     SET_ERROR_IF((!GLESv2Validate::arrayIndex(ctx,index)),GL_INVALID_VALUE);
304     s_glPrepareVertexAttribPointer(ctx, index, size, type, false, stride, pointer, 0, true);
305     if (ctx->isBindedBuffer(GL_ARRAY_BUFFER)) {
306         ctx->dispatcher().glVertexAttribIPointer(index, size, type, stride, pointer);
307     }
308 }
309 
glGetVertexAttribIiv(GLuint index,GLenum pname,GLint * params)310 GL_APICALL void GL_APIENTRY glGetVertexAttribIiv(GLuint index, GLenum pname, GLint * params) {
311     GET_CTX_V2();
312     ctx->dispatcher().glGetVertexAttribIiv(index, pname, params);
313 }
314 
glGetVertexAttribIuiv(GLuint index,GLenum pname,GLuint * params)315 GL_APICALL void GL_APIENTRY glGetVertexAttribIuiv(GLuint index, GLenum pname, GLuint * params) {
316     GET_CTX_V2();
317     ctx->dispatcher().glGetVertexAttribIuiv(index, pname, params);
318 }
319 
glVertexAttribDivisor(GLuint index,GLuint divisor)320 GL_APICALL void GL_APIENTRY glVertexAttribDivisor(GLuint index, GLuint divisor) {
321     GET_CTX_V2();
322     SET_ERROR_IF((!GLESv2Validate::arrayIndex(ctx,index)),GL_INVALID_VALUE);
323     ctx->setVertexAttribBindingIndex(index, index);
324     ctx->setVertexAttribDivisor(index, divisor);
325     ctx->dispatcher().glVertexAttribDivisor(index, divisor);
326 }
327 
glDrawArraysInstanced(GLenum mode,GLint first,GLsizei count,GLsizei primcount)328 GL_APICALL void GL_APIENTRY glDrawArraysInstanced(GLenum mode, GLint first, GLsizei count, GLsizei primcount) {
329     GET_CTX_V2();
330     SET_ERROR_IF(count < 0,GL_INVALID_VALUE)
331     SET_ERROR_IF(!(GLESv2Validate::drawMode(mode)),GL_INVALID_ENUM);
332     if (ctx->vertexAttributesBufferBacked()) {
333         s_glDrawPre(ctx, mode);
334         ctx->dispatcher().glDrawArraysInstanced(mode, first, count, primcount);
335         s_glDrawPost(ctx, mode);
336     } else {
337         ctx->drawWithEmulations(
338                 GLESv2Context::DrawCallCmd::ArraysInstanced,
339                 mode, first, count,
340                 0, nullptr, primcount, 0, 0 /* type, indices, start, end unused */);
341     }
342 }
343 
glDrawElementsInstanced(GLenum mode,GLsizei count,GLenum type,const void * indices,GLsizei primcount)344 GL_APICALL void GL_APIENTRY glDrawElementsInstanced(GLenum mode, GLsizei count, GLenum type, const void * indices, GLsizei primcount) {
345     GET_CTX_V2();
346     SET_ERROR_IF(count < 0,GL_INVALID_VALUE)
347     SET_ERROR_IF(!(GLESv2Validate::drawMode(mode) && GLESv2Validate::drawType(type)),GL_INVALID_ENUM);
348 
349     if (ctx->isBindedBuffer(GL_ELEMENT_ARRAY_BUFFER) &&
350         ctx->vertexAttributesBufferBacked()) {
351         s_glDrawPre(ctx, mode, type);
352         ctx->dispatcher().glDrawElementsInstanced(mode, count, type, indices, primcount);
353         s_glDrawPost(ctx, mode);
354     } else {
355         ctx->drawWithEmulations(
356                 GLESv2Context::DrawCallCmd::ElementsInstanced,
357                 mode, 0 /* first (unused) */, count, type, indices, primcount,
358                 0, 0 /* start, end (unused) */);
359     }
360 }
361 
glDrawRangeElements(GLenum mode,GLuint start,GLuint end,GLsizei count,GLenum type,const GLvoid * indices)362 GL_APICALL void GL_APIENTRY glDrawRangeElements(GLenum mode, GLuint start, GLuint end, GLsizei count, GLenum type, const GLvoid * indices) {
363     GET_CTX_V2();
364     SET_ERROR_IF(count < 0,GL_INVALID_VALUE)
365     SET_ERROR_IF(!(GLESv2Validate::drawMode(mode) && GLESv2Validate::drawType(type)),GL_INVALID_ENUM);
366 
367     if (ctx->isBindedBuffer(GL_ELEMENT_ARRAY_BUFFER) &&
368         ctx->vertexAttributesBufferBacked()) {
369         s_glDrawPre(ctx, mode, type);
370         ctx->dispatcher().glDrawRangeElements(mode, start, end, count, type, indices);
371         s_glDrawPost(ctx, mode);
372     } else {
373         ctx->drawWithEmulations(
374                 GLESv2Context::DrawCallCmd::RangeElements,
375                 mode, 0 /* first (unused) */, count, type, indices, 0 /* primcount (unused) */,
376                 start, end);
377     }
378 }
379 
380 // GuestSyncs: Tracks the system-wide set of GL syncs, puts them in a
381 // distinguished namespace from EGL syncs. This is in its own class as opposed
382 // to a NameSpace because a) no real need to snapshot save/load those and b) it
383 // needs to span all contexts and give the same names across the entire system,
384 // as sync objects live outside of GL context state.
385 // This is to fix dEQP negative_api tests that delete sync object 0x1 but fail due
386 // to it colliding with an EGL fence name.
387 class GuestSyncs {
388 public:
GuestSyncs()389     GuestSyncs() { }
390 
create(GLsync newHostSync)391     GLsync create(GLsync newHostSync) {
392         GLsync res = (GLsync)(uintptr_t)mNameCounter;
393         mSyncs[res] = newHostSync;
394         mNameCounter++;
395         if (!mNameCounter) mNameCounter = 0x1000;
396         return res;
397     }
398 
lookupWithError(GLsync guestSync,GLint * err)399     GLsync lookupWithError(GLsync guestSync, GLint* err) {
400         *err = GL_NO_ERROR;
401         GLsync host = (GLsync)0x0;
402 
403         const auto& it = mSyncs.find(guestSync);
404         if (it == mSyncs.end()) {
405             *err = GL_INVALID_VALUE;
406             return host;
407         } else {
408             host = it->second;
409         }
410         return host;
411     }
412 
removeWithError(GLsync guestSyncToDelete,GLint * err)413     GLsync removeWithError(GLsync guestSyncToDelete, GLint* err) {
414         *err = GL_NO_ERROR;
415         GLsync host = (GLsync)0x0;
416 
417         if (!guestSyncToDelete) {
418             return host;
419         }
420 
421         const auto& it = mSyncs.find(guestSyncToDelete);
422         if (it == mSyncs.end()) {
423             *err = GL_INVALID_VALUE;
424             return host;
425         } else {
426             host = it->second;
427         }
428 
429         mSyncs.erase(it);
430         return host;
431     }
432 
isSync(GLsync guestSync)433     bool isSync(GLsync guestSync) {
434         return mSyncs.find(guestSync) != mSyncs.end();
435     }
436 
lock()437     android::base::Lock& lock() { return mLock; }
438 
439 private:
440     std::unordered_map<GLsync, GLsync> mSyncs;
441     mutable android::base::Lock mLock;
442     uint32_t mNameCounter = 0x1;
443 };
444 
sSyncs()445 static GuestSyncs* sSyncs() {
446     static GuestSyncs* s = new GuestSyncs;
447     return s;
448 }
449 
internal_glFenceSync(GLenum condition,GLbitfield flags)450 static GLsync internal_glFenceSync(GLenum condition, GLbitfield flags) {
451     GET_CTX_V2_RET(0);
452     if (!ctx->dispatcher().glFenceSync) {
453         ctx->dispatcher().glFinish();
454         return (GLsync)0x42;
455     }
456     GLsync glFenceSyncRET = ctx->dispatcher().glFenceSync(condition, flags);
457     return glFenceSyncRET;
458 }
459 
internal_glClientWaitSync(GLsync wait_on,GLbitfield flags,GLuint64 timeout)460 static GLenum internal_glClientWaitSync(GLsync wait_on, GLbitfield flags, GLuint64 timeout) {
461     GET_CTX_V2_RET(GL_WAIT_FAILED);
462     if (!ctx->dispatcher().glFenceSync) {
463         return GL_ALREADY_SIGNALED;
464     }
465     GLenum glClientWaitSyncRET = ctx->dispatcher().glClientWaitSync(wait_on, flags, timeout);
466     return glClientWaitSyncRET;
467 }
468 
internal_glWaitSync(GLsync wait_on,GLbitfield flags,GLuint64 timeout)469 static void internal_glWaitSync(GLsync wait_on, GLbitfield flags, GLuint64 timeout) {
470     GET_CTX_V2();
471     if (!ctx->dispatcher().glFenceSync) {
472         return;
473     }
474     ctx->dispatcher().glWaitSync(wait_on, flags, timeout);
475 }
476 
internal_glDeleteSync(GLsync to_delete)477 static void internal_glDeleteSync(GLsync to_delete) {
478     GET_CTX_V2();
479     if (!ctx->dispatcher().glFenceSync) {
480         return;
481     }
482     ctx->dispatcher().glDeleteSync(to_delete);
483 }
484 
internal_glGetSynciv(GLsync sync,GLenum pname,GLsizei bufsize,GLsizei * length,GLint * values)485 static void internal_glGetSynciv(GLsync sync, GLenum pname, GLsizei bufsize, GLsizei *length, GLint *values) {
486     GET_CTX_V2();
487     if (!ctx->dispatcher().glGetSynciv) {
488         if (bufsize < sizeof(GLint)) return;
489         switch (pname) {
490             case GL_OBJECT_TYPE:
491                 if (length) *length = sizeof(GLint);
492                 *values = GL_SYNC_FENCE;
493                 break;
494             case GL_SYNC_CONDITION:
495                 if (length) *length = sizeof(GLint);
496                 *values = GL_SYNC_GPU_COMMANDS_COMPLETE;
497                 break;
498             case GL_SYNC_FLAGS:
499                 // Not supported
500                 break;
501             case GL_SYNC_STATUS:
502                 if (length) *length = sizeof(GLint);
503                 *values = GL_SIGNALED;
504                 break;
505             default:
506                 break;
507         }
508         return;
509     }
510     ctx->dispatcher().glGetSynciv(sync, pname, bufsize, length, values);
511 }
512 
glFenceSync(GLenum condition,GLbitfield flags)513 GL_APICALL GLsync GL_APIENTRY glFenceSync(GLenum condition, GLbitfield flags) {
514     GET_CTX_V2_RET(0);
515 
516     android::base::AutoLock lock(sSyncs()->lock());
517     GLsync hostSync = internal_glFenceSync(condition, flags);
518     GLsync guestSync = sSyncs()->create(hostSync);
519     return guestSync;
520 }
521 
glClientWaitSync(GLsync wait_on,GLbitfield flags,GLuint64 timeout)522 GL_APICALL GLenum GL_APIENTRY glClientWaitSync(GLsync wait_on, GLbitfield flags, GLuint64 timeout) {
523     GET_CTX_V2_RET(GL_WAIT_FAILED);
524     GLint err = GL_NO_ERROR;
525 
526     android::base::AutoLock lock(sSyncs()->lock());
527     GLsync hostSync = sSyncs()->lookupWithError(wait_on, &err);
528     RET_AND_SET_ERROR_IF(err != GL_NO_ERROR, err, GL_WAIT_FAILED);
529     return internal_glClientWaitSync(hostSync, flags, timeout);
530 }
531 
glWaitSync(GLsync wait_on,GLbitfield flags,GLuint64 timeout)532 GL_APICALL void GL_APIENTRY glWaitSync(GLsync wait_on, GLbitfield flags, GLuint64 timeout) {
533     GET_CTX_V2();
534     GLint err = GL_NO_ERROR;
535 
536     android::base::AutoLock lock(sSyncs()->lock());
537     GLsync hostSync = sSyncs()->lookupWithError(wait_on, &err);
538     SET_ERROR_IF(err != GL_NO_ERROR, err);
539     internal_glWaitSync(hostSync, flags, timeout);
540 }
541 
glDeleteSync(GLsync to_delete)542 GL_APICALL void GL_APIENTRY glDeleteSync(GLsync to_delete) {
543     GET_CTX_V2();
544     GLint err = GL_NO_ERROR;
545 
546     android::base::AutoLock lock(sSyncs()->lock());
547     GLsync hostSync = sSyncs()->removeWithError(to_delete, &err);
548     SET_ERROR_IF(err != GL_NO_ERROR, err);
549     internal_glDeleteSync(hostSync);
550 }
551 
glIsSync(GLsync sync)552 GL_APICALL GLboolean GL_APIENTRY glIsSync(GLsync sync) {
553     GET_CTX_V2_RET(0);
554 
555     android::base::AutoLock lock(sSyncs()->lock());
556     return sSyncs()->isSync(sync) ? GL_TRUE : GL_FALSE;
557 }
558 
glGetSynciv(GLsync sync,GLenum pname,GLsizei bufSize,GLsizei * length,GLint * values)559 GL_APICALL void GL_APIENTRY glGetSynciv(GLsync sync, GLenum pname, GLsizei bufSize, GLsizei * length, GLint * values) {
560     GET_CTX_V2();
561     GLint err = GL_NO_ERROR;
562 
563     android::base::AutoLock lock(sSyncs()->lock());
564     GLsync hostSync = sSyncs()->lookupWithError(sync, &err);
565     SET_ERROR_IF(err != GL_NO_ERROR, err);
566     ctx->dispatcher().glGetSynciv(hostSync, pname, bufSize, length, values);
567 }
568 
glDrawBuffers(GLsizei n,const GLenum * bufs)569 GL_APICALL void GL_APIENTRY glDrawBuffers(GLsizei n, const GLenum * bufs) {
570     GET_CTX_V2();
571     if (ctx->isDefaultFBOBound(GL_DRAW_FRAMEBUFFER)) {
572         SET_ERROR_IF(n != 1 || (bufs[0] != GL_NONE && bufs[0] != GL_BACK),
573                 GL_INVALID_OPERATION);
574         GLenum emulatedBufs = bufs[0] == GL_NONE ? GL_NONE
575                                                  : GL_COLOR_ATTACHMENT0;
576         ctx->setDefaultFBODrawBuffer(emulatedBufs);
577         ctx->dispatcher().glDrawBuffers(1, &emulatedBufs);
578     } else {
579         GLuint framebuffer = ctx->getFramebufferBinding(GL_DRAW_FRAMEBUFFER);
580         FramebufferData* fbObj = ctx->getFBOData(framebuffer);
581         fbObj->setDrawBuffers(n, bufs);
582         ctx->dispatcher().glDrawBuffers(n, bufs);
583     }
584 }
585 
glReadBuffer(GLenum src)586 GL_APICALL void GL_APIENTRY glReadBuffer(GLenum src) {
587     GET_CTX_V2();
588     // if default fbo is bound and src is GL_BACK,
589     // use GL_COLOR_ATTACHMENT0 all of a sudden.
590     // bc we are using fbo emulation.
591     if (ctx->isDefaultFBOBound(GL_READ_FRAMEBUFFER)) {
592         SET_ERROR_IF(src != GL_NONE && src != GL_BACK, GL_INVALID_OPERATION);
593         GLenum emulatedSrc = src == GL_NONE ? GL_NONE
594                                             : GL_COLOR_ATTACHMENT0;
595         ctx->setDefaultFBOReadBuffer(emulatedSrc);
596         ctx->dispatcher().glReadBuffer(emulatedSrc);
597     } else {
598         GLuint framebuffer = ctx->getFramebufferBinding(GL_READ_FRAMEBUFFER);
599         FramebufferData* fbObj = ctx->getFBOData(framebuffer);
600         fbObj->setReadBuffers(src);
601         ctx->dispatcher().glReadBuffer(src);
602     }
603 }
604 
glBlitFramebuffer(GLint srcX0,GLint srcY0,GLint srcX1,GLint srcY1,GLint dstX0,GLint dstY0,GLint dstX1,GLint dstY1,GLbitfield mask,GLenum filter)605 GL_APICALL void GL_APIENTRY glBlitFramebuffer(GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, GLbitfield mask, GLenum filter) {
606     GET_CTX_V2();
607     ctx->dispatcher().glBlitFramebuffer(srcX0, srcY0, srcX1, srcY1, dstX0, dstY0, dstX1, dstY1, mask, filter);
608 }
609 
sGetEmulatedAttachmentList(GLESv2Context * ctx,GLenum target,GLsizei numAttachments,const GLenum * attachments)610 static std::vector<GLenum> sGetEmulatedAttachmentList(GLESv2Context* ctx, GLenum target,
611                                                       GLsizei numAttachments, const GLenum* attachments) {
612     std::vector<GLenum> res(numAttachments);
613     memcpy(&res[0], attachments, numAttachments * sizeof(GLenum));
614 
615     if (!ctx->hasEmulatedDefaultFBO() ||
616         !ctx->isDefaultFBOBound(target)) return res;
617 
618 
619     for (int i = 0; i < numAttachments; i++) {
620         if (attachments[i] == GL_COLOR) res[i] = GL_COLOR_ATTACHMENT0;
621         if (attachments[i] == GL_DEPTH) res[i] = GL_DEPTH_ATTACHMENT;
622         if (attachments[i] == GL_STENCIL) res[i] = GL_STENCIL_ATTACHMENT;
623     }
624 
625     return res;
626 }
627 
glInvalidateFramebuffer(GLenum target,GLsizei numAttachments,const GLenum * attachments)628 GL_APICALL void GL_APIENTRY glInvalidateFramebuffer(GLenum target, GLsizei numAttachments, const GLenum * attachments) {
629     GET_CTX_V2();
630     SET_ERROR_IF(target != GL_FRAMEBUFFER &&
631                  target != GL_READ_FRAMEBUFFER &&
632                  target != GL_DRAW_FRAMEBUFFER, GL_INVALID_ENUM);
633 
634     GLint maxColorAttachments;
635     glGetIntegerv(GL_MAX_COLOR_ATTACHMENTS, &maxColorAttachments);
636 
637     for (int i = 0; i < numAttachments; i++) {
638         if (attachments[i] >= GL_COLOR_ATTACHMENT0 &&
639             attachments[i] <= GL_COLOR_ATTACHMENT15) {
640                 SET_ERROR_IF((GLint)(attachments[i] - GL_COLOR_ATTACHMENT0 + 1) >
641                              maxColorAttachments, GL_INVALID_OPERATION);
642         }
643     }
644 
645     std::vector<GLenum> emulatedAttachments = sGetEmulatedAttachmentList(ctx, target, numAttachments, attachments);
646     if (ctx->dispatcher().glInvalidateFramebuffer) {
647         ctx->dispatcher().glInvalidateFramebuffer(target, numAttachments, &emulatedAttachments[0]);
648     } else {
649         // If we are missing glInvalidateFramebuffer, just don't do anything and hope things work out.
650     }
651 }
652 
glInvalidateSubFramebuffer(GLenum target,GLsizei numAttachments,const GLenum * attachments,GLint x,GLint y,GLsizei width,GLsizei height)653 GL_APICALL void GL_APIENTRY glInvalidateSubFramebuffer(GLenum target, GLsizei numAttachments, const GLenum * attachments, GLint x, GLint y, GLsizei width, GLsizei height) {
654     GET_CTX_V2();
655     SET_ERROR_IF(target != GL_FRAMEBUFFER &&
656             target != GL_READ_FRAMEBUFFER &&
657             target != GL_DRAW_FRAMEBUFFER, GL_INVALID_ENUM);
658 
659     GLint maxColorAttachments;
660     glGetIntegerv(GL_MAX_COLOR_ATTACHMENTS, &maxColorAttachments);
661 
662     for (int i = 0; i < numAttachments; i++) {
663         if (attachments[i] >= GL_COLOR_ATTACHMENT0 &&
664                 attachments[i] <= GL_COLOR_ATTACHMENT15) {
665             SET_ERROR_IF((GLint)(attachments[i] - GL_COLOR_ATTACHMENT0 + 1) >
666                          maxColorAttachments, GL_INVALID_OPERATION);
667         }
668     }
669 
670     std::vector<GLenum> emulatedAttachments = sGetEmulatedAttachmentList(ctx, target, numAttachments, attachments);
671     if (ctx->dispatcher().glInvalidateSubFramebuffer) {
672         ctx->dispatcher().glInvalidateSubFramebuffer(target, numAttachments, &emulatedAttachments[0], x, y, width, height);
673     } else {
674         // If we are missing glInvalidateSubFramebuffer, just don't do anything and hope things work out.
675     }
676 }
677 
glFramebufferTextureLayer(GLenum target,GLenum attachment,GLuint texture,GLint level,GLint layer)678 GL_APICALL void GL_APIENTRY glFramebufferTextureLayer(GLenum target, GLenum attachment, GLuint texture, GLint level, GLint layer) {
679     GET_CTX_V2();
680     GLenum textarget = GL_TEXTURE_2D_ARRAY;
681     SET_ERROR_IF(!(GLESv2Validate::framebufferTarget(ctx, target) &&
682                    GLESv2Validate::framebufferAttachment(ctx, attachment)), GL_INVALID_ENUM);
683     SET_ERROR_IF(ctx->isDefaultFBOBound(target), GL_INVALID_OPERATION);
684     if (texture) {
685         if (!ctx->shareGroup()->isObject(NamedObjectType::TEXTURE, texture)) {
686             ctx->shareGroup()->genName(NamedObjectType::TEXTURE, texture);
687         }
688         TextureData* texData = getTextureData(texture);
689         textarget = texData->target;
690     }
691     if (ctx->shareGroup().get()) {
692         const GLuint globalTextureName = ctx->shareGroup()->getGlobalName(NamedObjectType::TEXTURE, texture);
693         ctx->dispatcher().glFramebufferTextureLayer(target, attachment, globalTextureName, level, layer);
694     }
695 
696     GLuint fbName = ctx->getFramebufferBinding(target);
697     auto fbObj = ctx->getFBOData(fbName);
698     if (fbObj) {
699         fbObj->setAttachment(
700             ctx, attachment, textarget, texture, ObjectDataPtr());
701     }
702 
703 }
704 
glRenderbufferStorageMultisample(GLenum target,GLsizei samples,GLenum internalformat,GLsizei width,GLsizei height)705 GL_APICALL void GL_APIENTRY glRenderbufferStorageMultisample(GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height) {
706     GET_CTX_V2();
707     GLint err = GL_NO_ERROR;
708     internalformat = sPrepareRenderbufferStorage(internalformat, width, height, samples, &err);
709     SET_ERROR_IF(err != GL_NO_ERROR, err);
710     ctx->dispatcher().glRenderbufferStorageMultisample(target, samples, internalformat, width, height);
711 }
712 
glGetInternalformativ(GLenum target,GLenum internalformat,GLenum pname,GLsizei bufSize,GLint * params)713 GL_APICALL void GL_APIENTRY glGetInternalformativ(GLenum target, GLenum internalformat, GLenum pname, GLsizei bufSize, GLint * params) {
714     GET_CTX_V2();
715     ctx->dispatcher().glGetInternalformativ(target, internalformat, pname, bufSize, params);
716 }
717 
glTexStorage2D(GLenum target,GLsizei levels,GLenum internalformat,GLsizei width,GLsizei height)718 GL_APICALL void GL_APIENTRY glTexStorage2D(GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height) {
719     GET_CTX_V2();
720     GLint err = GL_NO_ERROR;
721     GLenum format, type;
722     GLESv2Validate::getCompatibleFormatTypeForInternalFormat(internalformat, &format, &type);
723     sPrepareTexImage2D(target, 0, (GLint)internalformat, width, height, 0, format, type, 0, NULL, &type, (GLint*)&internalformat, &err);
724     SET_ERROR_IF(err != GL_NO_ERROR, err);
725     TextureData *texData = getTextureTargetData(target);
726     texData->texStorageLevels = levels;
727     ctx->dispatcher().glTexStorage2D(target, levels, internalformat, width, height);
728 }
729 
glBeginTransformFeedback(GLenum primitiveMode)730 GL_APICALL void GL_APIENTRY glBeginTransformFeedback(GLenum primitiveMode) {
731     GET_CTX_V2();
732     ctx->boundTransformFeedback()->mIsActive = true;
733     ctx->boundTransformFeedback()->mIsPaused = false;
734     ctx->dispatcher().glBeginTransformFeedback(primitiveMode);
735 }
736 
glEndTransformFeedback()737 GL_APICALL void GL_APIENTRY glEndTransformFeedback() {
738     GET_CTX_V2();
739     ctx->boundTransformFeedback()->mIsActive = false;
740     ctx->dispatcher().glEndTransformFeedback();
741 }
742 
glGenTransformFeedbacks(GLsizei n,GLuint * ids)743 GL_APICALL void GL_APIENTRY glGenTransformFeedbacks(GLsizei n, GLuint * ids) {
744     GET_CTX_V2();
745     SET_ERROR_IF(n < 0,GL_INVALID_VALUE);
746     for (int i = 0; i < n; i++) {
747         ids[i] = ctx->genTransformFeedbackName(0, true);
748     }
749 }
750 
glDeleteTransformFeedbacks(GLsizei n,const GLuint * ids)751 GL_APICALL void GL_APIENTRY glDeleteTransformFeedbacks(GLsizei n, const GLuint * ids) {
752     GET_CTX_V2();
753     SET_ERROR_IF(n < 0,GL_INVALID_VALUE);
754     ObjectLocalName boundTransformFeedback = ctx->getTransformFeedbackBinding();
755     TransformFeedbackData* tfData = ctx->boundTransformFeedback();
756     if (boundTransformFeedback) {
757         for (GLsizei i = 0; i < n; i++) {
758             SET_ERROR_IF(ids[i] == boundTransformFeedback && tfData->mIsActive,
759                          GL_INVALID_OPERATION);
760         }
761     }
762     for (GLsizei i = 0; i < n; i++) {
763         if (ids[i]) {
764             if (boundTransformFeedback == ids[i]) {
765                 assert(!tfData->mIsActive);
766                 ctx->bindTransformFeedback(0);
767             }
768             ctx->deleteTransformFeedback(ids[i]);
769         }
770     }
771 }
772 
glBindTransformFeedback(GLenum target,GLuint id)773 GL_APICALL void GL_APIENTRY glBindTransformFeedback(GLenum target, GLuint id) {
774     GET_CTX_V2();
775     unsigned int globalName = ctx->getTransformFeedbackGlobalName(id);
776     SET_ERROR_IF(id != 0 && globalName == 0, GL_INVALID_OPERATION);
777     ctx->bindTransformFeedback(id);
778     ctx->dispatcher().glBindTransformFeedback(target, globalName);
779 }
780 
glPauseTransformFeedback()781 GL_APICALL void GL_APIENTRY glPauseTransformFeedback() {
782     GET_CTX_V2();
783     ctx->boundTransformFeedback()->mIsPaused = true;
784     ctx->dispatcher().glPauseTransformFeedback();
785 }
786 
glResumeTransformFeedback()787 GL_APICALL void GL_APIENTRY glResumeTransformFeedback() {
788     GET_CTX_V2();
789     ctx->boundTransformFeedback()->mIsPaused = false;
790     ctx->dispatcher().glResumeTransformFeedback();
791 }
792 
glIsTransformFeedback(GLuint id)793 GL_APICALL GLboolean GL_APIENTRY glIsTransformFeedback(GLuint id) {
794     GET_CTX_V2_RET(0);
795     return ctx->hasBoundTransformFeedback(id);
796 }
797 
glTransformFeedbackVaryings(GLuint program,GLsizei count,const char ** varyings,GLenum bufferMode)798 EXTERN_PART GL_APICALL void GL_APIENTRY glTransformFeedbackVaryings(GLuint program, GLsizei count, const char ** varyings, GLenum bufferMode) {
799     GET_CTX_V2();
800     if (ctx->shareGroup().get()) {
801         const GLuint globalProgramName = ctx->shareGroup()->getGlobalName(NamedObjectType::SHADER_OR_PROGRAM, program);
802         ctx->dispatcher().glTransformFeedbackVaryings(globalProgramName, count, varyings, bufferMode);
803     }
804 }
805 
glGetTransformFeedbackVarying(GLuint program,GLuint index,GLsizei bufSize,GLsizei * length,GLsizei * size,GLenum * type,char * name)806 GL_APICALL void GL_APIENTRY glGetTransformFeedbackVarying(GLuint program, GLuint index, GLsizei bufSize, GLsizei * length, GLsizei * size, GLenum * type, char * name) {
807     GET_CTX_V2();
808     if (ctx->shareGroup().get()) {
809         const GLuint globalProgramName = ctx->shareGroup()->getGlobalName(NamedObjectType::SHADER_OR_PROGRAM, program);
810         ctx->dispatcher().glGetTransformFeedbackVarying(globalProgramName, index, bufSize, length, size, type, name);
811     }
812 }
813 
glGenSamplers(GLsizei n,GLuint * samplers)814 GL_APICALL void GL_APIENTRY glGenSamplers(GLsizei n, GLuint * samplers) {
815     GET_CTX_V2();
816     SET_ERROR_IF(n < 0,GL_INVALID_VALUE);
817 
818     if(ctx->shareGroup().get()) {
819         for(int i=0; i<n ;i++) {
820             samplers[i] = ctx->shareGroup()->genName(NamedObjectType::SAMPLER,
821                                                      0, true);
822             ctx->shareGroup()->setObjectData(NamedObjectType::SAMPLER,
823                     samplers[i], ObjectDataPtr(new SamplerData()));
824         }
825     }
826 }
827 
glDeleteSamplers(GLsizei n,const GLuint * samplers)828 GL_APICALL void GL_APIENTRY glDeleteSamplers(GLsizei n, const GLuint * samplers) {
829     GET_CTX_V2();
830     SET_ERROR_IF(n < 0,GL_INVALID_VALUE);
831 
832     if(ctx->shareGroup().get()) {
833         for(int i=0; i<n ;i++) {
834             ctx->shareGroup()->deleteName(NamedObjectType::SAMPLER, samplers[i]);
835         }
836     }
837 }
838 
glBindSampler(GLuint unit,GLuint sampler)839 GL_APICALL void GL_APIENTRY glBindSampler(GLuint unit, GLuint sampler) {
840     GET_CTX_V2();
841     if (ctx->shareGroup().get()) {
842         const GLuint globalSampler = ctx->shareGroup()->getGlobalName(NamedObjectType::SAMPLER, sampler);
843         SET_ERROR_IF(sampler && !globalSampler, GL_INVALID_OPERATION);
844         ctx->setBindSampler(unit, sampler);
845         ctx->dispatcher().glBindSampler(unit, globalSampler);
846     }
847 }
848 
glSamplerParameterf(GLuint sampler,GLenum pname,GLfloat param)849 GL_APICALL void GL_APIENTRY glSamplerParameterf(GLuint sampler, GLenum pname, GLfloat param) {
850     GET_CTX_V2();
851     if (ctx->shareGroup().get()) {
852         const GLuint globalSampler = ctx->shareGroup()->getGlobalName(
853                 NamedObjectType::SAMPLER, sampler);
854         SET_ERROR_IF(!globalSampler, GL_INVALID_OPERATION);
855         SamplerData* samplerData = (SamplerData*)ctx->shareGroup()->getObjectData(
856                 NamedObjectType::SAMPLER, sampler);
857         samplerData->setParamf(pname, param);
858         ctx->dispatcher().glSamplerParameterf(globalSampler, pname, param);
859     }
860 }
861 
glSamplerParameteri(GLuint sampler,GLenum pname,GLint param)862 GL_APICALL void GL_APIENTRY glSamplerParameteri(GLuint sampler, GLenum pname, GLint param) {
863     GET_CTX_V2();
864     if (ctx->shareGroup().get()) {
865         const GLuint globalSampler = ctx->shareGroup()->getGlobalName(
866         NamedObjectType::SAMPLER, sampler);
867         SET_ERROR_IF(!globalSampler, GL_INVALID_OPERATION);
868         SamplerData* samplerData = (SamplerData*)ctx->shareGroup()->getObjectData(
869                 NamedObjectType::SAMPLER, sampler);
870         samplerData->setParami(pname, param);
871         ctx->dispatcher().glSamplerParameteri(globalSampler, pname, param);
872     }
873 }
874 
glSamplerParameterfv(GLuint sampler,GLenum pname,const GLfloat * params)875 GL_APICALL void GL_APIENTRY glSamplerParameterfv(GLuint sampler, GLenum pname, const GLfloat * params) {
876     GET_CTX_V2();
877     if (ctx->shareGroup().get()) {
878         const GLuint globalSampler = ctx->shareGroup()->getGlobalName(NamedObjectType::SAMPLER, sampler);
879         ctx->dispatcher().glSamplerParameterfv(globalSampler, pname, params);
880     }
881 }
882 
glSamplerParameteriv(GLuint sampler,GLenum pname,const GLint * params)883 GL_APICALL void GL_APIENTRY glSamplerParameteriv(GLuint sampler, GLenum pname, const GLint * params) {
884     GET_CTX_V2();
885     if (ctx->shareGroup().get()) {
886         const GLuint globalSampler = ctx->shareGroup()->getGlobalName(NamedObjectType::SAMPLER, sampler);
887         ctx->dispatcher().glSamplerParameteriv(globalSampler, pname, params);
888     }
889 }
890 
glGetSamplerParameterfv(GLuint sampler,GLenum pname,GLfloat * params)891 GL_APICALL void GL_APIENTRY glGetSamplerParameterfv(GLuint sampler, GLenum pname, GLfloat * params) {
892     GET_CTX_V2();
893     if (ctx->shareGroup().get()) {
894         const GLuint globalSampler = ctx->shareGroup()->getGlobalName(NamedObjectType::SAMPLER, sampler);
895         ctx->dispatcher().glGetSamplerParameterfv(globalSampler, pname, params);
896     }
897 }
898 
glGetSamplerParameteriv(GLuint sampler,GLenum pname,GLint * params)899 GL_APICALL void GL_APIENTRY glGetSamplerParameteriv(GLuint sampler, GLenum pname, GLint * params) {
900     GET_CTX_V2();
901     if (ctx->shareGroup().get()) {
902         const GLuint globalSampler = ctx->shareGroup()->getGlobalName(NamedObjectType::SAMPLER, sampler);
903         ctx->dispatcher().glGetSamplerParameteriv(globalSampler, pname, params);
904     }
905 }
906 
glIsSampler(GLuint sampler)907 GL_APICALL GLboolean GL_APIENTRY glIsSampler(GLuint sampler) {
908     GET_CTX_V2_RET(0);
909     if (ctx->shareGroup().get()) {
910         const GLuint globalSampler = ctx->shareGroup()->getGlobalName(NamedObjectType::SAMPLER, sampler);
911         GLboolean glIsSamplerRET = ctx->dispatcher().glIsSampler(globalSampler);
912     return glIsSamplerRET;
913     } else return 0;
914 }
915 
glGenQueries(GLsizei n,GLuint * queries)916 GL_APICALL void GL_APIENTRY glGenQueries(GLsizei n, GLuint * queries) {
917     GET_CTX_V2();
918     SET_ERROR_IF(n < 0,GL_INVALID_VALUE);
919 
920     if(ctx->shareGroup().get()) {
921         for(int i=0; i<n ;i++) {
922             queries[i] = ctx->shareGroup()->genName(NamedObjectType::QUERY,
923                                                      0, true);
924         }
925     }
926 }
927 
glDeleteQueries(GLsizei n,const GLuint * queries)928 GL_APICALL void GL_APIENTRY glDeleteQueries(GLsizei n, const GLuint * queries) {
929     GET_CTX_V2();
930     SET_ERROR_IF(n < 0,GL_INVALID_VALUE);
931 
932     if(ctx->shareGroup().get()) {
933         for(int i=0; i<n ;i++) {
934             ctx->shareGroup()->deleteName(NamedObjectType::QUERY, queries[i]);
935         }
936     }
937 }
938 
glBeginQuery(GLenum target,GLuint query)939 GL_APICALL void GL_APIENTRY glBeginQuery(GLenum target, GLuint query) {
940     GET_CTX_V2();
941     if (ctx->shareGroup().get()) {
942         const GLuint globalQuery = ctx->shareGroup()->getGlobalName(NamedObjectType::QUERY, query);
943         ctx->dispatcher().glBeginQuery(target, globalQuery);
944     }
945 }
946 
glEndQuery(GLenum target)947 GL_APICALL void GL_APIENTRY glEndQuery(GLenum target) {
948     GET_CTX_V2();
949     ctx->dispatcher().glEndQuery(target);
950 }
951 
glGetQueryiv(GLenum target,GLenum pname,GLint * params)952 GL_APICALL void GL_APIENTRY glGetQueryiv(GLenum target, GLenum pname, GLint * params) {
953     GET_CTX_V2();
954     ctx->dispatcher().glGetQueryiv(target, pname, params);
955 }
956 
glGetQueryObjectuiv(GLuint query,GLenum pname,GLuint * params)957 GL_APICALL void GL_APIENTRY glGetQueryObjectuiv(GLuint query, GLenum pname, GLuint * params) {
958     GET_CTX_V2();
959     if (ctx->shareGroup().get()) {
960         const GLuint globalQuery = ctx->shareGroup()->getGlobalName(NamedObjectType::QUERY, query);
961         ctx->dispatcher().glGetQueryObjectuiv(globalQuery, pname, params);
962     }
963 }
964 
glIsQuery(GLuint query)965 GL_APICALL GLboolean GL_APIENTRY glIsQuery(GLuint query) {
966     GET_CTX_V2_RET(0);
967     if (ctx->shareGroup().get()) {
968         const GLuint globalQuery = ctx->shareGroup()->getGlobalName(NamedObjectType::QUERY, query);
969         GLboolean glIsQueryRET = ctx->dispatcher().glIsQuery(globalQuery);
970     return glIsQueryRET;
971     } else return 0;
972 }
973 
glProgramParameteri(GLuint program,GLenum pname,GLint value)974 GL_APICALL void GL_APIENTRY glProgramParameteri(GLuint program, GLenum pname, GLint value) {
975     GET_CTX_V2();
976     if (ctx->shareGroup().get()) {
977         const GLuint globalProgramName = ctx->shareGroup()->getGlobalName(NamedObjectType::SHADER_OR_PROGRAM, program);
978         ctx->dispatcher().glProgramParameteri(globalProgramName, pname, value);
979     }
980 }
981 
glProgramBinary(GLuint program,GLenum binaryFormat,const void * binary,GLsizei length)982 GL_APICALL void GL_APIENTRY glProgramBinary(GLuint program, GLenum binaryFormat, const void * binary, GLsizei length) {
983     GET_CTX_V2();
984     if (ctx->shareGroup().get()) {
985         const GLuint globalProgramName = ctx->shareGroup()->getGlobalName(NamedObjectType::SHADER_OR_PROGRAM, program);
986         SET_ERROR_IF(globalProgramName == 0, GL_INVALID_VALUE);
987 
988         auto objData =
989             ctx->shareGroup()->getObjectData(NamedObjectType::SHADER_OR_PROGRAM, program);
990         SET_ERROR_IF(!objData, GL_INVALID_OPERATION);
991         SET_ERROR_IF(objData->getDataType() != PROGRAM_DATA, GL_INVALID_OPERATION);
992 
993         ProgramData* programData = (ProgramData*)objData;
994 
995         ctx->dispatcher().glProgramBinary(globalProgramName, binaryFormat, binary, length);
996 
997         GLint linkStatus = GL_FALSE;
998         ctx->dispatcher().glGetProgramiv(globalProgramName, GL_LINK_STATUS, &linkStatus);
999 
1000         programData->setHostLinkStatus(linkStatus);
1001         programData->setLinkStatus(linkStatus);
1002 
1003         GLsizei infoLogLength = 0;
1004         ctx->dispatcher().glGetProgramiv(globalProgramName, GL_INFO_LOG_LENGTH, &infoLogLength);
1005 
1006         if (infoLogLength > 0) {
1007             std::vector<GLchar> infoLog(infoLogLength);
1008             ctx->dispatcher().glGetProgramInfoLog(globalProgramName, infoLogLength, &infoLogLength,
1009                                                   infoLog.data());
1010 
1011             if (infoLogLength) {
1012                 infoLog.resize(infoLogLength);
1013                 programData->setInfoLog(infoLog.data());
1014             }
1015         }
1016     }
1017 }
1018 
glGetProgramBinary(GLuint program,GLsizei bufsize,GLsizei * length,GLenum * binaryFormat,void * binary)1019 GL_APICALL void GL_APIENTRY glGetProgramBinary(GLuint program, GLsizei bufsize, GLsizei * length, GLenum * binaryFormat, void * binary) {
1020     GET_CTX_V2();
1021     if (ctx->shareGroup().get()) {
1022         const GLuint globalProgramName = ctx->shareGroup()->getGlobalName(NamedObjectType::SHADER_OR_PROGRAM, program);
1023         ctx->dispatcher().glGetProgramBinary(globalProgramName, bufsize, length, binaryFormat, binary);
1024     }
1025 }
1026 
glGetFragDataLocation(GLuint program,const char * name)1027 GL_APICALL GLint GL_APIENTRY glGetFragDataLocation(GLuint program, const char * name) {
1028     GET_CTX_V2_RET(0);
1029     if (ctx->shareGroup().get()) {
1030         const GLuint globalProgramName = ctx->shareGroup()->getGlobalName(NamedObjectType::SHADER_OR_PROGRAM, program);
1031         GLint glGetFragDataLocationRET = ctx->dispatcher().glGetFragDataLocation(globalProgramName, name);
1032     return glGetFragDataLocationRET;
1033     } else return 0;
1034 }
1035 
glGetInteger64v(GLenum pname,GLint64 * data)1036 GL_APICALL void GL_APIENTRY glGetInteger64v(GLenum pname, GLint64 * data) {
1037     GET_CTX_V2();
1038     s_glStateQueryTv<GLint64>(true, pname, data, s_glGetInteger64v_wrapper);
1039 }
1040 
glGetIntegeri_v(GLenum target,GLuint index,GLint * data)1041 GL_APICALL void GL_APIENTRY glGetIntegeri_v(GLenum target, GLuint index, GLint * data) {
1042     GET_CTX_V2();
1043     s_glStateQueryTi_v<GLint>(target, index, data, s_glGetIntegeri_v_wrapper);
1044 }
1045 
glGetInteger64i_v(GLenum target,GLuint index,GLint64 * data)1046 GL_APICALL void GL_APIENTRY glGetInteger64i_v(GLenum target, GLuint index, GLint64 * data) {
1047     GET_CTX_V2();
1048     s_glStateQueryTi_v<GLint64>(target, index, data, s_glGetInteger64i_v_wrapper);
1049 }
1050 
glTexImage3D(GLenum target,GLint level,GLint internalFormat,GLsizei width,GLsizei height,GLsizei depth,GLint border,GLenum format,GLenum type,const GLvoid * data)1051 GL_APICALL void GL_APIENTRY glTexImage3D(GLenum target, GLint level, GLint internalFormat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const GLvoid * data) {
1052     GET_CTX_V2();
1053     SET_ERROR_IF(!GLESv2Validate::pixelItnlFrmt(ctx,internalFormat), GL_INVALID_VALUE);
1054     SET_ERROR_IF(!GLESv2Validate::isCompressedFormat(internalFormat) &&
1055                  !GLESv2Validate::pixelSizedFrmt(ctx, internalFormat, format, type),
1056                  GL_INVALID_OPERATION);
1057 
1058     s_glInitTexImage3D(target, level, internalFormat, width, height, depth,
1059             border, format, type);
1060     // Desktop OpenGL doesn't support GL_BGRA_EXT as internal format.
1061     if (!isGles2Gles() && type == GL_UNSIGNED_BYTE && format == GL_BGRA_EXT &&
1062         internalFormat == GL_BGRA_EXT) {
1063         internalFormat = GL_RGBA;
1064     }
1065 
1066     if (isCoreProfile()) {
1067         GLEScontext::prepareCoreProfileEmulatedTexture(
1068             getTextureTargetData(target),
1069             true, target, format, type,
1070             &internalFormat, &format);
1071     }
1072 
1073     ctx->dispatcher().glTexImage3D(target, level, internalFormat, width, height, depth, border, format, type, data);
1074 }
1075 
glTexStorage3D(GLenum target,GLsizei levels,GLenum internalformat,GLsizei width,GLsizei height,GLsizei depth)1076 GL_APICALL void GL_APIENTRY glTexStorage3D(GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth) {
1077     GET_CTX_V2();
1078     GLenum format, type;
1079     GLESv2Validate::getCompatibleFormatTypeForInternalFormat(internalformat, &format, &type);
1080     s_glInitTexImage3D(target, 0, internalformat, width, height, depth, 0,
1081             format, type);
1082     // Desktop OpenGL doesn't support GL_BGRA_EXT as internal format.
1083     if (!isGles2Gles() && type == GL_UNSIGNED_BYTE && format == GL_BGRA_EXT &&
1084         internalformat == GL_BGRA8_EXT) {
1085         internalformat = GL_RGBA8;
1086     }
1087     TextureData *texData = getTextureTargetData(target);
1088     texData->texStorageLevels = levels;
1089     ctx->dispatcher().glTexStorage3D(target, levels, internalformat, width, height, depth);
1090 }
1091 
glTexSubImage3D(GLenum target,GLint level,GLint xoffset,GLint yoffset,GLint zoffset,GLsizei width,GLsizei height,GLsizei depth,GLenum format,GLenum type,const GLvoid * data)1092 GL_APICALL void GL_APIENTRY glTexSubImage3D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const GLvoid * data) {
1093     GET_CTX_V2();
1094     if (isCoreProfile() &&
1095         isCoreProfileEmulatedFormat(format)) {
1096         format = getCoreProfileEmulatedFormat(format);
1097     }
1098     TextureData* texData = getTextureTargetData(target);
1099     if (texData) {
1100         texData->setMipmapLevelAtLeast(level);
1101         texData->makeDirty();
1102     }
1103     ctx->dispatcher().glTexSubImage3D(target, level, xoffset, yoffset, zoffset, width, height, depth, format, type, data);
1104 }
1105 
glCompressedTexImage3D(GLenum target,GLint level,GLenum internalformat,GLsizei width,GLsizei height,GLsizei depth,GLint border,GLsizei imageSize,const GLvoid * data)1106 GL_APICALL void GL_APIENTRY glCompressedTexImage3D(GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLsizei imageSize, const GLvoid * data) {
1107     GET_CTX_V2();
1108     ctx->dispatcher().glCompressedTexImage3D(target, level, internalformat, width, height, depth, border, imageSize, data);
1109     if (ctx->shareGroup().get()) {
1110         TextureData *texData = getTextureTargetData(target);
1111 
1112         if (texData) {
1113             texData->hasStorage = true;
1114             texData->compressed = true;
1115             texData->compressedFormat = internalformat;
1116             texData->makeDirty();
1117         }
1118     }
1119 }
1120 
glCompressedTexSubImage3D(GLenum target,GLint level,GLint xoffset,GLint yoffset,GLint zoffset,GLsizei width,GLsizei height,GLsizei depth,GLenum format,GLsizei imageSize,const GLvoid * data)1121 GL_APICALL void GL_APIENTRY glCompressedTexSubImage3D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const GLvoid * data) {
1122     GET_CTX_V2();
1123     TextureData* texData = getTextureTargetData(target);
1124     if (texData) {
1125         texData->makeDirty();
1126     }
1127     ctx->dispatcher().glCompressedTexSubImage3D(target, level, xoffset, yoffset, zoffset, width, height, depth, format, imageSize, data);
1128 }
1129 
glCopyTexSubImage3D(GLenum target,GLint level,GLint xoffset,GLint yoffset,GLint zoffset,GLint x,GLint y,GLsizei width,GLsizei height)1130 GL_APICALL void GL_APIENTRY glCopyTexSubImage3D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height) {
1131     GET_CTX_V2();
1132     TextureData* texData = getTextureTargetData(target);
1133     if (texData) {
1134         texData->makeDirty();
1135     }
1136     ctx->dispatcher().glCopyTexSubImage3D(target, level, xoffset, yoffset, zoffset, x, y, width, height);
1137 }
1138 
glEnableiEXT(GLenum cap,GLuint index)1139 GL_APICALL void GL_APIENTRY glEnableiEXT(GLenum cap, GLuint index)
1140 {
1141     GET_CTX_V2();
1142     SET_ERROR_IF(!ctx->getCaps()->ext_GL_EXT_draw_buffers_indexed, GL_INVALID_OPERATION);
1143     ctx->setEnablei(cap, index, true);
1144     ctx->dispatcher().glEnableiEXT(cap, index);
1145 }
glDisableiEXT(GLenum cap,GLuint index)1146 GL_APICALL void GL_APIENTRY glDisableiEXT(GLenum cap, GLuint index)
1147 {
1148     GET_CTX_V2();
1149     SET_ERROR_IF(!ctx->getCaps()->ext_GL_EXT_draw_buffers_indexed, GL_INVALID_OPERATION);
1150     ctx->setEnablei(cap, index, false);
1151     ctx->dispatcher().glDisableiEXT(cap, index);
1152 }
1153 
glBlendEquationiEXT(GLuint buf,GLenum mode)1154 GL_APICALL void GL_APIENTRY glBlendEquationiEXT(GLuint buf, GLenum mode)
1155 {
1156     GET_CTX_V2();
1157     SET_ERROR_IF(!ctx->getCaps()->ext_GL_EXT_draw_buffers_indexed, GL_INVALID_OPERATION);
1158     ctx->setBlendEquationSeparatei(buf, mode, mode);
1159     ctx->dispatcher().glBlendEquationiEXT(buf, mode);
1160 }
1161 
glBlendEquationSeparateiEXT(GLuint buf,GLenum modeRGB,GLenum modeAlpha)1162 GL_APICALL void GL_APIENTRY glBlendEquationSeparateiEXT(GLuint buf, GLenum modeRGB, GLenum modeAlpha)
1163 {
1164     GET_CTX_V2();
1165     SET_ERROR_IF(!ctx->getCaps()->ext_GL_EXT_draw_buffers_indexed, GL_INVALID_OPERATION);
1166     ctx->setBlendEquationSeparatei(buf, modeRGB, modeAlpha);
1167     ctx->dispatcher().glBlendEquationSeparateiEXT(buf, modeRGB, modeAlpha);
1168 }
1169 
glBlendFunciEXT(GLuint buf,GLenum sfactor,GLenum dfactor)1170 GL_APICALL void GL_APIENTRY glBlendFunciEXT(GLuint buf, GLenum sfactor, GLenum dfactor)
1171 {
1172     GET_CTX_V2();
1173     SET_ERROR_IF(!ctx->getCaps()->ext_GL_EXT_draw_buffers_indexed, GL_INVALID_OPERATION);
1174     ctx->setBlendFuncSeparatei(buf, sfactor, dfactor, sfactor, dfactor);
1175     ctx->dispatcher().glBlendFunciEXT(buf, sfactor, dfactor);
1176 }
1177 
glBlendFuncSeparateiEXT(GLuint buf,GLenum srcRGB,GLenum dstRGB,GLenum srcAlpha,GLenum dstAlpha)1178 GL_APICALL void GL_APIENTRY glBlendFuncSeparateiEXT(GLuint buf, GLenum srcRGB, GLenum dstRGB, GLenum srcAlpha, GLenum dstAlpha)
1179 {
1180     GET_CTX_V2();
1181     SET_ERROR_IF(!ctx->getCaps()->ext_GL_EXT_draw_buffers_indexed, GL_INVALID_OPERATION);
1182     ctx->setBlendFuncSeparatei(buf, srcRGB, dstRGB, srcAlpha, dstAlpha);
1183     ctx->dispatcher().glBlendFuncSeparateiEXT(buf, srcRGB, dstRGB, srcAlpha, dstAlpha);
1184 }
1185 
glColorMaskiEXT(GLuint buf,GLboolean red,GLboolean green,GLboolean blue,GLboolean alpha)1186 GL_APICALL void GL_APIENTRY glColorMaskiEXT(GLuint buf, GLboolean red, GLboolean green,
1187     GLboolean blue, GLboolean alpha)
1188 {
1189     GET_CTX_V2();
1190     SET_ERROR_IF(!ctx->getCaps()->ext_GL_EXT_draw_buffers_indexed, GL_INVALID_OPERATION);
1191     ctx->setColorMaski(buf, red, green, blue, alpha);
1192     ctx->dispatcher().glColorMaskiEXT(buf, red, green, blue, alpha);
1193 }
1194 
glIsEnablediEXT(GLenum cap,GLuint index)1195 GL_APICALL GLboolean GL_APIENTRY glIsEnablediEXT(GLenum cap, GLuint index) {
1196     GET_CTX_RET(GL_FALSE);
1197     return ctx->dispatcher().glIsEnablediEXT(cap, index);
1198 }
1199 
1200