1 //
2 // Copyright 2019 The ANGLE Project Authors. All rights reserved.
3 // Use of this source code is governed by a BSD-style license that can be
4 // found in the LICENSE file.
5 //
6 // capture_gles2_params.cpp:
7 // Pointer parameter capture functions for the OpenGL ES 2.0 entry points.
8
9 #include "libANGLE/capture_gles_2_0_autogen.h"
10
11 #include "libANGLE/Context.h"
12 #include "libANGLE/Shader.h"
13 #include "libANGLE/formatutils.h"
14
15 using namespace angle;
16
17 namespace gl
18 {
19 // Parameter Captures
20
CaptureBindAttribLocation_name(const State & glState,bool isCallValid,ShaderProgramID program,GLuint index,const GLchar * name,ParamCapture * paramCapture)21 void CaptureBindAttribLocation_name(const State &glState,
22 bool isCallValid,
23 ShaderProgramID program,
24 GLuint index,
25 const GLchar *name,
26 ParamCapture *paramCapture)
27 {
28 CaptureString(name, paramCapture);
29 }
30
CaptureBufferData_data(const State & glState,bool isCallValid,BufferBinding targetPacked,GLsizeiptr size,const void * data,BufferUsage usagePacked,ParamCapture * paramCapture)31 void CaptureBufferData_data(const State &glState,
32 bool isCallValid,
33 BufferBinding targetPacked,
34 GLsizeiptr size,
35 const void *data,
36 BufferUsage usagePacked,
37 ParamCapture *paramCapture)
38 {
39 if (data)
40 {
41 CaptureMemory(data, size, paramCapture);
42 }
43 }
44
CaptureBufferSubData_data(const State & glState,bool isCallValid,BufferBinding targetPacked,GLintptr offset,GLsizeiptr size,const void * data,ParamCapture * paramCapture)45 void CaptureBufferSubData_data(const State &glState,
46 bool isCallValid,
47 BufferBinding targetPacked,
48 GLintptr offset,
49 GLsizeiptr size,
50 const void *data,
51 ParamCapture *paramCapture)
52 {
53 CaptureMemory(data, size, paramCapture);
54 }
55
CaptureCompressedTexImage2D_data(const State & glState,bool isCallValid,TextureTarget targetPacked,GLint level,GLenum internalformat,GLsizei width,GLsizei height,GLint border,GLsizei imageSize,const void * data,ParamCapture * paramCapture)56 void CaptureCompressedTexImage2D_data(const State &glState,
57 bool isCallValid,
58 TextureTarget targetPacked,
59 GLint level,
60 GLenum internalformat,
61 GLsizei width,
62 GLsizei height,
63 GLint border,
64 GLsizei imageSize,
65 const void *data,
66 ParamCapture *paramCapture)
67 {
68 if (glState.getTargetBuffer(gl::BufferBinding::PixelUnpack))
69 {
70 return;
71 }
72
73 if (!data)
74 {
75 return;
76 }
77
78 CaptureMemory(data, imageSize, paramCapture);
79 }
80
CaptureCompressedTexSubImage2D_data(const State & glState,bool isCallValid,TextureTarget targetPacked,GLint level,GLint xoffset,GLint yoffset,GLsizei width,GLsizei height,GLenum format,GLsizei imageSize,const void * data,ParamCapture * paramCapture)81 void CaptureCompressedTexSubImage2D_data(const State &glState,
82 bool isCallValid,
83 TextureTarget targetPacked,
84 GLint level,
85 GLint xoffset,
86 GLint yoffset,
87 GLsizei width,
88 GLsizei height,
89 GLenum format,
90 GLsizei imageSize,
91 const void *data,
92 ParamCapture *paramCapture)
93 {
94 CaptureCompressedTexImage2D_data(glState, isCallValid, targetPacked, level, 0, width, height, 0,
95 imageSize, data, paramCapture);
96 }
97
CaptureDeleteBuffers_buffersPacked(const State & glState,bool isCallValid,GLsizei n,const BufferID * buffers,ParamCapture * paramCapture)98 void CaptureDeleteBuffers_buffersPacked(const State &glState,
99 bool isCallValid,
100 GLsizei n,
101 const BufferID *buffers,
102 ParamCapture *paramCapture)
103 {
104 CaptureMemory(buffers, sizeof(BufferID) * n, paramCapture);
105 }
106
CaptureDeleteFramebuffers_framebuffersPacked(const State & glState,bool isCallValid,GLsizei n,const FramebufferID * framebuffers,ParamCapture * paramCapture)107 void CaptureDeleteFramebuffers_framebuffersPacked(const State &glState,
108 bool isCallValid,
109 GLsizei n,
110 const FramebufferID *framebuffers,
111 ParamCapture *paramCapture)
112 {
113 CaptureMemory(framebuffers, sizeof(FramebufferID) * n, paramCapture);
114 }
115
CaptureDeleteRenderbuffers_renderbuffersPacked(const State & glState,bool isCallValid,GLsizei n,const RenderbufferID * renderbuffers,ParamCapture * paramCapture)116 void CaptureDeleteRenderbuffers_renderbuffersPacked(const State &glState,
117 bool isCallValid,
118 GLsizei n,
119 const RenderbufferID *renderbuffers,
120 ParamCapture *paramCapture)
121 {
122 CaptureMemory(renderbuffers, sizeof(RenderbufferID) * n, paramCapture);
123 }
124
CaptureDeleteTextures_texturesPacked(const State & glState,bool isCallValid,GLsizei n,const TextureID * textures,ParamCapture * paramCapture)125 void CaptureDeleteTextures_texturesPacked(const State &glState,
126 bool isCallValid,
127 GLsizei n,
128 const TextureID *textures,
129 ParamCapture *paramCapture)
130 {
131 CaptureMemory(textures, sizeof(TextureID) * n, paramCapture);
132 }
133
CaptureDrawElements_indices(const State & glState,bool isCallValid,PrimitiveMode modePacked,GLsizei count,DrawElementsType typePacked,const void * indices,ParamCapture * paramCapture)134 void CaptureDrawElements_indices(const State &glState,
135 bool isCallValid,
136 PrimitiveMode modePacked,
137 GLsizei count,
138 DrawElementsType typePacked,
139 const void *indices,
140 ParamCapture *paramCapture)
141 {
142 if (glState.getVertexArray()->getElementArrayBuffer())
143 {
144 paramCapture->value.voidConstPointerVal = indices;
145 }
146 else
147 {
148 GLuint typeSize = gl::GetDrawElementsTypeSize(typePacked);
149 CaptureMemory(indices, typeSize * count, paramCapture);
150 paramCapture->value.voidConstPointerVal = paramCapture->data[0].data();
151 }
152 }
153
CaptureGenBuffers_buffersPacked(const State & glState,bool isCallValid,GLsizei n,BufferID * buffers,ParamCapture * paramCapture)154 void CaptureGenBuffers_buffersPacked(const State &glState,
155 bool isCallValid,
156 GLsizei n,
157 BufferID *buffers,
158 ParamCapture *paramCapture)
159 {
160 CaptureGenHandles(n, buffers, paramCapture);
161 }
162
CaptureGenFramebuffers_framebuffersPacked(const State & glState,bool isCallValid,GLsizei n,FramebufferID * framebuffers,ParamCapture * paramCapture)163 void CaptureGenFramebuffers_framebuffersPacked(const State &glState,
164 bool isCallValid,
165 GLsizei n,
166 FramebufferID *framebuffers,
167 ParamCapture *paramCapture)
168 {
169 CaptureGenHandles(n, framebuffers, paramCapture);
170 }
171
CaptureGenRenderbuffers_renderbuffersPacked(const State & glState,bool isCallValid,GLsizei n,RenderbufferID * renderbuffers,ParamCapture * paramCapture)172 void CaptureGenRenderbuffers_renderbuffersPacked(const State &glState,
173 bool isCallValid,
174 GLsizei n,
175 RenderbufferID *renderbuffers,
176 ParamCapture *paramCapture)
177 {
178 CaptureGenHandles(n, renderbuffers, paramCapture);
179 }
180
CaptureGenTextures_texturesPacked(const State & glState,bool isCallValid,GLsizei n,TextureID * textures,ParamCapture * paramCapture)181 void CaptureGenTextures_texturesPacked(const State &glState,
182 bool isCallValid,
183 GLsizei n,
184 TextureID *textures,
185 ParamCapture *paramCapture)
186 {
187 CaptureGenHandles(n, textures, paramCapture);
188 }
189
CaptureGetActiveAttrib_length(const State & glState,bool isCallValid,ShaderProgramID program,GLuint index,GLsizei bufSize,GLsizei * length,GLint * size,GLenum * type,GLchar * name,ParamCapture * paramCapture)190 void CaptureGetActiveAttrib_length(const State &glState,
191 bool isCallValid,
192 ShaderProgramID program,
193 GLuint index,
194 GLsizei bufSize,
195 GLsizei *length,
196 GLint *size,
197 GLenum *type,
198 GLchar *name,
199 ParamCapture *paramCapture)
200 {
201 UNIMPLEMENTED();
202 }
203
CaptureGetActiveAttrib_size(const State & glState,bool isCallValid,ShaderProgramID program,GLuint index,GLsizei bufSize,GLsizei * length,GLint * size,GLenum * type,GLchar * name,ParamCapture * paramCapture)204 void CaptureGetActiveAttrib_size(const State &glState,
205 bool isCallValid,
206 ShaderProgramID program,
207 GLuint index,
208 GLsizei bufSize,
209 GLsizei *length,
210 GLint *size,
211 GLenum *type,
212 GLchar *name,
213 ParamCapture *paramCapture)
214 {
215 UNIMPLEMENTED();
216 }
217
CaptureGetActiveAttrib_type(const State & glState,bool isCallValid,ShaderProgramID program,GLuint index,GLsizei bufSize,GLsizei * length,GLint * size,GLenum * type,GLchar * name,ParamCapture * paramCapture)218 void CaptureGetActiveAttrib_type(const State &glState,
219 bool isCallValid,
220 ShaderProgramID program,
221 GLuint index,
222 GLsizei bufSize,
223 GLsizei *length,
224 GLint *size,
225 GLenum *type,
226 GLchar *name,
227 ParamCapture *paramCapture)
228 {
229 UNIMPLEMENTED();
230 }
231
CaptureGetActiveAttrib_name(const State & glState,bool isCallValid,ShaderProgramID program,GLuint index,GLsizei bufSize,GLsizei * length,GLint * size,GLenum * type,GLchar * name,ParamCapture * paramCapture)232 void CaptureGetActiveAttrib_name(const State &glState,
233 bool isCallValid,
234 ShaderProgramID program,
235 GLuint index,
236 GLsizei bufSize,
237 GLsizei *length,
238 GLint *size,
239 GLenum *type,
240 GLchar *name,
241 ParamCapture *paramCapture)
242 {
243 CaptureStringLimit(name, bufSize, paramCapture);
244 }
245
CaptureGetActiveUniform_length(const State & glState,bool isCallValid,ShaderProgramID program,GLuint index,GLsizei bufSize,GLsizei * length,GLint * size,GLenum * type,GLchar * name,ParamCapture * paramCapture)246 void CaptureGetActiveUniform_length(const State &glState,
247 bool isCallValid,
248 ShaderProgramID program,
249 GLuint index,
250 GLsizei bufSize,
251 GLsizei *length,
252 GLint *size,
253 GLenum *type,
254 GLchar *name,
255 ParamCapture *paramCapture)
256 {
257 paramCapture->readBufferSizeBytes = sizeof(GLsizei);
258 }
259
CaptureGetActiveUniform_size(const State & glState,bool isCallValid,ShaderProgramID program,GLuint index,GLsizei bufSize,GLsizei * length,GLint * size,GLenum * type,GLchar * name,ParamCapture * paramCapture)260 void CaptureGetActiveUniform_size(const State &glState,
261 bool isCallValid,
262 ShaderProgramID program,
263 GLuint index,
264 GLsizei bufSize,
265 GLsizei *length,
266 GLint *size,
267 GLenum *type,
268 GLchar *name,
269 ParamCapture *paramCapture)
270 {
271 paramCapture->readBufferSizeBytes = sizeof(GLint);
272 }
273
CaptureGetActiveUniform_type(const State & glState,bool isCallValid,ShaderProgramID program,GLuint index,GLsizei bufSize,GLsizei * length,GLint * size,GLenum * type,GLchar * name,ParamCapture * paramCapture)274 void CaptureGetActiveUniform_type(const State &glState,
275 bool isCallValid,
276 ShaderProgramID program,
277 GLuint index,
278 GLsizei bufSize,
279 GLsizei *length,
280 GLint *size,
281 GLenum *type,
282 GLchar *name,
283 ParamCapture *paramCapture)
284 {
285 paramCapture->readBufferSizeBytes = sizeof(GLenum);
286 }
287
CaptureGetActiveUniform_name(const State & glState,bool isCallValid,ShaderProgramID program,GLuint index,GLsizei bufSize,GLsizei * length,GLint * size,GLenum * type,GLchar * name,ParamCapture * paramCapture)288 void CaptureGetActiveUniform_name(const State &glState,
289 bool isCallValid,
290 ShaderProgramID program,
291 GLuint index,
292 GLsizei bufSize,
293 GLsizei *length,
294 GLint *size,
295 GLenum *type,
296 GLchar *name,
297 ParamCapture *paramCapture)
298 {
299 CaptureStringLimit(name, bufSize, paramCapture);
300 }
301
CaptureGetAttachedShaders_count(const State & glState,bool isCallValid,ShaderProgramID program,GLsizei maxCount,GLsizei * count,ShaderProgramID * shaders,ParamCapture * paramCapture)302 void CaptureGetAttachedShaders_count(const State &glState,
303 bool isCallValid,
304 ShaderProgramID program,
305 GLsizei maxCount,
306 GLsizei *count,
307 ShaderProgramID *shaders,
308 ParamCapture *paramCapture)
309 {
310 UNIMPLEMENTED();
311 }
312
CaptureGetAttachedShaders_shadersPacked(const State & glState,bool isCallValid,ShaderProgramID program,GLsizei maxCount,GLsizei * count,ShaderProgramID * shaders,ParamCapture * paramCapture)313 void CaptureGetAttachedShaders_shadersPacked(const State &glState,
314 bool isCallValid,
315 ShaderProgramID program,
316 GLsizei maxCount,
317 GLsizei *count,
318 ShaderProgramID *shaders,
319 ParamCapture *paramCapture)
320 {
321 UNIMPLEMENTED();
322 }
323
CaptureGetAttribLocation_name(const State & glState,bool isCallValid,ShaderProgramID program,const GLchar * name,ParamCapture * paramCapture)324 void CaptureGetAttribLocation_name(const State &glState,
325 bool isCallValid,
326 ShaderProgramID program,
327 const GLchar *name,
328 ParamCapture *paramCapture)
329 {
330 CaptureString(name, paramCapture);
331 }
332
CaptureGetBooleanv_data(const State & glState,bool isCallValid,GLenum pname,GLboolean * data,ParamCapture * paramCapture)333 void CaptureGetBooleanv_data(const State &glState,
334 bool isCallValid,
335 GLenum pname,
336 GLboolean *data,
337 ParamCapture *paramCapture)
338 {
339 CaptureGetParameter(glState, pname, sizeof(GLboolean), paramCapture);
340 }
341
CaptureGetBufferParameteriv_params(const State & glState,bool isCallValid,BufferBinding targetPacked,GLenum pname,GLint * params,ParamCapture * paramCapture)342 void CaptureGetBufferParameteriv_params(const State &glState,
343 bool isCallValid,
344 BufferBinding targetPacked,
345 GLenum pname,
346 GLint *params,
347 ParamCapture *paramCapture)
348 {
349 UNIMPLEMENTED();
350 }
351
CaptureGetFloatv_data(const State & glState,bool isCallValid,GLenum pname,GLfloat * data,ParamCapture * paramCapture)352 void CaptureGetFloatv_data(const State &glState,
353 bool isCallValid,
354 GLenum pname,
355 GLfloat *data,
356 ParamCapture *paramCapture)
357 {
358 CaptureGetParameter(glState, pname, sizeof(GLfloat), paramCapture);
359 }
360
CaptureGetFramebufferAttachmentParameteriv_params(const State & glState,bool isCallValid,GLenum target,GLenum attachment,GLenum pname,GLint * params,ParamCapture * paramCapture)361 void CaptureGetFramebufferAttachmentParameteriv_params(const State &glState,
362 bool isCallValid,
363 GLenum target,
364 GLenum attachment,
365 GLenum pname,
366 GLint *params,
367 ParamCapture *paramCapture)
368 {
369 // All ES 2.0 queries only return one value.
370 paramCapture->readBufferSizeBytes = sizeof(GLint);
371 }
372
CaptureGetIntegerv_data(const State & glState,bool isCallValid,GLenum pname,GLint * data,ParamCapture * paramCapture)373 void CaptureGetIntegerv_data(const State &glState,
374 bool isCallValid,
375 GLenum pname,
376 GLint *data,
377 ParamCapture *paramCapture)
378 {
379 CaptureGetParameter(glState, pname, sizeof(GLint), paramCapture);
380 }
381
CaptureGetProgramInfoLog_length(const State & glState,bool isCallValid,ShaderProgramID program,GLsizei bufSize,GLsizei * length,GLchar * infoLog,ParamCapture * paramCapture)382 void CaptureGetProgramInfoLog_length(const State &glState,
383 bool isCallValid,
384 ShaderProgramID program,
385 GLsizei bufSize,
386 GLsizei *length,
387 GLchar *infoLog,
388 ParamCapture *paramCapture)
389 {
390 paramCapture->readBufferSizeBytes = sizeof(GLsizei);
391 }
392
CaptureGetProgramInfoLog_infoLog(const State & glState,bool isCallValid,ShaderProgramID program,GLsizei bufSize,GLsizei * length,GLchar * infoLog,ParamCapture * paramCapture)393 void CaptureGetProgramInfoLog_infoLog(const State &glState,
394 bool isCallValid,
395 ShaderProgramID program,
396 GLsizei bufSize,
397 GLsizei *length,
398 GLchar *infoLog,
399 ParamCapture *paramCapture)
400 {
401 gl::Program *programObj = GetLinkedProgramForCapture(glState, program);
402 ASSERT(programObj);
403 paramCapture->readBufferSizeBytes = programObj->getExecutable().getInfoLogLength() + 1;
404 }
405
CaptureGetProgramiv_params(const State & glState,bool isCallValid,ShaderProgramID program,GLenum pname,GLint * params,ParamCapture * paramCapture)406 void CaptureGetProgramiv_params(const State &glState,
407 bool isCallValid,
408 ShaderProgramID program,
409 GLenum pname,
410 GLint *params,
411 ParamCapture *paramCapture)
412 {
413 if (params)
414 {
415 paramCapture->readBufferSizeBytes = sizeof(GLint);
416 }
417 }
418
CaptureGetRenderbufferParameteriv_params(const State & glState,bool isCallValid,GLenum target,GLenum pname,GLint * params,ParamCapture * paramCapture)419 void CaptureGetRenderbufferParameteriv_params(const State &glState,
420 bool isCallValid,
421 GLenum target,
422 GLenum pname,
423 GLint *params,
424 ParamCapture *paramCapture)
425 {
426 UNIMPLEMENTED();
427 }
428
CaptureGetShaderInfoLog_length(const State & glState,bool isCallValid,ShaderProgramID shader,GLsizei bufSize,GLsizei * length,GLchar * infoLog,ParamCapture * paramCapture)429 void CaptureGetShaderInfoLog_length(const State &glState,
430 bool isCallValid,
431 ShaderProgramID shader,
432 GLsizei bufSize,
433 GLsizei *length,
434 GLchar *infoLog,
435 ParamCapture *paramCapture)
436 {
437 paramCapture->readBufferSizeBytes = sizeof(GLsizei);
438 }
439
CaptureGetShaderInfoLog_infoLog(const State & glState,bool isCallValid,ShaderProgramID shader,GLsizei bufSize,GLsizei * length,GLchar * infoLog,ParamCapture * paramCapture)440 void CaptureGetShaderInfoLog_infoLog(const State &glState,
441 bool isCallValid,
442 ShaderProgramID shader,
443 GLsizei bufSize,
444 GLsizei *length,
445 GLchar *infoLog,
446 ParamCapture *paramCapture)
447 {
448 gl::Shader *shaderObj = glState.getShaderProgramManagerForCapture().getShader(shader);
449 ASSERT(shaderObj && shaderObj->isCompiled());
450 paramCapture->readBufferSizeBytes = shaderObj->getInfoLogLength() + 1;
451 }
452
CaptureGetShaderPrecisionFormat_range(const State & glState,bool isCallValid,GLenum shadertype,GLenum precisiontype,GLint * range,GLint * precision,ParamCapture * paramCapture)453 void CaptureGetShaderPrecisionFormat_range(const State &glState,
454 bool isCallValid,
455 GLenum shadertype,
456 GLenum precisiontype,
457 GLint *range,
458 GLint *precision,
459 ParamCapture *paramCapture)
460 {
461 // range specifies a pointer to two-element array containing log2 of min and max
462 paramCapture->readBufferSizeBytes = 2 * sizeof(GLint);
463 }
464
CaptureGetShaderPrecisionFormat_precision(const State & glState,bool isCallValid,GLenum shadertype,GLenum precisiontype,GLint * range,GLint * precision,ParamCapture * paramCapture)465 void CaptureGetShaderPrecisionFormat_precision(const State &glState,
466 bool isCallValid,
467 GLenum shadertype,
468 GLenum precisiontype,
469 GLint *range,
470 GLint *precision,
471 ParamCapture *paramCapture)
472 {
473 paramCapture->readBufferSizeBytes = sizeof(GLint);
474 }
475
CaptureGetShaderSource_length(const State & glState,bool isCallValid,ShaderProgramID shader,GLsizei bufSize,GLsizei * length,GLchar * source,ParamCapture * paramCapture)476 void CaptureGetShaderSource_length(const State &glState,
477 bool isCallValid,
478 ShaderProgramID shader,
479 GLsizei bufSize,
480 GLsizei *length,
481 GLchar *source,
482 ParamCapture *paramCapture)
483 {
484 UNIMPLEMENTED();
485 }
486
CaptureGetShaderSource_source(const State & glState,bool isCallValid,ShaderProgramID shader,GLsizei bufSize,GLsizei * length,GLchar * source,ParamCapture * paramCapture)487 void CaptureGetShaderSource_source(const State &glState,
488 bool isCallValid,
489 ShaderProgramID shader,
490 GLsizei bufSize,
491 GLsizei *length,
492 GLchar *source,
493 ParamCapture *paramCapture)
494 {
495 UNIMPLEMENTED();
496 }
497
CaptureGetShaderiv_params(const State & glState,bool isCallValid,ShaderProgramID shader,GLenum pname,GLint * params,ParamCapture * paramCapture)498 void CaptureGetShaderiv_params(const State &glState,
499 bool isCallValid,
500 ShaderProgramID shader,
501 GLenum pname,
502 GLint *params,
503 ParamCapture *paramCapture)
504 {
505 if (params)
506 {
507 paramCapture->readBufferSizeBytes = sizeof(GLint);
508 }
509 }
510
CaptureGetTexParameterfv_params(const State & glState,bool isCallValid,TextureType targetPacked,GLenum pname,GLfloat * params,ParamCapture * paramCapture)511 void CaptureGetTexParameterfv_params(const State &glState,
512 bool isCallValid,
513 TextureType targetPacked,
514 GLenum pname,
515 GLfloat *params,
516 ParamCapture *paramCapture)
517 {
518 UNIMPLEMENTED();
519 }
520
CaptureGetTexParameteriv_params(const State & glState,bool isCallValid,TextureType targetPacked,GLenum pname,GLint * params,ParamCapture * paramCapture)521 void CaptureGetTexParameteriv_params(const State &glState,
522 bool isCallValid,
523 TextureType targetPacked,
524 GLenum pname,
525 GLint *params,
526 ParamCapture *paramCapture)
527 {
528 if (params)
529 {
530 paramCapture->readBufferSizeBytes = sizeof(GLint);
531 }
532 }
533
CaptureGetUniformLocation_name(const State & glState,bool isCallValid,ShaderProgramID program,const GLchar * name,ParamCapture * paramCapture)534 void CaptureGetUniformLocation_name(const State &glState,
535 bool isCallValid,
536 ShaderProgramID program,
537 const GLchar *name,
538 ParamCapture *paramCapture)
539 {
540 CaptureString(name, paramCapture);
541 }
542
CaptureGetUniformfv_params(const State & glState,bool isCallValid,ShaderProgramID program,UniformLocation location,GLfloat * params,ParamCapture * paramCapture)543 void CaptureGetUniformfv_params(const State &glState,
544 bool isCallValid,
545 ShaderProgramID program,
546 UniformLocation location,
547 GLfloat *params,
548 ParamCapture *paramCapture)
549 {
550 UNIMPLEMENTED();
551 }
552
CaptureGetUniformiv_params(const State & glState,bool isCallValid,ShaderProgramID program,UniformLocation location,GLint * params,ParamCapture * paramCapture)553 void CaptureGetUniformiv_params(const State &glState,
554 bool isCallValid,
555 ShaderProgramID program,
556 UniformLocation location,
557 GLint *params,
558 ParamCapture *paramCapture)
559 {
560 UNIMPLEMENTED();
561 }
562
CaptureGetVertexAttribPointerv_pointer(const State & glState,bool isCallValid,GLuint index,GLenum pname,void ** pointer,ParamCapture * paramCapture)563 void CaptureGetVertexAttribPointerv_pointer(const State &glState,
564 bool isCallValid,
565 GLuint index,
566 GLenum pname,
567 void **pointer,
568 ParamCapture *paramCapture)
569 {
570 paramCapture->readBufferSizeBytes = sizeof(void *);
571 }
572
CaptureGetVertexAttribfv_params(const State & glState,bool isCallValid,GLuint index,GLenum pname,GLfloat * params,ParamCapture * paramCapture)573 void CaptureGetVertexAttribfv_params(const State &glState,
574 bool isCallValid,
575 GLuint index,
576 GLenum pname,
577 GLfloat *params,
578 ParamCapture *paramCapture)
579 {
580 // Can be up to 4 current state values.
581 paramCapture->readBufferSizeBytes = sizeof(GLfloat) * 4;
582 }
583
CaptureGetVertexAttribiv_params(const State & glState,bool isCallValid,GLuint index,GLenum pname,GLint * params,ParamCapture * paramCapture)584 void CaptureGetVertexAttribiv_params(const State &glState,
585 bool isCallValid,
586 GLuint index,
587 GLenum pname,
588 GLint *params,
589 ParamCapture *paramCapture)
590 {
591 // Can be up to 4 current state values.
592 paramCapture->readBufferSizeBytes = sizeof(GLint) * 4;
593 }
594
CaptureReadPixels_pixels(const State & glState,bool isCallValid,GLint x,GLint y,GLsizei width,GLsizei height,GLenum format,GLenum type,void * pixels,ParamCapture * paramCapture)595 void CaptureReadPixels_pixels(const State &glState,
596 bool isCallValid,
597 GLint x,
598 GLint y,
599 GLsizei width,
600 GLsizei height,
601 GLenum format,
602 GLenum type,
603 void *pixels,
604 ParamCapture *paramCapture)
605 {
606 // Use a conservative upper bound instead of an exact size to be simple.
607 static constexpr GLsizei kMaxPixelSize = 32;
608 paramCapture->readBufferSizeBytes = kMaxPixelSize * width * height;
609 }
610
CaptureShaderBinary_shadersPacked(const State & glState,bool isCallValid,GLsizei count,const ShaderProgramID * shaders,GLenum binaryformat,const void * binary,GLsizei length,ParamCapture * paramCapture)611 void CaptureShaderBinary_shadersPacked(const State &glState,
612 bool isCallValid,
613 GLsizei count,
614 const ShaderProgramID *shaders,
615 GLenum binaryformat,
616 const void *binary,
617 GLsizei length,
618 ParamCapture *paramCapture)
619 {
620 UNIMPLEMENTED();
621 }
622
CaptureShaderBinary_binary(const State & glState,bool isCallValid,GLsizei count,const ShaderProgramID * shaders,GLenum binaryformat,const void * binary,GLsizei length,ParamCapture * paramCapture)623 void CaptureShaderBinary_binary(const State &glState,
624 bool isCallValid,
625 GLsizei count,
626 const ShaderProgramID *shaders,
627 GLenum binaryformat,
628 const void *binary,
629 GLsizei length,
630 ParamCapture *paramCapture)
631 {
632 UNIMPLEMENTED();
633 }
634
CaptureShaderSource_string(const State & glState,bool isCallValid,ShaderProgramID shader,GLsizei count,const GLchar * const * string,const GLint * length,ParamCapture * paramCapture)635 void CaptureShaderSource_string(const State &glState,
636 bool isCallValid,
637 ShaderProgramID shader,
638 GLsizei count,
639 const GLchar *const *string,
640 const GLint *length,
641 ParamCapture *paramCapture)
642 {
643 for (GLsizei index = 0; index < count; ++index)
644 {
645 size_t len = ((length && length[index] >= 0) ? length[index] : strlen(string[index]));
646 // includes the '\0' suffix
647 std::vector<uint8_t> data(len + 1, 0);
648 memcpy(data.data(), string[index], len);
649 paramCapture->data.emplace_back(std::move(data));
650 }
651 }
652
CaptureShaderSource_length(const State & glState,bool isCallValid,ShaderProgramID shader,GLsizei count,const GLchar * const * string,const GLint * length,ParamCapture * paramCapture)653 void CaptureShaderSource_length(const State &glState,
654 bool isCallValid,
655 ShaderProgramID shader,
656 GLsizei count,
657 const GLchar *const *string,
658 const GLint *length,
659 ParamCapture *paramCapture)
660 {
661 if (!length)
662 return;
663
664 for (GLsizei index = 0; index < count; ++index)
665 {
666 CaptureMemory(&length[index], sizeof(GLint), paramCapture);
667 }
668 }
669
CaptureTexImage2D_pixels(const State & glState,bool isCallValid,TextureTarget targetPacked,GLint level,GLint internalformat,GLsizei width,GLsizei height,GLint border,GLenum format,GLenum type,const void * pixels,ParamCapture * paramCapture)670 void CaptureTexImage2D_pixels(const State &glState,
671 bool isCallValid,
672 TextureTarget targetPacked,
673 GLint level,
674 GLint internalformat,
675 GLsizei width,
676 GLsizei height,
677 GLint border,
678 GLenum format,
679 GLenum type,
680 const void *pixels,
681 ParamCapture *paramCapture)
682 {
683 if (glState.getTargetBuffer(gl::BufferBinding::PixelUnpack))
684 {
685 return;
686 }
687
688 if (!pixels)
689 {
690 return;
691 }
692
693 const gl::InternalFormat &internalFormatInfo = gl::GetInternalFormatInfo(format, type);
694 const gl::PixelUnpackState &unpack = glState.getUnpackState();
695
696 GLuint srcRowPitch = 0;
697 (void)internalFormatInfo.computeRowPitch(type, width, unpack.alignment, unpack.rowLength,
698 &srcRowPitch);
699 GLuint srcDepthPitch = 0;
700 (void)internalFormatInfo.computeDepthPitch(height, unpack.imageHeight, srcRowPitch,
701 &srcDepthPitch);
702 GLuint srcSkipBytes = 0;
703 (void)internalFormatInfo.computeSkipBytes(type, srcRowPitch, srcDepthPitch, unpack, false,
704 &srcSkipBytes);
705
706 size_t captureSize = srcRowPitch * height + srcSkipBytes;
707 CaptureMemory(pixels, captureSize, paramCapture);
708 }
709
CaptureTexParameterfv_params(const State & glState,bool isCallValid,TextureType targetPacked,GLenum pname,const GLfloat * params,ParamCapture * paramCapture)710 void CaptureTexParameterfv_params(const State &glState,
711 bool isCallValid,
712 TextureType targetPacked,
713 GLenum pname,
714 const GLfloat *params,
715 ParamCapture *paramCapture)
716 {
717 UNIMPLEMENTED();
718 }
719
CaptureTexParameteriv_params(const State & glState,bool isCallValid,TextureType targetPacked,GLenum pname,const GLint * params,ParamCapture * paramCapture)720 void CaptureTexParameteriv_params(const State &glState,
721 bool isCallValid,
722 TextureType targetPacked,
723 GLenum pname,
724 const GLint *params,
725 ParamCapture *paramCapture)
726 {
727 UNIMPLEMENTED();
728 }
729
CaptureTexSubImage2D_pixels(const State & glState,bool isCallValid,TextureTarget targetPacked,GLint level,GLint xoffset,GLint yoffset,GLsizei width,GLsizei height,GLenum format,GLenum type,const void * pixels,ParamCapture * paramCapture)730 void CaptureTexSubImage2D_pixels(const State &glState,
731 bool isCallValid,
732 TextureTarget targetPacked,
733 GLint level,
734 GLint xoffset,
735 GLint yoffset,
736 GLsizei width,
737 GLsizei height,
738 GLenum format,
739 GLenum type,
740 const void *pixels,
741 ParamCapture *paramCapture)
742 {
743 CaptureTexImage2D_pixels(glState, isCallValid, targetPacked, level, 0, width, height, 0, format,
744 type, pixels, paramCapture);
745 }
746
CaptureUniform1fv_value(const State & glState,bool isCallValid,UniformLocation location,GLsizei count,const GLfloat * value,ParamCapture * paramCapture)747 void CaptureUniform1fv_value(const State &glState,
748 bool isCallValid,
749 UniformLocation location,
750 GLsizei count,
751 const GLfloat *value,
752 ParamCapture *paramCapture)
753 {
754 CaptureMemory(value, count * sizeof(GLfloat), paramCapture);
755 }
756
CaptureUniform1iv_value(const State & glState,bool isCallValid,UniformLocation location,GLsizei count,const GLint * value,ParamCapture * paramCapture)757 void CaptureUniform1iv_value(const State &glState,
758 bool isCallValid,
759 UniformLocation location,
760 GLsizei count,
761 const GLint *value,
762 ParamCapture *paramCapture)
763 {
764 CaptureMemory(value, count * sizeof(GLint), paramCapture);
765 }
766
CaptureUniform2fv_value(const State & glState,bool isCallValid,UniformLocation location,GLsizei count,const GLfloat * value,ParamCapture * paramCapture)767 void CaptureUniform2fv_value(const State &glState,
768 bool isCallValid,
769 UniformLocation location,
770 GLsizei count,
771 const GLfloat *value,
772 ParamCapture *paramCapture)
773 {
774 CaptureMemory(value, count * sizeof(GLfloat) * 2, paramCapture);
775 }
776
CaptureUniform2iv_value(const State & glState,bool isCallValid,UniformLocation location,GLsizei count,const GLint * value,ParamCapture * paramCapture)777 void CaptureUniform2iv_value(const State &glState,
778 bool isCallValid,
779 UniformLocation location,
780 GLsizei count,
781 const GLint *value,
782 ParamCapture *paramCapture)
783 {
784 CaptureMemory(value, count * sizeof(GLint) * 2, paramCapture);
785 }
786
CaptureUniform3fv_value(const State & glState,bool isCallValid,UniformLocation location,GLsizei count,const GLfloat * value,ParamCapture * paramCapture)787 void CaptureUniform3fv_value(const State &glState,
788 bool isCallValid,
789 UniformLocation location,
790 GLsizei count,
791 const GLfloat *value,
792 ParamCapture *paramCapture)
793 {
794 CaptureMemory(value, count * sizeof(GLfloat) * 3, paramCapture);
795 }
796
CaptureUniform3iv_value(const State & glState,bool isCallValid,UniformLocation location,GLsizei count,const GLint * value,ParamCapture * paramCapture)797 void CaptureUniform3iv_value(const State &glState,
798 bool isCallValid,
799 UniformLocation location,
800 GLsizei count,
801 const GLint *value,
802 ParamCapture *paramCapture)
803 {
804 CaptureMemory(value, count * sizeof(GLint) * 3, paramCapture);
805 }
806
CaptureUniform4fv_value(const State & glState,bool isCallValid,UniformLocation location,GLsizei count,const GLfloat * value,ParamCapture * paramCapture)807 void CaptureUniform4fv_value(const State &glState,
808 bool isCallValid,
809 UniformLocation location,
810 GLsizei count,
811 const GLfloat *value,
812 ParamCapture *paramCapture)
813 {
814 CaptureMemory(value, count * sizeof(GLfloat) * 4, paramCapture);
815 }
816
CaptureUniform4iv_value(const State & glState,bool isCallValid,UniformLocation location,GLsizei count,const GLint * value,ParamCapture * paramCapture)817 void CaptureUniform4iv_value(const State &glState,
818 bool isCallValid,
819 UniformLocation location,
820 GLsizei count,
821 const GLint *value,
822 ParamCapture *paramCapture)
823 {
824 CaptureMemory(value, count * sizeof(GLint) * 4, paramCapture);
825 }
826
CaptureUniformMatrix2fv_value(const State & glState,bool isCallValid,UniformLocation location,GLsizei count,GLboolean transpose,const GLfloat * value,ParamCapture * paramCapture)827 void CaptureUniformMatrix2fv_value(const State &glState,
828 bool isCallValid,
829 UniformLocation location,
830 GLsizei count,
831 GLboolean transpose,
832 const GLfloat *value,
833 ParamCapture *paramCapture)
834 {
835 CaptureMemory(value, count * sizeof(GLfloat) * 4, paramCapture);
836 }
837
CaptureUniformMatrix3fv_value(const State & glState,bool isCallValid,UniformLocation location,GLsizei count,GLboolean transpose,const GLfloat * value,ParamCapture * paramCapture)838 void CaptureUniformMatrix3fv_value(const State &glState,
839 bool isCallValid,
840 UniformLocation location,
841 GLsizei count,
842 GLboolean transpose,
843 const GLfloat *value,
844 ParamCapture *paramCapture)
845 {
846 CaptureMemory(value, count * sizeof(GLfloat) * 9, paramCapture);
847 }
848
CaptureUniformMatrix4fv_value(const State & glState,bool isCallValid,UniformLocation location,GLsizei count,GLboolean transpose,const GLfloat * value,ParamCapture * paramCapture)849 void CaptureUniformMatrix4fv_value(const State &glState,
850 bool isCallValid,
851 UniformLocation location,
852 GLsizei count,
853 GLboolean transpose,
854 const GLfloat *value,
855 ParamCapture *paramCapture)
856 {
857 CaptureMemory(value, count * sizeof(GLfloat) * 16, paramCapture);
858 }
859
CaptureVertexAttrib1fv_v(const State & glState,bool isCallValid,GLuint index,const GLfloat * v,ParamCapture * paramCapture)860 void CaptureVertexAttrib1fv_v(const State &glState,
861 bool isCallValid,
862 GLuint index,
863 const GLfloat *v,
864 ParamCapture *paramCapture)
865 {
866 CaptureMemory(v, sizeof(GLfloat), paramCapture);
867 }
868
CaptureVertexAttrib2fv_v(const State & glState,bool isCallValid,GLuint index,const GLfloat * v,ParamCapture * paramCapture)869 void CaptureVertexAttrib2fv_v(const State &glState,
870 bool isCallValid,
871 GLuint index,
872 const GLfloat *v,
873 ParamCapture *paramCapture)
874 {
875 CaptureMemory(v, sizeof(GLfloat) * 2, paramCapture);
876 }
877
CaptureVertexAttrib3fv_v(const State & glState,bool isCallValid,GLuint index,const GLfloat * v,ParamCapture * paramCapture)878 void CaptureVertexAttrib3fv_v(const State &glState,
879 bool isCallValid,
880 GLuint index,
881 const GLfloat *v,
882 ParamCapture *paramCapture)
883 {
884 CaptureMemory(v, sizeof(GLfloat) * 3, paramCapture);
885 }
886
CaptureVertexAttrib4fv_v(const State & glState,bool isCallValid,GLuint index,const GLfloat * v,ParamCapture * paramCapture)887 void CaptureVertexAttrib4fv_v(const State &glState,
888 bool isCallValid,
889 GLuint index,
890 const GLfloat *v,
891 ParamCapture *paramCapture)
892 {
893 CaptureMemory(v, sizeof(GLfloat) * 4, paramCapture);
894 }
895
CaptureVertexAttribPointer_pointer(const State & glState,bool isCallValid,GLuint index,GLint size,VertexAttribType typePacked,GLboolean normalized,GLsizei stride,const void * pointer,ParamCapture * paramCapture)896 void CaptureVertexAttribPointer_pointer(const State &glState,
897 bool isCallValid,
898 GLuint index,
899 GLint size,
900 VertexAttribType typePacked,
901 GLboolean normalized,
902 GLsizei stride,
903 const void *pointer,
904 ParamCapture *paramCapture)
905 {
906 paramCapture->value.voidConstPointerVal = pointer;
907 if (!glState.getTargetBuffer(gl::BufferBinding::Array))
908 {
909 paramCapture->arrayClientPointerIndex = index;
910 }
911 }
912 } // namespace gl
913