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