• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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_gles3_params.cpp:
7 //   Pointer parameter capture functions for the OpenGL ES 3.0 entry points.
8 
9 #include "libANGLE/capture/capture_gles_2_0_autogen.h"
10 #include "libANGLE/capture/capture_gles_3_0_autogen.h"
11 
12 using namespace angle;
13 
14 namespace gl
15 {
CaptureClearBufferfv_value(const State & glState,bool isCallValid,GLenum buffer,GLint drawbuffer,const GLfloat * value,ParamCapture * paramCapture)16 void CaptureClearBufferfv_value(const State &glState,
17                                 bool isCallValid,
18                                 GLenum buffer,
19                                 GLint drawbuffer,
20                                 const GLfloat *value,
21                                 ParamCapture *paramCapture)
22 {
23     CaptureClearBufferValue<GLfloat>(buffer, value, paramCapture);
24 }
25 
CaptureClearBufferiv_value(const State & glState,bool isCallValid,GLenum buffer,GLint drawbuffer,const GLint * value,ParamCapture * paramCapture)26 void CaptureClearBufferiv_value(const State &glState,
27                                 bool isCallValid,
28                                 GLenum buffer,
29                                 GLint drawbuffer,
30                                 const GLint *value,
31                                 ParamCapture *paramCapture)
32 {
33     CaptureClearBufferValue<GLint>(buffer, value, paramCapture);
34 }
35 
CaptureClearBufferuiv_value(const State & glState,bool isCallValid,GLenum buffer,GLint drawbuffer,const GLuint * value,ParamCapture * paramCapture)36 void CaptureClearBufferuiv_value(const State &glState,
37                                  bool isCallValid,
38                                  GLenum buffer,
39                                  GLint drawbuffer,
40                                  const GLuint *value,
41                                  ParamCapture *paramCapture)
42 {
43     CaptureClearBufferValue<GLuint>(buffer, value, paramCapture);
44 }
45 
CaptureCompressedTexImage3D_data(const State & glState,bool isCallValid,TextureTarget targetPacked,GLint level,GLenum internalformat,GLsizei width,GLsizei height,GLsizei depth,GLint border,GLsizei imageSize,const void * data,ParamCapture * paramCapture)46 void CaptureCompressedTexImage3D_data(const State &glState,
47                                       bool isCallValid,
48                                       TextureTarget targetPacked,
49                                       GLint level,
50                                       GLenum internalformat,
51                                       GLsizei width,
52                                       GLsizei height,
53                                       GLsizei depth,
54                                       GLint border,
55                                       GLsizei imageSize,
56                                       const void *data,
57                                       ParamCapture *paramCapture)
58 {
59     if (glState.getTargetBuffer(gl::BufferBinding::PixelUnpack))
60     {
61         return;
62     }
63 
64     if (!data)
65     {
66         return;
67     }
68 
69     CaptureMemory(data, imageSize, paramCapture);
70 }
71 
CaptureCompressedTexSubImage3D_data(const State & glState,bool isCallValid,TextureTarget targetPacked,GLint level,GLint xoffset,GLint yoffset,GLint zoffset,GLsizei width,GLsizei height,GLsizei depth,GLenum format,GLsizei imageSize,const void * data,ParamCapture * paramCapture)72 void CaptureCompressedTexSubImage3D_data(const State &glState,
73                                          bool isCallValid,
74                                          TextureTarget targetPacked,
75                                          GLint level,
76                                          GLint xoffset,
77                                          GLint yoffset,
78                                          GLint zoffset,
79                                          GLsizei width,
80                                          GLsizei height,
81                                          GLsizei depth,
82                                          GLenum format,
83                                          GLsizei imageSize,
84                                          const void *data,
85                                          ParamCapture *paramCapture)
86 {
87     CaptureCompressedTexImage3D_data(glState, isCallValid, targetPacked, level, 0, width, height,
88                                      depth, 0, imageSize, data, paramCapture);
89 }
90 
CaptureDeleteQueries_idsPacked(const State & glState,bool isCallValid,GLsizei n,const QueryID * ids,ParamCapture * paramCapture)91 void CaptureDeleteQueries_idsPacked(const State &glState,
92                                     bool isCallValid,
93                                     GLsizei n,
94                                     const QueryID *ids,
95                                     ParamCapture *paramCapture)
96 {
97     CaptureArray(ids, n, paramCapture);
98 }
99 
CaptureDeleteSamplers_samplersPacked(const State & glState,bool isCallValid,GLsizei count,const SamplerID * samplers,ParamCapture * paramCapture)100 void CaptureDeleteSamplers_samplersPacked(const State &glState,
101                                           bool isCallValid,
102                                           GLsizei count,
103                                           const SamplerID *samplers,
104                                           ParamCapture *paramCapture)
105 {
106     CaptureArray(samplers, count, paramCapture);
107 }
108 
CaptureDeleteTransformFeedbacks_idsPacked(const State & glState,bool isCallValid,GLsizei n,const TransformFeedbackID * ids,ParamCapture * paramCapture)109 void CaptureDeleteTransformFeedbacks_idsPacked(const State &glState,
110                                                bool isCallValid,
111                                                GLsizei n,
112                                                const TransformFeedbackID *ids,
113                                                ParamCapture *paramCapture)
114 {
115     CaptureArray(ids, n, paramCapture);
116 }
117 
CaptureDeleteVertexArrays_arraysPacked(const State & glState,bool isCallValid,GLsizei n,const VertexArrayID * arrays,ParamCapture * paramCapture)118 void CaptureDeleteVertexArrays_arraysPacked(const State &glState,
119                                             bool isCallValid,
120                                             GLsizei n,
121                                             const VertexArrayID *arrays,
122                                             ParamCapture *paramCapture)
123 {
124     CaptureArray(arrays, n, paramCapture);
125 }
126 
CaptureDrawBuffers_bufs(const State & glState,bool isCallValid,GLsizei n,const GLenum * bufs,ParamCapture * paramCapture)127 void CaptureDrawBuffers_bufs(const State &glState,
128                              bool isCallValid,
129                              GLsizei n,
130                              const GLenum *bufs,
131                              ParamCapture *paramCapture)
132 {
133     CaptureArray(bufs, n, paramCapture);
134 }
135 
CaptureDrawElementsInstanced_indices(const State & glState,bool isCallValid,PrimitiveMode modePacked,GLsizei count,DrawElementsType typePacked,const void * indices,GLsizei instancecount,ParamCapture * paramCapture)136 void CaptureDrawElementsInstanced_indices(const State &glState,
137                                           bool isCallValid,
138                                           PrimitiveMode modePacked,
139                                           GLsizei count,
140                                           DrawElementsType typePacked,
141                                           const void *indices,
142                                           GLsizei instancecount,
143                                           ParamCapture *paramCapture)
144 {
145     CaptureDrawElements_indices(glState, isCallValid, modePacked, count, typePacked, indices,
146                                 paramCapture);
147 }
148 
CaptureDrawRangeElements_indices(const State & glState,bool isCallValid,PrimitiveMode modePacked,GLuint start,GLuint end,GLsizei count,DrawElementsType typePacked,const void * indices,ParamCapture * paramCapture)149 void CaptureDrawRangeElements_indices(const State &glState,
150                                       bool isCallValid,
151                                       PrimitiveMode modePacked,
152                                       GLuint start,
153                                       GLuint end,
154                                       GLsizei count,
155                                       DrawElementsType typePacked,
156                                       const void *indices,
157                                       ParamCapture *paramCapture)
158 {
159     CaptureDrawElements_indices(glState, isCallValid, modePacked, count, typePacked, indices,
160                                 paramCapture);
161 }
162 
CaptureGenQueries_idsPacked(const State & glState,bool isCallValid,GLsizei n,QueryID * ids,ParamCapture * paramCapture)163 void CaptureGenQueries_idsPacked(const State &glState,
164                                  bool isCallValid,
165                                  GLsizei n,
166                                  QueryID *ids,
167                                  ParamCapture *paramCapture)
168 {
169     CaptureGenHandles(n, ids, paramCapture);
170 }
171 
CaptureGenSamplers_samplersPacked(const State & glState,bool isCallValid,GLsizei count,SamplerID * samplers,ParamCapture * paramCapture)172 void CaptureGenSamplers_samplersPacked(const State &glState,
173                                        bool isCallValid,
174                                        GLsizei count,
175                                        SamplerID *samplers,
176                                        ParamCapture *paramCapture)
177 {
178     CaptureGenHandles(count, samplers, paramCapture);
179 }
180 
CaptureGenTransformFeedbacks_idsPacked(const State & glState,bool isCallValid,GLsizei n,TransformFeedbackID * ids,ParamCapture * paramCapture)181 void CaptureGenTransformFeedbacks_idsPacked(const State &glState,
182                                             bool isCallValid,
183                                             GLsizei n,
184                                             TransformFeedbackID *ids,
185                                             ParamCapture *paramCapture)
186 {
187     CaptureGenHandles(n, ids, paramCapture);
188 }
189 
CaptureGenVertexArrays_arraysPacked(const State & glState,bool isCallValid,GLsizei n,VertexArrayID * arrays,ParamCapture * paramCapture)190 void CaptureGenVertexArrays_arraysPacked(const State &glState,
191                                          bool isCallValid,
192                                          GLsizei n,
193                                          VertexArrayID *arrays,
194                                          ParamCapture *paramCapture)
195 {
196     CaptureGenHandles(n, arrays, paramCapture);
197 }
198 
CaptureGetActiveUniformBlockName_length(const State & glState,bool isCallValid,ShaderProgramID program,UniformBlockIndex uniformBlockIndex,GLsizei bufSize,GLsizei * length,GLchar * uniformBlockName,ParamCapture * paramCapture)199 void CaptureGetActiveUniformBlockName_length(const State &glState,
200                                              bool isCallValid,
201                                              ShaderProgramID program,
202                                              UniformBlockIndex uniformBlockIndex,
203                                              GLsizei bufSize,
204                                              GLsizei *length,
205                                              GLchar *uniformBlockName,
206                                              ParamCapture *paramCapture)
207 {
208     // From the OpenGL ES 3.0 spec:
209     // The actual number of characters written into uniformBlockName, excluding the null terminator,
210     // is returned in length. If length is NULL, no length is returned.
211     if (length)
212     {
213         paramCapture->readBufferSizeBytes = sizeof(GLsizei);
214     }
215 }
216 
CaptureGetActiveUniformBlockName_uniformBlockName(const State & glState,bool isCallValid,ShaderProgramID program,UniformBlockIndex uniformBlockIndex,GLsizei bufSize,GLsizei * length,GLchar * uniformBlockName,ParamCapture * paramCapture)217 void CaptureGetActiveUniformBlockName_uniformBlockName(const State &glState,
218                                                        bool isCallValid,
219                                                        ShaderProgramID program,
220                                                        UniformBlockIndex uniformBlockIndex,
221                                                        GLsizei bufSize,
222                                                        GLsizei *length,
223                                                        GLchar *uniformBlockName,
224                                                        ParamCapture *paramCapture)
225 {
226     // From the OpenGL ES 3.0 spec:
227     // bufSize contains the maximum number of characters (including the null terminator) that will
228     // be written back to uniformBlockName.
229     CaptureStringLimit(uniformBlockName, bufSize, paramCapture);
230 }
231 
CaptureGetActiveUniformBlockiv_params(const State & glState,bool isCallValid,ShaderProgramID program,UniformBlockIndex uniformBlockIndex,GLenum pname,GLint * params,ParamCapture * paramCapture)232 void CaptureGetActiveUniformBlockiv_params(const State &glState,
233                                            bool isCallValid,
234                                            ShaderProgramID program,
235                                            UniformBlockIndex uniformBlockIndex,
236                                            GLenum pname,
237                                            GLint *params,
238                                            ParamCapture *paramCapture)
239 {
240     CaptureGetActiveUniformBlockivParameters(glState, program, uniformBlockIndex, pname,
241                                              paramCapture);
242 }
243 
CaptureGetActiveUniformsiv_uniformIndices(const State & glState,bool isCallValid,ShaderProgramID program,GLsizei uniformCount,const GLuint * uniformIndices,GLenum pname,GLint * params,ParamCapture * paramCapture)244 void CaptureGetActiveUniformsiv_uniformIndices(const State &glState,
245                                                bool isCallValid,
246                                                ShaderProgramID program,
247                                                GLsizei uniformCount,
248                                                const GLuint *uniformIndices,
249                                                GLenum pname,
250                                                GLint *params,
251                                                ParamCapture *paramCapture)
252 {
253     // From the OpenGL ES 3.0 spec:
254     // For GetActiveUniformsiv, uniformCountindicates both the number of
255     // elements in the array of indices uniformIndices and the number of
256     // parameters written to params upon successful return.
257     CaptureArray(uniformIndices, uniformCount, paramCapture);
258 }
259 
CaptureGetActiveUniformsiv_params(const State & glState,bool isCallValid,ShaderProgramID program,GLsizei uniformCount,const GLuint * uniformIndices,GLenum pname,GLint * params,ParamCapture * paramCapture)260 void CaptureGetActiveUniformsiv_params(const State &glState,
261                                        bool isCallValid,
262                                        ShaderProgramID program,
263                                        GLsizei uniformCount,
264                                        const GLuint *uniformIndices,
265                                        GLenum pname,
266                                        GLint *params,
267                                        ParamCapture *paramCapture)
268 {
269     // From the OpenGL ES 3.0 spec:
270     // For GetActiveUniformsiv, uniformCountindicates both the number of
271     // elements in the array of indices uniformIndices and the number of
272     // parameters written to params upon successful return.
273     paramCapture->readBufferSizeBytes = sizeof(GLint) * uniformCount;
274 }
275 
CaptureGetBufferParameteri64v_params(const State & glState,bool isCallValid,BufferBinding targetPacked,GLenum pname,GLint64 * params,ParamCapture * paramCapture)276 void CaptureGetBufferParameteri64v_params(const State &glState,
277                                           bool isCallValid,
278                                           BufferBinding targetPacked,
279                                           GLenum pname,
280                                           GLint64 *params,
281                                           ParamCapture *paramCapture)
282 {
283     UNIMPLEMENTED();
284 }
285 
CaptureGetBufferPointerv_params(const State & glState,bool isCallValid,BufferBinding targetPacked,GLenum pname,void ** params,ParamCapture * paramCapture)286 void CaptureGetBufferPointerv_params(const State &glState,
287                                      bool isCallValid,
288                                      BufferBinding targetPacked,
289                                      GLenum pname,
290                                      void **params,
291                                      ParamCapture *paramCapture)
292 {
293     UNIMPLEMENTED();
294 }
295 
CaptureGetFragDataLocation_name(const State & glState,bool isCallValid,ShaderProgramID program,const GLchar * name,ParamCapture * paramCapture)296 void CaptureGetFragDataLocation_name(const State &glState,
297                                      bool isCallValid,
298                                      ShaderProgramID program,
299                                      const GLchar *name,
300                                      ParamCapture *paramCapture)
301 {
302     CaptureString(name, paramCapture);
303 }
304 
CaptureGetInteger64i_v_data(const State & glState,bool isCallValid,GLenum target,GLuint index,GLint64 * data,ParamCapture * paramCapture)305 void CaptureGetInteger64i_v_data(const State &glState,
306                                  bool isCallValid,
307                                  GLenum target,
308                                  GLuint index,
309                                  GLint64 *data,
310                                  ParamCapture *paramCapture)
311 {
312     CaptureGetParameter(glState, target, sizeof(GLint64), paramCapture);
313 }
314 
CaptureGetInteger64v_data(const State & glState,bool isCallValid,GLenum pname,GLint64 * data,ParamCapture * paramCapture)315 void CaptureGetInteger64v_data(const State &glState,
316                                bool isCallValid,
317                                GLenum pname,
318                                GLint64 *data,
319                                ParamCapture *paramCapture)
320 {
321     CaptureGetParameter(glState, pname, sizeof(GLint64), paramCapture);
322 }
323 
CaptureGetIntegeri_v_data(const State & glState,bool isCallValid,GLenum target,GLuint index,GLint * data,ParamCapture * paramCapture)324 void CaptureGetIntegeri_v_data(const State &glState,
325                                bool isCallValid,
326                                GLenum target,
327                                GLuint index,
328                                GLint *data,
329                                ParamCapture *paramCapture)
330 {
331     CaptureGetParameter(glState, target, sizeof(GLint), paramCapture);
332 }
333 
CaptureGetInternalformativ_params(const State & glState,bool isCallValid,GLenum target,GLenum internalformat,GLenum pname,GLsizei bufSize,GLint * params,ParamCapture * paramCapture)334 void CaptureGetInternalformativ_params(const State &glState,
335                                        bool isCallValid,
336                                        GLenum target,
337                                        GLenum internalformat,
338                                        GLenum pname,
339                                        GLsizei bufSize,
340                                        GLint *params,
341                                        ParamCapture *paramCapture)
342 {
343     // From the OpenGL ES 3.0 spec:
344     //
345     // The information retrieved will be written to memory addressed by the pointer specified in
346     // params.
347     //
348     // No more than bufSize integers will be written to this memory.
349     //
350     // If pname is GL_NUM_SAMPLE_COUNTS, the number of sample counts that would be returned by
351     // querying GL_SAMPLES will be returned in params.
352     //
353     // If pname is GL_SAMPLES, the sample counts supported for internalformat and target are written
354     // into params in descending numeric order. Only positive values are returned.
355     //
356     // Querying GL_SAMPLES with bufSize of one will return just the maximum supported number of
357     // samples for this format.
358 
359     if (bufSize == 0)
360         return;
361 
362     if (params)
363     {
364         // For GL_NUM_SAMPLE_COUNTS, only one value is returned
365         // For GL_SAMPLES, two values will be returned, unless bufSize limits it to one
366         uint32_t paramCount = (pname == GL_SAMPLES && bufSize > 1) ? 2 : 1;
367 
368         paramCapture->readBufferSizeBytes = sizeof(GLint) * paramCount;
369     }
370 }
371 
CaptureGetProgramBinary_length(const State & glState,bool isCallValid,ShaderProgramID program,GLsizei bufSize,GLsizei * length,GLenum * binaryFormat,void * binary,ParamCapture * paramCapture)372 void CaptureGetProgramBinary_length(const State &glState,
373                                     bool isCallValid,
374                                     ShaderProgramID program,
375                                     GLsizei bufSize,
376                                     GLsizei *length,
377                                     GLenum *binaryFormat,
378                                     void *binary,
379                                     ParamCapture *paramCapture)
380 {
381     if (length)
382     {
383         paramCapture->readBufferSizeBytes = sizeof(GLsizei);
384     }
385 }
386 
CaptureGetProgramBinary_binaryFormat(const State & glState,bool isCallValid,ShaderProgramID program,GLsizei bufSize,GLsizei * length,GLenum * binaryFormat,void * binary,ParamCapture * paramCapture)387 void CaptureGetProgramBinary_binaryFormat(const State &glState,
388                                           bool isCallValid,
389                                           ShaderProgramID program,
390                                           GLsizei bufSize,
391                                           GLsizei *length,
392                                           GLenum *binaryFormat,
393                                           void *binary,
394                                           ParamCapture *paramCapture)
395 {
396     paramCapture->readBufferSizeBytes = sizeof(GLenum);
397 }
398 
CaptureGetProgramBinary_binary(const State & glState,bool isCallValid,ShaderProgramID program,GLsizei bufSize,GLsizei * length,GLenum * binaryFormat,void * binary,ParamCapture * paramCapture)399 void CaptureGetProgramBinary_binary(const State &glState,
400                                     bool isCallValid,
401                                     ShaderProgramID program,
402                                     GLsizei bufSize,
403                                     GLsizei *length,
404                                     GLenum *binaryFormat,
405                                     void *binary,
406                                     ParamCapture *paramCapture)
407 {
408     // If we have length, then actual binarySize was written there
409     // Otherwise, we don't know how many bytes were written
410     if (!length)
411     {
412         UNIMPLEMENTED();
413         return;
414     }
415 
416     GLsizei binarySize = *length;
417     if (binarySize > bufSize)
418     {
419         // This is a GL error, but clamp it anyway
420         binarySize = bufSize;
421     }
422 
423     paramCapture->readBufferSizeBytes = binarySize;
424 }
425 
CaptureGetQueryObjectuiv_params(const State & glState,bool isCallValid,QueryID id,GLenum pname,GLuint * params,ParamCapture * paramCapture)426 void CaptureGetQueryObjectuiv_params(const State &glState,
427                                      bool isCallValid,
428                                      QueryID id,
429                                      GLenum pname,
430                                      GLuint *params,
431                                      ParamCapture *paramCapture)
432 {
433     // This only returns one value
434     paramCapture->readBufferSizeBytes = sizeof(GLuint);
435 }
436 
CaptureGetQueryiv_params(const State & glState,bool isCallValid,QueryType targetPacked,GLenum pname,GLint * params,ParamCapture * paramCapture)437 void CaptureGetQueryiv_params(const State &glState,
438                               bool isCallValid,
439                               QueryType targetPacked,
440                               GLenum pname,
441                               GLint *params,
442                               ParamCapture *paramCapture)
443 {
444     // This only returns one value
445     paramCapture->readBufferSizeBytes = sizeof(GLint);
446 }
447 
CaptureGetSamplerParameterfv_params(const State & glState,bool isCallValid,SamplerID sampler,GLenum pname,GLfloat * params,ParamCapture * paramCapture)448 void CaptureGetSamplerParameterfv_params(const State &glState,
449                                          bool isCallValid,
450                                          SamplerID sampler,
451                                          GLenum pname,
452                                          GLfloat *params,
453                                          ParamCapture *paramCapture)
454 {
455     // page 458 https://www.khronos.org/registry/OpenGL/specs/es/3.2/es_spec_3.2.pdf
456     paramCapture->readBufferSizeBytes = 4 * sizeof(GLfloat);
457 }
458 
CaptureGetSamplerParameteriv_params(const State & glState,bool isCallValid,SamplerID sampler,GLenum pname,GLint * params,ParamCapture * paramCapture)459 void CaptureGetSamplerParameteriv_params(const State &glState,
460                                          bool isCallValid,
461                                          SamplerID sampler,
462                                          GLenum pname,
463                                          GLint *params,
464                                          ParamCapture *paramCapture)
465 {
466     // page 458 https://www.khronos.org/registry/OpenGL/specs/es/3.2/es_spec_3.2.pdf
467     paramCapture->readBufferSizeBytes = 4 * sizeof(GLint);
468 }
469 
CaptureGetSynciv_length(const State & glState,bool isCallValid,SyncID syncPacked,GLenum pname,GLsizei bufSize,GLsizei * length,GLint * values,ParamCapture * paramCapture)470 void CaptureGetSynciv_length(const State &glState,
471                              bool isCallValid,
472                              SyncID syncPacked,
473                              GLenum pname,
474                              GLsizei bufSize,
475                              GLsizei *length,
476                              GLint *values,
477                              ParamCapture *paramCapture)
478 {
479     if (length)
480     {
481         paramCapture->readBufferSizeBytes = sizeof(GLsizei);
482     }
483 }
484 
CaptureGetSynciv_values(const State & glState,bool isCallValid,SyncID syncPacked,GLenum pname,GLsizei bufSize,GLsizei * length,GLint * values,ParamCapture * paramCapture)485 void CaptureGetSynciv_values(const State &glState,
486                              bool isCallValid,
487                              SyncID syncPacked,
488                              GLenum pname,
489                              GLsizei bufSize,
490                              GLsizei *length,
491                              GLint *values,
492                              ParamCapture *paramCapture)
493 {
494     // Spec: On success, GetSynciv replaces up to bufSize integers in values with the corresponding
495     // property values of the object being queried. The actual number of integers replaced is
496     // returned in *length.If length is NULL, no length is returned.
497     if (bufSize == 0)
498         return;
499 
500     if (values)
501     {
502         paramCapture->readBufferSizeBytes = sizeof(GLint) * bufSize;
503     }
504 }
505 
CaptureGetTransformFeedbackVarying_length(const State & glState,bool isCallValid,ShaderProgramID program,GLuint index,GLsizei bufSize,GLsizei * length,GLsizei * size,GLenum * type,GLchar * name,ParamCapture * paramCapture)506 void CaptureGetTransformFeedbackVarying_length(const State &glState,
507                                                bool isCallValid,
508                                                ShaderProgramID program,
509                                                GLuint index,
510                                                GLsizei bufSize,
511                                                GLsizei *length,
512                                                GLsizei *size,
513                                                GLenum *type,
514                                                GLchar *name,
515                                                ParamCapture *paramCapture)
516 {
517     UNIMPLEMENTED();
518 }
519 
CaptureGetTransformFeedbackVarying_size(const State & glState,bool isCallValid,ShaderProgramID program,GLuint index,GLsizei bufSize,GLsizei * length,GLsizei * size,GLenum * type,GLchar * name,ParamCapture * paramCapture)520 void CaptureGetTransformFeedbackVarying_size(const State &glState,
521                                              bool isCallValid,
522                                              ShaderProgramID program,
523                                              GLuint index,
524                                              GLsizei bufSize,
525                                              GLsizei *length,
526                                              GLsizei *size,
527                                              GLenum *type,
528                                              GLchar *name,
529                                              ParamCapture *paramCapture)
530 {
531     UNIMPLEMENTED();
532 }
533 
CaptureGetTransformFeedbackVarying_type(const State & glState,bool isCallValid,ShaderProgramID program,GLuint index,GLsizei bufSize,GLsizei * length,GLsizei * size,GLenum * type,GLchar * name,ParamCapture * paramCapture)534 void CaptureGetTransformFeedbackVarying_type(const State &glState,
535                                              bool isCallValid,
536                                              ShaderProgramID program,
537                                              GLuint index,
538                                              GLsizei bufSize,
539                                              GLsizei *length,
540                                              GLsizei *size,
541                                              GLenum *type,
542                                              GLchar *name,
543                                              ParamCapture *paramCapture)
544 {
545     UNIMPLEMENTED();
546 }
547 
CaptureGetTransformFeedbackVarying_name(const State & glState,bool isCallValid,ShaderProgramID program,GLuint index,GLsizei bufSize,GLsizei * length,GLsizei * size,GLenum * type,GLchar * name,ParamCapture * paramCapture)548 void CaptureGetTransformFeedbackVarying_name(const State &glState,
549                                              bool isCallValid,
550                                              ShaderProgramID program,
551                                              GLuint index,
552                                              GLsizei bufSize,
553                                              GLsizei *length,
554                                              GLsizei *size,
555                                              GLenum *type,
556                                              GLchar *name,
557                                              ParamCapture *paramCapture)
558 {
559     UNIMPLEMENTED();
560 }
561 
CaptureGetUniformBlockIndex_uniformBlockName(const State & glState,bool isCallValid,ShaderProgramID program,const GLchar * uniformBlockName,ParamCapture * paramCapture)562 void CaptureGetUniformBlockIndex_uniformBlockName(const State &glState,
563                                                   bool isCallValid,
564                                                   ShaderProgramID program,
565                                                   const GLchar *uniformBlockName,
566                                                   ParamCapture *paramCapture)
567 {
568     CaptureString(uniformBlockName, paramCapture);
569 }
570 
CaptureGetUniformIndices_uniformNames(const State & glState,bool isCallValid,ShaderProgramID program,GLsizei uniformCount,const GLchar * const * uniformNames,GLuint * uniformIndices,ParamCapture * paramCapture)571 void CaptureGetUniformIndices_uniformNames(const State &glState,
572                                            bool isCallValid,
573                                            ShaderProgramID program,
574                                            GLsizei uniformCount,
575                                            const GLchar *const *uniformNames,
576                                            GLuint *uniformIndices,
577                                            ParamCapture *paramCapture)
578 {
579     for (GLsizei index = 0; index < uniformCount; ++index)
580     {
581         CaptureString(uniformNames[index], paramCapture);
582     }
583 }
584 
CaptureGetUniformIndices_uniformIndices(const State & glState,bool isCallValid,ShaderProgramID program,GLsizei uniformCount,const GLchar * const * uniformNames,GLuint * uniformIndices,ParamCapture * paramCapture)585 void CaptureGetUniformIndices_uniformIndices(const State &glState,
586                                              bool isCallValid,
587                                              ShaderProgramID program,
588                                              GLsizei uniformCount,
589                                              const GLchar *const *uniformNames,
590                                              GLuint *uniformIndices,
591                                              ParamCapture *paramCapture)
592 {
593     CaptureMemory(uniformIndices, sizeof(GLuint) * uniformCount, paramCapture);
594 }
595 
CaptureGetUniformuiv_params(const State & glState,bool isCallValid,ShaderProgramID program,UniformLocation location,GLuint * params,ParamCapture * paramCapture)596 void CaptureGetUniformuiv_params(const State &glState,
597                                  bool isCallValid,
598                                  ShaderProgramID program,
599                                  UniformLocation location,
600                                  GLuint *params,
601                                  ParamCapture *paramCapture)
602 {
603     /* At most a mat4 can be returned, so use this upper bound as count */
604     CaptureArray(params, 16 * sizeof(GLuint), paramCapture);
605 }
606 
CaptureGetVertexAttribIiv_params(const State & glState,bool isCallValid,GLuint index,GLenum pname,GLint * params,ParamCapture * paramCapture)607 void CaptureGetVertexAttribIiv_params(const State &glState,
608                                       bool isCallValid,
609                                       GLuint index,
610                                       GLenum pname,
611                                       GLint *params,
612                                       ParamCapture *paramCapture)
613 {
614     int nParams = pname == GL_CURRENT_VERTEX_ATTRIB ? 4 : 1;
615 
616     paramCapture->readBufferSizeBytes = nParams * sizeof(GLint);
617 }
618 
CaptureGetVertexAttribIuiv_params(const State & glState,bool isCallValid,GLuint index,GLenum pname,GLuint * params,ParamCapture * paramCapture)619 void CaptureGetVertexAttribIuiv_params(const State &glState,
620                                        bool isCallValid,
621                                        GLuint index,
622                                        GLenum pname,
623                                        GLuint *params,
624                                        ParamCapture *paramCapture)
625 {
626     int nParams = pname == GL_CURRENT_VERTEX_ATTRIB ? 4 : 1;
627 
628     paramCapture->readBufferSizeBytes = nParams * sizeof(GLuint);
629 }
630 
CaptureInvalidateFramebuffer_attachments(const State & glState,bool isCallValid,GLenum target,GLsizei numAttachments,const GLenum * attachments,ParamCapture * paramCapture)631 void CaptureInvalidateFramebuffer_attachments(const State &glState,
632                                               bool isCallValid,
633                                               GLenum target,
634                                               GLsizei numAttachments,
635                                               const GLenum *attachments,
636                                               ParamCapture *paramCapture)
637 {
638     CaptureMemory(attachments, sizeof(GLenum) * numAttachments, paramCapture);
639     paramCapture->value.voidConstPointerVal = paramCapture->data[0].data();
640 }
641 
CaptureInvalidateSubFramebuffer_attachments(const State & glState,bool isCallValid,GLenum target,GLsizei numAttachments,const GLenum * attachments,GLint x,GLint y,GLsizei width,GLsizei height,ParamCapture * paramCapture)642 void CaptureInvalidateSubFramebuffer_attachments(const State &glState,
643                                                  bool isCallValid,
644                                                  GLenum target,
645                                                  GLsizei numAttachments,
646                                                  const GLenum *attachments,
647                                                  GLint x,
648                                                  GLint y,
649                                                  GLsizei width,
650                                                  GLsizei height,
651                                                  ParamCapture *paramCapture)
652 {
653     CaptureMemory(attachments, sizeof(GLenum) * numAttachments, paramCapture);
654 }
655 
CaptureProgramBinary_binary(const State & glState,bool isCallValid,ShaderProgramID program,GLenum binaryFormat,const void * binary,GLsizei length,ParamCapture * paramCapture)656 void CaptureProgramBinary_binary(const State &glState,
657                                  bool isCallValid,
658                                  ShaderProgramID program,
659                                  GLenum binaryFormat,
660                                  const void *binary,
661                                  GLsizei length,
662                                  ParamCapture *paramCapture)
663 {
664     // Do nothing. glProgramBinary will be overridden in GenerateLinkedProgram.
665 }
666 
CaptureSamplerParameterfv_param(const State & glState,bool isCallValid,SamplerID sampler,GLenum pname,const GLfloat * param,ParamCapture * paramCapture)667 void CaptureSamplerParameterfv_param(const State &glState,
668                                      bool isCallValid,
669                                      SamplerID sampler,
670                                      GLenum pname,
671                                      const GLfloat *param,
672                                      ParamCapture *paramCapture)
673 {
674     CaptureTextureAndSamplerParameter_params<GLfloat>(pname, param, paramCapture);
675 }
676 
CaptureSamplerParameteriv_param(const State & glState,bool isCallValid,SamplerID sampler,GLenum pname,const GLint * param,ParamCapture * paramCapture)677 void CaptureSamplerParameteriv_param(const State &glState,
678                                      bool isCallValid,
679                                      SamplerID sampler,
680                                      GLenum pname,
681                                      const GLint *param,
682                                      ParamCapture *paramCapture)
683 {
684     CaptureTextureAndSamplerParameter_params<GLint>(pname, param, paramCapture);
685 }
686 
CaptureTexImage3D_pixels(const State & glState,bool isCallValid,TextureTarget targetPacked,GLint level,GLint internalformat,GLsizei width,GLsizei height,GLsizei depth,GLint border,GLenum format,GLenum type,const void * pixels,ParamCapture * paramCapture)687 void CaptureTexImage3D_pixels(const State &glState,
688                               bool isCallValid,
689                               TextureTarget targetPacked,
690                               GLint level,
691                               GLint internalformat,
692                               GLsizei width,
693                               GLsizei height,
694                               GLsizei depth,
695                               GLint border,
696                               GLenum format,
697                               GLenum type,
698                               const void *pixels,
699                               ParamCapture *paramCapture)
700 {
701     if (glState.getTargetBuffer(gl::BufferBinding::PixelUnpack))
702     {
703         return;
704     }
705 
706     if (!pixels)
707     {
708         return;
709     }
710 
711     const gl::InternalFormat &internalFormatInfo = gl::GetInternalFormatInfo(format, type);
712     const gl::PixelUnpackState &unpack           = glState.getUnpackState();
713 
714     const Extents size(width, height, depth);
715 
716     GLuint endByte = 0;
717     bool unpackSize =
718         internalFormatInfo.computePackUnpackEndByte(type, size, unpack, true, &endByte);
719     ASSERT(unpackSize);
720 
721     CaptureMemory(pixels, static_cast<size_t>(endByte), paramCapture);
722 }
723 
CaptureTexSubImage3D_pixels(const State & glState,bool isCallValid,TextureTarget targetPacked,GLint level,GLint xoffset,GLint yoffset,GLint zoffset,GLsizei width,GLsizei height,GLsizei depth,GLenum format,GLenum type,const void * pixels,ParamCapture * paramCapture)724 void CaptureTexSubImage3D_pixels(const State &glState,
725                                  bool isCallValid,
726                                  TextureTarget targetPacked,
727                                  GLint level,
728                                  GLint xoffset,
729                                  GLint yoffset,
730                                  GLint zoffset,
731                                  GLsizei width,
732                                  GLsizei height,
733                                  GLsizei depth,
734                                  GLenum format,
735                                  GLenum type,
736                                  const void *pixels,
737                                  ParamCapture *paramCapture)
738 {
739     CaptureTexImage3D_pixels(glState, isCallValid, targetPacked, level, 0, width, height, depth, 0,
740                              format, type, pixels, paramCapture);
741 }
742 
CaptureTransformFeedbackVaryings_varyings(const State & glState,bool isCallValid,ShaderProgramID program,GLsizei count,const GLchar * const * varyings,GLenum bufferMode,ParamCapture * paramCapture)743 void CaptureTransformFeedbackVaryings_varyings(const State &glState,
744                                                bool isCallValid,
745                                                ShaderProgramID program,
746                                                GLsizei count,
747                                                const GLchar *const *varyings,
748                                                GLenum bufferMode,
749                                                ParamCapture *paramCapture)
750 {
751     for (GLsizei index = 0; index < count; ++index)
752     {
753         CaptureString(varyings[index], paramCapture);
754     }
755 }
756 
CaptureUniform1uiv_value(const State & glState,bool isCallValid,UniformLocation location,GLsizei count,const GLuint * value,ParamCapture * paramCapture)757 void CaptureUniform1uiv_value(const State &glState,
758                               bool isCallValid,
759                               UniformLocation location,
760                               GLsizei count,
761                               const GLuint *value,
762                               ParamCapture *paramCapture)
763 {
764     CaptureMemory(value, count * sizeof(GLuint), paramCapture);
765 }
766 
CaptureUniform2uiv_value(const State & glState,bool isCallValid,UniformLocation location,GLsizei count,const GLuint * value,ParamCapture * paramCapture)767 void CaptureUniform2uiv_value(const State &glState,
768                               bool isCallValid,
769                               UniformLocation location,
770                               GLsizei count,
771                               const GLuint *value,
772                               ParamCapture *paramCapture)
773 {
774     CaptureMemory(value, count * sizeof(GLuint) * 2, paramCapture);
775 }
776 
CaptureUniform3uiv_value(const State & glState,bool isCallValid,UniformLocation location,GLsizei count,const GLuint * value,ParamCapture * paramCapture)777 void CaptureUniform3uiv_value(const State &glState,
778                               bool isCallValid,
779                               UniformLocation location,
780                               GLsizei count,
781                               const GLuint *value,
782                               ParamCapture *paramCapture)
783 {
784     CaptureMemory(value, count * sizeof(GLuint) * 3, paramCapture);
785 }
786 
CaptureUniform4uiv_value(const State & glState,bool isCallValid,UniformLocation location,GLsizei count,const GLuint * value,ParamCapture * paramCapture)787 void CaptureUniform4uiv_value(const State &glState,
788                               bool isCallValid,
789                               UniformLocation location,
790                               GLsizei count,
791                               const GLuint *value,
792                               ParamCapture *paramCapture)
793 {
794     CaptureMemory(value, count * sizeof(GLuint) * 4, paramCapture);
795 }
796 
CaptureUniformMatrix2x3fv_value(const State & glState,bool isCallValid,UniformLocation location,GLsizei count,GLboolean transpose,const GLfloat * value,ParamCapture * paramCapture)797 void CaptureUniformMatrix2x3fv_value(const State &glState,
798                                      bool isCallValid,
799                                      UniformLocation location,
800                                      GLsizei count,
801                                      GLboolean transpose,
802                                      const GLfloat *value,
803                                      ParamCapture *paramCapture)
804 {
805     CaptureMemory(value, count * sizeof(GLfloat) * 6, paramCapture);
806 }
807 
CaptureUniformMatrix2x4fv_value(const State & glState,bool isCallValid,UniformLocation location,GLsizei count,GLboolean transpose,const GLfloat * value,ParamCapture * paramCapture)808 void CaptureUniformMatrix2x4fv_value(const State &glState,
809                                      bool isCallValid,
810                                      UniformLocation location,
811                                      GLsizei count,
812                                      GLboolean transpose,
813                                      const GLfloat *value,
814                                      ParamCapture *paramCapture)
815 {
816     CaptureMemory(value, count * sizeof(GLfloat) * 8, paramCapture);
817 }
818 
CaptureUniformMatrix3x2fv_value(const State & glState,bool isCallValid,UniformLocation location,GLsizei count,GLboolean transpose,const GLfloat * value,ParamCapture * paramCapture)819 void CaptureUniformMatrix3x2fv_value(const State &glState,
820                                      bool isCallValid,
821                                      UniformLocation location,
822                                      GLsizei count,
823                                      GLboolean transpose,
824                                      const GLfloat *value,
825                                      ParamCapture *paramCapture)
826 {
827     CaptureMemory(value, count * sizeof(GLfloat) * 6, paramCapture);
828 }
829 
CaptureUniformMatrix3x4fv_value(const State & glState,bool isCallValid,UniformLocation location,GLsizei count,GLboolean transpose,const GLfloat * value,ParamCapture * paramCapture)830 void CaptureUniformMatrix3x4fv_value(const State &glState,
831                                      bool isCallValid,
832                                      UniformLocation location,
833                                      GLsizei count,
834                                      GLboolean transpose,
835                                      const GLfloat *value,
836                                      ParamCapture *paramCapture)
837 {
838     CaptureMemory(value, count * sizeof(GLfloat) * 12, paramCapture);
839 }
840 
CaptureUniformMatrix4x2fv_value(const State & glState,bool isCallValid,UniformLocation location,GLsizei count,GLboolean transpose,const GLfloat * value,ParamCapture * paramCapture)841 void CaptureUniformMatrix4x2fv_value(const State &glState,
842                                      bool isCallValid,
843                                      UniformLocation location,
844                                      GLsizei count,
845                                      GLboolean transpose,
846                                      const GLfloat *value,
847                                      ParamCapture *paramCapture)
848 {
849     CaptureMemory(value, count * sizeof(GLfloat) * 8, paramCapture);
850 }
851 
CaptureUniformMatrix4x3fv_value(const State & glState,bool isCallValid,UniformLocation location,GLsizei count,GLboolean transpose,const GLfloat * value,ParamCapture * paramCapture)852 void CaptureUniformMatrix4x3fv_value(const State &glState,
853                                      bool isCallValid,
854                                      UniformLocation location,
855                                      GLsizei count,
856                                      GLboolean transpose,
857                                      const GLfloat *value,
858                                      ParamCapture *paramCapture)
859 {
860     CaptureMemory(value, count * sizeof(GLfloat) * 12, paramCapture);
861 }
862 
CaptureVertexAttribI4iv_v(const State & glState,bool isCallValid,GLuint index,const GLint * v,ParamCapture * paramCapture)863 void CaptureVertexAttribI4iv_v(const State &glState,
864                                bool isCallValid,
865                                GLuint index,
866                                const GLint *v,
867                                ParamCapture *paramCapture)
868 {
869     UNIMPLEMENTED();
870 }
871 
CaptureVertexAttribI4uiv_v(const State & glState,bool isCallValid,GLuint index,const GLuint * v,ParamCapture * paramCapture)872 void CaptureVertexAttribI4uiv_v(const State &glState,
873                                 bool isCallValid,
874                                 GLuint index,
875                                 const GLuint *v,
876                                 ParamCapture *paramCapture)
877 {
878     UNIMPLEMENTED();
879 }
880 
CaptureVertexAttribIPointer_pointer(const State & glState,bool isCallValid,GLuint index,GLint size,VertexAttribType typePacked,GLsizei stride,const void * pointer,ParamCapture * paramCapture)881 void CaptureVertexAttribIPointer_pointer(const State &glState,
882                                          bool isCallValid,
883                                          GLuint index,
884                                          GLint size,
885                                          VertexAttribType typePacked,
886                                          GLsizei stride,
887                                          const void *pointer,
888                                          ParamCapture *paramCapture)
889 {
890     CaptureVertexAttribPointer_pointer(glState, isCallValid, index, size, typePacked, false, stride,
891                                        pointer, paramCapture);
892 }
893 
894 }  // namespace gl
895