1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
|
//
// Copyright (c) 2016 The ANGLE Project Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
//
// queryutils.cpp: Utilities for querying values from GL objects
#include "libANGLE/queryutils.h"
#include "common/utilities.h"
#include "libANGLE/Buffer.h"
#include "libANGLE/Framebuffer.h"
#include "libANGLE/Program.h"
#include "libANGLE/Renderbuffer.h"
#include "libANGLE/Sampler.h"
#include "libANGLE/Shader.h"
#include "libANGLE/Texture.h"
#include "libANGLE/Uniform.h"
#include "libANGLE/VertexAttribute.h"
namespace gl
{
namespace
{
template <typename ParamType>
void QueryTexParameterBase(const Texture *texture, GLenum pname, ParamType *params)
{
ASSERT(texture != nullptr);
switch (pname)
{
case GL_TEXTURE_MAG_FILTER:
*params = ConvertFromGLenum<ParamType>(texture->getMagFilter());
break;
case GL_TEXTURE_MIN_FILTER:
*params = ConvertFromGLenum<ParamType>(texture->getMinFilter());
break;
case GL_TEXTURE_WRAP_S:
*params = ConvertFromGLenum<ParamType>(texture->getWrapS());
break;
case GL_TEXTURE_WRAP_T:
*params = ConvertFromGLenum<ParamType>(texture->getWrapT());
break;
case GL_TEXTURE_WRAP_R:
*params = ConvertFromGLenum<ParamType>(texture->getWrapR());
break;
case GL_TEXTURE_IMMUTABLE_FORMAT:
*params = ConvertFromGLboolean<ParamType>(texture->getImmutableFormat());
break;
case GL_TEXTURE_IMMUTABLE_LEVELS:
*params = ConvertFromGLuint<ParamType>(texture->getImmutableLevels());
break;
case GL_TEXTURE_USAGE_ANGLE:
*params = ConvertFromGLenum<ParamType>(texture->getUsage());
break;
case GL_TEXTURE_MAX_ANISOTROPY_EXT:
*params = ConvertFromGLfloat<ParamType>(texture->getMaxAnisotropy());
break;
case GL_TEXTURE_SWIZZLE_R:
*params = ConvertFromGLenum<ParamType>(texture->getSwizzleRed());
break;
case GL_TEXTURE_SWIZZLE_G:
*params = ConvertFromGLenum<ParamType>(texture->getSwizzleGreen());
break;
case GL_TEXTURE_SWIZZLE_B:
*params = ConvertFromGLenum<ParamType>(texture->getSwizzleBlue());
break;
case GL_TEXTURE_SWIZZLE_A:
*params = ConvertFromGLenum<ParamType>(texture->getSwizzleAlpha());
break;
case GL_TEXTURE_BASE_LEVEL:
*params = ConvertFromGLuint<ParamType>(texture->getBaseLevel());
break;
case GL_TEXTURE_MAX_LEVEL:
*params = ConvertFromGLuint<ParamType>(texture->getMaxLevel());
break;
case GL_TEXTURE_MIN_LOD:
*params = ConvertFromGLfloat<ParamType>(texture->getSamplerState().minLod);
break;
case GL_TEXTURE_MAX_LOD:
*params = ConvertFromGLfloat<ParamType>(texture->getSamplerState().maxLod);
break;
case GL_TEXTURE_COMPARE_MODE:
*params = ConvertFromGLenum<ParamType>(texture->getCompareMode());
break;
case GL_TEXTURE_COMPARE_FUNC:
*params = ConvertFromGLenum<ParamType>(texture->getCompareFunc());
break;
case GL_TEXTURE_SRGB_DECODE_EXT:
*params = ConvertFromGLenum<ParamType>(texture->getSRGBDecode());
break;
default:
UNREACHABLE();
break;
}
}
template <typename ParamType>
void SetTexParameterBase(Texture *texture, GLenum pname, const ParamType *params)
{
ASSERT(texture != nullptr);
switch (pname)
{
case GL_TEXTURE_WRAP_S:
texture->setWrapS(ConvertToGLenum(params[0]));
break;
case GL_TEXTURE_WRAP_T:
texture->setWrapT(ConvertToGLenum(params[0]));
break;
case GL_TEXTURE_WRAP_R:
texture->setWrapR(ConvertToGLenum(params[0]));
break;
case GL_TEXTURE_MIN_FILTER:
texture->setMinFilter(ConvertToGLenum(params[0]));
break;
case GL_TEXTURE_MAG_FILTER:
texture->setMagFilter(ConvertToGLenum(params[0]));
break;
case GL_TEXTURE_USAGE_ANGLE:
texture->setUsage(ConvertToGLenum(params[0]));
break;
case GL_TEXTURE_MAX_ANISOTROPY_EXT:
texture->setMaxAnisotropy(ConvertToGLfloat(params[0]));
break;
case GL_TEXTURE_COMPARE_MODE:
texture->setCompareMode(ConvertToGLenum(params[0]));
break;
case GL_TEXTURE_COMPARE_FUNC:
texture->setCompareFunc(ConvertToGLenum(params[0]));
break;
case GL_TEXTURE_SWIZZLE_R:
texture->setSwizzleRed(ConvertToGLenum(params[0]));
break;
case GL_TEXTURE_SWIZZLE_G:
texture->setSwizzleGreen(ConvertToGLenum(params[0]));
break;
case GL_TEXTURE_SWIZZLE_B:
texture->setSwizzleBlue(ConvertToGLenum(params[0]));
break;
case GL_TEXTURE_SWIZZLE_A:
texture->setSwizzleAlpha(ConvertToGLenum(params[0]));
break;
case GL_TEXTURE_BASE_LEVEL:
texture->setBaseLevel(ConvertToGLuint(params[0]));
break;
case GL_TEXTURE_MAX_LEVEL:
texture->setMaxLevel(ConvertToGLuint(params[0]));
break;
case GL_TEXTURE_MIN_LOD:
texture->setMinLod(ConvertToGLfloat(params[0]));
break;
case GL_TEXTURE_MAX_LOD:
texture->setMaxLod(ConvertToGLfloat(params[0]));
break;
case GL_TEXTURE_SRGB_DECODE_EXT:
texture->setSRGBDecode(ConvertToGLenum(params[0]));
break;
default:
UNREACHABLE();
break;
}
}
template <typename ParamType>
void QuerySamplerParameterBase(const Sampler *sampler, GLenum pname, ParamType *params)
{
switch (pname)
{
case GL_TEXTURE_MIN_FILTER:
*params = ConvertFromGLenum<ParamType>(sampler->getMinFilter());
break;
case GL_TEXTURE_MAG_FILTER:
*params = ConvertFromGLenum<ParamType>(sampler->getMagFilter());
break;
case GL_TEXTURE_WRAP_S:
*params = ConvertFromGLenum<ParamType>(sampler->getWrapS());
break;
case GL_TEXTURE_WRAP_T:
*params = ConvertFromGLenum<ParamType>(sampler->getWrapT());
break;
case GL_TEXTURE_WRAP_R:
*params = ConvertFromGLenum<ParamType>(sampler->getWrapR());
break;
case GL_TEXTURE_MAX_ANISOTROPY_EXT:
*params = ConvertFromGLfloat<ParamType>(sampler->getMaxAnisotropy());
break;
case GL_TEXTURE_MIN_LOD:
*params = ConvertFromGLfloat<ParamType>(sampler->getMinLod());
break;
case GL_TEXTURE_MAX_LOD:
*params = ConvertFromGLfloat<ParamType>(sampler->getMaxLod());
break;
case GL_TEXTURE_COMPARE_MODE:
*params = ConvertFromGLenum<ParamType>(sampler->getCompareMode());
break;
case GL_TEXTURE_COMPARE_FUNC:
*params = ConvertFromGLenum<ParamType>(sampler->getCompareFunc());
break;
case GL_TEXTURE_SRGB_DECODE_EXT:
*params = ConvertFromGLenum<ParamType>(sampler->getSRGBDecode());
break;
default:
UNREACHABLE();
break;
}
}
template <typename ParamType>
void SetSamplerParameterBase(Sampler *sampler, GLenum pname, const ParamType *params)
{
switch (pname)
{
case GL_TEXTURE_WRAP_S:
sampler->setWrapS(ConvertToGLenum(params[0]));
break;
case GL_TEXTURE_WRAP_T:
sampler->setWrapT(ConvertToGLenum(params[0]));
break;
case GL_TEXTURE_WRAP_R:
sampler->setWrapR(ConvertToGLenum(params[0]));
break;
case GL_TEXTURE_MIN_FILTER:
sampler->setMinFilter(ConvertToGLenum(params[0]));
break;
case GL_TEXTURE_MAG_FILTER:
sampler->setMagFilter(ConvertToGLenum(params[0]));
break;
case GL_TEXTURE_MAX_ANISOTROPY_EXT:
sampler->setMaxAnisotropy(ConvertToGLfloat(params[0]));
break;
case GL_TEXTURE_COMPARE_MODE:
sampler->setCompareMode(ConvertToGLenum(params[0]));
break;
case GL_TEXTURE_COMPARE_FUNC:
sampler->setCompareFunc(ConvertToGLenum(params[0]));
break;
case GL_TEXTURE_MIN_LOD:
sampler->setMinLod(ConvertToGLfloat(params[0]));
break;
case GL_TEXTURE_MAX_LOD:
sampler->setMaxLod(ConvertToGLfloat(params[0]));
break;
case GL_TEXTURE_SRGB_DECODE_EXT:
sampler->setSRGBDecode(ConvertToGLenum(params[0]));
break;
default:
UNREACHABLE();
break;
}
}
template <typename ParamType, typename CurrentDataType>
ParamType ConvertCurrentValue(CurrentDataType currentValue)
{
return static_cast<ParamType>(currentValue);
}
template <>
GLint ConvertCurrentValue(GLfloat currentValue)
{
return iround<GLint>(currentValue);
}
template <typename ParamType, typename CurrentDataType, size_t CurrentValueCount>
void QueryVertexAttribBase(const VertexAttribute &attrib,
const CurrentDataType (¤tValueData)[CurrentValueCount],
GLenum pname,
ParamType *params)
{
switch (pname)
{
case GL_CURRENT_VERTEX_ATTRIB:
for (size_t i = 0; i < CurrentValueCount; ++i)
{
params[i] = ConvertCurrentValue<ParamType>(currentValueData[i]);
}
break;
case GL_VERTEX_ATTRIB_ARRAY_ENABLED:
*params = ConvertFromGLboolean<ParamType>(attrib.enabled);
break;
case GL_VERTEX_ATTRIB_ARRAY_SIZE:
*params = ConvertFromGLuint<ParamType>(attrib.size);
break;
case GL_VERTEX_ATTRIB_ARRAY_STRIDE:
*params = ConvertFromGLuint<ParamType>(attrib.stride);
break;
case GL_VERTEX_ATTRIB_ARRAY_TYPE:
*params = ConvertFromGLenum<ParamType>(attrib.type);
break;
case GL_VERTEX_ATTRIB_ARRAY_NORMALIZED:
*params = ConvertFromGLboolean<ParamType>(attrib.normalized);
break;
case GL_VERTEX_ATTRIB_ARRAY_BUFFER_BINDING:
*params = ConvertFromGLuint<ParamType>(attrib.buffer.id());
break;
case GL_VERTEX_ATTRIB_ARRAY_DIVISOR:
*params = ConvertFromGLuint<ParamType>(attrib.divisor);
break;
case GL_VERTEX_ATTRIB_ARRAY_INTEGER:
*params = ConvertFromGLboolean<ParamType>(attrib.pureInteger);
break;
default:
UNREACHABLE();
break;
}
}
template <typename ParamType>
void QueryBufferParameterBase(const Buffer *buffer, GLenum pname, ParamType *params)
{
ASSERT(buffer != nullptr);
switch (pname)
{
case GL_BUFFER_USAGE:
*params = ConvertFromGLenum<ParamType>(buffer->getUsage());
break;
case GL_BUFFER_SIZE:
*params = ConvertFromGLint64<ParamType>(buffer->getSize());
break;
case GL_BUFFER_ACCESS_FLAGS:
*params = ConvertFromGLuint<ParamType>(buffer->getAccessFlags());
break;
case GL_BUFFER_ACCESS_OES:
*params = ConvertFromGLenum<ParamType>(buffer->getAccess());
break;
case GL_BUFFER_MAPPED:
*params = ConvertFromGLboolean<ParamType>(buffer->isMapped());
break;
case GL_BUFFER_MAP_OFFSET:
*params = ConvertFromGLint64<ParamType>(buffer->getMapOffset());
break;
case GL_BUFFER_MAP_LENGTH:
*params = ConvertFromGLint64<ParamType>(buffer->getMapLength());
break;
default:
UNREACHABLE();
break;
}
}
} // anonymous namespace
void QueryFramebufferAttachmentParameteriv(const Framebuffer *framebuffer,
GLenum attachment,
GLenum pname,
GLint *params)
{
ASSERT(framebuffer);
const FramebufferAttachment *attachmentObject = framebuffer->getAttachment(attachment);
if (attachmentObject == nullptr)
{
// ES 2.0.25 spec pg 127 states that if the value of FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE
// is NONE, then querying any other pname will generate INVALID_ENUM.
// ES 3.0.2 spec pg 235 states that if the attachment type is none,
// GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME will return zero and be an
// INVALID_OPERATION for all other pnames
switch (pname)
{
case GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE:
*params = GL_NONE;
break;
case GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME:
*params = 0;
break;
default:
UNREACHABLE();
break;
}
return;
}
switch (pname)
{
case GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE:
*params = attachmentObject->type();
break;
case GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME:
*params = attachmentObject->id();
break;
case GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL:
*params = attachmentObject->mipLevel();
break;
case GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE:
*params = attachmentObject->cubeMapFace();
break;
case GL_FRAMEBUFFER_ATTACHMENT_RED_SIZE:
*params = attachmentObject->getRedSize();
break;
case GL_FRAMEBUFFER_ATTACHMENT_GREEN_SIZE:
*params = attachmentObject->getGreenSize();
break;
case GL_FRAMEBUFFER_ATTACHMENT_BLUE_SIZE:
*params = attachmentObject->getBlueSize();
break;
case GL_FRAMEBUFFER_ATTACHMENT_ALPHA_SIZE:
*params = attachmentObject->getAlphaSize();
break;
case GL_FRAMEBUFFER_ATTACHMENT_DEPTH_SIZE:
*params = attachmentObject->getDepthSize();
break;
case GL_FRAMEBUFFER_ATTACHMENT_STENCIL_SIZE:
*params = attachmentObject->getStencilSize();
break;
case GL_FRAMEBUFFER_ATTACHMENT_COMPONENT_TYPE:
*params = attachmentObject->getComponentType();
break;
case GL_FRAMEBUFFER_ATTACHMENT_COLOR_ENCODING:
*params = attachmentObject->getColorEncoding();
break;
case GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LAYER:
*params = attachmentObject->layer();
break;
default:
UNREACHABLE();
break;
}
}
void QueryBufferParameteriv(const Buffer *buffer, GLenum pname, GLint *params)
{
QueryBufferParameterBase(buffer, pname, params);
}
void QueryBufferParameteri64v(const Buffer *buffer, GLenum pname, GLint64 *params)
{
QueryBufferParameterBase(buffer, pname, params);
}
void QueryBufferPointerv(const Buffer *buffer, GLenum pname, void **params)
{
switch (pname)
{
case GL_BUFFER_MAP_POINTER:
*params = buffer->getMapPointer();
break;
default:
UNREACHABLE();
break;
}
}
void QueryProgramiv(const Program *program, GLenum pname, GLint *params)
{
ASSERT(program != nullptr);
switch (pname)
{
case GL_DELETE_STATUS:
*params = program->isFlaggedForDeletion();
return;
case GL_LINK_STATUS:
*params = program->isLinked();
return;
case GL_VALIDATE_STATUS:
*params = program->isValidated();
return;
case GL_INFO_LOG_LENGTH:
*params = program->getInfoLogLength();
return;
case GL_ATTACHED_SHADERS:
*params = program->getAttachedShadersCount();
return;
case GL_ACTIVE_ATTRIBUTES:
*params = program->getActiveAttributeCount();
return;
case GL_ACTIVE_ATTRIBUTE_MAX_LENGTH:
*params = program->getActiveAttributeMaxLength();
return;
case GL_ACTIVE_UNIFORMS:
*params = program->getActiveUniformCount();
return;
case GL_ACTIVE_UNIFORM_MAX_LENGTH:
*params = program->getActiveUniformMaxLength();
return;
case GL_PROGRAM_BINARY_LENGTH_OES:
*params = program->getBinaryLength();
return;
case GL_ACTIVE_UNIFORM_BLOCKS:
*params = program->getActiveUniformBlockCount();
return;
case GL_ACTIVE_UNIFORM_BLOCK_MAX_NAME_LENGTH:
*params = program->getActiveUniformBlockMaxLength();
break;
case GL_TRANSFORM_FEEDBACK_BUFFER_MODE:
*params = program->getTransformFeedbackBufferMode();
break;
case GL_TRANSFORM_FEEDBACK_VARYINGS:
*params = program->getTransformFeedbackVaryingCount();
break;
case GL_TRANSFORM_FEEDBACK_VARYING_MAX_LENGTH:
*params = program->getTransformFeedbackVaryingMaxLength();
break;
case GL_PROGRAM_BINARY_RETRIEVABLE_HINT:
*params = program->getBinaryRetrievableHint();
break;
default:
UNREACHABLE();
break;
}
}
void QueryRenderbufferiv(const Renderbuffer *renderbuffer, GLenum pname, GLint *params)
{
ASSERT(renderbuffer != nullptr);
switch (pname)
{
case GL_RENDERBUFFER_WIDTH:
*params = renderbuffer->getWidth();
break;
case GL_RENDERBUFFER_HEIGHT:
*params = renderbuffer->getHeight();
break;
case GL_RENDERBUFFER_INTERNAL_FORMAT:
*params = renderbuffer->getFormat().info->internalFormat;
break;
case GL_RENDERBUFFER_RED_SIZE:
*params = renderbuffer->getRedSize();
break;
case GL_RENDERBUFFER_GREEN_SIZE:
*params = renderbuffer->getGreenSize();
break;
case GL_RENDERBUFFER_BLUE_SIZE:
*params = renderbuffer->getBlueSize();
break;
case GL_RENDERBUFFER_ALPHA_SIZE:
*params = renderbuffer->getAlphaSize();
break;
case GL_RENDERBUFFER_DEPTH_SIZE:
*params = renderbuffer->getDepthSize();
break;
case GL_RENDERBUFFER_STENCIL_SIZE:
*params = renderbuffer->getStencilSize();
break;
case GL_RENDERBUFFER_SAMPLES_ANGLE:
*params = renderbuffer->getSamples();
break;
default:
UNREACHABLE();
break;
}
}
void QueryShaderiv(const Shader *shader, GLenum pname, GLint *params)
{
ASSERT(shader != nullptr);
switch (pname)
{
case GL_SHADER_TYPE:
*params = shader->getType();
return;
case GL_DELETE_STATUS:
*params = shader->isFlaggedForDeletion();
return;
case GL_COMPILE_STATUS:
*params = shader->isCompiled() ? GL_TRUE : GL_FALSE;
return;
case GL_INFO_LOG_LENGTH:
*params = shader->getInfoLogLength();
return;
case GL_SHADER_SOURCE_LENGTH:
*params = shader->getSourceLength();
return;
case GL_TRANSLATED_SHADER_SOURCE_LENGTH_ANGLE:
*params = shader->getTranslatedSourceWithDebugInfoLength();
return;
default:
UNREACHABLE();
break;
}
}
void QueryTexParameterfv(const Texture *texture, GLenum pname, GLfloat *params)
{
QueryTexParameterBase(texture, pname, params);
}
void QueryTexParameteriv(const Texture *texture, GLenum pname, GLint *params)
{
QueryTexParameterBase(texture, pname, params);
}
void QuerySamplerParameterfv(const Sampler *sampler, GLenum pname, GLfloat *params)
{
QuerySamplerParameterBase(sampler, pname, params);
}
void QuerySamplerParameteriv(const Sampler *sampler, GLenum pname, GLint *params)
{
QuerySamplerParameterBase(sampler, pname, params);
}
void QueryVertexAttribfv(const VertexAttribute &attrib,
const VertexAttribCurrentValueData ¤tValueData,
GLenum pname,
GLfloat *params)
{
QueryVertexAttribBase(attrib, currentValueData.FloatValues, pname, params);
}
void QueryVertexAttribiv(const VertexAttribute &attrib,
const VertexAttribCurrentValueData ¤tValueData,
GLenum pname,
GLint *params)
{
QueryVertexAttribBase(attrib, currentValueData.FloatValues, pname, params);
}
void QueryVertexAttribPointerv(const VertexAttribute &attrib, GLenum pname, GLvoid **pointer)
{
switch (pname)
{
case GL_VERTEX_ATTRIB_ARRAY_POINTER:
*pointer = const_cast<GLvoid *>(attrib.pointer);
break;
default:
UNREACHABLE();
break;
}
}
void QueryVertexAttribIiv(const VertexAttribute &attrib,
const VertexAttribCurrentValueData ¤tValueData,
GLenum pname,
GLint *params)
{
QueryVertexAttribBase(attrib, currentValueData.IntValues, pname, params);
}
void QueryVertexAttribIuiv(const VertexAttribute &attrib,
const VertexAttribCurrentValueData ¤tValueData,
GLenum pname,
GLuint *params)
{
QueryVertexAttribBase(attrib, currentValueData.UnsignedIntValues, pname, params);
}
void QueryActiveUniformBlockiv(const Program *program,
GLuint uniformBlockIndex,
GLenum pname,
GLint *params)
{
const UniformBlock &uniformBlock = program->getUniformBlockByIndex(uniformBlockIndex);
switch (pname)
{
case GL_UNIFORM_BLOCK_BINDING:
*params = ConvertToGLint(program->getUniformBlockBinding(uniformBlockIndex));
break;
case GL_UNIFORM_BLOCK_DATA_SIZE:
*params = ConvertToGLint(uniformBlock.dataSize);
break;
case GL_UNIFORM_BLOCK_NAME_LENGTH:
*params = ConvertToGLint(uniformBlock.nameWithArrayIndex().size() + 1);
break;
case GL_UNIFORM_BLOCK_ACTIVE_UNIFORMS:
*params = ConvertToGLint(uniformBlock.memberUniformIndexes.size());
break;
case GL_UNIFORM_BLOCK_ACTIVE_UNIFORM_INDICES:
for (size_t blockMemberIndex = 0;
blockMemberIndex < uniformBlock.memberUniformIndexes.size(); blockMemberIndex++)
{
params[blockMemberIndex] =
ConvertToGLint(uniformBlock.memberUniformIndexes[blockMemberIndex]);
}
break;
case GL_UNIFORM_BLOCK_REFERENCED_BY_VERTEX_SHADER:
*params = ConvertToGLint(uniformBlock.vertexStaticUse);
break;
case GL_UNIFORM_BLOCK_REFERENCED_BY_FRAGMENT_SHADER:
*params = ConvertToGLint(uniformBlock.fragmentStaticUse);
break;
default:
UNREACHABLE();
break;
}
}
void QueryInternalFormativ(const TextureCaps &format, GLenum pname, GLsizei bufSize, GLint *params)
{
switch (pname)
{
case GL_NUM_SAMPLE_COUNTS:
if (bufSize != 0)
{
*params = static_cast<GLint>(format.sampleCounts.size());
}
break;
case GL_SAMPLES:
{
size_t returnCount = std::min<size_t>(bufSize, format.sampleCounts.size());
auto sampleReverseIt = format.sampleCounts.rbegin();
for (size_t sampleIndex = 0; sampleIndex < returnCount; ++sampleIndex)
{
params[sampleIndex] = *sampleReverseIt++;
}
}
break;
default:
UNREACHABLE();
break;
}
}
void SetTexParameterf(Texture *texture, GLenum pname, GLfloat param)
{
SetTexParameterBase(texture, pname, ¶m);
}
void SetTexParameterfv(Texture *texture, GLenum pname, const GLfloat *params)
{
SetTexParameterBase(texture, pname, params);
}
void SetTexParameteri(Texture *texture, GLenum pname, GLint param)
{
SetTexParameterBase(texture, pname, ¶m);
}
void SetTexParameteriv(Texture *texture, GLenum pname, const GLint *params)
{
SetTexParameterBase(texture, pname, params);
}
void SetSamplerParameterf(Sampler *sampler, GLenum pname, GLfloat param)
{
SetSamplerParameterBase(sampler, pname, ¶m);
}
void SetSamplerParameterfv(Sampler *sampler, GLenum pname, const GLfloat *params)
{
SetSamplerParameterBase(sampler, pname, params);
}
void SetSamplerParameteri(Sampler *sampler, GLenum pname, GLint param)
{
SetSamplerParameterBase(sampler, pname, ¶m);
}
void SetSamplerParameteriv(Sampler *sampler, GLenum pname, const GLint *params)
{
SetSamplerParameterBase(sampler, pname, params);
}
}
|