1 // SwiftShader Software Renderer
\r
3 // Copyright(c) 2015 Google Inc.
\r
5 // All rights reserved. No part of this software may be copied, distributed, transmitted,
\r
6 // transcribed, stored in a retrieval system, translated into any human or computer
\r
7 // language by any means, or disclosed to third parties without the explicit written
\r
8 // agreement of Google Inc. Without such an agreement, no rights or licenses, express
\r
9 // or implied, including but not limited to any patent rights, are granted to you.
\r
11 // libGLESv3.cpp: Implements the exported OpenGL ES 3.0 functions.
\r
16 #include "Framebuffer.h"
\r
17 #include "Program.h"
\r
19 #include "Sampler.h"
\r
20 #include "Texture.h"
\r
21 #include "common/debug.h"
\r
23 #include <GLES3/gl3.h>
\r
24 #include <GLES2/gl2ext.h>
\r
26 using namespace es2;
\r
28 typedef std::pair<GLenum, GLenum> InternalFormatTypePair;
\r
29 typedef std::map<InternalFormatTypePair, GLenum> FormatMap;
\r
31 // A helper function to insert data into the format map with fewer characters.
\r
32 static void InsertFormatMapping(FormatMap& map, GLenum internalformat, GLenum format, GLenum type)
\r
34 map[InternalFormatTypePair(internalformat, type)] = format;
\r
37 static bool validImageSize(GLint level, GLsizei width, GLsizei height)
\r
39 if(level < 0 || level >= es2::IMPLEMENTATION_MAX_TEXTURE_LEVELS || width < 0 || height < 0)
\r
47 static bool validateSubImageParams(bool compressed, GLsizei width, GLsizei height, GLint xoffset, GLint yoffset, GLenum target, GLint level, GLenum format, es2::Texture *texture)
\r
51 return error(GL_INVALID_OPERATION, false);
\r
54 if(compressed != texture->isCompressed(target, level))
\r
56 return error(GL_INVALID_OPERATION, false);
\r
59 if(format != GL_NONE && format != texture->getFormat(target, level))
\r
61 return error(GL_INVALID_OPERATION, false);
\r
66 if((width % 4 != 0 && width != texture->getWidth(target, 0)) ||
\r
67 (height % 4 != 0 && height != texture->getHeight(target, 0)))
\r
69 return error(GL_INVALID_OPERATION, false);
\r
73 if(xoffset + width > texture->getWidth(target, level) ||
\r
74 yoffset + height > texture->getHeight(target, level))
\r
76 return error(GL_INVALID_VALUE, false);
\r
82 static bool validateSubImageParams(bool compressed, GLsizei width, GLsizei height, GLsizei depth, GLint xoffset, GLint yoffset, GLint zoffset, GLenum target, GLint level, GLenum format, es2::Texture *texture)
\r
86 return error(GL_INVALID_OPERATION, false);
\r
89 if(compressed != texture->isCompressed(target, level))
\r
91 return error(GL_INVALID_OPERATION, false);
\r
94 if(format != GL_NONE && format != texture->getFormat(target, level))
\r
96 return error(GL_INVALID_OPERATION, false);
\r
101 if((width % 4 != 0 && width != texture->getWidth(target, 0)) ||
\r
102 (height % 4 != 0 && height != texture->getHeight(target, 0)) ||
\r
103 (depth % 4 != 0 && depth != texture->getDepth(target, 0)))
\r
105 return error(GL_INVALID_OPERATION, false);
\r
109 if(xoffset + width > texture->getWidth(target, level) ||
\r
110 yoffset + height > texture->getHeight(target, level) ||
\r
111 zoffset + depth > texture->getDepth(target, level))
\r
113 return error(GL_INVALID_VALUE, false);
\r
119 static bool validateColorBufferFormat(GLenum textureFormat, GLenum colorbufferFormat)
\r
121 switch(textureFormat)
\r
124 if(colorbufferFormat != GL_ALPHA &&
\r
125 colorbufferFormat != GL_RGBA &&
\r
126 colorbufferFormat != GL_RGBA4 &&
\r
127 colorbufferFormat != GL_RGB5_A1 &&
\r
128 colorbufferFormat != GL_RGBA8)
\r
130 return error(GL_INVALID_OPERATION, false);
\r
135 if(colorbufferFormat != GL_RGB &&
\r
136 colorbufferFormat != GL_RGB565 &&
\r
137 colorbufferFormat != GL_RGB8 &&
\r
138 colorbufferFormat != GL_RGBA &&
\r
139 colorbufferFormat != GL_RGBA4 &&
\r
140 colorbufferFormat != GL_RGB5_A1 &&
\r
141 colorbufferFormat != GL_RGBA8)
\r
143 return error(GL_INVALID_OPERATION, false);
\r
146 case GL_LUMINANCE_ALPHA:
\r
148 if(colorbufferFormat != GL_RGBA &&
\r
149 colorbufferFormat != GL_RGBA4 &&
\r
150 colorbufferFormat != GL_RGB5_A1 &&
\r
151 colorbufferFormat != GL_RGBA8)
\r
153 return error(GL_INVALID_OPERATION, false);
\r
156 case GL_ETC1_RGB8_OES:
\r
157 case GL_COMPRESSED_R11_EAC:
\r
158 case GL_COMPRESSED_SIGNED_R11_EAC:
\r
159 case GL_COMPRESSED_RG11_EAC:
\r
160 case GL_COMPRESSED_SIGNED_RG11_EAC:
\r
161 case GL_COMPRESSED_RGB8_ETC2:
\r
162 case GL_COMPRESSED_SRGB8_ETC2:
\r
163 case GL_COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2:
\r
164 case GL_COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2:
\r
165 case GL_COMPRESSED_RGBA8_ETC2_EAC:
\r
166 case GL_COMPRESSED_SRGB8_ALPHA8_ETC2_EAC:
\r
167 return error(GL_INVALID_OPERATION, false);
\r
168 case GL_COMPRESSED_RGB_S3TC_DXT1_EXT:
\r
169 case GL_COMPRESSED_RGBA_S3TC_DXT1_EXT:
\r
170 case GL_COMPRESSED_RGBA_S3TC_DXT3_ANGLE:
\r
171 case GL_COMPRESSED_RGBA_S3TC_DXT5_ANGLE:
\r
174 return error(GL_INVALID_OPERATION, false);
\r
178 return error(GL_INVALID_ENUM, false);
\r
180 case GL_DEPTH_COMPONENT:
\r
181 case GL_DEPTH_STENCIL:
\r
182 return error(GL_INVALID_OPERATION, false);
\r
184 return error(GL_INVALID_ENUM, false);
\r
189 static FormatMap BuildFormatMap3D()
\r
193 // Internal format | Format | Type
\r
194 InsertFormatMapping(map, GL_RGB, GL_RGB, GL_UNSIGNED_BYTE);
\r
195 InsertFormatMapping(map, GL_RGB, GL_RGB, GL_UNSIGNED_SHORT_5_6_5);
\r
196 InsertFormatMapping(map, GL_RGBA, GL_RGBA, GL_UNSIGNED_BYTE);
\r
197 InsertFormatMapping(map, GL_RGBA, GL_RGBA, GL_UNSIGNED_SHORT_4_4_4_4);
\r
198 InsertFormatMapping(map, GL_RGBA, GL_RGBA, GL_UNSIGNED_SHORT_5_5_5_1);
\r
199 InsertFormatMapping(map, GL_LUMINANCE_ALPHA, GL_LUMINANCE_ALPHA, GL_UNSIGNED_BYTE);
\r
200 InsertFormatMapping(map, GL_LUMINANCE, GL_LUMINANCE, GL_UNSIGNED_BYTE);
\r
201 InsertFormatMapping(map, GL_ALPHA, GL_ALPHA, GL_UNSIGNED_BYTE);
\r
202 InsertFormatMapping(map, GL_R8, GL_RED, GL_UNSIGNED_BYTE);
\r
203 InsertFormatMapping(map, GL_R8_SNORM, GL_RED, GL_UNSIGNED_BYTE);
\r
204 InsertFormatMapping(map, GL_R16F, GL_RED, GL_HALF_FLOAT);
\r
205 InsertFormatMapping(map, GL_R16F, GL_RED, GL_FLOAT);
\r
206 InsertFormatMapping(map, GL_R32F, GL_RED, GL_FLOAT);
\r
207 InsertFormatMapping(map, GL_R8UI, GL_RED_INTEGER, GL_UNSIGNED_BYTE);
\r
208 InsertFormatMapping(map, GL_R8I, GL_RED_INTEGER, GL_BYTE);
\r
209 InsertFormatMapping(map, GL_R16UI, GL_RED_INTEGER, GL_UNSIGNED_SHORT);
\r
210 InsertFormatMapping(map, GL_R16I, GL_RED_INTEGER, GL_SHORT);
\r
211 InsertFormatMapping(map, GL_R32UI, GL_RED_INTEGER, GL_UNSIGNED_INT);
\r
212 InsertFormatMapping(map, GL_R32I, GL_RED_INTEGER, GL_INT);
\r
213 InsertFormatMapping(map, GL_RG8, GL_RG, GL_UNSIGNED_BYTE);
\r
214 InsertFormatMapping(map, GL_RG8_SNORM, GL_RG, GL_BYTE);
\r
215 InsertFormatMapping(map, GL_R16F, GL_RED, GL_HALF_FLOAT);
\r
216 InsertFormatMapping(map, GL_R16F, GL_RED, GL_FLOAT);
\r
217 InsertFormatMapping(map, GL_RG32F, GL_RG, GL_FLOAT);
\r
218 InsertFormatMapping(map, GL_RG8UI, GL_RG_INTEGER, GL_UNSIGNED_BYTE);
\r
219 InsertFormatMapping(map, GL_RG8I, GL_RG_INTEGER, GL_BYTE);
\r
220 InsertFormatMapping(map, GL_RG16UI, GL_RG_INTEGER, GL_UNSIGNED_SHORT);
\r
221 InsertFormatMapping(map, GL_RG16I, GL_RG_INTEGER, GL_SHORT);
\r
222 InsertFormatMapping(map, GL_RG32UI, GL_RG_INTEGER, GL_UNSIGNED_INT);
\r
223 InsertFormatMapping(map, GL_RG32I, GL_RG_INTEGER, GL_INT);
\r
224 InsertFormatMapping(map, GL_RGB8, GL_RGB, GL_UNSIGNED_BYTE);
\r
225 InsertFormatMapping(map, GL_SRGB8, GL_RGB, GL_UNSIGNED_BYTE);
\r
226 InsertFormatMapping(map, GL_RGB565, GL_RGB, GL_UNSIGNED_BYTE);
\r
227 InsertFormatMapping(map, GL_RGB565, GL_RGB, GL_UNSIGNED_SHORT_5_6_5);
\r
228 InsertFormatMapping(map, GL_RGB8_SNORM, GL_RGB, GL_BYTE);
\r
229 InsertFormatMapping(map, GL_R11F_G11F_B10F, GL_RGB, GL_UNSIGNED_INT_10F_11F_11F_REV);
\r
230 InsertFormatMapping(map, GL_R11F_G11F_B10F, GL_RGB, GL_HALF_FLOAT);
\r
231 InsertFormatMapping(map, GL_R11F_G11F_B10F, GL_RGB, GL_FLOAT);
\r
232 InsertFormatMapping(map, GL_RGB9_E5, GL_RGB, GL_UNSIGNED_INT_5_9_9_9_REV);
\r
233 InsertFormatMapping(map, GL_RGB9_E5, GL_RGB, GL_HALF_FLOAT);
\r
234 InsertFormatMapping(map, GL_RGB9_E5, GL_RGB, GL_FLOAT);
\r
235 InsertFormatMapping(map, GL_RGB16F, GL_RGB, GL_HALF_FLOAT);
\r
236 InsertFormatMapping(map, GL_RGB16F, GL_RGB, GL_FLOAT);
\r
237 InsertFormatMapping(map, GL_RGB32F, GL_RGB, GL_FLOAT);
\r
238 InsertFormatMapping(map, GL_RGB8UI, GL_RGB_INTEGER, GL_UNSIGNED_BYTE);
\r
239 InsertFormatMapping(map, GL_RGB8I, GL_RGB_INTEGER, GL_BYTE);
\r
240 InsertFormatMapping(map, GL_RGB16UI, GL_RGB_INTEGER, GL_UNSIGNED_SHORT);
\r
241 InsertFormatMapping(map, GL_RGB16I, GL_RGB_INTEGER, GL_SHORT);
\r
242 InsertFormatMapping(map, GL_RGB32UI, GL_RGB_INTEGER, GL_UNSIGNED_INT);
\r
243 InsertFormatMapping(map, GL_RGB32I, GL_RGB_INTEGER, GL_INT);
\r
244 InsertFormatMapping(map, GL_RGBA8, GL_RGBA, GL_UNSIGNED_BYTE);
\r
245 InsertFormatMapping(map, GL_SRGB8_ALPHA8, GL_RGBA, GL_UNSIGNED_BYTE);
\r
246 InsertFormatMapping(map, GL_RGB5_A1, GL_RGBA, GL_UNSIGNED_BYTE);
\r
247 InsertFormatMapping(map, GL_RGB5_A1, GL_RGBA, GL_UNSIGNED_SHORT_5_5_5_1);
\r
248 InsertFormatMapping(map, GL_RGB5_A1, GL_RGBA, GL_UNSIGNED_INT_2_10_10_10_REV);
\r
249 InsertFormatMapping(map, GL_RGBA4, GL_RGBA, GL_UNSIGNED_BYTE);
\r
250 InsertFormatMapping(map, GL_RGBA4, GL_RGBA, GL_UNSIGNED_SHORT_4_4_4_4);
\r
251 InsertFormatMapping(map, GL_RGB10_A2, GL_RGBA, GL_UNSIGNED_INT_2_10_10_10_REV);
\r
252 InsertFormatMapping(map, GL_RGBA16F, GL_RGBA, GL_HALF_FLOAT);
\r
253 InsertFormatMapping(map, GL_RGBA16F, GL_RGBA, GL_FLOAT);
\r
254 InsertFormatMapping(map, GL_RGBA32F, GL_RGBA, GL_FLOAT);
\r
255 InsertFormatMapping(map, GL_RGBA8UI, GL_RGBA_INTEGER, GL_UNSIGNED_BYTE);
\r
256 InsertFormatMapping(map, GL_RGBA8I, GL_RGBA_INTEGER, GL_BYTE);
\r
257 InsertFormatMapping(map, GL_RGB10_A2UI, GL_RGBA_INTEGER, GL_UNSIGNED_INT_2_10_10_10_REV);
\r
258 InsertFormatMapping(map, GL_RGBA16UI, GL_RGBA_INTEGER, GL_UNSIGNED_SHORT);
\r
259 InsertFormatMapping(map, GL_RGBA16I, GL_RGBA_INTEGER, GL_SHORT);
\r
260 InsertFormatMapping(map, GL_RGBA32UI, GL_RGBA_INTEGER, GL_UNSIGNED_INT);
\r
261 InsertFormatMapping(map, GL_RGBA32I, GL_RGBA_INTEGER, GL_INT);
\r
263 InsertFormatMapping(map, GL_DEPTH_COMPONENT16, GL_DEPTH_COMPONENT, GL_UNSIGNED_SHORT);
\r
264 InsertFormatMapping(map, GL_DEPTH_COMPONENT16, GL_DEPTH_COMPONENT, GL_UNSIGNED_INT);
\r
265 InsertFormatMapping(map, GL_DEPTH_COMPONENT24, GL_DEPTH_COMPONENT, GL_UNSIGNED_INT);
\r
266 InsertFormatMapping(map, GL_DEPTH_COMPONENT32F, GL_DEPTH_COMPONENT, GL_FLOAT);
\r
267 InsertFormatMapping(map, GL_DEPTH24_STENCIL8, GL_DEPTH_STENCIL, GL_UNSIGNED_INT_24_8);
\r
268 InsertFormatMapping(map, GL_DEPTH32F_STENCIL8, GL_DEPTH_STENCIL, GL_FLOAT_32_UNSIGNED_INT_24_8_REV);
\r
273 static bool ValidateType3D(GLenum type)
\r
277 case GL_UNSIGNED_BYTE:
\r
279 case GL_UNSIGNED_SHORT:
\r
281 case GL_UNSIGNED_INT:
\r
283 case GL_HALF_FLOAT:
\r
285 case GL_UNSIGNED_SHORT_5_6_5:
\r
286 case GL_UNSIGNED_SHORT_4_4_4_4:
\r
287 case GL_UNSIGNED_SHORT_5_5_5_1:
\r
288 case GL_UNSIGNED_INT_2_10_10_10_REV:
\r
289 case GL_UNSIGNED_INT_10F_11F_11F_REV:
\r
290 case GL_UNSIGNED_INT_5_9_9_9_REV:
\r
291 case GL_UNSIGNED_INT_24_8:
\r
292 case GL_FLOAT_32_UNSIGNED_INT_24_8_REV:
\r
300 static bool ValidateFormat3D(GLenum format)
\r
308 case GL_DEPTH_COMPONENT:
\r
309 case GL_DEPTH_STENCIL:
\r
310 case GL_LUMINANCE_ALPHA:
\r
313 case GL_RED_INTEGER:
\r
314 case GL_RG_INTEGER:
\r
315 case GL_RGB_INTEGER:
\r
316 case GL_RGBA_INTEGER:
\r
324 static bool ValidateInternalFormat3D(GLenum internalformat, GLenum format, GLenum type)
\r
326 static const FormatMap formatMap = BuildFormatMap3D();
\r
327 FormatMap::const_iterator iter = formatMap.find(InternalFormatTypePair(internalformat, type));
\r
328 if(iter != formatMap.end())
\r
330 return iter->second == format;
\r
335 typedef std::map<GLenum, GLenum> FormatMapStorage;
\r
337 // A helper function to insert data into the format map with fewer characters.
\r
338 static void InsertFormatStorageMapping(FormatMapStorage& map, GLenum internalformat, GLenum type)
\r
340 map[internalformat] = type;
\r
343 static FormatMapStorage BuildFormatMapStorage2D()
\r
345 FormatMapStorage map;
\r
347 // Internal format | Type
\r
348 InsertFormatStorageMapping(map, GL_R8, GL_UNSIGNED_BYTE);
\r
349 InsertFormatStorageMapping(map, GL_R8_SNORM, GL_UNSIGNED_BYTE);
\r
350 InsertFormatStorageMapping(map, GL_R16F, GL_HALF_FLOAT);
\r
351 InsertFormatStorageMapping(map, GL_R32F, GL_FLOAT);
\r
352 InsertFormatStorageMapping(map, GL_R8UI, GL_UNSIGNED_BYTE);
\r
353 InsertFormatStorageMapping(map, GL_R8I, GL_BYTE);
\r
354 InsertFormatStorageMapping(map, GL_R16UI, GL_UNSIGNED_SHORT);
\r
355 InsertFormatStorageMapping(map, GL_R16I, GL_SHORT);
\r
356 InsertFormatStorageMapping(map, GL_R32UI, GL_UNSIGNED_INT);
\r
357 InsertFormatStorageMapping(map, GL_R32I, GL_INT);
\r
358 InsertFormatStorageMapping(map, GL_RG8, GL_UNSIGNED_BYTE);
\r
359 InsertFormatStorageMapping(map, GL_RG8_SNORM, GL_BYTE);
\r
360 InsertFormatStorageMapping(map, GL_R16F, GL_HALF_FLOAT);
\r
361 InsertFormatStorageMapping(map, GL_RG32F, GL_FLOAT);
\r
362 InsertFormatStorageMapping(map, GL_RG8UI, GL_UNSIGNED_BYTE);
\r
363 InsertFormatStorageMapping(map, GL_RG8I, GL_BYTE);
\r
364 InsertFormatStorageMapping(map, GL_RG16UI, GL_UNSIGNED_SHORT);
\r
365 InsertFormatStorageMapping(map, GL_RG16I, GL_SHORT);
\r
366 InsertFormatStorageMapping(map, GL_RG32UI, GL_UNSIGNED_INT);
\r
367 InsertFormatStorageMapping(map, GL_RG32I, GL_INT);
\r
368 InsertFormatStorageMapping(map, GL_RGB8, GL_UNSIGNED_BYTE);
\r
369 InsertFormatStorageMapping(map, GL_SRGB8, GL_UNSIGNED_BYTE);
\r
370 InsertFormatStorageMapping(map, GL_RGB565, GL_UNSIGNED_SHORT_5_6_5);
\r
371 InsertFormatStorageMapping(map, GL_RGB8_SNORM, GL_BYTE);
\r
372 InsertFormatStorageMapping(map, GL_R11F_G11F_B10F, GL_UNSIGNED_INT_10F_11F_11F_REV);
\r
373 InsertFormatStorageMapping(map, GL_RGB9_E5, GL_UNSIGNED_INT_5_9_9_9_REV);
\r
374 InsertFormatStorageMapping(map, GL_RGB16F, GL_HALF_FLOAT);
\r
375 InsertFormatStorageMapping(map, GL_RGB32F, GL_FLOAT);
\r
376 InsertFormatStorageMapping(map, GL_RGB8UI, GL_UNSIGNED_BYTE);
\r
377 InsertFormatStorageMapping(map, GL_RGB8I, GL_BYTE);
\r
378 InsertFormatStorageMapping(map, GL_RGB16UI, GL_UNSIGNED_SHORT);
\r
379 InsertFormatStorageMapping(map, GL_RGB16I, GL_SHORT);
\r
380 InsertFormatStorageMapping(map, GL_RGB32UI, GL_UNSIGNED_INT);
\r
381 InsertFormatStorageMapping(map, GL_RGB32I, GL_INT);
\r
382 InsertFormatStorageMapping(map, GL_RGBA8, GL_UNSIGNED_BYTE);
\r
383 InsertFormatStorageMapping(map, GL_SRGB8_ALPHA8, GL_UNSIGNED_BYTE);
\r
384 InsertFormatStorageMapping(map, GL_RGB5_A1, GL_UNSIGNED_SHORT_5_5_5_1);
\r
385 InsertFormatStorageMapping(map, GL_RGBA4, GL_UNSIGNED_SHORT_4_4_4_4);
\r
386 InsertFormatStorageMapping(map, GL_RGB10_A2, GL_UNSIGNED_INT_2_10_10_10_REV);
\r
387 InsertFormatStorageMapping(map, GL_RGBA16F, GL_HALF_FLOAT);
\r
388 InsertFormatStorageMapping(map, GL_RGBA32F, GL_FLOAT);
\r
389 InsertFormatStorageMapping(map, GL_RGBA8UI, GL_UNSIGNED_BYTE);
\r
390 InsertFormatStorageMapping(map, GL_RGBA8I, GL_BYTE);
\r
391 InsertFormatStorageMapping(map, GL_RGB10_A2UI, GL_UNSIGNED_INT_2_10_10_10_REV);
\r
392 InsertFormatStorageMapping(map, GL_RGBA16UI, GL_UNSIGNED_SHORT);
\r
393 InsertFormatStorageMapping(map, GL_RGBA16I, GL_SHORT);
\r
394 InsertFormatStorageMapping(map, GL_RGBA32UI, GL_UNSIGNED_INT);
\r
395 InsertFormatStorageMapping(map, GL_RGBA32I, GL_INT);
\r
397 InsertFormatStorageMapping(map, GL_DEPTH_COMPONENT16, GL_UNSIGNED_SHORT);
\r
398 InsertFormatStorageMapping(map, GL_DEPTH_COMPONENT24, GL_UNSIGNED_INT);
\r
399 InsertFormatStorageMapping(map, GL_DEPTH_COMPONENT32F, GL_FLOAT);
\r
400 InsertFormatStorageMapping(map, GL_DEPTH24_STENCIL8, GL_UNSIGNED_INT_24_8);
\r
401 InsertFormatStorageMapping(map, GL_DEPTH32F_STENCIL8, GL_FLOAT_32_UNSIGNED_INT_24_8_REV);
\r
406 static bool GetStorageType(GLenum internalformat, GLenum& type)
\r
408 static const FormatMapStorage formatMap = BuildFormatMapStorage2D();
\r
409 FormatMapStorage::const_iterator iter = formatMap.find(internalformat);
\r
410 if(iter != formatMap.end())
\r
412 type = iter->second;
\r
418 static bool ValidateQueryTarget(GLenum target)
\r
422 case GL_ANY_SAMPLES_PASSED:
\r
423 case GL_ANY_SAMPLES_PASSED_CONSERVATIVE:
\r
424 case GL_TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN:
\r
433 static bool ValidateBufferTarget(GLenum target)
\r
437 case GL_ARRAY_BUFFER:
\r
438 case GL_COPY_READ_BUFFER:
\r
439 case GL_COPY_WRITE_BUFFER:
\r
440 case GL_ELEMENT_ARRAY_BUFFER:
\r
441 case GL_PIXEL_PACK_BUFFER:
\r
442 case GL_PIXEL_UNPACK_BUFFER:
\r
443 case GL_TRANSFORM_FEEDBACK_BUFFER:
\r
444 case GL_UNIFORM_BUFFER:
\r
456 GL_APICALL void GL_APIENTRY glReadBuffer(GLenum src)
\r
458 TRACE("(GLenum src = 0x%X)", src);
\r
460 es2::Context *context = es2::getContext();
\r
464 GLuint readFramebufferName = context->getReadFramebufferName();
\r
469 if(readFramebufferName != 0)
\r
471 return error(GL_INVALID_OPERATION);
\r
473 context->setReadFramebufferColorIndex(0);
\r
476 context->setReadFramebufferColorIndex(GL_INVALID_INDEX);
\r
478 case GL_COLOR_ATTACHMENT0:
\r
479 case GL_COLOR_ATTACHMENT1:
\r
480 case GL_COLOR_ATTACHMENT2:
\r
481 case GL_COLOR_ATTACHMENT3:
\r
482 case GL_COLOR_ATTACHMENT4:
\r
483 case GL_COLOR_ATTACHMENT5:
\r
484 case GL_COLOR_ATTACHMENT6:
\r
485 case GL_COLOR_ATTACHMENT7:
\r
486 case GL_COLOR_ATTACHMENT8:
\r
487 case GL_COLOR_ATTACHMENT9:
\r
488 case GL_COLOR_ATTACHMENT10:
\r
489 case GL_COLOR_ATTACHMENT11:
\r
490 case GL_COLOR_ATTACHMENT12:
\r
491 case GL_COLOR_ATTACHMENT13:
\r
492 case GL_COLOR_ATTACHMENT14:
\r
493 case GL_COLOR_ATTACHMENT15:
\r
495 GLuint index = (src - GL_COLOR_ATTACHMENT0);
\r
496 if(index >= es2::IMPLEMENTATION_MAX_COLOR_ATTACHMENTS)
\r
498 return error(GL_INVALID_ENUM);
\r
500 if(readFramebufferName == 0)
\r
502 return error(GL_INVALID_OPERATION);
\r
504 context->setReadFramebufferColorIndex(index);
\r
508 error(GL_INVALID_ENUM);
\r
513 GL_APICALL void GL_APIENTRY glDrawRangeElements(GLenum mode, GLuint start, GLuint end, GLsizei count, GLenum type, const void *indices)
\r
515 TRACE("(GLenum mode = 0x%X, GLuint start = %d, GLuint end = %d, "
\r
516 "GLsizei count = %d, GLenum type = 0x%x, const void* indices = %p)",
\r
517 mode, start, end, count, type, indices);
\r
524 case GL_LINE_STRIP:
\r
526 case GL_TRIANGLE_FAN:
\r
527 case GL_TRIANGLE_STRIP:
\r
530 return error(GL_INVALID_ENUM);
\r
535 case GL_UNSIGNED_BYTE:
\r
536 case GL_UNSIGNED_SHORT:
\r
537 case GL_UNSIGNED_INT:
\r
540 return error(GL_INVALID_ENUM);
\r
543 if((count < 0) || (end < start))
\r
545 return error(GL_INVALID_VALUE);
\r
548 es2::Context *context = es2::getContext();
\r
552 es2::TransformFeedback* transformFeedback = context->getTransformFeedback();
\r
553 if(transformFeedback && transformFeedback->isActive() && !transformFeedback->isPaused())
\r
555 return error(GL_INVALID_OPERATION);
\r
558 context->drawElements(mode, start, end, count, type, indices);
\r
562 GL_APICALL void GL_APIENTRY glTexImage3D(GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const void *pixels)
\r
564 TRACE("(GLenum target = 0x%X, GLint level = %d, GLenum internalformat = 0x%X, "
\r
565 "GLsizei width = %d, GLsizei height = %d, GLsizei depth = %d, GLint border = %d, "
\r
566 "GLenum format = 0x%X, GLenum type = 0x%x, const GLvoid* pixels = %p)",
\r
567 target, level, internalformat, width, height, depth, border, format, type, pixels);
\r
571 case GL_TEXTURE_3D:
\r
572 case GL_TEXTURE_2D_ARRAY:
\r
575 return error(GL_INVALID_ENUM);
\r
578 if(!ValidateType3D(type) || !ValidateFormat3D(format))
\r
580 return error(GL_INVALID_ENUM);
\r
583 if((level < 0) || (level >= es2::IMPLEMENTATION_MAX_TEXTURE_LEVELS))
\r
585 return error(GL_INVALID_VALUE);
\r
588 const GLsizei maxSize3D = es2::IMPLEMENTATION_MAX_TEXTURE_SIZE >> level;
\r
589 if((width < 0) || (height < 0) || (depth < 0) || (width > maxSize3D) || (height > maxSize3D) || (depth > maxSize3D))
\r
591 return error(GL_INVALID_VALUE);
\r
596 return error(GL_INVALID_VALUE);
\r
599 if(!ValidateInternalFormat3D(internalformat, format, type))
\r
601 return error(GL_INVALID_OPERATION);
\r
604 es2::Context *context = es2::getContext();
\r
608 es2::Texture3D *texture = (target == GL_TEXTURE_3D) ? context->getTexture3D() : context->getTexture2DArray();
\r
612 return error(GL_INVALID_OPERATION);
\r
615 texture->setImage(level, width, height, depth, internalformat, type, context->getUnpackInfo(), pixels);
\r
619 GL_APICALL void GL_APIENTRY glTexSubImage3D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const void *pixels)
\r
621 TRACE("(GLenum target = 0x%X, GLint level = %d, GLint xoffset = %d, GLint yoffset = %d, "
\r
622 "GLint zoffset = %d, GLsizei width = %d, GLsizei height = %d, GLsizei depth = %d, "
\r
623 "GLenum format = 0x%X, GLenum type = 0x%x, const GLvoid* pixels = %p)",
\r
624 target, level, xoffset, yoffset, zoffset, width, height, depth, format, type, pixels);
\r
628 case GL_TEXTURE_3D:
\r
629 case GL_TEXTURE_2D_ARRAY:
\r
632 return error(GL_INVALID_ENUM);
\r
635 if(!ValidateType3D(type) || !ValidateFormat3D(format))
\r
637 return error(GL_INVALID_ENUM);
\r
640 if((level < 0) || (level >= es2::IMPLEMENTATION_MAX_TEXTURE_LEVELS))
\r
642 return error(GL_INVALID_VALUE);
\r
645 if((width < 0) || (height < 0) || (depth < 0) || (xoffset < 0) || (yoffset < 0) || (zoffset < 0))
\r
647 return error(GL_INVALID_VALUE);
\r
650 es2::Context *context = es2::getContext();
\r
654 es2::Texture3D *texture = (target == GL_TEXTURE_3D) ? context->getTexture3D() : context->getTexture2DArray();
\r
656 if(validateSubImageParams(false, width, height, depth, xoffset, yoffset, zoffset, target, level, format, texture))
\r
658 texture->subImage(level, xoffset, yoffset, zoffset, width, height, depth, format, type, context->getUnpackInfo(), pixels);
\r
663 GL_APICALL void GL_APIENTRY glCopyTexSubImage3D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height)
\r
665 TRACE("(GLenum target = 0x%X, GLint level = %d, GLint xoffset = %d, GLint yoffset = %d, "
\r
666 "GLint zoffset = %d, GLint x = %d, GLint y = %d, GLsizei width = %d, GLsizei height = %d)",
\r
667 target, level, xoffset, yoffset, zoffset, x, y, width, height);
\r
671 case GL_TEXTURE_3D:
\r
672 case GL_TEXTURE_2D_ARRAY:
\r
675 return error(GL_INVALID_ENUM);
\r
678 if((level < 0) || (level >= es2::IMPLEMENTATION_MAX_TEXTURE_LEVELS))
\r
680 return error(GL_INVALID_VALUE);
\r
683 if((width < 0) || (height < 0) || (xoffset < 0) || (yoffset < 0) || (zoffset < 0))
\r
685 return error(GL_INVALID_VALUE);
\r
688 es2::Context *context = es2::getContext();
\r
692 es2::Framebuffer *framebuffer = context->getReadFramebuffer();
\r
694 if(framebuffer->completeness() != GL_FRAMEBUFFER_COMPLETE)
\r
696 return error(GL_INVALID_FRAMEBUFFER_OPERATION);
\r
699 es2::Renderbuffer *source = framebuffer->getReadColorbuffer();
\r
701 if(context->getReadFramebufferName() != 0 && (!source || source->getSamples() > 1))
\r
703 return error(GL_INVALID_OPERATION);
\r
706 GLenum colorbufferFormat = source->getFormat();
\r
707 es2::Texture3D *texture = (target == GL_TEXTURE_3D) ? context->getTexture3D() : context->getTexture2DArray();
\r
709 if(!validateSubImageParams(false, width, height, 1, xoffset, yoffset, zoffset, target, level, GL_NONE, texture))
\r
714 GLenum textureFormat = texture->getFormat(target, level);
\r
716 if(!validateColorBufferFormat(textureFormat, colorbufferFormat))
\r
721 texture->copySubImage(target, level, xoffset, yoffset, zoffset, x, y, width, height, framebuffer);
\r
725 GL_APICALL void GL_APIENTRY glCompressedTexImage3D(GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLsizei imageSize, const void *data)
\r
727 TRACE("(GLenum target = 0x%X, GLint level = %d, GLenum internalformat = 0x%X, GLsizei width = %d, "
\r
728 "GLsizei height = %d, GLsizei depth = %d, GLint border = %d, GLsizei imageSize = %d, const GLvoid* data = %p)",
\r
729 target, level, internalformat, width, height, depth, border, imageSize, data);
\r
733 case GL_TEXTURE_3D:
\r
734 case GL_TEXTURE_2D_ARRAY:
\r
737 return error(GL_INVALID_ENUM);
\r
740 if((level < 0) || (level >= es2::IMPLEMENTATION_MAX_TEXTURE_LEVELS))
\r
742 return error(GL_INVALID_VALUE);
\r
745 const GLsizei maxSize3D = es2::IMPLEMENTATION_MAX_TEXTURE_SIZE >> level;
\r
746 if((width < 0) || (height < 0) || (depth < 0) || (width > maxSize3D) || (height > maxSize3D) || (depth > maxSize3D) || (border != 0) || (imageSize < 0))
\r
748 return error(GL_INVALID_VALUE);
\r
751 switch(internalformat)
\r
753 case GL_ETC1_RGB8_OES:
\r
754 case GL_COMPRESSED_R11_EAC:
\r
755 case GL_COMPRESSED_SIGNED_R11_EAC:
\r
756 case GL_COMPRESSED_RG11_EAC:
\r
757 case GL_COMPRESSED_SIGNED_RG11_EAC:
\r
758 case GL_COMPRESSED_RGB8_ETC2:
\r
759 case GL_COMPRESSED_SRGB8_ETC2:
\r
760 case GL_COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2:
\r
761 case GL_COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2:
\r
762 case GL_COMPRESSED_RGBA8_ETC2_EAC:
\r
763 case GL_COMPRESSED_SRGB8_ALPHA8_ETC2_EAC:
\r
765 case GL_COMPRESSED_RGB_S3TC_DXT1_EXT:
\r
766 case GL_COMPRESSED_RGBA_S3TC_DXT1_EXT:
\r
767 case GL_COMPRESSED_RGBA_S3TC_DXT3_ANGLE:
\r
768 case GL_COMPRESSED_RGBA_S3TC_DXT5_ANGLE:
\r
771 return error(GL_INVALID_ENUM);
\r
774 case GL_DEPTH_COMPONENT:
\r
775 case GL_DEPTH_COMPONENT16:
\r
776 case GL_DEPTH_COMPONENT32_OES:
\r
777 case GL_DEPTH_STENCIL:
\r
778 case GL_DEPTH24_STENCIL8:
\r
779 return error(GL_INVALID_OPERATION);
\r
781 return error(GL_INVALID_ENUM);
\r
784 if(imageSize != egl::ComputeCompressedSize(width, height, internalformat) * depth)
\r
786 return error(GL_INVALID_VALUE);
\r
789 es2::Context *context = es2::getContext();
\r
793 es2::Texture3D *texture = (target == GL_TEXTURE_3D) ? context->getTexture3D() : context->getTexture2DArray();
\r
797 return error(GL_INVALID_OPERATION);
\r
800 texture->setCompressedImage(level, internalformat, width, height, depth, imageSize, data);
\r
804 GL_APICALL void GL_APIENTRY glCompressedTexSubImage3D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const void *data)
\r
806 TRACE("(GLenum target = 0x%X, GLint level = %d, GLint xoffset = %d, GLint yoffset = %d, "
\r
807 "GLint zoffset = %d, GLsizei width = %d, GLsizei height = %d, GLsizei depth = %d, "
\r
808 "GLenum format = 0x%X, GLsizei imageSize = %d, const void *data = %p)",
\r
809 target, level, xoffset, yoffset, zoffset, width, height, depth, format, imageSize, data);
\r
813 case GL_TEXTURE_3D:
\r
814 case GL_TEXTURE_2D_ARRAY:
\r
817 return error(GL_INVALID_ENUM);
\r
820 if(xoffset < 0 || yoffset < 0 || zoffset < 0 || !validImageSize(level, width, height) || depth < 0 || imageSize < 0)
\r
822 return error(GL_INVALID_VALUE);
\r
827 case GL_ETC1_RGB8_OES:
\r
828 case GL_COMPRESSED_R11_EAC:
\r
829 case GL_COMPRESSED_SIGNED_R11_EAC:
\r
830 case GL_COMPRESSED_RG11_EAC:
\r
831 case GL_COMPRESSED_SIGNED_RG11_EAC:
\r
832 case GL_COMPRESSED_RGB8_ETC2:
\r
833 case GL_COMPRESSED_SRGB8_ETC2:
\r
834 case GL_COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2:
\r
835 case GL_COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2:
\r
836 case GL_COMPRESSED_RGBA8_ETC2_EAC:
\r
837 case GL_COMPRESSED_SRGB8_ALPHA8_ETC2_EAC:
\r
839 case GL_COMPRESSED_RGB_S3TC_DXT1_EXT:
\r
840 case GL_COMPRESSED_RGBA_S3TC_DXT1_EXT:
\r
841 case GL_COMPRESSED_RGBA_S3TC_DXT3_ANGLE:
\r
842 case GL_COMPRESSED_RGBA_S3TC_DXT5_ANGLE:
\r
845 return error(GL_INVALID_ENUM);
\r
849 return error(GL_INVALID_ENUM);
\r
852 if(width == 0 || height == 0 || depth == 0 || data == NULL)
\r
857 es2::Context *context = es2::getContext();
\r
861 es2::Texture3D *texture = (target == GL_TEXTURE_3D) ? context->getTexture3D() : context->getTexture2DArray();
\r
865 return error(GL_INVALID_OPERATION);
\r
868 texture->subImageCompressed(level, xoffset, yoffset, zoffset, width, height, depth, format, imageSize, data);
\r
872 GL_APICALL void GL_APIENTRY glGenQueries(GLsizei n, GLuint *ids)
\r
874 TRACE("(GLsizei n = %d, GLuint* ids = %p)", n, ids);
\r
878 return error(GL_INVALID_VALUE);
\r
881 es2::Context *context = es2::getContext();
\r
885 for(int i = 0; i < n; i++)
\r
887 ids[i] = context->createQuery();
\r
892 GL_APICALL void GL_APIENTRY glDeleteQueries(GLsizei n, const GLuint *ids)
\r
894 TRACE("(GLsizei n = %d, GLuint* ids = %p)", n, ids);
\r
898 return error(GL_INVALID_VALUE);
\r
901 es2::Context *context = es2::getContext();
\r
905 for(int i = 0; i < n; i++)
\r
907 context->deleteQuery(ids[i]);
\r
912 GL_APICALL GLboolean GL_APIENTRY glIsQuery(GLuint id)
\r
914 TRACE("(GLuint id = %d)", id);
\r
921 es2::Context *context = es2::getContext();
\r
925 es2::Query *queryObject = context->getQuery(id);
\r
936 GL_APICALL void GL_APIENTRY glBeginQuery(GLenum target, GLuint id)
\r
938 TRACE("(GLenum target = 0x%X, GLuint id = %d)", target, id);
\r
940 if(!ValidateQueryTarget(target))
\r
942 return error(GL_INVALID_ENUM);
\r
947 return error(GL_INVALID_OPERATION);
\r
950 es2::Context *context = es2::getContext();
\r
954 context->beginQuery(target, id);
\r
958 GL_APICALL void GL_APIENTRY glEndQuery(GLenum target)
\r
960 TRACE("(GLenum target = 0x%X)", target);
\r
962 if(!ValidateQueryTarget(target))
\r
964 return error(GL_INVALID_ENUM);
\r
967 es2::Context *context = es2::getContext();
\r
971 context->endQuery(target);
\r
975 GL_APICALL void GL_APIENTRY glGetQueryiv(GLenum target, GLenum pname, GLint *params)
\r
977 TRACE("(GLenum target = 0x%X, GLenum pname = 0x%X, GLint *params = %p)",
\r
978 target, pname, params);
\r
980 if(!ValidateQueryTarget(target) || (pname != GL_CURRENT_QUERY))
\r
982 return error(GL_INVALID_ENUM);
\r
985 es2::Context *context = es2::getContext();
\r
989 params[0] = context->getActiveQuery(target);
\r
993 GL_APICALL void GL_APIENTRY glGetQueryObjectuiv(GLuint id, GLenum pname, GLuint *params)
\r
995 TRACE("(GLuint id = %d, GLenum pname = 0x%X, GLint *params = %p)",
\r
996 id, pname, params);
\r
1000 case GL_QUERY_RESULT:
\r
1001 case GL_QUERY_RESULT_AVAILABLE:
\r
1004 return error(GL_INVALID_ENUM);
\r
1007 es2::Context *context = es2::getContext();
\r
1011 es2::Query *queryObject = context->getQuery(id);
\r
1015 return error(GL_INVALID_OPERATION);
\r
1018 if(context->getActiveQuery(queryObject->getType()) == id)
\r
1020 return error(GL_INVALID_OPERATION);
\r
1025 case GL_QUERY_RESULT:
\r
1026 params[0] = queryObject->getResult();
\r
1028 case GL_QUERY_RESULT_AVAILABLE:
\r
1029 params[0] = queryObject->isResultAvailable();
\r
1037 GL_APICALL GLboolean GL_APIENTRY glUnmapBuffer(GLenum target)
\r
1039 TRACE("(GLenum target = 0x%X)", target);
\r
1041 es2::Context *context = es2::getContext();
\r
1045 es2::Buffer *buffer = nullptr;
\r
1046 if(!context->getBuffer(target, &buffer))
\r
1048 return error(GL_INVALID_ENUM, GL_TRUE);
\r
1053 // A null buffer means that "0" is bound to the requested buffer target
\r
1054 return error(GL_INVALID_OPERATION, GL_TRUE);
\r
1057 return buffer->unmap() ? GL_TRUE : GL_FALSE;
\r
1063 GL_APICALL void GL_APIENTRY glGetBufferPointerv(GLenum target, GLenum pname, void **params)
\r
1065 TRACE("(GLenum target = 0x%X, GLenum pname = 0x%X, GLint *params = %p)",
\r
1066 target, pname, params);
\r
1068 if(pname != GL_BUFFER_MAP_POINTER)
\r
1070 return error(GL_INVALID_ENUM);
\r
1073 es2::Context *context = es2::getContext();
\r
1077 es2::Buffer *buffer = nullptr;
\r
1078 if(!context->getBuffer(target, &buffer))
\r
1080 return error(GL_INVALID_ENUM);
\r
1085 // A null buffer means that "0" is bound to the requested buffer target
\r
1086 return error(GL_INVALID_OPERATION);
\r
1089 *params = buffer->isMapped() ? (void*)(((const char*)buffer->data()) + buffer->offset()) : nullptr;
\r
1093 GL_APICALL void GL_APIENTRY glDrawBuffers(GLsizei n, const GLenum *bufs)
\r
1095 TRACE("(GLsizei n = %d, const GLenum *bufs = %p)", n, bufs);
\r
1097 if(n < 0 || n > es2::IMPLEMENTATION_MAX_DRAW_BUFFERS)
\r
1099 return error(GL_INVALID_VALUE);
\r
1107 es2::Context *context = es2::getContext();
\r
1111 GLuint drawFramebufferName = context->getDrawFramebufferName();
\r
1113 if((drawFramebufferName == 0) && (n != 1))
\r
1115 return error(GL_INVALID_OPERATION);
\r
1118 for(int i = 0; i < n; ++i)
\r
1123 if(drawFramebufferName != 0)
\r
1125 return error(GL_INVALID_OPERATION);
\r
1130 case GL_COLOR_ATTACHMENT0:
\r
1131 case GL_COLOR_ATTACHMENT1:
\r
1132 case GL_COLOR_ATTACHMENT2:
\r
1133 case GL_COLOR_ATTACHMENT3:
\r
1134 case GL_COLOR_ATTACHMENT4:
\r
1135 case GL_COLOR_ATTACHMENT5:
\r
1136 case GL_COLOR_ATTACHMENT6:
\r
1137 case GL_COLOR_ATTACHMENT7:
\r
1138 case GL_COLOR_ATTACHMENT8:
\r
1139 case GL_COLOR_ATTACHMENT9:
\r
1140 case GL_COLOR_ATTACHMENT10:
\r
1141 case GL_COLOR_ATTACHMENT11:
\r
1142 case GL_COLOR_ATTACHMENT12:
\r
1143 case GL_COLOR_ATTACHMENT13:
\r
1144 case GL_COLOR_ATTACHMENT14:
\r
1145 case GL_COLOR_ATTACHMENT15:
\r
1147 GLuint index = (bufs[i] - GL_COLOR_ATTACHMENT0);
\r
1148 if(index >= es2::IMPLEMENTATION_MAX_COLOR_ATTACHMENTS)
\r
1150 return error(GL_INVALID_ENUM);
\r
1154 return error(GL_INVALID_OPERATION);
\r
1156 if(drawFramebufferName == 0)
\r
1158 return error(GL_INVALID_OPERATION);
\r
1163 return error(GL_INVALID_ENUM);
\r
1167 context->setDrawFramebufferColorIndices(n, bufs);
\r
1171 GL_APICALL void GL_APIENTRY glUniformMatrix2x3fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat *value)
\r
1173 TRACE("(GLint location = %d, GLsizei count = %d, GLboolean transpose = %d, const GLfloat *value = %p)", location, count, transpose, value);
\r
1177 return error(GL_INVALID_VALUE);
\r
1180 if(location == -1)
\r
1185 es2::Context *context = es2::getContext();
\r
1189 es2::Program *program = context->getCurrentProgram();
\r
1193 return error(GL_INVALID_OPERATION);
\r
1196 if(!program->setUniformMatrix2x3fv(location, count, transpose, value))
\r
1198 return error(GL_INVALID_OPERATION);
\r
1203 GL_APICALL void GL_APIENTRY glUniformMatrix3x2fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat *value)
\r
1205 TRACE("(GLint location = %d, GLsizei count = %d, GLboolean transpose = %d, const GLfloat *value = %p)", location, count, transpose, value);
\r
1209 return error(GL_INVALID_VALUE);
\r
1212 if(location == -1)
\r
1217 es2::Context *context = es2::getContext();
\r
1221 es2::Program *program = context->getCurrentProgram();
\r
1225 return error(GL_INVALID_OPERATION);
\r
1228 if(!program->setUniformMatrix3x2fv(location, count, transpose, value))
\r
1230 return error(GL_INVALID_OPERATION);
\r
1235 GL_APICALL void GL_APIENTRY glUniformMatrix2x4fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat *value)
\r
1237 TRACE("(GLint location = %d, GLsizei count = %d, GLboolean transpose = %d, const GLfloat *value = %p)", location, count, transpose, value);
\r
1241 return error(GL_INVALID_VALUE);
\r
1244 if(location == -1)
\r
1249 es2::Context *context = es2::getContext();
\r
1253 es2::Program *program = context->getCurrentProgram();
\r
1257 return error(GL_INVALID_OPERATION);
\r
1260 if(!program->setUniformMatrix2x4fv(location, count, transpose, value))
\r
1262 return error(GL_INVALID_OPERATION);
\r
1267 GL_APICALL void GL_APIENTRY glUniformMatrix4x2fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat *value)
\r
1269 TRACE("(GLint location = %d, GLsizei count = %d, GLboolean transpose = %d, const GLfloat *value = %p)", location, count, transpose, value);
\r
1273 return error(GL_INVALID_VALUE);
\r
1276 if(location == -1)
\r
1281 es2::Context *context = es2::getContext();
\r
1285 es2::Program *program = context->getCurrentProgram();
\r
1289 return error(GL_INVALID_OPERATION);
\r
1292 if(!program->setUniformMatrix4x2fv(location, count, transpose, value))
\r
1294 return error(GL_INVALID_OPERATION);
\r
1299 GL_APICALL void GL_APIENTRY glUniformMatrix3x4fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat *value)
\r
1301 TRACE("(GLint location = %d, GLsizei count = %d, GLboolean transpose = %d, const GLfloat *value = %p)", location, count, transpose, value);
\r
1305 return error(GL_INVALID_VALUE);
\r
1308 if(location == -1)
\r
1313 es2::Context *context = es2::getContext();
\r
1317 es2::Program *program = context->getCurrentProgram();
\r
1321 return error(GL_INVALID_OPERATION);
\r
1324 if(!program->setUniformMatrix3x4fv(location, count, transpose, value))
\r
1326 return error(GL_INVALID_OPERATION);
\r
1331 GL_APICALL void GL_APIENTRY glUniformMatrix4x3fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat *value)
\r
1333 TRACE("(GLint location = %d, GLsizei count = %d, GLboolean transpose = %d, const GLfloat *value = %p)", location, count, transpose, value);
\r
1337 return error(GL_INVALID_VALUE);
\r
1340 if(location == -1)
\r
1345 es2::Context *context = es2::getContext();
\r
1349 es2::Program *program = context->getCurrentProgram();
\r
1353 return error(GL_INVALID_OPERATION);
\r
1356 if(!program->setUniformMatrix4x3fv(location, count, transpose, value))
\r
1358 return error(GL_INVALID_OPERATION);
\r
1363 GL_APICALL void GL_APIENTRY glBlitFramebuffer(GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, GLbitfield mask, GLenum filter)
\r
1365 TRACE("(GLint srcX0 = %d, GLint srcY0 = %d, GLint srcX1 = %d, GLint srcY1 = %d, "
\r
1366 "GLint dstX0 = %d, GLint dstY0 = %d, GLint dstX1 = %d, GLint dstY1 = %d, "
\r
1367 "GLbitfield mask = 0x%X, GLenum filter = 0x%X)",
\r
1368 srcX0, srcY0, srcX1, srcX1, dstX0, dstY0, dstX1, dstY1, mask, filter);
\r
1376 return error(GL_INVALID_ENUM);
\r
1379 if((mask & ~(GL_COLOR_BUFFER_BIT | GL_STENCIL_BUFFER_BIT | GL_DEPTH_BUFFER_BIT)) != 0)
\r
1381 return error(GL_INVALID_VALUE);
\r
1384 es2::Context *context = es2::getContext();
\r
1388 if(context->getReadFramebufferName() == context->getDrawFramebufferName())
\r
1390 ERR("Blits with the same source and destination framebuffer are not supported by this implementation.");
\r
1391 return error(GL_INVALID_OPERATION);
\r
1394 context->blitFramebuffer(srcX0, srcY0, srcX1, srcY1, dstX0, dstY0, dstX1, dstY1, mask);
\r
1398 GL_APICALL void GL_APIENTRY glRenderbufferStorageMultisample(GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height)
\r
1400 TRACE("(GLenum target = 0x%X, GLsizei samples = %d, GLenum internalformat = 0x%X, GLsizei width = %d, GLsizei height = %d)",
\r
1401 target, samples, internalformat, width, height);
\r
1405 case GL_RENDERBUFFER:
\r
1408 return error(GL_INVALID_ENUM);
\r
1411 if(width < 0 || height < 0 || samples < 0)
\r
1413 return error(GL_INVALID_VALUE);
\r
1416 es2::Context *context = es2::getContext();
\r
1420 if(width > es2::IMPLEMENTATION_MAX_RENDERBUFFER_SIZE ||
\r
1421 height > es2::IMPLEMENTATION_MAX_RENDERBUFFER_SIZE ||
\r
1422 samples > es2::IMPLEMENTATION_MAX_SAMPLES)
\r
1424 return error(GL_INVALID_VALUE);
\r
1427 GLuint handle = context->getRenderbufferName();
\r
1430 return error(GL_INVALID_OPERATION);
\r
1433 switch(internalformat)
\r
1435 case GL_DEPTH_COMPONENT16:
\r
1436 case GL_DEPTH_COMPONENT24:
\r
1437 case GL_DEPTH_COMPONENT32F:
\r
1438 context->setRenderbufferStorage(new es2::Depthbuffer(width, height, samples));
\r
1460 case GL_RGB10_A2UI:
\r
1467 return error(GL_INVALID_OPERATION);
\r
1472 case GL_SRGB8_ALPHA8:
\r
1478 context->setRenderbufferStorage(new es2::Colorbuffer(width, height, internalformat, samples));
\r
1480 case GL_STENCIL_INDEX8:
\r
1481 context->setRenderbufferStorage(new es2::Stencilbuffer(width, height, samples));
\r
1483 case GL_DEPTH24_STENCIL8:
\r
1484 case GL_DEPTH32F_STENCIL8:
\r
1485 context->setRenderbufferStorage(new es2::DepthStencilbuffer(width, height, samples));
\r
1489 return error(GL_INVALID_ENUM);
\r
1494 GL_APICALL void GL_APIENTRY glFramebufferTextureLayer(GLenum target, GLenum attachment, GLuint texture, GLint level, GLint layer)
\r
1496 TRACE("(GLenum target = 0x%X, GLenum attachment = 0x%X, GLuint texture = %d, GLint level = %d, GLint layer = %d)",
\r
1497 target, attachment, texture, level, layer);
\r
1499 if(texture != 0 && layer < 0 || level < 0)
\r
1501 return error(GL_INVALID_VALUE);
\r
1504 es2::Context *context = es2::getContext();
\r
1508 Texture* textureObject = context->getTexture(texture);
\r
1511 if(!textureObject)
\r
1513 return error(GL_INVALID_VALUE);
\r
1516 switch(textureObject->getTarget())
\r
1518 case GL_TEXTURE_3D:
\r
1519 case GL_TEXTURE_2D_ARRAY:
\r
1520 if(layer >= es2::IMPLEMENTATION_MAX_TEXTURE_SIZE || (level >= es2::IMPLEMENTATION_MAX_TEXTURE_LEVELS))
\r
1522 return error(GL_INVALID_VALUE);
\r
1526 return error(GL_INVALID_OPERATION);
\r
1529 if(textureObject->isCompressed(target, level))
\r
1531 return error(GL_INVALID_OPERATION);
\r
1535 es2::Framebuffer *framebuffer = nullptr;
\r
1538 case GL_DRAW_FRAMEBUFFER:
\r
1539 case GL_FRAMEBUFFER:
\r
1540 framebuffer = context->getDrawFramebuffer();
\r
1542 case GL_READ_FRAMEBUFFER:
\r
1543 framebuffer = context->getReadFramebuffer();
\r
1546 return error(GL_INVALID_ENUM);
\r
1549 switch(attachment)
\r
1551 case GL_COLOR_ATTACHMENT0:
\r
1552 case GL_COLOR_ATTACHMENT1:
\r
1553 case GL_COLOR_ATTACHMENT2:
\r
1554 case GL_COLOR_ATTACHMENT3:
\r
1555 case GL_COLOR_ATTACHMENT4:
\r
1556 case GL_COLOR_ATTACHMENT5:
\r
1557 case GL_COLOR_ATTACHMENT6:
\r
1558 case GL_COLOR_ATTACHMENT7:
\r
1559 case GL_COLOR_ATTACHMENT8:
\r
1560 case GL_COLOR_ATTACHMENT9:
\r
1561 case GL_COLOR_ATTACHMENT10:
\r
1562 case GL_COLOR_ATTACHMENT11:
\r
1563 case GL_COLOR_ATTACHMENT12:
\r
1564 case GL_COLOR_ATTACHMENT13:
\r
1565 case GL_COLOR_ATTACHMENT14:
\r
1566 case GL_COLOR_ATTACHMENT15:
\r
1567 if(!framebuffer || framebuffer->getColorbufferName(attachment - GL_COLOR_ATTACHMENT0) == 0)
\r
1569 return error(GL_INVALID_OPERATION);
\r
1571 framebuffer->setColorbuffer(target, texture, attachment - GL_COLOR_ATTACHMENT0, layer, level);
\r
1573 case GL_DEPTH_ATTACHMENT:
\r
1574 if(!framebuffer || framebuffer->getDepthbufferName() == 0)
\r
1576 return error(GL_INVALID_OPERATION);
\r
1578 framebuffer->setDepthbuffer(target, texture, layer, level);
\r
1580 case GL_STENCIL_ATTACHMENT:
\r
1581 if(!framebuffer || framebuffer->getStencilbufferName() == 0)
\r
1583 return error(GL_INVALID_OPERATION);
\r
1585 framebuffer->setStencilbuffer(target, texture, layer, level);
\r
1587 case GL_DEPTH_STENCIL_ATTACHMENT:
\r
1588 if(!framebuffer || framebuffer->getDepthbufferName() == 0 || framebuffer->getStencilbufferName() == 0)
\r
1590 return error(GL_INVALID_OPERATION);
\r
1592 framebuffer->setDepthbuffer(target, texture, layer, level);
\r
1593 framebuffer->setStencilbuffer(target, texture, layer, level);
\r
1596 return error(GL_INVALID_ENUM);
\r
1601 GL_APICALL void *GL_APIENTRY glMapBufferRange(GLenum target, GLintptr offset, GLsizeiptr length, GLbitfield access)
\r
1603 TRACE("(GLenum target = 0x%X, GLintptr offset = %d, GLsizeiptr length = %d, GLbitfield access = %X)",
\r
1604 target, offset, length, access);
\r
1606 es2::Context *context = es2::getContext();
\r
1610 es2::Buffer *buffer = nullptr;
\r
1611 if(!context->getBuffer(target, &buffer))
\r
1613 return error(GL_INVALID_ENUM, nullptr);
\r
1618 // A null buffer means that "0" is bound to the requested buffer target
\r
1619 return error(GL_INVALID_OPERATION, nullptr);
\r
1622 GLint bufferSize = buffer->size();
\r
1623 if((offset < 0) || (length < 0) || ((offset + length) > bufferSize))
\r
1625 error(GL_INVALID_VALUE);
\r
1628 if((access & ~(GL_MAP_READ_BIT |
\r
1629 GL_MAP_WRITE_BIT |
\r
1630 GL_MAP_INVALIDATE_RANGE_BIT |
\r
1631 GL_MAP_INVALIDATE_BUFFER_BIT |
\r
1632 GL_MAP_FLUSH_EXPLICIT_BIT |
\r
1633 GL_MAP_UNSYNCHRONIZED_BIT)) != 0)
\r
1635 error(GL_INVALID_VALUE);
\r
1638 return buffer->mapRange(offset, length, access);
\r
1644 GL_APICALL void GL_APIENTRY glFlushMappedBufferRange(GLenum target, GLintptr offset, GLsizeiptr length)
\r
1646 TRACE("(GLenum target = 0x%X, GLintptr offset = %d, GLsizeiptr length = %d)",
\r
1647 target, offset, length);
\r
1649 es2::Context *context = es2::getContext();
\r
1653 es2::Buffer *buffer = nullptr;
\r
1654 if(!context->getBuffer(target, &buffer))
\r
1656 return error(GL_INVALID_ENUM);
\r
1661 // A null buffer means that "0" is bound to the requested buffer target
\r
1662 return error(GL_INVALID_OPERATION);
\r
1665 GLint bufferSize = buffer->size();
\r
1666 if((offset < 0) || (length < 0) || ((offset + length) > bufferSize))
\r
1668 error(GL_INVALID_VALUE);
\r
1671 buffer->flushMappedRange(offset, length);
\r
1675 GL_APICALL void GL_APIENTRY glBindVertexArray(GLuint array)
\r
1677 TRACE("(GLuint array = %d)", array);
\r
1684 es2::Context *context = es2::getContext();
\r
1686 if(context && !context->bindVertexArray(array))
\r
1688 return error(GL_INVALID_OPERATION);
\r
1692 GL_APICALL void GL_APIENTRY glDeleteVertexArrays(GLsizei n, const GLuint *arrays)
\r
1694 TRACE("(GLsizei n = %d, const GLuint *arrays = %p)", n, arrays);
\r
1698 return error(GL_INVALID_VALUE);
\r
1701 es2::Context *context = es2::getContext();
\r
1705 for(int i = 0; i < n; i++)
\r
1707 context->deleteVertexArray(arrays[i]);
\r
1712 GL_APICALL void GL_APIENTRY glGenVertexArrays(GLsizei n, GLuint *arrays)
\r
1714 TRACE("(GLsizei n = %d, const GLuint *arrays = %p)", n, arrays);
\r
1718 return error(GL_INVALID_VALUE);
\r
1721 es2::Context *context = es2::getContext();
\r
1725 for(int i = 0; i < n; i++)
\r
1727 arrays[i] = context->createVertexArray();
\r
1732 GL_APICALL GLboolean GL_APIENTRY glIsVertexArray(GLuint array)
\r
1734 TRACE("(GLuint array = %d)", array);
\r
1741 es2::Context *context = es2::getContext();
\r
1745 es2::VertexArray *arrayObject = context->getVertexArray(array);
\r
1756 GL_APICALL void GL_APIENTRY glGetIntegeri_v(GLenum target, GLuint index, GLint *data)
\r
1758 TRACE("(GLenum target = 0x%X, GLuint index = %d, GLint* data = %p)",
\r
1759 target, index, data);
\r
1761 es2::Context *context = es2::getContext();
\r
1765 if(!context->getTransformFeedbackiv(index, target, data) &&
\r
1766 !context->getIntegerv(target, data))
\r
1768 GLenum nativeType;
\r
1769 unsigned int numParams = 0;
\r
1770 if(!context->getQueryParameterInfo(target, &nativeType, &numParams))
\r
1771 return error(GL_INVALID_ENUM);
\r
1773 if(numParams == 0)
\r
1774 return; // it is known that target is valid, but there are no parameters to return
\r
1776 if(nativeType == GL_BOOL)
\r
1778 GLboolean *boolParams = NULL;
\r
1779 boolParams = new GLboolean[numParams];
\r
1781 context->getBooleanv(target, boolParams);
\r
1783 for(unsigned int i = 0; i < numParams; ++i)
\r
1785 data[i] = (boolParams[i] == GL_FALSE) ? 0 : 1;
\r
1788 delete[] boolParams;
\r
1790 else if(nativeType == GL_FLOAT)
\r
1792 GLfloat *floatParams = NULL;
\r
1793 floatParams = new GLfloat[numParams];
\r
1795 context->getFloatv(target, floatParams);
\r
1797 for(unsigned int i = 0; i < numParams; ++i)
\r
1799 if(target == GL_DEPTH_RANGE || target == GL_COLOR_CLEAR_VALUE || target == GL_DEPTH_CLEAR_VALUE || target == GL_BLEND_COLOR)
\r
1801 data[i] = es2::floatToInt(floatParams[i]);
\r
1805 data[i] = (GLint)(floatParams[i] > 0.0f ? floor(floatParams[i] + 0.5) : ceil(floatParams[i] - 0.5));
\r
1809 delete[] floatParams;
\r
1815 GL_APICALL void GL_APIENTRY glBeginTransformFeedback(GLenum primitiveMode)
\r
1817 TRACE("(GLenum primitiveMode = 0x%X)", primitiveMode);
\r
1819 switch(primitiveMode)
\r
1823 case GL_TRIANGLES:
\r
1826 return error(GL_INVALID_ENUM);
\r
1829 es2::Context *context = es2::getContext();
\r
1833 es2::TransformFeedback *transformFeedbackObject = context->getTransformFeedback();
\r
1835 if(transformFeedbackObject)
\r
1837 if(transformFeedbackObject->isActive())
\r
1839 return error(GL_INVALID_OPERATION);
\r
1841 transformFeedbackObject->begin(primitiveMode);
\r
1845 return error(GL_INVALID_OPERATION);
\r
1850 GL_APICALL void GL_APIENTRY glEndTransformFeedback(void)
\r
1854 es2::Context *context = es2::getContext();
\r
1858 es2::TransformFeedback *transformFeedbackObject = context->getTransformFeedback();
\r
1860 if(transformFeedbackObject)
\r
1862 if(!transformFeedbackObject->isActive())
\r
1864 return error(GL_INVALID_OPERATION);
\r
1866 transformFeedbackObject->end();
\r
1870 return error(GL_INVALID_OPERATION);
\r
1875 GL_APICALL void GL_APIENTRY glBindBufferRange(GLenum target, GLuint index, GLuint buffer, GLintptr offset, GLsizeiptr size)
\r
1877 TRACE("(GLenum target = 0x%X, GLuint index = %d, GLuint buffer = %d, GLintptr offset = %d, GLsizeiptr size = %d)",
\r
1878 target, index, buffer, offset, size);
\r
1880 if(buffer != 0 && size <= 0)
\r
1882 return error(GL_INVALID_VALUE);
\r
1885 es2::Context *context = es2::getContext();
\r
1891 case GL_TRANSFORM_FEEDBACK_BUFFER:
\r
1892 if(index >= es2::IMPLEMENTATION_MAX_TRANSFORM_FEEDBACK_SEPARATE_ATTRIBS)
\r
1894 return error(GL_INVALID_VALUE);
\r
1896 if(size & 0x3 || offset & 0x3) // size and offset must be multiples of 4
\r
1898 return error(GL_INVALID_VALUE);
\r
1900 context->bindIndexedTransformFeedbackBuffer(buffer, index, offset, size);
\r
1901 context->bindGenericTransformFeedbackBuffer(buffer);
\r
1903 case GL_UNIFORM_BUFFER:
\r
1904 if(index >= es2::IMPLEMENTATION_MAX_UNIFORM_BUFFER_BINDINGS)
\r
1906 return error(GL_INVALID_VALUE);
\r
1908 if(offset % es2::IMPLEMENTATION_UNIFORM_BUFFER_OFFSET_ALIGNMENT != 0)
\r
1910 return error(GL_INVALID_VALUE);
\r
1912 context->bindIndexedUniformBuffer(buffer, index, offset, size);
\r
1913 context->bindGenericUniformBuffer(buffer);
\r
1916 return error(GL_INVALID_ENUM);
\r
1921 GL_APICALL void GL_APIENTRY glBindBufferBase(GLenum target, GLuint index, GLuint buffer)
\r
1923 TRACE("(GLenum target = 0x%X, GLuint index = %d, GLuint buffer = %d)",
\r
1924 target, index, buffer);
\r
1926 es2::Context *context = es2::getContext();
\r
1932 case GL_TRANSFORM_FEEDBACK_BUFFER:
\r
1933 if(index >= es2::IMPLEMENTATION_MAX_TRANSFORM_FEEDBACK_SEPARATE_ATTRIBS)
\r
1935 return error(GL_INVALID_VALUE);
\r
1937 context->bindIndexedTransformFeedbackBuffer(buffer, index, 0, 0);
\r
1938 context->bindGenericTransformFeedbackBuffer(buffer);
\r
1940 case GL_UNIFORM_BUFFER:
\r
1941 if(index >= es2::IMPLEMENTATION_MAX_UNIFORM_BUFFER_BINDINGS)
\r
1943 return error(GL_INVALID_VALUE);
\r
1945 context->bindIndexedUniformBuffer(buffer, index, 0, 0);
\r
1946 context->bindGenericUniformBuffer(buffer);
\r
1949 return error(GL_INVALID_ENUM);
\r
1954 GL_APICALL void GL_APIENTRY glTransformFeedbackVaryings(GLuint program, GLsizei count, const GLchar *const*varyings, GLenum bufferMode)
\r
1956 TRACE("(GLuint program = %d, GLsizei count = %d, const GLchar *const*varyings = %p, GLenum bufferMode = 0x%X)",
\r
1957 program, count, varyings, bufferMode);
\r
1959 switch(bufferMode)
\r
1961 case GL_SEPARATE_ATTRIBS:
\r
1962 if(count > es2::IMPLEMENTATION_MAX_TRANSFORM_FEEDBACK_SEPARATE_ATTRIBS)
\r
1964 return error(GL_INVALID_VALUE);
\r
1966 case GL_INTERLEAVED_ATTRIBS:
\r
1969 return error(GL_INVALID_ENUM);
\r
1972 es2::Context *context = es2::getContext();
\r
1976 es2::Program *programObject = context->getProgram(program);
\r
1978 if(!programObject)
\r
1980 return error(GL_INVALID_VALUE);
\r
1983 programObject->setTransformFeedbackVaryings(count, varyings, bufferMode);
\r
1987 GL_APICALL void GL_APIENTRY glGetTransformFeedbackVarying(GLuint program, GLuint index, GLsizei bufSize, GLsizei *length, GLsizei *size, GLenum *type, GLchar *name)
\r
1989 TRACE("(GLuint program = %d, GLuint index = %d, GLsizei bufSize = %d, GLsizei *length = %p, GLsizei *size = %p, GLenum *type = %p, GLchar *name = %p)",
\r
1990 program, index, bufSize, length, size, type, name);
\r
1994 return error(GL_INVALID_VALUE);
\r
1997 es2::Context *context = es2::getContext();
\r
2001 es2::Program *programObject = context->getProgram(program);
\r
2003 if(!programObject)
\r
2005 return error(GL_INVALID_VALUE);
\r
2008 if(index >= static_cast<GLuint>(programObject->getTransformFeedbackVaryingCount()))
\r
2010 return error(GL_INVALID_VALUE);
\r
2013 programObject->getTransformFeedbackVarying(index, bufSize, length, size, type, name);
\r
2017 GL_APICALL void GL_APIENTRY glVertexAttribIPointer(GLuint index, GLint size, GLenum type, GLsizei stride, const void *pointer)
\r
2019 TRACE("(GLuint program = %d, GLuint index = %d, GLsizei bufSize = %d, GLsizei *length = %p, GLsizei *size = %p, GLenum *type = %p, GLchar *name = %p)",
\r
2020 index, size, type, stride, pointer);
\r
2022 if(index >= es2::MAX_VERTEX_ATTRIBS)
\r
2024 return error(GL_INVALID_VALUE);
\r
2027 if(size < 1 || size > 4 || stride < 0)
\r
2029 return error(GL_INVALID_VALUE);
\r
2035 case GL_UNSIGNED_BYTE:
\r
2037 case GL_UNSIGNED_SHORT:
\r
2039 case GL_UNSIGNED_INT:
\r
2042 return error(GL_INVALID_ENUM);
\r
2045 es2::Context *context = es2::getContext();
\r
2049 context->setVertexAttribState(index, context->getArrayBuffer(), size, type, false, stride, pointer);
\r
2053 GL_APICALL void GL_APIENTRY glGetVertexAttribIiv(GLuint index, GLenum pname, GLint *params)
\r
2055 TRACE("(GLuint index = %d, GLenum pname = 0x%X, GLint *params = %p)",
\r
2056 index, pname, params);
\r
2058 es2::Context *context = es2::getContext();
\r
2062 if(index >= es2::MAX_VERTEX_ATTRIBS)
\r
2064 return error(GL_INVALID_VALUE);
\r
2067 const es2::VertexAttribute &attribState = context->getVertexAttribState(index);
\r
2071 case GL_VERTEX_ATTRIB_ARRAY_ENABLED:
\r
2072 *params = (attribState.mArrayEnabled ? GL_TRUE : GL_FALSE);
\r
2074 case GL_VERTEX_ATTRIB_ARRAY_SIZE:
\r
2075 *params = attribState.mSize;
\r
2077 case GL_VERTEX_ATTRIB_ARRAY_STRIDE:
\r
2078 *params = attribState.mStride;
\r
2080 case GL_VERTEX_ATTRIB_ARRAY_TYPE:
\r
2081 *params = attribState.mType;
\r
2083 case GL_VERTEX_ATTRIB_ARRAY_NORMALIZED:
\r
2084 *params = (attribState.mNormalized ? GL_TRUE : GL_FALSE);
\r
2086 case GL_VERTEX_ATTRIB_ARRAY_BUFFER_BINDING:
\r
2087 *params = attribState.mBoundBuffer.name();
\r
2089 case GL_CURRENT_VERTEX_ATTRIB:
\r
2091 const VertexAttribute& attrib = context->getCurrentVertexAttributes()[index];
\r
2092 for(int i = 0; i < 4; ++i)
\r
2094 params[i] = attrib.getCurrentValueI(i);
\r
2098 case GL_VERTEX_ATTRIB_ARRAY_INTEGER:
\r
2099 switch(attribState.mType)
\r
2102 case GL_UNSIGNED_BYTE:
\r
2104 case GL_UNSIGNED_SHORT:
\r
2106 case GL_INT_2_10_10_10_REV:
\r
2107 case GL_UNSIGNED_INT:
\r
2109 *params = GL_TRUE;
\r
2112 *params = GL_FALSE;
\r
2116 case GL_VERTEX_ATTRIB_ARRAY_DIVISOR:
\r
2117 *params = attribState.mDivisor;
\r
2119 default: return error(GL_INVALID_ENUM);
\r
2124 GL_APICALL void GL_APIENTRY glGetVertexAttribIuiv(GLuint index, GLenum pname, GLuint *params)
\r
2126 TRACE("(GLuint index = %d, GLenum pname = 0x%X, GLuint *params = %p)",
\r
2127 index, pname, params);
\r
2129 es2::Context *context = es2::getContext();
\r
2133 if(index >= es2::MAX_VERTEX_ATTRIBS)
\r
2135 return error(GL_INVALID_VALUE);
\r
2138 const es2::VertexAttribute &attribState = context->getVertexAttribState(index);
\r
2142 case GL_VERTEX_ATTRIB_ARRAY_ENABLED:
\r
2143 *params = (attribState.mArrayEnabled ? GL_TRUE : GL_FALSE);
\r
2145 case GL_VERTEX_ATTRIB_ARRAY_SIZE:
\r
2146 *params = attribState.mSize;
\r
2148 case GL_VERTEX_ATTRIB_ARRAY_STRIDE:
\r
2149 *params = attribState.mStride;
\r
2151 case GL_VERTEX_ATTRIB_ARRAY_TYPE:
\r
2152 *params = attribState.mType;
\r
2154 case GL_VERTEX_ATTRIB_ARRAY_NORMALIZED:
\r
2155 *params = (attribState.mNormalized ? GL_TRUE : GL_FALSE);
\r
2157 case GL_VERTEX_ATTRIB_ARRAY_BUFFER_BINDING:
\r
2158 *params = attribState.mBoundBuffer.name();
\r
2160 case GL_CURRENT_VERTEX_ATTRIB:
\r
2162 const VertexAttribute& attrib = context->getCurrentVertexAttributes()[index];
\r
2163 for(int i = 0; i < 4; ++i)
\r
2165 params[i] = attrib.getCurrentValueUI(i);
\r
2169 case GL_VERTEX_ATTRIB_ARRAY_INTEGER:
\r
2170 switch(attribState.mType)
\r
2173 case GL_UNSIGNED_BYTE:
\r
2175 case GL_UNSIGNED_SHORT:
\r
2177 case GL_INT_2_10_10_10_REV:
\r
2178 case GL_UNSIGNED_INT:
\r
2180 *params = GL_TRUE;
\r
2183 *params = GL_FALSE;
\r
2187 case GL_VERTEX_ATTRIB_ARRAY_DIVISOR:
\r
2188 *params = attribState.mDivisor;
\r
2190 default: return error(GL_INVALID_ENUM);
\r
2195 GL_APICALL void GL_APIENTRY glVertexAttribI4i(GLuint index, GLint x, GLint y, GLint z, GLint w)
\r
2197 TRACE("(GLuint index = %d, GLint x = %d, GLint y = %d, GLint z = %d, GLint w = %d)",
\r
2198 index, x, y, z, w);
\r
2200 if(index >= es2::MAX_VERTEX_ATTRIBS)
\r
2202 return error(GL_INVALID_VALUE);
\r
2205 es2::Context *context = es2::getContext();
\r
2209 GLint vals[4] = { x, y, z, w };
\r
2210 context->setVertexAttrib(index, vals);
\r
2214 GL_APICALL void GL_APIENTRY glVertexAttribI4ui(GLuint index, GLuint x, GLuint y, GLuint z, GLuint w)
\r
2216 TRACE("(GLuint index = %d, GLint x = %d, GLint y = %d, GLint z = %d, GLint w = %d)",
\r
2217 index, x, y, z, w);
\r
2219 if(index >= es2::MAX_VERTEX_ATTRIBS)
\r
2221 return error(GL_INVALID_VALUE);
\r
2224 es2::Context *context = es2::getContext();
\r
2228 GLuint vals[4] = { x, y, z, w };
\r
2229 context->setVertexAttrib(index, vals);
\r
2233 GL_APICALL void GL_APIENTRY glVertexAttribI4iv(GLuint index, const GLint *v)
\r
2235 TRACE("(GLuint index = %d, GLint *v = %p)", index, v);
\r
2237 if(index >= es2::MAX_VERTEX_ATTRIBS)
\r
2239 return error(GL_INVALID_VALUE);
\r
2242 es2::Context *context = es2::getContext();
\r
2246 context->setVertexAttrib(index, v);
\r
2250 GL_APICALL void GL_APIENTRY glVertexAttribI4uiv(GLuint index, const GLuint *v)
\r
2252 TRACE("(GLuint index = %d, GLint *v = %p)", index, v);
\r
2254 if(index >= es2::MAX_VERTEX_ATTRIBS)
\r
2256 return error(GL_INVALID_VALUE);
\r
2259 es2::Context *context = es2::getContext();
\r
2263 context->setVertexAttrib(index, v);
\r
2267 GL_APICALL void GL_APIENTRY glGetUniformuiv(GLuint program, GLint location, GLuint *params)
\r
2269 TRACE("(GLuint program = %d, GLint location = %d, GLuint *params = %p)",
\r
2270 program, location, params);
\r
2272 es2::Context *context = es2::getContext();
\r
2278 return error(GL_INVALID_VALUE);
\r
2281 es2::Program *programObject = context->getProgram(program);
\r
2283 if(!programObject || !programObject->isLinked())
\r
2285 return error(GL_INVALID_OPERATION);
\r
2288 if(!programObject)
\r
2290 return error(GL_INVALID_OPERATION);
\r
2293 if(!programObject->getUniformuiv(location, NULL, params))
\r
2295 return error(GL_INVALID_OPERATION);
\r
2300 GL_APICALL GLint GL_APIENTRY glGetFragDataLocation(GLuint program, const GLchar *name)
\r
2302 TRACE("(GLuint program = %d, const GLchar *name = %p)", program, name);
\r
2304 es2::Context *context = es2::getContext();
\r
2306 if(strstr(name, "gl_") == name)
\r
2313 es2::Program *programObject = context->getProgram(program);
\r
2315 if(!programObject)
\r
2317 if(context->getShader(program))
\r
2319 return error(GL_INVALID_OPERATION, -1);
\r
2323 return error(GL_INVALID_VALUE, -1);
\r
2327 if(!programObject->isLinked())
\r
2329 return error(GL_INVALID_OPERATION, -1);
\r
2337 GL_APICALL void GL_APIENTRY glUniform1ui(GLint location, GLuint v0)
\r
2339 glUniform1uiv(location, 1, &v0);
\r
2342 GL_APICALL void GL_APIENTRY glUniform2ui(GLint location, GLuint v0, GLuint v1)
\r
2344 GLuint xy[2] = { v0, v1 };
\r
2346 glUniform2uiv(location, 1, (GLuint*)&xy);
\r
2349 GL_APICALL void GL_APIENTRY glUniform3ui(GLint location, GLuint v0, GLuint v1, GLuint v2)
\r
2351 GLuint xyz[3] = { v0, v1, v2 };
\r
2353 glUniform3uiv(location, 1, (GLuint*)&xyz);
\r
2356 GL_APICALL void GL_APIENTRY glUniform4ui(GLint location, GLuint v0, GLuint v1, GLuint v2, GLuint v3)
\r
2358 GLuint xyzw[4] = { v0, v1, v2, v3 };
\r
2360 glUniform4uiv(location, 1, (GLuint*)&xyzw);
\r
2363 GL_APICALL void GL_APIENTRY glUniform1uiv(GLint location, GLsizei count, const GLuint *value)
\r
2365 TRACE("(GLint location = %d, GLsizei count = %d, const GLuint *value = %p)",
\r
2366 location, count, value);
\r
2370 return error(GL_INVALID_VALUE);
\r
2373 if(location == -1)
\r
2378 es2::Context *context = es2::getContext();
\r
2382 es2::Program *program = context->getCurrentProgram();
\r
2386 return error(GL_INVALID_OPERATION);
\r
2389 if(!program->setUniform1uiv(location, count, value))
\r
2391 return error(GL_INVALID_OPERATION);
\r
2396 GL_APICALL void GL_APIENTRY glUniform2uiv(GLint location, GLsizei count, const GLuint *value)
\r
2398 TRACE("(GLint location = %d, GLsizei count = %d, const GLuint *value = %p)",
\r
2399 location, count, value);
\r
2403 return error(GL_INVALID_VALUE);
\r
2406 if(location == -1)
\r
2411 es2::Context *context = es2::getContext();
\r
2415 es2::Program *program = context->getCurrentProgram();
\r
2419 return error(GL_INVALID_OPERATION);
\r
2422 if(!program->setUniform2uiv(location, count, value))
\r
2424 return error(GL_INVALID_OPERATION);
\r
2429 GL_APICALL void GL_APIENTRY glUniform3uiv(GLint location, GLsizei count, const GLuint *value)
\r
2431 TRACE("(GLint location = %d, GLsizei count = %d, const GLuint *value = %p)",
\r
2432 location, count, value);
\r
2436 return error(GL_INVALID_VALUE);
\r
2439 if(location == -1)
\r
2444 es2::Context *context = es2::getContext();
\r
2448 es2::Program *program = context->getCurrentProgram();
\r
2452 return error(GL_INVALID_OPERATION);
\r
2455 if(!program->setUniform3uiv(location, count, value))
\r
2457 return error(GL_INVALID_OPERATION);
\r
2462 GL_APICALL void GL_APIENTRY glUniform4uiv(GLint location, GLsizei count, const GLuint *value)
\r
2464 TRACE("(GLint location = %d, GLsizei count = %d, const GLuint *value = %p)",
\r
2465 location, count, value);
\r
2469 return error(GL_INVALID_VALUE);
\r
2472 if(location == -1)
\r
2477 es2::Context *context = es2::getContext();
\r
2481 es2::Program *program = context->getCurrentProgram();
\r
2485 return error(GL_INVALID_OPERATION);
\r
2488 if(!program->setUniform4uiv(location, count, value))
\r
2490 return error(GL_INVALID_OPERATION);
\r
2495 GL_APICALL void GL_APIENTRY glClearBufferiv(GLenum buffer, GLint drawbuffer, const GLint *value)
\r
2497 TRACE("(GLenum buffer = 0x%X, GLint drawbuffer = %d, const GLint *value = %p)",
\r
2498 buffer, drawbuffer, value);
\r
2500 es2::Context *context = es2::getContext();
\r
2507 if(drawbuffer < 0 || drawbuffer >= es2::IMPLEMENTATION_MAX_DRAW_BUFFERS)
\r
2509 return error(GL_INVALID_VALUE);
\r
2513 context->clearColorBuffer(drawbuffer, value);
\r
2517 if(drawbuffer != 0)
\r
2519 return error(GL_INVALID_VALUE);
\r
2523 context->clearStencilBuffer(drawbuffer, value);
\r
2527 return error(GL_INVALID_ENUM);
\r
2532 GL_APICALL void GL_APIENTRY glClearBufferuiv(GLenum buffer, GLint drawbuffer, const GLuint *value)
\r
2534 TRACE("(GLenum buffer = 0x%X, GLint drawbuffer = %d, const GLuint *value = %p)",
\r
2535 buffer, drawbuffer, value);
\r
2537 es2::Context *context = es2::getContext();
\r
2544 if(drawbuffer < 0 || drawbuffer >= es2::IMPLEMENTATION_MAX_DRAW_BUFFERS)
\r
2546 return error(GL_INVALID_VALUE);
\r
2550 context->clearColorBuffer(drawbuffer, value);
\r
2554 return error(GL_INVALID_ENUM);
\r
2559 GL_APICALL void GL_APIENTRY glClearBufferfv(GLenum buffer, GLint drawbuffer, const GLfloat *value)
\r
2561 TRACE("(GLenum buffer = 0x%X, GLint drawbuffer = %d, const GLfloat *value = %p)",
\r
2562 buffer, drawbuffer, value);
\r
2564 es2::Context *context = es2::getContext();
\r
2571 if(drawbuffer < 0 || drawbuffer >= es2::IMPLEMENTATION_MAX_DRAW_BUFFERS)
\r
2573 return error(GL_INVALID_VALUE);
\r
2577 context->clearColorBuffer(drawbuffer, value);
\r
2581 if(drawbuffer != 0)
\r
2583 return error(GL_INVALID_VALUE);
\r
2587 context->clearDepthBuffer(drawbuffer, value);
\r
2591 return error(GL_INVALID_ENUM);
\r
2596 GL_APICALL void GL_APIENTRY glClearBufferfi(GLenum buffer, GLint drawbuffer, GLfloat depth, GLint stencil)
\r
2598 TRACE("(GLenum buffer = 0x%X, GLint drawbuffer = %d, GLfloat depth = %f, GLint stencil = %d)",
\r
2599 buffer, drawbuffer, depth, stencil);
\r
2601 es2::Context *context = es2::getContext();
\r
2607 case GL_DEPTH_STENCIL:
\r
2608 if(drawbuffer != 0)
\r
2610 return error(GL_INVALID_VALUE);
\r
2614 context->clearDepthStencilBuffer(drawbuffer, depth, stencil);
\r
2618 return error(GL_INVALID_ENUM);
\r
2623 GL_APICALL const GLubyte *GL_APIENTRY glGetStringi(GLenum name, GLuint index)
\r
2625 TRACE("(GLenum name = 0x%X, GLuint index = %d)", name, index);
\r
2627 es2::Context *context = es2::getContext();
\r
2630 GLuint numExtensions;
\r
2631 context->getExtensions(0, &numExtensions);
\r
2633 if(index >= numExtensions)
\r
2635 return error(GL_INVALID_VALUE, (GLubyte*)NULL);
\r
2640 case GL_EXTENSIONS:
\r
2641 return context->getExtensions(index);
\r
2643 return error(GL_INVALID_ENUM, (GLubyte*)NULL);
\r
2647 return (GLubyte*)NULL;
\r
2650 GL_APICALL void GL_APIENTRY glCopyBufferSubData(GLenum readTarget, GLenum writeTarget, GLintptr readOffset, GLintptr writeOffset, GLsizeiptr size)
\r
2652 TRACE("(GLenum readTarget = 0x%X, GLenum writeTarget = 0x%X, GLintptr readOffset = %d, GLintptr writeOffset = %d, GLsizeiptr size = %d)",
\r
2653 readTarget, writeTarget, readOffset, writeOffset, size);
\r
2655 if(readOffset < 0 || writeOffset < 0 || size < 0)
\r
2657 return error(GL_INVALID_VALUE);
\r
2660 es2::Context *context = es2::getContext();
\r
2664 es2::Buffer *readBuffer = nullptr, *writeBuffer = nullptr;
\r
2665 if(!context->getBuffer(readTarget, &readBuffer) || !context->getBuffer(writeTarget, &writeBuffer))
\r
2667 return error(GL_INVALID_ENUM);
\r
2669 if(!readBuffer || readBuffer->isMapped() || !writeBuffer || writeBuffer->isMapped())
\r
2671 return error(GL_INVALID_OPERATION);
\r
2673 if((readBuffer == writeBuffer) && // If same buffer, check for overlap
\r
2674 ((readOffset >= writeOffset) && (readOffset < (writeOffset + size)) ||
\r
2675 (writeOffset >= readOffset) && (writeOffset < (readOffset + size))))
\r
2677 return error(GL_INVALID_VALUE);
\r
2679 if((static_cast<size_t>(readOffset + size) > readBuffer->size()) ||
\r
2680 (static_cast<size_t>(writeOffset + size) > writeBuffer->size()))
\r
2682 return error(GL_INVALID_VALUE);
\r
2685 writeBuffer->bufferSubData(((char*)readBuffer->data()) + readOffset, size, writeOffset);
\r
2689 GL_APICALL void GL_APIENTRY glGetUniformIndices(GLuint program, GLsizei uniformCount, const GLchar *const*uniformNames, GLuint *uniformIndices)
\r
2691 TRACE("(GLuint program = %d, GLsizei uniformCount = %d, const GLchar *const*uniformNames = %p, GLuint *uniformIndices = %p)",
\r
2692 program, uniformCount, uniformNames, uniformIndices);
\r
2694 if (uniformCount < 0)
\r
2696 return error(GL_INVALID_VALUE);
\r
2699 es2::Context *context = es2::getContext();
\r
2703 es2::Program *programObject = context->getProgram(program);
\r
2705 if(!programObject)
\r
2707 return error(GL_INVALID_OPERATION);
\r
2710 if(!programObject->isLinked())
\r
2712 for(int uniformId = 0; uniformId < uniformCount; uniformId++)
\r
2714 uniformIndices[uniformId] = GL_INVALID_INDEX;
\r
2719 for(int uniformId = 0; uniformId < uniformCount; uniformId++)
\r
2721 uniformIndices[uniformId] = programObject->getUniformIndex(uniformNames[uniformId]);
\r
2727 GL_APICALL void GL_APIENTRY glGetActiveUniformsiv(GLuint program, GLsizei uniformCount, const GLuint *uniformIndices, GLenum pname, GLint *params)
\r
2729 TRACE("(GLuint program = %d, GLsizei uniformCount = %d, const GLchar *const*uniformNames = %p, GLenum pname = 0x%X, GLuint *uniformIndices = %p)",
\r
2730 program, uniformCount, uniformIndices, pname, uniformIndices);
\r
2734 case GL_UNIFORM_TYPE:
\r
2735 case GL_UNIFORM_SIZE:
\r
2736 case GL_UNIFORM_NAME_LENGTH:
\r
2737 case GL_UNIFORM_BLOCK_INDEX:
\r
2738 case GL_UNIFORM_OFFSET:
\r
2739 case GL_UNIFORM_ARRAY_STRIDE:
\r
2740 case GL_UNIFORM_MATRIX_STRIDE:
\r
2741 case GL_UNIFORM_IS_ROW_MAJOR:
\r
2744 return error(GL_INVALID_ENUM);
\r
2747 es2::Context *context = es2::getContext();
\r
2751 es2::Program *programObject = context->getProgram(program);
\r
2753 if(!programObject)
\r
2755 return error(GL_INVALID_OPERATION);
\r
2758 for(int uniformId = 0; uniformId < uniformCount; uniformId++)
\r
2760 const GLuint index = uniformIndices[uniformId];
\r
2762 if(index >= programObject->getActiveUniformCount())
\r
2764 return error(GL_INVALID_VALUE);
\r
2768 for(int uniformId = 0; uniformId < uniformCount; uniformId++)
\r
2770 const GLuint index = uniformIndices[uniformId];
\r
2771 params[uniformId] = programObject->getActiveUniformi(index, pname);
\r
2776 GL_APICALL GLuint GL_APIENTRY glGetUniformBlockIndex(GLuint program, const GLchar *uniformBlockName)
\r
2778 TRACE("(GLuint program = %d, const GLchar *uniformBlockName = %p)",
\r
2779 program, uniformBlockName);
\r
2781 es2::Context *context = es2::getContext();
\r
2785 es2::Program *programObject = context->getProgram(program);
\r
2787 if(!programObject)
\r
2789 return error(GL_INVALID_OPERATION, GL_INVALID_INDEX);
\r
2792 return programObject->getUniformBlockIndex(uniformBlockName);
\r
2795 return GL_INVALID_INDEX;
\r
2798 GL_APICALL void GL_APIENTRY glGetActiveUniformBlockiv(GLuint program, GLuint uniformBlockIndex, GLenum pname, GLint *params)
\r
2800 TRACE("(GLuint program = %d, GLuint uniformBlockIndex = %d, GLenum pname = 0x%X, GLint *params = %p)",
\r
2801 program, uniformBlockIndex, pname, params);
\r
2803 es2::Context *context = es2::getContext();
\r
2807 es2::Program *programObject = context->getProgram(program);
\r
2809 if(!programObject)
\r
2811 return error(GL_INVALID_OPERATION);
\r
2816 case GL_UNIFORM_BLOCK_BINDING:
\r
2817 *params = static_cast<GLint>(programObject->getUniformBlockBinding(uniformBlockIndex));
\r
2819 case GL_UNIFORM_BLOCK_DATA_SIZE:
\r
2820 case GL_UNIFORM_BLOCK_NAME_LENGTH:
\r
2821 case GL_UNIFORM_BLOCK_ACTIVE_UNIFORMS:
\r
2822 case GL_UNIFORM_BLOCK_ACTIVE_UNIFORM_INDICES:
\r
2823 case GL_UNIFORM_BLOCK_REFERENCED_BY_VERTEX_SHADER:
\r
2824 case GL_UNIFORM_BLOCK_REFERENCED_BY_FRAGMENT_SHADER:
\r
2825 programObject->getActiveUniformBlockiv(uniformBlockIndex, pname, params);
\r
2828 return error(GL_INVALID_ENUM);
\r
2833 GL_APICALL void GL_APIENTRY glGetActiveUniformBlockName(GLuint program, GLuint uniformBlockIndex, GLsizei bufSize, GLsizei *length, GLchar *uniformBlockName)
\r
2835 TRACE("(GLuint program = %d, GLuint uniformBlockIndex = %d, GLsizei bufSize = %d, GLsizei *length = %p, GLchar *uniformBlockName = %p)",
\r
2836 program, uniformBlockIndex, bufSize, length, uniformBlockName);
\r
2838 es2::Context *context = es2::getContext();
\r
2842 es2::Program *programObject = context->getProgram(program);
\r
2844 if(!programObject)
\r
2846 return error(GL_INVALID_OPERATION);
\r
2849 programObject->getActiveUniformBlockName(uniformBlockIndex, bufSize, length, uniformBlockName);
\r
2853 GL_APICALL void GL_APIENTRY glUniformBlockBinding(GLuint program, GLuint uniformBlockIndex, GLuint uniformBlockBinding)
\r
2855 TRACE("(GLuint program = %d, GLuint uniformBlockIndex = %d, GLuint uniformBlockBinding = %d)",
\r
2856 program, uniformBlockIndex, uniformBlockBinding);
\r
2858 if(uniformBlockBinding >= es2::IMPLEMENTATION_MAX_UNIFORM_BUFFER_BINDINGS)
\r
2860 return error(GL_INVALID_VALUE);
\r
2863 es2::Context *context = es2::getContext();
\r
2867 es2::Program *programObject = context->getProgram(program);
\r
2869 if(!programObject)
\r
2871 return error(GL_INVALID_VALUE);
\r
2874 programObject->bindUniformBlock(uniformBlockIndex, uniformBlockIndex);
\r
2878 GL_APICALL void GL_APIENTRY glDrawArraysInstanced(GLenum mode, GLint first, GLsizei count, GLsizei instanceCount)
\r
2880 TRACE("(GLenum mode = 0x%X, GLint first = %d, GLsizei count = %d, GLsizei instanceCount = %d)",
\r
2881 mode, first, count, instanceCount);
\r
2887 case GL_LINE_LOOP:
\r
2888 case GL_LINE_STRIP:
\r
2889 case GL_TRIANGLES:
\r
2890 case GL_TRIANGLE_FAN:
\r
2891 case GL_TRIANGLE_STRIP:
\r
2894 return error(GL_INVALID_ENUM);
\r
2897 if(count < 0 || instanceCount < 0)
\r
2899 return error(GL_INVALID_VALUE);
\r
2902 es2::Context *context = es2::getContext();
\r
2906 es2::TransformFeedback* transformFeedback = context->getTransformFeedback();
\r
2907 if(transformFeedback && transformFeedback->isActive() && (mode != transformFeedback->primitiveMode()))
\r
2909 return error(GL_INVALID_OPERATION);
\r
2912 context->drawArrays(mode, first, count, instanceCount);
\r
2916 GL_APICALL void GL_APIENTRY glDrawElementsInstanced(GLenum mode, GLsizei count, GLenum type, const void *indices, GLsizei instanceCount)
\r
2918 TRACE("(GLenum mode = 0x%X, GLsizei count = %d, GLenum type = 0x%X, const void *indices = %p, GLsizei instanceCount = %d)",
\r
2919 mode, count, type, indices, instanceCount);
\r
2925 case GL_LINE_LOOP:
\r
2926 case GL_LINE_STRIP:
\r
2927 case GL_TRIANGLES:
\r
2928 case GL_TRIANGLE_FAN:
\r
2929 case GL_TRIANGLE_STRIP:
\r
2932 return error(GL_INVALID_ENUM);
\r
2937 case GL_UNSIGNED_BYTE:
\r
2938 case GL_UNSIGNED_SHORT:
\r
2939 case GL_UNSIGNED_INT:
\r
2942 return error(GL_INVALID_ENUM);
\r
2945 if(count < 0 || instanceCount < 0)
\r
2947 return error(GL_INVALID_VALUE);
\r
2950 es2::Context *context = es2::getContext();
\r
2954 es2::TransformFeedback* transformFeedback = context->getTransformFeedback();
\r
2955 if(transformFeedback && transformFeedback->isActive() && !transformFeedback->isPaused())
\r
2957 return error(GL_INVALID_OPERATION);
\r
2960 context->drawElements(mode, 0, MAX_ELEMENT_INDEX, count, type, indices, instanceCount);
\r
2964 GL_APICALL GLsync GL_APIENTRY glFenceSync(GLenum condition, GLbitfield flags)
\r
2966 TRACE("(GLenum condition = 0x%X, GLbitfield flags = %X)", condition, flags);
\r
2970 case GL_SYNC_GPU_COMMANDS_COMPLETE:
\r
2973 return error(GL_INVALID_ENUM, nullptr);
\r
2978 return error(GL_INVALID_VALUE, nullptr);
\r
2981 es2::Context *context = es2::getContext();
\r
2985 return context->createFenceSync(condition, flags);
\r
2991 GL_APICALL GLboolean GL_APIENTRY glIsSync(GLsync sync)
\r
2993 TRACE("(GLsync sync = %p)", sync);
\r
2995 es2::Context *context = es2::getContext();
\r
2999 es2::FenceSync *fenceSyncObject = context->getFenceSync(sync);
\r
3001 if(fenceSyncObject)
\r
3010 GL_APICALL void GL_APIENTRY glDeleteSync(GLsync sync)
\r
3012 TRACE("(GLsync sync = %p)", sync);
\r
3014 es2::Context *context = es2::getContext();
\r
3018 context->deleteFenceSync(sync);
\r
3022 GL_APICALL GLenum GL_APIENTRY glClientWaitSync(GLsync sync, GLbitfield flags, GLuint64 timeout)
\r
3024 TRACE("(GLsync sync = %p, GLbitfield flags = %X, GLuint64 timeout = %llu)", sync, flags, timeout);
\r
3026 if((flags & ~(GL_SYNC_FLUSH_COMMANDS_BIT)) != 0)
\r
3028 error(GL_INVALID_VALUE);
\r
3031 es2::Context *context = es2::getContext();
\r
3035 es2::FenceSync *fenceSyncObject = context->getFenceSync(sync);
\r
3037 if(fenceSyncObject)
\r
3039 return fenceSyncObject->clientWait(flags, timeout);
\r
3043 return error(GL_INVALID_VALUE, GL_FALSE);
\r
3050 GL_APICALL void GL_APIENTRY glWaitSync(GLsync sync, GLbitfield flags, GLuint64 timeout)
\r
3052 TRACE("(GLsync sync = %p, GLbitfield flags = %X, GLuint64 timeout = %llu)", sync, flags, timeout);
\r
3056 return error(GL_INVALID_VALUE);
\r
3059 if(timeout != GL_TIMEOUT_IGNORED)
\r
3061 return error(GL_INVALID_VALUE);
\r
3064 es2::Context *context = es2::getContext();
\r
3068 es2::FenceSync *fenceSyncObject = context->getFenceSync(sync);
\r
3070 if(fenceSyncObject)
\r
3072 fenceSyncObject->serverWait(flags, timeout);
\r
3076 return error(GL_INVALID_VALUE);
\r
3081 GL_APICALL void GL_APIENTRY glGetInteger64v(GLenum pname, GLint64 *data)
\r
3083 TRACE("(GLenum pname = 0x%X, GLint64 *data = %p)", pname, data);
\r
3085 es2::Context *context = es2::getContext();
\r
3089 if(!(context->getIntegerv(pname, data)))
\r
3091 GLenum nativeType;
\r
3092 unsigned int numParams = 0;
\r
3093 if(!context->getQueryParameterInfo(pname, &nativeType, &numParams))
\r
3094 return error(GL_INVALID_ENUM);
\r
3096 if(numParams == 0)
\r
3097 return; // it is known that pname is valid, but there are no parameters to return
\r
3099 if(nativeType == GL_BOOL)
\r
3101 GLboolean *boolParams = NULL;
\r
3102 boolParams = new GLboolean[numParams];
\r
3104 context->getBooleanv(pname, boolParams);
\r
3106 for(unsigned int i = 0; i < numParams; ++i)
\r
3108 data[i] = (boolParams[i] == GL_FALSE) ? 0 : 1;
\r
3111 delete[] boolParams;
\r
3113 else if(nativeType == GL_FLOAT)
\r
3115 GLfloat *floatParams = NULL;
\r
3116 floatParams = new GLfloat[numParams];
\r
3118 context->getFloatv(pname, floatParams);
\r
3120 for(unsigned int i = 0; i < numParams; ++i)
\r
3122 if(pname == GL_DEPTH_RANGE || pname == GL_COLOR_CLEAR_VALUE || pname == GL_DEPTH_CLEAR_VALUE || pname == GL_BLEND_COLOR)
\r
3124 data[i] = (GLint64)(es2::floatToInt(floatParams[i]));
\r
3128 data[i] = (GLint64)(floatParams[i] > 0.0f ? floor(floatParams[i] + 0.5) : ceil(floatParams[i] - 0.5));
\r
3132 delete[] floatParams;
\r
3138 GL_APICALL void GL_APIENTRY glGetSynciv(GLsync sync, GLenum pname, GLsizei bufSize, GLsizei *length, GLint *values)
\r
3140 TRACE("(GLsync sync = %p, GLenum pname = 0x%X, GLsizei bufSize = %d, GLsizei *length = %p, GLint *values = %p)",
\r
3141 sync, pname, bufSize, length, values);
\r
3146 GL_APICALL void GL_APIENTRY glGetInteger64i_v(GLenum target, GLuint index, GLint64 *data)
\r
3148 TRACE("(GLenum target = 0x%X, GLuint index = %d, GLint64 *data = %p)", target, index, data);
\r
3150 es2::Context *context = es2::getContext();
\r
3154 if(!context->getTransformFeedbackiv(index, target, data) &&
\r
3155 !context->getIntegerv(target, data))
\r
3157 GLenum nativeType;
\r
3158 unsigned int numParams = 0;
\r
3159 if(!context->getQueryParameterInfo(target, &nativeType, &numParams))
\r
3160 return error(GL_INVALID_ENUM);
\r
3162 if(numParams == 0)
\r
3163 return; // it is known that target is valid, but there are no parameters to return
\r
3165 if(nativeType == GL_BOOL)
\r
3167 GLboolean *boolParams = NULL;
\r
3168 boolParams = new GLboolean[numParams];
\r
3170 context->getBooleanv(target, boolParams);
\r
3172 for(unsigned int i = 0; i < numParams; ++i)
\r
3174 data[i] = (boolParams[i] == GL_FALSE) ? 0 : 1;
\r
3177 delete[] boolParams;
\r
3179 else if(nativeType == GL_FLOAT)
\r
3181 GLfloat *floatParams = NULL;
\r
3182 floatParams = new GLfloat[numParams];
\r
3184 context->getFloatv(target, floatParams);
\r
3186 for(unsigned int i = 0; i < numParams; ++i)
\r
3188 if(target == GL_DEPTH_RANGE || target == GL_COLOR_CLEAR_VALUE || target == GL_DEPTH_CLEAR_VALUE || target == GL_BLEND_COLOR)
\r
3190 data[i] = (GLint64)(es2::floatToInt(floatParams[i]));
\r
3194 data[i] = (GLint64)(floatParams[i] > 0.0f ? floor(floatParams[i] + 0.5) : ceil(floatParams[i] - 0.5));
\r
3198 delete[] floatParams;
\r
3204 GL_APICALL void GL_APIENTRY glGetBufferParameteri64v(GLenum target, GLenum pname, GLint64 *params)
\r
3206 TRACE("(GLenum target = 0x%X, GLenum pname = 0x%X, GLint64 *params = %p)", target, pname, params);
\r
3208 es2::Context *context = es2::getContext();
\r
3212 es2::Buffer *buffer = nullptr;
\r
3214 if(!context->getBuffer(target, &buffer))
\r
3216 return error(GL_INVALID_ENUM);
\r
3221 // A null buffer means that "0" is bound to the requested buffer target
\r
3222 return error(GL_INVALID_OPERATION);
\r
3227 case GL_BUFFER_USAGE:
\r
3228 *params = buffer->usage();
\r
3230 case GL_BUFFER_SIZE:
\r
3231 *params = buffer->size();
\r
3233 case GL_BUFFER_ACCESS_FLAGS:
\r
3234 *params = buffer->access();
\r
3236 case GL_BUFFER_MAPPED:
\r
3237 *params = buffer->isMapped();
\r
3239 case GL_BUFFER_MAP_LENGTH:
\r
3240 *params = buffer->length();
\r
3242 case GL_BUFFER_MAP_OFFSET:
\r
3243 *params = buffer->offset();
\r
3246 return error(GL_INVALID_ENUM);
\r
3251 GL_APICALL void GL_APIENTRY glGenSamplers(GLsizei count, GLuint *samplers)
\r
3253 TRACE("(GLsizei count = %d, GLuint *samplers = %p)", count, samplers);
\r
3257 return error(GL_INVALID_VALUE);
\r
3260 es2::Context *context = es2::getContext();
\r
3264 for(int i = 0; i < count; i++)
\r
3266 samplers[i] = context->createSampler();
\r
3271 GL_APICALL void GL_APIENTRY glDeleteSamplers(GLsizei count, const GLuint *samplers)
\r
3273 TRACE("(GLsizei count = %d, GLuint *samplers = %p)", count, samplers);
\r
3277 return error(GL_INVALID_VALUE);
\r
3280 es2::Context *context = es2::getContext();
\r
3284 for(int i = 0; i < count; i++)
\r
3286 context->deleteSampler(samplers[i]);
\r
3291 GL_APICALL GLboolean GL_APIENTRY glIsSampler(GLuint sampler)
\r
3293 TRACE("(GLuint sampler = %d)", sampler);
\r
3300 es2::Context *context = es2::getContext();
\r
3304 es2::Sampler *samplerObject = context->getSampler(sampler);
\r
3315 GL_APICALL void GL_APIENTRY glBindSampler(GLuint unit, GLuint sampler)
\r
3317 TRACE("(GLuint unit = %d, GLuint sampler = %d)", unit, sampler);
\r
3319 if(unit >= es2::MAX_COMBINED_TEXTURE_IMAGE_UNITS)
\r
3321 return error(GL_INVALID_VALUE);
\r
3324 es2::Context *context = es2::getContext();
\r
3330 es2::Sampler *samplerObject = context->getSampler(sampler);
\r
3332 if(!samplerObject)
\r
3334 return error(GL_INVALID_OPERATION);
\r
3338 context->bindSampler(unit, sampler);
\r
3342 GL_APICALL void GL_APIENTRY glSamplerParameteri(GLuint sampler, GLenum pname, GLint param)
\r
3344 TRACE("(GLuint sampler = %d, GLenum pname = 0x%X, GLint param = %d)",
\r
3345 sampler, pname, param);
\r
3347 glSamplerParameteriv(sampler, pname, ¶m);
\r
3350 GL_APICALL void GL_APIENTRY glSamplerParameteriv(GLuint sampler, GLenum pname, const GLint *param)
\r
3352 TRACE("(GLuint sampler = %d, GLenum pname = 0x%X, const GLint *param = %p)",
\r
3353 sampler, pname, param);
\r
3355 es2::Context *context = es2::getContext();
\r
3359 es2::Sampler *samplerObject = (sampler != 0) ? context->getSampler(sampler) : nullptr;
\r
3361 if(!samplerObject)
\r
3363 return error(GL_INVALID_VALUE);
\r
3368 case GL_TEXTURE_WRAP_S:
\r
3371 case GL_CLAMP_TO_EDGE:
\r
3372 case GL_MIRRORED_REPEAT:
\r
3374 samplerObject->mWrapModeS = *param;
\r
3377 return error(GL_INVALID_ENUM);
\r
3380 case GL_TEXTURE_WRAP_T:
\r
3383 case GL_CLAMP_TO_EDGE:
\r
3384 case GL_MIRRORED_REPEAT:
\r
3386 samplerObject->mWrapModeT = *param;
\r
3389 return error(GL_INVALID_ENUM);
\r
3392 case GL_TEXTURE_WRAP_R:
\r
3395 case GL_CLAMP_TO_EDGE:
\r
3396 case GL_MIRRORED_REPEAT:
\r
3398 samplerObject->mWrapModeR = *param;
\r
3401 return error(GL_INVALID_ENUM);
\r
3404 case GL_TEXTURE_MIN_FILTER:
\r
3409 case GL_NEAREST_MIPMAP_NEAREST:
\r
3410 case GL_LINEAR_MIPMAP_NEAREST:
\r
3411 case GL_NEAREST_MIPMAP_LINEAR:
\r
3412 case GL_LINEAR_MIPMAP_LINEAR:
\r
3413 samplerObject->mMinFilter = *param;
\r
3416 return error(GL_INVALID_ENUM);
\r
3419 case GL_TEXTURE_MAG_FILTER:
\r
3424 samplerObject->mMagFilter = *param;
\r
3427 return error(GL_INVALID_ENUM);
\r
3430 case GL_TEXTURE_MIN_LOD:
\r
3431 samplerObject->mMinLod = (GLfloat)*param;
\r
3433 case GL_TEXTURE_MAX_LOD:
\r
3434 samplerObject->mMaxLod = (GLfloat)*param;
\r
3436 case GL_TEXTURE_COMPARE_MODE:
\r
3439 case GL_COMPARE_REF_TO_TEXTURE:
\r
3441 samplerObject->mCompareMode = *param;
\r
3444 return error(GL_INVALID_ENUM);
\r
3447 case GL_TEXTURE_COMPARE_FUNC:
\r
3458 samplerObject->mCompareFunc = *param;
\r
3461 return error(GL_INVALID_ENUM);
\r
3465 return error(GL_INVALID_ENUM);
\r
3470 GL_APICALL void GL_APIENTRY glSamplerParameterf(GLuint sampler, GLenum pname, GLfloat param)
\r
3472 TRACE("(GLuint sampler = %d, GLenum pname = 0x%X, GLfloat param = %f)",
\r
3473 sampler, pname, param);
\r
3475 glSamplerParameterfv(sampler, pname, ¶m);
\r
3478 GL_APICALL void GL_APIENTRY glSamplerParameterfv(GLuint sampler, GLenum pname, const GLfloat *param)
\r
3480 TRACE("(GLuint sampler = %d, GLenum pname = 0x%X, const GLfloat *param = %p)",
\r
3481 sampler, pname, param);
\r
3483 es2::Context *context = es2::getContext();
\r
3487 es2::Sampler *samplerObject = (sampler != 0) ? context->getSampler(sampler) : nullptr;
\r
3489 if(!samplerObject)
\r
3491 return error(GL_INVALID_VALUE);
\r
3496 case GL_TEXTURE_WRAP_S:
\r
3497 switch((GLenum)*param)
\r
3499 case GL_CLAMP_TO_EDGE:
\r
3500 case GL_MIRRORED_REPEAT:
\r
3502 samplerObject->mWrapModeS = (GLenum)*param;
\r
3505 return error(GL_INVALID_ENUM);
\r
3508 case GL_TEXTURE_WRAP_T:
\r
3509 switch((GLenum)*param)
\r
3511 case GL_CLAMP_TO_EDGE:
\r
3512 case GL_MIRRORED_REPEAT:
\r
3514 samplerObject->mWrapModeT = (GLenum)*param;
\r
3517 return error(GL_INVALID_ENUM);
\r
3520 case GL_TEXTURE_WRAP_R:
\r
3521 switch((GLenum)*param)
\r
3523 case GL_CLAMP_TO_EDGE:
\r
3524 case GL_MIRRORED_REPEAT:
\r
3526 samplerObject->mWrapModeR = (GLenum)*param;
\r
3529 return error(GL_INVALID_ENUM);
\r
3532 case GL_TEXTURE_MIN_FILTER:
\r
3533 switch((GLenum)*param)
\r
3537 case GL_NEAREST_MIPMAP_NEAREST:
\r
3538 case GL_LINEAR_MIPMAP_NEAREST:
\r
3539 case GL_NEAREST_MIPMAP_LINEAR:
\r
3540 case GL_LINEAR_MIPMAP_LINEAR:
\r
3541 samplerObject->mMinFilter = (GLenum)*param;
\r
3544 return error(GL_INVALID_ENUM);
\r
3547 case GL_TEXTURE_MAG_FILTER:
\r
3548 switch((GLenum)*param)
\r
3552 samplerObject->mMagFilter = (GLenum)*param;
\r
3555 return error(GL_INVALID_ENUM);
\r
3558 case GL_TEXTURE_MIN_LOD:
\r
3559 samplerObject->mMinLod = *param;
\r
3561 case GL_TEXTURE_MAX_LOD:
\r
3562 samplerObject->mMaxLod = *param;
\r
3564 case GL_TEXTURE_COMPARE_MODE:
\r
3565 switch((GLenum)*param)
\r
3567 case GL_COMPARE_REF_TO_TEXTURE:
\r
3569 samplerObject->mCompareMode = (GLenum)*param;
\r
3572 return error(GL_INVALID_ENUM);
\r
3575 case GL_TEXTURE_COMPARE_FUNC:
\r
3576 switch((GLenum)*param)
\r
3586 samplerObject->mCompareFunc = (GLenum)*param;
\r
3589 return error(GL_INVALID_ENUM);
\r
3593 return error(GL_INVALID_ENUM);
\r
3598 GL_APICALL void GL_APIENTRY glGetSamplerParameteriv(GLuint sampler, GLenum pname, GLint *params)
\r
3600 TRACE("(GLuint sampler = %d, GLenum pname = 0x%X, GLint *params = %p)",
\r
3601 sampler, pname, params);
\r
3603 es2::Context *context = es2::getContext();
\r
3607 es2::Sampler *samplerObject = (sampler != 0) ? context->getSampler(sampler) : nullptr;
\r
3609 if(!samplerObject)
\r
3611 return error(GL_INVALID_VALUE);
\r
3616 case GL_TEXTURE_WRAP_S:
\r
3617 *params = samplerObject->mWrapModeS;
\r
3619 case GL_TEXTURE_WRAP_T:
\r
3620 *params = samplerObject->mWrapModeT;
\r
3622 case GL_TEXTURE_WRAP_R:
\r
3623 *params = samplerObject->mWrapModeR;
\r
3625 case GL_TEXTURE_MIN_FILTER:
\r
3626 *params = samplerObject->mMinFilter;
\r
3628 case GL_TEXTURE_MAG_FILTER:
\r
3629 *params = samplerObject->mMagFilter;
\r
3631 case GL_TEXTURE_MIN_LOD:
\r
3632 *params = (GLint)samplerObject->mMinLod;
\r
3634 case GL_TEXTURE_MAX_LOD:
\r
3635 *params = (GLint)samplerObject->mMaxLod;
\r
3637 case GL_TEXTURE_COMPARE_MODE:
\r
3638 *params = samplerObject->mCompareMode;
\r
3640 case GL_TEXTURE_COMPARE_FUNC:
\r
3641 *params = samplerObject->mCompareFunc;
\r
3644 return error(GL_INVALID_ENUM);
\r
3649 GL_APICALL void GL_APIENTRY glGetSamplerParameterfv(GLuint sampler, GLenum pname, GLfloat *params)
\r
3651 TRACE("(GLuint sampler = %d, GLenum pname = 0x%X, GLfloat *params = %p)",
\r
3652 sampler, pname, params);
\r
3654 es2::Context *context = es2::getContext();
\r
3658 es2::Sampler *samplerObject = (sampler != 0) ? context->getSampler(sampler) : nullptr;
\r
3660 if(!samplerObject)
\r
3662 return error(GL_INVALID_VALUE);
\r
3667 case GL_TEXTURE_WRAP_S:
\r
3668 *params = (GLfloat)samplerObject->mWrapModeS;
\r
3670 case GL_TEXTURE_WRAP_T:
\r
3671 *params = (GLfloat)samplerObject->mWrapModeT;
\r
3673 case GL_TEXTURE_WRAP_R:
\r
3674 *params = (GLfloat)samplerObject->mWrapModeR;
\r
3676 case GL_TEXTURE_MIN_FILTER:
\r
3677 *params = (GLfloat)samplerObject->mMinFilter;
\r
3679 case GL_TEXTURE_MAG_FILTER:
\r
3680 *params = (GLfloat)samplerObject->mMagFilter;
\r
3682 case GL_TEXTURE_MIN_LOD:
\r
3683 *params = samplerObject->mMinLod;
\r
3685 case GL_TEXTURE_MAX_LOD:
\r
3686 *params = samplerObject->mMaxLod;
\r
3688 case GL_TEXTURE_COMPARE_MODE:
\r
3689 *params = (GLfloat)samplerObject->mCompareMode;
\r
3691 case GL_TEXTURE_COMPARE_FUNC:
\r
3692 *params = (GLfloat)samplerObject->mCompareFunc;
\r
3695 return error(GL_INVALID_ENUM);
\r
3700 GL_APICALL void GL_APIENTRY glVertexAttribDivisor(GLuint index, GLuint divisor)
\r
3702 TRACE("(GLuint index = %d, GLuint divisor = %d)", index, divisor);
\r
3704 es2::Context *context = es2::getContext();
\r
3708 if(index >= es2::MAX_VERTEX_ATTRIBS)
\r
3710 return error(GL_INVALID_VALUE);
\r
3713 context->setVertexAttribDivisor(index, divisor);
\r
3717 GL_APICALL void GL_APIENTRY glBindTransformFeedback(GLenum target, GLuint id)
\r
3719 TRACE("(GLenum target = 0x%X, GLuint id = %d)", target, id);
\r
3721 if(target != GL_TRANSFORM_FEEDBACK)
\r
3723 return error(GL_INVALID_ENUM);
\r
3726 es2::Context *context = es2::getContext();
\r
3730 es2::TransformFeedback *transformFeedbackObject = context->getTransformFeedback();
\r
3732 if(transformFeedbackObject && transformFeedbackObject->isActive() && !transformFeedbackObject->isPaused())
\r
3734 return error(GL_INVALID_OPERATION);
\r
3737 if(!context->bindTransformFeedback(id))
\r
3739 return error(GL_INVALID_OPERATION);
\r
3744 GL_APICALL void GL_APIENTRY glDeleteTransformFeedbacks(GLsizei n, const GLuint *ids)
\r
3746 TRACE("(GLsizei n = %d, const GLuint *ids = %p)", n, ids);
\r
3750 return error(GL_INVALID_VALUE);
\r
3753 es2::Context *context = es2::getContext();
\r
3757 for(int i = 0; i < n; i++)
\r
3761 context->deleteTransformFeedback(ids[i]);
\r
3767 GL_APICALL void GL_APIENTRY glGenTransformFeedbacks(GLsizei n, GLuint *ids)
\r
3769 TRACE("(GLsizei n = %d, const GLuint *ids = %p)", n, ids);
\r
3773 return error(GL_INVALID_VALUE);
\r
3776 es2::Context *context = es2::getContext();
\r
3780 for(int i = 0; i < n; i++)
\r
3782 ids[i] = context->createTransformFeedback();
\r
3787 GL_APICALL GLboolean GL_APIENTRY glIsTransformFeedback(GLuint id)
\r
3789 TRACE("(GLuint id = %d)", id);
\r
3796 es2::Context *context = es2::getContext();
\r
3800 es2::TransformFeedback *transformFeedbackObject = context->getTransformFeedback(id);
\r
3802 if(transformFeedbackObject)
\r
3811 GL_APICALL void GL_APIENTRY glPauseTransformFeedback(void)
\r
3815 es2::Context *context = es2::getContext();
\r
3819 es2::TransformFeedback *transformFeedbackObject = context->getTransformFeedback();
\r
3821 if(transformFeedbackObject)
\r
3823 if(!transformFeedbackObject->isActive() || transformFeedbackObject->isPaused())
\r
3825 return error(GL_INVALID_OPERATION);
\r
3827 transformFeedbackObject->setPaused(true);
\r
3832 GL_APICALL void GL_APIENTRY glResumeTransformFeedback(void)
\r
3836 es2::Context *context = es2::getContext();
\r
3840 es2::TransformFeedback *transformFeedbackObject = context->getTransformFeedback();
\r
3842 if(transformFeedbackObject)
\r
3844 if(!transformFeedbackObject->isActive() || !transformFeedbackObject->isPaused())
\r
3846 return error(GL_INVALID_OPERATION);
\r
3848 transformFeedbackObject->setPaused(false);
\r
3853 GL_APICALL void GL_APIENTRY glGetProgramBinary(GLuint program, GLsizei bufSize, GLsizei *length, GLenum *binaryFormat, void *binary)
\r
3855 TRACE("(GLuint program = %d, GLsizei bufSize = %d, GLsizei *length = %p, GLenum *binaryFormat = %p, void *binary = %p)",
\r
3856 program, bufSize, length, binaryFormat, binary);
\r
3861 GL_APICALL void GL_APIENTRY glProgramBinary(GLuint program, GLenum binaryFormat, const void *binary, GLsizei length)
\r
3863 TRACE("(GLuint program = %d, GLenum binaryFormat = 0x%X, const void *binary = %p, GLsizei length = %d)",
\r
3864 program, binaryFormat, binaryFormat, length);
\r
3869 GL_APICALL void GL_APIENTRY glProgramParameteri(GLuint program, GLenum pname, GLint value)
\r
3871 TRACE("(GLuint program = %d, GLenum pname = 0x%X, GLint value = %d)",
\r
3872 program, pname, value);
\r
3874 es2::Context *context = es2::getContext();
\r
3878 es2::Program *programObject = context->getProgram(program);
\r
3880 if(!programObject)
\r
3882 return error(GL_INVALID_OPERATION);
\r
3887 case GL_PROGRAM_BINARY_RETRIEVABLE_HINT:
\r
3888 programObject->setBinaryRetrievable(value != GL_FALSE);
\r
3891 return error(GL_INVALID_ENUM);
\r
3896 GL_APICALL void GL_APIENTRY glInvalidateFramebuffer(GLenum target, GLsizei numAttachments, const GLenum *attachments)
\r
3898 TRACE("(GLenum target = 0x%X, GLsizei numAttachments = %d, const GLenum *attachments = %p)",
\r
3899 target, numAttachments, attachments);
\r
3904 GL_APICALL void GL_APIENTRY glInvalidateSubFramebuffer(GLenum target, GLsizei numAttachments, const GLenum *attachments, GLint x, GLint y, GLsizei width, GLsizei height)
\r
3906 TRACE("(GLenum target = 0x%X, GLsizei numAttachments = %d, const GLenum *attachments = %p, GLint x = %d, GLint y = %d, GLsizei width = %d, GLsizei height = %d)",
\r
3907 target, numAttachments, attachments, x, y, width, height);
\r
3912 GL_APICALL void GL_APIENTRY glTexStorage2D(GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height)
\r
3914 TRACE("(GLenum target = 0x%X, GLsizei levels = %d, GLenum internalformat = 0x%X, GLsizei width = %d, GLsizei height = %d)",
\r
3915 target, levels, internalformat, width, height);
\r
3917 if(width < 1 || height < 1 || levels < 1)
\r
3919 return error(GL_INVALID_VALUE);
\r
3922 if(levels > es2::IMPLEMENTATION_MAX_TEXTURE_LEVELS || levels > (log2(std::max(width, height)) + 1))
\r
3924 return error(GL_INVALID_OPERATION);
\r
3928 if(!GetStorageType(internalformat, type))
\r
3930 return error(GL_INVALID_ENUM);
\r
3933 es2::Context *context = es2::getContext();
\r
3939 case GL_TEXTURE_2D:
\r
3941 es2::Texture2D *texture = context->getTexture2D();
\r
3942 if(!texture || texture->name == 0 || texture->getImmutableFormat() == GL_TRUE)
\r
3944 return error(GL_INVALID_OPERATION);
\r
3947 for(int level = 0; level < levels; ++level)
\r
3949 texture->setImage(level, width, height, internalformat, type, context->getUnpackInfo(), NULL);
\r
3950 width = std::max(1, (width / 2));
\r
3951 height = std::max(1, (height / 2));
\r
3953 texture->setImmutableFormat(GL_TRUE);
\r
3956 case GL_TEXTURE_CUBE_MAP:
\r
3958 es2::TextureCubeMap *texture = context->getTextureCubeMap();
\r
3959 if(!texture || texture->name == 0 || texture->getImmutableFormat())
\r
3961 return error(GL_INVALID_OPERATION);
\r
3964 for(int level = 0; level < levels; ++level)
\r
3966 for(int face = GL_TEXTURE_CUBE_MAP_POSITIVE_X; face <= GL_TEXTURE_CUBE_MAP_NEGATIVE_Z; ++face)
\r
3968 texture->setImage(face, level, width, height, internalformat, type, context->getUnpackInfo(), NULL);
\r
3970 width = std::max(1, (width / 2));
\r
3971 height = std::max(1, (height / 2));
\r
3973 texture->setImmutableFormat(GL_TRUE);
\r
3977 return error(GL_INVALID_ENUM);
\r
3982 GL_APICALL void GL_APIENTRY glTexStorage3D(GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth)
\r
3984 TRACE("(GLenum target = 0x%X, GLsizei levels = %d, GLenum internalformat = 0x%X, GLsizei width = %d, GLsizei height = %d, GLsizei depth = %d)",
\r
3985 target, levels, internalformat, width, height, depth);
\r
3987 if(width < 1 || height < 1 || depth < 1 || levels < 1)
\r
3989 return error(GL_INVALID_VALUE);
\r
3993 if(!GetStorageType(internalformat, type))
\r
3995 return error(GL_INVALID_ENUM);
\r
3998 es2::Context *context = es2::getContext();
\r
4004 case GL_TEXTURE_3D:
\r
4006 if(levels > es2::IMPLEMENTATION_MAX_TEXTURE_LEVELS || levels >(log2(std::max(std::max(width, height), depth)) + 1))
\r
4008 return error(GL_INVALID_OPERATION);
\r
4011 es2::Texture3D *texture = context->getTexture3D();
\r
4012 if(!texture || texture->name == 0 || texture->getImmutableFormat() == GL_TRUE)
\r
4014 return error(GL_INVALID_OPERATION);
\r
4017 for(int level = 0; level < levels; ++level)
\r
4019 texture->setImage(level, width, height, depth, internalformat, type, context->getUnpackInfo(), NULL);
\r
4020 width = std::max(1, (width / 2));
\r
4021 height = std::max(1, (height / 2));
\r
4022 depth = std::max(1, (depth / 2));
\r
4024 texture->setImmutableFormat(GL_TRUE);
\r
4027 case GL_TEXTURE_2D_ARRAY:
\r
4029 if(levels > es2::IMPLEMENTATION_MAX_TEXTURE_LEVELS || levels >(log2(std::max(width, height)) + 1))
\r
4031 return error(GL_INVALID_OPERATION);
\r
4034 es2::Texture3D *texture = context->getTexture2DArray();
\r
4035 if(!texture || texture->name == 0 || texture->getImmutableFormat())
\r
4037 return error(GL_INVALID_OPERATION);
\r
4040 for(int level = 0; level < levels; ++level)
\r
4042 for(int face = GL_TEXTURE_CUBE_MAP_POSITIVE_X; face <= GL_TEXTURE_CUBE_MAP_NEGATIVE_Z; ++face)
\r
4044 texture->setImage(level, width, height, depth, internalformat, type, context->getUnpackInfo(), NULL);
\r
4046 width = std::max(1, (width / 2));
\r
4047 height = std::max(1, (height / 2));
\r
4049 texture->setImmutableFormat(GL_TRUE);
\r
4053 return error(GL_INVALID_ENUM);
\r
4058 GL_APICALL void GL_APIENTRY glGetInternalformativ(GLenum target, GLenum internalformat, GLenum pname, GLsizei bufSize, GLint *params)
\r
4060 TRACE("(GLenum target = 0x%X, GLenum internalformat = 0x%X, GLenum pname = 0x%X, GLsizei bufSize = %d, GLint *params = %p)",
\r
4061 target, internalformat, pname, bufSize, params);
\r
4065 return error(GL_INVALID_VALUE);
\r
4068 if(!IsColorRenderable(internalformat) && !IsDepthRenderable(internalformat) && !IsStencilRenderable(internalformat))
\r
4070 return error(GL_INVALID_ENUM);
\r
4075 case GL_RENDERBUFFER:
\r
4078 return error(GL_INVALID_ENUM);
\r
4081 sw::Format requestedFormat = es2sw::ConvertRenderbufferFormat(internalformat);
\r
4082 std::vector<GLint> supportedMultiSampleDepths;
\r
4083 int maxDepth = Context::getSupportedMultiSampleDepth(requestedFormat, INT_MAX);
\r
4084 for(int depth = maxDepth; depth > 1;)
\r
4086 supportedMultiSampleDepths.push_back(depth);
\r
4087 for(int nextDepth = depth - 1; nextDepth >= 0; --nextDepth)
\r
4089 int supportedDepth = Context::getSupportedMultiSampleDepth(requestedFormat, nextDepth);
\r
4090 if(supportedDepth != depth)
\r
4092 depth = supportedDepth;
\r
4101 *params = supportedMultiSampleDepths.size();
\r
4103 case GL_NUM_SAMPLE_COUNTS:
\r
4105 size_t returnCount = std::min<size_t>(bufSize, supportedMultiSampleDepths.size());
\r
4106 for(size_t sampleIndex = 0; sampleIndex < returnCount; ++sampleIndex)
\r
4108 params[sampleIndex] = supportedMultiSampleDepths[sampleIndex];
\r
4113 return error(GL_INVALID_ENUM);
\r