blob: 51803389228d9e9ffde8c6f659df1381b3f8901c [file] [log] [blame]
keunyoungb85b2752013-03-08 12:28:03 -08001/*
2* Copyright (C) 2011 The Android Open Source Project
3*
4* Licensed under the Apache License, Version 2.0 (the "License");
5* you may not use this file except in compliance with the License.
6* You may obtain a copy of the License at
7*
8* http://www.apache.org/licenses/LICENSE-2.0
9*
10* Unless required by applicable law or agreed to in writing, software
11* distributed under the License is distributed on an "AS IS" BASIS,
12* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13* See the License for the specific language governing permissions and
14* limitations under the License.
15*/
16#ifndef _GL_CLIENT_STATE_H_
17#define _GL_CLIENT_STATE_H_
18
19#define GL_API
20#ifndef ANDROID
21#define GL_APIENTRY
22#define GL_APIENTRYP
23#endif
24
Lingfeng Yang74e29292017-01-10 14:54:38 -080025#include "TextureSharedData.h"
26
keunyoungb85b2752013-03-08 12:28:03 -080027#include <GLES/gl.h>
28#include <GLES/glext.h>
29#include <GLES2/gl2.h>
30#include <GLES2/gl2ext.h>
31
32#include <stdio.h>
33#include <stdlib.h>
34#include "ErrorLog.h"
35#include "codec_defs.h"
36
Lingfeng Yang57cb41b2016-04-08 14:42:34 -070037#include <vector>
Lingfeng Yang74e29292017-01-10 14:54:38 -080038#include <map>
Lingfeng Yange00ec9d2016-09-16 08:54:03 -070039#include <set>
Lingfeng Yang57cb41b2016-04-08 14:42:34 -070040
41// Tracking framebuffer objects:
42// which framebuffer is bound,
43// and which texture names
44// are currently bound to which attachment points.
45struct FboProps {
Lingfeng Yang57cb41b2016-04-08 14:42:34 -070046 GLuint name;
47 bool previouslyBound;
Lingfeng Yang35d5f3b2017-01-09 13:23:25 -080048 std::vector<GLuint> colorAttachmenti_textures;
Lingfeng Yang57cb41b2016-04-08 14:42:34 -070049 GLuint depthAttachment_texture;
50 GLuint stencilAttachment_texture;
Lingfeng Yang35d5f3b2017-01-09 13:23:25 -080051 GLuint depthstencilAttachment_texture;
Lingfeng Yang57cb41b2016-04-08 14:42:34 -070052
Lingfeng Yang35d5f3b2017-01-09 13:23:25 -080053 std::vector<bool> colorAttachmenti_hasTex;
Lingfeng Yang57cb41b2016-04-08 14:42:34 -070054 bool depthAttachment_hasTexObj;
55 bool stencilAttachment_hasTexObj;
Lingfeng Yang35d5f3b2017-01-09 13:23:25 -080056 bool depthstencilAttachment_hasTexObj;
Lingfeng Yang57cb41b2016-04-08 14:42:34 -070057
Lingfeng Yang35d5f3b2017-01-09 13:23:25 -080058 std::vector<GLuint> colorAttachmenti_rbos;
Lingfeng Yang57cb41b2016-04-08 14:42:34 -070059 GLuint depthAttachment_rbo;
60 GLuint stencilAttachment_rbo;
Lingfeng Yang35d5f3b2017-01-09 13:23:25 -080061 GLuint depthstencilAttachment_rbo;
Lingfeng Yang57cb41b2016-04-08 14:42:34 -070062
Lingfeng Yang35d5f3b2017-01-09 13:23:25 -080063 std::vector<bool> colorAttachmenti_hasRbo;
Lingfeng Yang57cb41b2016-04-08 14:42:34 -070064 bool depthAttachment_hasRbo;
65 bool stencilAttachment_hasRbo;
Lingfeng Yang35d5f3b2017-01-09 13:23:25 -080066 bool depthstencilAttachment_hasRbo;
Lingfeng Yang57cb41b2016-04-08 14:42:34 -070067};
68
69// Same for Rbo's
70struct RboProps {
71 GLenum target;
72 GLuint name;
Lingfeng Yang69066602016-04-12 09:29:11 -070073 GLenum format;
Lingfeng Yang35d5f3b2017-01-09 13:23:25 -080074 GLsizei multisamples;
Lingfeng Yang57cb41b2016-04-08 14:42:34 -070075 bool previouslyBound;
76};
77
Lingfeng Yang69066602016-04-12 09:29:11 -070078// Enum for describing whether a framebuffer attachment
79// is a texture or renderbuffer.
80enum FboAttachmentType {
81 FBO_ATTACHMENT_RENDERBUFFER = 0,
82 FBO_ATTACHMENT_TEXTURE = 1,
83 FBO_ATTACHMENT_NONE = 2
84};
85
86// Tracking FBO format
87struct FboFormatInfo {
88 FboAttachmentType type;
89 GLenum rb_format;
Lingfeng Yang35d5f3b2017-01-09 13:23:25 -080090 GLsizei rb_multisamples;
91
Lingfeng Yang69066602016-04-12 09:29:11 -070092 GLint tex_internalformat;
93 GLenum tex_format;
94 GLenum tex_type;
Lingfeng Yang74e29292017-01-10 14:54:38 -080095 GLsizei tex_multisamples;
Lingfeng Yang69066602016-04-12 09:29:11 -070096};
97
keunyoungb85b2752013-03-08 12:28:03 -080098class GLClientState {
99public:
100 typedef enum {
101 VERTEX_LOCATION = 0,
102 NORMAL_LOCATION = 1,
103 COLOR_LOCATION = 2,
104 POINTSIZE_LOCATION = 3,
105 TEXCOORD0_LOCATION = 4,
106 TEXCOORD1_LOCATION = 5,
107 TEXCOORD2_LOCATION = 6,
108 TEXCOORD3_LOCATION = 7,
109 TEXCOORD4_LOCATION = 8,
110 TEXCOORD5_LOCATION = 9,
111 TEXCOORD6_LOCATION = 10,
112 TEXCOORD7_LOCATION = 11,
113 MATRIXINDEX_LOCATION = 12,
114 WEIGHT_LOCATION = 13,
115 LAST_LOCATION = 14
116 } StateLocation;
117
118 typedef struct {
119 GLint enabled;
120 GLint size;
121 GLenum type;
122 GLsizei stride;
123 void *data;
Lingfeng Yangf654f3f2017-01-09 13:12:33 -0800124 GLuint reloffset;
keunyoungb85b2752013-03-08 12:28:03 -0800125 GLuint bufferObject;
126 GLenum glConst;
127 unsigned int elementSize;
128 bool enableDirty; // true if any enable state has changed since last draw
129 bool normalized;
Lingfeng Yangf654f3f2017-01-09 13:12:33 -0800130 GLuint divisor;
131 bool isInt;
132 int bindingindex;
keunyoungb85b2752013-03-08 12:28:03 -0800133 } VertexAttribState;
134
Lingfeng Yangf654f3f2017-01-09 13:12:33 -0800135 struct BufferBinding {
136 GLintptr offset;
137 GLintptr stride;
138 GLintptr effectiveStride;
139 GLsizeiptr size;
140 GLuint buffer;
141 GLuint divisor;
Lingfeng Yang9a2fa6f2019-11-08 09:41:17 -0800142 GLint vertexAttribLoc;
Lingfeng Yangf654f3f2017-01-09 13:12:33 -0800143 };
144
145 typedef std::vector<VertexAttribState> VertexAttribStateVector;
146 typedef std::vector<BufferBinding> VertexAttribBindingVector;
147
148 struct VAOState {
149 VAOState(GLuint ibo, int nLoc, int nBindings) :
Lingfeng Yangf654f3f2017-01-09 13:12:33 -0800150 attribState(nLoc),
Matt Wachowskidfbc1b32018-08-10 12:50:40 -0700151 bindingState(nBindings),
Lingfeng Yang554a5152019-02-21 20:20:48 -0800152 element_array_buffer_binding(ibo),
153 element_array_buffer_binding_lastEncode(ibo) { }
Lingfeng Yangf654f3f2017-01-09 13:12:33 -0800154 VertexAttribStateVector attribState;
155 VertexAttribBindingVector bindingState;
156 GLuint element_array_buffer_binding;
Lingfeng Yang554a5152019-02-21 20:20:48 -0800157 GLuint element_array_buffer_binding_lastEncode;
158 int attributesNeedingUpdateForDraw[CODEC_MAX_VERTEX_ATTRIBUTES];
159 int numAttributesNeedingUpdateForDraw;
Lingfeng Yangf654f3f2017-01-09 13:12:33 -0800160 };
161
162 typedef std::map<GLuint, VAOState> VAOStateMap;
163 struct VAOStateRef {
164 VAOStateRef() { }
165 VAOStateRef(
166 VAOStateMap::iterator iter) : it(iter) { }
Lingfeng Yang554a5152019-02-21 20:20:48 -0800167 VAOState& vaoState() { return it->second; }
Lingfeng Yangf654f3f2017-01-09 13:12:33 -0800168 VertexAttribState& operator[](size_t k) { return it->second.attribState[k]; }
169 BufferBinding& bufferBinding(size_t k) { return it->second.bindingState[k]; }
170 VertexAttribBindingVector& bufferBindings() { return it->second.bindingState; }
171 const VertexAttribBindingVector& bufferBindings_const() const { return it->second.bindingState; }
172 GLuint vaoId() const { return it->first; }
173 GLuint& iboId() { return it->second.element_array_buffer_binding; }
Lingfeng Yang554a5152019-02-21 20:20:48 -0800174 GLuint& iboIdLastEncode() { return it->second.element_array_buffer_binding_lastEncode; }
Lingfeng Yangf654f3f2017-01-09 13:12:33 -0800175 VAOStateMap::iterator it;
176 };
177
keunyoungb85b2752013-03-08 12:28:03 -0800178 typedef struct {
179 int unpack_alignment;
Lingfeng Yang74e29292017-01-10 14:54:38 -0800180
181 int unpack_row_length;
182 int unpack_image_height;
183 int unpack_skip_pixels;
184 int unpack_skip_rows;
185 int unpack_skip_images;
186
keunyoungb85b2752013-03-08 12:28:03 -0800187 int pack_alignment;
Lingfeng Yang74e29292017-01-10 14:54:38 -0800188
189 int pack_row_length;
190 int pack_skip_pixels;
191 int pack_skip_rows;
keunyoungb85b2752013-03-08 12:28:03 -0800192 } PixelStoreState;
193
194 enum {
Lingfeng Yang74e29292017-01-10 14:54:38 -0800195 MAX_TEXTURE_UNITS = 256,
keunyoungb85b2752013-03-08 12:28:03 -0800196 };
197
198public:
Lingfeng Yangf654f3f2017-01-09 13:12:33 -0800199 GLClientState();
200 GLClientState(int majorVersion, int minorVersion);
keunyoungb85b2752013-03-08 12:28:03 -0800201 ~GLClientState();
202 int nLocations() { return m_nLocations; }
203 const PixelStoreState *pixelStoreState() { return &m_pixelStore; }
204 int setPixelStore(GLenum param, GLint value);
Lingfeng Yangf654f3f2017-01-09 13:12:33 -0800205 GLuint currentVertexArrayObject() const { return m_currVaoState.vaoId(); }
Lingfeng Yangd3ae1062017-01-18 11:42:04 -0800206 const VertexAttribBindingVector& currentVertexBufferBindings() const {
207 return m_currVaoState.bufferBindings_const();
208 }
209
Lingfeng Yangf654f3f2017-01-09 13:12:33 -0800210 GLuint currentArrayVbo() { return m_arrayBuffer; }
211 GLuint currentIndexVbo() { return m_currVaoState.iboId(); }
keunyoungb85b2752013-03-08 12:28:03 -0800212 void enable(int location, int state);
Lingfeng Yangf654f3f2017-01-09 13:12:33 -0800213 // Vertex array objects and vertex attributes
214 void addVertexArrayObjects(GLsizei n, GLuint* arrays);
215 void removeVertexArrayObjects(GLsizei n, const GLuint* arrays);
216 void addVertexArrayObject(GLuint name);
217 void removeVertexArrayObject(GLuint name);
218 void setVertexArrayObject(GLuint vao);
219 bool isVertexArrayObject(GLuint vao) const;
220 void setVertexAttribState(int location, int size, GLenum type, GLboolean normalized, GLsizei stride, const void *data, bool isInt = false);
221 void setVertexBindingDivisor(int bindingindex, GLuint divisor);
222 const BufferBinding& getCurrAttributeBindingInfo(int attribindex);
223 void setVertexAttribBinding(int attribindex, int bindingindex);
224 void setVertexAttribFormat(int location, int size, GLenum type, GLboolean normalized, GLuint reloffset, bool isInt = false);
Lingfeng Yang9a2fa6f2019-11-08 09:41:17 -0800225 void getVBOUsage(bool* hasClientArrays, bool* hasVBOs);
Lingfeng Yangf654f3f2017-01-09 13:12:33 -0800226 const VertexAttribState& getState(int location);
227 const VertexAttribState& getStateAndEnableDirty(int location, bool *enableChanged);
Lingfeng Yang554a5152019-02-21 20:20:48 -0800228 void updateEnableDirtyArrayForDraw();
229 VAOState& currentVaoState();
keunyoungb85b2752013-03-08 12:28:03 -0800230 int getLocation(GLenum loc);
231 void setActiveTexture(int texUnit) {m_activeTexture = texUnit; };
232 int getActiveTexture() const { return m_activeTexture; }
Lingfeng Yangb0176982016-03-01 21:27:49 -0800233 void setMaxVertexAttribs(int val) {
234 m_maxVertexAttribs = val;
235 m_maxVertexAttribsDirty = false;
236 }
keunyoungb85b2752013-03-08 12:28:03 -0800237
Lingfeng Yangd3ae1062017-01-18 11:42:04 -0800238 void addBuffer(GLuint id);
239 void removeBuffer(GLuint id);
240 bool bufferIdExists(GLuint id) const;
Lingfeng Yangf654f3f2017-01-09 13:12:33 -0800241 void unBindBuffer(GLuint id);
bohub0f0cdf2014-11-06 18:08:07 -0800242
Lingfeng Yangf654f3f2017-01-09 13:12:33 -0800243 int bindBuffer(GLenum target, GLuint id);
244 void bindIndexedBuffer(GLenum target, GLuint index, GLuint buffer, GLintptr offset, GLsizeiptr size, GLintptr stride, GLintptr effectiveStride);
245 int getMaxIndexedBufferBindings(GLenum target) const;
Lingfeng Yang2c3a0da2019-03-07 20:43:53 -0800246 bool isNonIndexedBindNoOp(GLenum target, GLuint buffer);
Lingfeng Yang554a5152019-02-21 20:20:48 -0800247 bool isIndexedBindNoOp(GLenum target, GLuint index, GLuint buffer, GLintptr offset, GLsizeiptr size, GLintptr stride, GLintptr effectiveStride);
keunyoungb85b2752013-03-08 12:28:03 -0800248
Lingfeng Yangf654f3f2017-01-09 13:12:33 -0800249 int getBuffer(GLenum target);
Lingfeng Yang554a5152019-02-21 20:20:48 -0800250 GLuint getLastEncodedBufferBind(GLenum target);
251 void setLastEncodedBufferBind(GLenum target, GLuint id);
Lingfeng Yangf654f3f2017-01-09 13:12:33 -0800252
Lingfeng Yang74e29292017-01-10 14:54:38 -0800253 size_t pixelDataSize(GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, int pack) const;
254 size_t pboNeededDataSize(GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, int pack) const;
255 size_t clearBufferNumElts(GLenum buffer) const;
Lingfeng Yang22dc42d2018-05-29 10:11:38 -0700256 void getPackingOffsets2D(GLsizei width, GLsizei height, GLenum format, GLenum type, int* startOffset, int* pixelRowSize, int* totalRowSize, int* skipRows) const;
keunyoungb85b2752013-03-08 12:28:03 -0800257
258 void setCurrentProgram(GLint program) { m_currentProgram = program; }
Lingfeng Yangd3ae1062017-01-18 11:42:04 -0800259 void setCurrentShaderProgram(GLint program) { m_currentShaderProgram = program; }
keunyoungb85b2752013-03-08 12:28:03 -0800260 GLint currentProgram() const { return m_currentProgram; }
Lingfeng Yangd3ae1062017-01-18 11:42:04 -0800261 GLint currentShaderProgram() const { return m_currentShaderProgram; }
keunyoungb85b2752013-03-08 12:28:03 -0800262
Lingfeng Yangf654f3f2017-01-09 13:12:33 -0800263 struct UniformBlockInfoKey {
264 GLuint program;
265 GLuint uniformBlockIndex;
266 };
267 struct UniformBlockInfoKeyCompare {
268 bool operator() (const UniformBlockInfoKey& a,
269 const UniformBlockInfoKey& b) const {
270 if (a.program != b.program) return a.program < b.program;
271 if (a.uniformBlockIndex != b.uniformBlockIndex) return a.uniformBlockIndex < b.uniformBlockIndex;
272 return false;
273 }
274 };
275 struct UniformBlockUniformInfo {
276 size_t numActiveUniforms;
277 };
278
279 typedef std::map<UniformBlockInfoKey, UniformBlockUniformInfo, UniformBlockInfoKeyCompare> UniformBlockInfoMap;
280 UniformBlockInfoMap m_uniformBlockInfoMap;
281
Lingfeng Yange6556dc2017-01-09 12:04:12 -0800282 void setNumActiveUniformsInUniformBlock(GLuint program, GLuint uniformBlockIndex, GLint numActiveUniforms);
283 size_t numActiveUniformsInUniformBlock(GLuint program, GLuint uniformBlockIndex) const;
Lingfeng Yangb3dc29f2017-01-09 13:25:31 -0800284
285 typedef std::map<GLuint, GLuint> ProgramPipelineMap;
286 typedef ProgramPipelineMap::iterator ProgramPipelineIterator;
287 void associateProgramWithPipeline(GLuint program, GLuint pipeline);
288 ProgramPipelineIterator programPipelineBegin();
289 ProgramPipelineIterator programPipelineEnd();
290
keunyoungb85b2752013-03-08 12:28:03 -0800291 /* OES_EGL_image_external
292 *
293 * These functions manipulate GL state which interacts with the
294 * OES_EGL_image_external extension, to support client-side emulation on
295 * top of host implementations that don't have it.
296 *
297 * Most of these calls should only be used with TEXTURE_2D or
298 * TEXTURE_EXTERNAL_OES texture targets; TEXTURE_CUBE_MAP or other extension
299 * targets should bypass this. An exception is bindTexture(), which should
300 * see all glBindTexture() calls for any target.
301 */
302
303 // glActiveTexture(GL_TEXTURE0 + i)
304 // Sets the active texture unit. Up to MAX_TEXTURE_UNITS are supported.
305 GLenum setActiveTextureUnit(GLenum texture);
306 GLenum getActiveTextureUnit() const;
307
308 // glEnable(GL_TEXTURE_(2D|EXTERNAL_OES))
309 void enableTextureTarget(GLenum target);
310
311 // glDisable(GL_TEXTURE_(2D|EXTERNAL_OES))
312 void disableTextureTarget(GLenum target);
313
Lingfeng Yang554a5152019-02-21 20:20:48 -0800314 void bindSampler(GLuint unit, GLuint sampler);
315 bool isSamplerBindNoOp(GLuint unit, GLuint sampler);
316 void onDeleteSamplers(GLsizei n, const GLuint* samplers);
317
keunyoungb85b2752013-03-08 12:28:03 -0800318 // Implements the target priority logic:
319 // * Return GL_TEXTURE_EXTERNAL_OES if enabled, else
320 // * Return GL_TEXTURE_2D if enabled, else
321 // * Return the allDisabled value.
322 // For some cases passing GL_TEXTURE_2D for allDisabled makes callee code
323 // simpler; for other cases passing a recognizable enum like GL_ZERO or
324 // GL_INVALID_ENUM is appropriate.
325 GLenum getPriorityEnabledTarget(GLenum allDisabled) const;
326
327 // glBindTexture(GL_TEXTURE_*, ...)
328 // Set the target binding of the active texture unit to texture. Returns
329 // GL_NO_ERROR on success or GL_INVALID_OPERATION if the texture has
330 // previously been bound to a different target. If firstUse is not NULL,
331 // it is set to indicate whether this is the first use of the texture.
332 // For accurate error detection, bindTexture should be called for *all*
333 // targets, not just 2D and EXTERNAL_OES.
334 GLenum bindTexture(GLenum target, GLuint texture, GLboolean* firstUse);
Lingfeng Yang74e29292017-01-10 14:54:38 -0800335 void setBoundEGLImage(GLenum target, GLeglImageOES image);
keunyoungb85b2752013-03-08 12:28:03 -0800336
337 // Return the texture currently bound to GL_TEXTURE_(2D|EXTERNAL_OES).
338 GLuint getBoundTexture(GLenum target) const;
Lingfeng Yang74e29292017-01-10 14:54:38 -0800339 // Other publicly-visible texture queries
340 GLenum queryTexLastBoundTarget(GLuint name) const;
341 GLenum queryTexFormat(GLuint name) const;
342 GLint queryTexInternalFormat(GLuint name) const;
343 GLsizei queryTexWidth(GLsizei level, GLuint name) const;
344 GLsizei queryTexHeight(GLsizei level, GLuint name) const;
345 GLsizei queryTexDepth(GLsizei level, GLuint name) const;
346 bool queryTexEGLImageBacked(GLuint name) const;
keunyoungb85b2752013-03-08 12:28:03 -0800347
Lingfeng Yange00ec9d2016-09-16 08:54:03 -0700348 // For AMD GPUs, it is easy for the emulator to segfault
349 // (esp. in dEQP) when a cube map is defined using glCopyTexImage2D
350 // and uses GL_LUMINANCE as internal format.
351 // In particular, the segfault happens when negative components of
352 // cube maps are defined before positive ones,
353 // This procedure checks internal state to see if we have defined
354 // the positive component of a cube map already. If not, it returns
355 // which positive component needs to be defined first.
356 // If there is no need for the extra definition, 0 is returned.
357 GLenum copyTexImageLuminanceCubeMapAMDWorkaround(GLenum target, GLint level,
358 GLenum internalformat);
359
Lingfeng Yang69066602016-04-12 09:29:11 -0700360 // Tracks the format of the currently bound texture.
361 // This is to pass dEQP tests for fbo completeness.
362 void setBoundTextureInternalFormat(GLenum target, GLint format);
363 void setBoundTextureFormat(GLenum target, GLenum format);
364 void setBoundTextureType(GLenum target, GLenum type);
Lingfeng Yang74e29292017-01-10 14:54:38 -0800365 void setBoundTextureDims(GLenum target, GLsizei level, GLsizei width, GLsizei height, GLsizei depth);
366 void setBoundTextureSamples(GLenum target, GLsizei samples);
367
368 // glTexStorage2D disallows any change in texture format after it is set for a particular texture.
369 void setBoundTextureImmutableFormat(GLenum target);
370 bool isBoundTextureImmutableFormat(GLenum target) const;
Lingfeng Yang69066602016-04-12 09:29:11 -0700371
keunyoungb85b2752013-03-08 12:28:03 -0800372 // glDeleteTextures(...)
373 // Remove references to the to-be-deleted textures.
374 void deleteTextures(GLsizei n, const GLuint* textures);
375
Lingfeng Yang57cb41b2016-04-08 14:42:34 -0700376 // Render buffer objects
377 void addRenderbuffers(GLsizei n, GLuint* renderbuffers);
378 void removeRenderbuffers(GLsizei n, const GLuint* renderbuffers);
379 bool usedRenderbufferName(GLuint name) const;
380 void bindRenderbuffer(GLenum target, GLuint name);
381 GLuint boundRenderbuffer() const;
Lingfeng Yang69066602016-04-12 09:29:11 -0700382 void setBoundRenderbufferFormat(GLenum format);
Lingfeng Yang35d5f3b2017-01-09 13:23:25 -0800383 void setBoundRenderbufferSamples(GLsizei samples);
Lingfeng Yang57cb41b2016-04-08 14:42:34 -0700384
385 // Frame buffer objects
386 void addFramebuffers(GLsizei n, GLuint* framebuffers);
387 void removeFramebuffers(GLsizei n, const GLuint* framebuffers);
388 bool usedFramebufferName(GLuint name) const;
389 void bindFramebuffer(GLenum target, GLuint name);
Lingfeng Yang35d5f3b2017-01-09 13:23:25 -0800390 void setCheckFramebufferStatus(GLenum target, GLenum status);
391 GLenum getCheckFramebufferStatus(GLenum target) const;
392 GLuint boundFramebuffer(GLenum target) const;
Lingfeng Yang57cb41b2016-04-08 14:42:34 -0700393
394 // Texture object -> FBO
Lingfeng Yang35d5f3b2017-01-09 13:23:25 -0800395 void attachTextureObject(GLenum target, GLenum attachment, GLuint texture);
396 GLuint getFboAttachmentTextureId(GLenum target, GLenum attachment) const;
Lingfeng Yang57cb41b2016-04-08 14:42:34 -0700397
398 // RBO -> FBO
Lingfeng Yang35d5f3b2017-01-09 13:23:25 -0800399 void detachRbo(GLuint renderbuffer);
400 void detachRboFromFbo(GLenum target, GLenum attachment, GLuint renderbuffer);
401 void attachRbo(GLenum target, GLenum attachment, GLuint renderbuffer);
402 GLuint getFboAttachmentRboId(GLenum target, GLenum attachment) const;
Lingfeng Yang57cb41b2016-04-08 14:42:34 -0700403
404 // FBO attachments in general
Lingfeng Yang35d5f3b2017-01-09 13:23:25 -0800405 bool attachmentHasObject(GLenum target, GLenum attachment) const;
406 GLuint objectOfAttachment(GLenum target, GLenum attachment) const;
407
Lingfeng Yang4a66b312017-01-09 13:27:49 -0800408 // Transform feedback state
409 void setTransformFeedbackActiveUnpaused(bool activeUnpaused);
410 bool getTransformFeedbackActiveUnpaused() const;
Lingfeng Yang57cb41b2016-04-08 14:42:34 -0700411
Lingfeng Yang74e29292017-01-10 14:54:38 -0800412 void setTextureData(SharedTextureDataMap* sharedTexData);
Lingfeng Yang57cb41b2016-04-08 14:42:34 -0700413 // set eglsurface property on default framebuffer
414 // if coming from eglMakeCurrent
415 void fromMakeCurrent();
Lingfeng Yangf654f3f2017-01-09 13:12:33 -0800416 // set indexed buffer state.
417 // We need to query the underlying OpenGL to get
418 // accurate values for indexed buffers
419 // and # render targets.
420 void initFromCaps(
421 int max_transform_feedback_separate_attribs,
422 int max_uniform_buffer_bindings,
423 int max_atomic_counter_buffer_bindings,
424 int max_shader_storage_buffer_bindings,
425 int max_vertex_attrib_bindings,
426 int max_color_attachments,
427 int max_draw_buffers);
428 bool needsInitFromCaps() const;
Lingfeng Yang57cb41b2016-04-08 14:42:34 -0700429
Lingfeng Yang69066602016-04-12 09:29:11 -0700430 // Queries the format backing the current framebuffer.
431 // Type differs depending on whether the attachment
432 // is a texture or renderbuffer.
433 void getBoundFramebufferFormat(
Lingfeng Yang35d5f3b2017-01-09 13:23:25 -0800434 GLenum target,
435 GLenum attachment,
436 FboFormatInfo* res_info) const;
437 FboAttachmentType getBoundFramebufferAttachmentType(
438 GLenum target,
439 GLenum attachment) const;
440 int getMaxColorAttachments() const;
441 int getMaxDrawBuffers() const;
keunyoungb85b2752013-03-08 12:28:03 -0800442private:
Lingfeng Yangf654f3f2017-01-09 13:12:33 -0800443 void init();
444 bool m_initialized;
keunyoungb85b2752013-03-08 12:28:03 -0800445 PixelStoreState m_pixelStore;
Lingfeng Yangf654f3f2017-01-09 13:12:33 -0800446
Lingfeng Yangd3ae1062017-01-18 11:42:04 -0800447 std::set<GLuint> mBufferIds;
448
Lingfeng Yangf654f3f2017-01-09 13:12:33 -0800449 // GL_ARRAY_BUFFER_BINDING is separate from VAO state
450 GLuint m_arrayBuffer;
Lingfeng Yang554a5152019-02-21 20:20:48 -0800451 GLuint m_arrayBuffer_lastEncode;
Lingfeng Yangf654f3f2017-01-09 13:12:33 -0800452 VAOStateMap m_vaoMap;
453 VAOStateRef m_currVaoState;
454
Lingfeng Yang28a757c2019-11-08 21:37:59 -0800455 uint16_t m_attribEnableCache;
456 uint16_t m_vaoAttribBindingCacheInvalid;
457 uint16_t m_vaoAttribBindingHasClientArrayCache;
458 uint16_t m_vaoAttribBindingHasVboCache;
Lingfeng Yangf8519c12019-11-09 09:35:23 -0800459 uint8_t m_noClientArraysCache;
Lingfeng Yang9a2fa6f2019-11-08 09:41:17 -0800460
Lingfeng Yangf654f3f2017-01-09 13:12:33 -0800461 // Other buffer id's, other targets
462 GLuint m_copyReadBuffer;
463 GLuint m_copyWriteBuffer;
464
465 GLuint m_pixelPackBuffer;
466 GLuint m_pixelUnpackBuffer;
467
468 GLuint m_transformFeedbackBuffer;
469 GLuint m_uniformBuffer;
470
471 GLuint m_atomicCounterBuffer;
472 GLuint m_dispatchIndirectBuffer;
473 GLuint m_drawIndirectBuffer;
474 GLuint m_shaderStorageBuffer;
475
476 bool m_transformFeedbackActiveUnpaused;
477
478 int m_max_transform_feedback_separate_attribs;
479 int m_max_uniform_buffer_bindings;
480 int m_max_atomic_counter_buffer_bindings;
481 int m_max_shader_storage_buffer_bindings;
482 int m_max_vertex_attrib_bindings;
483 std::vector<BufferBinding> m_indexedTransformFeedbackBuffers;
484 std::vector<BufferBinding> m_indexedUniformBuffers;
485 std::vector<BufferBinding> m_indexedAtomicCounterBuffers;
486 std::vector<BufferBinding> m_indexedShaderStorageBuffers;
487
Lingfeng Yang74e29292017-01-10 14:54:38 -0800488 int m_glesMajorVersion;
489 int m_glesMinorVersion;
Lingfeng Yangb0176982016-03-01 21:27:49 -0800490 int m_maxVertexAttribs;
491 bool m_maxVertexAttribsDirty;
keunyoungb85b2752013-03-08 12:28:03 -0800492 int m_nLocations;
keunyoungb85b2752013-03-08 12:28:03 -0800493 int m_activeTexture;
494 GLint m_currentProgram;
Lingfeng Yangd3ae1062017-01-18 11:42:04 -0800495 GLint m_currentShaderProgram;
Lingfeng Yangb3dc29f2017-01-09 13:25:31 -0800496 ProgramPipelineMap m_programPipelines;
keunyoungb85b2752013-03-08 12:28:03 -0800497
keunyoungb85b2752013-03-08 12:28:03 -0800498 enum TextureTarget {
499 TEXTURE_2D = 0,
500 TEXTURE_EXTERNAL = 1,
Lingfeng Yang74e29292017-01-10 14:54:38 -0800501 TEXTURE_CUBE_MAP = 2,
502 TEXTURE_2D_ARRAY = 3,
503 TEXTURE_3D = 4,
504 TEXTURE_2D_MULTISAMPLE = 5,
keunyoungb85b2752013-03-08 12:28:03 -0800505 TEXTURE_TARGET_COUNT
506 };
507 struct TextureUnit {
508 unsigned int enables;
509 GLuint texture[TEXTURE_TARGET_COUNT];
Lingfeng Yang554a5152019-02-21 20:20:48 -0800510 GLuint boundSampler;
keunyoungb85b2752013-03-08 12:28:03 -0800511 };
keunyoungb85b2752013-03-08 12:28:03 -0800512 struct TextureState {
513 TextureUnit unit[MAX_TEXTURE_UNITS];
514 TextureUnit* activeUnit;
Lingfeng Yang74e29292017-01-10 14:54:38 -0800515 // Initialized from shared group.
516 SharedTextureDataMap* textureRecs;
keunyoungb85b2752013-03-08 12:28:03 -0800517 };
518 TextureState m_tex;
519
Lingfeng Yange00ec9d2016-09-16 08:54:03 -0700520 // State tracking of cube map definitions.
521 // Currently used only for driver workarounds
522 // when using GL_LUMINANCE and defining cube maps with
523 // glCopyTexImage2D.
524 struct CubeMapDef {
525 GLuint id;
526 GLenum target;
527 GLint level;
528 GLenum internalformat;
529 };
530 struct CubeMapDefCompare {
531 bool operator() (const CubeMapDef& a,
532 const CubeMapDef& b) const {
533 if (a.id != b.id) return a.id < b.id;
534 if (a.target != b.target) return a.target < b.target;
535 if (a.level != b.level) return a.level < b.level;
536 if (a.internalformat != b.internalformat)
537 return a.internalformat < b.internalformat;
538 return false;
539 }
540 };
541 std::set<CubeMapDef, CubeMapDefCompare> m_cubeMapDefs;
542 void writeCopyTexImageState(GLenum target, GLint level,
543 GLenum internalformat);
544 GLenum copyTexImageNeededTarget(GLenum target, GLint level,
545 GLenum internalformat);
Lingfeng Yang57cb41b2016-04-08 14:42:34 -0700546
Lingfeng Yang35d5f3b2017-01-09 13:23:25 -0800547 int m_max_color_attachments;
548 int m_max_draw_buffers;
Lingfeng Yang57cb41b2016-04-08 14:42:34 -0700549 struct RboState {
550 GLuint boundRenderbuffer;
551 size_t boundRenderbufferIndex;
552 std::vector<RboProps> rboData;
553 };
554 RboState mRboState;
555 void addFreshRenderbuffer(GLuint name);
556 void setBoundRenderbufferIndex();
557 size_t getRboIndex(GLuint name) const;
558 RboProps& boundRboProps();
559 const RboProps& boundRboProps_const() const;
560
561 struct FboState {
Lingfeng Yang35d5f3b2017-01-09 13:23:25 -0800562 GLuint boundDrawFramebuffer;
563 GLuint boundReadFramebuffer;
Lingfeng Yang57cb41b2016-04-08 14:42:34 -0700564 size_t boundFramebufferIndex;
Lingfeng Yang35d5f3b2017-01-09 13:23:25 -0800565 std::map<GLuint, FboProps> fboData;
566 GLenum drawFboCheckStatus;
567 GLenum readFboCheckStatus;
Lingfeng Yang57cb41b2016-04-08 14:42:34 -0700568 };
569 FboState mFboState;
570 void addFreshFramebuffer(GLuint name);
Lingfeng Yang35d5f3b2017-01-09 13:23:25 -0800571 FboProps& boundFboProps(GLenum target);
572 const FboProps& boundFboProps_const(GLenum target) const;
Lingfeng Yang57cb41b2016-04-08 14:42:34 -0700573
Lingfeng Yang69066602016-04-12 09:29:11 -0700574 // Querying framebuffer format
575 GLenum queryRboFormat(GLuint name) const;
Lingfeng Yang35d5f3b2017-01-09 13:23:25 -0800576 GLsizei queryRboSamples(GLuint name) const;
Lingfeng Yang69066602016-04-12 09:29:11 -0700577 GLenum queryTexType(GLuint name) const;
Lingfeng Yang74e29292017-01-10 14:54:38 -0800578 GLsizei queryTexSamples(GLuint name) const;
Lingfeng Yang69066602016-04-12 09:29:11 -0700579
keunyoungb85b2752013-03-08 12:28:03 -0800580 static int compareTexId(const void* pid, const void* prec);
581 TextureRec* addTextureRec(GLuint id, GLenum target);
Lingfeng Yang74e29292017-01-10 14:54:38 -0800582 TextureRec* getTextureRec(GLuint id) const;
keunyoungb85b2752013-03-08 12:28:03 -0800583
584public:
585 void getClientStatePointer(GLenum pname, GLvoid** params);
586
587 template <class T>
588 int getVertexAttribParameter(GLuint index, GLenum param, T *ptr)
589 {
590 bool handled = true;
Lingfeng Yangf654f3f2017-01-09 13:12:33 -0800591 const VertexAttribState& vertexAttrib = getState(index);
592 const BufferBinding& vertexAttribBufferBinding =
593 m_currVaoState.bufferBindings_const()[vertexAttrib.bindingindex];
keunyoungb85b2752013-03-08 12:28:03 -0800594
595 switch(param) {
Lingfeng Yangd3ae1062017-01-18 11:42:04 -0800596#define GL_VERTEX_ATTRIB_BINDING 0x82D4
597 case GL_VERTEX_ATTRIB_BINDING:
598 *ptr = (T)vertexAttrib.bindingindex;
599 break;
600#define GL_VERTEX_ATTRIB_RELATIVE_OFFSET 0x82D5
601 case GL_VERTEX_ATTRIB_RELATIVE_OFFSET:
602 *ptr = (T)vertexAttrib.reloffset;
603 break;
keunyoungb85b2752013-03-08 12:28:03 -0800604 case GL_VERTEX_ATTRIB_ARRAY_BUFFER_BINDING:
Lingfeng Yangf654f3f2017-01-09 13:12:33 -0800605 *ptr = (T)(vertexAttribBufferBinding.buffer);
keunyoungb85b2752013-03-08 12:28:03 -0800606 break;
607 case GL_VERTEX_ATTRIB_ARRAY_ENABLED:
Lingfeng Yangf654f3f2017-01-09 13:12:33 -0800608 *ptr = (T)(vertexAttrib.enabled);
609 break;
610#define GL_VERTEX_ATTRIB_ARRAY_INTEGER 0x88FD
611 case GL_VERTEX_ATTRIB_ARRAY_INTEGER:
612 *ptr = (T)(vertexAttrib.isInt);
keunyoungb85b2752013-03-08 12:28:03 -0800613 break;
614 case GL_VERTEX_ATTRIB_ARRAY_SIZE:
Lingfeng Yangf654f3f2017-01-09 13:12:33 -0800615 *ptr = (T)(vertexAttrib.size);
keunyoungb85b2752013-03-08 12:28:03 -0800616 break;
617 case GL_VERTEX_ATTRIB_ARRAY_STRIDE:
Lingfeng Yangf654f3f2017-01-09 13:12:33 -0800618 *ptr = (T)(vertexAttribBufferBinding.stride);
keunyoungb85b2752013-03-08 12:28:03 -0800619 break;
620 case GL_VERTEX_ATTRIB_ARRAY_TYPE:
Lingfeng Yangf654f3f2017-01-09 13:12:33 -0800621 *ptr = (T)(vertexAttrib.type);
keunyoungb85b2752013-03-08 12:28:03 -0800622 break;
623 case GL_VERTEX_ATTRIB_ARRAY_NORMALIZED:
Lingfeng Yangf654f3f2017-01-09 13:12:33 -0800624 *ptr = (T)(vertexAttrib.normalized);
keunyoungb85b2752013-03-08 12:28:03 -0800625 break;
626 case GL_CURRENT_VERTEX_ATTRIB:
627 handled = false;
628 break;
629 default:
630 handled = false;
631 ERR("unknown vertex-attrib parameter param %d\n", param);
632 }
633 return handled;
634 }
635
636 template <class T>
Lingfeng Yangf654f3f2017-01-09 13:12:33 -0800637 bool getClientStateParameter(GLenum param, T* out)
keunyoungb85b2752013-03-08 12:28:03 -0800638 {
639 bool isClientStateParam = false;
640 switch (param) {
641 case GL_CLIENT_ACTIVE_TEXTURE: {
642 GLint tex = getActiveTexture() + GL_TEXTURE0;
Lingfeng Yangf654f3f2017-01-09 13:12:33 -0800643 *out = tex;
keunyoungb85b2752013-03-08 12:28:03 -0800644 isClientStateParam = true;
645 break;
646 }
647 case GL_VERTEX_ARRAY_SIZE: {
Lingfeng Yangf654f3f2017-01-09 13:12:33 -0800648 const GLClientState::VertexAttribState& state = getState(GLClientState::VERTEX_LOCATION);
649 *out = state.size;
keunyoungb85b2752013-03-08 12:28:03 -0800650 isClientStateParam = true;
651 break;
652 }
653 case GL_VERTEX_ARRAY_TYPE: {
Lingfeng Yangf654f3f2017-01-09 13:12:33 -0800654 const GLClientState::VertexAttribState& state = getState(GLClientState::VERTEX_LOCATION);
655 *out = state.type;
keunyoungb85b2752013-03-08 12:28:03 -0800656 isClientStateParam = true;
657 break;
658 }
659 case GL_VERTEX_ARRAY_STRIDE: {
Lingfeng Yangf654f3f2017-01-09 13:12:33 -0800660 const GLClientState::VertexAttribState& state = getState(GLClientState::VERTEX_LOCATION);
661 *out = state.stride;
keunyoungb85b2752013-03-08 12:28:03 -0800662 isClientStateParam = true;
663 break;
664 }
665 case GL_COLOR_ARRAY_SIZE: {
Lingfeng Yangf654f3f2017-01-09 13:12:33 -0800666 const GLClientState::VertexAttribState& state = getState(GLClientState::COLOR_LOCATION);
667 *out = state.size;
keunyoungb85b2752013-03-08 12:28:03 -0800668 isClientStateParam = true;
669 break;
670 }
671 case GL_COLOR_ARRAY_TYPE: {
Lingfeng Yangf654f3f2017-01-09 13:12:33 -0800672 const GLClientState::VertexAttribState& state = getState(GLClientState::COLOR_LOCATION);
673 *out = state.type;
keunyoungb85b2752013-03-08 12:28:03 -0800674 isClientStateParam = true;
675 break;
676 }
677 case GL_COLOR_ARRAY_STRIDE: {
Lingfeng Yangf654f3f2017-01-09 13:12:33 -0800678 const GLClientState::VertexAttribState& state = getState(GLClientState::COLOR_LOCATION);
679 *out = state.stride;
keunyoungb85b2752013-03-08 12:28:03 -0800680 isClientStateParam = true;
681 break;
682 }
683 case GL_NORMAL_ARRAY_TYPE: {
Lingfeng Yangf654f3f2017-01-09 13:12:33 -0800684 const GLClientState::VertexAttribState& state = getState(GLClientState::NORMAL_LOCATION);
685 *out = state.type;
keunyoungb85b2752013-03-08 12:28:03 -0800686 isClientStateParam = true;
687 break;
688 }
689 case GL_NORMAL_ARRAY_STRIDE: {
Lingfeng Yangf654f3f2017-01-09 13:12:33 -0800690 const GLClientState::VertexAttribState& state = getState(GLClientState::NORMAL_LOCATION);
691 *out = state.stride;
keunyoungb85b2752013-03-08 12:28:03 -0800692 isClientStateParam = true;
693 break;
694 }
695 case GL_TEXTURE_COORD_ARRAY_SIZE: {
Lingfeng Yangf654f3f2017-01-09 13:12:33 -0800696 const GLClientState::VertexAttribState& state = getState(getActiveTexture() + GLClientState::TEXCOORD0_LOCATION);
697 *out = state.size;
keunyoungb85b2752013-03-08 12:28:03 -0800698 isClientStateParam = true;
699 break;
700 }
701 case GL_TEXTURE_COORD_ARRAY_TYPE: {
Lingfeng Yangf654f3f2017-01-09 13:12:33 -0800702 const GLClientState::VertexAttribState& state = getState(getActiveTexture() + GLClientState::TEXCOORD0_LOCATION);
703 *out = state.type;
keunyoungb85b2752013-03-08 12:28:03 -0800704 isClientStateParam = true;
705 break;
706 }
707 case GL_TEXTURE_COORD_ARRAY_STRIDE: {
Lingfeng Yangf654f3f2017-01-09 13:12:33 -0800708 const GLClientState::VertexAttribState& state = getState(getActiveTexture() + GLClientState::TEXCOORD0_LOCATION);
709 *out = state.stride;
keunyoungb85b2752013-03-08 12:28:03 -0800710 isClientStateParam = true;
711 break;
712 }
713 case GL_POINT_SIZE_ARRAY_TYPE_OES: {
Lingfeng Yangf654f3f2017-01-09 13:12:33 -0800714 const GLClientState::VertexAttribState& state = getState(GLClientState::POINTSIZE_LOCATION);
715 *out = state.type;
keunyoungb85b2752013-03-08 12:28:03 -0800716 isClientStateParam = true;
717 break;
718 }
719 case GL_POINT_SIZE_ARRAY_STRIDE_OES: {
Lingfeng Yangf654f3f2017-01-09 13:12:33 -0800720 const GLClientState::VertexAttribState& state = getState(GLClientState::POINTSIZE_LOCATION);
721 *out = state.stride;
keunyoungb85b2752013-03-08 12:28:03 -0800722 isClientStateParam = true;
723 break;
724 }
725 case GL_MATRIX_INDEX_ARRAY_SIZE_OES: {
Lingfeng Yangf654f3f2017-01-09 13:12:33 -0800726 const GLClientState::VertexAttribState& state = getState(GLClientState::MATRIXINDEX_LOCATION);
727 *out = state.size;
keunyoungb85b2752013-03-08 12:28:03 -0800728 isClientStateParam = true;
729 break;
730 }
731 case GL_MATRIX_INDEX_ARRAY_TYPE_OES: {
Lingfeng Yangf654f3f2017-01-09 13:12:33 -0800732 const GLClientState::VertexAttribState& state = getState(GLClientState::MATRIXINDEX_LOCATION);
733 *out = state.type;
keunyoungb85b2752013-03-08 12:28:03 -0800734 isClientStateParam = true;
735 break;
736 }
737 case GL_MATRIX_INDEX_ARRAY_STRIDE_OES: {
Lingfeng Yangf654f3f2017-01-09 13:12:33 -0800738 const GLClientState::VertexAttribState& state = getState(GLClientState::MATRIXINDEX_LOCATION);
739 *out = state.stride;
keunyoungb85b2752013-03-08 12:28:03 -0800740 isClientStateParam = true;
741 break;
742 }
743 case GL_WEIGHT_ARRAY_SIZE_OES: {
Lingfeng Yangf654f3f2017-01-09 13:12:33 -0800744 const GLClientState::VertexAttribState& state = getState(GLClientState::WEIGHT_LOCATION);
745 *out = state.size;
keunyoungb85b2752013-03-08 12:28:03 -0800746 isClientStateParam = true;
747 break;
748 }
749 case GL_WEIGHT_ARRAY_TYPE_OES: {
Lingfeng Yangf654f3f2017-01-09 13:12:33 -0800750 const GLClientState::VertexAttribState& state = getState(GLClientState::WEIGHT_LOCATION);
751 *out = state.type;
keunyoungb85b2752013-03-08 12:28:03 -0800752 isClientStateParam = true;
753 break;
754 }
755 case GL_WEIGHT_ARRAY_STRIDE_OES: {
Lingfeng Yangf654f3f2017-01-09 13:12:33 -0800756 const GLClientState::VertexAttribState& state = getState(GLClientState::WEIGHT_LOCATION);
757 *out = state.stride;
keunyoungb85b2752013-03-08 12:28:03 -0800758 isClientStateParam = true;
759 break;
760 }
761 case GL_VERTEX_ARRAY_BUFFER_BINDING: {
Lingfeng Yangf654f3f2017-01-09 13:12:33 -0800762 const GLClientState::VertexAttribState& state = getState(GLClientState::VERTEX_LOCATION);
763 *out = state.bufferObject;
keunyoungb85b2752013-03-08 12:28:03 -0800764 isClientStateParam = true;
765 break;
766 }
767 case GL_NORMAL_ARRAY_BUFFER_BINDING: {
Lingfeng Yangf654f3f2017-01-09 13:12:33 -0800768 const GLClientState::VertexAttribState& state = getState(GLClientState::NORMAL_LOCATION);
769 *out = state.bufferObject;
keunyoungb85b2752013-03-08 12:28:03 -0800770 isClientStateParam = true;
771 break;
772 }
773 case GL_COLOR_ARRAY_BUFFER_BINDING: {
Lingfeng Yangf654f3f2017-01-09 13:12:33 -0800774 const GLClientState::VertexAttribState& state = getState(GLClientState::COLOR_LOCATION);
775 *out = state.bufferObject;
keunyoungb85b2752013-03-08 12:28:03 -0800776 isClientStateParam = true;
777 break;
778 }
779 case GL_TEXTURE_COORD_ARRAY_BUFFER_BINDING: {
Lingfeng Yangf654f3f2017-01-09 13:12:33 -0800780 const GLClientState::VertexAttribState& state = getState(getActiveTexture()+GLClientState::TEXCOORD0_LOCATION);
781 *out = state.bufferObject;
keunyoungb85b2752013-03-08 12:28:03 -0800782 isClientStateParam = true;
783 break;
784 }
785 case GL_POINT_SIZE_ARRAY_BUFFER_BINDING_OES: {
Lingfeng Yangf654f3f2017-01-09 13:12:33 -0800786 const GLClientState::VertexAttribState& state = getState(GLClientState::POINTSIZE_LOCATION);
787 *out = state.bufferObject;
keunyoungb85b2752013-03-08 12:28:03 -0800788 isClientStateParam = true;
789 break;
790 }
791 case GL_MATRIX_INDEX_ARRAY_BUFFER_BINDING_OES: {
Lingfeng Yangf654f3f2017-01-09 13:12:33 -0800792 const GLClientState::VertexAttribState& state = getState(GLClientState::MATRIXINDEX_LOCATION);
793 *out = state.bufferObject;
keunyoungb85b2752013-03-08 12:28:03 -0800794 isClientStateParam = true;
795 break;
796 }
797 case GL_WEIGHT_ARRAY_BUFFER_BINDING_OES: {
Lingfeng Yangf654f3f2017-01-09 13:12:33 -0800798 const GLClientState::VertexAttribState& state = getState(GLClientState::WEIGHT_LOCATION);
799 *out = state.bufferObject;
keunyoungb85b2752013-03-08 12:28:03 -0800800 isClientStateParam = true;
801 break;
802 }
803 case GL_ARRAY_BUFFER_BINDING: {
804 int buffer = getBuffer(GL_ARRAY_BUFFER);
Lingfeng Yangf654f3f2017-01-09 13:12:33 -0800805 *out = buffer;
keunyoungb85b2752013-03-08 12:28:03 -0800806 isClientStateParam = true;
807 break;
808 }
809 case GL_ELEMENT_ARRAY_BUFFER_BINDING: {
810 int buffer = getBuffer(GL_ELEMENT_ARRAY_BUFFER);
Lingfeng Yangf654f3f2017-01-09 13:12:33 -0800811 *out = buffer;
keunyoungb85b2752013-03-08 12:28:03 -0800812 isClientStateParam = true;
813 break;
814 }
Lingfeng Yangb0176982016-03-01 21:27:49 -0800815 case GL_MAX_VERTEX_ATTRIBS: {
816 if (m_maxVertexAttribsDirty) {
817 isClientStateParam = false;
818 } else {
Lingfeng Yangf654f3f2017-01-09 13:12:33 -0800819 *out = m_maxVertexAttribs;
Lingfeng Yangb0176982016-03-01 21:27:49 -0800820 isClientStateParam = true;
821 }
822 break;
Lingfeng Yangf654f3f2017-01-09 13:12:33 -0800823 }
keunyoungb85b2752013-03-08 12:28:03 -0800824 }
825 return isClientStateParam;
826 }
827
828};
829#endif