blob: 054e310acc30e89ec967e9cce6e2e71bfe4e19f0 [file] [log] [blame]
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001//
Geoff Lang48dcae72014-02-05 16:28:24 -05002// Copyright (c) 2002-2014 The ANGLE Project Authors. All rights reserved.
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003// Use of this source code is governed by a BSD-style license that can be
4// found in the LICENSE file.
5//
6
7// libGLESv2.cpp: Implements the exported OpenGL ES 2.0 functions.
8
daniel@transgaming.coma0ce7e62011-01-25 14:47:16 +00009#include "common/version.h"
Geoff Lang0b7eef72014-06-12 14:10:47 -040010#include "common/utilities.h"
daniel@transgaming.combbf56f72010-04-20 18:52:13 +000011
12#include "libGLESv2/main.h"
shannonwoods@chromium.org8dcfc6a2013-05-30 00:09:48 +000013#include "libGLESv2/formatutils.h"
daniel@transgaming.combbf56f72010-04-20 18:52:13 +000014#include "libGLESv2/Buffer.h"
apatrick@chromium.orgd3bd0ad2010-08-30 18:55:36 +000015#include "libGLESv2/Fence.h"
daniel@transgaming.combbf56f72010-04-20 18:52:13 +000016#include "libGLESv2/Framebuffer.h"
shannon.woods@transgaming.com486d9e92013-02-28 23:15:41 +000017#include "libGLESv2/Renderbuffer.h"
daniel@transgaming.combbf56f72010-04-20 18:52:13 +000018#include "libGLESv2/Program.h"
apatrick@chromium.orgea09f9b2012-06-08 00:45:32 +000019#include "libGLESv2/ProgramBinary.h"
daniel@transgaming.combbf56f72010-04-20 18:52:13 +000020#include "libGLESv2/Texture.h"
daniel@transgaming.com86bdb822012-01-20 18:24:39 +000021#include "libGLESv2/Query.h"
shannon.woods@transgaming.com486d9e92013-02-28 23:15:41 +000022#include "libGLESv2/Context.h"
Jamie Madill57a89722013-07-02 11:57:03 -040023#include "libGLESv2/VertexArray.h"
Brandon Jones5bf98292014-06-06 17:19:38 -070024#include "libGLESv2/VertexAttribute.h"
Geoff Langc8058452014-02-03 12:04:11 -050025#include "libGLESv2/TransformFeedback.h"
Jamie Madille261b442014-06-25 12:42:21 -040026#include "libGLESv2/FramebufferAttachment.h"
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +000027
Geoff Lange8ebe7f2013-08-05 15:03:13 -040028#include "libGLESv2/validationES.h"
29#include "libGLESv2/validationES2.h"
30#include "libGLESv2/validationES3.h"
Jamie Madill55856b12014-01-02 13:59:50 -050031#include "libGLESv2/queryconversions.h"
Jamie Madill478fdb22013-07-19 16:36:59 -040032
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +000033extern "C"
34{
35
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +000036// OpenGL ES 2.0 functions
37
Kenneth Russell67ea1902014-10-06 16:44:50 -070038void GL_APIENTRY glActiveTexture(GLenum texture)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +000039{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +000040 EVENT("(GLenum texture = 0x%X)", texture);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +000041
Geoff Langbfdea662014-07-23 14:16:32 -040042 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -040043 if (context)
44 {
Geoff Lang3a61c322014-07-10 13:01:54 -040045 if (texture < GL_TEXTURE0 || texture > GL_TEXTURE0 + context->getCaps().maxCombinedTextureImageUnits - 1)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +000046 {
Geoff Langb1196682014-07-23 13:47:29 -040047 context->recordError(gl::Error(GL_INVALID_ENUM));
48 return;
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +000049 }
Geoff Langbfdea662014-07-23 14:16:32 -040050
51 context->getState().setActiveSampler(texture - GL_TEXTURE0);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +000052 }
53}
54
Kenneth Russell67ea1902014-10-06 16:44:50 -070055void GL_APIENTRY glAttachShader(GLuint program, GLuint shader)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +000056{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +000057 EVENT("(GLuint program = %d, GLuint shader = %d)", program, shader);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +000058
Geoff Langbfdea662014-07-23 14:16:32 -040059 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -040060 if (context)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +000061 {
Geoff Langbfdea662014-07-23 14:16:32 -040062 gl::Program *programObject = context->getProgram(program);
63 gl::Shader *shaderObject = context->getShader(shader);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +000064
Geoff Langbfdea662014-07-23 14:16:32 -040065 if (!programObject)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +000066 {
Geoff Langbfdea662014-07-23 14:16:32 -040067 if (context->getShader(program))
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +000068 {
Geoff Langb1196682014-07-23 13:47:29 -040069 context->recordError(gl::Error(GL_INVALID_OPERATION));
70 return;
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +000071 }
Geoff Langbfdea662014-07-23 14:16:32 -040072 else
73 {
Geoff Langb1196682014-07-23 13:47:29 -040074 context->recordError(gl::Error(GL_INVALID_VALUE));
75 return;
Geoff Langbfdea662014-07-23 14:16:32 -040076 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +000077 }
Geoff Langbfdea662014-07-23 14:16:32 -040078
79 if (!shaderObject)
80 {
81 if (context->getProgram(shader))
82 {
Geoff Langb1196682014-07-23 13:47:29 -040083 context->recordError(gl::Error(GL_INVALID_OPERATION));
84 return;
Geoff Langbfdea662014-07-23 14:16:32 -040085 }
86 else
87 {
Geoff Langb1196682014-07-23 13:47:29 -040088 context->recordError(gl::Error(GL_INVALID_VALUE));
89 return;
Geoff Langbfdea662014-07-23 14:16:32 -040090 }
91 }
92
93 if (!programObject->attachShader(shaderObject))
94 {
Geoff Langb1196682014-07-23 13:47:29 -040095 context->recordError(gl::Error(GL_INVALID_OPERATION));
96 return;
Geoff Langbfdea662014-07-23 14:16:32 -040097 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +000098 }
99}
100
Kenneth Russell67ea1902014-10-06 16:44:50 -0700101void GL_APIENTRY glBeginQueryEXT(GLenum target, GLuint id)
daniel@transgaming.com86bdb822012-01-20 18:24:39 +0000102{
103 EVENT("(GLenum target = 0x%X, GLuint %d)", target, id);
104
Geoff Langbfdea662014-07-23 14:16:32 -0400105 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -0400106 if (context)
107 {
108 if (!ValidateBeginQuery(context, target, id))
daniel@transgaming.com86bdb822012-01-20 18:24:39 +0000109 {
Geoff Langbfdea662014-07-23 14:16:32 -0400110 return;
daniel@transgaming.com86bdb822012-01-20 18:24:39 +0000111 }
Geoff Langbfdea662014-07-23 14:16:32 -0400112
Geoff Lang5aad9672014-09-08 11:10:42 -0400113 gl::Error error = context->beginQuery(target, id);
114 if (error.isError())
115 {
116 context->recordError(error);
117 return;
118 }
daniel@transgaming.com86bdb822012-01-20 18:24:39 +0000119 }
120}
121
Kenneth Russell67ea1902014-10-06 16:44:50 -0700122void GL_APIENTRY glBindAttribLocation(GLuint program, GLuint index, const GLchar* name)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000123{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +0000124 EVENT("(GLuint program = %d, GLuint index = %d, const GLchar* name = 0x%0.8p)", program, index, name);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000125
Geoff Langbfdea662014-07-23 14:16:32 -0400126 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -0400127 if (context)
128 {
Geoff Langb1196682014-07-23 13:47:29 -0400129 if (index >= gl::MAX_VERTEX_ATTRIBS)
130 {
131 context->recordError(gl::Error(GL_INVALID_VALUE));
132 return;
133 }
134
Geoff Langbfdea662014-07-23 14:16:32 -0400135 gl::Program *programObject = context->getProgram(program);
136
137 if (!programObject)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000138 {
Geoff Langbfdea662014-07-23 14:16:32 -0400139 if (context->getShader(program))
daniel@transgaming.com98079832010-04-13 03:26:29 +0000140 {
Geoff Langb1196682014-07-23 13:47:29 -0400141 context->recordError(gl::Error(GL_INVALID_OPERATION));
142 return;
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000143 }
Geoff Langbfdea662014-07-23 14:16:32 -0400144 else
145 {
Geoff Langb1196682014-07-23 13:47:29 -0400146 context->recordError(gl::Error(GL_INVALID_VALUE));
147 return;
Geoff Langbfdea662014-07-23 14:16:32 -0400148 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000149 }
Geoff Langbfdea662014-07-23 14:16:32 -0400150
151 if (strncmp(name, "gl_", 3) == 0)
152 {
Geoff Langb1196682014-07-23 13:47:29 -0400153 context->recordError(gl::Error(GL_INVALID_OPERATION));
154 return;
Geoff Langbfdea662014-07-23 14:16:32 -0400155 }
156
157 programObject->bindAttributeLocation(index, name);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000158 }
159}
160
Kenneth Russell67ea1902014-10-06 16:44:50 -0700161void GL_APIENTRY glBindBuffer(GLenum target, GLuint buffer)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000162{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +0000163 EVENT("(GLenum target = 0x%X, GLuint buffer = %d)", target, buffer);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000164
Geoff Langbfdea662014-07-23 14:16:32 -0400165 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -0400166 if (context)
167 {
168 if (!gl::ValidBufferTarget(context, target))
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000169 {
Geoff Langb1196682014-07-23 13:47:29 -0400170 context->recordError(gl::Error(GL_INVALID_ENUM));
171 return;
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000172 }
Geoff Langbfdea662014-07-23 14:16:32 -0400173
174 switch (target)
175 {
176 case GL_ARRAY_BUFFER:
177 context->bindArrayBuffer(buffer);
178 return;
179 case GL_ELEMENT_ARRAY_BUFFER:
180 context->bindElementArrayBuffer(buffer);
181 return;
182 case GL_COPY_READ_BUFFER:
183 context->bindCopyReadBuffer(buffer);
184 return;
185 case GL_COPY_WRITE_BUFFER:
186 context->bindCopyWriteBuffer(buffer);
187 return;
188 case GL_PIXEL_PACK_BUFFER:
189 context->bindPixelPackBuffer(buffer);
190 return;
191 case GL_PIXEL_UNPACK_BUFFER:
192 context->bindPixelUnpackBuffer(buffer);
193 return;
194 case GL_UNIFORM_BUFFER:
195 context->bindGenericUniformBuffer(buffer);
196 return;
197 case GL_TRANSFORM_FEEDBACK_BUFFER:
198 context->bindGenericTransformFeedbackBuffer(buffer);
199 return;
Geoff Langb1196682014-07-23 13:47:29 -0400200
Geoff Langbfdea662014-07-23 14:16:32 -0400201 default:
Geoff Langb1196682014-07-23 13:47:29 -0400202 context->recordError(gl::Error(GL_INVALID_ENUM));
203 return;
Geoff Langbfdea662014-07-23 14:16:32 -0400204 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000205 }
206}
207
Kenneth Russell67ea1902014-10-06 16:44:50 -0700208void GL_APIENTRY glBindFramebuffer(GLenum target, GLuint framebuffer)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000209{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +0000210 EVENT("(GLenum target = 0x%X, GLuint framebuffer = %d)", target, framebuffer);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000211
Geoff Langbfdea662014-07-23 14:16:32 -0400212 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -0400213 if (context)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000214 {
Geoff Langb1196682014-07-23 13:47:29 -0400215 if (!gl::ValidFramebufferTarget(target))
216 {
217 context->recordError(gl::Error(GL_INVALID_ENUM));
218 return;
219 }
220
Geoff Langbfdea662014-07-23 14:16:32 -0400221 if (target == GL_READ_FRAMEBUFFER_ANGLE || target == GL_FRAMEBUFFER)
222 {
223 context->bindReadFramebuffer(framebuffer);
224 }
225
226 if (target == GL_DRAW_FRAMEBUFFER_ANGLE || target == GL_FRAMEBUFFER)
227 {
228 context->bindDrawFramebuffer(framebuffer);
229 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000230 }
231}
232
Kenneth Russell67ea1902014-10-06 16:44:50 -0700233void GL_APIENTRY glBindRenderbuffer(GLenum target, GLuint renderbuffer)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000234{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +0000235 EVENT("(GLenum target = 0x%X, GLuint renderbuffer = %d)", target, renderbuffer);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000236
Geoff Langbfdea662014-07-23 14:16:32 -0400237 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -0400238 if (context)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000239 {
Geoff Langb1196682014-07-23 13:47:29 -0400240 if (target != GL_RENDERBUFFER)
241 {
242 context->recordError(gl::Error(GL_INVALID_ENUM));
243 return;
244 }
245
Geoff Langbfdea662014-07-23 14:16:32 -0400246 context->bindRenderbuffer(renderbuffer);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000247 }
248}
249
Kenneth Russell67ea1902014-10-06 16:44:50 -0700250void GL_APIENTRY glBindTexture(GLenum target, GLuint texture)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000251{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +0000252 EVENT("(GLenum target = 0x%X, GLuint texture = %d)", target, texture);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000253
Geoff Langbfdea662014-07-23 14:16:32 -0400254 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -0400255 if (context)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000256 {
Geoff Langbfdea662014-07-23 14:16:32 -0400257 gl::Texture *textureObject = context->getTexture(texture);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000258
Geoff Langbfdea662014-07-23 14:16:32 -0400259 if (textureObject && textureObject->getTarget() != target && texture != 0)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000260 {
Geoff Langb1196682014-07-23 13:47:29 -0400261 context->recordError(gl::Error(GL_INVALID_OPERATION));
262 return;
Geoff Langbfdea662014-07-23 14:16:32 -0400263 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000264
Geoff Langbfdea662014-07-23 14:16:32 -0400265 switch (target)
266 {
267 case GL_TEXTURE_2D:
Geoff Langbfdea662014-07-23 14:16:32 -0400268 case GL_TEXTURE_CUBE_MAP:
Geoff Lang76b10c92014-09-05 16:28:14 -0400269 break;
Geoff Langb1196682014-07-23 13:47:29 -0400270
Geoff Langbfdea662014-07-23 14:16:32 -0400271 case GL_TEXTURE_3D:
Geoff Langbfdea662014-07-23 14:16:32 -0400272 case GL_TEXTURE_2D_ARRAY:
273 if (context->getClientVersion() < 3)
274 {
Geoff Langb1196682014-07-23 13:47:29 -0400275 context->recordError(gl::Error(GL_INVALID_ENUM));
276 return;
Geoff Langbfdea662014-07-23 14:16:32 -0400277 }
Geoff Lang76b10c92014-09-05 16:28:14 -0400278 break;
Geoff Langb1196682014-07-23 13:47:29 -0400279
Geoff Langbfdea662014-07-23 14:16:32 -0400280 default:
Geoff Langb1196682014-07-23 13:47:29 -0400281 context->recordError(gl::Error(GL_INVALID_ENUM));
282 return;
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000283 }
Geoff Lang76b10c92014-09-05 16:28:14 -0400284
285 context->bindTexture(target, texture);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000286 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000287}
288
Kenneth Russell67ea1902014-10-06 16:44:50 -0700289void GL_APIENTRY glBlendColor(GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000290{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +0000291 EVENT("(GLclampf red = %f, GLclampf green = %f, GLclampf blue = %f, GLclampf alpha = %f)",
daniel@transgaming.comb5b06162010-03-21 04:31:32 +0000292 red, green, blue, alpha);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000293
Geoff Langbfdea662014-07-23 14:16:32 -0400294 gl::Context* context = gl::getNonLostContext();
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000295
Geoff Langbfdea662014-07-23 14:16:32 -0400296 if (context)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000297 {
Geoff Langbfdea662014-07-23 14:16:32 -0400298 context->getState().setBlendColor(gl::clamp01(red), gl::clamp01(green), gl::clamp01(blue), gl::clamp01(alpha));
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000299 }
300}
301
Kenneth Russell67ea1902014-10-06 16:44:50 -0700302void GL_APIENTRY glBlendEquation(GLenum mode)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000303{
304 glBlendEquationSeparate(mode, mode);
305}
306
Kenneth Russell67ea1902014-10-06 16:44:50 -0700307void GL_APIENTRY glBlendEquationSeparate(GLenum modeRGB, GLenum modeAlpha)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000308{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +0000309 EVENT("(GLenum modeRGB = 0x%X, GLenum modeAlpha = 0x%X)", modeRGB, modeAlpha);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000310
Geoff Langbfdea662014-07-23 14:16:32 -0400311 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -0400312 if (context)
313 {
Geoff Langb1196682014-07-23 13:47:29 -0400314 switch (modeRGB)
315 {
316 case GL_FUNC_ADD:
317 case GL_FUNC_SUBTRACT:
318 case GL_FUNC_REVERSE_SUBTRACT:
319 case GL_MIN:
320 case GL_MAX:
321 break;
322
323 default:
324 context->recordError(gl::Error(GL_INVALID_ENUM));
325 return;
326 }
327
328 switch (modeAlpha)
329 {
330 case GL_FUNC_ADD:
331 case GL_FUNC_SUBTRACT:
332 case GL_FUNC_REVERSE_SUBTRACT:
333 case GL_MIN:
334 case GL_MAX:
335 break;
336
337 default:
338 context->recordError(gl::Error(GL_INVALID_ENUM));
339 return;
340 }
341
Geoff Langbfdea662014-07-23 14:16:32 -0400342 context->getState().setBlendEquation(modeRGB, modeAlpha);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000343 }
344}
345
Kenneth Russell67ea1902014-10-06 16:44:50 -0700346void GL_APIENTRY glBlendFunc(GLenum sfactor, GLenum dfactor)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000347{
348 glBlendFuncSeparate(sfactor, dfactor, sfactor, dfactor);
349}
350
Kenneth Russell67ea1902014-10-06 16:44:50 -0700351void GL_APIENTRY glBlendFuncSeparate(GLenum srcRGB, GLenum dstRGB, GLenum srcAlpha, GLenum dstAlpha)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000352{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +0000353 EVENT("(GLenum srcRGB = 0x%X, GLenum dstRGB = 0x%X, GLenum srcAlpha = 0x%X, GLenum dstAlpha = 0x%X)",
daniel@transgaming.comb5b06162010-03-21 04:31:32 +0000354 srcRGB, dstRGB, srcAlpha, dstAlpha);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000355
Geoff Langbfdea662014-07-23 14:16:32 -0400356 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -0400357 if (context)
358 {
Geoff Langb1196682014-07-23 13:47:29 -0400359 switch (srcRGB)
360 {
361 case GL_ZERO:
362 case GL_ONE:
363 case GL_SRC_COLOR:
364 case GL_ONE_MINUS_SRC_COLOR:
365 case GL_DST_COLOR:
366 case GL_ONE_MINUS_DST_COLOR:
367 case GL_SRC_ALPHA:
368 case GL_ONE_MINUS_SRC_ALPHA:
369 case GL_DST_ALPHA:
370 case GL_ONE_MINUS_DST_ALPHA:
371 case GL_CONSTANT_COLOR:
372 case GL_ONE_MINUS_CONSTANT_COLOR:
373 case GL_CONSTANT_ALPHA:
374 case GL_ONE_MINUS_CONSTANT_ALPHA:
375 case GL_SRC_ALPHA_SATURATE:
376 break;
377
378 default:
379 context->recordError(gl::Error(GL_INVALID_ENUM));
380 return;
381 }
382
383 switch (dstRGB)
384 {
385 case GL_ZERO:
386 case GL_ONE:
387 case GL_SRC_COLOR:
388 case GL_ONE_MINUS_SRC_COLOR:
389 case GL_DST_COLOR:
390 case GL_ONE_MINUS_DST_COLOR:
391 case GL_SRC_ALPHA:
392 case GL_ONE_MINUS_SRC_ALPHA:
393 case GL_DST_ALPHA:
394 case GL_ONE_MINUS_DST_ALPHA:
395 case GL_CONSTANT_COLOR:
396 case GL_ONE_MINUS_CONSTANT_COLOR:
397 case GL_CONSTANT_ALPHA:
398 case GL_ONE_MINUS_CONSTANT_ALPHA:
399 break;
400
401 case GL_SRC_ALPHA_SATURATE:
402 if (context->getClientVersion() < 3)
403 {
404 context->recordError(gl::Error(GL_INVALID_ENUM));
405 return;
406 }
407 break;
408
409 default:
410 context->recordError(gl::Error(GL_INVALID_ENUM));
411 return;
412 }
413
414 switch (srcAlpha)
415 {
416 case GL_ZERO:
417 case GL_ONE:
418 case GL_SRC_COLOR:
419 case GL_ONE_MINUS_SRC_COLOR:
420 case GL_DST_COLOR:
421 case GL_ONE_MINUS_DST_COLOR:
422 case GL_SRC_ALPHA:
423 case GL_ONE_MINUS_SRC_ALPHA:
424 case GL_DST_ALPHA:
425 case GL_ONE_MINUS_DST_ALPHA:
426 case GL_CONSTANT_COLOR:
427 case GL_ONE_MINUS_CONSTANT_COLOR:
428 case GL_CONSTANT_ALPHA:
429 case GL_ONE_MINUS_CONSTANT_ALPHA:
430 case GL_SRC_ALPHA_SATURATE:
431 break;
432
433 default:
434 context->recordError(gl::Error(GL_INVALID_ENUM));
435 return;
436 }
437
438 switch (dstAlpha)
439 {
440 case GL_ZERO:
441 case GL_ONE:
442 case GL_SRC_COLOR:
443 case GL_ONE_MINUS_SRC_COLOR:
444 case GL_DST_COLOR:
445 case GL_ONE_MINUS_DST_COLOR:
446 case GL_SRC_ALPHA:
447 case GL_ONE_MINUS_SRC_ALPHA:
448 case GL_DST_ALPHA:
449 case GL_ONE_MINUS_DST_ALPHA:
450 case GL_CONSTANT_COLOR:
451 case GL_ONE_MINUS_CONSTANT_COLOR:
452 case GL_CONSTANT_ALPHA:
453 case GL_ONE_MINUS_CONSTANT_ALPHA:
454 break;
455
456 case GL_SRC_ALPHA_SATURATE:
457 if (context->getClientVersion() < 3)
458 {
459 context->recordError(gl::Error(GL_INVALID_ENUM));
460 return;
461 }
462 break;
463
464 default:
465 context->recordError(gl::Error(GL_INVALID_ENUM));
466 return;
467 }
468
469 bool constantColorUsed = (srcRGB == GL_CONSTANT_COLOR || srcRGB == GL_ONE_MINUS_CONSTANT_COLOR ||
470 dstRGB == GL_CONSTANT_COLOR || dstRGB == GL_ONE_MINUS_CONSTANT_COLOR);
471
472 bool constantAlphaUsed = (srcRGB == GL_CONSTANT_ALPHA || srcRGB == GL_ONE_MINUS_CONSTANT_ALPHA ||
473 dstRGB == GL_CONSTANT_ALPHA || dstRGB == GL_ONE_MINUS_CONSTANT_ALPHA);
474
475 if (constantColorUsed && constantAlphaUsed)
476 {
477 ERR("Simultaneous use of GL_CONSTANT_ALPHA/GL_ONE_MINUS_CONSTANT_ALPHA and GL_CONSTANT_COLOR/GL_ONE_MINUS_CONSTANT_COLOR invalid under WebGL");
478 context->recordError(gl::Error(GL_INVALID_OPERATION));
479 return;
480 }
481
Geoff Langbfdea662014-07-23 14:16:32 -0400482 context->getState().setBlendFactors(srcRGB, dstRGB, srcAlpha, dstAlpha);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000483 }
484}
485
Kenneth Russell67ea1902014-10-06 16:44:50 -0700486void GL_APIENTRY glBufferData(GLenum target, GLsizeiptr size, const GLvoid* data, GLenum usage)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000487{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +0000488 EVENT("(GLenum target = 0x%X, GLsizeiptr size = %d, const GLvoid* data = 0x%0.8p, GLenum usage = %d)",
daniel@transgaming.comb5b06162010-03-21 04:31:32 +0000489 target, size, data, usage);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000490
Geoff Langbfdea662014-07-23 14:16:32 -0400491 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -0400492 if (context)
493 {
Geoff Langb1196682014-07-23 13:47:29 -0400494 if (size < 0)
495 {
496 context->recordError(gl::Error(GL_INVALID_VALUE));
497 return;
498 }
499
500 switch (usage)
501 {
502 case GL_STREAM_DRAW:
503 case GL_STATIC_DRAW:
504 case GL_DYNAMIC_DRAW:
505 break;
506
507 case GL_STREAM_READ:
508 case GL_STREAM_COPY:
509 case GL_STATIC_READ:
510 case GL_STATIC_COPY:
511 case GL_DYNAMIC_READ:
512 case GL_DYNAMIC_COPY:
513 if (context->getClientVersion() < 3)
514 {
515 context->recordError(gl::Error(GL_INVALID_ENUM));
516 return;
517 }
518 break;
519
520 default:
521 context->recordError(gl::Error(GL_INVALID_ENUM));
522 return;
523 }
524
Geoff Langbfdea662014-07-23 14:16:32 -0400525 if (!gl::ValidBufferTarget(context, target))
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000526 {
Geoff Langb1196682014-07-23 13:47:29 -0400527 context->recordError(gl::Error(GL_INVALID_ENUM));
528 return;
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000529 }
530
Geoff Langbfdea662014-07-23 14:16:32 -0400531 gl::Buffer *buffer = context->getState().getTargetBuffer(target);
532
533 if (!buffer)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000534 {
Geoff Langb1196682014-07-23 13:47:29 -0400535 context->recordError(gl::Error(GL_INVALID_OPERATION));
536 return;
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000537 }
Geoff Langbfdea662014-07-23 14:16:32 -0400538
Geoff Lang2a1c15a2014-07-25 11:43:00 -0400539 gl::Error error = buffer->bufferData(data, size, usage);
540 if (error.isError())
541 {
542 context->recordError(error);
543 return;
544 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000545 }
546}
547
Kenneth Russell67ea1902014-10-06 16:44:50 -0700548void GL_APIENTRY glBufferSubData(GLenum target, GLintptr offset, GLsizeiptr size, const GLvoid* data)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000549{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +0000550 EVENT("(GLenum target = 0x%X, GLintptr offset = %d, GLsizeiptr size = %d, const GLvoid* data = 0x%0.8p)",
daniel@transgaming.comb5b06162010-03-21 04:31:32 +0000551 target, offset, size, data);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000552
Geoff Langbfdea662014-07-23 14:16:32 -0400553 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -0400554 if (context)
555 {
Geoff Langb1196682014-07-23 13:47:29 -0400556 if (size < 0 || offset < 0)
557 {
558 context->recordError(gl::Error(GL_INVALID_VALUE));
559 return;
560 }
561
562 if (data == NULL)
563 {
564 return;
565 }
566
Geoff Langbfdea662014-07-23 14:16:32 -0400567 if (!gl::ValidBufferTarget(context, target))
568 {
Geoff Langb1196682014-07-23 13:47:29 -0400569 context->recordError(gl::Error(GL_INVALID_ENUM));
570 return;
Geoff Langbfdea662014-07-23 14:16:32 -0400571 }
572
573 gl::Buffer *buffer = context->getState().getTargetBuffer(target);
574
575 if (!buffer)
576 {
Geoff Langb1196682014-07-23 13:47:29 -0400577 context->recordError(gl::Error(GL_INVALID_OPERATION));
578 return;
Geoff Langbfdea662014-07-23 14:16:32 -0400579 }
580
581 if (buffer->isMapped())
582 {
Geoff Langb1196682014-07-23 13:47:29 -0400583 context->recordError(gl::Error(GL_INVALID_OPERATION));
584 return;
Geoff Langbfdea662014-07-23 14:16:32 -0400585 }
586
587 // Check for possible overflow of size + offset
588 if (!rx::IsUnsignedAdditionSafe<size_t>(size, offset))
589 {
Geoff Langb1196682014-07-23 13:47:29 -0400590 context->recordError(gl::Error(GL_OUT_OF_MEMORY));
591 return;
Geoff Langbfdea662014-07-23 14:16:32 -0400592 }
593
594 if (size + offset > buffer->getSize())
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000595 {
Geoff Langb1196682014-07-23 13:47:29 -0400596 context->recordError(gl::Error(GL_INVALID_VALUE));
597 return;
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000598 }
599
Geoff Lang2a1c15a2014-07-25 11:43:00 -0400600 gl::Error error = buffer->bufferSubData(data, size, offset);
601 if (error.isError())
602 {
603 context->recordError(error);
604 return;
605 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000606 }
607}
608
Kenneth Russell67ea1902014-10-06 16:44:50 -0700609GLenum GL_APIENTRY glCheckFramebufferStatus(GLenum target)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000610{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +0000611 EVENT("(GLenum target = 0x%X)", target);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000612
Geoff Langbfdea662014-07-23 14:16:32 -0400613 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -0400614 if (context)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000615 {
Geoff Langb1196682014-07-23 13:47:29 -0400616 if (!gl::ValidFramebufferTarget(target))
617 {
618 context->recordError(gl::Error(GL_INVALID_ENUM));
619 return 0;
620 }
621
Geoff Langbfdea662014-07-23 14:16:32 -0400622 gl::Framebuffer *framebuffer = context->getState().getTargetFramebuffer(target);
623 ASSERT(framebuffer);
624 return framebuffer->completeness();
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000625 }
626
627 return 0;
628}
629
Kenneth Russell67ea1902014-10-06 16:44:50 -0700630void GL_APIENTRY glClear(GLbitfield mask)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000631{
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +0000632 EVENT("(GLbitfield mask = 0x%X)", mask);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000633
Geoff Langbfdea662014-07-23 14:16:32 -0400634 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -0400635 if (context)
636 {
637 gl::Framebuffer *framebufferObject = context->getState().getDrawFramebuffer();
638
639 if (!framebufferObject || framebufferObject->completeness() != GL_FRAMEBUFFER_COMPLETE)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000640 {
Geoff Langb1196682014-07-23 13:47:29 -0400641 context->recordError(gl::Error(GL_INVALID_FRAMEBUFFER_OPERATION));
642 return;
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000643 }
Geoff Langbfdea662014-07-23 14:16:32 -0400644
645 if ((mask & ~(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT)) != 0)
646 {
Geoff Langb1196682014-07-23 13:47:29 -0400647 context->recordError(gl::Error(GL_INVALID_VALUE));
648 return;
Geoff Langbfdea662014-07-23 14:16:32 -0400649 }
650
Geoff Langcc79b8c2014-07-25 13:48:02 -0400651 gl::Error error = context->clear(mask);
652 if (error.isError())
653 {
654 context->recordError(error);
655 return;
656 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000657 }
658}
659
Kenneth Russell67ea1902014-10-06 16:44:50 -0700660void GL_APIENTRY glClearColor(GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000661{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +0000662 EVENT("(GLclampf red = %f, GLclampf green = %f, GLclampf blue = %f, GLclampf alpha = %f)",
daniel@transgaming.comb5b06162010-03-21 04:31:32 +0000663 red, green, blue, alpha);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000664
Geoff Langbfdea662014-07-23 14:16:32 -0400665 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -0400666 if (context)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000667 {
Geoff Langbfdea662014-07-23 14:16:32 -0400668 context->getState().setClearColor(red, green, blue, alpha);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000669 }
670}
671
Kenneth Russell67ea1902014-10-06 16:44:50 -0700672void GL_APIENTRY glClearDepthf(GLclampf depth)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000673{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +0000674 EVENT("(GLclampf depth = %f)", depth);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000675
Geoff Langbfdea662014-07-23 14:16:32 -0400676 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -0400677 if (context)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000678 {
Geoff Langbfdea662014-07-23 14:16:32 -0400679 context->getState().setClearDepth(depth);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000680 }
681}
682
Kenneth Russell67ea1902014-10-06 16:44:50 -0700683void GL_APIENTRY glClearStencil(GLint s)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000684{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +0000685 EVENT("(GLint s = %d)", s);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000686
Geoff Langbfdea662014-07-23 14:16:32 -0400687 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -0400688 if (context)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000689 {
Geoff Langbfdea662014-07-23 14:16:32 -0400690 context->getState().setClearStencil(s);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000691 }
692}
693
Kenneth Russell67ea1902014-10-06 16:44:50 -0700694void GL_APIENTRY glColorMask(GLboolean red, GLboolean green, GLboolean blue, GLboolean alpha)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000695{
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +0000696 EVENT("(GLboolean red = %d, GLboolean green = %u, GLboolean blue = %u, GLboolean alpha = %u)",
daniel@transgaming.comb5b06162010-03-21 04:31:32 +0000697 red, green, blue, alpha);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000698
Geoff Langbfdea662014-07-23 14:16:32 -0400699 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -0400700 if (context)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000701 {
Geoff Langbfdea662014-07-23 14:16:32 -0400702 context->getState().setColorMask(red == GL_TRUE, green == GL_TRUE, blue == GL_TRUE, alpha == GL_TRUE);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000703 }
704}
705
Kenneth Russell67ea1902014-10-06 16:44:50 -0700706void GL_APIENTRY glCompileShader(GLuint shader)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000707{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +0000708 EVENT("(GLuint shader = %d)", shader);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000709
Geoff Langbfdea662014-07-23 14:16:32 -0400710 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -0400711 if (context)
712 {
713 gl::Shader *shaderObject = context->getShader(shader);
714
715 if (!shaderObject)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000716 {
Geoff Langbfdea662014-07-23 14:16:32 -0400717 if (context->getProgram(shader))
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000718 {
Geoff Langb1196682014-07-23 13:47:29 -0400719 context->recordError(gl::Error(GL_INVALID_OPERATION));
720 return;
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000721 }
Geoff Langbfdea662014-07-23 14:16:32 -0400722 else
daniel@transgaming.com5d752f22010-10-07 13:37:20 +0000723 {
Geoff Langb1196682014-07-23 13:47:29 -0400724 context->recordError(gl::Error(GL_INVALID_VALUE));
725 return;
daniel@transgaming.com5d752f22010-10-07 13:37:20 +0000726 }
daniel@transgaming.com01868132010-08-24 19:21:17 +0000727 }
Geoff Langbfdea662014-07-23 14:16:32 -0400728
729 shaderObject->compile();
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000730 }
Geoff Langbfdea662014-07-23 14:16:32 -0400731}
732
Kenneth Russell67ea1902014-10-06 16:44:50 -0700733void GL_APIENTRY glCompressedTexImage2D(GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height,
Geoff Langbfdea662014-07-23 14:16:32 -0400734 GLint border, GLsizei imageSize, const GLvoid* data)
735{
736 EVENT("(GLenum target = 0x%X, GLint level = %d, GLenum internalformat = 0x%X, GLsizei width = %d, "
737 "GLsizei height = %d, GLint border = %d, GLsizei imageSize = %d, const GLvoid* data = 0x%0.8p)",
738 target, level, internalformat, width, height, border, imageSize, data);
739
740 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -0400741 if (context)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000742 {
Geoff Langbfdea662014-07-23 14:16:32 -0400743 if (context->getClientVersion() < 3 &&
744 !ValidateES2TexImageParameters(context, target, level, internalformat, true, false,
745 0, 0, width, height, border, GL_NONE, GL_NONE, data))
746 {
747 return;
748 }
749
750 if (context->getClientVersion() >= 3 &&
751 !ValidateES3TexImageParameters(context, target, level, internalformat, true, false,
752 0, 0, 0, width, height, 1, border, GL_NONE, GL_NONE, data))
753 {
754 return;
755 }
756
Geoff Lang5d601382014-07-22 15:14:06 -0400757 const gl::InternalFormat &formatInfo = gl::GetInternalFormatInfo(internalformat);
758 if (imageSize < 0 || static_cast<GLuint>(imageSize) != formatInfo.computeBlockSize(GL_UNSIGNED_BYTE, width, height))
Geoff Langbfdea662014-07-23 14:16:32 -0400759 {
Geoff Langb1196682014-07-23 13:47:29 -0400760 context->recordError(gl::Error(GL_INVALID_VALUE));
761 return;
Geoff Langbfdea662014-07-23 14:16:32 -0400762 }
763
764 switch (target)
765 {
766 case GL_TEXTURE_2D:
767 {
768 gl::Texture2D *texture = context->getTexture2D();
Geoff Langb5348332014-09-02 13:16:34 -0400769 gl::Error error = texture->setCompressedImage(level, internalformat, width, height, imageSize, data);
770 if (error.isError())
771 {
772 context->recordError(error);
773 return;
774 }
Geoff Langbfdea662014-07-23 14:16:32 -0400775 }
776 break;
777
778 case GL_TEXTURE_CUBE_MAP_POSITIVE_X:
779 case GL_TEXTURE_CUBE_MAP_NEGATIVE_X:
780 case GL_TEXTURE_CUBE_MAP_POSITIVE_Y:
781 case GL_TEXTURE_CUBE_MAP_NEGATIVE_Y:
782 case GL_TEXTURE_CUBE_MAP_POSITIVE_Z:
783 case GL_TEXTURE_CUBE_MAP_NEGATIVE_Z:
784 {
785 gl::TextureCubeMap *texture = context->getTextureCubeMap();
Geoff Langb5348332014-09-02 13:16:34 -0400786 gl::Error error = texture->setCompressedImage(target, level, internalformat, width, height, imageSize, data);
787 if (error.isError())
788 {
789 context->recordError(error);
790 return;
791 }
Geoff Langbfdea662014-07-23 14:16:32 -0400792 }
793 break;
794
795 default:
Geoff Langb1196682014-07-23 13:47:29 -0400796 context->recordError(gl::Error(GL_INVALID_ENUM));
797 return;
Geoff Langbfdea662014-07-23 14:16:32 -0400798 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000799 }
800}
801
Kenneth Russell67ea1902014-10-06 16:44:50 -0700802void GL_APIENTRY glCompressedTexSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height,
daniel@transgaming.comfe4b8272010-04-08 03:51:20 +0000803 GLenum format, GLsizei imageSize, const GLvoid* data)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000804{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +0000805 EVENT("(GLenum target = 0x%X, GLint level = %d, GLint xoffset = %d, GLint yoffset = %d, "
daniel@transgaming.comb5b06162010-03-21 04:31:32 +0000806 "GLsizei width = %d, GLsizei height = %d, GLenum format = 0x%X, "
daniel@transgaming.comfe4b8272010-04-08 03:51:20 +0000807 "GLsizei imageSize = %d, const GLvoid* data = 0x%0.8p)",
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000808 target, level, xoffset, yoffset, width, height, format, imageSize, data);
809
Geoff Langbfdea662014-07-23 14:16:32 -0400810 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -0400811 if (context)
812 {
813 if (context->getClientVersion() < 3 &&
814 !ValidateES2TexImageParameters(context, target, level, GL_NONE, true, true,
815 xoffset, yoffset, width, height, 0, GL_NONE, GL_NONE, data))
daniel@transgaming.com01868132010-08-24 19:21:17 +0000816 {
Geoff Langbfdea662014-07-23 14:16:32 -0400817 return;
daniel@transgaming.com01868132010-08-24 19:21:17 +0000818 }
Geoff Langbfdea662014-07-23 14:16:32 -0400819
820 if (context->getClientVersion() >= 3 &&
821 !ValidateES3TexImageParameters(context, target, level, GL_NONE, true, true,
822 xoffset, yoffset, 0, width, height, 1, 0, GL_NONE, GL_NONE, data))
823 {
824 return;
825 }
826
Geoff Lang5d601382014-07-22 15:14:06 -0400827 const gl::InternalFormat &formatInfo = gl::GetInternalFormatInfo(format);
828 if (imageSize < 0 || static_cast<GLuint>(imageSize) != formatInfo.computeBlockSize(GL_UNSIGNED_BYTE, width, height))
Geoff Langbfdea662014-07-23 14:16:32 -0400829 {
Geoff Langb1196682014-07-23 13:47:29 -0400830 context->recordError(gl::Error(GL_INVALID_VALUE));
831 return;
Geoff Langbfdea662014-07-23 14:16:32 -0400832 }
833
834 switch (target)
835 {
836 case GL_TEXTURE_2D:
837 {
838 gl::Texture2D *texture = context->getTexture2D();
Geoff Langb5348332014-09-02 13:16:34 -0400839 gl::Error error = texture->subImageCompressed(level, xoffset, yoffset, width, height, format, imageSize, data);
840 if (error.isError())
841 {
842 context->recordError(error);
843 return;
844 }
Geoff Langbfdea662014-07-23 14:16:32 -0400845 }
846 break;
847
848 case GL_TEXTURE_CUBE_MAP_POSITIVE_X:
849 case GL_TEXTURE_CUBE_MAP_NEGATIVE_X:
850 case GL_TEXTURE_CUBE_MAP_POSITIVE_Y:
851 case GL_TEXTURE_CUBE_MAP_NEGATIVE_Y:
852 case GL_TEXTURE_CUBE_MAP_POSITIVE_Z:
853 case GL_TEXTURE_CUBE_MAP_NEGATIVE_Z:
854 {
855 gl::TextureCubeMap *texture = context->getTextureCubeMap();
Geoff Langb5348332014-09-02 13:16:34 -0400856 gl::Error error = texture->subImageCompressed(target, level, xoffset, yoffset, width, height, format, imageSize, data);
857 if (error.isError())
858 {
859 context->recordError(error);
860 return;
861 }
Geoff Langbfdea662014-07-23 14:16:32 -0400862 }
863 break;
864
865 default:
Geoff Langb1196682014-07-23 13:47:29 -0400866 context->recordError(gl::Error(GL_INVALID_ENUM));
867 return;
Geoff Langbfdea662014-07-23 14:16:32 -0400868 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000869 }
870}
871
Kenneth Russell67ea1902014-10-06 16:44:50 -0700872void GL_APIENTRY glCopyTexImage2D(GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height, GLint border)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000873{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +0000874 EVENT("(GLenum target = 0x%X, GLint level = %d, GLenum internalformat = 0x%X, "
daniel@transgaming.comb5b06162010-03-21 04:31:32 +0000875 "GLint x = %d, GLint y = %d, GLsizei width = %d, GLsizei height = %d, GLint border = %d)",
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000876 target, level, internalformat, x, y, width, height, border);
877
Geoff Langbfdea662014-07-23 14:16:32 -0400878 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -0400879 if (context)
880 {
881 if (context->getClientVersion() < 3 &&
882 !ValidateES2CopyTexImageParameters(context, target, level, internalformat, false,
883 0, 0, x, y, width, height, border))
daniel@transgaming.comb8c28ed2010-04-13 03:26:32 +0000884 {
Geoff Langbfdea662014-07-23 14:16:32 -0400885 return;
daniel@transgaming.comb8c28ed2010-04-13 03:26:32 +0000886 }
Geoff Langbfdea662014-07-23 14:16:32 -0400887
888 if (context->getClientVersion() >= 3 &&
889 !ValidateES3CopyTexImageParameters(context, target, level, internalformat, false,
890 0, 0, 0, x, y, width, height, border))
891 {
892 return;
893 }
894
895 gl::Framebuffer *framebuffer = context->getState().getReadFramebuffer();
896
897 switch (target)
898 {
899 case GL_TEXTURE_2D:
900 {
901 gl::Texture2D *texture = context->getTexture2D();
Geoff Langef7b0162014-09-04 13:29:23 -0400902 gl::Error error = texture->copyImage(level, internalformat, x, y, width, height, framebuffer);
903 if (error.isError())
904 {
905 context->recordError(error);
906 return;
907 }
Geoff Langbfdea662014-07-23 14:16:32 -0400908 }
909 break;
910
911 case GL_TEXTURE_CUBE_MAP_POSITIVE_X:
912 case GL_TEXTURE_CUBE_MAP_NEGATIVE_X:
913 case GL_TEXTURE_CUBE_MAP_POSITIVE_Y:
914 case GL_TEXTURE_CUBE_MAP_NEGATIVE_Y:
915 case GL_TEXTURE_CUBE_MAP_POSITIVE_Z:
916 case GL_TEXTURE_CUBE_MAP_NEGATIVE_Z:
917 {
918 gl::TextureCubeMap *texture = context->getTextureCubeMap();
Geoff Langef7b0162014-09-04 13:29:23 -0400919 gl::Error error = texture->copyImage(target, level, internalformat, x, y, width, height, framebuffer);
920 if (error.isError())
921 {
922 context->recordError(error);
923 return;
924 }
Geoff Langbfdea662014-07-23 14:16:32 -0400925 }
926 break;
927
Geoff Langb1196682014-07-23 13:47:29 -0400928 default:
929 context->recordError(gl::Error(GL_INVALID_ENUM));
930 return;
Geoff Langbfdea662014-07-23 14:16:32 -0400931 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000932 }
933}
934
Kenneth Russell67ea1902014-10-06 16:44:50 -0700935void GL_APIENTRY glCopyTexSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000936{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +0000937 EVENT("(GLenum target = 0x%X, GLint level = %d, GLint xoffset = %d, GLint yoffset = %d, "
daniel@transgaming.comb5b06162010-03-21 04:31:32 +0000938 "GLint x = %d, GLint y = %d, GLsizei width = %d, GLsizei height = %d)",
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000939 target, level, xoffset, yoffset, x, y, width, height);
940
Geoff Langbfdea662014-07-23 14:16:32 -0400941 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -0400942 if (context)
943 {
944 if (context->getClientVersion() < 3 &&
945 !ValidateES2CopyTexImageParameters(context, target, level, GL_NONE, true,
946 xoffset, yoffset, x, y, width, height, 0))
daniel@transgaming.comb8c28ed2010-04-13 03:26:32 +0000947 {
Geoff Langbfdea662014-07-23 14:16:32 -0400948 return;
daniel@transgaming.comb8c28ed2010-04-13 03:26:32 +0000949 }
daniel@transgaming.comb8c28ed2010-04-13 03:26:32 +0000950
Geoff Langbfdea662014-07-23 14:16:32 -0400951 if (context->getClientVersion() >= 3 &&
952 !ValidateES3CopyTexImageParameters(context, target, level, GL_NONE, true,
953 xoffset, yoffset, 0, x, y, width, height, 0))
954 {
955 return;
956 }
957
958 gl::Framebuffer *framebuffer = context->getState().getReadFramebuffer();
959
960 switch (target)
961 {
962 case GL_TEXTURE_2D:
963 {
964 gl::Texture2D *texture = context->getTexture2D();
Geoff Langef7b0162014-09-04 13:29:23 -0400965 gl::Error error = texture->copySubImage(target, level, xoffset, yoffset, 0, x, y, width, height, framebuffer);
966 if (error.isError())
967 {
968 context->recordError(error);
969 return;
970 }
Geoff Langbfdea662014-07-23 14:16:32 -0400971 }
972 break;
973
974 case GL_TEXTURE_CUBE_MAP_POSITIVE_X:
975 case GL_TEXTURE_CUBE_MAP_NEGATIVE_X:
976 case GL_TEXTURE_CUBE_MAP_POSITIVE_Y:
977 case GL_TEXTURE_CUBE_MAP_NEGATIVE_Y:
978 case GL_TEXTURE_CUBE_MAP_POSITIVE_Z:
979 case GL_TEXTURE_CUBE_MAP_NEGATIVE_Z:
980 {
981 gl::TextureCubeMap *texture = context->getTextureCubeMap();
Geoff Langef7b0162014-09-04 13:29:23 -0400982 gl::Error error = texture->copySubImage(target, level, xoffset, yoffset, 0, x, y, width, height, framebuffer);
983 if (error.isError())
984 {
985 context->recordError(error);
986 return;
987 }
Geoff Langbfdea662014-07-23 14:16:32 -0400988 }
989 break;
990
991 default:
Geoff Langb1196682014-07-23 13:47:29 -0400992 context->recordError(gl::Error(GL_INVALID_ENUM));
993 return;
Geoff Langbfdea662014-07-23 14:16:32 -0400994 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000995 }
996}
997
Kenneth Russell67ea1902014-10-06 16:44:50 -0700998GLuint GL_APIENTRY glCreateProgram(void)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000999{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00001000 EVENT("()");
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001001
Geoff Langbfdea662014-07-23 14:16:32 -04001002 gl::Context *context = gl::getNonLostContext();
1003 if (context)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001004 {
Geoff Langbfdea662014-07-23 14:16:32 -04001005 return context->createProgram();
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001006 }
1007
1008 return 0;
1009}
1010
Kenneth Russell67ea1902014-10-06 16:44:50 -07001011GLuint GL_APIENTRY glCreateShader(GLenum type)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001012{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00001013 EVENT("(GLenum type = 0x%X)", type);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001014
Geoff Langbfdea662014-07-23 14:16:32 -04001015 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04001016 if (context)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001017 {
Geoff Langbfdea662014-07-23 14:16:32 -04001018 switch (type)
1019 {
1020 case GL_FRAGMENT_SHADER:
1021 case GL_VERTEX_SHADER:
1022 return context->createShader(type);
Geoff Langb1196682014-07-23 13:47:29 -04001023
Geoff Langbfdea662014-07-23 14:16:32 -04001024 default:
Geoff Langb1196682014-07-23 13:47:29 -04001025 context->recordError(gl::Error(GL_INVALID_ENUM));
1026 return 0;
Geoff Langbfdea662014-07-23 14:16:32 -04001027 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001028 }
1029
1030 return 0;
1031}
1032
Kenneth Russell67ea1902014-10-06 16:44:50 -07001033void GL_APIENTRY glCullFace(GLenum mode)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001034{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00001035 EVENT("(GLenum mode = 0x%X)", mode);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001036
Geoff Langb1196682014-07-23 13:47:29 -04001037 gl::Context *context = gl::getNonLostContext();
1038 if (context)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001039 {
Geoff Langb1196682014-07-23 13:47:29 -04001040 switch (mode)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001041 {
Geoff Langb1196682014-07-23 13:47:29 -04001042 case GL_FRONT:
1043 case GL_BACK:
1044 case GL_FRONT_AND_BACK:
1045 break;
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001046
Geoff Langb1196682014-07-23 13:47:29 -04001047 default:
1048 context->recordError(gl::Error(GL_INVALID_ENUM));
1049 return;
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001050 }
Geoff Langb1196682014-07-23 13:47:29 -04001051
1052 context->getState().setCullMode(mode);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001053 }
1054}
1055
Kenneth Russell67ea1902014-10-06 16:44:50 -07001056void GL_APIENTRY glDeleteBuffers(GLsizei n, const GLuint* buffers)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001057{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00001058 EVENT("(GLsizei n = %d, const GLuint* buffers = 0x%0.8p)", n, buffers);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001059
Geoff Langbfdea662014-07-23 14:16:32 -04001060 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04001061 if (context)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001062 {
Geoff Langb1196682014-07-23 13:47:29 -04001063 if (n < 0)
1064 {
1065 context->recordError(gl::Error(GL_INVALID_VALUE));
1066 return;
1067 }
1068
Geoff Langbfdea662014-07-23 14:16:32 -04001069 for (int i = 0; i < n; i++)
1070 {
1071 context->deleteBuffer(buffers[i]);
1072 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001073 }
1074}
1075
Kenneth Russell67ea1902014-10-06 16:44:50 -07001076void GL_APIENTRY glDeleteFencesNV(GLsizei n, const GLuint* fences)
apatrick@chromium.orgd3bd0ad2010-08-30 18:55:36 +00001077{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00001078 EVENT("(GLsizei n = %d, const GLuint* fences = 0x%0.8p)", n, fences);
apatrick@chromium.orgd3bd0ad2010-08-30 18:55:36 +00001079
Geoff Langbfdea662014-07-23 14:16:32 -04001080 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04001081 if (context)
apatrick@chromium.orgd3bd0ad2010-08-30 18:55:36 +00001082 {
Geoff Langb1196682014-07-23 13:47:29 -04001083 if (n < 0)
1084 {
1085 context->recordError(gl::Error(GL_INVALID_VALUE));
1086 return;
1087 }
1088
Geoff Langbfdea662014-07-23 14:16:32 -04001089 for (int i = 0; i < n; i++)
1090 {
1091 context->deleteFenceNV(fences[i]);
1092 }
apatrick@chromium.orgd3bd0ad2010-08-30 18:55:36 +00001093 }
1094}
1095
Kenneth Russell67ea1902014-10-06 16:44:50 -07001096void GL_APIENTRY glDeleteFramebuffers(GLsizei n, const GLuint* framebuffers)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001097{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00001098 EVENT("(GLsizei n = %d, const GLuint* framebuffers = 0x%0.8p)", n, framebuffers);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001099
Geoff Langbfdea662014-07-23 14:16:32 -04001100 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04001101 if (context)
1102 {
Geoff Langb1196682014-07-23 13:47:29 -04001103 if (n < 0)
1104 {
1105 context->recordError(gl::Error(GL_INVALID_VALUE));
1106 return;
1107 }
1108
Geoff Langbfdea662014-07-23 14:16:32 -04001109 for (int i = 0; i < n; i++)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001110 {
Geoff Langbfdea662014-07-23 14:16:32 -04001111 if (framebuffers[i] != 0)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001112 {
Geoff Langbfdea662014-07-23 14:16:32 -04001113 context->deleteFramebuffer(framebuffers[i]);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001114 }
1115 }
1116 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001117}
1118
Kenneth Russell67ea1902014-10-06 16:44:50 -07001119void GL_APIENTRY glDeleteProgram(GLuint program)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001120{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00001121 EVENT("(GLuint program = %d)", program);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001122
Geoff Langbfdea662014-07-23 14:16:32 -04001123 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04001124 if (context)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001125 {
Geoff Langb1196682014-07-23 13:47:29 -04001126 if (program == 0)
1127 {
1128 return;
1129 }
1130
Geoff Langbfdea662014-07-23 14:16:32 -04001131 if (!context->getProgram(program))
1132 {
1133 if(context->getShader(program))
1134 {
Geoff Langb1196682014-07-23 13:47:29 -04001135 context->recordError(gl::Error(GL_INVALID_OPERATION));
1136 return;
Geoff Langbfdea662014-07-23 14:16:32 -04001137 }
1138 else
1139 {
Geoff Langb1196682014-07-23 13:47:29 -04001140 context->recordError(gl::Error(GL_INVALID_VALUE));
1141 return;
Geoff Langbfdea662014-07-23 14:16:32 -04001142 }
1143 }
1144
1145 context->deleteProgram(program);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001146 }
1147}
1148
Kenneth Russell67ea1902014-10-06 16:44:50 -07001149void GL_APIENTRY glDeleteQueriesEXT(GLsizei n, const GLuint *ids)
daniel@transgaming.com86bdb822012-01-20 18:24:39 +00001150{
1151 EVENT("(GLsizei n = %d, const GLuint *ids = 0x%0.8p)", n, ids);
1152
Geoff Langbfdea662014-07-23 14:16:32 -04001153 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04001154 if (context)
daniel@transgaming.com86bdb822012-01-20 18:24:39 +00001155 {
Geoff Langb1196682014-07-23 13:47:29 -04001156 if (n < 0)
1157 {
1158 context->recordError(gl::Error(GL_INVALID_VALUE));
1159 return;
1160 }
1161
Geoff Langbfdea662014-07-23 14:16:32 -04001162 for (int i = 0; i < n; i++)
1163 {
1164 context->deleteQuery(ids[i]);
1165 }
daniel@transgaming.com86bdb822012-01-20 18:24:39 +00001166 }
1167}
1168
Kenneth Russell67ea1902014-10-06 16:44:50 -07001169void GL_APIENTRY glDeleteRenderbuffers(GLsizei n, const GLuint* renderbuffers)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001170{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00001171 EVENT("(GLsizei n = %d, const GLuint* renderbuffers = 0x%0.8p)", n, renderbuffers);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001172
Geoff Langbfdea662014-07-23 14:16:32 -04001173 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04001174 if (context)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001175 {
Geoff Langb1196682014-07-23 13:47:29 -04001176 if (n < 0)
1177 {
1178 context->recordError(gl::Error(GL_INVALID_VALUE));
1179 return;
1180 }
1181
Geoff Langbfdea662014-07-23 14:16:32 -04001182 for (int i = 0; i < n; i++)
1183 {
1184 context->deleteRenderbuffer(renderbuffers[i]);
1185 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001186 }
1187}
1188
Kenneth Russell67ea1902014-10-06 16:44:50 -07001189void GL_APIENTRY glDeleteShader(GLuint shader)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001190{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00001191 EVENT("(GLuint shader = %d)", shader);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001192
Geoff Langbfdea662014-07-23 14:16:32 -04001193 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04001194 if (context)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001195 {
Geoff Langb1196682014-07-23 13:47:29 -04001196 if (shader == 0)
1197 {
1198 return;
1199 }
1200
Geoff Langbfdea662014-07-23 14:16:32 -04001201 if (!context->getShader(shader))
1202 {
1203 if(context->getProgram(shader))
1204 {
Geoff Langb1196682014-07-23 13:47:29 -04001205 context->recordError(gl::Error(GL_INVALID_OPERATION));
1206 return;
Geoff Langbfdea662014-07-23 14:16:32 -04001207 }
1208 else
1209 {
Geoff Langb1196682014-07-23 13:47:29 -04001210 context->recordError(gl::Error(GL_INVALID_VALUE));
1211 return;
Geoff Langbfdea662014-07-23 14:16:32 -04001212 }
1213 }
1214
1215 context->deleteShader(shader);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001216 }
1217}
1218
Kenneth Russell67ea1902014-10-06 16:44:50 -07001219void GL_APIENTRY glDeleteTextures(GLsizei n, const GLuint* textures)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001220{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00001221 EVENT("(GLsizei n = %d, const GLuint* textures = 0x%0.8p)", n, textures);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001222
Geoff Langbfdea662014-07-23 14:16:32 -04001223 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04001224 if (context)
1225 {
Geoff Langb1196682014-07-23 13:47:29 -04001226 if (n < 0)
1227 {
1228 context->recordError(gl::Error(GL_INVALID_VALUE));
1229 return;
1230 }
1231
Geoff Langbfdea662014-07-23 14:16:32 -04001232 for (int i = 0; i < n; i++)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001233 {
Geoff Langbfdea662014-07-23 14:16:32 -04001234 if (textures[i] != 0)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001235 {
Geoff Langbfdea662014-07-23 14:16:32 -04001236 context->deleteTexture(textures[i]);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001237 }
1238 }
1239 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001240}
1241
Kenneth Russell67ea1902014-10-06 16:44:50 -07001242void GL_APIENTRY glDepthFunc(GLenum func)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001243{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00001244 EVENT("(GLenum func = 0x%X)", func);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001245
Geoff Langbfdea662014-07-23 14:16:32 -04001246 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04001247 if (context)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001248 {
Geoff Langb1196682014-07-23 13:47:29 -04001249 switch (func)
1250 {
1251 case GL_NEVER:
1252 case GL_ALWAYS:
1253 case GL_LESS:
1254 case GL_LEQUAL:
1255 case GL_EQUAL:
1256 case GL_GREATER:
1257 case GL_GEQUAL:
1258 case GL_NOTEQUAL:
1259 context->getState().setDepthFunc(func);
1260 break;
1261
1262 default:
1263 context->recordError(gl::Error(GL_INVALID_ENUM));
1264 return;
1265 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001266 }
1267}
1268
Kenneth Russell67ea1902014-10-06 16:44:50 -07001269void GL_APIENTRY glDepthMask(GLboolean flag)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001270{
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00001271 EVENT("(GLboolean flag = %u)", flag);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001272
Geoff Langbfdea662014-07-23 14:16:32 -04001273 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04001274 if (context)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001275 {
Geoff Langbfdea662014-07-23 14:16:32 -04001276 context->getState().setDepthMask(flag != GL_FALSE);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001277 }
1278}
1279
Kenneth Russell67ea1902014-10-06 16:44:50 -07001280void GL_APIENTRY glDepthRangef(GLclampf zNear, GLclampf zFar)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001281{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00001282 EVENT("(GLclampf zNear = %f, GLclampf zFar = %f)", zNear, zFar);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001283
Geoff Langbfdea662014-07-23 14:16:32 -04001284 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04001285 if (context)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001286 {
Geoff Langbfdea662014-07-23 14:16:32 -04001287 context->getState().setDepthRange(zNear, zFar);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001288 }
1289}
1290
Kenneth Russell67ea1902014-10-06 16:44:50 -07001291void GL_APIENTRY glDetachShader(GLuint program, GLuint shader)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001292{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00001293 EVENT("(GLuint program = %d, GLuint shader = %d)", program, shader);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001294
Geoff Langbfdea662014-07-23 14:16:32 -04001295 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04001296 if (context)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001297 {
Geoff Langbfdea662014-07-23 14:16:32 -04001298 gl::Program *programObject = context->getProgram(program);
1299 gl::Shader *shaderObject = context->getShader(shader);
1300
1301 if (!programObject)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001302 {
Geoff Langbfdea662014-07-23 14:16:32 -04001303 gl::Shader *shaderByProgramHandle;
1304 shaderByProgramHandle = context->getShader(program);
1305 if (!shaderByProgramHandle)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001306 {
Geoff Langb1196682014-07-23 13:47:29 -04001307 context->recordError(gl::Error(GL_INVALID_VALUE));
1308 return;
daniel@transgaming.com73c2c2e2010-04-13 03:26:11 +00001309 }
Geoff Langbfdea662014-07-23 14:16:32 -04001310 else
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001311 {
Geoff Langb1196682014-07-23 13:47:29 -04001312 context->recordError(gl::Error(GL_INVALID_OPERATION));
1313 return;
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001314 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001315 }
Geoff Langbfdea662014-07-23 14:16:32 -04001316
1317 if (!shaderObject)
1318 {
1319 gl::Program *programByShaderHandle = context->getProgram(shader);
1320 if (!programByShaderHandle)
1321 {
Geoff Langb1196682014-07-23 13:47:29 -04001322 context->recordError(gl::Error(GL_INVALID_VALUE));
1323 return;
Geoff Langbfdea662014-07-23 14:16:32 -04001324 }
1325 else
1326 {
Geoff Langb1196682014-07-23 13:47:29 -04001327 context->recordError(gl::Error(GL_INVALID_OPERATION));
1328 return;
Geoff Langbfdea662014-07-23 14:16:32 -04001329 }
1330 }
1331
1332 if (!programObject->detachShader(shaderObject))
1333 {
Geoff Langb1196682014-07-23 13:47:29 -04001334 context->recordError(gl::Error(GL_INVALID_OPERATION));
1335 return;
Geoff Langbfdea662014-07-23 14:16:32 -04001336 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001337 }
1338}
1339
Kenneth Russell67ea1902014-10-06 16:44:50 -07001340void GL_APIENTRY glDisable(GLenum cap)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001341{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00001342 EVENT("(GLenum cap = 0x%X)", cap);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001343
Geoff Langbfdea662014-07-23 14:16:32 -04001344 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04001345 if (context)
1346 {
1347 if (!ValidCap(context, cap))
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001348 {
Geoff Langb1196682014-07-23 13:47:29 -04001349 context->recordError(gl::Error(GL_INVALID_ENUM));
1350 return;
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001351 }
Geoff Langbfdea662014-07-23 14:16:32 -04001352
1353 context->getState().setEnableFeature(cap, false);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001354 }
1355}
1356
Kenneth Russell67ea1902014-10-06 16:44:50 -07001357void GL_APIENTRY glDisableVertexAttribArray(GLuint index)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001358{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00001359 EVENT("(GLuint index = %d)", index);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001360
Geoff Langbfdea662014-07-23 14:16:32 -04001361 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04001362 if (context)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001363 {
Geoff Langb1196682014-07-23 13:47:29 -04001364 if (index >= gl::MAX_VERTEX_ATTRIBS)
1365 {
1366 context->recordError(gl::Error(GL_INVALID_VALUE));
1367 return;
1368 }
1369
Geoff Langbfdea662014-07-23 14:16:32 -04001370 context->getState().setEnableVertexAttribArray(index, false);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001371 }
1372}
1373
Kenneth Russell67ea1902014-10-06 16:44:50 -07001374void GL_APIENTRY glDrawArrays(GLenum mode, GLint first, GLsizei count)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001375{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00001376 EVENT("(GLenum mode = 0x%X, GLint first = %d, GLsizei count = %d)", mode, first, count);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001377
Geoff Langbfdea662014-07-23 14:16:32 -04001378 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04001379 if (context)
1380 {
Jamie Madill2b976812014-08-25 15:47:49 -04001381 if (!ValidateDrawArrays(context, mode, first, count, 0))
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001382 {
Geoff Langbfdea662014-07-23 14:16:32 -04001383 return;
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001384 }
Geoff Langbfdea662014-07-23 14:16:32 -04001385
Geoff Langc77e8c32014-09-08 16:28:24 -04001386 gl::Error error = context->drawArrays(mode, first, count, 0);
1387 if (error.isError())
1388 {
1389 context->recordError(error);
1390 return;
1391 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001392 }
1393}
1394
Kenneth Russell67ea1902014-10-06 16:44:50 -07001395void GL_APIENTRY glDrawArraysInstancedANGLE(GLenum mode, GLint first, GLsizei count, GLsizei primcount)
daniel@transgaming.comd2820bf2012-01-27 15:38:48 +00001396{
1397 EVENT("(GLenum mode = 0x%X, GLint first = %d, GLsizei count = %d, GLsizei primcount = %d)", mode, first, count, primcount);
1398
Geoff Langbfdea662014-07-23 14:16:32 -04001399 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04001400 if (context)
1401 {
Geoff Lang87a93302014-09-16 13:29:43 -04001402 if (!ValidateDrawArraysInstancedANGLE(context, mode, first, count, primcount))
daniel@transgaming.comd2820bf2012-01-27 15:38:48 +00001403 {
Geoff Langbfdea662014-07-23 14:16:32 -04001404 return;
daniel@transgaming.comd2820bf2012-01-27 15:38:48 +00001405 }
Geoff Langbfdea662014-07-23 14:16:32 -04001406
Geoff Langc77e8c32014-09-08 16:28:24 -04001407 gl::Error error = context->drawArrays(mode, first, count, primcount);
1408 if (error.isError())
1409 {
1410 context->recordError(error);
1411 return;
1412 }
daniel@transgaming.comd2820bf2012-01-27 15:38:48 +00001413 }
1414}
1415
Kenneth Russell67ea1902014-10-06 16:44:50 -07001416void GL_APIENTRY glDrawElements(GLenum mode, GLsizei count, GLenum type, const GLvoid* indices)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001417{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00001418 EVENT("(GLenum mode = 0x%X, GLsizei count = %d, GLenum type = 0x%X, const GLvoid* indices = 0x%0.8p)",
daniel@transgaming.comb5b06162010-03-21 04:31:32 +00001419 mode, count, type, indices);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001420
Geoff Langbfdea662014-07-23 14:16:32 -04001421 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04001422 if (context)
1423 {
Jamie Madill2b976812014-08-25 15:47:49 -04001424 rx::RangeUI indexRange;
1425 if (!ValidateDrawElements(context, mode, count, type, indices, 0, &indexRange))
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001426 {
Geoff Langbfdea662014-07-23 14:16:32 -04001427 return;
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001428 }
Geoff Langbfdea662014-07-23 14:16:32 -04001429
Geoff Langc77e8c32014-09-08 16:28:24 -04001430 gl::Error error = context->drawElements(mode, count, type, indices, 0, indexRange);
1431 if (error.isError())
1432 {
1433 context->recordError(error);
1434 return;
1435 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001436 }
1437}
1438
Kenneth Russell67ea1902014-10-06 16:44:50 -07001439void GL_APIENTRY glDrawElementsInstancedANGLE(GLenum mode, GLsizei count, GLenum type, const GLvoid *indices, GLsizei primcount)
daniel@transgaming.comd2820bf2012-01-27 15:38:48 +00001440{
1441 EVENT("(GLenum mode = 0x%X, GLsizei count = %d, GLenum type = 0x%X, const GLvoid* indices = 0x%0.8p, GLsizei primcount = %d)",
1442 mode, count, type, indices, primcount);
1443
Geoff Langbfdea662014-07-23 14:16:32 -04001444 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04001445 if (context)
1446 {
Jamie Madill2b976812014-08-25 15:47:49 -04001447 rx::RangeUI indexRange;
Geoff Lang87a93302014-09-16 13:29:43 -04001448 if (!ValidateDrawElementsInstancedANGLE(context, mode, count, type, indices, primcount, &indexRange))
daniel@transgaming.comd2820bf2012-01-27 15:38:48 +00001449 {
Geoff Langbfdea662014-07-23 14:16:32 -04001450 return;
daniel@transgaming.comd2820bf2012-01-27 15:38:48 +00001451 }
Geoff Langbfdea662014-07-23 14:16:32 -04001452
Geoff Langc77e8c32014-09-08 16:28:24 -04001453 gl::Error error = context->drawElements(mode, count, type, indices, primcount, indexRange);
1454 if (error.isError())
1455 {
1456 context->recordError(error);
1457 return;
1458 }
daniel@transgaming.comd2820bf2012-01-27 15:38:48 +00001459 }
1460}
1461
Kenneth Russell67ea1902014-10-06 16:44:50 -07001462void GL_APIENTRY glEnable(GLenum cap)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001463{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00001464 EVENT("(GLenum cap = 0x%X)", cap);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001465
Geoff Langbfdea662014-07-23 14:16:32 -04001466 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04001467 if (context)
1468 {
1469 if (!ValidCap(context, cap))
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001470 {
Geoff Langb1196682014-07-23 13:47:29 -04001471 context->recordError(gl::Error(GL_INVALID_ENUM));
1472 return;
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001473 }
Geoff Langbfdea662014-07-23 14:16:32 -04001474
1475 context->getState().setEnableFeature(cap, true);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001476 }
1477}
1478
Kenneth Russell67ea1902014-10-06 16:44:50 -07001479void GL_APIENTRY glEnableVertexAttribArray(GLuint index)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001480{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00001481 EVENT("(GLuint index = %d)", index);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001482
Geoff Langbfdea662014-07-23 14:16:32 -04001483 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04001484 if (context)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001485 {
Geoff Langb1196682014-07-23 13:47:29 -04001486 if (index >= gl::MAX_VERTEX_ATTRIBS)
1487 {
1488 context->recordError(gl::Error(GL_INVALID_VALUE));
1489 return;
1490 }
1491
Geoff Langbfdea662014-07-23 14:16:32 -04001492 context->getState().setEnableVertexAttribArray(index, true);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001493 }
1494}
1495
Kenneth Russell67ea1902014-10-06 16:44:50 -07001496void GL_APIENTRY glEndQueryEXT(GLenum target)
daniel@transgaming.com86bdb822012-01-20 18:24:39 +00001497{
1498 EVENT("GLenum target = 0x%X)", target);
1499
Geoff Langbfdea662014-07-23 14:16:32 -04001500 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04001501 if (context)
1502 {
1503 if (!ValidateEndQuery(context, target))
daniel@transgaming.com86bdb822012-01-20 18:24:39 +00001504 {
Geoff Langbfdea662014-07-23 14:16:32 -04001505 return;
daniel@transgaming.com86bdb822012-01-20 18:24:39 +00001506 }
Geoff Langbfdea662014-07-23 14:16:32 -04001507
Geoff Lang5aad9672014-09-08 11:10:42 -04001508 gl::Error error = context->endQuery(target);
1509 if (error.isError())
1510 {
1511 context->recordError(error);
1512 return;
1513 }
daniel@transgaming.com86bdb822012-01-20 18:24:39 +00001514 }
1515}
1516
Kenneth Russell67ea1902014-10-06 16:44:50 -07001517void GL_APIENTRY glFinishFenceNV(GLuint fence)
apatrick@chromium.orgd3bd0ad2010-08-30 18:55:36 +00001518{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00001519 EVENT("(GLuint fence = %d)", fence);
apatrick@chromium.orgd3bd0ad2010-08-30 18:55:36 +00001520
Geoff Langbfdea662014-07-23 14:16:32 -04001521 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04001522 if (context)
1523 {
1524 gl::FenceNV *fenceObject = context->getFenceNV(fence);
1525
1526 if (fenceObject == NULL)
apatrick@chromium.orgd3bd0ad2010-08-30 18:55:36 +00001527 {
Geoff Langb1196682014-07-23 13:47:29 -04001528 context->recordError(gl::Error(GL_INVALID_OPERATION));
1529 return;
apatrick@chromium.orgd3bd0ad2010-08-30 18:55:36 +00001530 }
Geoff Langbfdea662014-07-23 14:16:32 -04001531
1532 if (fenceObject->isFence() != GL_TRUE)
1533 {
Geoff Langb1196682014-07-23 13:47:29 -04001534 context->recordError(gl::Error(GL_INVALID_OPERATION));
1535 return;
Geoff Langbfdea662014-07-23 14:16:32 -04001536 }
1537
1538 fenceObject->finishFence();
apatrick@chromium.orgd3bd0ad2010-08-30 18:55:36 +00001539 }
1540}
1541
Kenneth Russell67ea1902014-10-06 16:44:50 -07001542void GL_APIENTRY glFinish(void)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001543{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00001544 EVENT("()");
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001545
Geoff Langbfdea662014-07-23 14:16:32 -04001546 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04001547 if (context)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001548 {
Geoff Lang26298562014-10-01 10:49:03 -04001549 gl::Error error = context->sync(true);
1550 if (error.isError())
1551 {
1552 context->recordError(error);
1553 return;
1554 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001555 }
1556}
1557
Kenneth Russell67ea1902014-10-06 16:44:50 -07001558void GL_APIENTRY glFlush(void)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001559{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00001560 EVENT("()");
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001561
Geoff Langbfdea662014-07-23 14:16:32 -04001562 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04001563 if (context)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001564 {
Geoff Lang26298562014-10-01 10:49:03 -04001565 gl::Error error = context->sync(false);
1566 if (error.isError())
1567 {
1568 context->recordError(error);
1569 return;
1570 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001571 }
1572}
1573
Kenneth Russell67ea1902014-10-06 16:44:50 -07001574void GL_APIENTRY glFramebufferRenderbuffer(GLenum target, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001575{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00001576 EVENT("(GLenum target = 0x%X, GLenum attachment = 0x%X, GLenum renderbuffertarget = 0x%X, "
daniel@transgaming.comb5b06162010-03-21 04:31:32 +00001577 "GLuint renderbuffer = %d)", target, attachment, renderbuffertarget, renderbuffer);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001578
Geoff Langbfdea662014-07-23 14:16:32 -04001579 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04001580 if (context)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001581 {
Geoff Langb1196682014-07-23 13:47:29 -04001582 if (!gl::ValidFramebufferTarget(target) || (renderbuffertarget != GL_RENDERBUFFER && renderbuffer != 0))
1583 {
1584 context->recordError(gl::Error(GL_INVALID_ENUM));
1585 return;
1586 }
1587
Geoff Langbfdea662014-07-23 14:16:32 -04001588 if (!gl::ValidateFramebufferRenderbufferParameters(context, target, attachment, renderbuffertarget, renderbuffer))
1589 {
1590 return;
1591 }
1592
1593 gl::Framebuffer *framebuffer = context->getState().getTargetFramebuffer(target);
1594 ASSERT(framebuffer);
1595
1596 if (attachment >= GL_COLOR_ATTACHMENT0_EXT && attachment <= GL_COLOR_ATTACHMENT15_EXT)
1597 {
1598 unsigned int colorAttachment = (attachment - GL_COLOR_ATTACHMENT0_EXT);
1599 framebuffer->setColorbuffer(colorAttachment, GL_RENDERBUFFER, renderbuffer, 0, 0);
1600 }
1601 else
1602 {
1603 switch (attachment)
1604 {
1605 case GL_DEPTH_ATTACHMENT:
1606 framebuffer->setDepthbuffer(GL_RENDERBUFFER, renderbuffer, 0, 0);
1607 break;
1608 case GL_STENCIL_ATTACHMENT:
1609 framebuffer->setStencilbuffer(GL_RENDERBUFFER, renderbuffer, 0, 0);
1610 break;
1611 case GL_DEPTH_STENCIL_ATTACHMENT:
1612 framebuffer->setDepthStencilBuffer(GL_RENDERBUFFER, renderbuffer, 0, 0);
1613 break;
1614 default:
1615 UNREACHABLE();
1616 break;
1617 }
1618 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001619 }
1620}
1621
Kenneth Russell67ea1902014-10-06 16:44:50 -07001622void GL_APIENTRY glFramebufferTexture2D(GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001623{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00001624 EVENT("(GLenum target = 0x%X, GLenum attachment = 0x%X, GLenum textarget = 0x%X, "
daniel@transgaming.comb5b06162010-03-21 04:31:32 +00001625 "GLuint texture = %d, GLint level = %d)", target, attachment, textarget, texture, level);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001626
Geoff Langbfdea662014-07-23 14:16:32 -04001627 gl::Context *context = gl::getNonLostContext();
1628 if (context)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001629 {
Geoff Langbfdea662014-07-23 14:16:32 -04001630 if (!ValidateFramebufferTexture2D(context, target, attachment, textarget, texture, level))
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001631 {
Geoff Langbfdea662014-07-23 14:16:32 -04001632 return;
1633 }
shannon.woods%transgaming.com@gtempaccount.com89ae1132013-04-13 03:28:43 +00001634
Geoff Langbfdea662014-07-23 14:16:32 -04001635 if (texture == 0)
1636 {
1637 textarget = GL_NONE;
1638 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001639
Geoff Langbfdea662014-07-23 14:16:32 -04001640 gl::Framebuffer *framebuffer = context->getState().getTargetFramebuffer(target);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001641
Geoff Langbfdea662014-07-23 14:16:32 -04001642 if (attachment >= GL_COLOR_ATTACHMENT0_EXT && attachment <= GL_COLOR_ATTACHMENT15_EXT)
1643 {
1644 const unsigned int colorAttachment = (attachment - GL_COLOR_ATTACHMENT0_EXT);
1645 framebuffer->setColorbuffer(colorAttachment, textarget, texture, level, 0);
1646 }
1647 else
1648 {
1649 switch (attachment)
daniel@transgaming.comfbc09532010-04-26 15:33:41 +00001650 {
Geoff Langbfdea662014-07-23 14:16:32 -04001651 case GL_DEPTH_ATTACHMENT: framebuffer->setDepthbuffer(textarget, texture, level, 0); break;
1652 case GL_STENCIL_ATTACHMENT: framebuffer->setStencilbuffer(textarget, texture, level, 0); break;
1653 case GL_DEPTH_STENCIL_ATTACHMENT: framebuffer->setDepthStencilBuffer(textarget, texture, level, 0); break;
daniel@transgaming.comfbc09532010-04-26 15:33:41 +00001654 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001655 }
1656 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001657}
1658
Kenneth Russell67ea1902014-10-06 16:44:50 -07001659void GL_APIENTRY glFrontFace(GLenum mode)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001660{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00001661 EVENT("(GLenum mode = 0x%X)", mode);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001662
Geoff Langb1196682014-07-23 13:47:29 -04001663 gl::Context *context = gl::getNonLostContext();
1664 if (context)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001665 {
Geoff Langb1196682014-07-23 13:47:29 -04001666 switch (mode)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001667 {
Geoff Langb1196682014-07-23 13:47:29 -04001668 case GL_CW:
1669 case GL_CCW:
1670 context->getState().setFrontFace(mode);
1671 break;
1672 default:
1673 context->recordError(gl::Error(GL_INVALID_ENUM));
1674 return;
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001675 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001676 }
1677}
1678
Kenneth Russell67ea1902014-10-06 16:44:50 -07001679void GL_APIENTRY glGenBuffers(GLsizei n, GLuint* buffers)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001680{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00001681 EVENT("(GLsizei n = %d, GLuint* buffers = 0x%0.8p)", n, buffers);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001682
Geoff Langbfdea662014-07-23 14:16:32 -04001683 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04001684 if (context)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001685 {
Geoff Langb1196682014-07-23 13:47:29 -04001686 if (n < 0)
1687 {
1688 context->recordError(gl::Error(GL_INVALID_VALUE));
1689 return;
1690 }
1691
Geoff Langbfdea662014-07-23 14:16:32 -04001692 for (int i = 0; i < n; i++)
1693 {
1694 buffers[i] = context->createBuffer();
1695 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001696 }
1697}
1698
Kenneth Russell67ea1902014-10-06 16:44:50 -07001699void GL_APIENTRY glGenerateMipmap(GLenum target)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001700{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00001701 EVENT("(GLenum target = 0x%X)", target);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001702
Geoff Langbfdea662014-07-23 14:16:32 -04001703 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04001704 if (context)
1705 {
1706 if (!ValidTextureTarget(context, target))
daniel@transgaming.com8fd99e22010-04-20 18:52:00 +00001707 {
Geoff Langb1196682014-07-23 13:47:29 -04001708 context->recordError(gl::Error(GL_INVALID_ENUM));
1709 return;
daniel@transgaming.com8fd99e22010-04-20 18:52:00 +00001710 }
Geoff Langbfdea662014-07-23 14:16:32 -04001711
1712 gl::Texture *texture = context->getTargetTexture(target);
1713
1714 if (texture == NULL)
1715 {
Geoff Langb1196682014-07-23 13:47:29 -04001716 context->recordError(gl::Error(GL_INVALID_OPERATION));
1717 return;
Geoff Langbfdea662014-07-23 14:16:32 -04001718 }
1719
1720 GLenum internalFormat = texture->getBaseLevelInternalFormat();
1721 const gl::TextureCaps &formatCaps = context->getTextureCaps().get(internalFormat);
Geoff Lang5d601382014-07-22 15:14:06 -04001722 const gl::InternalFormat &formatInfo = gl::GetInternalFormatInfo(internalFormat);
Geoff Langbfdea662014-07-23 14:16:32 -04001723
1724 // GenerateMipmap should not generate an INVALID_OPERATION for textures created with
1725 // unsized formats or that are color renderable and filterable. Since we do not track if
1726 // the texture was created with sized or unsized format (only sized formats are stored),
1727 // it is not possible to make sure the the LUMA formats can generate mipmaps (they should
1728 // be able to) because they aren't color renderable. Simply do a special case for LUMA
1729 // textures since they're the only texture format that can be created with unsized formats
1730 // that is not color renderable. New unsized formats are unlikely to be added, since ES2
1731 // was the last version to use add them.
1732 bool isLUMA = internalFormat == GL_LUMINANCE8_EXT ||
1733 internalFormat == GL_LUMINANCE8_ALPHA8_EXT ||
1734 internalFormat == GL_ALPHA8_EXT;
1735
Geoff Lang5d601382014-07-22 15:14:06 -04001736 if (formatInfo.depthBits > 0 || formatInfo.stencilBits > 0 || !formatCaps.filterable ||
1737 (!formatCaps.renderable && !isLUMA) || formatInfo.compressed)
Geoff Langbfdea662014-07-23 14:16:32 -04001738 {
Geoff Langb1196682014-07-23 13:47:29 -04001739 context->recordError(gl::Error(GL_INVALID_OPERATION));
1740 return;
Geoff Langbfdea662014-07-23 14:16:32 -04001741 }
1742
1743 // GL_EXT_sRGB does not support mipmap generation on sRGB textures
Geoff Lang5d601382014-07-22 15:14:06 -04001744 if (context->getClientVersion() == 2 && formatInfo.colorEncoding == GL_SRGB)
Geoff Langbfdea662014-07-23 14:16:32 -04001745 {
Geoff Langb1196682014-07-23 13:47:29 -04001746 context->recordError(gl::Error(GL_INVALID_OPERATION));
1747 return;
Geoff Langbfdea662014-07-23 14:16:32 -04001748 }
1749
1750 // Non-power of 2 ES2 check
1751 if (!context->getExtensions().textureNPOT && (!gl::isPow2(texture->getBaseLevelWidth()) || !gl::isPow2(texture->getBaseLevelHeight())))
1752 {
1753 ASSERT(context->getClientVersion() <= 2 && (target == GL_TEXTURE_2D || target == GL_TEXTURE_CUBE_MAP));
Geoff Langb1196682014-07-23 13:47:29 -04001754 context->recordError(gl::Error(GL_INVALID_OPERATION));
1755 return;
Geoff Langbfdea662014-07-23 14:16:32 -04001756 }
1757
1758 // Cube completeness check
1759 if (target == GL_TEXTURE_CUBE_MAP)
1760 {
1761 gl::TextureCubeMap *textureCube = static_cast<gl::TextureCubeMap *>(texture);
1762 if (!textureCube->isCubeComplete())
1763 {
Geoff Langb1196682014-07-23 13:47:29 -04001764 context->recordError(gl::Error(GL_INVALID_OPERATION));
1765 return;
Geoff Langbfdea662014-07-23 14:16:32 -04001766 }
1767 }
1768
1769 texture->generateMipmaps();
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001770 }
1771}
1772
Kenneth Russell67ea1902014-10-06 16:44:50 -07001773void GL_APIENTRY glGenFencesNV(GLsizei n, GLuint* fences)
apatrick@chromium.orgd3bd0ad2010-08-30 18:55:36 +00001774{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00001775 EVENT("(GLsizei n = %d, GLuint* fences = 0x%0.8p)", n, fences);
apatrick@chromium.orgd3bd0ad2010-08-30 18:55:36 +00001776
Geoff Langbfdea662014-07-23 14:16:32 -04001777 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04001778 if (context)
apatrick@chromium.orgd3bd0ad2010-08-30 18:55:36 +00001779 {
Geoff Langb1196682014-07-23 13:47:29 -04001780 if (n < 0)
1781 {
1782 context->recordError(gl::Error(GL_INVALID_VALUE));
1783 return;
1784 }
1785
Geoff Langbfdea662014-07-23 14:16:32 -04001786 for (int i = 0; i < n; i++)
1787 {
1788 fences[i] = context->createFenceNV();
1789 }
apatrick@chromium.orgd3bd0ad2010-08-30 18:55:36 +00001790 }
1791}
1792
Kenneth Russell67ea1902014-10-06 16:44:50 -07001793void GL_APIENTRY glGenFramebuffers(GLsizei n, GLuint* framebuffers)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001794{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00001795 EVENT("(GLsizei n = %d, GLuint* framebuffers = 0x%0.8p)", n, framebuffers);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001796
Geoff Langbfdea662014-07-23 14:16:32 -04001797 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04001798 if (context)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001799 {
Geoff Langb1196682014-07-23 13:47:29 -04001800 if (n < 0)
1801 {
1802 context->recordError(gl::Error(GL_INVALID_VALUE));
1803 return;
1804 }
1805
Geoff Langbfdea662014-07-23 14:16:32 -04001806 for (int i = 0; i < n; i++)
1807 {
1808 framebuffers[i] = context->createFramebuffer();
1809 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001810 }
1811}
1812
Kenneth Russell67ea1902014-10-06 16:44:50 -07001813void GL_APIENTRY glGenQueriesEXT(GLsizei n, GLuint* ids)
daniel@transgaming.com86bdb822012-01-20 18:24:39 +00001814{
1815 EVENT("(GLsizei n = %d, GLuint* ids = 0x%0.8p)", n, ids);
1816
Geoff Langbfdea662014-07-23 14:16:32 -04001817 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04001818 if (context)
1819 {
1820 if (n < 0)
daniel@transgaming.com86bdb822012-01-20 18:24:39 +00001821 {
Geoff Langb1196682014-07-23 13:47:29 -04001822 context->recordError(gl::Error(GL_INVALID_VALUE));
1823 return;
daniel@transgaming.com86bdb822012-01-20 18:24:39 +00001824 }
Geoff Langbfdea662014-07-23 14:16:32 -04001825
1826 for (GLsizei i = 0; i < n; i++)
1827 {
1828 ids[i] = context->createQuery();
1829 }
daniel@transgaming.com86bdb822012-01-20 18:24:39 +00001830 }
1831}
1832
Kenneth Russell67ea1902014-10-06 16:44:50 -07001833void GL_APIENTRY glGenRenderbuffers(GLsizei n, GLuint* renderbuffers)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001834{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00001835 EVENT("(GLsizei n = %d, GLuint* renderbuffers = 0x%0.8p)", n, renderbuffers);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001836
Geoff Langbfdea662014-07-23 14:16:32 -04001837 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04001838 if (context)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001839 {
Geoff Langb1196682014-07-23 13:47:29 -04001840 if (n < 0)
1841 {
1842 context->recordError(gl::Error(GL_INVALID_VALUE));
1843 return;
1844 }
1845
Geoff Langbfdea662014-07-23 14:16:32 -04001846 for (int i = 0; i < n; i++)
1847 {
1848 renderbuffers[i] = context->createRenderbuffer();
1849 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001850 }
1851}
1852
Kenneth Russell67ea1902014-10-06 16:44:50 -07001853void GL_APIENTRY glGenTextures(GLsizei n, GLuint* textures)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001854{
Jamie Madill1fc7e2c2014-01-21 16:47:10 -05001855 EVENT("(GLsizei n = %d, GLuint* textures = 0x%0.8p)", n, textures);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001856
Geoff Langbfdea662014-07-23 14:16:32 -04001857 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04001858 if (context)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001859 {
Geoff Langb1196682014-07-23 13:47:29 -04001860 if (n < 0)
1861 {
1862 context->recordError(gl::Error(GL_INVALID_VALUE));
1863 return;
1864 }
1865
Geoff Langbfdea662014-07-23 14:16:32 -04001866 for (int i = 0; i < n; i++)
1867 {
1868 textures[i] = context->createTexture();
1869 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001870 }
1871}
1872
Kenneth Russell67ea1902014-10-06 16:44:50 -07001873void GL_APIENTRY glGetActiveAttrib(GLuint program, GLuint index, GLsizei bufsize, GLsizei *length, GLint *size, GLenum *type, GLchar *name)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001874{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00001875 EVENT("(GLuint program = %d, GLuint index = %d, GLsizei bufsize = %d, GLsizei *length = 0x%0.8p, "
daniel@transgaming.com85423182010-04-22 13:35:27 +00001876 "GLint *size = 0x%0.8p, GLenum *type = %0.8p, GLchar *name = %0.8p)",
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001877 program, index, bufsize, length, size, type, name);
1878
Geoff Langbfdea662014-07-23 14:16:32 -04001879 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04001880 if (context)
1881 {
Geoff Langb1196682014-07-23 13:47:29 -04001882 if (bufsize < 0)
1883 {
1884 context->recordError(gl::Error(GL_INVALID_VALUE));
1885 return;
1886 }
1887
Geoff Langbfdea662014-07-23 14:16:32 -04001888 gl::Program *programObject = context->getProgram(program);
1889
1890 if (!programObject)
1891 {
1892 if (context->getShader(program))
1893 {
Geoff Langb1196682014-07-23 13:47:29 -04001894 context->recordError(gl::Error(GL_INVALID_OPERATION));
1895 return;
Geoff Langbfdea662014-07-23 14:16:32 -04001896 }
1897 else
1898 {
Geoff Langb1196682014-07-23 13:47:29 -04001899 context->recordError(gl::Error(GL_INVALID_VALUE));
1900 return;
Geoff Langbfdea662014-07-23 14:16:32 -04001901 }
1902 }
1903
1904 if (index >= (GLuint)programObject->getActiveAttributeCount())
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001905 {
Geoff Langb1196682014-07-23 13:47:29 -04001906 context->recordError(gl::Error(GL_INVALID_VALUE));
1907 return;
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001908 }
1909
Geoff Langbfdea662014-07-23 14:16:32 -04001910 programObject->getActiveAttribute(index, bufsize, length, size, type, name);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001911 }
1912}
1913
Kenneth Russell67ea1902014-10-06 16:44:50 -07001914void GL_APIENTRY glGetActiveUniform(GLuint program, GLuint index, GLsizei bufsize, GLsizei* length, GLint* size, GLenum* type, GLchar* name)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001915{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00001916 EVENT("(GLuint program = %d, GLuint index = %d, GLsizei bufsize = %d, "
daniel@transgaming.comfe4b8272010-04-08 03:51:20 +00001917 "GLsizei* length = 0x%0.8p, GLint* size = 0x%0.8p, GLenum* type = 0x%0.8p, GLchar* name = 0x%0.8p)",
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001918 program, index, bufsize, length, size, type, name);
1919
Geoff Langbfdea662014-07-23 14:16:32 -04001920
1921 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04001922 if (context)
1923 {
Geoff Langb1196682014-07-23 13:47:29 -04001924 if (bufsize < 0)
1925 {
1926 context->recordError(gl::Error(GL_INVALID_VALUE));
1927 return;
1928 }
1929
Geoff Langbfdea662014-07-23 14:16:32 -04001930 gl::Program *programObject = context->getProgram(program);
1931
1932 if (!programObject)
1933 {
1934 if (context->getShader(program))
1935 {
Geoff Langb1196682014-07-23 13:47:29 -04001936 context->recordError(gl::Error(GL_INVALID_OPERATION));
1937 return;
Geoff Langbfdea662014-07-23 14:16:32 -04001938 }
1939 else
1940 {
Geoff Langb1196682014-07-23 13:47:29 -04001941 context->recordError(gl::Error(GL_INVALID_VALUE));
1942 return;
Geoff Langbfdea662014-07-23 14:16:32 -04001943 }
1944 }
1945
1946 if (index >= (GLuint)programObject->getActiveUniformCount())
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001947 {
Geoff Langb1196682014-07-23 13:47:29 -04001948 context->recordError(gl::Error(GL_INVALID_VALUE));
1949 return;
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001950 }
1951
Geoff Langbfdea662014-07-23 14:16:32 -04001952 programObject->getActiveUniform(index, bufsize, length, size, type, name);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001953 }
1954}
1955
Kenneth Russell67ea1902014-10-06 16:44:50 -07001956void GL_APIENTRY glGetAttachedShaders(GLuint program, GLsizei maxcount, GLsizei* count, GLuint* shaders)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001957{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00001958 EVENT("(GLuint program = %d, GLsizei maxcount = %d, GLsizei* count = 0x%0.8p, GLuint* shaders = 0x%0.8p)",
daniel@transgaming.comb5b06162010-03-21 04:31:32 +00001959 program, maxcount, count, shaders);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001960
Geoff Langbfdea662014-07-23 14:16:32 -04001961 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04001962 if (context)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001963 {
Geoff Langb1196682014-07-23 13:47:29 -04001964 if (maxcount < 0)
1965 {
1966 context->recordError(gl::Error(GL_INVALID_VALUE));
1967 return;
1968 }
1969
Geoff Langbfdea662014-07-23 14:16:32 -04001970 gl::Program *programObject = context->getProgram(program);
1971
1972 if (!programObject)
1973 {
1974 if (context->getShader(program))
1975 {
Geoff Langb1196682014-07-23 13:47:29 -04001976 context->recordError(gl::Error(GL_INVALID_OPERATION));
1977 return;
Geoff Langbfdea662014-07-23 14:16:32 -04001978 }
1979 else
1980 {
Geoff Langb1196682014-07-23 13:47:29 -04001981 context->recordError(gl::Error(GL_INVALID_VALUE));
1982 return;
Geoff Langbfdea662014-07-23 14:16:32 -04001983 }
1984 }
1985
1986 return programObject->getAttachedShaders(maxcount, count, shaders);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001987 }
1988}
1989
Kenneth Russell67ea1902014-10-06 16:44:50 -07001990GLint GL_APIENTRY glGetAttribLocation(GLuint program, const GLchar* name)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001991{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00001992 EVENT("(GLuint program = %d, const GLchar* name = %s)", program, name);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001993
Geoff Langbfdea662014-07-23 14:16:32 -04001994 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04001995 if (context)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001996 {
Geoff Langbfdea662014-07-23 14:16:32 -04001997 gl::Program *programObject = context->getProgram(program);
1998
1999 if (!programObject)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002000 {
Geoff Langbfdea662014-07-23 14:16:32 -04002001 if (context->getShader(program))
daniel@transgaming.comcf4aa872010-04-13 03:26:27 +00002002 {
Geoff Langb1196682014-07-23 13:47:29 -04002003 context->recordError(gl::Error(GL_INVALID_OPERATION));
2004 return -1;
daniel@transgaming.comcf4aa872010-04-13 03:26:27 +00002005 }
Geoff Langbfdea662014-07-23 14:16:32 -04002006 else
2007 {
Geoff Langb1196682014-07-23 13:47:29 -04002008 context->recordError(gl::Error(GL_INVALID_VALUE));
2009 return -1;
Geoff Langbfdea662014-07-23 14:16:32 -04002010 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002011 }
Geoff Langbfdea662014-07-23 14:16:32 -04002012
2013 gl::ProgramBinary *programBinary = programObject->getProgramBinary();
2014 if (!programObject->isLinked() || !programBinary)
2015 {
Geoff Langb1196682014-07-23 13:47:29 -04002016 context->recordError(gl::Error(GL_INVALID_OPERATION));
2017 return -1;
Geoff Langbfdea662014-07-23 14:16:32 -04002018 }
2019
2020 return programBinary->getAttributeLocation(name);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002021 }
2022
2023 return -1;
2024}
2025
Kenneth Russell67ea1902014-10-06 16:44:50 -07002026void GL_APIENTRY glGetBooleanv(GLenum pname, GLboolean* params)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002027{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00002028 EVENT("(GLenum pname = 0x%X, GLboolean* params = 0x%0.8p)", pname, params);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002029
Geoff Langbfdea662014-07-23 14:16:32 -04002030 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04002031 if (context)
2032 {
2033 GLenum nativeType;
2034 unsigned int numParams = 0;
2035 if (!ValidateStateQuery(context, pname, &nativeType, &numParams))
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002036 {
Geoff Langbfdea662014-07-23 14:16:32 -04002037 return;
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002038 }
Geoff Langbfdea662014-07-23 14:16:32 -04002039
2040 if (nativeType == GL_BOOL)
2041 {
2042 context->getBooleanv(pname, params);
2043 }
2044 else
2045 {
2046 CastStateValues(context, nativeType, pname, numParams, params);
2047 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002048 }
2049}
2050
Kenneth Russell67ea1902014-10-06 16:44:50 -07002051void GL_APIENTRY glGetBufferParameteriv(GLenum target, GLenum pname, GLint* params)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002052{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00002053 EVENT("(GLenum target = 0x%X, GLenum pname = 0x%X, GLint* params = 0x%0.8p)", target, pname, params);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002054
Geoff Langbfdea662014-07-23 14:16:32 -04002055 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04002056 if (context)
2057 {
2058 if (!gl::ValidBufferTarget(context, target))
daniel@transgaming.comaa0ccbd2010-04-15 20:45:05 +00002059 {
Geoff Langb1196682014-07-23 13:47:29 -04002060 context->recordError(gl::Error(GL_INVALID_ENUM));
2061 return;
daniel@transgaming.comaa0ccbd2010-04-15 20:45:05 +00002062 }
Geoff Langbfdea662014-07-23 14:16:32 -04002063
2064 if (!gl::ValidBufferParameter(context, pname))
2065 {
Geoff Langb1196682014-07-23 13:47:29 -04002066 context->recordError(gl::Error(GL_INVALID_ENUM));
2067 return;
Geoff Langbfdea662014-07-23 14:16:32 -04002068 }
2069
2070 gl::Buffer *buffer = context->getState().getTargetBuffer(target);
2071
2072 if (!buffer)
2073 {
2074 // A null buffer means that "0" is bound to the requested buffer target
Geoff Langb1196682014-07-23 13:47:29 -04002075 context->recordError(gl::Error(GL_INVALID_OPERATION));
2076 return;
Geoff Langbfdea662014-07-23 14:16:32 -04002077 }
2078
2079 switch (pname)
2080 {
2081 case GL_BUFFER_USAGE:
2082 *params = static_cast<GLint>(buffer->getUsage());
2083 break;
2084 case GL_BUFFER_SIZE:
2085 *params = gl::clampCast<GLint>(buffer->getSize());
2086 break;
2087 case GL_BUFFER_ACCESS_FLAGS:
2088 *params = buffer->getAccessFlags();
2089 break;
2090 case GL_BUFFER_MAPPED:
2091 *params = static_cast<GLint>(buffer->isMapped());
2092 break;
2093 case GL_BUFFER_MAP_OFFSET:
2094 *params = gl::clampCast<GLint>(buffer->getMapOffset());
2095 break;
2096 case GL_BUFFER_MAP_LENGTH:
2097 *params = gl::clampCast<GLint>(buffer->getMapLength());
2098 break;
2099 default: UNREACHABLE(); break;
2100 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002101 }
2102}
2103
Kenneth Russell67ea1902014-10-06 16:44:50 -07002104GLenum GL_APIENTRY glGetError(void)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002105{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00002106 EVENT("()");
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002107
2108 gl::Context *context = gl::getContext();
2109
2110 if (context)
2111 {
daniel@transgaming.com82b28912011-12-12 21:01:35 +00002112 return context->getError();
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002113 }
2114
2115 return GL_NO_ERROR;
2116}
2117
Kenneth Russell67ea1902014-10-06 16:44:50 -07002118void GL_APIENTRY glGetFenceivNV(GLuint fence, GLenum pname, GLint *params)
apatrick@chromium.orgd3bd0ad2010-08-30 18:55:36 +00002119{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00002120 EVENT("(GLuint fence = %d, GLenum pname = 0x%X, GLint *params = 0x%0.8p)", fence, pname, params);
apatrick@chromium.orgd3bd0ad2010-08-30 18:55:36 +00002121
Geoff Langbfdea662014-07-23 14:16:32 -04002122 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04002123 if (context)
2124 {
2125 gl::FenceNV *fenceObject = context->getFenceNV(fence);
2126
2127 if (fenceObject == NULL)
apatrick@chromium.orgd3bd0ad2010-08-30 18:55:36 +00002128 {
Geoff Langb1196682014-07-23 13:47:29 -04002129 context->recordError(gl::Error(GL_INVALID_OPERATION));
2130 return;
apatrick@chromium.orgd3bd0ad2010-08-30 18:55:36 +00002131 }
Geoff Langbfdea662014-07-23 14:16:32 -04002132
2133 if (fenceObject->isFence() != GL_TRUE)
2134 {
Geoff Langb1196682014-07-23 13:47:29 -04002135 context->recordError(gl::Error(GL_INVALID_OPERATION));
2136 return;
Geoff Langbfdea662014-07-23 14:16:32 -04002137 }
2138
2139 switch (pname)
2140 {
2141 case GL_FENCE_STATUS_NV:
Kenneth Russellcaa549c2014-10-10 17:52:59 -07002142 {
2143 // GL_NV_fence spec:
2144 // Once the status of a fence has been finished (via FinishFenceNV) or tested and the returned status is TRUE (via either TestFenceNV
2145 // or GetFenceivNV querying the FENCE_STATUS_NV), the status remains TRUE until the next SetFenceNV of the fence.
2146 GLboolean status = GL_TRUE;
2147 if (fenceObject->getStatus() != GL_TRUE)
2148 {
2149 gl::Error error = fenceObject->testFence(&status);
2150 if (error.isError())
2151 {
2152 context->recordError(error);
2153 return;
2154 }
2155 }
2156 *params = status;
2157 break;
2158 }
2159
Geoff Langbfdea662014-07-23 14:16:32 -04002160 case GL_FENCE_CONDITION_NV:
Kenneth Russellcaa549c2014-10-10 17:52:59 -07002161 {
2162 *params = fenceObject->getCondition();
2163 break;
2164 }
Geoff Langbfdea662014-07-23 14:16:32 -04002165
Geoff Langb1196682014-07-23 13:47:29 -04002166 default:
Kenneth Russellcaa549c2014-10-10 17:52:59 -07002167 {
2168 context->recordError(gl::Error(GL_INVALID_ENUM));
2169 return;
2170 }
Geoff Lang882033e2014-09-30 11:26:07 -04002171 }
apatrick@chromium.orgd3bd0ad2010-08-30 18:55:36 +00002172 }
2173}
2174
Kenneth Russell67ea1902014-10-06 16:44:50 -07002175void GL_APIENTRY glGetFloatv(GLenum pname, GLfloat* params)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002176{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00002177 EVENT("(GLenum pname = 0x%X, GLfloat* params = 0x%0.8p)", pname, params);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002178
Geoff Langbfdea662014-07-23 14:16:32 -04002179 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04002180 if (context)
2181 {
2182 GLenum nativeType;
2183 unsigned int numParams = 0;
2184 if (!ValidateStateQuery(context, pname, &nativeType, &numParams))
daniel@transgaming.com32e58cd2010-03-24 09:44:10 +00002185 {
Geoff Langbfdea662014-07-23 14:16:32 -04002186 return;
daniel@transgaming.com32e58cd2010-03-24 09:44:10 +00002187 }
Geoff Langbfdea662014-07-23 14:16:32 -04002188
2189 if (nativeType == GL_FLOAT)
2190 {
2191 context->getFloatv(pname, params);
2192 }
2193 else
2194 {
2195 CastStateValues(context, nativeType, pname, numParams, params);
2196 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002197 }
2198}
2199
Kenneth Russell67ea1902014-10-06 16:44:50 -07002200void GL_APIENTRY glGetFramebufferAttachmentParameteriv(GLenum target, GLenum attachment, GLenum pname, GLint* params)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002201{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00002202 EVENT("(GLenum target = 0x%X, GLenum attachment = 0x%X, GLenum pname = 0x%X, GLint* params = 0x%0.8p)",
daniel@transgaming.comb5b06162010-03-21 04:31:32 +00002203 target, attachment, pname, params);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002204
Geoff Langbfdea662014-07-23 14:16:32 -04002205 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04002206 if (context)
2207 {
2208 if (!gl::ValidFramebufferTarget(target))
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002209 {
Geoff Langb1196682014-07-23 13:47:29 -04002210 context->recordError(gl::Error(GL_INVALID_ENUM));
2211 return;
Geoff Langbfdea662014-07-23 14:16:32 -04002212 }
2213
2214 int clientVersion = context->getClientVersion();
2215
2216 switch (pname)
2217 {
2218 case GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE:
2219 case GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME:
2220 case GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL:
2221 case GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE:
2222 break;
Geoff Langb1196682014-07-23 13:47:29 -04002223
Geoff Langbfdea662014-07-23 14:16:32 -04002224 case GL_FRAMEBUFFER_ATTACHMENT_COLOR_ENCODING:
2225 if (clientVersion < 3 && !context->getExtensions().sRGB)
daniel@transgaming.comc46c9c02010-04-23 18:34:55 +00002226 {
Geoff Langb1196682014-07-23 13:47:29 -04002227 context->recordError(gl::Error(GL_INVALID_ENUM));
2228 return;
daniel@transgaming.comc46c9c02010-04-23 18:34:55 +00002229 }
Geoff Langbfdea662014-07-23 14:16:32 -04002230 break;
Geoff Langb1196682014-07-23 13:47:29 -04002231
Geoff Langbfdea662014-07-23 14:16:32 -04002232 case GL_FRAMEBUFFER_ATTACHMENT_RED_SIZE:
2233 case GL_FRAMEBUFFER_ATTACHMENT_GREEN_SIZE:
2234 case GL_FRAMEBUFFER_ATTACHMENT_BLUE_SIZE:
2235 case GL_FRAMEBUFFER_ATTACHMENT_ALPHA_SIZE:
2236 case GL_FRAMEBUFFER_ATTACHMENT_DEPTH_SIZE:
2237 case GL_FRAMEBUFFER_ATTACHMENT_STENCIL_SIZE:
2238 case GL_FRAMEBUFFER_ATTACHMENT_COMPONENT_TYPE:
2239 case GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LAYER:
2240 if (clientVersion < 3)
2241 {
Geoff Langb1196682014-07-23 13:47:29 -04002242 context->recordError(gl::Error(GL_INVALID_ENUM));
2243 return;
Geoff Langbfdea662014-07-23 14:16:32 -04002244 }
2245 break;
Geoff Langb1196682014-07-23 13:47:29 -04002246
Geoff Langbfdea662014-07-23 14:16:32 -04002247 default:
Geoff Langb1196682014-07-23 13:47:29 -04002248 context->recordError(gl::Error(GL_INVALID_ENUM));
2249 return;
Geoff Langbfdea662014-07-23 14:16:32 -04002250 }
daniel@transgaming.comc46c9c02010-04-23 18:34:55 +00002251
Geoff Langbfdea662014-07-23 14:16:32 -04002252 // Determine if the attachment is a valid enum
2253 switch (attachment)
2254 {
2255 case GL_BACK:
2256 case GL_FRONT:
2257 case GL_DEPTH:
2258 case GL_STENCIL:
2259 case GL_DEPTH_STENCIL_ATTACHMENT:
2260 if (clientVersion < 3)
2261 {
Geoff Langb1196682014-07-23 13:47:29 -04002262 context->recordError(gl::Error(GL_INVALID_ENUM));
2263 return;
Geoff Langbfdea662014-07-23 14:16:32 -04002264 }
2265 break;
2266
2267 case GL_DEPTH_ATTACHMENT:
2268 case GL_STENCIL_ATTACHMENT:
2269 break;
2270
2271 default:
2272 if (attachment < GL_COLOR_ATTACHMENT0_EXT ||
2273 (attachment - GL_COLOR_ATTACHMENT0_EXT) >= context->getCaps().maxColorAttachments)
2274 {
Geoff Langb1196682014-07-23 13:47:29 -04002275 context->recordError(gl::Error(GL_INVALID_ENUM));
2276 return;
Geoff Langbfdea662014-07-23 14:16:32 -04002277 }
2278 break;
2279 }
2280
2281 GLuint framebufferHandle = context->getState().getTargetFramebuffer(target)->id();
2282 gl::Framebuffer *framebuffer = context->getFramebuffer(framebufferHandle);
2283
2284 if (framebufferHandle == 0)
2285 {
2286 if (clientVersion < 3)
2287 {
Geoff Langb1196682014-07-23 13:47:29 -04002288 context->recordError(gl::Error(GL_INVALID_OPERATION));
2289 return;
Geoff Langbfdea662014-07-23 14:16:32 -04002290 }
2291
2292 switch (attachment)
2293 {
2294 case GL_BACK:
2295 case GL_DEPTH:
2296 case GL_STENCIL:
2297 break;
Geoff Langb1196682014-07-23 13:47:29 -04002298
Geoff Langbfdea662014-07-23 14:16:32 -04002299 default:
Geoff Langb1196682014-07-23 13:47:29 -04002300 context->recordError(gl::Error(GL_INVALID_OPERATION));
2301 return;
Geoff Langbfdea662014-07-23 14:16:32 -04002302 }
2303 }
2304 else
2305 {
2306 if (attachment >= GL_COLOR_ATTACHMENT0_EXT && attachment <= GL_COLOR_ATTACHMENT15_EXT)
2307 {
2308 // Valid attachment query
2309 }
2310 else
2311 {
2312 switch (attachment)
2313 {
2314 case GL_DEPTH_ATTACHMENT:
2315 case GL_STENCIL_ATTACHMENT:
2316 break;
Geoff Langb1196682014-07-23 13:47:29 -04002317
Geoff Langbfdea662014-07-23 14:16:32 -04002318 case GL_DEPTH_STENCIL_ATTACHMENT:
2319 if (framebuffer->hasValidDepthStencil())
2320 {
Geoff Langb1196682014-07-23 13:47:29 -04002321 context->recordError(gl::Error(GL_INVALID_OPERATION));
2322 return;
Geoff Langbfdea662014-07-23 14:16:32 -04002323 }
2324 break;
Geoff Langb1196682014-07-23 13:47:29 -04002325
Geoff Langbfdea662014-07-23 14:16:32 -04002326 default:
Geoff Langb1196682014-07-23 13:47:29 -04002327 context->recordError(gl::Error(GL_INVALID_OPERATION));
2328 return;
Geoff Langbfdea662014-07-23 14:16:32 -04002329 }
2330 }
2331 }
2332
2333 GLenum attachmentType = GL_NONE;
2334 GLuint attachmentHandle = 0;
2335 GLuint attachmentLevel = 0;
2336 GLuint attachmentLayer = 0;
2337
2338 const gl::FramebufferAttachment *attachmentObject = framebuffer->getAttachment(attachment);
2339
2340 if (attachmentObject)
2341 {
2342 attachmentType = attachmentObject->type();
2343 attachmentHandle = attachmentObject->id();
2344 attachmentLevel = attachmentObject->mipLevel();
2345 attachmentLayer = attachmentObject->layer();
2346 }
2347
2348 GLenum attachmentObjectType; // Type category
2349 if (framebufferHandle == 0)
2350 {
2351 attachmentObjectType = GL_FRAMEBUFFER_DEFAULT;
2352 }
2353 else if (attachmentType == GL_NONE || attachmentType == GL_RENDERBUFFER)
2354 {
2355 attachmentObjectType = attachmentType;
2356 }
2357 else if (gl::ValidTexture2DDestinationTarget(context, attachmentType))
2358 {
2359 attachmentObjectType = GL_TEXTURE;
2360 }
2361 else
2362 {
2363 UNREACHABLE();
2364 return;
2365 }
2366
2367 if (attachmentObjectType == GL_NONE)
2368 {
2369 // ES 2.0.25 spec pg 127 states that if the value of FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE
2370 // is NONE, then querying any other pname will generate INVALID_ENUM.
2371
2372 // ES 3.0.2 spec pg 235 states that if the attachment type is none,
2373 // GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME will return zero and be an
2374 // INVALID_OPERATION for all other pnames
Jamie Madill1e3fa742014-06-16 10:34:00 -04002375
Geoff Lang646559f2013-08-15 11:08:15 -04002376 switch (pname)
daniel@transgaming.coma27ff1e2010-08-24 19:20:11 +00002377 {
Geoff Lang646559f2013-08-15 11:08:15 -04002378 case GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE:
Geoff Langbfdea662014-07-23 14:16:32 -04002379 *params = attachmentObjectType;
2380 break;
2381
Geoff Lang646559f2013-08-15 11:08:15 -04002382 case GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME:
Geoff Lang05b05022014-06-11 15:31:45 -04002383 if (clientVersion < 3)
daniel@transgaming.coma27ff1e2010-08-24 19:20:11 +00002384 {
Geoff Langb1196682014-07-23 13:47:29 -04002385 context->recordError(gl::Error(GL_INVALID_ENUM));
2386 return;
daniel@transgaming.coma27ff1e2010-08-24 19:20:11 +00002387 }
Geoff Langbfdea662014-07-23 14:16:32 -04002388 *params = 0;
Geoff Lang646559f2013-08-15 11:08:15 -04002389 break;
2390
2391 default:
Jamie Madill1e3fa742014-06-16 10:34:00 -04002392 if (clientVersion < 3)
shannon.woods%transgaming.com@gtempaccount.com89ae1132013-04-13 03:28:43 +00002393 {
Geoff Langb1196682014-07-23 13:47:29 -04002394 context->recordError(gl::Error(GL_INVALID_ENUM));
2395 return;
Geoff Lang646559f2013-08-15 11:08:15 -04002396 }
2397 else
2398 {
Geoff Langb1196682014-07-23 13:47:29 -04002399 context->recordError(gl::Error(GL_INVALID_OPERATION));
2400 return;
daniel@transgaming.comc46c9c02010-04-23 18:34:55 +00002401 }
daniel@transgaming.comc46c9c02010-04-23 18:34:55 +00002402 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002403 }
Geoff Langbfdea662014-07-23 14:16:32 -04002404 else
2405 {
2406 ASSERT(attachmentObjectType == GL_RENDERBUFFER || attachmentObjectType == GL_TEXTURE ||
2407 attachmentObjectType == GL_FRAMEBUFFER_DEFAULT);
2408 ASSERT(attachmentObject != NULL);
2409
2410 switch (pname)
2411 {
2412 case GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE:
2413 *params = attachmentObjectType;
2414 break;
2415
2416 case GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME:
2417 if (attachmentObjectType != GL_RENDERBUFFER && attachmentObjectType != GL_TEXTURE)
2418 {
Geoff Langb1196682014-07-23 13:47:29 -04002419 context->recordError(gl::Error(GL_INVALID_ENUM));
2420 return;
Geoff Langbfdea662014-07-23 14:16:32 -04002421 }
2422 *params = attachmentHandle;
2423 break;
2424
2425 case GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL:
2426 if (attachmentObjectType != GL_TEXTURE)
2427 {
Geoff Langb1196682014-07-23 13:47:29 -04002428 context->recordError(gl::Error(GL_INVALID_ENUM));
2429 return;
Geoff Langbfdea662014-07-23 14:16:32 -04002430 }
2431 *params = attachmentLevel;
2432 break;
2433
2434 case GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE:
2435 if (attachmentObjectType != GL_TEXTURE)
2436 {
Geoff Langb1196682014-07-23 13:47:29 -04002437 context->recordError(gl::Error(GL_INVALID_ENUM));
2438 return;
Geoff Langbfdea662014-07-23 14:16:32 -04002439 }
2440 *params = gl::IsCubemapTextureTarget(attachmentType) ? attachmentType : 0;
2441 break;
2442
2443 case GL_FRAMEBUFFER_ATTACHMENT_RED_SIZE:
2444 *params = attachmentObject->getRedSize();
2445 break;
2446
2447 case GL_FRAMEBUFFER_ATTACHMENT_GREEN_SIZE:
2448 *params = attachmentObject->getGreenSize();
2449 break;
2450
2451 case GL_FRAMEBUFFER_ATTACHMENT_BLUE_SIZE:
2452 *params = attachmentObject->getBlueSize();
2453 break;
2454
2455 case GL_FRAMEBUFFER_ATTACHMENT_ALPHA_SIZE:
2456 *params = attachmentObject->getAlphaSize();
2457 break;
2458
2459 case GL_FRAMEBUFFER_ATTACHMENT_DEPTH_SIZE:
2460 *params = attachmentObject->getDepthSize();
2461 break;
2462
2463 case GL_FRAMEBUFFER_ATTACHMENT_STENCIL_SIZE:
2464 *params = attachmentObject->getStencilSize();
2465 break;
2466
2467 case GL_FRAMEBUFFER_ATTACHMENT_COMPONENT_TYPE:
Jamie Madillee85d1b2014-09-17 10:35:23 -04002468 if (attachment == GL_DEPTH_STENCIL_ATTACHMENT)
Geoff Langbfdea662014-07-23 14:16:32 -04002469 {
Geoff Langb1196682014-07-23 13:47:29 -04002470 context->recordError(gl::Error(GL_INVALID_OPERATION));
2471 return;
Geoff Langbfdea662014-07-23 14:16:32 -04002472 }
2473 *params = attachmentObject->getComponentType();
2474 break;
2475
2476 case GL_FRAMEBUFFER_ATTACHMENT_COLOR_ENCODING:
2477 *params = attachmentObject->getColorEncoding();
2478 break;
2479
2480 case GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LAYER:
2481 if (attachmentObjectType != GL_TEXTURE)
2482 {
Geoff Langb1196682014-07-23 13:47:29 -04002483 context->recordError(gl::Error(GL_INVALID_ENUM));
2484 return;
Geoff Langbfdea662014-07-23 14:16:32 -04002485 }
2486 *params = attachmentLayer;
2487 break;
2488
2489 default:
2490 UNREACHABLE();
2491 break;
2492 }
2493 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002494 }
2495}
2496
Kenneth Russell67ea1902014-10-06 16:44:50 -07002497GLenum GL_APIENTRY glGetGraphicsResetStatusEXT(void)
daniel@transgaming.com17f548c2011-11-09 17:47:02 +00002498{
2499 EVENT("()");
2500
Geoff Langbfdea662014-07-23 14:16:32 -04002501 gl::Context *context = gl::getContext();
daniel@transgaming.com17f548c2011-11-09 17:47:02 +00002502
Geoff Langbfdea662014-07-23 14:16:32 -04002503 if (context)
daniel@transgaming.com17f548c2011-11-09 17:47:02 +00002504 {
Geoff Langbfdea662014-07-23 14:16:32 -04002505 return context->getResetStatus();
daniel@transgaming.com17f548c2011-11-09 17:47:02 +00002506 }
Geoff Langbfdea662014-07-23 14:16:32 -04002507
2508 return GL_NO_ERROR;
daniel@transgaming.com17f548c2011-11-09 17:47:02 +00002509}
2510
Kenneth Russell67ea1902014-10-06 16:44:50 -07002511void GL_APIENTRY glGetIntegerv(GLenum pname, GLint* params)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002512{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00002513 EVENT("(GLenum pname = 0x%X, GLint* params = 0x%0.8p)", pname, params);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002514
Geoff Langbfdea662014-07-23 14:16:32 -04002515 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04002516 if (context)
2517 {
2518 GLenum nativeType;
2519 unsigned int numParams = 0;
2520
2521 if (!ValidateStateQuery(context, pname, &nativeType, &numParams))
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002522 {
Geoff Langbfdea662014-07-23 14:16:32 -04002523 return;
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002524 }
Geoff Langbfdea662014-07-23 14:16:32 -04002525
2526 if (nativeType == GL_INT)
2527 {
2528 context->getIntegerv(pname, params);
2529 }
2530 else
2531 {
2532 CastStateValues(context, nativeType, pname, numParams, params);
2533 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002534 }
2535}
2536
Kenneth Russell67ea1902014-10-06 16:44:50 -07002537void GL_APIENTRY glGetProgramiv(GLuint program, GLenum pname, GLint* params)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002538{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00002539 EVENT("(GLuint program = %d, GLenum pname = %d, GLint* params = 0x%0.8p)", program, pname, params);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002540
Geoff Langbfdea662014-07-23 14:16:32 -04002541 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04002542 if (context)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002543 {
Geoff Langbfdea662014-07-23 14:16:32 -04002544 gl::Program *programObject = context->getProgram(program);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002545
Geoff Langbfdea662014-07-23 14:16:32 -04002546 if (!programObject)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002547 {
Geoff Langb1196682014-07-23 13:47:29 -04002548 context->recordError(gl::Error(GL_INVALID_VALUE));
2549 return;
Geoff Langbfdea662014-07-23 14:16:32 -04002550 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002551
Geoff Langbfdea662014-07-23 14:16:32 -04002552 if (context->getClientVersion() < 3)
2553 {
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002554 switch (pname)
2555 {
shannonwoods@chromium.orge684b582013-05-30 00:07:42 +00002556 case GL_ACTIVE_UNIFORM_BLOCKS:
shannonwoods@chromium.orge684b582013-05-30 00:07:42 +00002557 case GL_ACTIVE_UNIFORM_BLOCK_MAX_NAME_LENGTH:
Geoff Lang1b6edcb2014-02-03 14:27:56 -05002558 case GL_TRANSFORM_FEEDBACK_BUFFER_MODE:
Geoff Lang1b6edcb2014-02-03 14:27:56 -05002559 case GL_TRANSFORM_FEEDBACK_VARYINGS:
Geoff Lang1b6edcb2014-02-03 14:27:56 -05002560 case GL_TRANSFORM_FEEDBACK_VARYING_MAX_LENGTH:
Geoff Langb1196682014-07-23 13:47:29 -04002561 context->recordError(gl::Error(GL_INVALID_ENUM));
2562 return;
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002563 }
2564 }
Geoff Langbfdea662014-07-23 14:16:32 -04002565
2566 switch (pname)
2567 {
2568 case GL_DELETE_STATUS:
2569 *params = programObject->isFlaggedForDeletion();
2570 return;
2571 case GL_LINK_STATUS:
2572 *params = programObject->isLinked();
2573 return;
2574 case GL_VALIDATE_STATUS:
2575 *params = programObject->isValidated();
2576 return;
2577 case GL_INFO_LOG_LENGTH:
2578 *params = programObject->getInfoLogLength();
2579 return;
2580 case GL_ATTACHED_SHADERS:
2581 *params = programObject->getAttachedShadersCount();
2582 return;
2583 case GL_ACTIVE_ATTRIBUTES:
2584 *params = programObject->getActiveAttributeCount();
2585 return;
2586 case GL_ACTIVE_ATTRIBUTE_MAX_LENGTH:
2587 *params = programObject->getActiveAttributeMaxLength();
2588 return;
2589 case GL_ACTIVE_UNIFORMS:
2590 *params = programObject->getActiveUniformCount();
2591 return;
2592 case GL_ACTIVE_UNIFORM_MAX_LENGTH:
2593 *params = programObject->getActiveUniformMaxLength();
2594 return;
2595 case GL_PROGRAM_BINARY_LENGTH_OES:
2596 *params = programObject->getProgramBinaryLength();
2597 return;
2598 case GL_ACTIVE_UNIFORM_BLOCKS:
2599 *params = programObject->getActiveUniformBlockCount();
2600 return;
2601 case GL_ACTIVE_UNIFORM_BLOCK_MAX_NAME_LENGTH:
2602 *params = programObject->getActiveUniformBlockMaxLength();
2603 break;
2604 case GL_TRANSFORM_FEEDBACK_BUFFER_MODE:
2605 *params = programObject->getTransformFeedbackBufferMode();
2606 break;
2607 case GL_TRANSFORM_FEEDBACK_VARYINGS:
2608 *params = programObject->getTransformFeedbackVaryingCount();
2609 break;
2610 case GL_TRANSFORM_FEEDBACK_VARYING_MAX_LENGTH:
2611 *params = programObject->getTransformFeedbackVaryingMaxLength();
2612 break;
Geoff Langb1196682014-07-23 13:47:29 -04002613
Geoff Langbfdea662014-07-23 14:16:32 -04002614 default:
Geoff Langb1196682014-07-23 13:47:29 -04002615 context->recordError(gl::Error(GL_INVALID_ENUM));
2616 return;
Geoff Langbfdea662014-07-23 14:16:32 -04002617 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002618 }
2619}
2620
Kenneth Russell67ea1902014-10-06 16:44:50 -07002621void GL_APIENTRY glGetProgramInfoLog(GLuint program, GLsizei bufsize, GLsizei* length, GLchar* infolog)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002622{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00002623 EVENT("(GLuint program = %d, GLsizei bufsize = %d, GLsizei* length = 0x%0.8p, GLchar* infolog = 0x%0.8p)",
daniel@transgaming.comb5b06162010-03-21 04:31:32 +00002624 program, bufsize, length, infolog);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002625
Geoff Langbfdea662014-07-23 14:16:32 -04002626 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04002627 if (context)
2628 {
Geoff Langb1196682014-07-23 13:47:29 -04002629 if (bufsize < 0)
2630 {
2631 context->recordError(gl::Error(GL_INVALID_VALUE));
2632 return;
2633 }
2634
Geoff Langbfdea662014-07-23 14:16:32 -04002635 gl::Program *programObject = context->getProgram(program);
2636
2637 if (!programObject)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002638 {
Geoff Langb1196682014-07-23 13:47:29 -04002639 context->recordError(gl::Error(GL_INVALID_VALUE));
2640 return;
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002641 }
2642
Geoff Langbfdea662014-07-23 14:16:32 -04002643 programObject->getInfoLog(bufsize, length, infolog);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002644 }
2645}
2646
Kenneth Russell67ea1902014-10-06 16:44:50 -07002647void GL_APIENTRY glGetQueryivEXT(GLenum target, GLenum pname, GLint *params)
daniel@transgaming.com86bdb822012-01-20 18:24:39 +00002648{
2649 EVENT("GLenum target = 0x%X, GLenum pname = 0x%X, GLint *params = 0x%0.8p)", target, pname, params);
2650
Geoff Langbfdea662014-07-23 14:16:32 -04002651 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04002652 if (context)
2653 {
2654 if (!ValidQueryType(context, target))
daniel@transgaming.com86bdb822012-01-20 18:24:39 +00002655 {
Geoff Langb1196682014-07-23 13:47:29 -04002656 context->recordError(gl::Error(GL_INVALID_ENUM));
2657 return;
daniel@transgaming.com86bdb822012-01-20 18:24:39 +00002658 }
Geoff Langbfdea662014-07-23 14:16:32 -04002659
2660 switch (pname)
2661 {
2662 case GL_CURRENT_QUERY_EXT:
2663 params[0] = context->getState().getActiveQueryId(target);
2664 break;
2665
2666 default:
Geoff Langb1196682014-07-23 13:47:29 -04002667 context->recordError(gl::Error(GL_INVALID_ENUM));
2668 return;
Geoff Langbfdea662014-07-23 14:16:32 -04002669 }
daniel@transgaming.com86bdb822012-01-20 18:24:39 +00002670 }
2671}
2672
Kenneth Russell67ea1902014-10-06 16:44:50 -07002673void GL_APIENTRY glGetQueryObjectuivEXT(GLuint id, GLenum pname, GLuint *params)
daniel@transgaming.com86bdb822012-01-20 18:24:39 +00002674{
2675 EVENT("(GLuint id = %d, GLenum pname = 0x%X, GLuint *params = 0x%0.8p)", id, pname, params);
2676
Geoff Langbfdea662014-07-23 14:16:32 -04002677 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04002678 if (context)
2679 {
2680 gl::Query *queryObject = context->getQuery(id, false, GL_NONE);
2681
2682 if (!queryObject)
daniel@transgaming.com86bdb822012-01-20 18:24:39 +00002683 {
Geoff Langb1196682014-07-23 13:47:29 -04002684 context->recordError(gl::Error(GL_INVALID_OPERATION));
2685 return;
daniel@transgaming.com86bdb822012-01-20 18:24:39 +00002686 }
Geoff Langbfdea662014-07-23 14:16:32 -04002687
2688 if (context->getState().getActiveQueryId(queryObject->getType()) == id)
2689 {
Geoff Langb1196682014-07-23 13:47:29 -04002690 context->recordError(gl::Error(GL_INVALID_OPERATION));
2691 return;
Geoff Langbfdea662014-07-23 14:16:32 -04002692 }
2693
2694 switch(pname)
2695 {
2696 case GL_QUERY_RESULT_EXT:
Geoff Lang5aad9672014-09-08 11:10:42 -04002697 {
2698 gl::Error error = queryObject->getResult(params);
2699 if (error.isError())
2700 {
2701 context->recordError(error);
2702 return;
2703 }
2704 }
Geoff Langbfdea662014-07-23 14:16:32 -04002705 break;
Geoff Lang5aad9672014-09-08 11:10:42 -04002706
Geoff Langbfdea662014-07-23 14:16:32 -04002707 case GL_QUERY_RESULT_AVAILABLE_EXT:
Geoff Lang5aad9672014-09-08 11:10:42 -04002708 {
2709 gl::Error error = queryObject->isResultAvailable(params);
2710 if (error.isError())
2711 {
2712 context->recordError(error);
2713 return;
2714 }
2715 }
Geoff Langbfdea662014-07-23 14:16:32 -04002716 break;
Geoff Lang5aad9672014-09-08 11:10:42 -04002717
Geoff Langbfdea662014-07-23 14:16:32 -04002718 default:
Geoff Langb1196682014-07-23 13:47:29 -04002719 context->recordError(gl::Error(GL_INVALID_ENUM));
2720 return;
Geoff Langbfdea662014-07-23 14:16:32 -04002721 }
daniel@transgaming.com86bdb822012-01-20 18:24:39 +00002722 }
2723}
2724
Kenneth Russell67ea1902014-10-06 16:44:50 -07002725void GL_APIENTRY glGetRenderbufferParameteriv(GLenum target, GLenum pname, GLint* params)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002726{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00002727 EVENT("(GLenum target = 0x%X, GLenum pname = 0x%X, GLint* params = 0x%0.8p)", target, pname, params);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002728
Geoff Langbfdea662014-07-23 14:16:32 -04002729 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04002730 if (context)
2731 {
2732 if (target != GL_RENDERBUFFER)
daniel@transgaming.com4901fca2010-04-20 18:52:41 +00002733 {
Geoff Langb1196682014-07-23 13:47:29 -04002734 context->recordError(gl::Error(GL_INVALID_ENUM));
2735 return;
daniel@transgaming.com4901fca2010-04-20 18:52:41 +00002736 }
Geoff Langbfdea662014-07-23 14:16:32 -04002737
2738 if (context->getState().getRenderbufferId() == 0)
2739 {
Geoff Langb1196682014-07-23 13:47:29 -04002740 context->recordError(gl::Error(GL_INVALID_OPERATION));
2741 return;
Geoff Langbfdea662014-07-23 14:16:32 -04002742 }
2743
2744 gl::Renderbuffer *renderbuffer = context->getRenderbuffer(context->getState().getRenderbufferId());
2745
2746 switch (pname)
2747 {
2748 case GL_RENDERBUFFER_WIDTH: *params = renderbuffer->getWidth(); break;
2749 case GL_RENDERBUFFER_HEIGHT: *params = renderbuffer->getHeight(); break;
2750 case GL_RENDERBUFFER_INTERNAL_FORMAT: *params = renderbuffer->getInternalFormat(); break;
2751 case GL_RENDERBUFFER_RED_SIZE: *params = renderbuffer->getRedSize(); break;
2752 case GL_RENDERBUFFER_GREEN_SIZE: *params = renderbuffer->getGreenSize(); break;
2753 case GL_RENDERBUFFER_BLUE_SIZE: *params = renderbuffer->getBlueSize(); break;
2754 case GL_RENDERBUFFER_ALPHA_SIZE: *params = renderbuffer->getAlphaSize(); break;
2755 case GL_RENDERBUFFER_DEPTH_SIZE: *params = renderbuffer->getDepthSize(); break;
2756 case GL_RENDERBUFFER_STENCIL_SIZE: *params = renderbuffer->getStencilSize(); break;
Geoff Langb1196682014-07-23 13:47:29 -04002757
Geoff Langbfdea662014-07-23 14:16:32 -04002758 case GL_RENDERBUFFER_SAMPLES_ANGLE:
2759 if (!context->getExtensions().framebufferMultisample)
2760 {
Geoff Langb1196682014-07-23 13:47:29 -04002761 context->recordError(gl::Error(GL_INVALID_ENUM));
2762 return;
Geoff Langbfdea662014-07-23 14:16:32 -04002763 }
2764 *params = renderbuffer->getSamples();
2765 break;
Geoff Langb1196682014-07-23 13:47:29 -04002766
Geoff Langbfdea662014-07-23 14:16:32 -04002767 default:
Geoff Langb1196682014-07-23 13:47:29 -04002768 context->recordError(gl::Error(GL_INVALID_ENUM));
2769 return;
Geoff Langbfdea662014-07-23 14:16:32 -04002770 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002771 }
2772}
2773
Kenneth Russell67ea1902014-10-06 16:44:50 -07002774void GL_APIENTRY glGetShaderiv(GLuint shader, GLenum pname, GLint* params)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002775{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00002776 EVENT("(GLuint shader = %d, GLenum pname = %d, GLint* params = 0x%0.8p)", shader, pname, params);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002777
Geoff Langbfdea662014-07-23 14:16:32 -04002778 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04002779 if (context)
2780 {
2781 gl::Shader *shaderObject = context->getShader(shader);
2782
2783 if (!shaderObject)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002784 {
Geoff Langb1196682014-07-23 13:47:29 -04002785 context->recordError(gl::Error(GL_INVALID_VALUE));
2786 return;
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002787 }
Geoff Langbfdea662014-07-23 14:16:32 -04002788
2789 switch (pname)
2790 {
2791 case GL_SHADER_TYPE:
2792 *params = shaderObject->getType();
2793 return;
2794 case GL_DELETE_STATUS:
2795 *params = shaderObject->isFlaggedForDeletion();
2796 return;
2797 case GL_COMPILE_STATUS:
2798 *params = shaderObject->isCompiled() ? GL_TRUE : GL_FALSE;
2799 return;
2800 case GL_INFO_LOG_LENGTH:
2801 *params = shaderObject->getInfoLogLength();
2802 return;
2803 case GL_SHADER_SOURCE_LENGTH:
2804 *params = shaderObject->getSourceLength();
2805 return;
2806 case GL_TRANSLATED_SHADER_SOURCE_LENGTH_ANGLE:
2807 *params = shaderObject->getTranslatedSourceLength();
2808 return;
Geoff Langb1196682014-07-23 13:47:29 -04002809
Geoff Langbfdea662014-07-23 14:16:32 -04002810 default:
Geoff Langb1196682014-07-23 13:47:29 -04002811 context->recordError(gl::Error(GL_INVALID_ENUM));
2812 return;
Geoff Langbfdea662014-07-23 14:16:32 -04002813 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002814 }
2815}
2816
Kenneth Russell67ea1902014-10-06 16:44:50 -07002817void GL_APIENTRY glGetShaderInfoLog(GLuint shader, GLsizei bufsize, GLsizei* length, GLchar* infolog)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002818{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00002819 EVENT("(GLuint shader = %d, GLsizei bufsize = %d, GLsizei* length = 0x%0.8p, GLchar* infolog = 0x%0.8p)",
daniel@transgaming.comb5b06162010-03-21 04:31:32 +00002820 shader, bufsize, length, infolog);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002821
Geoff Langbfdea662014-07-23 14:16:32 -04002822 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04002823 if (context)
2824 {
Geoff Langb1196682014-07-23 13:47:29 -04002825 if (bufsize < 0)
2826 {
2827 context->recordError(gl::Error(GL_INVALID_VALUE));
2828 return;
2829 }
2830
Geoff Langbfdea662014-07-23 14:16:32 -04002831 gl::Shader *shaderObject = context->getShader(shader);
2832
2833 if (!shaderObject)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002834 {
Geoff Langb1196682014-07-23 13:47:29 -04002835 context->recordError(gl::Error(GL_INVALID_VALUE));
2836 return;
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002837 }
2838
Geoff Langbfdea662014-07-23 14:16:32 -04002839 shaderObject->getInfoLog(bufsize, length, infolog);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002840 }
2841}
2842
Kenneth Russell67ea1902014-10-06 16:44:50 -07002843void GL_APIENTRY glGetShaderPrecisionFormat(GLenum shadertype, GLenum precisiontype, GLint* range, GLint* precision)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002844{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00002845 EVENT("(GLenum shadertype = 0x%X, GLenum precisiontype = 0x%X, GLint* range = 0x%0.8p, GLint* precision = 0x%0.8p)",
daniel@transgaming.comb5b06162010-03-21 04:31:32 +00002846 shadertype, precisiontype, range, precision);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002847
Geoff Langb1196682014-07-23 13:47:29 -04002848 gl::Context *context = gl::getNonLostContext();
2849 if (context)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002850 {
Geoff Langb1196682014-07-23 13:47:29 -04002851 switch (shadertype)
2852 {
2853 case GL_VERTEX_SHADER:
2854 case GL_FRAGMENT_SHADER:
2855 break;
Geoff Langbfdea662014-07-23 14:16:32 -04002856
Geoff Langb1196682014-07-23 13:47:29 -04002857 default:
2858 context->recordError(gl::Error(GL_INVALID_ENUM));
2859 return;
2860 }
2861
2862 switch (precisiontype)
2863 {
2864 case GL_LOW_FLOAT:
2865 case GL_MEDIUM_FLOAT:
2866 case GL_HIGH_FLOAT:
2867 // Assume IEEE 754 precision
2868 range[0] = 127;
2869 range[1] = 127;
2870 *precision = 23;
2871 break;
2872
2873 case GL_LOW_INT:
2874 case GL_MEDIUM_INT:
2875 case GL_HIGH_INT:
2876 // Some (most) hardware only supports single-precision floating-point numbers,
2877 // which can accurately represent integers up to +/-16777216
2878 range[0] = 24;
2879 range[1] = 24;
2880 *precision = 0;
2881 break;
2882
2883 default:
2884 context->recordError(gl::Error(GL_INVALID_ENUM));
2885 return;
2886 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002887 }
2888}
2889
Kenneth Russell67ea1902014-10-06 16:44:50 -07002890void GL_APIENTRY glGetShaderSource(GLuint shader, GLsizei bufsize, GLsizei* length, GLchar* source)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002891{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00002892 EVENT("(GLuint shader = %d, GLsizei bufsize = %d, GLsizei* length = 0x%0.8p, GLchar* source = 0x%0.8p)",
daniel@transgaming.comb5b06162010-03-21 04:31:32 +00002893 shader, bufsize, length, source);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002894
Geoff Langbfdea662014-07-23 14:16:32 -04002895 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04002896 if (context)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002897 {
Geoff Langb1196682014-07-23 13:47:29 -04002898 if (bufsize < 0)
2899 {
2900 context->recordError(gl::Error(GL_INVALID_VALUE));
2901 return;
2902 }
2903
Geoff Langbfdea662014-07-23 14:16:32 -04002904 gl::Shader *shaderObject = context->getShader(shader);
2905
2906 if (!shaderObject)
2907 {
Geoff Langb1196682014-07-23 13:47:29 -04002908 context->recordError(gl::Error(GL_INVALID_OPERATION));
2909 return;
Geoff Langbfdea662014-07-23 14:16:32 -04002910 }
2911
2912 shaderObject->getSource(bufsize, length, source);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002913 }
2914}
2915
Kenneth Russell67ea1902014-10-06 16:44:50 -07002916void GL_APIENTRY glGetTranslatedShaderSourceANGLE(GLuint shader, GLsizei bufsize, GLsizei* length, GLchar* source)
zmo@google.coma574f782011-10-03 21:45:23 +00002917{
2918 EVENT("(GLuint shader = %d, GLsizei bufsize = %d, GLsizei* length = 0x%0.8p, GLchar* source = 0x%0.8p)",
2919 shader, bufsize, length, source);
2920
Geoff Langbfdea662014-07-23 14:16:32 -04002921 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04002922 if (context)
zmo@google.coma574f782011-10-03 21:45:23 +00002923 {
Geoff Langb1196682014-07-23 13:47:29 -04002924 if (bufsize < 0)
2925 {
2926 context->recordError(gl::Error(GL_INVALID_VALUE));
2927 return;
2928 }
2929
Geoff Langbfdea662014-07-23 14:16:32 -04002930 gl::Shader *shaderObject = context->getShader(shader);
2931
2932 if (!shaderObject)
2933 {
Geoff Langb1196682014-07-23 13:47:29 -04002934 context->recordError(gl::Error(GL_INVALID_OPERATION));
2935 return;
Geoff Langbfdea662014-07-23 14:16:32 -04002936 }
2937
2938 shaderObject->getTranslatedSource(bufsize, length, source);
zmo@google.coma574f782011-10-03 21:45:23 +00002939 }
2940}
2941
Kenneth Russell67ea1902014-10-06 16:44:50 -07002942const GLubyte* GL_APIENTRY glGetString(GLenum name)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002943{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00002944 EVENT("(GLenum name = 0x%X)", name);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002945
Geoff Langbfdea662014-07-23 14:16:32 -04002946 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.com3e4c6002010-05-05 18:50:13 +00002947
Geoff Langbfdea662014-07-23 14:16:32 -04002948 switch (name)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002949 {
Geoff Langbfdea662014-07-23 14:16:32 -04002950 case GL_VENDOR:
2951 return (GLubyte*)"Google Inc.";
Geoff Langb1196682014-07-23 13:47:29 -04002952
Geoff Langbfdea662014-07-23 14:16:32 -04002953 case GL_RENDERER:
2954 return (GLubyte*)((context != NULL) ? context->getRendererString().c_str() : "ANGLE");
Geoff Langb1196682014-07-23 13:47:29 -04002955
Geoff Langbfdea662014-07-23 14:16:32 -04002956 case GL_VERSION:
2957 if (context->getClientVersion() == 2)
2958 {
2959 return (GLubyte*)"OpenGL ES 2.0 (ANGLE " ANGLE_VERSION_STRING ")";
2960 }
2961 else
2962 {
2963 return (GLubyte*)"OpenGL ES 3.0 (ANGLE " ANGLE_VERSION_STRING ")";
2964 }
Geoff Langb1196682014-07-23 13:47:29 -04002965
Geoff Langbfdea662014-07-23 14:16:32 -04002966 case GL_SHADING_LANGUAGE_VERSION:
2967 if (context->getClientVersion() == 2)
2968 {
2969 return (GLubyte*)"OpenGL ES GLSL ES 1.00 (ANGLE " ANGLE_VERSION_STRING ")";
2970 }
2971 else
2972 {
2973 return (GLubyte*)"OpenGL ES GLSL ES 3.00 (ANGLE " ANGLE_VERSION_STRING ")";
2974 }
Geoff Langb1196682014-07-23 13:47:29 -04002975
Geoff Langbfdea662014-07-23 14:16:32 -04002976 case GL_EXTENSIONS:
2977 return (GLubyte*)((context != NULL) ? context->getExtensionString().c_str() : "");
Geoff Langb1196682014-07-23 13:47:29 -04002978
Geoff Langbfdea662014-07-23 14:16:32 -04002979 default:
Geoff Langb1196682014-07-23 13:47:29 -04002980 if (context)
2981 {
2982 context->recordError(gl::Error(GL_INVALID_ENUM));
2983 }
2984 return NULL;
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002985 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002986}
2987
Kenneth Russell67ea1902014-10-06 16:44:50 -07002988void GL_APIENTRY glGetTexParameterfv(GLenum target, GLenum pname, GLfloat* params)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002989{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00002990 EVENT("(GLenum target = 0x%X, GLenum pname = 0x%X, GLfloat* params = 0x%0.8p)", target, pname, params);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002991
Geoff Langbfdea662014-07-23 14:16:32 -04002992 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04002993 if (context)
2994 {
2995 gl::Texture *texture = context->getTargetTexture(target);
2996
2997 if (!texture)
daniel@transgaming.com5d2bee92010-04-20 18:51:56 +00002998 {
Geoff Langb1196682014-07-23 13:47:29 -04002999 context->recordError(gl::Error(GL_INVALID_ENUM));
3000 return;
daniel@transgaming.com5d2bee92010-04-20 18:51:56 +00003001 }
Geoff Langbfdea662014-07-23 14:16:32 -04003002
3003 switch (pname)
3004 {
3005 case GL_TEXTURE_MAG_FILTER:
3006 *params = (GLfloat)texture->getSamplerState().magFilter;
3007 break;
3008 case GL_TEXTURE_MIN_FILTER:
3009 *params = (GLfloat)texture->getSamplerState().minFilter;
3010 break;
3011 case GL_TEXTURE_WRAP_S:
3012 *params = (GLfloat)texture->getSamplerState().wrapS;
3013 break;
3014 case GL_TEXTURE_WRAP_T:
3015 *params = (GLfloat)texture->getSamplerState().wrapT;
3016 break;
3017 case GL_TEXTURE_WRAP_R:
3018 if (context->getClientVersion() < 3)
3019 {
Geoff Langb1196682014-07-23 13:47:29 -04003020 context->recordError(gl::Error(GL_INVALID_ENUM));
3021 return;
Geoff Langbfdea662014-07-23 14:16:32 -04003022 }
3023 *params = (GLfloat)texture->getSamplerState().wrapR;
3024 break;
3025 case GL_TEXTURE_IMMUTABLE_FORMAT:
3026 // Exposed to ES2.0 through EXT_texture_storage, no client version validation.
3027 *params = (GLfloat)(texture->isImmutable() ? GL_TRUE : GL_FALSE);
3028 break;
3029 case GL_TEXTURE_IMMUTABLE_LEVELS:
3030 if (context->getClientVersion() < 3)
3031 {
Geoff Langb1196682014-07-23 13:47:29 -04003032 context->recordError(gl::Error(GL_INVALID_ENUM));
3033 return;
Geoff Langbfdea662014-07-23 14:16:32 -04003034 }
3035 *params = (GLfloat)texture->immutableLevelCount();
3036 break;
3037 case GL_TEXTURE_USAGE_ANGLE:
3038 *params = (GLfloat)texture->getUsage();
3039 break;
3040 case GL_TEXTURE_MAX_ANISOTROPY_EXT:
3041 if (!context->getExtensions().textureFilterAnisotropic)
3042 {
Geoff Langb1196682014-07-23 13:47:29 -04003043 context->recordError(gl::Error(GL_INVALID_ENUM));
3044 return;
Geoff Langbfdea662014-07-23 14:16:32 -04003045 }
3046 *params = (GLfloat)texture->getSamplerState().maxAnisotropy;
3047 break;
3048 case GL_TEXTURE_SWIZZLE_R:
3049 if (context->getClientVersion() < 3)
3050 {
Geoff Langb1196682014-07-23 13:47:29 -04003051 context->recordError(gl::Error(GL_INVALID_ENUM));
3052 return;
Geoff Langbfdea662014-07-23 14:16:32 -04003053 }
3054 *params = (GLfloat)texture->getSamplerState().swizzleRed;
3055 break;
3056 case GL_TEXTURE_SWIZZLE_G:
3057 if (context->getClientVersion() < 3)
3058 {
Geoff Langb1196682014-07-23 13:47:29 -04003059 context->recordError(gl::Error(GL_INVALID_ENUM));
3060 return;
Geoff Langbfdea662014-07-23 14:16:32 -04003061 }
3062 *params = (GLfloat)texture->getSamplerState().swizzleGreen;
3063 break;
3064 case GL_TEXTURE_SWIZZLE_B:
3065 if (context->getClientVersion() < 3)
3066 {
Geoff Langb1196682014-07-23 13:47:29 -04003067 context->recordError(gl::Error(GL_INVALID_ENUM));
3068 return;
Geoff Langbfdea662014-07-23 14:16:32 -04003069 }
3070 *params = (GLfloat)texture->getSamplerState().swizzleBlue;
3071 break;
3072 case GL_TEXTURE_SWIZZLE_A:
3073 if (context->getClientVersion() < 3)
3074 {
Geoff Langb1196682014-07-23 13:47:29 -04003075 context->recordError(gl::Error(GL_INVALID_ENUM));
3076 return;
Geoff Langbfdea662014-07-23 14:16:32 -04003077 }
3078 *params = (GLfloat)texture->getSamplerState().swizzleAlpha;
3079 break;
3080 case GL_TEXTURE_BASE_LEVEL:
3081 if (context->getClientVersion() < 3)
3082 {
Geoff Langb1196682014-07-23 13:47:29 -04003083 context->recordError(gl::Error(GL_INVALID_ENUM));
3084 return;
Geoff Langbfdea662014-07-23 14:16:32 -04003085 }
3086 *params = (GLfloat)texture->getSamplerState().baseLevel;
3087 break;
3088 case GL_TEXTURE_MAX_LEVEL:
3089 if (context->getClientVersion() < 3)
3090 {
Geoff Langb1196682014-07-23 13:47:29 -04003091 context->recordError(gl::Error(GL_INVALID_ENUM));
3092 return;
Geoff Langbfdea662014-07-23 14:16:32 -04003093 }
3094 *params = (GLfloat)texture->getSamplerState().maxLevel;
3095 break;
3096 case GL_TEXTURE_MIN_LOD:
3097 if (context->getClientVersion() < 3)
3098 {
Geoff Langb1196682014-07-23 13:47:29 -04003099 context->recordError(gl::Error(GL_INVALID_ENUM));
3100 return;
Geoff Langbfdea662014-07-23 14:16:32 -04003101 }
3102 *params = texture->getSamplerState().minLod;
3103 break;
3104 case GL_TEXTURE_MAX_LOD:
3105 if (context->getClientVersion() < 3)
3106 {
Geoff Langb1196682014-07-23 13:47:29 -04003107 context->recordError(gl::Error(GL_INVALID_ENUM));
3108 return;
Geoff Langbfdea662014-07-23 14:16:32 -04003109 }
3110 *params = texture->getSamplerState().maxLod;
3111 break;
Geoff Langb1196682014-07-23 13:47:29 -04003112
Geoff Langbfdea662014-07-23 14:16:32 -04003113 default:
Geoff Langb1196682014-07-23 13:47:29 -04003114 context->recordError(gl::Error(GL_INVALID_ENUM));
3115 return;
Geoff Langbfdea662014-07-23 14:16:32 -04003116 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003117 }
3118}
3119
Kenneth Russell67ea1902014-10-06 16:44:50 -07003120void GL_APIENTRY glGetTexParameteriv(GLenum target, GLenum pname, GLint* params)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003121{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00003122 EVENT("(GLenum target = 0x%X, GLenum pname = 0x%X, GLint* params = 0x%0.8p)", target, pname, params);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003123
Geoff Langbfdea662014-07-23 14:16:32 -04003124 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04003125 if (context)
3126 {
3127 gl::Texture *texture = context->getTargetTexture(target);
3128
3129 if (!texture)
daniel@transgaming.com5d2bee92010-04-20 18:51:56 +00003130 {
Geoff Langb1196682014-07-23 13:47:29 -04003131 context->recordError(gl::Error(GL_INVALID_ENUM));
3132 return;
daniel@transgaming.com5d2bee92010-04-20 18:51:56 +00003133 }
Geoff Langbfdea662014-07-23 14:16:32 -04003134
3135 switch (pname)
3136 {
3137 case GL_TEXTURE_MAG_FILTER:
3138 *params = texture->getSamplerState().magFilter;
3139 break;
3140 case GL_TEXTURE_MIN_FILTER:
3141 *params = texture->getSamplerState().minFilter;
3142 break;
3143 case GL_TEXTURE_WRAP_S:
3144 *params = texture->getSamplerState().wrapS;
3145 break;
3146 case GL_TEXTURE_WRAP_T:
3147 *params = texture->getSamplerState().wrapT;
3148 break;
3149 case GL_TEXTURE_WRAP_R:
3150 if (context->getClientVersion() < 3)
3151 {
Geoff Langb1196682014-07-23 13:47:29 -04003152 context->recordError(gl::Error(GL_INVALID_ENUM));
3153 return;
Geoff Langbfdea662014-07-23 14:16:32 -04003154 }
3155 *params = texture->getSamplerState().wrapR;
3156 break;
3157 case GL_TEXTURE_IMMUTABLE_FORMAT:
3158 // Exposed to ES2.0 through EXT_texture_storage, no client version validation.
3159 *params = texture->isImmutable() ? GL_TRUE : GL_FALSE;
3160 break;
3161 case GL_TEXTURE_IMMUTABLE_LEVELS:
3162 if (context->getClientVersion() < 3)
3163 {
Geoff Langb1196682014-07-23 13:47:29 -04003164 context->recordError(gl::Error(GL_INVALID_ENUM));
3165 return;
Geoff Langbfdea662014-07-23 14:16:32 -04003166 }
3167 *params = texture->immutableLevelCount();
3168 break;
3169 case GL_TEXTURE_USAGE_ANGLE:
3170 *params = texture->getUsage();
3171 break;
3172 case GL_TEXTURE_MAX_ANISOTROPY_EXT:
3173 if (!context->getExtensions().textureFilterAnisotropic)
3174 {
Geoff Langb1196682014-07-23 13:47:29 -04003175 context->recordError(gl::Error(GL_INVALID_ENUM));
3176 return;
Geoff Langbfdea662014-07-23 14:16:32 -04003177 }
3178 *params = (GLint)texture->getSamplerState().maxAnisotropy;
3179 break;
3180 case GL_TEXTURE_SWIZZLE_R:
3181 if (context->getClientVersion() < 3)
3182 {
Geoff Langb1196682014-07-23 13:47:29 -04003183 context->recordError(gl::Error(GL_INVALID_ENUM));
3184 return;
Geoff Langbfdea662014-07-23 14:16:32 -04003185 }
3186 *params = texture->getSamplerState().swizzleRed;
3187 break;
3188 case GL_TEXTURE_SWIZZLE_G:
3189 if (context->getClientVersion() < 3)
3190 {
Geoff Langb1196682014-07-23 13:47:29 -04003191 context->recordError(gl::Error(GL_INVALID_ENUM));
3192 return;
Geoff Langbfdea662014-07-23 14:16:32 -04003193 }
3194 *params = texture->getSamplerState().swizzleGreen;
3195 break;
3196 case GL_TEXTURE_SWIZZLE_B:
3197 if (context->getClientVersion() < 3)
3198 {
Geoff Langb1196682014-07-23 13:47:29 -04003199 context->recordError(gl::Error(GL_INVALID_ENUM));
3200 return;
Geoff Langbfdea662014-07-23 14:16:32 -04003201 }
3202 *params = texture->getSamplerState().swizzleBlue;
3203 break;
3204 case GL_TEXTURE_SWIZZLE_A:
3205 if (context->getClientVersion() < 3)
3206 {
Geoff Langb1196682014-07-23 13:47:29 -04003207 context->recordError(gl::Error(GL_INVALID_ENUM));
3208 return;
Geoff Langbfdea662014-07-23 14:16:32 -04003209 }
3210 *params = texture->getSamplerState().swizzleAlpha;
3211 break;
3212 case GL_TEXTURE_BASE_LEVEL:
3213 if (context->getClientVersion() < 3)
3214 {
Geoff Langb1196682014-07-23 13:47:29 -04003215 context->recordError(gl::Error(GL_INVALID_ENUM));
3216 return;
Geoff Langbfdea662014-07-23 14:16:32 -04003217 }
3218 *params = texture->getSamplerState().baseLevel;
3219 break;
3220 case GL_TEXTURE_MAX_LEVEL:
3221 if (context->getClientVersion() < 3)
3222 {
Geoff Langb1196682014-07-23 13:47:29 -04003223 context->recordError(gl::Error(GL_INVALID_ENUM));
3224 return;
Geoff Langbfdea662014-07-23 14:16:32 -04003225 }
3226 *params = texture->getSamplerState().maxLevel;
3227 break;
3228 case GL_TEXTURE_MIN_LOD:
3229 if (context->getClientVersion() < 3)
3230 {
Geoff Langb1196682014-07-23 13:47:29 -04003231 context->recordError(gl::Error(GL_INVALID_ENUM));
3232 return;
Geoff Langbfdea662014-07-23 14:16:32 -04003233 }
3234 *params = (GLint)texture->getSamplerState().minLod;
3235 break;
3236 case GL_TEXTURE_MAX_LOD:
3237 if (context->getClientVersion() < 3)
3238 {
Geoff Langb1196682014-07-23 13:47:29 -04003239 context->recordError(gl::Error(GL_INVALID_ENUM));
3240 return;
Geoff Langbfdea662014-07-23 14:16:32 -04003241 }
3242 *params = (GLint)texture->getSamplerState().maxLod;
3243 break;
Geoff Langb1196682014-07-23 13:47:29 -04003244
Geoff Langbfdea662014-07-23 14:16:32 -04003245 default:
Geoff Langb1196682014-07-23 13:47:29 -04003246 context->recordError(gl::Error(GL_INVALID_ENUM));
3247 return;
Geoff Langbfdea662014-07-23 14:16:32 -04003248 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003249 }
3250}
3251
Kenneth Russell67ea1902014-10-06 16:44:50 -07003252void GL_APIENTRY glGetnUniformfvEXT(GLuint program, GLint location, GLsizei bufSize, GLfloat* params)
daniel@transgaming.com9a849122011-11-12 03:18:00 +00003253{
3254 EVENT("(GLuint program = %d, GLint location = %d, GLsizei bufSize = %d, GLfloat* params = 0x%0.8p)",
3255 program, location, bufSize, params);
3256
Geoff Langbfdea662014-07-23 14:16:32 -04003257 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04003258 if (context)
3259 {
Jamie Madill0063c512014-08-25 15:47:53 -04003260 if (!ValidateGetnUniformfvEXT(context, program, location, bufSize, params))
daniel@transgaming.com9a849122011-11-12 03:18:00 +00003261 {
Jamie Madill0063c512014-08-25 15:47:53 -04003262 return;
daniel@transgaming.com9a849122011-11-12 03:18:00 +00003263 }
3264
Jamie Madilla502c742014-08-28 17:19:13 -04003265 gl::Program *programObject = context->getProgram(program);
3266 ASSERT(programObject);
3267 gl::ProgramBinary *programBinary = programObject->getProgramBinary();
Jamie Madill0063c512014-08-25 15:47:53 -04003268 ASSERT(programBinary);
Geoff Langbfdea662014-07-23 14:16:32 -04003269
Jamie Madill99a1e982014-08-25 15:47:54 -04003270 programBinary->getUniformfv(location, params);
daniel@transgaming.com9a849122011-11-12 03:18:00 +00003271 }
3272}
3273
Kenneth Russell67ea1902014-10-06 16:44:50 -07003274void GL_APIENTRY glGetUniformfv(GLuint program, GLint location, GLfloat* params)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003275{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00003276 EVENT("(GLuint program = %d, GLint location = %d, GLfloat* params = 0x%0.8p)", program, location, params);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003277
Geoff Langbfdea662014-07-23 14:16:32 -04003278 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04003279 if (context)
3280 {
Jamie Madill0063c512014-08-25 15:47:53 -04003281 if (!ValidateGetUniformfv(context, program, location, params))
daniel@transgaming.combb3d9d02010-04-13 03:26:06 +00003282 {
Jamie Madill0063c512014-08-25 15:47:53 -04003283 return;
daniel@transgaming.com9a849122011-11-12 03:18:00 +00003284 }
Geoff Langbfdea662014-07-23 14:16:32 -04003285
Jamie Madilla502c742014-08-28 17:19:13 -04003286 gl::Program *programObject = context->getProgram(program);
3287 ASSERT(programObject);
3288 gl::ProgramBinary *programBinary = programObject->getProgramBinary();
Jamie Madill0063c512014-08-25 15:47:53 -04003289 ASSERT(programBinary);
Geoff Langbfdea662014-07-23 14:16:32 -04003290
Jamie Madill99a1e982014-08-25 15:47:54 -04003291 programBinary->getUniformfv(location, params);
daniel@transgaming.com9a849122011-11-12 03:18:00 +00003292 }
3293}
3294
Kenneth Russell67ea1902014-10-06 16:44:50 -07003295void GL_APIENTRY glGetnUniformivEXT(GLuint program, GLint location, GLsizei bufSize, GLint* params)
daniel@transgaming.com9a849122011-11-12 03:18:00 +00003296{
Geoff Langbfdea662014-07-23 14:16:32 -04003297 EVENT("(GLuint program = %d, GLint location = %d, GLsizei bufSize = %d, GLint* params = 0x%0.8p)",
daniel@transgaming.com9a849122011-11-12 03:18:00 +00003298 program, location, bufSize, params);
3299
Geoff Langbfdea662014-07-23 14:16:32 -04003300 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04003301 if (context)
3302 {
Jamie Madill0063c512014-08-25 15:47:53 -04003303 if (!ValidateGetnUniformivEXT(context, program, location, bufSize, params))
daniel@transgaming.com9a849122011-11-12 03:18:00 +00003304 {
Jamie Madill0063c512014-08-25 15:47:53 -04003305 return;
daniel@transgaming.com9a849122011-11-12 03:18:00 +00003306 }
3307
Jamie Madilla502c742014-08-28 17:19:13 -04003308 gl::Program *programObject = context->getProgram(program);
3309 ASSERT(programObject);
3310 gl::ProgramBinary *programBinary = programObject->getProgramBinary();
Jamie Madill0063c512014-08-25 15:47:53 -04003311 ASSERT(programBinary);
Geoff Langbfdea662014-07-23 14:16:32 -04003312
Jamie Madill99a1e982014-08-25 15:47:54 -04003313 programBinary->getUniformiv(location, params);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003314 }
3315}
3316
Kenneth Russell67ea1902014-10-06 16:44:50 -07003317void GL_APIENTRY glGetUniformiv(GLuint program, GLint location, GLint* params)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003318{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00003319 EVENT("(GLuint program = %d, GLint location = %d, GLint* params = 0x%0.8p)", program, location, params);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003320
Geoff Langbfdea662014-07-23 14:16:32 -04003321 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04003322 if (context)
3323 {
Jamie Madill0063c512014-08-25 15:47:53 -04003324 if (!ValidateGetUniformiv(context, program, location, params))
daniel@transgaming.combb3d9d02010-04-13 03:26:06 +00003325 {
Jamie Madill0063c512014-08-25 15:47:53 -04003326 return;
daniel@transgaming.combb3d9d02010-04-13 03:26:06 +00003327 }
Geoff Langbfdea662014-07-23 14:16:32 -04003328
Jamie Madilla502c742014-08-28 17:19:13 -04003329 gl::Program *programObject = context->getProgram(program);
3330 ASSERT(programObject);
3331 gl::ProgramBinary *programBinary = programObject->getProgramBinary();
Jamie Madill0063c512014-08-25 15:47:53 -04003332 ASSERT(programBinary);
Geoff Langbfdea662014-07-23 14:16:32 -04003333
Jamie Madill99a1e982014-08-25 15:47:54 -04003334 programBinary->getUniformiv(location, params);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003335 }
3336}
3337
Kenneth Russell67ea1902014-10-06 16:44:50 -07003338GLint GL_APIENTRY glGetUniformLocation(GLuint program, const GLchar* name)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003339{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00003340 EVENT("(GLuint program = %d, const GLchar* name = 0x%0.8p)", program, name);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003341
Geoff Langbfdea662014-07-23 14:16:32 -04003342 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04003343 if (context)
3344 {
Geoff Langb1196682014-07-23 13:47:29 -04003345 if (strstr(name, "gl_") == name)
3346 {
3347 return -1;
3348 }
3349
Geoff Langbfdea662014-07-23 14:16:32 -04003350 gl::Program *programObject = context->getProgram(program);
3351
3352 if (!programObject)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003353 {
Geoff Langbfdea662014-07-23 14:16:32 -04003354 if (context->getShader(program))
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003355 {
Geoff Langb1196682014-07-23 13:47:29 -04003356 context->recordError(gl::Error(GL_INVALID_OPERATION));
3357 return -1;
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003358 }
Geoff Langbfdea662014-07-23 14:16:32 -04003359 else
3360 {
Geoff Langb1196682014-07-23 13:47:29 -04003361 context->recordError(gl::Error(GL_INVALID_VALUE));
3362 return -1;
Geoff Langbfdea662014-07-23 14:16:32 -04003363 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003364 }
Geoff Langbfdea662014-07-23 14:16:32 -04003365
3366 gl::ProgramBinary *programBinary = programObject->getProgramBinary();
3367 if (!programObject->isLinked() || !programBinary)
3368 {
Geoff Langb1196682014-07-23 13:47:29 -04003369 context->recordError(gl::Error(GL_INVALID_OPERATION));
3370 return -1;
Geoff Langbfdea662014-07-23 14:16:32 -04003371 }
3372
3373 return programBinary->getUniformLocation(name);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003374 }
3375
3376 return -1;
3377}
3378
Kenneth Russell67ea1902014-10-06 16:44:50 -07003379void GL_APIENTRY glGetVertexAttribfv(GLuint index, GLenum pname, GLfloat* params)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003380{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00003381 EVENT("(GLuint index = %d, GLenum pname = 0x%X, GLfloat* params = 0x%0.8p)", index, pname, params);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003382
Geoff Langbfdea662014-07-23 14:16:32 -04003383 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04003384 if (context)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003385 {
Geoff Langbfdea662014-07-23 14:16:32 -04003386 if (index >= gl::MAX_VERTEX_ATTRIBS)
daniel@transgaming.come0078962010-04-15 20:45:08 +00003387 {
Geoff Langb1196682014-07-23 13:47:29 -04003388 context->recordError(gl::Error(GL_INVALID_VALUE));
3389 return;
Geoff Langbfdea662014-07-23 14:16:32 -04003390 }
daniel@transgaming.come0078962010-04-15 20:45:08 +00003391
Geoff Langbfdea662014-07-23 14:16:32 -04003392 const gl::VertexAttribute &attribState = context->getState().getVertexAttribState(index);
Geoff Langb1196682014-07-23 13:47:29 -04003393 if (!gl::ValidateGetVertexAttribParameters(context, pname))
Geoff Langbfdea662014-07-23 14:16:32 -04003394 {
3395 return;
3396 }
daniel@transgaming.com428d1582010-05-04 03:35:25 +00003397
Geoff Langbfdea662014-07-23 14:16:32 -04003398 if (pname == GL_CURRENT_VERTEX_ATTRIB)
3399 {
3400 const gl::VertexAttribCurrentValueData &currentValueData = context->getState().getVertexAttribCurrentValue(index);
3401 for (int i = 0; i < 4; ++i)
daniel@transgaming.come0078962010-04-15 20:45:08 +00003402 {
Geoff Langbfdea662014-07-23 14:16:32 -04003403 params[i] = currentValueData.FloatValues[i];
daniel@transgaming.come0078962010-04-15 20:45:08 +00003404 }
3405 }
Geoff Langbfdea662014-07-23 14:16:32 -04003406 else
3407 {
3408 *params = gl::QuerySingleVertexAttributeParameter<GLfloat>(attribState, pname);
3409 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003410 }
3411}
3412
Kenneth Russell67ea1902014-10-06 16:44:50 -07003413void GL_APIENTRY glGetVertexAttribiv(GLuint index, GLenum pname, GLint* params)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003414{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00003415 EVENT("(GLuint index = %d, GLenum pname = 0x%X, GLint* params = 0x%0.8p)", index, pname, params);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003416
Geoff Langbfdea662014-07-23 14:16:32 -04003417 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04003418 if (context)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003419 {
Geoff Langbfdea662014-07-23 14:16:32 -04003420 if (index >= gl::MAX_VERTEX_ATTRIBS)
daniel@transgaming.come0078962010-04-15 20:45:08 +00003421 {
Geoff Langb1196682014-07-23 13:47:29 -04003422 context->recordError(gl::Error(GL_INVALID_VALUE));
3423 return;
Geoff Langbfdea662014-07-23 14:16:32 -04003424 }
daniel@transgaming.come0078962010-04-15 20:45:08 +00003425
Geoff Langbfdea662014-07-23 14:16:32 -04003426 const gl::VertexAttribute &attribState = context->getState().getVertexAttribState(index);
daniel@transgaming.com428d1582010-05-04 03:35:25 +00003427
Geoff Langb1196682014-07-23 13:47:29 -04003428 if (!gl::ValidateGetVertexAttribParameters(context, pname))
Geoff Langbfdea662014-07-23 14:16:32 -04003429 {
3430 return;
3431 }
Jamie Madillaff71502013-07-02 11:57:05 -04003432
Geoff Langbfdea662014-07-23 14:16:32 -04003433 if (pname == GL_CURRENT_VERTEX_ATTRIB)
3434 {
3435 const gl::VertexAttribCurrentValueData &currentValueData = context->getState().getVertexAttribCurrentValue(index);
3436 for (int i = 0; i < 4; ++i)
Jamie Madillaff71502013-07-02 11:57:05 -04003437 {
Geoff Langbfdea662014-07-23 14:16:32 -04003438 float currentValue = currentValueData.FloatValues[i];
3439 params[i] = gl::iround<GLint>(currentValue);
daniel@transgaming.come0078962010-04-15 20:45:08 +00003440 }
3441 }
Geoff Langbfdea662014-07-23 14:16:32 -04003442 else
3443 {
3444 *params = gl::QuerySingleVertexAttributeParameter<GLint>(attribState, pname);
3445 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003446 }
3447}
3448
Kenneth Russell67ea1902014-10-06 16:44:50 -07003449void GL_APIENTRY glGetVertexAttribPointerv(GLuint index, GLenum pname, GLvoid** pointer)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003450{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00003451 EVENT("(GLuint index = %d, GLenum pname = 0x%X, GLvoid** pointer = 0x%0.8p)", index, pname, pointer);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003452
Geoff Langbfdea662014-07-23 14:16:32 -04003453 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04003454 if (context)
3455 {
3456 if (index >= gl::MAX_VERTEX_ATTRIBS)
daniel@transgaming.come0078962010-04-15 20:45:08 +00003457 {
Geoff Langb1196682014-07-23 13:47:29 -04003458 context->recordError(gl::Error(GL_INVALID_VALUE));
3459 return;
daniel@transgaming.come0078962010-04-15 20:45:08 +00003460 }
Geoff Langbfdea662014-07-23 14:16:32 -04003461
3462 if (pname != GL_VERTEX_ATTRIB_ARRAY_POINTER)
3463 {
Geoff Langb1196682014-07-23 13:47:29 -04003464 context->recordError(gl::Error(GL_INVALID_ENUM));
3465 return;
Geoff Langbfdea662014-07-23 14:16:32 -04003466 }
3467
3468 *pointer = const_cast<GLvoid*>(context->getState().getVertexAttribPointer(index));
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003469 }
3470}
3471
Kenneth Russell67ea1902014-10-06 16:44:50 -07003472void GL_APIENTRY glHint(GLenum target, GLenum mode)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003473{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00003474 EVENT("(GLenum target = 0x%X, GLenum mode = 0x%X)", target, mode);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003475
Geoff Langbfdea662014-07-23 14:16:32 -04003476 gl::Context *context = gl::getNonLostContext();
Geoff Langb1196682014-07-23 13:47:29 -04003477 if (context)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003478 {
Geoff Langb1196682014-07-23 13:47:29 -04003479 switch (mode)
3480 {
3481 case GL_FASTEST:
3482 case GL_NICEST:
3483 case GL_DONT_CARE:
3484 break;
3485
3486 default:
3487 context->recordError(gl::Error(GL_INVALID_ENUM));
3488 return;
3489 }
3490
3491 switch (target)
3492 {
3493 case GL_GENERATE_MIPMAP_HINT:
3494 context->getState().setGenerateMipmapHint(mode);
3495 break;
3496
3497 case GL_FRAGMENT_SHADER_DERIVATIVE_HINT_OES:
3498 context->getState().setFragmentShaderDerivativeHint(mode);
3499 break;
3500
3501 default:
3502 context->recordError(gl::Error(GL_INVALID_ENUM));
3503 return;
3504 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003505 }
3506}
3507
Kenneth Russell67ea1902014-10-06 16:44:50 -07003508GLboolean GL_APIENTRY glIsBuffer(GLuint buffer)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003509{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00003510 EVENT("(GLuint buffer = %d)", buffer);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003511
Geoff Langbfdea662014-07-23 14:16:32 -04003512 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04003513 if (context && buffer)
3514 {
3515 gl::Buffer *bufferObject = context->getBuffer(buffer);
3516
3517 if (bufferObject)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003518 {
Geoff Langbfdea662014-07-23 14:16:32 -04003519 return GL_TRUE;
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003520 }
3521 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003522
3523 return GL_FALSE;
3524}
3525
Kenneth Russell67ea1902014-10-06 16:44:50 -07003526GLboolean GL_APIENTRY glIsEnabled(GLenum cap)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003527{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00003528 EVENT("(GLenum cap = 0x%X)", cap);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003529
Geoff Langbfdea662014-07-23 14:16:32 -04003530 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04003531 if (context)
3532 {
3533 if (!ValidCap(context, cap))
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003534 {
Geoff Langb1196682014-07-23 13:47:29 -04003535 context->recordError(gl::Error(GL_INVALID_ENUM));
3536 return GL_FALSE;
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003537 }
Geoff Langbfdea662014-07-23 14:16:32 -04003538
3539 return context->getState().getEnableFeature(cap);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003540 }
3541
3542 return false;
3543}
3544
Kenneth Russell67ea1902014-10-06 16:44:50 -07003545GLboolean GL_APIENTRY glIsFenceNV(GLuint fence)
daniel@transgaming.comfe208882010-09-01 15:47:57 +00003546{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00003547 EVENT("(GLuint fence = %d)", fence);
apatrick@chromium.orgd3bd0ad2010-08-30 18:55:36 +00003548
Geoff Langbfdea662014-07-23 14:16:32 -04003549 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04003550 if (context)
3551 {
3552 gl::FenceNV *fenceObject = context->getFenceNV(fence);
3553
3554 if (fenceObject == NULL)
apatrick@chromium.orgd3bd0ad2010-08-30 18:55:36 +00003555 {
Geoff Langbfdea662014-07-23 14:16:32 -04003556 return GL_FALSE;
apatrick@chromium.orgd3bd0ad2010-08-30 18:55:36 +00003557 }
Geoff Langbfdea662014-07-23 14:16:32 -04003558
3559 return fenceObject->isFence();
apatrick@chromium.orgd3bd0ad2010-08-30 18:55:36 +00003560 }
3561
3562 return GL_FALSE;
daniel@transgaming.comfe208882010-09-01 15:47:57 +00003563}
apatrick@chromium.orgd3bd0ad2010-08-30 18:55:36 +00003564
Kenneth Russell67ea1902014-10-06 16:44:50 -07003565GLboolean GL_APIENTRY glIsFramebuffer(GLuint framebuffer)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003566{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00003567 EVENT("(GLuint framebuffer = %d)", framebuffer);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003568
Geoff Langbfdea662014-07-23 14:16:32 -04003569 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04003570 if (context && framebuffer)
3571 {
3572 gl::Framebuffer *framebufferObject = context->getFramebuffer(framebuffer);
3573
3574 if (framebufferObject)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003575 {
Geoff Langbfdea662014-07-23 14:16:32 -04003576 return GL_TRUE;
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003577 }
3578 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003579
3580 return GL_FALSE;
3581}
3582
Kenneth Russell67ea1902014-10-06 16:44:50 -07003583GLboolean GL_APIENTRY glIsProgram(GLuint program)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003584{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00003585 EVENT("(GLuint program = %d)", program);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003586
Geoff Langbfdea662014-07-23 14:16:32 -04003587 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04003588 if (context && program)
3589 {
3590 gl::Program *programObject = context->getProgram(program);
3591
3592 if (programObject)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003593 {
Geoff Langbfdea662014-07-23 14:16:32 -04003594 return GL_TRUE;
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003595 }
3596 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003597
3598 return GL_FALSE;
3599}
3600
Kenneth Russell67ea1902014-10-06 16:44:50 -07003601GLboolean GL_APIENTRY glIsQueryEXT(GLuint id)
daniel@transgaming.com86bdb822012-01-20 18:24:39 +00003602{
3603 EVENT("(GLuint id = %d)", id);
3604
Geoff Langbfdea662014-07-23 14:16:32 -04003605 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04003606 if (context)
daniel@transgaming.com86bdb822012-01-20 18:24:39 +00003607 {
Geoff Langbfdea662014-07-23 14:16:32 -04003608 return (context->getQuery(id, false, GL_NONE) != NULL) ? GL_TRUE : GL_FALSE;
daniel@transgaming.com86bdb822012-01-20 18:24:39 +00003609 }
3610
3611 return GL_FALSE;
3612}
3613
Kenneth Russell67ea1902014-10-06 16:44:50 -07003614GLboolean GL_APIENTRY glIsRenderbuffer(GLuint renderbuffer)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003615{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00003616 EVENT("(GLuint renderbuffer = %d)", renderbuffer);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003617
Geoff Langbfdea662014-07-23 14:16:32 -04003618 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04003619 if (context && renderbuffer)
3620 {
3621 gl::Renderbuffer *renderbufferObject = context->getRenderbuffer(renderbuffer);
3622
3623 if (renderbufferObject)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003624 {
Geoff Langbfdea662014-07-23 14:16:32 -04003625 return GL_TRUE;
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003626 }
3627 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003628
3629 return GL_FALSE;
3630}
3631
Kenneth Russell67ea1902014-10-06 16:44:50 -07003632GLboolean GL_APIENTRY glIsShader(GLuint shader)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003633{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00003634 EVENT("(GLuint shader = %d)", shader);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003635
Geoff Langbfdea662014-07-23 14:16:32 -04003636 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04003637 if (context && shader)
3638 {
3639 gl::Shader *shaderObject = context->getShader(shader);
3640
3641 if (shaderObject)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003642 {
Geoff Langbfdea662014-07-23 14:16:32 -04003643 return GL_TRUE;
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003644 }
3645 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003646
3647 return GL_FALSE;
3648}
3649
Kenneth Russell67ea1902014-10-06 16:44:50 -07003650GLboolean GL_APIENTRY glIsTexture(GLuint texture)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003651{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00003652 EVENT("(GLuint texture = %d)", texture);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003653
Geoff Langbfdea662014-07-23 14:16:32 -04003654 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04003655 if (context && texture)
3656 {
3657 gl::Texture *textureObject = context->getTexture(texture);
3658
3659 if (textureObject)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003660 {
Geoff Langbfdea662014-07-23 14:16:32 -04003661 return GL_TRUE;
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003662 }
3663 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003664
3665 return GL_FALSE;
3666}
3667
Kenneth Russell67ea1902014-10-06 16:44:50 -07003668void GL_APIENTRY glLineWidth(GLfloat width)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003669{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00003670 EVENT("(GLfloat width = %f)", width);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003671
Geoff Langbfdea662014-07-23 14:16:32 -04003672 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04003673 if (context)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003674 {
Geoff Langb1196682014-07-23 13:47:29 -04003675 if (width <= 0.0f)
3676 {
3677 context->recordError(gl::Error(GL_INVALID_VALUE));
3678 return;
3679 }
3680
Geoff Langbfdea662014-07-23 14:16:32 -04003681 context->getState().setLineWidth(width);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003682 }
3683}
3684
Kenneth Russell67ea1902014-10-06 16:44:50 -07003685void GL_APIENTRY glLinkProgram(GLuint program)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003686{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00003687 EVENT("(GLuint program = %d)", program);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003688
Geoff Langbfdea662014-07-23 14:16:32 -04003689 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04003690 if (context)
3691 {
3692 gl::Program *programObject = context->getProgram(program);
3693
3694 if (!programObject)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003695 {
Geoff Langbfdea662014-07-23 14:16:32 -04003696 if (context->getShader(program))
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003697 {
Geoff Langb1196682014-07-23 13:47:29 -04003698 context->recordError(gl::Error(GL_INVALID_OPERATION));
3699 return;
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003700 }
Geoff Langbfdea662014-07-23 14:16:32 -04003701 else
3702 {
Geoff Langb1196682014-07-23 13:47:29 -04003703 context->recordError(gl::Error(GL_INVALID_VALUE));
3704 return;
Geoff Langbfdea662014-07-23 14:16:32 -04003705 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003706 }
Geoff Langbfdea662014-07-23 14:16:32 -04003707
Geoff Langb543aff2014-09-30 14:52:54 -04003708 gl::Error error = context->linkProgram(program);
3709 if (error.isError())
3710 {
3711 context->recordError(error);
3712 return;
3713 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003714 }
3715}
3716
Kenneth Russell67ea1902014-10-06 16:44:50 -07003717void GL_APIENTRY glPixelStorei(GLenum pname, GLint param)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003718{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00003719 EVENT("(GLenum pname = 0x%X, GLint param = %d)", pname, param);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003720
Geoff Langbfdea662014-07-23 14:16:32 -04003721 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04003722 if (context)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003723 {
Geoff Langbfdea662014-07-23 14:16:32 -04003724 switch (pname)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003725 {
Geoff Langbfdea662014-07-23 14:16:32 -04003726 case GL_UNPACK_ALIGNMENT:
3727 if (param != 1 && param != 2 && param != 4 && param != 8)
daniel@transgaming.com3489e3a2010-03-21 04:31:11 +00003728 {
Geoff Langb1196682014-07-23 13:47:29 -04003729 context->recordError(gl::Error(GL_INVALID_VALUE));
3730 return;
Geoff Langbfdea662014-07-23 14:16:32 -04003731 }
daniel@transgaming.com3489e3a2010-03-21 04:31:11 +00003732
Geoff Langbfdea662014-07-23 14:16:32 -04003733 context->getState().setUnpackAlignment(param);
3734 break;
daniel@transgaming.com3489e3a2010-03-21 04:31:11 +00003735
Geoff Langbfdea662014-07-23 14:16:32 -04003736 case GL_PACK_ALIGNMENT:
3737 if (param != 1 && param != 2 && param != 4 && param != 8)
3738 {
Geoff Langb1196682014-07-23 13:47:29 -04003739 context->recordError(gl::Error(GL_INVALID_VALUE));
3740 return;
Geoff Langbfdea662014-07-23 14:16:32 -04003741 }
daniel@transgaming.com3489e3a2010-03-21 04:31:11 +00003742
Geoff Langbfdea662014-07-23 14:16:32 -04003743 context->getState().setPackAlignment(param);
3744 break;
daniel@transgaming.com3489e3a2010-03-21 04:31:11 +00003745
Geoff Langbfdea662014-07-23 14:16:32 -04003746 case GL_PACK_REVERSE_ROW_ORDER_ANGLE:
3747 context->getState().setPackReverseRowOrder(param != 0);
3748 break;
bsalomon@google.com56d46ab2011-11-23 14:53:10 +00003749
Geoff Langbfdea662014-07-23 14:16:32 -04003750 case GL_UNPACK_IMAGE_HEIGHT:
3751 case GL_UNPACK_SKIP_IMAGES:
3752 case GL_UNPACK_ROW_LENGTH:
3753 case GL_UNPACK_SKIP_ROWS:
3754 case GL_UNPACK_SKIP_PIXELS:
3755 case GL_PACK_ROW_LENGTH:
3756 case GL_PACK_SKIP_ROWS:
3757 case GL_PACK_SKIP_PIXELS:
3758 if (context->getClientVersion() < 3)
3759 {
Geoff Langb1196682014-07-23 13:47:29 -04003760 context->recordError(gl::Error(GL_INVALID_ENUM));
3761 return;
daniel@transgaming.com3489e3a2010-03-21 04:31:11 +00003762 }
Geoff Langbfdea662014-07-23 14:16:32 -04003763 UNIMPLEMENTED();
3764 break;
3765
3766 default:
Geoff Langb1196682014-07-23 13:47:29 -04003767 context->recordError(gl::Error(GL_INVALID_ENUM));
3768 return;
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003769 }
3770 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003771}
3772
Kenneth Russell67ea1902014-10-06 16:44:50 -07003773void GL_APIENTRY glPolygonOffset(GLfloat factor, GLfloat units)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003774{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00003775 EVENT("(GLfloat factor = %f, GLfloat units = %f)", factor, units);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003776
Geoff Langbfdea662014-07-23 14:16:32 -04003777 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04003778 if (context)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003779 {
Geoff Langbfdea662014-07-23 14:16:32 -04003780 context->getState().setPolygonOffsetParams(factor, units);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003781 }
3782}
3783
Kenneth Russell67ea1902014-10-06 16:44:50 -07003784void GL_APIENTRY glReadnPixelsEXT(GLint x, GLint y, GLsizei width, GLsizei height,
daniel@transgaming.comb7915a52011-11-12 03:14:20 +00003785 GLenum format, GLenum type, GLsizei bufSize,
3786 GLvoid *data)
3787{
3788 EVENT("(GLint x = %d, GLint y = %d, GLsizei width = %d, GLsizei height = %d, "
3789 "GLenum format = 0x%X, GLenum type = 0x%X, GLsizei bufSize = 0x%d, GLvoid *data = 0x%0.8p)",
3790 x, y, width, height, format, type, bufSize, data);
3791
Geoff Langbfdea662014-07-23 14:16:32 -04003792 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04003793 if (context)
daniel@transgaming.comb7915a52011-11-12 03:14:20 +00003794 {
Geoff Langb1196682014-07-23 13:47:29 -04003795 if (width < 0 || height < 0 || bufSize < 0)
3796 {
3797 context->recordError(gl::Error(GL_INVALID_VALUE));
3798 return;
3799 }
3800
Geoff Langbfdea662014-07-23 14:16:32 -04003801 if (!gl::ValidateReadPixelsParameters(context, x, y, width, height,
3802 format, type, &bufSize, data))
3803 {
3804 return;
3805 }
3806
Geoff Lang63d2fc72014-07-25 14:51:41 -04003807 gl::Error error = context->readPixels(x, y, width, height, format, type, &bufSize, data);
3808 if (error.isError())
3809 {
3810 context->recordError(error);
3811 return;
3812 }
daniel@transgaming.comb7915a52011-11-12 03:14:20 +00003813 }
3814}
3815
Kenneth Russell67ea1902014-10-06 16:44:50 -07003816void GL_APIENTRY glReadPixels(GLint x, GLint y, GLsizei width, GLsizei height,
daniel@transgaming.comb7915a52011-11-12 03:14:20 +00003817 GLenum format, GLenum type, GLvoid* pixels)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003818{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00003819 EVENT("(GLint x = %d, GLint y = %d, GLsizei width = %d, GLsizei height = %d, "
daniel@transgaming.comfe4b8272010-04-08 03:51:20 +00003820 "GLenum format = 0x%X, GLenum type = 0x%X, GLvoid* pixels = 0x%0.8p)",
daniel@transgaming.comb5b06162010-03-21 04:31:32 +00003821 x, y, width, height, format, type, pixels);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003822
Geoff Langbfdea662014-07-23 14:16:32 -04003823 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04003824 if (context)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003825 {
Geoff Langb1196682014-07-23 13:47:29 -04003826 if (width < 0 || height < 0)
3827 {
3828 context->recordError(gl::Error(GL_INVALID_VALUE));
3829 return;
3830 }
3831
Geoff Langbfdea662014-07-23 14:16:32 -04003832 if (!gl::ValidateReadPixelsParameters(context, x, y, width, height,
3833 format, type, NULL, pixels))
3834 {
3835 return;
3836 }
3837
Geoff Lang63d2fc72014-07-25 14:51:41 -04003838 gl::Error error = context->readPixels(x, y, width, height, format, type, NULL, pixels);
3839 if (error.isError())
3840 {
3841 context->recordError(error);
3842 return;
3843 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003844 }
3845}
3846
Kenneth Russell67ea1902014-10-06 16:44:50 -07003847void GL_APIENTRY glReleaseShaderCompiler(void)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003848{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00003849 EVENT("()");
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003850
Brandon Jonesf05cdee2014-08-27 15:24:07 -07003851 gl::Context *context = gl::getNonLostContext();
3852
3853 if (context)
3854 {
3855 context->releaseShaderCompiler();
3856 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003857}
3858
Kenneth Russell67ea1902014-10-06 16:44:50 -07003859void GL_APIENTRY glRenderbufferStorageMultisampleANGLE(GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003860{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00003861 EVENT("(GLenum target = 0x%X, GLsizei samples = %d, GLenum internalformat = 0x%X, GLsizei width = %d, GLsizei height = %d)",
daniel@transgaming.com1f135d82010-08-24 19:20:36 +00003862 target, samples, internalformat, width, height);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003863
Geoff Langbfdea662014-07-23 14:16:32 -04003864 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04003865 if (context)
3866 {
3867 if (!ValidateRenderbufferStorageParameters(context, target, samples, internalformat,
3868 width, height, true))
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003869 {
Geoff Langbfdea662014-07-23 14:16:32 -04003870 return;
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003871 }
Geoff Langbfdea662014-07-23 14:16:32 -04003872
3873 context->setRenderbufferStorage(width, height, internalformat, samples);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003874 }
3875}
3876
Kenneth Russell67ea1902014-10-06 16:44:50 -07003877void GL_APIENTRY glRenderbufferStorage(GLenum target, GLenum internalformat, GLsizei width, GLsizei height)
daniel@transgaming.com1f135d82010-08-24 19:20:36 +00003878{
3879 glRenderbufferStorageMultisampleANGLE(target, 0, internalformat, width, height);
3880}
3881
Kenneth Russell67ea1902014-10-06 16:44:50 -07003882void GL_APIENTRY glSampleCoverage(GLclampf value, GLboolean invert)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003883{
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00003884 EVENT("(GLclampf value = %f, GLboolean invert = %u)", value, invert);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003885
Geoff Langbfdea662014-07-23 14:16:32 -04003886 gl::Context* context = gl::getNonLostContext();
daniel@transgaming.comfab5a1a2010-03-11 19:22:30 +00003887
Geoff Langbfdea662014-07-23 14:16:32 -04003888 if (context)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003889 {
Geoff Langbfdea662014-07-23 14:16:32 -04003890 context->getState().setSampleCoverageParams(gl::clamp01(value), invert == GL_TRUE);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003891 }
3892}
3893
Kenneth Russell67ea1902014-10-06 16:44:50 -07003894void GL_APIENTRY glSetFenceNV(GLuint fence, GLenum condition)
daniel@transgaming.comfe208882010-09-01 15:47:57 +00003895{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00003896 EVENT("(GLuint fence = %d, GLenum condition = 0x%X)", fence, condition);
apatrick@chromium.orgd3bd0ad2010-08-30 18:55:36 +00003897
Geoff Langbfdea662014-07-23 14:16:32 -04003898 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04003899 if (context)
apatrick@chromium.orgd3bd0ad2010-08-30 18:55:36 +00003900 {
Geoff Langb1196682014-07-23 13:47:29 -04003901 if (condition != GL_ALL_COMPLETED_NV)
3902 {
3903 context->recordError(gl::Error(GL_INVALID_ENUM));
3904 return;
3905 }
3906
Geoff Langbfdea662014-07-23 14:16:32 -04003907 gl::FenceNV *fenceObject = context->getFenceNV(fence);
3908
3909 if (fenceObject == NULL)
3910 {
Geoff Langb1196682014-07-23 13:47:29 -04003911 context->recordError(gl::Error(GL_INVALID_OPERATION));
3912 return;
Geoff Langbfdea662014-07-23 14:16:32 -04003913 }
3914
Geoff Lang882033e2014-09-30 11:26:07 -04003915 gl::Error error = fenceObject->setFence(condition);
3916 if (error.isError())
3917 {
3918 context->recordError(error);
3919 return;
3920 }
apatrick@chromium.orgd3bd0ad2010-08-30 18:55:36 +00003921 }
daniel@transgaming.comfe208882010-09-01 15:47:57 +00003922}
apatrick@chromium.orgd3bd0ad2010-08-30 18:55:36 +00003923
Kenneth Russell67ea1902014-10-06 16:44:50 -07003924void GL_APIENTRY glScissor(GLint x, GLint y, GLsizei width, GLsizei height)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003925{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00003926 EVENT("(GLint x = %d, GLint y = %d, GLsizei width = %d, GLsizei height = %d)", x, y, width, height);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003927
Geoff Langbfdea662014-07-23 14:16:32 -04003928 gl::Context* context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04003929 if (context)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003930 {
Geoff Langb1196682014-07-23 13:47:29 -04003931 if (width < 0 || height < 0)
3932 {
3933 context->recordError(gl::Error(GL_INVALID_VALUE));
3934 return;
3935 }
3936
Geoff Langbfdea662014-07-23 14:16:32 -04003937 context->getState().setScissorParams(x, y, width, height);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003938 }
3939}
3940
Kenneth Russell67ea1902014-10-06 16:44:50 -07003941void GL_APIENTRY glShaderBinary(GLsizei n, const GLuint* shaders, GLenum binaryformat, const GLvoid* binary, GLsizei length)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003942{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00003943 EVENT("(GLsizei n = %d, const GLuint* shaders = 0x%0.8p, GLenum binaryformat = 0x%X, "
daniel@transgaming.comfe4b8272010-04-08 03:51:20 +00003944 "const GLvoid* binary = 0x%0.8p, GLsizei length = %d)",
daniel@transgaming.comb5b06162010-03-21 04:31:32 +00003945 n, shaders, binaryformat, binary, length);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003946
Geoff Lang900013c2014-07-07 11:32:19 -04003947 gl::Context* context = gl::getNonLostContext();
3948 if (context)
3949 {
3950 const std::vector<GLenum> &shaderBinaryFormats = context->getCaps().shaderBinaryFormats;
3951 if (std::find(shaderBinaryFormats.begin(), shaderBinaryFormats.end(), binaryformat) == shaderBinaryFormats.end())
3952 {
Geoff Langb1196682014-07-23 13:47:29 -04003953 context->recordError(gl::Error(GL_INVALID_ENUM));
3954 return;
Geoff Lang900013c2014-07-07 11:32:19 -04003955 }
3956
3957 // No binary shader formats are supported.
3958 UNIMPLEMENTED();
3959 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003960}
3961
Kenneth Russell67ea1902014-10-06 16:44:50 -07003962void GL_APIENTRY glShaderSource(GLuint shader, GLsizei count, const GLchar* const* string, const GLint* length)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003963{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00003964 EVENT("(GLuint shader = %d, GLsizei count = %d, const GLchar** string = 0x%0.8p, const GLint* length = 0x%0.8p)",
daniel@transgaming.comb5b06162010-03-21 04:31:32 +00003965 shader, count, string, length);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003966
Geoff Langbfdea662014-07-23 14:16:32 -04003967 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04003968 if (context)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003969 {
Geoff Langb1196682014-07-23 13:47:29 -04003970 if (count < 0)
3971 {
3972 context->recordError(gl::Error(GL_INVALID_VALUE));
3973 return;
3974 }
3975
Geoff Langbfdea662014-07-23 14:16:32 -04003976 gl::Shader *shaderObject = context->getShader(shader);
3977
3978 if (!shaderObject)
3979 {
3980 if (context->getProgram(shader))
3981 {
Geoff Langb1196682014-07-23 13:47:29 -04003982 context->recordError(gl::Error(GL_INVALID_OPERATION));
3983 return;
Geoff Langbfdea662014-07-23 14:16:32 -04003984 }
3985 else
3986 {
Geoff Langb1196682014-07-23 13:47:29 -04003987 context->recordError(gl::Error(GL_INVALID_VALUE));
3988 return;
Geoff Langbfdea662014-07-23 14:16:32 -04003989 }
3990 }
3991
3992 shaderObject->setSource(count, string, length);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003993 }
3994}
3995
Kenneth Russell67ea1902014-10-06 16:44:50 -07003996void GL_APIENTRY glStencilFunc(GLenum func, GLint ref, GLuint mask)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003997{
daniel@transgaming.comfab5a1a2010-03-11 19:22:30 +00003998 glStencilFuncSeparate(GL_FRONT_AND_BACK, func, ref, mask);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003999}
4000
Kenneth Russell67ea1902014-10-06 16:44:50 -07004001void GL_APIENTRY glStencilFuncSeparate(GLenum face, GLenum func, GLint ref, GLuint mask)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004002{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00004003 EVENT("(GLenum face = 0x%X, GLenum func = 0x%X, GLint ref = %d, GLuint mask = %d)", face, func, ref, mask);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004004
Geoff Langbfdea662014-07-23 14:16:32 -04004005 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04004006 if (context)
4007 {
Geoff Langb1196682014-07-23 13:47:29 -04004008 switch (face)
4009 {
4010 case GL_FRONT:
4011 case GL_BACK:
4012 case GL_FRONT_AND_BACK:
4013 break;
4014
4015 default:
4016 context->recordError(gl::Error(GL_INVALID_ENUM));
4017 return;
4018 }
4019
4020 switch (func)
4021 {
4022 case GL_NEVER:
4023 case GL_ALWAYS:
4024 case GL_LESS:
4025 case GL_LEQUAL:
4026 case GL_EQUAL:
4027 case GL_GEQUAL:
4028 case GL_GREATER:
4029 case GL_NOTEQUAL:
4030 break;
4031
4032 default:
4033 context->recordError(gl::Error(GL_INVALID_ENUM));
4034 return;
4035 }
4036
Geoff Langbfdea662014-07-23 14:16:32 -04004037 if (face == GL_FRONT || face == GL_FRONT_AND_BACK)
4038 {
4039 context->getState().setStencilParams(func, ref, mask);
4040 }
4041
4042 if (face == GL_BACK || face == GL_FRONT_AND_BACK)
4043 {
4044 context->getState().setStencilBackParams(func, ref, mask);
4045 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004046 }
4047}
4048
Kenneth Russell67ea1902014-10-06 16:44:50 -07004049void GL_APIENTRY glStencilMask(GLuint mask)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004050{
4051 glStencilMaskSeparate(GL_FRONT_AND_BACK, mask);
4052}
4053
Kenneth Russell67ea1902014-10-06 16:44:50 -07004054void GL_APIENTRY glStencilMaskSeparate(GLenum face, GLuint mask)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004055{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00004056 EVENT("(GLenum face = 0x%X, GLuint mask = %d)", face, mask);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004057
Geoff Langbfdea662014-07-23 14:16:32 -04004058 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04004059 if (context)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004060 {
Geoff Langb1196682014-07-23 13:47:29 -04004061 switch (face)
4062 {
4063 case GL_FRONT:
4064 case GL_BACK:
4065 case GL_FRONT_AND_BACK:
4066 break;
4067
4068 default:
4069 context->recordError(gl::Error(GL_INVALID_ENUM));
4070 return;
4071 }
4072
Geoff Langbfdea662014-07-23 14:16:32 -04004073 if (face == GL_FRONT || face == GL_FRONT_AND_BACK)
4074 {
4075 context->getState().setStencilWritemask(mask);
4076 }
4077
4078 if (face == GL_BACK || face == GL_FRONT_AND_BACK)
4079 {
4080 context->getState().setStencilBackWritemask(mask);
4081 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004082 }
4083}
4084
Kenneth Russell67ea1902014-10-06 16:44:50 -07004085void GL_APIENTRY glStencilOp(GLenum fail, GLenum zfail, GLenum zpass)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004086{
4087 glStencilOpSeparate(GL_FRONT_AND_BACK, fail, zfail, zpass);
4088}
4089
Kenneth Russell67ea1902014-10-06 16:44:50 -07004090void GL_APIENTRY glStencilOpSeparate(GLenum face, GLenum fail, GLenum zfail, GLenum zpass)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004091{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00004092 EVENT("(GLenum face = 0x%X, GLenum fail = 0x%X, GLenum zfail = 0x%X, GLenum zpas = 0x%Xs)",
daniel@transgaming.comb5b06162010-03-21 04:31:32 +00004093 face, fail, zfail, zpass);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004094
Geoff Langbfdea662014-07-23 14:16:32 -04004095 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04004096 if (context)
4097 {
Geoff Langb1196682014-07-23 13:47:29 -04004098 switch (face)
4099 {
4100 case GL_FRONT:
4101 case GL_BACK:
4102 case GL_FRONT_AND_BACK:
4103 break;
4104
4105 default:
4106 context->recordError(gl::Error(GL_INVALID_ENUM));
4107 return;
4108 }
4109
4110 switch (fail)
4111 {
4112 case GL_ZERO:
4113 case GL_KEEP:
4114 case GL_REPLACE:
4115 case GL_INCR:
4116 case GL_DECR:
4117 case GL_INVERT:
4118 case GL_INCR_WRAP:
4119 case GL_DECR_WRAP:
4120 break;
4121
4122 default:
4123 context->recordError(gl::Error(GL_INVALID_ENUM));
4124 return;
4125 }
4126
4127 switch (zfail)
4128 {
4129 case GL_ZERO:
4130 case GL_KEEP:
4131 case GL_REPLACE:
4132 case GL_INCR:
4133 case GL_DECR:
4134 case GL_INVERT:
4135 case GL_INCR_WRAP:
4136 case GL_DECR_WRAP:
4137 break;
4138
4139 default:
4140 context->recordError(gl::Error(GL_INVALID_ENUM));
4141 return;
4142 }
4143
4144 switch (zpass)
4145 {
4146 case GL_ZERO:
4147 case GL_KEEP:
4148 case GL_REPLACE:
4149 case GL_INCR:
4150 case GL_DECR:
4151 case GL_INVERT:
4152 case GL_INCR_WRAP:
4153 case GL_DECR_WRAP:
4154 break;
4155
4156 default:
4157 context->recordError(gl::Error(GL_INVALID_ENUM));
4158 return;
4159 }
4160
Geoff Langbfdea662014-07-23 14:16:32 -04004161 if (face == GL_FRONT || face == GL_FRONT_AND_BACK)
4162 {
4163 context->getState().setStencilOperations(fail, zfail, zpass);
4164 }
4165
4166 if (face == GL_BACK || face == GL_FRONT_AND_BACK)
4167 {
4168 context->getState().setStencilBackOperations(fail, zfail, zpass);
4169 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004170 }
4171}
4172
Kenneth Russell67ea1902014-10-06 16:44:50 -07004173GLboolean GL_APIENTRY glTestFenceNV(GLuint fence)
daniel@transgaming.comfe208882010-09-01 15:47:57 +00004174{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00004175 EVENT("(GLuint fence = %d)", fence);
apatrick@chromium.orgd3bd0ad2010-08-30 18:55:36 +00004176
Geoff Langbfdea662014-07-23 14:16:32 -04004177 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04004178 if (context)
4179 {
4180 gl::FenceNV *fenceObject = context->getFenceNV(fence);
4181
4182 if (fenceObject == NULL)
apatrick@chromium.orgd3bd0ad2010-08-30 18:55:36 +00004183 {
Geoff Langb1196682014-07-23 13:47:29 -04004184 context->recordError(gl::Error(GL_INVALID_OPERATION));
4185 return GL_TRUE;
apatrick@chromium.orgd3bd0ad2010-08-30 18:55:36 +00004186 }
Geoff Langbfdea662014-07-23 14:16:32 -04004187
4188 if (fenceObject->isFence() != GL_TRUE)
4189 {
Geoff Langb1196682014-07-23 13:47:29 -04004190 context->recordError(gl::Error(GL_INVALID_OPERATION));
4191 return GL_TRUE;
Geoff Langbfdea662014-07-23 14:16:32 -04004192 }
4193
Geoff Lang882033e2014-09-30 11:26:07 -04004194 GLboolean result;
4195 gl::Error error = fenceObject->testFence(&result);
4196 if (error.isError())
4197 {
4198 context->recordError(error);
4199 return GL_TRUE;
4200 }
4201
4202 return result;
apatrick@chromium.orgd3bd0ad2010-08-30 18:55:36 +00004203 }
Geoff Langbfdea662014-07-23 14:16:32 -04004204
apatrick@chromium.orgd3bd0ad2010-08-30 18:55:36 +00004205 return GL_TRUE;
daniel@transgaming.comfe208882010-09-01 15:47:57 +00004206}
apatrick@chromium.orgd3bd0ad2010-08-30 18:55:36 +00004207
Kenneth Russell67ea1902014-10-06 16:44:50 -07004208void GL_APIENTRY glTexImage2D(GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height,
daniel@transgaming.comfe4b8272010-04-08 03:51:20 +00004209 GLint border, GLenum format, GLenum type, const GLvoid* pixels)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004210{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00004211 EVENT("(GLenum target = 0x%X, GLint level = %d, GLint internalformat = %d, GLsizei width = %d, GLsizei height = %d, "
Jamie Madill1fc7e2c2014-01-21 16:47:10 -05004212 "GLint border = %d, GLenum format = 0x%X, GLenum type = 0x%X, const GLvoid* pixels = 0x%0.8p)",
daniel@transgaming.comb5b06162010-03-21 04:31:32 +00004213 target, level, internalformat, width, height, border, format, type, pixels);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004214
Geoff Langbfdea662014-07-23 14:16:32 -04004215 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04004216 if (context)
4217 {
4218 if (context->getClientVersion() < 3 &&
4219 !ValidateES2TexImageParameters(context, target, level, internalformat, false, false,
4220 0, 0, width, height, border, format, type, pixels))
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004221 {
Geoff Langbfdea662014-07-23 14:16:32 -04004222 return;
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004223 }
Geoff Langbfdea662014-07-23 14:16:32 -04004224
4225 if (context->getClientVersion() >= 3 &&
4226 !ValidateES3TexImageParameters(context, target, level, internalformat, false, false,
4227 0, 0, 0, width, height, 1, border, format, type, pixels))
4228 {
4229 return;
4230 }
4231
4232 switch (target)
4233 {
4234 case GL_TEXTURE_2D:
4235 {
4236 gl::Texture2D *texture = context->getTexture2D();
Geoff Lang1ba6b8d2014-08-28 10:57:31 -04004237 gl::Error error = texture->setImage(level, width, height, internalformat, format, type, context->getState().getUnpackState(), pixels);
4238 if (error.isError())
4239 {
4240 context->recordError(error);
4241 return;
4242 }
Geoff Langbfdea662014-07-23 14:16:32 -04004243 }
4244 break;
Geoff Lang8376cea2014-09-02 11:47:07 -04004245
Geoff Langbfdea662014-07-23 14:16:32 -04004246 case GL_TEXTURE_CUBE_MAP_POSITIVE_X:
Geoff Langbfdea662014-07-23 14:16:32 -04004247 case GL_TEXTURE_CUBE_MAP_NEGATIVE_X:
Geoff Langbfdea662014-07-23 14:16:32 -04004248 case GL_TEXTURE_CUBE_MAP_POSITIVE_Y:
Geoff Langbfdea662014-07-23 14:16:32 -04004249 case GL_TEXTURE_CUBE_MAP_NEGATIVE_Y:
Geoff Langbfdea662014-07-23 14:16:32 -04004250 case GL_TEXTURE_CUBE_MAP_POSITIVE_Z:
Geoff Langbfdea662014-07-23 14:16:32 -04004251 case GL_TEXTURE_CUBE_MAP_NEGATIVE_Z:
4252 {
4253 gl::TextureCubeMap *texture = context->getTextureCubeMap();
Geoff Lang8376cea2014-09-02 11:47:07 -04004254 gl::Error error = texture->setImage(target, level, width, height, internalformat, format, type, context->getState().getUnpackState(), pixels);
Geoff Lang1ba6b8d2014-08-28 10:57:31 -04004255 if (error.isError())
4256 {
4257 context->recordError(error);
4258 return;
4259 }
Geoff Langbfdea662014-07-23 14:16:32 -04004260 }
4261 break;
Geoff Lang8376cea2014-09-02 11:47:07 -04004262
Geoff Langbfdea662014-07-23 14:16:32 -04004263 default: UNREACHABLE();
4264 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004265 }
4266}
4267
Kenneth Russell67ea1902014-10-06 16:44:50 -07004268void GL_APIENTRY glTexParameterf(GLenum target, GLenum pname, GLfloat param)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004269{
daniel@transgaming.com07ab8412012-07-12 15:17:09 +00004270 EVENT("(GLenum target = 0x%X, GLenum pname = 0x%X, GLint param = %f)", target, pname, param);
4271
Geoff Langbfdea662014-07-23 14:16:32 -04004272 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04004273 if (context)
4274 {
4275 if (!ValidateTexParamParameters(context, pname, static_cast<GLint>(param)))
daniel@transgaming.com07ab8412012-07-12 15:17:09 +00004276 {
Geoff Langbfdea662014-07-23 14:16:32 -04004277 return;
daniel@transgaming.com07ab8412012-07-12 15:17:09 +00004278 }
Geoff Langbfdea662014-07-23 14:16:32 -04004279
4280 gl::Texture *texture = context->getTargetTexture(target);
4281
4282 if (!texture)
4283 {
Geoff Langb1196682014-07-23 13:47:29 -04004284 context->recordError(gl::Error(GL_INVALID_ENUM));
4285 return;
Geoff Langbfdea662014-07-23 14:16:32 -04004286 }
4287
4288 switch (pname)
4289 {
4290 case GL_TEXTURE_WRAP_S: texture->getSamplerState().wrapS = gl::uiround<GLenum>(param); break;
4291 case GL_TEXTURE_WRAP_T: texture->getSamplerState().wrapT = gl::uiround<GLenum>(param); break;
4292 case GL_TEXTURE_WRAP_R: texture->getSamplerState().wrapR = gl::uiround<GLenum>(param); break;
4293 case GL_TEXTURE_MIN_FILTER: texture->getSamplerState().minFilter = gl::uiround<GLenum>(param); break;
4294 case GL_TEXTURE_MAG_FILTER: texture->getSamplerState().magFilter = gl::uiround<GLenum>(param); break;
4295 case GL_TEXTURE_USAGE_ANGLE: texture->setUsage(gl::uiround<GLenum>(param)); break;
4296 case GL_TEXTURE_MAX_ANISOTROPY_EXT: texture->getSamplerState().maxAnisotropy = std::min(param, context->getExtensions().maxTextureAnisotropy); break;
4297 case GL_TEXTURE_COMPARE_MODE: texture->getSamplerState().compareMode = gl::uiround<GLenum>(param); break;
4298 case GL_TEXTURE_COMPARE_FUNC: texture->getSamplerState().compareFunc = gl::uiround<GLenum>(param); break;
4299 case GL_TEXTURE_SWIZZLE_R: texture->getSamplerState().swizzleRed = gl::uiround<GLenum>(param); break;
4300 case GL_TEXTURE_SWIZZLE_G: texture->getSamplerState().swizzleGreen = gl::uiround<GLenum>(param); break;
4301 case GL_TEXTURE_SWIZZLE_B: texture->getSamplerState().swizzleBlue = gl::uiround<GLenum>(param); break;
4302 case GL_TEXTURE_SWIZZLE_A: texture->getSamplerState().swizzleAlpha = gl::uiround<GLenum>(param); break;
4303 case GL_TEXTURE_BASE_LEVEL: texture->getSamplerState().baseLevel = gl::iround<GLint>(param); break;
4304 case GL_TEXTURE_MAX_LEVEL: texture->getSamplerState().maxLevel = gl::iround<GLint>(param); break;
4305 case GL_TEXTURE_MIN_LOD: texture->getSamplerState().minLod = param; break;
4306 case GL_TEXTURE_MAX_LOD: texture->getSamplerState().maxLod = param; break;
4307 default: UNREACHABLE(); break;
4308 }
daniel@transgaming.com07ab8412012-07-12 15:17:09 +00004309 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004310}
4311
Kenneth Russell67ea1902014-10-06 16:44:50 -07004312void GL_APIENTRY glTexParameterfv(GLenum target, GLenum pname, const GLfloat* params)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004313{
daniel@transgaming.com07ab8412012-07-12 15:17:09 +00004314 glTexParameterf(target, pname, (GLfloat)*params);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004315}
4316
Kenneth Russell67ea1902014-10-06 16:44:50 -07004317void GL_APIENTRY glTexParameteri(GLenum target, GLenum pname, GLint param)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004318{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00004319 EVENT("(GLenum target = 0x%X, GLenum pname = 0x%X, GLint param = %d)", target, pname, param);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004320
Geoff Langbfdea662014-07-23 14:16:32 -04004321 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04004322 if (context)
4323 {
4324 if (!ValidateTexParamParameters(context, pname, param))
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004325 {
Geoff Langbfdea662014-07-23 14:16:32 -04004326 return;
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004327 }
Geoff Langbfdea662014-07-23 14:16:32 -04004328
4329 gl::Texture *texture = context->getTargetTexture(target);
4330
4331 if (!texture)
4332 {
Geoff Langb1196682014-07-23 13:47:29 -04004333 context->recordError(gl::Error(GL_INVALID_ENUM));
4334 return;
Geoff Langbfdea662014-07-23 14:16:32 -04004335 }
4336
4337 switch (pname)
4338 {
4339 case GL_TEXTURE_WRAP_S: texture->getSamplerState().wrapS = (GLenum)param; break;
4340 case GL_TEXTURE_WRAP_T: texture->getSamplerState().wrapT = (GLenum)param; break;
4341 case GL_TEXTURE_WRAP_R: texture->getSamplerState().wrapR = (GLenum)param; break;
4342 case GL_TEXTURE_MIN_FILTER: texture->getSamplerState().minFilter = (GLenum)param; break;
4343 case GL_TEXTURE_MAG_FILTER: texture->getSamplerState().magFilter = (GLenum)param; break;
4344 case GL_TEXTURE_USAGE_ANGLE: texture->setUsage((GLenum)param); break;
4345 case GL_TEXTURE_MAX_ANISOTROPY_EXT: texture->getSamplerState().maxAnisotropy = std::min((float)param, context->getExtensions().maxTextureAnisotropy); break;
4346 case GL_TEXTURE_COMPARE_MODE: texture->getSamplerState().compareMode = (GLenum)param; break;
4347 case GL_TEXTURE_COMPARE_FUNC: texture->getSamplerState().compareFunc = (GLenum)param; break;
4348 case GL_TEXTURE_SWIZZLE_R: texture->getSamplerState().swizzleRed = (GLenum)param; break;
4349 case GL_TEXTURE_SWIZZLE_G: texture->getSamplerState().swizzleGreen = (GLenum)param; break;
4350 case GL_TEXTURE_SWIZZLE_B: texture->getSamplerState().swizzleBlue = (GLenum)param; break;
4351 case GL_TEXTURE_SWIZZLE_A: texture->getSamplerState().swizzleAlpha = (GLenum)param; break;
4352 case GL_TEXTURE_BASE_LEVEL: texture->getSamplerState().baseLevel = param; break;
4353 case GL_TEXTURE_MAX_LEVEL: texture->getSamplerState().maxLevel = param; break;
4354 case GL_TEXTURE_MIN_LOD: texture->getSamplerState().minLod = (GLfloat)param; break;
4355 case GL_TEXTURE_MAX_LOD: texture->getSamplerState().maxLod = (GLfloat)param; break;
4356 default: UNREACHABLE(); break;
4357 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004358 }
4359}
4360
Kenneth Russell67ea1902014-10-06 16:44:50 -07004361void GL_APIENTRY glTexParameteriv(GLenum target, GLenum pname, const GLint* params)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004362{
4363 glTexParameteri(target, pname, *params);
4364}
4365
Kenneth Russell67ea1902014-10-06 16:44:50 -07004366void GL_APIENTRY glTexStorage2DEXT(GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height)
daniel@transgaming.com64a0fb22011-11-11 04:10:40 +00004367{
4368 EVENT("(GLenum target = 0x%X, GLsizei levels = %d, GLenum internalformat = 0x%X, GLsizei width = %d, GLsizei height = %d)",
4369 target, levels, internalformat, width, height);
4370
Geoff Langbfdea662014-07-23 14:16:32 -04004371 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04004372 if (context)
4373 {
4374 if (!context->getExtensions().textureStorage)
daniel@transgaming.com64a0fb22011-11-11 04:10:40 +00004375 {
Geoff Langb1196682014-07-23 13:47:29 -04004376 context->recordError(gl::Error(GL_INVALID_OPERATION));
4377 return;
daniel@transgaming.com64a0fb22011-11-11 04:10:40 +00004378 }
Geoff Langbfdea662014-07-23 14:16:32 -04004379
4380 if (context->getClientVersion() < 3 &&
4381 !ValidateES2TexStorageParameters(context, target, levels, internalformat, width, height))
4382 {
4383 return;
4384 }
4385
4386 if (context->getClientVersion() >= 3 &&
4387 !ValidateES3TexStorageParameters(context, target, levels, internalformat, width, height, 1))
4388 {
4389 return;
4390 }
4391
4392 switch (target)
4393 {
4394 case GL_TEXTURE_2D:
4395 {
4396 gl::Texture2D *texture2d = context->getTexture2D();
Geoff Lang1f8532b2014-09-05 09:46:13 -04004397 gl::Error error = texture2d->storage(levels, internalformat, width, height);
4398 if (error.isError())
4399 {
4400 context->recordError(error);
4401 return;
4402 }
Geoff Langbfdea662014-07-23 14:16:32 -04004403 }
4404 break;
4405
4406 case GL_TEXTURE_CUBE_MAP:
4407 {
4408 gl::TextureCubeMap *textureCube = context->getTextureCubeMap();
Geoff Lang1f8532b2014-09-05 09:46:13 -04004409 gl::Error error = textureCube->storage(levels, internalformat, width);
4410 if (error.isError())
4411 {
4412 context->recordError(error);
4413 return;
4414 }
Geoff Langbfdea662014-07-23 14:16:32 -04004415 }
4416 break;
4417
4418 default:
Geoff Langb1196682014-07-23 13:47:29 -04004419 context->recordError(gl::Error(GL_INVALID_ENUM));
4420 return;
Geoff Langbfdea662014-07-23 14:16:32 -04004421 }
daniel@transgaming.com64a0fb22011-11-11 04:10:40 +00004422 }
4423}
4424
Kenneth Russell67ea1902014-10-06 16:44:50 -07004425void GL_APIENTRY glTexSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height,
daniel@transgaming.comfe4b8272010-04-08 03:51:20 +00004426 GLenum format, GLenum type, const GLvoid* pixels)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004427{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00004428 EVENT("(GLenum target = 0x%X, GLint level = %d, GLint xoffset = %d, GLint yoffset = %d, "
daniel@transgaming.comb5b06162010-03-21 04:31:32 +00004429 "GLsizei width = %d, GLsizei height = %d, GLenum format = 0x%X, GLenum type = 0x%X, "
daniel@transgaming.comfe4b8272010-04-08 03:51:20 +00004430 "const GLvoid* pixels = 0x%0.8p)",
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004431 target, level, xoffset, yoffset, width, height, format, type, pixels);
4432
Geoff Langbfdea662014-07-23 14:16:32 -04004433 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04004434 if (context)
4435 {
4436 if (context->getClientVersion() < 3 &&
4437 !ValidateES2TexImageParameters(context, target, level, GL_NONE, false, true,
4438 xoffset, yoffset, width, height, 0, format, type, pixels))
daniel@transgaming.com00c75962010-03-11 20:36:15 +00004439 {
Geoff Langbfdea662014-07-23 14:16:32 -04004440 return;
daniel@transgaming.com00c75962010-03-11 20:36:15 +00004441 }
Geoff Langbfdea662014-07-23 14:16:32 -04004442
4443 if (context->getClientVersion() >= 3 &&
4444 !ValidateES3TexImageParameters(context, target, level, GL_NONE, false, true,
4445 xoffset, yoffset, 0, width, height, 1, 0, format, type, pixels))
4446 {
4447 return;
4448 }
4449
4450 // Zero sized uploads are valid but no-ops
4451 if (width == 0 || height == 0)
4452 {
4453 return;
4454 }
4455
4456 switch (target)
4457 {
4458 case GL_TEXTURE_2D:
4459 {
4460 gl::Texture2D *texture = context->getTexture2D();
Geoff Lang1ba6b8d2014-08-28 10:57:31 -04004461 gl::Error error = texture->subImage(level, xoffset, yoffset, width, height, format, type, context->getState().getUnpackState(), pixels);
4462 if (error.isError())
4463 {
4464 context->recordError(error);
4465 return;
4466 }
Geoff Langbfdea662014-07-23 14:16:32 -04004467 }
4468 break;
4469
4470 case GL_TEXTURE_CUBE_MAP_POSITIVE_X:
4471 case GL_TEXTURE_CUBE_MAP_NEGATIVE_X:
4472 case GL_TEXTURE_CUBE_MAP_POSITIVE_Y:
4473 case GL_TEXTURE_CUBE_MAP_NEGATIVE_Y:
4474 case GL_TEXTURE_CUBE_MAP_POSITIVE_Z:
4475 case GL_TEXTURE_CUBE_MAP_NEGATIVE_Z:
4476 {
4477 gl::TextureCubeMap *texture = context->getTextureCubeMap();
Geoff Lang1ba6b8d2014-08-28 10:57:31 -04004478 gl::Error error = texture->subImage(target, level, xoffset, yoffset, width, height, format, type, context->getState().getUnpackState(), pixels);
4479 if (error.isError())
4480 {
4481 context->recordError(error);
4482 return;
4483 }
Geoff Langbfdea662014-07-23 14:16:32 -04004484 }
4485 break;
4486
4487 default:
4488 UNREACHABLE();
4489 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004490 }
4491}
4492
Kenneth Russell67ea1902014-10-06 16:44:50 -07004493void GL_APIENTRY glUniform1f(GLint location, GLfloat x)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004494{
4495 glUniform1fv(location, 1, &x);
4496}
4497
Kenneth Russell67ea1902014-10-06 16:44:50 -07004498void GL_APIENTRY glUniform1fv(GLint location, GLsizei count, const GLfloat* v)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004499{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00004500 EVENT("(GLint location = %d, GLsizei count = %d, const GLfloat* v = 0x%0.8p)", location, count, v);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004501
Geoff Langbfdea662014-07-23 14:16:32 -04004502 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04004503 if (context)
4504 {
4505 if (!ValidateUniform(context, GL_FLOAT, location, count))
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004506 {
Geoff Langbfdea662014-07-23 14:16:32 -04004507 return;
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004508 }
Geoff Langbfdea662014-07-23 14:16:32 -04004509
4510 gl::ProgramBinary *programBinary = context->getState().getCurrentProgramBinary();
4511 programBinary->setUniform1fv(location, count, v);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004512 }
4513}
4514
Kenneth Russell67ea1902014-10-06 16:44:50 -07004515void GL_APIENTRY glUniform1i(GLint location, GLint x)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004516{
4517 glUniform1iv(location, 1, &x);
4518}
4519
Kenneth Russell67ea1902014-10-06 16:44:50 -07004520void GL_APIENTRY glUniform1iv(GLint location, GLsizei count, const GLint* v)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004521{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00004522 EVENT("(GLint location = %d, GLsizei count = %d, const GLint* v = 0x%0.8p)", location, count, v);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004523
Geoff Langbfdea662014-07-23 14:16:32 -04004524 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04004525 if (context)
4526 {
4527 if (!ValidateUniform(context, GL_INT, location, count))
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004528 {
Geoff Langbfdea662014-07-23 14:16:32 -04004529 return;
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004530 }
Geoff Langbfdea662014-07-23 14:16:32 -04004531
4532 gl::ProgramBinary *programBinary = context->getState().getCurrentProgramBinary();
4533 programBinary->setUniform1iv(location, count, v);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004534 }
4535}
4536
Kenneth Russell67ea1902014-10-06 16:44:50 -07004537void GL_APIENTRY glUniform2f(GLint location, GLfloat x, GLfloat y)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004538{
4539 GLfloat xy[2] = {x, y};
4540
Geoff Lang3b3ad1f2014-03-05 14:35:01 -05004541 glUniform2fv(location, 1, xy);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004542}
4543
Kenneth Russell67ea1902014-10-06 16:44:50 -07004544void GL_APIENTRY glUniform2fv(GLint location, GLsizei count, const GLfloat* v)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004545{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00004546 EVENT("(GLint location = %d, GLsizei count = %d, const GLfloat* v = 0x%0.8p)", location, count, v);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004547
Geoff Langbfdea662014-07-23 14:16:32 -04004548 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04004549 if (context)
4550 {
4551 if (!ValidateUniform(context, GL_FLOAT_VEC2, location, count))
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004552 {
Geoff Langbfdea662014-07-23 14:16:32 -04004553 return;
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004554 }
Geoff Langbfdea662014-07-23 14:16:32 -04004555
4556 gl::ProgramBinary *programBinary = context->getState().getCurrentProgramBinary();
4557 programBinary->setUniform2fv(location, count, v);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004558 }
4559}
4560
Kenneth Russell67ea1902014-10-06 16:44:50 -07004561void GL_APIENTRY glUniform2i(GLint location, GLint x, GLint y)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004562{
Geoff Lang3b3ad1f2014-03-05 14:35:01 -05004563 GLint xy[2] = {x, y};
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004564
Geoff Lang3b3ad1f2014-03-05 14:35:01 -05004565 glUniform2iv(location, 1, xy);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004566}
4567
Kenneth Russell67ea1902014-10-06 16:44:50 -07004568void GL_APIENTRY glUniform2iv(GLint location, GLsizei count, const GLint* v)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004569{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00004570 EVENT("(GLint location = %d, GLsizei count = %d, const GLint* v = 0x%0.8p)", location, count, v);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004571
Geoff Langbfdea662014-07-23 14:16:32 -04004572 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04004573 if (context)
4574 {
4575 if (!ValidateUniform(context, GL_INT_VEC2, location, count))
daniel@transgaming.com9a95e2b2010-04-13 03:26:03 +00004576 {
Geoff Langbfdea662014-07-23 14:16:32 -04004577 return;
daniel@transgaming.com9a95e2b2010-04-13 03:26:03 +00004578 }
Geoff Langbfdea662014-07-23 14:16:32 -04004579
4580 gl::ProgramBinary *programBinary = context->getState().getCurrentProgramBinary();
4581 programBinary->setUniform2iv(location, count, v);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004582 }
4583}
4584
Kenneth Russell67ea1902014-10-06 16:44:50 -07004585void GL_APIENTRY glUniform3f(GLint location, GLfloat x, GLfloat y, GLfloat z)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004586{
4587 GLfloat xyz[3] = {x, y, z};
4588
Geoff Lang3b3ad1f2014-03-05 14:35:01 -05004589 glUniform3fv(location, 1, xyz);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004590}
4591
Kenneth Russell67ea1902014-10-06 16:44:50 -07004592void GL_APIENTRY glUniform3fv(GLint location, GLsizei count, const GLfloat* v)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004593{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00004594 EVENT("(GLint location = %d, GLsizei count = %d, const GLfloat* v = 0x%0.8p)", location, count, v);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004595
Geoff Langbfdea662014-07-23 14:16:32 -04004596 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04004597 if (context)
4598 {
4599 if (!ValidateUniform(context, GL_FLOAT_VEC3, location, count))
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004600 {
Geoff Langbfdea662014-07-23 14:16:32 -04004601 return;
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004602 }
Geoff Langbfdea662014-07-23 14:16:32 -04004603
4604 gl::ProgramBinary *programBinary = context->getState().getCurrentProgramBinary();
4605 programBinary->setUniform3fv(location, count, v);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004606 }
4607}
4608
Kenneth Russell67ea1902014-10-06 16:44:50 -07004609void GL_APIENTRY glUniform3i(GLint location, GLint x, GLint y, GLint z)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004610{
4611 GLint xyz[3] = {x, y, z};
4612
Geoff Lang3b3ad1f2014-03-05 14:35:01 -05004613 glUniform3iv(location, 1, xyz);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004614}
4615
Kenneth Russell67ea1902014-10-06 16:44:50 -07004616void GL_APIENTRY glUniform3iv(GLint location, GLsizei count, const GLint* v)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004617{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00004618 EVENT("(GLint location = %d, GLsizei count = %d, const GLint* v = 0x%0.8p)", location, count, v);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004619
Geoff Langbfdea662014-07-23 14:16:32 -04004620 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04004621 if (context)
4622 {
4623 if (!ValidateUniform(context, GL_INT_VEC3, location, count))
daniel@transgaming.com9a95e2b2010-04-13 03:26:03 +00004624 {
Geoff Langbfdea662014-07-23 14:16:32 -04004625 return;
daniel@transgaming.com9a95e2b2010-04-13 03:26:03 +00004626 }
Geoff Langbfdea662014-07-23 14:16:32 -04004627
4628 gl::ProgramBinary *programBinary = context->getState().getCurrentProgramBinary();
4629 programBinary->setUniform3iv(location, count, v);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004630 }
4631}
4632
Kenneth Russell67ea1902014-10-06 16:44:50 -07004633void GL_APIENTRY glUniform4f(GLint location, GLfloat x, GLfloat y, GLfloat z, GLfloat w)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004634{
4635 GLfloat xyzw[4] = {x, y, z, w};
4636
Geoff Lang3b3ad1f2014-03-05 14:35:01 -05004637 glUniform4fv(location, 1, xyzw);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004638}
4639
Kenneth Russell67ea1902014-10-06 16:44:50 -07004640void GL_APIENTRY glUniform4fv(GLint location, GLsizei count, const GLfloat* v)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004641{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00004642 EVENT("(GLint location = %d, GLsizei count = %d, const GLfloat* v = 0x%0.8p)", location, count, v);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004643
Geoff Langbfdea662014-07-23 14:16:32 -04004644 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04004645 if (context)
4646 {
4647 if (!ValidateUniform(context, GL_FLOAT_VEC4, location, count))
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004648 {
Geoff Langbfdea662014-07-23 14:16:32 -04004649 return;
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004650 }
Geoff Langbfdea662014-07-23 14:16:32 -04004651
4652 gl::ProgramBinary *programBinary = context->getState().getCurrentProgramBinary();
4653 programBinary->setUniform4fv(location, count, v);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004654 }
4655}
4656
Kenneth Russell67ea1902014-10-06 16:44:50 -07004657void GL_APIENTRY glUniform4i(GLint location, GLint x, GLint y, GLint z, GLint w)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004658{
4659 GLint xyzw[4] = {x, y, z, w};
4660
Geoff Lang3b3ad1f2014-03-05 14:35:01 -05004661 glUniform4iv(location, 1, xyzw);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004662}
4663
Kenneth Russell67ea1902014-10-06 16:44:50 -07004664void GL_APIENTRY glUniform4iv(GLint location, GLsizei count, const GLint* v)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004665{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00004666 EVENT("(GLint location = %d, GLsizei count = %d, const GLint* v = 0x%0.8p)", location, count, v);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004667
Geoff Langbfdea662014-07-23 14:16:32 -04004668 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04004669 if (context)
4670 {
4671 if (!ValidateUniform(context, GL_INT_VEC4, location, count))
daniel@transgaming.com9a95e2b2010-04-13 03:26:03 +00004672 {
Geoff Langbfdea662014-07-23 14:16:32 -04004673 return;
daniel@transgaming.com9a95e2b2010-04-13 03:26:03 +00004674 }
Geoff Langbfdea662014-07-23 14:16:32 -04004675
4676 gl::ProgramBinary *programBinary = context->getState().getCurrentProgramBinary();
4677 programBinary->setUniform4iv(location, count, v);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004678 }
4679}
4680
Kenneth Russell67ea1902014-10-06 16:44:50 -07004681void GL_APIENTRY glUniformMatrix2fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004682{
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00004683 EVENT("(GLint location = %d, GLsizei count = %d, GLboolean transpose = %u, const GLfloat* value = 0x%0.8p)",
daniel@transgaming.comb5b06162010-03-21 04:31:32 +00004684 location, count, transpose, value);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004685
Geoff Langbfdea662014-07-23 14:16:32 -04004686 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04004687 if (context)
4688 {
4689 if (!ValidateUniformMatrix(context, GL_FLOAT_MAT2, location, count, transpose))
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004690 {
Geoff Langbfdea662014-07-23 14:16:32 -04004691 return;
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004692 }
Geoff Langbfdea662014-07-23 14:16:32 -04004693
4694 gl::ProgramBinary *programBinary = context->getState().getCurrentProgramBinary();
4695 programBinary->setUniformMatrix2fv(location, count, transpose, value);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004696 }
4697}
4698
Kenneth Russell67ea1902014-10-06 16:44:50 -07004699void GL_APIENTRY glUniformMatrix3fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004700{
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00004701 EVENT("(GLint location = %d, GLsizei count = %d, GLboolean transpose = %u, const GLfloat* value = 0x%0.8p)",
daniel@transgaming.comb5b06162010-03-21 04:31:32 +00004702 location, count, transpose, value);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004703
Geoff Langbfdea662014-07-23 14:16:32 -04004704 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04004705 if (context)
4706 {
4707 if (!ValidateUniformMatrix(context, GL_FLOAT_MAT3, location, count, transpose))
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004708 {
Geoff Langbfdea662014-07-23 14:16:32 -04004709 return;
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004710 }
Geoff Langbfdea662014-07-23 14:16:32 -04004711
4712 gl::ProgramBinary *programBinary = context->getState().getCurrentProgramBinary();
4713 programBinary->setUniformMatrix3fv(location, count, transpose, value);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004714 }
4715}
4716
Kenneth Russell67ea1902014-10-06 16:44:50 -07004717void GL_APIENTRY glUniformMatrix4fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004718{
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00004719 EVENT("(GLint location = %d, GLsizei count = %d, GLboolean transpose = %u, const GLfloat* value = 0x%0.8p)",
daniel@transgaming.comb5b06162010-03-21 04:31:32 +00004720 location, count, transpose, value);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004721
Geoff Langbfdea662014-07-23 14:16:32 -04004722 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04004723 if (context)
4724 {
4725 if (!ValidateUniformMatrix(context, GL_FLOAT_MAT4, location, count, transpose))
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004726 {
Geoff Langbfdea662014-07-23 14:16:32 -04004727 return;
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004728 }
Geoff Langbfdea662014-07-23 14:16:32 -04004729
4730 gl::ProgramBinary *programBinary = context->getState().getCurrentProgramBinary();
4731 programBinary->setUniformMatrix4fv(location, count, transpose, value);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004732 }
4733}
4734
Kenneth Russell67ea1902014-10-06 16:44:50 -07004735void GL_APIENTRY glUseProgram(GLuint program)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004736{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00004737 EVENT("(GLuint program = %d)", program);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004738
Geoff Langbfdea662014-07-23 14:16:32 -04004739 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04004740 if (context)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004741 {
Geoff Langbfdea662014-07-23 14:16:32 -04004742 gl::Program *programObject = context->getProgram(program);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004743
Geoff Langbfdea662014-07-23 14:16:32 -04004744 if (!programObject && program != 0)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004745 {
Geoff Langbfdea662014-07-23 14:16:32 -04004746 if (context->getShader(program))
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004747 {
Geoff Langb1196682014-07-23 13:47:29 -04004748 context->recordError(gl::Error(GL_INVALID_OPERATION));
4749 return;
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004750 }
Geoff Langbfdea662014-07-23 14:16:32 -04004751 else
4752 {
Geoff Langb1196682014-07-23 13:47:29 -04004753 context->recordError(gl::Error(GL_INVALID_VALUE));
4754 return;
Geoff Langbfdea662014-07-23 14:16:32 -04004755 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004756 }
Geoff Langbfdea662014-07-23 14:16:32 -04004757
4758 if (program != 0 && !programObject->isLinked())
4759 {
Geoff Langb1196682014-07-23 13:47:29 -04004760 context->recordError(gl::Error(GL_INVALID_OPERATION));
4761 return;
Geoff Langbfdea662014-07-23 14:16:32 -04004762 }
4763
4764 context->useProgram(program);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004765 }
4766}
4767
Kenneth Russell67ea1902014-10-06 16:44:50 -07004768void GL_APIENTRY glValidateProgram(GLuint program)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004769{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00004770 EVENT("(GLuint program = %d)", program);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004771
Geoff Langbfdea662014-07-23 14:16:32 -04004772 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04004773 if (context)
4774 {
4775 gl::Program *programObject = context->getProgram(program);
4776
4777 if (!programObject)
daniel@transgaming.com86a7a132010-04-29 03:32:32 +00004778 {
Geoff Langbfdea662014-07-23 14:16:32 -04004779 if (context->getShader(program))
daniel@transgaming.com86a7a132010-04-29 03:32:32 +00004780 {
Geoff Langb1196682014-07-23 13:47:29 -04004781 context->recordError(gl::Error(GL_INVALID_OPERATION));
4782 return;
daniel@transgaming.com86a7a132010-04-29 03:32:32 +00004783 }
Geoff Langbfdea662014-07-23 14:16:32 -04004784 else
4785 {
Geoff Langb1196682014-07-23 13:47:29 -04004786 context->recordError(gl::Error(GL_INVALID_VALUE));
4787 return;
Geoff Langbfdea662014-07-23 14:16:32 -04004788 }
daniel@transgaming.com86a7a132010-04-29 03:32:32 +00004789 }
Geoff Langbfdea662014-07-23 14:16:32 -04004790
Brandon Jones43a53e22014-08-28 16:23:22 -07004791 programObject->validate(context->getCaps());
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004792 }
4793}
4794
Kenneth Russell67ea1902014-10-06 16:44:50 -07004795void GL_APIENTRY glVertexAttrib1f(GLuint index, GLfloat x)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004796{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00004797 EVENT("(GLuint index = %d, GLfloat x = %f)", index, x);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004798
Geoff Langbfdea662014-07-23 14:16:32 -04004799 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04004800 if (context)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004801 {
Geoff Langb1196682014-07-23 13:47:29 -04004802 if (index >= gl::MAX_VERTEX_ATTRIBS)
4803 {
4804 context->recordError(gl::Error(GL_INVALID_VALUE));
4805 return;
4806 }
4807
Geoff Langbfdea662014-07-23 14:16:32 -04004808 GLfloat vals[4] = { x, 0, 0, 1 };
4809 context->getState().setVertexAttribf(index, vals);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004810 }
4811}
4812
Kenneth Russell67ea1902014-10-06 16:44:50 -07004813void GL_APIENTRY glVertexAttrib1fv(GLuint index, const GLfloat* values)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004814{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00004815 EVENT("(GLuint index = %d, const GLfloat* values = 0x%0.8p)", index, values);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004816
Geoff Langbfdea662014-07-23 14:16:32 -04004817 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04004818 if (context)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004819 {
Geoff Langb1196682014-07-23 13:47:29 -04004820 if (index >= gl::MAX_VERTEX_ATTRIBS)
4821 {
4822 context->recordError(gl::Error(GL_INVALID_VALUE));
4823 return;
4824 }
4825
Geoff Langbfdea662014-07-23 14:16:32 -04004826 GLfloat vals[4] = { values[0], 0, 0, 1 };
4827 context->getState().setVertexAttribf(index, vals);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004828 }
4829}
4830
Kenneth Russell67ea1902014-10-06 16:44:50 -07004831void GL_APIENTRY glVertexAttrib2f(GLuint index, GLfloat x, GLfloat y)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004832{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00004833 EVENT("(GLuint index = %d, GLfloat x = %f, GLfloat y = %f)", index, x, y);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004834
Geoff Langbfdea662014-07-23 14:16:32 -04004835 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04004836 if (context)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004837 {
Geoff Langb1196682014-07-23 13:47:29 -04004838 if (index >= gl::MAX_VERTEX_ATTRIBS)
4839 {
4840 context->recordError(gl::Error(GL_INVALID_VALUE));
4841 return;
4842 }
4843
Geoff Langbfdea662014-07-23 14:16:32 -04004844 GLfloat vals[4] = { x, y, 0, 1 };
4845 context->getState().setVertexAttribf(index, vals);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004846 }
4847}
4848
Kenneth Russell67ea1902014-10-06 16:44:50 -07004849void GL_APIENTRY glVertexAttrib2fv(GLuint index, const GLfloat* values)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004850{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00004851 EVENT("(GLuint index = %d, const GLfloat* values = 0x%0.8p)", index, values);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004852
Geoff Langbfdea662014-07-23 14:16:32 -04004853 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04004854 if (context)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004855 {
Geoff Langb1196682014-07-23 13:47:29 -04004856 if (index >= gl::MAX_VERTEX_ATTRIBS)
4857 {
4858 context->recordError(gl::Error(GL_INVALID_VALUE));
4859 return;
4860 }
4861
Geoff Langbfdea662014-07-23 14:16:32 -04004862 GLfloat vals[4] = { values[0], values[1], 0, 1 };
4863 context->getState().setVertexAttribf(index, vals);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004864 }
4865}
4866
Kenneth Russell67ea1902014-10-06 16:44:50 -07004867void GL_APIENTRY glVertexAttrib3f(GLuint index, GLfloat x, GLfloat y, GLfloat z)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004868{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00004869 EVENT("(GLuint index = %d, GLfloat x = %f, GLfloat y = %f, GLfloat z = %f)", index, x, y, z);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004870
Geoff Langbfdea662014-07-23 14:16:32 -04004871 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04004872 if (context)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004873 {
Geoff Langb1196682014-07-23 13:47:29 -04004874 if (index >= gl::MAX_VERTEX_ATTRIBS)
4875 {
4876 context->recordError(gl::Error(GL_INVALID_VALUE));
4877 return;
4878 }
4879
Geoff Langbfdea662014-07-23 14:16:32 -04004880 GLfloat vals[4] = { x, y, z, 1 };
4881 context->getState().setVertexAttribf(index, vals);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004882 }
4883}
4884
Kenneth Russell67ea1902014-10-06 16:44:50 -07004885void GL_APIENTRY glVertexAttrib3fv(GLuint index, const GLfloat* values)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004886{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00004887 EVENT("(GLuint index = %d, const GLfloat* values = 0x%0.8p)", index, values);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004888
Geoff Langbfdea662014-07-23 14:16:32 -04004889 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04004890 if (context)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004891 {
Geoff Langb1196682014-07-23 13:47:29 -04004892 if (index >= gl::MAX_VERTEX_ATTRIBS)
4893 {
4894 context->recordError(gl::Error(GL_INVALID_VALUE));
4895 return;
4896 }
4897
Geoff Langbfdea662014-07-23 14:16:32 -04004898 GLfloat vals[4] = { values[0], values[1], values[2], 1 };
4899 context->getState().setVertexAttribf(index, vals);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004900 }
4901}
4902
Kenneth Russell67ea1902014-10-06 16:44:50 -07004903void GL_APIENTRY glVertexAttrib4f(GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004904{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00004905 EVENT("(GLuint index = %d, GLfloat x = %f, GLfloat y = %f, GLfloat z = %f, GLfloat w = %f)", index, x, y, z, w);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004906
Geoff Langbfdea662014-07-23 14:16:32 -04004907 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04004908 if (context)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004909 {
Geoff Langb1196682014-07-23 13:47:29 -04004910 if (index >= gl::MAX_VERTEX_ATTRIBS)
4911 {
4912 context->recordError(gl::Error(GL_INVALID_VALUE));
4913 return;
4914 }
4915
Geoff Langbfdea662014-07-23 14:16:32 -04004916 GLfloat vals[4] = { x, y, z, w };
4917 context->getState().setVertexAttribf(index, vals);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004918 }
4919}
4920
Kenneth Russell67ea1902014-10-06 16:44:50 -07004921void GL_APIENTRY glVertexAttrib4fv(GLuint index, const GLfloat* values)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004922{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00004923 EVENT("(GLuint index = %d, const GLfloat* values = 0x%0.8p)", index, values);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004924
Geoff Langbfdea662014-07-23 14:16:32 -04004925 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04004926 if (context)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004927 {
Geoff Langb1196682014-07-23 13:47:29 -04004928 if (index >= gl::MAX_VERTEX_ATTRIBS)
4929 {
4930 context->recordError(gl::Error(GL_INVALID_VALUE));
4931 return;
4932 }
4933
Geoff Langbfdea662014-07-23 14:16:32 -04004934 context->getState().setVertexAttribf(index, values);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004935 }
4936}
4937
Kenneth Russell67ea1902014-10-06 16:44:50 -07004938void GL_APIENTRY glVertexAttribDivisorANGLE(GLuint index, GLuint divisor)
daniel@transgaming.comd2820bf2012-01-27 15:38:48 +00004939{
4940 EVENT("(GLuint index = %d, GLuint divisor = %d)", index, divisor);
4941
Geoff Langbfdea662014-07-23 14:16:32 -04004942 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04004943 if (context)
daniel@transgaming.comd2820bf2012-01-27 15:38:48 +00004944 {
Geoff Langb1196682014-07-23 13:47:29 -04004945 if (index >= gl::MAX_VERTEX_ATTRIBS)
4946 {
4947 context->recordError(gl::Error(GL_INVALID_VALUE));
4948 return;
4949 }
4950
Geoff Langbfdea662014-07-23 14:16:32 -04004951 context->setVertexAttribDivisor(index, divisor);
daniel@transgaming.comd2820bf2012-01-27 15:38:48 +00004952 }
4953}
4954
Kenneth Russell67ea1902014-10-06 16:44:50 -07004955void GL_APIENTRY glVertexAttribPointer(GLuint index, GLint size, GLenum type, GLboolean normalized, GLsizei stride, const GLvoid* ptr)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004956{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00004957 EVENT("(GLuint index = %d, GLint size = %d, GLenum type = 0x%X, "
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00004958 "GLboolean normalized = %u, GLsizei stride = %d, const GLvoid* ptr = 0x%0.8p)",
daniel@transgaming.comb5b06162010-03-21 04:31:32 +00004959 index, size, type, normalized, stride, ptr);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004960
Geoff Langbfdea662014-07-23 14:16:32 -04004961 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04004962 if (context)
4963 {
Geoff Langb1196682014-07-23 13:47:29 -04004964 if (index >= gl::MAX_VERTEX_ATTRIBS)
4965 {
4966 context->recordError(gl::Error(GL_INVALID_VALUE));
4967 return;
4968 }
4969
4970 if (size < 1 || size > 4)
4971 {
4972 context->recordError(gl::Error(GL_INVALID_VALUE));
4973 return;
4974 }
4975
4976 switch (type)
4977 {
4978 case GL_BYTE:
4979 case GL_UNSIGNED_BYTE:
4980 case GL_SHORT:
4981 case GL_UNSIGNED_SHORT:
4982 case GL_FIXED:
4983 case GL_FLOAT:
4984 break;
4985
4986 case GL_HALF_FLOAT:
4987 case GL_INT:
4988 case GL_UNSIGNED_INT:
4989 case GL_INT_2_10_10_10_REV:
4990 case GL_UNSIGNED_INT_2_10_10_10_REV:
4991 if (context->getClientVersion() < 3)
4992 {
4993 context->recordError(gl::Error(GL_INVALID_ENUM));
4994 return;
4995 }
4996 break;
4997
4998 default:
4999 context->recordError(gl::Error(GL_INVALID_ENUM));
5000 return;
5001 }
5002
5003 if (stride < 0)
5004 {
5005 context->recordError(gl::Error(GL_INVALID_VALUE));
5006 return;
5007 }
5008
5009 if ((type == GL_INT_2_10_10_10_REV || type == GL_UNSIGNED_INT_2_10_10_10_REV) && size != 4)
5010 {
5011 context->recordError(gl::Error(GL_INVALID_OPERATION));
5012 return;
5013 }
5014
Geoff Langbfdea662014-07-23 14:16:32 -04005015 // [OpenGL ES 3.0.2] Section 2.8 page 24:
5016 // An INVALID_OPERATION error is generated when a non-zero vertex array object
5017 // is bound, zero is bound to the ARRAY_BUFFER buffer object binding point,
5018 // and the pointer argument is not NULL.
5019 if (context->getState().getVertexArray()->id() != 0 && context->getState().getArrayBufferId() == 0 && ptr != NULL)
shannon.woods%transgaming.com@gtempaccount.com1ab57be2013-04-13 03:38:39 +00005020 {
Geoff Langb1196682014-07-23 13:47:29 -04005021 context->recordError(gl::Error(GL_INVALID_OPERATION));
5022 return;
shannon.woods%transgaming.com@gtempaccount.com1ab57be2013-04-13 03:38:39 +00005023 }
5024
Geoff Langbfdea662014-07-23 14:16:32 -04005025 context->getState().setVertexAttribState(index, context->getState().getTargetBuffer(GL_ARRAY_BUFFER), size, type,
5026 normalized == GL_TRUE, false, stride, ptr);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005027 }
5028}
5029
Kenneth Russell67ea1902014-10-06 16:44:50 -07005030void GL_APIENTRY glViewport(GLint x, GLint y, GLsizei width, GLsizei height)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005031{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00005032 EVENT("(GLint x = %d, GLint y = %d, GLsizei width = %d, GLsizei height = %d)", x, y, width, height);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005033
Geoff Langbfdea662014-07-23 14:16:32 -04005034 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04005035 if (context)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005036 {
Geoff Langb1196682014-07-23 13:47:29 -04005037 if (width < 0 || height < 0)
5038 {
5039 context->recordError(gl::Error(GL_INVALID_VALUE));
5040 return;
5041 }
5042
Geoff Langbfdea662014-07-23 14:16:32 -04005043 context->getState().setViewportParams(x, y, width, height);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005044 }
5045}
5046
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005047// OpenGL ES 3.0 functions
5048
Kenneth Russell67ea1902014-10-06 16:44:50 -07005049void GL_APIENTRY glReadBuffer(GLenum mode)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005050{
5051 EVENT("(GLenum mode = 0x%X)", mode);
5052
Geoff Langbfdea662014-07-23 14:16:32 -04005053 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04005054 if (context)
5055 {
5056 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005057 {
Geoff Langb1196682014-07-23 13:47:29 -04005058 context->recordError(gl::Error(GL_INVALID_OPERATION));
5059 return;
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00005060 }
Geoff Langbfdea662014-07-23 14:16:32 -04005061
5062 // glReadBuffer
5063 UNIMPLEMENTED();
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005064 }
5065}
5066
Kenneth Russell67ea1902014-10-06 16:44:50 -07005067void GL_APIENTRY glDrawRangeElements(GLenum mode, GLuint start, GLuint end, GLsizei count, GLenum type, const GLvoid* indices)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005068{
5069 EVENT("(GLenum mode = 0x%X, GLuint start = %u, GLuint end = %u, GLsizei count = %d, GLenum type = 0x%X, "
5070 "const GLvoid* indices = 0x%0.8p)", mode, start, end, count, type, indices);
5071
Geoff Langbfdea662014-07-23 14:16:32 -04005072 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04005073 if (context)
5074 {
5075 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005076 {
Geoff Langb1196682014-07-23 13:47:29 -04005077 context->recordError(gl::Error(GL_INVALID_OPERATION));
5078 return;
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00005079 }
Geoff Langbfdea662014-07-23 14:16:32 -04005080
5081 // glDrawRangeElements
5082 UNIMPLEMENTED();
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005083 }
5084}
5085
Kenneth Russell67ea1902014-10-06 16:44:50 -07005086void GL_APIENTRY glTexImage3D(GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const GLvoid* pixels)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005087{
5088 EVENT("(GLenum target = 0x%X, GLint level = %d, GLint internalformat = %d, GLsizei width = %d, "
5089 "GLsizei height = %d, GLsizei depth = %d, GLint border = %d, GLenum format = 0x%X, "
5090 "GLenum type = 0x%X, const GLvoid* pixels = 0x%0.8p)",
5091 target, level, internalformat, width, height, depth, border, format, type, pixels);
5092
Geoff Langbfdea662014-07-23 14:16:32 -04005093 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04005094 if (context)
5095 {
5096 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005097 {
Geoff Langb1196682014-07-23 13:47:29 -04005098 context->recordError(gl::Error(GL_INVALID_OPERATION));
5099 return;
shannon.woods%transgaming.com@gtempaccount.com875994b2013-04-13 03:45:17 +00005100 }
Geoff Langbfdea662014-07-23 14:16:32 -04005101
5102 // validateES3TexImageFormat sets the error code if there is an error
5103 if (!ValidateES3TexImageParameters(context, target, level, internalformat, false, false,
5104 0, 0, 0, width, height, depth, border, format, type, pixels))
5105 {
5106 return;
5107 }
5108
5109 switch(target)
5110 {
5111 case GL_TEXTURE_3D:
5112 {
5113 gl::Texture3D *texture = context->getTexture3D();
Geoff Lang1ba6b8d2014-08-28 10:57:31 -04005114 gl::Error error = texture->setImage(level, width, height, depth, internalformat, format, type, context->getState().getUnpackState(), pixels);
5115 if (error.isError())
5116 {
5117 context->recordError(error);
5118 return;
5119 }
Geoff Langbfdea662014-07-23 14:16:32 -04005120 }
5121 break;
5122
5123 case GL_TEXTURE_2D_ARRAY:
5124 {
5125 gl::Texture2DArray *texture = context->getTexture2DArray();
Geoff Lang1ba6b8d2014-08-28 10:57:31 -04005126 gl::Error error = texture->setImage(level, width, height, depth, internalformat, format, type, context->getState().getUnpackState(), pixels);
5127 if (error.isError())
5128 {
5129 context->recordError(error);
5130 return;
5131 }
Geoff Langbfdea662014-07-23 14:16:32 -04005132 }
5133 break;
5134
5135 default:
Geoff Langb1196682014-07-23 13:47:29 -04005136 context->recordError(gl::Error(GL_INVALID_ENUM));
5137 return;
Geoff Langbfdea662014-07-23 14:16:32 -04005138 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005139 }
5140}
5141
Kenneth Russell67ea1902014-10-06 16:44:50 -07005142void GL_APIENTRY glTexSubImage3D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const GLvoid* pixels)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005143{
5144 EVENT("(GLenum target = 0x%X, GLint level = %d, GLint xoffset = %d, GLint yoffset = %d, "
5145 "GLint zoffset = %d, GLsizei width = %d, GLsizei height = %d, GLsizei depth = %d, "
5146 "GLenum format = 0x%X, GLenum type = 0x%X, const GLvoid* pixels = 0x%0.8p)",
5147 target, level, xoffset, yoffset, zoffset, width, height, depth, format, type, pixels);
5148
Geoff Langbfdea662014-07-23 14:16:32 -04005149 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04005150 if (context)
5151 {
5152 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005153 {
Geoff Langb1196682014-07-23 13:47:29 -04005154 context->recordError(gl::Error(GL_INVALID_OPERATION));
5155 return;
shannon.woods%transgaming.com@gtempaccount.com875994b2013-04-13 03:45:17 +00005156 }
Geoff Langbfdea662014-07-23 14:16:32 -04005157
5158 // validateES3TexImageFormat sets the error code if there is an error
5159 if (!ValidateES3TexImageParameters(context, target, level, GL_NONE, false, true,
5160 xoffset, yoffset, zoffset, width, height, depth, 0,
5161 format, type, pixels))
5162 {
5163 return;
5164 }
5165
5166 // Zero sized uploads are valid but no-ops
5167 if (width == 0 || height == 0 || depth == 0)
5168 {
5169 return;
5170 }
5171
5172 switch(target)
5173 {
5174 case GL_TEXTURE_3D:
5175 {
5176 gl::Texture3D *texture = context->getTexture3D();
Geoff Lang1ba6b8d2014-08-28 10:57:31 -04005177 gl::Error error = texture->subImage(level, xoffset, yoffset, zoffset, width, height, depth, format, type, context->getState().getUnpackState(), pixels);
5178 if (error.isError())
5179 {
5180 context->recordError(error);
5181 return;
5182 }
Geoff Langbfdea662014-07-23 14:16:32 -04005183 }
5184 break;
5185
5186 case GL_TEXTURE_2D_ARRAY:
5187 {
5188 gl::Texture2DArray *texture = context->getTexture2DArray();
Geoff Lang1ba6b8d2014-08-28 10:57:31 -04005189 gl::Error error = texture->subImage(level, xoffset, yoffset, zoffset, width, height, depth, format, type, context->getState().getUnpackState(), pixels);
5190 if (error.isError())
5191 {
5192 context->recordError(error);
5193 return;
5194 }
Geoff Langbfdea662014-07-23 14:16:32 -04005195 }
5196 break;
5197
5198 default:
Geoff Langb1196682014-07-23 13:47:29 -04005199 context->recordError(gl::Error(GL_INVALID_ENUM));
5200 return;
Geoff Langbfdea662014-07-23 14:16:32 -04005201 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005202 }
5203}
5204
Kenneth Russell67ea1902014-10-06 16:44:50 -07005205void GL_APIENTRY glCopyTexSubImage3D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005206{
5207 EVENT("(GLenum target = 0x%X, GLint level = %d, GLint xoffset = %d, GLint yoffset = %d, "
5208 "GLint zoffset = %d, GLint x = %d, GLint y = %d, GLsizei width = %d, GLsizei height = %d)",
5209 target, level, xoffset, yoffset, zoffset, x, y, width, height);
5210
Geoff Langbfdea662014-07-23 14:16:32 -04005211 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04005212 if (context)
5213 {
5214 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005215 {
Geoff Langb1196682014-07-23 13:47:29 -04005216 context->recordError(gl::Error(GL_INVALID_OPERATION));
5217 return;
shannon.woods%transgaming.com@gtempaccount.com875994b2013-04-13 03:45:17 +00005218 }
Geoff Langbfdea662014-07-23 14:16:32 -04005219
5220 if (!ValidateES3CopyTexImageParameters(context, target, level, GL_NONE, true, xoffset, yoffset, zoffset,
5221 x, y, width, height, 0))
5222 {
5223 return;
5224 }
5225
5226 gl::Framebuffer *framebuffer = context->getState().getReadFramebuffer();
5227 gl::Texture *texture = NULL;
5228 switch (target)
5229 {
5230 case GL_TEXTURE_3D:
5231 texture = context->getTexture3D();
5232 break;
5233
5234 case GL_TEXTURE_2D_ARRAY:
5235 texture = context->getTexture2DArray();
5236 break;
5237
5238 default:
Geoff Langb1196682014-07-23 13:47:29 -04005239 context->recordError(gl::Error(GL_INVALID_ENUM));
5240 return;
Geoff Langbfdea662014-07-23 14:16:32 -04005241 }
5242
Geoff Langef7b0162014-09-04 13:29:23 -04005243 gl::Error error = texture->copySubImage(target, level, xoffset, yoffset, zoffset, x, y, width, height, framebuffer);
5244 if (error.isError())
5245 {
5246 context->recordError(error);
5247 return;
5248 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005249 }
5250}
5251
Kenneth Russell67ea1902014-10-06 16:44:50 -07005252void GL_APIENTRY glCompressedTexImage3D(GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLsizei imageSize, const GLvoid* data)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005253{
Geoff Langeef52cc2013-10-16 15:07:39 -04005254 EVENT("(GLenum target = 0x%X, GLint level = %d, GLenum internalformat = 0x%X, GLsizei width = %d, "
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005255 "GLsizei height = %d, GLsizei depth = %d, GLint border = %d, GLsizei imageSize = %d, "
5256 "const GLvoid* data = 0x%0.8p)",
5257 target, level, internalformat, width, height, depth, border, imageSize, data);
5258
Geoff Langbfdea662014-07-23 14:16:32 -04005259 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04005260 if (context)
5261 {
5262 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005263 {
Geoff Langb1196682014-07-23 13:47:29 -04005264 context->recordError(gl::Error(GL_INVALID_OPERATION));
5265 return;
shannon.woods%transgaming.com@gtempaccount.com875994b2013-04-13 03:45:17 +00005266 }
Geoff Langbfdea662014-07-23 14:16:32 -04005267
Geoff Lang5d601382014-07-22 15:14:06 -04005268 const gl::InternalFormat &formatInfo = gl::GetInternalFormatInfo(internalformat);
5269 if (imageSize < 0 || static_cast<GLuint>(imageSize) != formatInfo.computeBlockSize(GL_UNSIGNED_BYTE, width, height))
Geoff Langbfdea662014-07-23 14:16:32 -04005270 {
Geoff Langb1196682014-07-23 13:47:29 -04005271 context->recordError(gl::Error(GL_INVALID_VALUE));
5272 return;
Geoff Langbfdea662014-07-23 14:16:32 -04005273 }
5274
5275 // validateES3TexImageFormat sets the error code if there is an error
5276 if (!ValidateES3TexImageParameters(context, target, level, internalformat, true, false,
5277 0, 0, 0, width, height, depth, border, GL_NONE, GL_NONE, data))
5278 {
5279 return;
5280 }
5281
5282 switch(target)
5283 {
5284 case GL_TEXTURE_3D:
5285 {
5286 gl::Texture3D *texture = context->getTexture3D();
Geoff Langb5348332014-09-02 13:16:34 -04005287 gl::Error error = texture->setCompressedImage(level, internalformat, width, height, depth, imageSize, data);
5288 if (error.isError())
5289 {
5290 context->recordError(error);
5291 return;
5292 }
Geoff Langbfdea662014-07-23 14:16:32 -04005293 }
5294 break;
5295
5296 case GL_TEXTURE_2D_ARRAY:
5297 {
5298 gl::Texture2DArray *texture = context->getTexture2DArray();
Geoff Langb5348332014-09-02 13:16:34 -04005299 gl::Error error = texture->setCompressedImage(level, internalformat, width, height, depth, imageSize, data);
5300 if (error.isError())
5301 {
5302 context->recordError(error);
5303 return;
5304 }
Geoff Langbfdea662014-07-23 14:16:32 -04005305 }
5306 break;
5307
5308 default:
Geoff Langb1196682014-07-23 13:47:29 -04005309 context->recordError(gl::Error(GL_INVALID_ENUM));
5310 return;
Geoff Langbfdea662014-07-23 14:16:32 -04005311 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005312 }
5313}
5314
Kenneth Russell67ea1902014-10-06 16:44:50 -07005315void GL_APIENTRY glCompressedTexSubImage3D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const GLvoid* data)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005316{
5317 EVENT("(GLenum target = 0x%X, GLint level = %d, GLint xoffset = %d, GLint yoffset = %d, "
5318 "GLint zoffset = %d, GLsizei width = %d, GLsizei height = %d, GLsizei depth = %d, "
5319 "GLenum format = 0x%X, GLsizei imageSize = %d, const GLvoid* data = 0x%0.8p)",
5320 target, level, xoffset, yoffset, zoffset, width, height, depth, format, imageSize, data);
5321
Geoff Langbfdea662014-07-23 14:16:32 -04005322 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04005323 if (context)
5324 {
5325 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005326 {
Geoff Langb1196682014-07-23 13:47:29 -04005327 context->recordError(gl::Error(GL_INVALID_OPERATION));
5328 return;
shannon.woods%transgaming.com@gtempaccount.com875994b2013-04-13 03:45:17 +00005329 }
Geoff Langbfdea662014-07-23 14:16:32 -04005330
Geoff Lang5d601382014-07-22 15:14:06 -04005331 const gl::InternalFormat &formatInfo = gl::GetInternalFormatInfo(format);
5332 if (imageSize < 0 || static_cast<GLuint>(imageSize) != formatInfo.computeBlockSize(GL_UNSIGNED_BYTE, width, height))
Geoff Langbfdea662014-07-23 14:16:32 -04005333 {
Geoff Langb1196682014-07-23 13:47:29 -04005334 context->recordError(gl::Error(GL_INVALID_VALUE));
5335 return;
Geoff Langbfdea662014-07-23 14:16:32 -04005336 }
5337
5338 if (!data)
5339 {
Geoff Langb1196682014-07-23 13:47:29 -04005340 context->recordError(gl::Error(GL_INVALID_VALUE));
5341 return;
Geoff Langbfdea662014-07-23 14:16:32 -04005342 }
5343
5344 // validateES3TexImageFormat sets the error code if there is an error
5345 if (!ValidateES3TexImageParameters(context, target, level, GL_NONE, true, true,
5346 0, 0, 0, width, height, depth, 0, GL_NONE, GL_NONE, data))
5347 {
5348 return;
5349 }
5350
5351 // Zero sized uploads are valid but no-ops
5352 if (width == 0 || height == 0)
5353 {
5354 return;
5355 }
5356
5357 switch(target)
5358 {
5359 case GL_TEXTURE_3D:
5360 {
5361 gl::Texture3D *texture = context->getTexture3D();
Geoff Langb5348332014-09-02 13:16:34 -04005362 gl::Error error = texture->subImageCompressed(level, xoffset, yoffset, zoffset, width, height, depth,
5363 format, imageSize, data);
5364 if (error.isError())
5365 {
5366 context->recordError(error);
5367 return;
5368 }
Geoff Langbfdea662014-07-23 14:16:32 -04005369 }
5370 break;
5371
5372 case GL_TEXTURE_2D_ARRAY:
5373 {
5374 gl::Texture2DArray *texture = context->getTexture2DArray();
Geoff Langb5348332014-09-02 13:16:34 -04005375 gl::Error error = texture->subImageCompressed(level, xoffset, yoffset, zoffset, width, height, depth,
5376 format, imageSize, data);
5377 if (error.isError())
5378 {
5379 context->recordError(error);
5380 return;
5381 }
Geoff Langbfdea662014-07-23 14:16:32 -04005382 }
5383 break;
5384
Geoff Langb1196682014-07-23 13:47:29 -04005385 default:
5386 context->recordError(gl::Error(GL_INVALID_ENUM));
5387 return;
Geoff Langbfdea662014-07-23 14:16:32 -04005388 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005389 }
5390}
5391
Kenneth Russell67ea1902014-10-06 16:44:50 -07005392void GL_APIENTRY glGenQueries(GLsizei n, GLuint* ids)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005393{
5394 EVENT("(GLsizei n = %d, GLuint* ids = 0x%0.8p)", n, ids);
5395
Geoff Langbfdea662014-07-23 14:16:32 -04005396 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04005397 if (context)
5398 {
5399 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005400 {
Geoff Langb1196682014-07-23 13:47:29 -04005401 context->recordError(gl::Error(GL_INVALID_OPERATION));
5402 return;
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00005403 }
Geoff Langbfdea662014-07-23 14:16:32 -04005404
5405 if (n < 0)
5406 {
Geoff Langb1196682014-07-23 13:47:29 -04005407 context->recordError(gl::Error(GL_INVALID_VALUE));
5408 return;
Geoff Langbfdea662014-07-23 14:16:32 -04005409 }
5410
5411 for (GLsizei i = 0; i < n; i++)
5412 {
5413 ids[i] = context->createQuery();
5414 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005415 }
5416}
5417
Kenneth Russell67ea1902014-10-06 16:44:50 -07005418void GL_APIENTRY glDeleteQueries(GLsizei n, const GLuint* ids)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005419{
5420 EVENT("(GLsizei n = %d, GLuint* ids = 0x%0.8p)", n, ids);
5421
Geoff Langbfdea662014-07-23 14:16:32 -04005422 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04005423 if (context)
5424 {
5425 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005426 {
Geoff Langb1196682014-07-23 13:47:29 -04005427 context->recordError(gl::Error(GL_INVALID_OPERATION));
5428 return;
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00005429 }
Geoff Langbfdea662014-07-23 14:16:32 -04005430
5431 if (n < 0)
5432 {
Geoff Langb1196682014-07-23 13:47:29 -04005433 context->recordError(gl::Error(GL_INVALID_VALUE));
5434 return;
Geoff Langbfdea662014-07-23 14:16:32 -04005435 }
5436
5437 for (GLsizei i = 0; i < n; i++)
5438 {
5439 context->deleteQuery(ids[i]);
5440 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005441 }
5442}
5443
Kenneth Russell67ea1902014-10-06 16:44:50 -07005444GLboolean GL_APIENTRY glIsQuery(GLuint id)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005445{
5446 EVENT("(GLuint id = %u)", id);
5447
Geoff Langbfdea662014-07-23 14:16:32 -04005448 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04005449 if (context)
5450 {
5451 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005452 {
Geoff Langb1196682014-07-23 13:47:29 -04005453 context->recordError(gl::Error(GL_INVALID_OPERATION));
5454 return GL_FALSE;
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00005455 }
Geoff Langbfdea662014-07-23 14:16:32 -04005456
5457 return (context->getQuery(id, false, GL_NONE) != NULL) ? GL_TRUE : GL_FALSE;
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005458 }
5459
5460 return GL_FALSE;
5461}
5462
Kenneth Russell67ea1902014-10-06 16:44:50 -07005463void GL_APIENTRY glBeginQuery(GLenum target, GLuint id)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005464{
5465 EVENT("(GLenum target = 0x%X, GLuint id = %u)", target, id);
5466
Geoff Langbfdea662014-07-23 14:16:32 -04005467 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04005468 if (context)
5469 {
5470 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005471 {
Geoff Langb1196682014-07-23 13:47:29 -04005472 context->recordError(gl::Error(GL_INVALID_OPERATION));
5473 return;
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00005474 }
Geoff Langbfdea662014-07-23 14:16:32 -04005475
5476 if (!ValidateBeginQuery(context, target, id))
5477 {
5478 return;
5479 }
Geoff Lang5aad9672014-09-08 11:10:42 -04005480
5481 gl::Error error = context->beginQuery(target, id);
5482 if (error.isError())
5483 {
5484 context->recordError(error);
5485 return;
5486 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005487 }
5488}
5489
Kenneth Russell67ea1902014-10-06 16:44:50 -07005490void GL_APIENTRY glEndQuery(GLenum target)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005491{
5492 EVENT("(GLenum target = 0x%X)", target);
5493
Geoff Langbfdea662014-07-23 14:16:32 -04005494 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04005495 if (context)
5496 {
5497 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005498 {
Geoff Langb1196682014-07-23 13:47:29 -04005499 context->recordError(gl::Error(GL_INVALID_OPERATION));
5500 return;
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00005501 }
Geoff Langbfdea662014-07-23 14:16:32 -04005502
5503 if (!ValidateEndQuery(context, target))
5504 {
5505 return;
5506 }
5507
Geoff Lang5aad9672014-09-08 11:10:42 -04005508 gl::Error error = context->endQuery(target);
5509 if (error.isError())
5510 {
5511 context->recordError(error);
5512 return;
5513 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005514 }
5515}
5516
Kenneth Russell67ea1902014-10-06 16:44:50 -07005517void GL_APIENTRY glGetQueryiv(GLenum target, GLenum pname, GLint* params)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005518{
5519 EVENT("(GLenum target = 0x%X, GLenum pname = 0x%X, GLint* params = 0x%0.8p)", target, pname, params);
5520
Geoff Langbfdea662014-07-23 14:16:32 -04005521 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04005522 if (context)
5523 {
5524 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005525 {
Geoff Langb1196682014-07-23 13:47:29 -04005526 context->recordError(gl::Error(GL_INVALID_OPERATION));
5527 return;
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00005528 }
Geoff Langbfdea662014-07-23 14:16:32 -04005529
5530 if (!ValidQueryType(context, target))
5531 {
Geoff Langb1196682014-07-23 13:47:29 -04005532 context->recordError(gl::Error(GL_INVALID_ENUM));
5533 return;
Geoff Langbfdea662014-07-23 14:16:32 -04005534 }
5535
5536 switch (pname)
5537 {
5538 case GL_CURRENT_QUERY:
5539 params[0] = static_cast<GLint>(context->getState().getActiveQueryId(target));
5540 break;
5541
5542 default:
Geoff Langb1196682014-07-23 13:47:29 -04005543 context->recordError(gl::Error(GL_INVALID_ENUM));
5544 return;
Geoff Langbfdea662014-07-23 14:16:32 -04005545 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005546 }
5547}
5548
Kenneth Russell67ea1902014-10-06 16:44:50 -07005549void GL_APIENTRY glGetQueryObjectuiv(GLuint id, GLenum pname, GLuint* params)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005550{
5551 EVENT("(GLuint id = %u, GLenum pname = 0x%X, GLint* params = 0x%0.8p)", id, pname, params);
5552
Geoff Langbfdea662014-07-23 14:16:32 -04005553 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04005554 if (context)
5555 {
5556 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005557 {
Geoff Langb1196682014-07-23 13:47:29 -04005558 context->recordError(gl::Error(GL_INVALID_OPERATION));
5559 return;
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00005560 }
Geoff Langbfdea662014-07-23 14:16:32 -04005561
5562 gl::Query *queryObject = context->getQuery(id, false, GL_NONE);
5563
5564 if (!queryObject)
5565 {
Geoff Langb1196682014-07-23 13:47:29 -04005566 context->recordError(gl::Error(GL_INVALID_OPERATION));
5567 return;
Geoff Langbfdea662014-07-23 14:16:32 -04005568 }
5569
5570 if (context->getState().getActiveQueryId(queryObject->getType()) == id)
5571 {
Geoff Langb1196682014-07-23 13:47:29 -04005572 context->recordError(gl::Error(GL_INVALID_OPERATION));
5573 return;
Geoff Langbfdea662014-07-23 14:16:32 -04005574 }
5575
5576 switch(pname)
5577 {
Geoff Lang5aad9672014-09-08 11:10:42 -04005578 case GL_QUERY_RESULT_EXT:
5579 {
5580 gl::Error error = queryObject->getResult(params);
5581 if (error.isError())
5582 {
5583 context->recordError(error);
5584 return;
5585 }
5586 }
Geoff Langbfdea662014-07-23 14:16:32 -04005587 break;
Geoff Langb1196682014-07-23 13:47:29 -04005588
Geoff Lang5aad9672014-09-08 11:10:42 -04005589 case GL_QUERY_RESULT_AVAILABLE_EXT:
5590 {
5591 gl::Error error = queryObject->isResultAvailable(params);
5592 if (error.isError())
5593 {
5594 context->recordError(error);
5595 return;
5596 }
5597 }
Geoff Langbfdea662014-07-23 14:16:32 -04005598 break;
Geoff Langb1196682014-07-23 13:47:29 -04005599
Geoff Langbfdea662014-07-23 14:16:32 -04005600 default:
Geoff Langb1196682014-07-23 13:47:29 -04005601 context->recordError(gl::Error(GL_INVALID_ENUM));
5602 return;
Geoff Langbfdea662014-07-23 14:16:32 -04005603 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005604 }
5605}
5606
Kenneth Russell67ea1902014-10-06 16:44:50 -07005607GLboolean GL_APIENTRY glUnmapBuffer(GLenum target)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005608{
5609 EVENT("(GLenum target = 0x%X)", target);
5610
Geoff Langbfdea662014-07-23 14:16:32 -04005611 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04005612 if (context)
5613 {
5614 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005615 {
Geoff Langb1196682014-07-23 13:47:29 -04005616 context->recordError(gl::Error(GL_INVALID_OPERATION));
5617 return GL_FALSE;
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00005618 }
Geoff Langbfdea662014-07-23 14:16:32 -04005619
5620 return glUnmapBufferOES(target);
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005621 }
5622
5623 return GL_FALSE;
5624}
5625
Kenneth Russell67ea1902014-10-06 16:44:50 -07005626void GL_APIENTRY glGetBufferPointerv(GLenum target, GLenum pname, GLvoid** params)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005627{
5628 EVENT("(GLenum target = 0x%X, GLenum pname = 0x%X, GLvoid** params = 0x%0.8p)", target, pname, params);
5629
Geoff Langbfdea662014-07-23 14:16:32 -04005630 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04005631 if (context)
5632 {
5633 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005634 {
Geoff Langb1196682014-07-23 13:47:29 -04005635 context->recordError(gl::Error(GL_INVALID_OPERATION));
5636 return;
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00005637 }
Geoff Langbfdea662014-07-23 14:16:32 -04005638
5639 glGetBufferPointervOES(target, pname, params);
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005640 }
5641}
5642
Kenneth Russell67ea1902014-10-06 16:44:50 -07005643void GL_APIENTRY glDrawBuffers(GLsizei n, const GLenum* bufs)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005644{
Geoff Langbfdea662014-07-23 14:16:32 -04005645 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04005646 if (context)
5647 {
5648 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005649 {
Geoff Langb1196682014-07-23 13:47:29 -04005650 context->recordError(gl::Error(GL_INVALID_OPERATION));
5651 return;
shannon.woods%transgaming.com@gtempaccount.com7948c5f2013-04-13 03:38:58 +00005652 }
Geoff Langbfdea662014-07-23 14:16:32 -04005653
5654 glDrawBuffersEXT(n, bufs);
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005655 }
5656}
5657
Kenneth Russell67ea1902014-10-06 16:44:50 -07005658void GL_APIENTRY glUniformMatrix2x3fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005659{
5660 EVENT("(GLint location = %d, GLsizei count = %d, GLboolean transpose = %u, const GLfloat* value = 0x%0.8p)",
5661 location, count, transpose, value);
5662
Geoff Langbfdea662014-07-23 14:16:32 -04005663 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04005664 if (context)
5665 {
5666 if (!ValidateUniformMatrix(context, GL_FLOAT_MAT2x3, location, count, transpose))
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005667 {
Geoff Langbfdea662014-07-23 14:16:32 -04005668 return;
shannon.woods%transgaming.com@gtempaccount.comf1306162013-04-13 03:40:04 +00005669 }
Geoff Langbfdea662014-07-23 14:16:32 -04005670
5671 gl::ProgramBinary *programBinary = context->getState().getCurrentProgramBinary();
5672 programBinary->setUniformMatrix2x3fv(location, count, transpose, value);
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005673 }
5674}
5675
Kenneth Russell67ea1902014-10-06 16:44:50 -07005676void GL_APIENTRY glUniformMatrix3x2fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005677{
5678 EVENT("(GLint location = %d, GLsizei count = %d, GLboolean transpose = %u, const GLfloat* value = 0x%0.8p)",
5679 location, count, transpose, value);
5680
Geoff Langbfdea662014-07-23 14:16:32 -04005681 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04005682 if (context)
5683 {
5684 if (!ValidateUniformMatrix(context, GL_FLOAT_MAT3x2, location, count, transpose))
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005685 {
Geoff Langbfdea662014-07-23 14:16:32 -04005686 return;
shannon.woods%transgaming.com@gtempaccount.comf1306162013-04-13 03:40:04 +00005687 }
Geoff Langbfdea662014-07-23 14:16:32 -04005688
5689 gl::ProgramBinary *programBinary = context->getState().getCurrentProgramBinary();
5690 programBinary->setUniformMatrix3x2fv(location, count, transpose, value);
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005691 }
5692}
5693
Kenneth Russell67ea1902014-10-06 16:44:50 -07005694void GL_APIENTRY glUniformMatrix2x4fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005695{
5696 EVENT("(GLint location = %d, GLsizei count = %d, GLboolean transpose = %u, const GLfloat* value = 0x%0.8p)",
5697 location, count, transpose, value);
5698
Geoff Langbfdea662014-07-23 14:16:32 -04005699 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04005700 if (context)
5701 {
5702 if (!ValidateUniformMatrix(context, GL_FLOAT_MAT2x4, location, count, transpose))
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005703 {
Geoff Langbfdea662014-07-23 14:16:32 -04005704 return;
shannon.woods%transgaming.com@gtempaccount.comf1306162013-04-13 03:40:04 +00005705 }
Geoff Langbfdea662014-07-23 14:16:32 -04005706
5707 gl::ProgramBinary *programBinary = context->getState().getCurrentProgramBinary();
5708 programBinary->setUniformMatrix2x4fv(location, count, transpose, value);
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005709 }
5710}
5711
Kenneth Russell67ea1902014-10-06 16:44:50 -07005712void GL_APIENTRY glUniformMatrix4x2fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005713{
5714 EVENT("(GLint location = %d, GLsizei count = %d, GLboolean transpose = %u, const GLfloat* value = 0x%0.8p)",
5715 location, count, transpose, value);
5716
Geoff Langbfdea662014-07-23 14:16:32 -04005717 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04005718 if (context)
5719 {
5720 if (!ValidateUniformMatrix(context, GL_FLOAT_MAT4x2, location, count, transpose))
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005721 {
Geoff Langbfdea662014-07-23 14:16:32 -04005722 return;
shannon.woods%transgaming.com@gtempaccount.comf1306162013-04-13 03:40:04 +00005723 }
Geoff Langbfdea662014-07-23 14:16:32 -04005724
5725 gl::ProgramBinary *programBinary = context->getState().getCurrentProgramBinary();
5726 programBinary->setUniformMatrix4x2fv(location, count, transpose, value);
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005727 }
5728}
5729
Kenneth Russell67ea1902014-10-06 16:44:50 -07005730void GL_APIENTRY glUniformMatrix3x4fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005731{
5732 EVENT("(GLint location = %d, GLsizei count = %d, GLboolean transpose = %u, const GLfloat* value = 0x%0.8p)",
5733 location, count, transpose, value);
5734
Geoff Langbfdea662014-07-23 14:16:32 -04005735 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04005736 if (context)
5737 {
5738 if (!ValidateUniformMatrix(context, GL_FLOAT_MAT3x4, location, count, transpose))
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005739 {
Geoff Langbfdea662014-07-23 14:16:32 -04005740 return;
shannon.woods%transgaming.com@gtempaccount.comf1306162013-04-13 03:40:04 +00005741 }
Geoff Langbfdea662014-07-23 14:16:32 -04005742
5743 gl::ProgramBinary *programBinary = context->getState().getCurrentProgramBinary();
5744 programBinary->setUniformMatrix3x4fv(location, count, transpose, value);
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005745 }
5746}
5747
Kenneth Russell67ea1902014-10-06 16:44:50 -07005748void GL_APIENTRY glUniformMatrix4x3fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005749{
5750 EVENT("(GLint location = %d, GLsizei count = %d, GLboolean transpose = %u, const GLfloat* value = 0x%0.8p)",
5751 location, count, transpose, value);
5752
Geoff Langbfdea662014-07-23 14:16:32 -04005753 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04005754 if (context)
5755 {
5756 if (!ValidateUniformMatrix(context, GL_FLOAT_MAT4x3, location, count, transpose))
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005757 {
Geoff Langbfdea662014-07-23 14:16:32 -04005758 return;
shannon.woods%transgaming.com@gtempaccount.comf1306162013-04-13 03:40:04 +00005759 }
Geoff Langbfdea662014-07-23 14:16:32 -04005760
5761 gl::ProgramBinary *programBinary = context->getState().getCurrentProgramBinary();
5762 programBinary->setUniformMatrix4x3fv(location, count, transpose, value);
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005763 }
5764}
5765
Kenneth Russell67ea1902014-10-06 16:44:50 -07005766void GL_APIENTRY glBlitFramebuffer(GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, GLbitfield mask, GLenum filter)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005767{
5768 EVENT("(GLint srcX0 = %d, GLint srcY0 = %d, GLint srcX1 = %d, GLint srcY1 = %d, GLint dstX0 = %d, "
5769 "GLint dstY0 = %d, GLint dstX1 = %d, GLint dstY1 = %d, GLbitfield mask = 0x%X, GLenum filter = 0x%X)",
5770 srcX0, srcY0, srcX1, srcY1, dstX0, dstY0, dstX1, dstY1, mask, filter);
5771
Geoff Langbfdea662014-07-23 14:16:32 -04005772 gl::Context *context = gl::getNonLostContext();
5773 if (context)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005774 {
Geoff Langbfdea662014-07-23 14:16:32 -04005775 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005776 {
Geoff Langb1196682014-07-23 13:47:29 -04005777 context->recordError(gl::Error(GL_INVALID_OPERATION));
5778 return;
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00005779 }
Geoff Langbfdea662014-07-23 14:16:32 -04005780
5781 if (!ValidateBlitFramebufferParameters(context, srcX0, srcY0, srcX1, srcY1,
5782 dstX0, dstY0, dstX1, dstY1, mask, filter,
5783 false))
5784 {
5785 return;
5786 }
5787
Geoff Lang64839152014-08-26 16:23:25 -04005788 gl::Error error = context->blitFramebuffer(srcX0, srcY0, srcX1, srcY1, dstX0, dstY0, dstX1, dstY1,
5789 mask, filter);
5790 if (error.isError())
5791 {
5792 context->recordError(error);
5793 return;
5794 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005795 }
5796}
5797
Kenneth Russell67ea1902014-10-06 16:44:50 -07005798void GL_APIENTRY glRenderbufferStorageMultisample(GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005799{
5800 EVENT("(GLenum target = 0x%X, GLsizei samples = %d, GLenum internalformat = 0x%X, GLsizei width = %d, GLsizei height = %d)",
5801 target, samples, internalformat, width, height);
5802
Geoff Langbfdea662014-07-23 14:16:32 -04005803 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04005804 if (context)
5805 {
5806 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005807 {
Geoff Langb1196682014-07-23 13:47:29 -04005808 context->recordError(gl::Error(GL_INVALID_OPERATION));
5809 return;
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00005810 }
Geoff Langbfdea662014-07-23 14:16:32 -04005811
5812 if (!ValidateRenderbufferStorageParameters(context, target, samples, internalformat,
5813 width, height, false))
5814 {
5815 return;
5816 }
5817
5818 context->setRenderbufferStorage(width, height, internalformat, samples);
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005819 }
5820}
5821
Kenneth Russell67ea1902014-10-06 16:44:50 -07005822void GL_APIENTRY glFramebufferTextureLayer(GLenum target, GLenum attachment, GLuint texture, GLint level, GLint layer)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005823{
5824 EVENT("(GLenum target = 0x%X, GLenum attachment = 0x%X, GLuint texture = %u, GLint level = %d, GLint layer = %d)",
5825 target, attachment, texture, level, layer);
5826
Geoff Langbfdea662014-07-23 14:16:32 -04005827 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04005828 if (context)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005829 {
Geoff Langbfdea662014-07-23 14:16:32 -04005830 if (!ValidateFramebufferTextureLayer(context, target, attachment, texture,
5831 level, layer))
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005832 {
Geoff Langbfdea662014-07-23 14:16:32 -04005833 return;
5834 }
Geoff Lang3ed0c482013-07-25 17:03:18 -04005835
Geoff Langbfdea662014-07-23 14:16:32 -04005836 gl::Framebuffer *framebuffer = context->getState().getTargetFramebuffer(target);
5837 ASSERT(framebuffer);
Geoff Lang3ed0c482013-07-25 17:03:18 -04005838
Geoff Langbfdea662014-07-23 14:16:32 -04005839 gl::Texture *textureObject = context->getTexture(texture);
5840 GLenum textarget = textureObject ? textureObject->getTarget() : GL_NONE;
Geoff Lang3ed0c482013-07-25 17:03:18 -04005841
Geoff Langbfdea662014-07-23 14:16:32 -04005842 if (attachment >= GL_COLOR_ATTACHMENT0_EXT && attachment <= GL_COLOR_ATTACHMENT15_EXT)
5843 {
5844 const unsigned int colorAttachment = (attachment - GL_COLOR_ATTACHMENT0_EXT);
5845 framebuffer->setColorbuffer(colorAttachment, textarget, texture, level, layer);
5846 }
5847 else
5848 {
5849 switch (attachment)
Geoff Lang3ed0c482013-07-25 17:03:18 -04005850 {
Geoff Langbfdea662014-07-23 14:16:32 -04005851 case GL_DEPTH_ATTACHMENT: framebuffer->setDepthbuffer(textarget, texture, level, layer); break;
5852 case GL_STENCIL_ATTACHMENT: framebuffer->setStencilbuffer(textarget, texture, level, layer); break;
5853 case GL_DEPTH_STENCIL_ATTACHMENT: framebuffer->setDepthStencilBuffer(textarget, texture, level, layer); break;
Geoff Lang3ed0c482013-07-25 17:03:18 -04005854 }
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00005855 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005856 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005857}
5858
Kenneth Russell67ea1902014-10-06 16:44:50 -07005859GLvoid* GL_APIENTRY glMapBufferRange(GLenum target, GLintptr offset, GLsizeiptr length, GLbitfield access)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005860{
5861 EVENT("(GLenum target = 0x%X, GLintptr offset = %d, GLsizeiptr length = %d, GLbitfield access = 0x%X)",
5862 target, offset, length, access);
5863
Geoff Langbfdea662014-07-23 14:16:32 -04005864 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04005865 if (context)
5866 {
5867 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005868 {
Geoff Langb1196682014-07-23 13:47:29 -04005869 context->recordError(gl::Error(GL_INVALID_OPERATION));
5870 return NULL;
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00005871 }
Geoff Langbfdea662014-07-23 14:16:32 -04005872
5873 return glMapBufferRangeEXT(target, offset, length, access);
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005874 }
5875
5876 return NULL;
5877}
5878
Kenneth Russell67ea1902014-10-06 16:44:50 -07005879void GL_APIENTRY glFlushMappedBufferRange(GLenum target, GLintptr offset, GLsizeiptr length)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005880{
5881 EVENT("(GLenum target = 0x%X, GLintptr offset = %d, GLsizeiptr length = %d)", target, offset, length);
5882
Geoff Langbfdea662014-07-23 14:16:32 -04005883 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04005884 if (context)
5885 {
5886 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005887 {
Geoff Langb1196682014-07-23 13:47:29 -04005888 context->recordError(gl::Error(GL_INVALID_OPERATION));
5889 return;
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00005890 }
Geoff Langbfdea662014-07-23 14:16:32 -04005891
5892 glFlushMappedBufferRangeEXT(target, offset, length);
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005893 }
5894}
5895
Kenneth Russell67ea1902014-10-06 16:44:50 -07005896void GL_APIENTRY glBindVertexArray(GLuint array)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005897{
5898 EVENT("(GLuint array = %u)", array);
5899
Geoff Langbfdea662014-07-23 14:16:32 -04005900 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04005901 if (context)
5902 {
5903 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005904 {
Geoff Langb1196682014-07-23 13:47:29 -04005905 context->recordError(gl::Error(GL_INVALID_OPERATION));
5906 return;
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00005907 }
Geoff Langbfdea662014-07-23 14:16:32 -04005908
5909 gl::VertexArray *vao = context->getVertexArray(array);
5910
5911 if (!vao)
5912 {
5913 // The default VAO should always exist
5914 ASSERT(array != 0);
Geoff Langb1196682014-07-23 13:47:29 -04005915 context->recordError(gl::Error(GL_INVALID_OPERATION));
5916 return;
Geoff Langbfdea662014-07-23 14:16:32 -04005917 }
5918
5919 context->bindVertexArray(array);
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005920 }
5921}
5922
Kenneth Russell67ea1902014-10-06 16:44:50 -07005923void GL_APIENTRY glDeleteVertexArrays(GLsizei n, const GLuint* arrays)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005924{
5925 EVENT("(GLsizei n = %d, const GLuint* arrays = 0x%0.8p)", n, arrays);
5926
Geoff Langbfdea662014-07-23 14:16:32 -04005927 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04005928 if (context)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005929 {
Geoff Langbfdea662014-07-23 14:16:32 -04005930 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005931 {
Geoff Langb1196682014-07-23 13:47:29 -04005932 context->recordError(gl::Error(GL_INVALID_OPERATION));
5933 return;
Geoff Langbfdea662014-07-23 14:16:32 -04005934 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005935
Geoff Langbfdea662014-07-23 14:16:32 -04005936 if (n < 0)
5937 {
Geoff Langb1196682014-07-23 13:47:29 -04005938 context->recordError(gl::Error(GL_INVALID_VALUE));
5939 return;
Geoff Langbfdea662014-07-23 14:16:32 -04005940 }
Jamie Madilld1028542013-07-02 11:57:04 -04005941
Geoff Langbfdea662014-07-23 14:16:32 -04005942 for (int arrayIndex = 0; arrayIndex < n; arrayIndex++)
5943 {
5944 if (arrays[arrayIndex] != 0)
Jamie Madilld1028542013-07-02 11:57:04 -04005945 {
Geoff Langbfdea662014-07-23 14:16:32 -04005946 context->deleteVertexArray(arrays[arrayIndex]);
Jamie Madilld1028542013-07-02 11:57:04 -04005947 }
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00005948 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005949 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005950}
5951
Kenneth Russell67ea1902014-10-06 16:44:50 -07005952void GL_APIENTRY glGenVertexArrays(GLsizei n, GLuint* arrays)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005953{
5954 EVENT("(GLsizei n = %d, GLuint* arrays = 0x%0.8p)", n, arrays);
5955
Geoff Langbfdea662014-07-23 14:16:32 -04005956 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04005957 if (context)
5958 {
5959 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005960 {
Geoff Langb1196682014-07-23 13:47:29 -04005961 context->recordError(gl::Error(GL_INVALID_OPERATION));
5962 return;
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00005963 }
Geoff Langbfdea662014-07-23 14:16:32 -04005964
5965 if (n < 0)
5966 {
Geoff Langb1196682014-07-23 13:47:29 -04005967 context->recordError(gl::Error(GL_INVALID_VALUE));
5968 return;
Geoff Langbfdea662014-07-23 14:16:32 -04005969 }
5970
5971 for (int arrayIndex = 0; arrayIndex < n; arrayIndex++)
5972 {
5973 arrays[arrayIndex] = context->createVertexArray();
5974 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005975 }
5976}
5977
Kenneth Russell67ea1902014-10-06 16:44:50 -07005978GLboolean GL_APIENTRY glIsVertexArray(GLuint array)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005979{
5980 EVENT("(GLuint array = %u)", array);
5981
Geoff Langbfdea662014-07-23 14:16:32 -04005982 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04005983 if (context)
5984 {
5985 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005986 {
Geoff Langb1196682014-07-23 13:47:29 -04005987 context->recordError(gl::Error(GL_INVALID_OPERATION));
5988 return GL_FALSE;
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00005989 }
Geoff Langbfdea662014-07-23 14:16:32 -04005990
5991 if (array == 0)
5992 {
5993 return GL_FALSE;
5994 }
5995
5996 gl::VertexArray *vao = context->getVertexArray(array);
5997
5998 return (vao != NULL ? GL_TRUE : GL_FALSE);
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005999 }
6000
6001 return GL_FALSE;
6002}
6003
Kenneth Russell67ea1902014-10-06 16:44:50 -07006004void GL_APIENTRY glGetIntegeri_v(GLenum target, GLuint index, GLint* data)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006005{
6006 EVENT("(GLenum target = 0x%X, GLuint index = %u, GLint* data = 0x%0.8p)",
6007 target, index, data);
6008
Geoff Langbfdea662014-07-23 14:16:32 -04006009 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04006010 if (context)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006011 {
Geoff Langbfdea662014-07-23 14:16:32 -04006012 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006013 {
Geoff Langb1196682014-07-23 13:47:29 -04006014 context->recordError(gl::Error(GL_INVALID_OPERATION));
6015 return;
Geoff Langbfdea662014-07-23 14:16:32 -04006016 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006017
Geoff Lang3a61c322014-07-10 13:01:54 -04006018 const gl::Caps &caps = context->getCaps();
Geoff Langbfdea662014-07-23 14:16:32 -04006019 switch (target)
6020 {
6021 case GL_TRANSFORM_FEEDBACK_BUFFER_START:
6022 case GL_TRANSFORM_FEEDBACK_BUFFER_SIZE:
6023 case GL_TRANSFORM_FEEDBACK_BUFFER_BINDING:
Geoff Lang05881a02014-07-10 14:05:30 -04006024 if (index >= caps.maxTransformFeedbackSeparateAttributes)
6025 {
Geoff Langb1196682014-07-23 13:47:29 -04006026 context->recordError(gl::Error(GL_INVALID_VALUE));
6027 return;
Geoff Lang05881a02014-07-10 14:05:30 -04006028 }
Geoff Langbfdea662014-07-23 14:16:32 -04006029 break;
Geoff Langb1196682014-07-23 13:47:29 -04006030
Geoff Langbfdea662014-07-23 14:16:32 -04006031 case GL_UNIFORM_BUFFER_START:
6032 case GL_UNIFORM_BUFFER_SIZE:
6033 case GL_UNIFORM_BUFFER_BINDING:
Geoff Lang3a61c322014-07-10 13:01:54 -04006034 if (index >= caps.maxCombinedUniformBlocks)
6035 {
Geoff Langb1196682014-07-23 13:47:29 -04006036 context->recordError(gl::Error(GL_INVALID_VALUE));
6037 return;
Geoff Lang3a61c322014-07-10 13:01:54 -04006038 }
Geoff Langbfdea662014-07-23 14:16:32 -04006039 break;
Geoff Langb1196682014-07-23 13:47:29 -04006040
Geoff Langbfdea662014-07-23 14:16:32 -04006041 default:
Geoff Langb1196682014-07-23 13:47:29 -04006042 context->recordError(gl::Error(GL_INVALID_ENUM));
6043 return;
Geoff Langbfdea662014-07-23 14:16:32 -04006044 }
6045
6046 if (!(context->getIndexedIntegerv(target, index, data)))
6047 {
6048 GLenum nativeType;
6049 unsigned int numParams = 0;
6050 if (!context->getIndexedQueryParameterInfo(target, &nativeType, &numParams))
Geoff Langb1196682014-07-23 13:47:29 -04006051 {
6052 context->recordError(gl::Error(GL_INVALID_ENUM));
6053 return;
6054 }
Shannon Woods15934d52013-08-19 14:28:49 -04006055
Geoff Langbfdea662014-07-23 14:16:32 -04006056 if (numParams == 0)
Geoff Langb1196682014-07-23 13:47:29 -04006057 {
Geoff Langbfdea662014-07-23 14:16:32 -04006058 return; // it is known that pname is valid, but there are no parameters to return
Geoff Langb1196682014-07-23 13:47:29 -04006059 }
Geoff Langbfdea662014-07-23 14:16:32 -04006060
6061 if (nativeType == GL_INT_64_ANGLEX)
Shannon Woods15934d52013-08-19 14:28:49 -04006062 {
Geoff Langbfdea662014-07-23 14:16:32 -04006063 GLint64 minIntValue = static_cast<GLint64>(std::numeric_limits<int>::min());
6064 GLint64 maxIntValue = static_cast<GLint64>(std::numeric_limits<int>::max());
6065 GLint64 *int64Params = new GLint64[numParams];
Shannon Woods15934d52013-08-19 14:28:49 -04006066
Geoff Langbfdea662014-07-23 14:16:32 -04006067 context->getIndexedInteger64v(target, index, int64Params);
Shannon Woods15934d52013-08-19 14:28:49 -04006068
Geoff Langbfdea662014-07-23 14:16:32 -04006069 for (unsigned int i = 0; i < numParams; ++i)
Shannon Woods15934d52013-08-19 14:28:49 -04006070 {
Geoff Langbfdea662014-07-23 14:16:32 -04006071 GLint64 clampedValue = std::max(std::min(int64Params[i], maxIntValue), minIntValue);
6072 data[i] = static_cast<GLint>(clampedValue);
Shannon Woods15934d52013-08-19 14:28:49 -04006073 }
Geoff Langbfdea662014-07-23 14:16:32 -04006074
6075 delete [] int64Params;
6076 }
6077 else
6078 {
6079 UNREACHABLE();
Shannon Woods15934d52013-08-19 14:28:49 -04006080 }
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00006081 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006082 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006083}
6084
Kenneth Russell67ea1902014-10-06 16:44:50 -07006085void GL_APIENTRY glBeginTransformFeedback(GLenum primitiveMode)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006086{
6087 EVENT("(GLenum primitiveMode = 0x%X)", primitiveMode);
6088
Geoff Langbfdea662014-07-23 14:16:32 -04006089 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04006090 if (context)
6091 {
6092 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006093 {
Geoff Langb1196682014-07-23 13:47:29 -04006094 context->recordError(gl::Error(GL_INVALID_OPERATION));
6095 return;
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00006096 }
Geoff Langbfdea662014-07-23 14:16:32 -04006097
6098 switch (primitiveMode)
6099 {
6100 case GL_TRIANGLES:
6101 case GL_LINES:
6102 case GL_POINTS:
6103 break;
Geoff Langb1196682014-07-23 13:47:29 -04006104
Geoff Langbfdea662014-07-23 14:16:32 -04006105 default:
Geoff Langb1196682014-07-23 13:47:29 -04006106 context->recordError(gl::Error(GL_INVALID_ENUM));
6107 return;
Geoff Langbfdea662014-07-23 14:16:32 -04006108 }
6109
6110 gl::TransformFeedback *transformFeedback = context->getState().getCurrentTransformFeedback();
6111 ASSERT(transformFeedback != NULL);
6112
6113 if (transformFeedback->isStarted())
6114 {
Geoff Langb1196682014-07-23 13:47:29 -04006115 context->recordError(gl::Error(GL_INVALID_OPERATION));
6116 return;
Geoff Langbfdea662014-07-23 14:16:32 -04006117 }
6118
6119 if (transformFeedback->isPaused())
6120 {
6121 transformFeedback->resume();
6122 }
6123 else
6124 {
6125 transformFeedback->start(primitiveMode);
6126 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006127 }
6128}
6129
Kenneth Russell67ea1902014-10-06 16:44:50 -07006130void GL_APIENTRY glEndTransformFeedback(void)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006131{
6132 EVENT("(void)");
6133
Geoff Langbfdea662014-07-23 14:16:32 -04006134 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04006135 if (context)
6136 {
6137 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006138 {
Geoff Langb1196682014-07-23 13:47:29 -04006139 context->recordError(gl::Error(GL_INVALID_OPERATION));
6140 return;
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00006141 }
Geoff Langbfdea662014-07-23 14:16:32 -04006142
6143 gl::TransformFeedback *transformFeedback = context->getState().getCurrentTransformFeedback();
6144 ASSERT(transformFeedback != NULL);
6145
6146 if (!transformFeedback->isStarted())
6147 {
Geoff Langb1196682014-07-23 13:47:29 -04006148 context->recordError(gl::Error(GL_INVALID_OPERATION));
6149 return;
Geoff Langbfdea662014-07-23 14:16:32 -04006150 }
6151
6152 transformFeedback->stop();
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006153 }
6154}
6155
Kenneth Russell67ea1902014-10-06 16:44:50 -07006156void GL_APIENTRY glBindBufferRange(GLenum target, GLuint index, GLuint buffer, GLintptr offset, GLsizeiptr size)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006157{
6158 EVENT("(GLenum target = 0x%X, GLuint index = %u, GLuint buffer = %u, GLintptr offset = %d, GLsizeiptr size = %d)",
6159 target, index, buffer, offset, size);
6160
Geoff Langbfdea662014-07-23 14:16:32 -04006161 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04006162 if (context)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006163 {
Geoff Langbfdea662014-07-23 14:16:32 -04006164 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006165 {
Geoff Langb1196682014-07-23 13:47:29 -04006166 context->recordError(gl::Error(GL_INVALID_OPERATION));
6167 return;
Geoff Langbfdea662014-07-23 14:16:32 -04006168 }
6169
Geoff Lang3a61c322014-07-10 13:01:54 -04006170 const gl::Caps &caps = context->getCaps();
Geoff Langbfdea662014-07-23 14:16:32 -04006171 switch (target)
6172 {
6173 case GL_TRANSFORM_FEEDBACK_BUFFER:
Geoff Lang05881a02014-07-10 14:05:30 -04006174 if (index >= caps.maxTransformFeedbackSeparateAttributes)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006175 {
Geoff Langb1196682014-07-23 13:47:29 -04006176 context->recordError(gl::Error(GL_INVALID_VALUE));
6177 return;
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006178 }
Geoff Langbfdea662014-07-23 14:16:32 -04006179 break;
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006180
Geoff Langbfdea662014-07-23 14:16:32 -04006181 case GL_UNIFORM_BUFFER:
Geoff Lang3a61c322014-07-10 13:01:54 -04006182 if (index >= caps.maxUniformBufferBindings)
shannon.woods%transgaming.com@gtempaccount.comd4e61972013-04-13 03:37:04 +00006183 {
Geoff Langb1196682014-07-23 13:47:29 -04006184 context->recordError(gl::Error(GL_INVALID_VALUE));
6185 return;
shannon.woods%transgaming.com@gtempaccount.comd4e61972013-04-13 03:37:04 +00006186 }
Geoff Langbfdea662014-07-23 14:16:32 -04006187 break;
shannon.woods%transgaming.com@gtempaccount.comd4e61972013-04-13 03:37:04 +00006188
Geoff Langbfdea662014-07-23 14:16:32 -04006189 default:
Geoff Langb1196682014-07-23 13:47:29 -04006190 context->recordError(gl::Error(GL_INVALID_ENUM));
6191 return;
Geoff Langbfdea662014-07-23 14:16:32 -04006192 }
6193
6194 if (buffer != 0 && size <= 0)
6195 {
Geoff Langb1196682014-07-23 13:47:29 -04006196 context->recordError(gl::Error(GL_INVALID_VALUE));
6197 return;
Geoff Langbfdea662014-07-23 14:16:32 -04006198 }
6199
6200 switch (target)
6201 {
6202 case GL_TRANSFORM_FEEDBACK_BUFFER:
6203
6204 // size and offset must be a multiple of 4
6205 if (buffer != 0 && ((offset % 4) != 0 || (size % 4) != 0))
shannon.woods%transgaming.com@gtempaccount.comd4e61972013-04-13 03:37:04 +00006206 {
Geoff Langb1196682014-07-23 13:47:29 -04006207 context->recordError(gl::Error(GL_INVALID_VALUE));
6208 return;
shannon.woods%transgaming.com@gtempaccount.comd4e61972013-04-13 03:37:04 +00006209 }
6210
Geoff Langbfdea662014-07-23 14:16:32 -04006211 context->bindIndexedTransformFeedbackBuffer(buffer, index, offset, size);
6212 context->bindGenericTransformFeedbackBuffer(buffer);
6213 break;
6214
6215 case GL_UNIFORM_BUFFER:
6216
6217 // it is an error to bind an offset not a multiple of the alignment
Geoff Lang3a61c322014-07-10 13:01:54 -04006218 if (buffer != 0 && (offset % caps.uniformBufferOffsetAlignment) != 0)
shannon.woods%transgaming.com@gtempaccount.comd4e61972013-04-13 03:37:04 +00006219 {
Geoff Langb1196682014-07-23 13:47:29 -04006220 context->recordError(gl::Error(GL_INVALID_VALUE));
6221 return;
shannon.woods%transgaming.com@gtempaccount.comd4e61972013-04-13 03:37:04 +00006222 }
Geoff Langbfdea662014-07-23 14:16:32 -04006223
6224 context->bindIndexedUniformBuffer(buffer, index, offset, size);
6225 context->bindGenericUniformBuffer(buffer);
6226 break;
6227
6228 default:
6229 UNREACHABLE();
shannon.woods%transgaming.com@gtempaccount.comd4e61972013-04-13 03:37:04 +00006230 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006231 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006232}
6233
Kenneth Russell67ea1902014-10-06 16:44:50 -07006234void GL_APIENTRY glBindBufferBase(GLenum target, GLuint index, GLuint buffer)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006235{
6236 EVENT("(GLenum target = 0x%X, GLuint index = %u, GLuint buffer = %u)",
6237 target, index, buffer);
6238
Geoff Langbfdea662014-07-23 14:16:32 -04006239 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04006240 if (context)
6241 {
6242 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006243 {
Geoff Langb1196682014-07-23 13:47:29 -04006244 context->recordError(gl::Error(GL_INVALID_OPERATION));
6245 return;
shannon.woods%transgaming.com@gtempaccount.comd4e61972013-04-13 03:37:04 +00006246 }
Geoff Langbfdea662014-07-23 14:16:32 -04006247
Geoff Lang3a61c322014-07-10 13:01:54 -04006248 const gl::Caps &caps = context->getCaps();
Geoff Langbfdea662014-07-23 14:16:32 -04006249 switch (target)
6250 {
6251 case GL_TRANSFORM_FEEDBACK_BUFFER:
Geoff Lang05881a02014-07-10 14:05:30 -04006252 if (index >= caps.maxTransformFeedbackSeparateAttributes)
Geoff Langbfdea662014-07-23 14:16:32 -04006253 {
Geoff Langb1196682014-07-23 13:47:29 -04006254 context->recordError(gl::Error(GL_INVALID_VALUE));
6255 return;
Geoff Langbfdea662014-07-23 14:16:32 -04006256 }
6257 break;
6258
6259 case GL_UNIFORM_BUFFER:
Geoff Lang3a61c322014-07-10 13:01:54 -04006260 if (index >= caps.maxUniformBufferBindings)
Geoff Langbfdea662014-07-23 14:16:32 -04006261 {
Geoff Langb1196682014-07-23 13:47:29 -04006262 context->recordError(gl::Error(GL_INVALID_VALUE));
6263 return;
Geoff Langbfdea662014-07-23 14:16:32 -04006264 }
6265 break;
6266
6267 default:
Geoff Langb1196682014-07-23 13:47:29 -04006268 context->recordError(gl::Error(GL_INVALID_ENUM));
6269 return;
Geoff Langbfdea662014-07-23 14:16:32 -04006270 }
6271
6272 switch (target)
6273 {
6274 case GL_TRANSFORM_FEEDBACK_BUFFER:
6275 context->bindIndexedTransformFeedbackBuffer(buffer, index, 0, 0);
6276 context->bindGenericTransformFeedbackBuffer(buffer);
6277 break;
6278
6279 case GL_UNIFORM_BUFFER:
6280 context->bindIndexedUniformBuffer(buffer, index, 0, 0);
6281 context->bindGenericUniformBuffer(buffer);
6282 break;
6283
6284 default:
6285 UNREACHABLE();
6286 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006287 }
6288}
6289
Kenneth Russell67ea1902014-10-06 16:44:50 -07006290void GL_APIENTRY glTransformFeedbackVaryings(GLuint program, GLsizei count, const GLchar* const* varyings, GLenum bufferMode)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006291{
6292 EVENT("(GLuint program = %u, GLsizei count = %d, const GLchar* const* varyings = 0x%0.8p, GLenum bufferMode = 0x%X)",
6293 program, count, varyings, bufferMode);
6294
Geoff Langbfdea662014-07-23 14:16:32 -04006295 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04006296 if (context)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006297 {
Geoff Langbfdea662014-07-23 14:16:32 -04006298 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006299 {
Geoff Langb1196682014-07-23 13:47:29 -04006300 context->recordError(gl::Error(GL_INVALID_OPERATION));
6301 return;
Geoff Langbfdea662014-07-23 14:16:32 -04006302 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006303
Geoff Langbfdea662014-07-23 14:16:32 -04006304 if (count < 0)
6305 {
Geoff Langb1196682014-07-23 13:47:29 -04006306 context->recordError(gl::Error(GL_INVALID_VALUE));
6307 return;
Geoff Langbfdea662014-07-23 14:16:32 -04006308 }
6309
Geoff Lang05881a02014-07-10 14:05:30 -04006310 const gl::Caps &caps = context->getCaps();
Geoff Langbfdea662014-07-23 14:16:32 -04006311 switch (bufferMode)
6312 {
6313 case GL_INTERLEAVED_ATTRIBS:
6314 break;
6315 case GL_SEPARATE_ATTRIBS:
Geoff Lang05881a02014-07-10 14:05:30 -04006316 if (static_cast<GLuint>(count) > caps.maxTransformFeedbackSeparateAttributes)
Geoff Lang48dcae72014-02-05 16:28:24 -05006317 {
Geoff Langb1196682014-07-23 13:47:29 -04006318 context->recordError(gl::Error(GL_INVALID_VALUE));
6319 return;
Geoff Lang48dcae72014-02-05 16:28:24 -05006320 }
Geoff Langbfdea662014-07-23 14:16:32 -04006321 break;
6322 default:
Geoff Langb1196682014-07-23 13:47:29 -04006323 context->recordError(gl::Error(GL_INVALID_ENUM));
6324 return;
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00006325 }
Geoff Langbfdea662014-07-23 14:16:32 -04006326
6327 if (!gl::ValidProgram(context, program))
6328 {
6329 return;
6330 }
6331
6332 gl::Program *programObject = context->getProgram(program);
6333 ASSERT(programObject);
6334
6335 programObject->setTransformFeedbackVaryings(count, varyings, bufferMode);
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006336 }
6337}
6338
Kenneth Russell67ea1902014-10-06 16:44:50 -07006339void GL_APIENTRY glGetTransformFeedbackVarying(GLuint program, GLuint index, GLsizei bufSize, GLsizei* length, GLsizei* size, GLenum* type, GLchar* name)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006340{
6341 EVENT("(GLuint program = %u, GLuint index = %u, GLsizei bufSize = %d, GLsizei* length = 0x%0.8p, "
6342 "GLsizei* size = 0x%0.8p, GLenum* type = 0x%0.8p, GLchar* name = 0x%0.8p)",
6343 program, index, bufSize, length, size, type, name);
6344
Geoff Langbfdea662014-07-23 14:16:32 -04006345 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04006346 if (context)
6347 {
6348 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006349 {
Geoff Langb1196682014-07-23 13:47:29 -04006350 context->recordError(gl::Error(GL_INVALID_OPERATION));
6351 return;
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00006352 }
Geoff Langbfdea662014-07-23 14:16:32 -04006353
6354 if (bufSize < 0)
6355 {
Geoff Langb1196682014-07-23 13:47:29 -04006356 context->recordError(gl::Error(GL_INVALID_VALUE));
6357 return;
Geoff Langbfdea662014-07-23 14:16:32 -04006358 }
6359
6360 if (!gl::ValidProgram(context, program))
6361 {
6362 return;
6363 }
6364
6365 gl::Program *programObject = context->getProgram(program);
6366 ASSERT(programObject);
6367
6368 if (index >= static_cast<GLuint>(programObject->getTransformFeedbackVaryingCount()))
6369 {
Geoff Langb1196682014-07-23 13:47:29 -04006370 context->recordError(gl::Error(GL_INVALID_VALUE));
6371 return;
Geoff Langbfdea662014-07-23 14:16:32 -04006372 }
6373
6374 programObject->getTransformFeedbackVarying(index, bufSize, length, size, type, name);
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006375 }
6376}
6377
Kenneth Russell67ea1902014-10-06 16:44:50 -07006378void GL_APIENTRY glVertexAttribIPointer(GLuint index, GLint size, GLenum type, GLsizei stride, const GLvoid* pointer)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006379{
6380 EVENT("(GLuint index = %u, GLint size = %d, GLenum type = 0x%X, GLsizei stride = %d, const GLvoid* pointer = 0x%0.8p)",
6381 index, size, type, stride, pointer);
6382
Geoff Langbfdea662014-07-23 14:16:32 -04006383 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04006384 if (context)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006385 {
Geoff Langbfdea662014-07-23 14:16:32 -04006386 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006387 {
Geoff Langb1196682014-07-23 13:47:29 -04006388 context->recordError(gl::Error(GL_INVALID_OPERATION));
6389 return;
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006390 }
6391
Geoff Langb1196682014-07-23 13:47:29 -04006392 if (index >= gl::MAX_VERTEX_ATTRIBS)
6393 {
6394 context->recordError(gl::Error(GL_INVALID_VALUE));
6395 return;
6396 }
shannon.woods%transgaming.com@gtempaccount.coma8885862013-04-13 03:37:53 +00006397
Geoff Langb1196682014-07-23 13:47:29 -04006398 if (size < 1 || size > 4)
6399 {
6400 context->recordError(gl::Error(GL_INVALID_VALUE));
6401 return;
6402 }
shannon.woods%transgaming.com@gtempaccount.coma8885862013-04-13 03:37:53 +00006403
Geoff Langb1196682014-07-23 13:47:29 -04006404 switch (type)
6405 {
6406 case GL_BYTE:
6407 case GL_UNSIGNED_BYTE:
6408 case GL_SHORT:
6409 case GL_UNSIGNED_SHORT:
6410 case GL_INT:
6411 case GL_UNSIGNED_INT:
6412 case GL_INT_2_10_10_10_REV:
6413 case GL_UNSIGNED_INT_2_10_10_10_REV:
6414 break;
shannon.woods%transgaming.com@gtempaccount.coma8885862013-04-13 03:37:53 +00006415
Geoff Langb1196682014-07-23 13:47:29 -04006416 default:
6417 context->recordError(gl::Error(GL_INVALID_ENUM));
6418 return;
6419 }
shannon.woods%transgaming.com@gtempaccount.coma8885862013-04-13 03:37:53 +00006420
Geoff Langb1196682014-07-23 13:47:29 -04006421 if (stride < 0)
6422 {
6423 context->recordError(gl::Error(GL_INVALID_VALUE));
6424 return;
6425 }
Geoff Langbfdea662014-07-23 14:16:32 -04006426
Geoff Langb1196682014-07-23 13:47:29 -04006427 if ((type == GL_INT_2_10_10_10_REV || type == GL_UNSIGNED_INT_2_10_10_10_REV) && size != 4)
6428 {
6429 context->recordError(gl::Error(GL_INVALID_OPERATION));
6430 return;
6431 }
6432
Geoff Langbfdea662014-07-23 14:16:32 -04006433 // [OpenGL ES 3.0.2] Section 2.8 page 24:
6434 // An INVALID_OPERATION error is generated when a non-zero vertex array object
6435 // is bound, zero is bound to the ARRAY_BUFFER buffer object binding point,
6436 // and the pointer argument is not NULL.
6437 if (context->getState().getVertexArray()->id() != 0 && context->getState().getArrayBufferId() == 0 && pointer != NULL)
shannon.woods%transgaming.com@gtempaccount.com1ab57be2013-04-13 03:38:39 +00006438 {
Geoff Langb1196682014-07-23 13:47:29 -04006439 context->recordError(gl::Error(GL_INVALID_OPERATION));
6440 return;
shannon.woods%transgaming.com@gtempaccount.com1ab57be2013-04-13 03:38:39 +00006441 }
6442
Geoff Langbfdea662014-07-23 14:16:32 -04006443 context->getState().setVertexAttribState(index, context->getState().getTargetBuffer(GL_ARRAY_BUFFER), size, type, false, true,
6444 stride, pointer);
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006445 }
6446}
6447
Kenneth Russell67ea1902014-10-06 16:44:50 -07006448void GL_APIENTRY glGetVertexAttribIiv(GLuint index, GLenum pname, GLint* params)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006449{
6450 EVENT("(GLuint index = %u, GLenum pname = 0x%X, GLint* params = 0x%0.8p)",
6451 index, pname, params);
6452
Geoff Langbfdea662014-07-23 14:16:32 -04006453 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04006454 if (context)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006455 {
Geoff Langbfdea662014-07-23 14:16:32 -04006456 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006457 {
Geoff Langb1196682014-07-23 13:47:29 -04006458 context->recordError(gl::Error(GL_INVALID_OPERATION));
6459 return;
Geoff Langbfdea662014-07-23 14:16:32 -04006460 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006461
Geoff Langbfdea662014-07-23 14:16:32 -04006462 if (index >= gl::MAX_VERTEX_ATTRIBS)
6463 {
Geoff Langb1196682014-07-23 13:47:29 -04006464 context->recordError(gl::Error(GL_INVALID_VALUE));
6465 return;
Geoff Langbfdea662014-07-23 14:16:32 -04006466 }
Jamie Madilla7d05862013-07-02 11:57:06 -04006467
Geoff Langbfdea662014-07-23 14:16:32 -04006468 const gl::VertexAttribute &attribState = context->getState().getVertexAttribState(index);
Jamie Madilla7d05862013-07-02 11:57:06 -04006469
Geoff Langb1196682014-07-23 13:47:29 -04006470 if (!gl::ValidateGetVertexAttribParameters(context, pname))
Geoff Langbfdea662014-07-23 14:16:32 -04006471 {
6472 return;
6473 }
Jamie Madilla7d05862013-07-02 11:57:06 -04006474
Geoff Langbfdea662014-07-23 14:16:32 -04006475 if (pname == GL_CURRENT_VERTEX_ATTRIB)
6476 {
6477 const gl::VertexAttribCurrentValueData &currentValueData = context->getState().getVertexAttribCurrentValue(index);
6478 for (int i = 0; i < 4; ++i)
Jamie Madilla7d05862013-07-02 11:57:06 -04006479 {
Geoff Langbfdea662014-07-23 14:16:32 -04006480 params[i] = currentValueData.IntValues[i];
Jamie Madilla7d05862013-07-02 11:57:06 -04006481 }
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00006482 }
Geoff Langbfdea662014-07-23 14:16:32 -04006483 else
6484 {
6485 *params = gl::QuerySingleVertexAttributeParameter<GLint>(attribState, pname);
6486 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006487 }
6488}
6489
Kenneth Russell67ea1902014-10-06 16:44:50 -07006490void GL_APIENTRY glGetVertexAttribIuiv(GLuint index, GLenum pname, GLuint* params)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006491{
6492 EVENT("(GLuint index = %u, GLenum pname = 0x%X, GLuint* params = 0x%0.8p)",
6493 index, pname, params);
6494
Geoff Langbfdea662014-07-23 14:16:32 -04006495 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04006496 if (context)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006497 {
Geoff Langbfdea662014-07-23 14:16:32 -04006498 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006499 {
Geoff Langb1196682014-07-23 13:47:29 -04006500 context->recordError(gl::Error(GL_INVALID_OPERATION));
6501 return;
Geoff Langbfdea662014-07-23 14:16:32 -04006502 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006503
Geoff Langbfdea662014-07-23 14:16:32 -04006504 if (index >= gl::MAX_VERTEX_ATTRIBS)
6505 {
Geoff Langb1196682014-07-23 13:47:29 -04006506 context->recordError(gl::Error(GL_INVALID_VALUE));
6507 return;
Geoff Langbfdea662014-07-23 14:16:32 -04006508 }
Jamie Madilla7d05862013-07-02 11:57:06 -04006509
Geoff Langbfdea662014-07-23 14:16:32 -04006510 const gl::VertexAttribute &attribState = context->getState().getVertexAttribState(index);
Jamie Madilla7d05862013-07-02 11:57:06 -04006511
Geoff Langb1196682014-07-23 13:47:29 -04006512 if (!gl::ValidateGetVertexAttribParameters(context, pname))
Geoff Langbfdea662014-07-23 14:16:32 -04006513 {
6514 return;
6515 }
Jamie Madilla7d05862013-07-02 11:57:06 -04006516
Geoff Langbfdea662014-07-23 14:16:32 -04006517 if (pname == GL_CURRENT_VERTEX_ATTRIB)
6518 {
6519 const gl::VertexAttribCurrentValueData &currentValueData = context->getState().getVertexAttribCurrentValue(index);
6520 for (int i = 0; i < 4; ++i)
Jamie Madilla7d05862013-07-02 11:57:06 -04006521 {
Geoff Langbfdea662014-07-23 14:16:32 -04006522 params[i] = currentValueData.UnsignedIntValues[i];
Jamie Madilla7d05862013-07-02 11:57:06 -04006523 }
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00006524 }
Geoff Langbfdea662014-07-23 14:16:32 -04006525 else
6526 {
6527 *params = gl::QuerySingleVertexAttributeParameter<GLuint>(attribState, pname);
6528 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006529 }
6530}
6531
Kenneth Russell67ea1902014-10-06 16:44:50 -07006532void GL_APIENTRY glVertexAttribI4i(GLuint index, GLint x, GLint y, GLint z, GLint w)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006533{
6534 EVENT("(GLuint index = %u, GLint x = %d, GLint y = %d, GLint z = %d, GLint w = %d)",
6535 index, x, y, z, w);
6536
Geoff Langbfdea662014-07-23 14:16:32 -04006537 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04006538 if (context)
6539 {
6540 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006541 {
Geoff Langb1196682014-07-23 13:47:29 -04006542 context->recordError(gl::Error(GL_INVALID_OPERATION));
6543 return;
shannon.woods%transgaming.com@gtempaccount.coma8885862013-04-13 03:37:53 +00006544 }
Geoff Langbfdea662014-07-23 14:16:32 -04006545
6546 if (index >= gl::MAX_VERTEX_ATTRIBS)
6547 {
Geoff Langb1196682014-07-23 13:47:29 -04006548 context->recordError(gl::Error(GL_INVALID_VALUE));
6549 return;
Geoff Langbfdea662014-07-23 14:16:32 -04006550 }
6551
6552 GLint vals[4] = { x, y, z, w };
6553 context->getState().setVertexAttribi(index, vals);
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006554 }
6555}
6556
Kenneth Russell67ea1902014-10-06 16:44:50 -07006557void GL_APIENTRY glVertexAttribI4ui(GLuint index, GLuint x, GLuint y, GLuint z, GLuint w)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006558{
6559 EVENT("(GLuint index = %u, GLuint x = %u, GLuint y = %u, GLuint z = %u, GLuint w = %u)",
6560 index, x, y, z, w);
6561
Geoff Langbfdea662014-07-23 14:16:32 -04006562 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04006563 if (context)
6564 {
6565 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006566 {
Geoff Langb1196682014-07-23 13:47:29 -04006567 context->recordError(gl::Error(GL_INVALID_OPERATION));
6568 return;
shannon.woods%transgaming.com@gtempaccount.coma8885862013-04-13 03:37:53 +00006569 }
Geoff Langbfdea662014-07-23 14:16:32 -04006570
6571 if (index >= gl::MAX_VERTEX_ATTRIBS)
6572 {
Geoff Langb1196682014-07-23 13:47:29 -04006573 context->recordError(gl::Error(GL_INVALID_VALUE));
6574 return;
Geoff Langbfdea662014-07-23 14:16:32 -04006575 }
6576
6577 GLuint vals[4] = { x, y, z, w };
6578 context->getState().setVertexAttribu(index, vals);
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006579 }
6580}
6581
Kenneth Russell67ea1902014-10-06 16:44:50 -07006582void GL_APIENTRY glVertexAttribI4iv(GLuint index, const GLint* v)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006583{
6584 EVENT("(GLuint index = %u, const GLint* v = 0x%0.8p)", index, v);
6585
Geoff Langbfdea662014-07-23 14:16:32 -04006586 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04006587 if (context)
6588 {
6589 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006590 {
Geoff Langb1196682014-07-23 13:47:29 -04006591 context->recordError(gl::Error(GL_INVALID_OPERATION));
6592 return;
shannon.woods%transgaming.com@gtempaccount.coma8885862013-04-13 03:37:53 +00006593 }
Geoff Langbfdea662014-07-23 14:16:32 -04006594
6595 if (index >= gl::MAX_VERTEX_ATTRIBS)
6596 {
Geoff Langb1196682014-07-23 13:47:29 -04006597 context->recordError(gl::Error(GL_INVALID_VALUE));
6598 return;
Geoff Langbfdea662014-07-23 14:16:32 -04006599 }
6600
6601 context->getState().setVertexAttribi(index, v);
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006602 }
6603}
6604
Kenneth Russell67ea1902014-10-06 16:44:50 -07006605void GL_APIENTRY glVertexAttribI4uiv(GLuint index, const GLuint* v)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006606{
6607 EVENT("(GLuint index = %u, const GLuint* v = 0x%0.8p)", index, v);
6608
Geoff Langbfdea662014-07-23 14:16:32 -04006609 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04006610 if (context)
6611 {
6612 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006613 {
Geoff Langb1196682014-07-23 13:47:29 -04006614 context->recordError(gl::Error(GL_INVALID_OPERATION));
6615 return;
shannon.woods%transgaming.com@gtempaccount.coma8885862013-04-13 03:37:53 +00006616 }
Geoff Langbfdea662014-07-23 14:16:32 -04006617
6618 if (index >= gl::MAX_VERTEX_ATTRIBS)
6619 {
Geoff Langb1196682014-07-23 13:47:29 -04006620 context->recordError(gl::Error(GL_INVALID_VALUE));
6621 return;
Geoff Langbfdea662014-07-23 14:16:32 -04006622 }
6623
6624 context->getState().setVertexAttribu(index, v);
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006625 }
6626}
6627
Kenneth Russell67ea1902014-10-06 16:44:50 -07006628void GL_APIENTRY glGetUniformuiv(GLuint program, GLint location, GLuint* params)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006629{
6630 EVENT("(GLuint program = %u, GLint location = %d, GLuint* params = 0x%0.8p)",
6631 program, location, params);
6632
Geoff Langbfdea662014-07-23 14:16:32 -04006633 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04006634 if (context)
6635 {
Jamie Madill0063c512014-08-25 15:47:53 -04006636 if (!ValidateGetUniformuiv(context, program, location, params))
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006637 {
Jamie Madill0063c512014-08-25 15:47:53 -04006638 return;
shannon.woods%transgaming.com@gtempaccount.come2290122013-04-13 03:41:07 +00006639 }
Geoff Langbfdea662014-07-23 14:16:32 -04006640
Jamie Madilla502c742014-08-28 17:19:13 -04006641 gl::Program *programObject = context->getProgram(program);
6642 ASSERT(programObject);
6643 gl::ProgramBinary *programBinary = programObject->getProgramBinary();
Jamie Madill0063c512014-08-25 15:47:53 -04006644 ASSERT(programBinary);
Geoff Langbfdea662014-07-23 14:16:32 -04006645
Jamie Madill99a1e982014-08-25 15:47:54 -04006646 programBinary->getUniformuiv(location, params);
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006647 }
6648}
6649
Kenneth Russell67ea1902014-10-06 16:44:50 -07006650GLint GL_APIENTRY glGetFragDataLocation(GLuint program, const GLchar *name)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006651{
6652 EVENT("(GLuint program = %u, const GLchar *name = 0x%0.8p)",
6653 program, name);
6654
Geoff Langbfdea662014-07-23 14:16:32 -04006655 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04006656 if (context)
6657 {
6658 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006659 {
Geoff Langb1196682014-07-23 13:47:29 -04006660 context->recordError(gl::Error(GL_INVALID_OPERATION));
6661 return -1;
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00006662 }
Geoff Langbfdea662014-07-23 14:16:32 -04006663
6664 if (program == 0)
6665 {
Geoff Langb1196682014-07-23 13:47:29 -04006666 context->recordError(gl::Error(GL_INVALID_VALUE));
6667 return -1;
Geoff Langbfdea662014-07-23 14:16:32 -04006668 }
6669
6670 gl::Program *programObject = context->getProgram(program);
6671
6672 if (!programObject || !programObject->isLinked())
6673 {
Geoff Langb1196682014-07-23 13:47:29 -04006674 context->recordError(gl::Error(GL_INVALID_OPERATION));
6675 return -1;
Geoff Langbfdea662014-07-23 14:16:32 -04006676 }
6677
6678 gl::ProgramBinary *programBinary = programObject->getProgramBinary();
6679 if (!programBinary)
6680 {
Geoff Langb1196682014-07-23 13:47:29 -04006681 context->recordError(gl::Error(GL_INVALID_OPERATION));
6682 return -1;
Geoff Langbfdea662014-07-23 14:16:32 -04006683 }
6684
6685 return programBinary->getFragDataLocation(name);
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006686 }
6687
6688 return 0;
6689}
6690
Kenneth Russell67ea1902014-10-06 16:44:50 -07006691void GL_APIENTRY glUniform1ui(GLint location, GLuint v0)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006692{
shannon.woods%transgaming.com@gtempaccount.com8431b9c2013-04-13 03:40:17 +00006693 glUniform1uiv(location, 1, &v0);
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006694}
6695
Kenneth Russell67ea1902014-10-06 16:44:50 -07006696void GL_APIENTRY glUniform2ui(GLint location, GLuint v0, GLuint v1)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006697{
shannon.woods%transgaming.com@gtempaccount.com8431b9c2013-04-13 03:40:17 +00006698 const GLuint xy[] = { v0, v1 };
6699 glUniform2uiv(location, 1, xy);
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006700}
6701
Kenneth Russell67ea1902014-10-06 16:44:50 -07006702void GL_APIENTRY glUniform3ui(GLint location, GLuint v0, GLuint v1, GLuint v2)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006703{
shannon.woods%transgaming.com@gtempaccount.com8431b9c2013-04-13 03:40:17 +00006704 const GLuint xyz[] = { v0, v1, v2 };
6705 glUniform3uiv(location, 1, xyz);
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006706}
6707
Kenneth Russell67ea1902014-10-06 16:44:50 -07006708void GL_APIENTRY glUniform4ui(GLint location, GLuint v0, GLuint v1, GLuint v2, GLuint v3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006709{
shannon.woods%transgaming.com@gtempaccount.com8431b9c2013-04-13 03:40:17 +00006710 const GLuint xyzw[] = { v0, v1, v2, v3 };
6711 glUniform4uiv(location, 1, xyzw);
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006712}
6713
Kenneth Russell67ea1902014-10-06 16:44:50 -07006714void GL_APIENTRY glUniform1uiv(GLint location, GLsizei count, const GLuint* value)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006715{
6716 EVENT("(GLint location = %d, GLsizei count = %d, const GLuint* value = 0x%0.8p)",
6717 location, count, value);
6718
Geoff Langbfdea662014-07-23 14:16:32 -04006719 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04006720 if (context)
6721 {
6722 if (!ValidateUniform(context, GL_UNSIGNED_INT, location, count))
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006723 {
Geoff Langbfdea662014-07-23 14:16:32 -04006724 return;
shannon.woods%transgaming.com@gtempaccount.com50ea4ab2013-04-13 03:40:36 +00006725 }
Geoff Langbfdea662014-07-23 14:16:32 -04006726
6727 gl::ProgramBinary *programBinary = context->getState().getCurrentProgramBinary();
6728 programBinary->setUniform1uiv(location, count, value);
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006729 }
6730}
6731
Kenneth Russell67ea1902014-10-06 16:44:50 -07006732void GL_APIENTRY glUniform2uiv(GLint location, GLsizei count, const GLuint* value)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006733{
6734 EVENT("(GLint location = %d, GLsizei count = %d, const GLuint* value = 0x%0.8p)",
6735 location, count, value);
6736
Geoff Langbfdea662014-07-23 14:16:32 -04006737 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04006738 if (context)
6739 {
6740 if (!ValidateUniform(context, GL_UNSIGNED_INT_VEC2, location, count))
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006741 {
Geoff Langbfdea662014-07-23 14:16:32 -04006742 return;
shannon.woods%transgaming.com@gtempaccount.com50ea4ab2013-04-13 03:40:36 +00006743 }
Geoff Langbfdea662014-07-23 14:16:32 -04006744
6745 gl::ProgramBinary *programBinary = context->getState().getCurrentProgramBinary();
6746 programBinary->setUniform2uiv(location, count, value);
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006747 }
6748}
6749
Kenneth Russell67ea1902014-10-06 16:44:50 -07006750void GL_APIENTRY glUniform3uiv(GLint location, GLsizei count, const GLuint* value)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006751{
6752 EVENT("(GLint location = %d, GLsizei count = %d, const GLuint* value)",
6753 location, count, value);
6754
Geoff Langbfdea662014-07-23 14:16:32 -04006755 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04006756 if (context)
6757 {
6758 if (!ValidateUniform(context, GL_UNSIGNED_INT_VEC3, location, count))
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006759 {
Geoff Langbfdea662014-07-23 14:16:32 -04006760 return;
shannon.woods%transgaming.com@gtempaccount.com50ea4ab2013-04-13 03:40:36 +00006761 }
Geoff Langbfdea662014-07-23 14:16:32 -04006762
6763 gl::ProgramBinary *programBinary = context->getState().getCurrentProgramBinary();
6764 programBinary->setUniform3uiv(location, count, value);
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006765 }
6766}
6767
Kenneth Russell67ea1902014-10-06 16:44:50 -07006768void GL_APIENTRY glUniform4uiv(GLint location, GLsizei count, const GLuint* value)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006769{
6770 EVENT("(GLint location = %d, GLsizei count = %d, const GLuint* value = 0x%0.8p)",
6771 location, count, value);
6772
Geoff Langbfdea662014-07-23 14:16:32 -04006773 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04006774 if (context)
6775 {
6776 if (!ValidateUniform(context, GL_UNSIGNED_INT_VEC4, location, count))
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006777 {
Geoff Langbfdea662014-07-23 14:16:32 -04006778 return;
shannon.woods%transgaming.com@gtempaccount.com50ea4ab2013-04-13 03:40:36 +00006779 }
Geoff Langbfdea662014-07-23 14:16:32 -04006780
6781 gl::ProgramBinary *programBinary = context->getState().getCurrentProgramBinary();
6782 programBinary->setUniform4uiv(location, count, value);
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006783 }
6784}
6785
Kenneth Russell67ea1902014-10-06 16:44:50 -07006786void GL_APIENTRY glClearBufferiv(GLenum buffer, GLint drawbuffer, const GLint* value)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006787{
6788 EVENT("(GLenum buffer = 0x%X, GLint drawbuffer = %d, const GLint* value = 0x%0.8p)",
6789 buffer, drawbuffer, value);
6790
Geoff Langbfdea662014-07-23 14:16:32 -04006791 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04006792 if (context)
6793 {
6794 if (!ValidateClearBuffer(context))
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006795 {
Geoff Langbfdea662014-07-23 14:16:32 -04006796 return;
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00006797 }
Geoff Langbfdea662014-07-23 14:16:32 -04006798
6799 switch (buffer)
6800 {
6801 case GL_COLOR:
6802 if (drawbuffer < 0 || static_cast<GLuint>(drawbuffer) >= context->getCaps().maxDrawBuffers)
6803 {
Geoff Langb1196682014-07-23 13:47:29 -04006804 context->recordError(gl::Error(GL_INVALID_VALUE));
6805 return;
Geoff Langbfdea662014-07-23 14:16:32 -04006806 }
6807 break;
Geoff Langb1196682014-07-23 13:47:29 -04006808
Geoff Langbfdea662014-07-23 14:16:32 -04006809 case GL_STENCIL:
6810 if (drawbuffer != 0)
6811 {
Geoff Langb1196682014-07-23 13:47:29 -04006812 context->recordError(gl::Error(GL_INVALID_VALUE));
6813 return;
Geoff Langbfdea662014-07-23 14:16:32 -04006814 }
6815 break;
Geoff Langb1196682014-07-23 13:47:29 -04006816
Geoff Langbfdea662014-07-23 14:16:32 -04006817 default:
Geoff Langb1196682014-07-23 13:47:29 -04006818 context->recordError(gl::Error(GL_INVALID_ENUM));
6819 return;
Geoff Langbfdea662014-07-23 14:16:32 -04006820 }
6821
Geoff Langcc79b8c2014-07-25 13:48:02 -04006822 gl::Error error = context->clearBufferiv(buffer, drawbuffer, value);
6823 if (error.isError())
6824 {
6825 context->recordError(error);
6826 return;
6827 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006828 }
6829}
6830
Kenneth Russell67ea1902014-10-06 16:44:50 -07006831void GL_APIENTRY glClearBufferuiv(GLenum buffer, GLint drawbuffer, const GLuint* value)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006832{
6833 EVENT("(GLenum buffer = 0x%X, GLint drawbuffer = %d, const GLuint* value = 0x%0.8p)",
6834 buffer, drawbuffer, value);
6835
Geoff Langbfdea662014-07-23 14:16:32 -04006836 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04006837 if (context)
6838 {
6839 if (!ValidateClearBuffer(context))
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006840 {
Geoff Langbfdea662014-07-23 14:16:32 -04006841 return;
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00006842 }
Geoff Langbfdea662014-07-23 14:16:32 -04006843
6844 switch (buffer)
6845 {
6846 case GL_COLOR:
6847 if (drawbuffer < 0 || static_cast<GLuint>(drawbuffer) >= context->getCaps().maxDrawBuffers)
6848 {
Geoff Langb1196682014-07-23 13:47:29 -04006849 context->recordError(gl::Error(GL_INVALID_VALUE));
6850 return;
Geoff Langbfdea662014-07-23 14:16:32 -04006851 }
6852 break;
Geoff Langb1196682014-07-23 13:47:29 -04006853
Geoff Langbfdea662014-07-23 14:16:32 -04006854 default:
Geoff Langb1196682014-07-23 13:47:29 -04006855 context->recordError(gl::Error(GL_INVALID_ENUM));
6856 return;
Geoff Langbfdea662014-07-23 14:16:32 -04006857 }
6858
Geoff Langcc79b8c2014-07-25 13:48:02 -04006859 gl::Error error = context->clearBufferuiv(buffer, drawbuffer, value);
6860 if (error.isError())
6861 {
6862 context->recordError(error);
6863 return;
6864 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006865 }
6866}
6867
Kenneth Russell67ea1902014-10-06 16:44:50 -07006868void GL_APIENTRY glClearBufferfv(GLenum buffer, GLint drawbuffer, const GLfloat* value)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006869{
6870 EVENT("(GLenum buffer = 0x%X, GLint drawbuffer = %d, const GLfloat* value = 0x%0.8p)",
6871 buffer, drawbuffer, value);
6872
Geoff Langbfdea662014-07-23 14:16:32 -04006873 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04006874 if (context)
6875 {
6876 if (!ValidateClearBuffer(context))
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006877 {
Geoff Langbfdea662014-07-23 14:16:32 -04006878 return;
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00006879 }
Geoff Langbfdea662014-07-23 14:16:32 -04006880
6881 switch (buffer)
6882 {
6883 case GL_COLOR:
6884 if (drawbuffer < 0 || static_cast<GLuint>(drawbuffer) >= context->getCaps().maxDrawBuffers)
6885 {
Geoff Langb1196682014-07-23 13:47:29 -04006886 context->recordError(gl::Error(GL_INVALID_VALUE));
6887 return;
Geoff Langbfdea662014-07-23 14:16:32 -04006888 }
6889 break;
Geoff Langb1196682014-07-23 13:47:29 -04006890
Geoff Langbfdea662014-07-23 14:16:32 -04006891 case GL_DEPTH:
6892 if (drawbuffer != 0)
6893 {
Geoff Langb1196682014-07-23 13:47:29 -04006894 context->recordError(gl::Error(GL_INVALID_VALUE));
6895 return;
Geoff Langbfdea662014-07-23 14:16:32 -04006896 }
6897 break;
Geoff Langb1196682014-07-23 13:47:29 -04006898
Geoff Langbfdea662014-07-23 14:16:32 -04006899 default:
Geoff Langb1196682014-07-23 13:47:29 -04006900 context->recordError(gl::Error(GL_INVALID_ENUM));
6901 return;
Geoff Langbfdea662014-07-23 14:16:32 -04006902 }
6903
Geoff Langcc79b8c2014-07-25 13:48:02 -04006904 gl::Error error = context->clearBufferfv(buffer, drawbuffer, value);
6905 if (error.isError())
6906 {
6907 context->recordError(error);
6908 return;
6909 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006910 }
6911}
6912
Kenneth Russell67ea1902014-10-06 16:44:50 -07006913void GL_APIENTRY glClearBufferfi(GLenum buffer, GLint drawbuffer, GLfloat depth, GLint stencil)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006914{
6915 EVENT("(GLenum buffer = 0x%X, GLint drawbuffer = %d, GLfloat depth, GLint stencil = %d)",
6916 buffer, drawbuffer, depth, stencil);
6917
Geoff Langbfdea662014-07-23 14:16:32 -04006918 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04006919 if (context)
6920 {
6921 if (!ValidateClearBuffer(context))
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006922 {
Geoff Langbfdea662014-07-23 14:16:32 -04006923 return;
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00006924 }
Geoff Langbfdea662014-07-23 14:16:32 -04006925
6926 switch (buffer)
6927 {
6928 case GL_DEPTH_STENCIL:
6929 if (drawbuffer != 0)
6930 {
Geoff Langb1196682014-07-23 13:47:29 -04006931 context->recordError(gl::Error(GL_INVALID_VALUE));
6932 return;
Geoff Langbfdea662014-07-23 14:16:32 -04006933 }
6934 break;
Geoff Langb1196682014-07-23 13:47:29 -04006935
Geoff Langbfdea662014-07-23 14:16:32 -04006936 default:
Geoff Langb1196682014-07-23 13:47:29 -04006937 context->recordError(gl::Error(GL_INVALID_ENUM));
6938 return;
Geoff Langbfdea662014-07-23 14:16:32 -04006939 }
6940
Geoff Langcc79b8c2014-07-25 13:48:02 -04006941 gl::Error error = context->clearBufferfi(buffer, drawbuffer, depth, stencil);
6942 if (error.isError())
6943 {
6944 context->recordError(error);
6945 return;
6946 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006947 }
6948}
6949
Kenneth Russell67ea1902014-10-06 16:44:50 -07006950const GLubyte* GL_APIENTRY glGetStringi(GLenum name, GLuint index)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006951{
6952 EVENT("(GLenum name = 0x%X, GLuint index = %u)", name, index);
6953
Geoff Langbfdea662014-07-23 14:16:32 -04006954 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04006955 if (context)
6956 {
6957 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006958 {
Geoff Langb1196682014-07-23 13:47:29 -04006959 context->recordError(gl::Error(GL_INVALID_OPERATION));
6960 return NULL;
shannonwoods@chromium.org302df742013-05-30 00:05:54 +00006961 }
Geoff Langbfdea662014-07-23 14:16:32 -04006962
6963 if (name != GL_EXTENSIONS)
6964 {
Geoff Langb1196682014-07-23 13:47:29 -04006965 context->recordError(gl::Error(GL_INVALID_ENUM));
6966 return NULL;
Geoff Langbfdea662014-07-23 14:16:32 -04006967 }
6968
6969 if (index >= context->getExtensionStringCount())
6970 {
Geoff Langb1196682014-07-23 13:47:29 -04006971 context->recordError(gl::Error(GL_INVALID_VALUE));
6972 return NULL;
Geoff Langbfdea662014-07-23 14:16:32 -04006973 }
6974
6975 return reinterpret_cast<const GLubyte*>(context->getExtensionString(index).c_str());
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006976 }
6977
6978 return NULL;
6979}
6980
Kenneth Russell67ea1902014-10-06 16:44:50 -07006981void GL_APIENTRY glCopyBufferSubData(GLenum readTarget, GLenum writeTarget, GLintptr readOffset, GLintptr writeOffset, GLsizeiptr size)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006982{
6983 EVENT("(GLenum readTarget = 0x%X, GLenum writeTarget = 0x%X, GLintptr readOffset = %d, GLintptr writeOffset = %d, GLsizeiptr size = %d)",
6984 readTarget, writeTarget, readOffset, writeOffset, size);
6985
Geoff Langbfdea662014-07-23 14:16:32 -04006986 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04006987 if (context)
6988 {
6989 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006990 {
Geoff Langb1196682014-07-23 13:47:29 -04006991 context->recordError(gl::Error(GL_INVALID_OPERATION));
6992 return;
shannon.woods%transgaming.com@gtempaccount.com296c3f22013-04-13 03:39:39 +00006993 }
Geoff Langbfdea662014-07-23 14:16:32 -04006994
6995 if (!gl::ValidBufferTarget(context, readTarget) || !gl::ValidBufferTarget(context, readTarget))
6996 {
Geoff Langb1196682014-07-23 13:47:29 -04006997 context->recordError(gl::Error(GL_INVALID_ENUM));
6998 return;
Geoff Langbfdea662014-07-23 14:16:32 -04006999 }
7000
7001 gl::Buffer *readBuffer = context->getState().getTargetBuffer(readTarget);
7002 gl::Buffer *writeBuffer = context->getState().getTargetBuffer(writeTarget);
7003
7004 if (!readBuffer || !writeBuffer)
7005 {
Geoff Langb1196682014-07-23 13:47:29 -04007006 context->recordError(gl::Error(GL_INVALID_OPERATION));
7007 return;
Geoff Langbfdea662014-07-23 14:16:32 -04007008 }
7009
Jamie Madillcfaaf722014-07-31 10:47:54 -04007010 // Verify that readBuffer and writeBuffer are not currently mapped
Geoff Langbfdea662014-07-23 14:16:32 -04007011 if (readBuffer->isMapped() || writeBuffer->isMapped())
7012 {
Geoff Langb1196682014-07-23 13:47:29 -04007013 context->recordError(gl::Error(GL_INVALID_OPERATION));
7014 return;
Geoff Langbfdea662014-07-23 14:16:32 -04007015 }
7016
7017 if (readOffset < 0 || writeOffset < 0 || size < 0 ||
7018 static_cast<unsigned int>(readOffset + size) > readBuffer->getSize() ||
7019 static_cast<unsigned int>(writeOffset + size) > writeBuffer->getSize())
7020 {
Geoff Langb1196682014-07-23 13:47:29 -04007021 context->recordError(gl::Error(GL_INVALID_VALUE));
7022 return;
Geoff Langbfdea662014-07-23 14:16:32 -04007023 }
7024
Kenneth Russell67ea1902014-10-06 16:44:50 -07007025 if (readBuffer == writeBuffer && std::abs(readOffset - writeOffset) < size)
Geoff Langbfdea662014-07-23 14:16:32 -04007026 {
Geoff Langb1196682014-07-23 13:47:29 -04007027 context->recordError(gl::Error(GL_INVALID_VALUE));
7028 return;
Geoff Langbfdea662014-07-23 14:16:32 -04007029 }
7030
Geoff Langbfdea662014-07-23 14:16:32 -04007031 // if size is zero, the copy is a successful no-op
7032 if (size > 0)
7033 {
Geoff Lang2a1c15a2014-07-25 11:43:00 -04007034 gl::Error error = writeBuffer->copyBufferSubData(readBuffer, readOffset, writeOffset, size);
7035 if (error.isError())
7036 {
7037 context->recordError(error);
7038 return;
7039 }
Geoff Langbfdea662014-07-23 14:16:32 -04007040 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007041 }
7042}
7043
Kenneth Russell67ea1902014-10-06 16:44:50 -07007044void GL_APIENTRY glGetUniformIndices(GLuint program, GLsizei uniformCount, const GLchar* const* uniformNames, GLuint* uniformIndices)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007045{
7046 EVENT("(GLuint program = %u, GLsizei uniformCount = %d, const GLchar* const* uniformNames = 0x%0.8p, GLuint* uniformIndices = 0x%0.8p)",
7047 program, uniformCount, uniformNames, uniformIndices);
7048
Geoff Langbfdea662014-07-23 14:16:32 -04007049 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04007050 if (context)
7051 {
7052 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007053 {
Geoff Langb1196682014-07-23 13:47:29 -04007054 context->recordError(gl::Error(GL_INVALID_OPERATION));
7055 return;
Geoff Langbfdea662014-07-23 14:16:32 -04007056 }
7057
7058 if (uniformCount < 0)
7059 {
Geoff Langb1196682014-07-23 13:47:29 -04007060 context->recordError(gl::Error(GL_INVALID_VALUE));
7061 return;
Geoff Langbfdea662014-07-23 14:16:32 -04007062 }
7063
7064 gl::Program *programObject = context->getProgram(program);
7065
7066 if (!programObject)
7067 {
7068 if (context->getShader(program))
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007069 {
Geoff Langb1196682014-07-23 13:47:29 -04007070 context->recordError(gl::Error(GL_INVALID_OPERATION));
7071 return;
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007072 }
Geoff Langbfdea662014-07-23 14:16:32 -04007073 else
shannonwoods@chromium.orgc2ed9912013-05-30 00:05:33 +00007074 {
Geoff Langb1196682014-07-23 13:47:29 -04007075 context->recordError(gl::Error(GL_INVALID_VALUE));
7076 return;
shannonwoods@chromium.orgc2ed9912013-05-30 00:05:33 +00007077 }
Geoff Langbfdea662014-07-23 14:16:32 -04007078 }
shannonwoods@chromium.orgc2ed9912013-05-30 00:05:33 +00007079
Geoff Langbfdea662014-07-23 14:16:32 -04007080 gl::ProgramBinary *programBinary = programObject->getProgramBinary();
7081 if (!programObject->isLinked() || !programBinary)
7082 {
7083 for (int uniformId = 0; uniformId < uniformCount; uniformId++)
shannonwoods@chromium.orgc2ed9912013-05-30 00:05:33 +00007084 {
Geoff Langbfdea662014-07-23 14:16:32 -04007085 uniformIndices[uniformId] = GL_INVALID_INDEX;
shannonwoods@chromium.orgc2ed9912013-05-30 00:05:33 +00007086 }
7087 }
Geoff Langbfdea662014-07-23 14:16:32 -04007088 else
7089 {
7090 for (int uniformId = 0; uniformId < uniformCount; uniformId++)
7091 {
7092 uniformIndices[uniformId] = programBinary->getUniformIndex(uniformNames[uniformId]);
7093 }
7094 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007095 }
7096}
7097
Kenneth Russell67ea1902014-10-06 16:44:50 -07007098void GL_APIENTRY glGetActiveUniformsiv(GLuint program, GLsizei uniformCount, const GLuint* uniformIndices, GLenum pname, GLint* params)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007099{
7100 EVENT("(GLuint program = %u, GLsizei uniformCount = %d, const GLuint* uniformIndices = 0x%0.8p, GLenum pname = 0x%X, GLint* params = 0x%0.8p)",
7101 program, uniformCount, uniformIndices, pname, params);
7102
Geoff Langbfdea662014-07-23 14:16:32 -04007103 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04007104 if (context)
7105 {
7106 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007107 {
Geoff Langb1196682014-07-23 13:47:29 -04007108 context->recordError(gl::Error(GL_INVALID_OPERATION));
7109 return;
Geoff Langbfdea662014-07-23 14:16:32 -04007110 }
7111
7112 if (uniformCount < 0)
7113 {
Geoff Langb1196682014-07-23 13:47:29 -04007114 context->recordError(gl::Error(GL_INVALID_VALUE));
7115 return;
Geoff Langbfdea662014-07-23 14:16:32 -04007116 }
7117
7118 gl::Program *programObject = context->getProgram(program);
7119
7120 if (!programObject)
7121 {
7122 if (context->getShader(program))
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007123 {
Geoff Langb1196682014-07-23 13:47:29 -04007124 context->recordError(gl::Error(GL_INVALID_OPERATION));
7125 return;
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007126 }
Geoff Langbfdea662014-07-23 14:16:32 -04007127 else
shannonwoods@chromium.org2a9a9d22013-05-30 00:05:40 +00007128 {
Geoff Langb1196682014-07-23 13:47:29 -04007129 context->recordError(gl::Error(GL_INVALID_VALUE));
7130 return;
shannonwoods@chromium.org2a9a9d22013-05-30 00:05:40 +00007131 }
shannonwoods@chromium.org2a9a9d22013-05-30 00:05:40 +00007132 }
Geoff Langbfdea662014-07-23 14:16:32 -04007133
7134 switch (pname)
7135 {
7136 case GL_UNIFORM_TYPE:
7137 case GL_UNIFORM_SIZE:
7138 case GL_UNIFORM_NAME_LENGTH:
7139 case GL_UNIFORM_BLOCK_INDEX:
7140 case GL_UNIFORM_OFFSET:
7141 case GL_UNIFORM_ARRAY_STRIDE:
7142 case GL_UNIFORM_MATRIX_STRIDE:
7143 case GL_UNIFORM_IS_ROW_MAJOR:
7144 break;
Geoff Langb1196682014-07-23 13:47:29 -04007145
Geoff Langbfdea662014-07-23 14:16:32 -04007146 default:
Geoff Langb1196682014-07-23 13:47:29 -04007147 context->recordError(gl::Error(GL_INVALID_ENUM));
7148 return;
Geoff Langbfdea662014-07-23 14:16:32 -04007149 }
7150
7151 gl::ProgramBinary *programBinary = programObject->getProgramBinary();
7152
7153 if (!programBinary && uniformCount > 0)
7154 {
Geoff Langb1196682014-07-23 13:47:29 -04007155 context->recordError(gl::Error(GL_INVALID_VALUE));
7156 return;
Geoff Langbfdea662014-07-23 14:16:32 -04007157 }
7158
7159 for (int uniformId = 0; uniformId < uniformCount; uniformId++)
7160 {
7161 const GLuint index = uniformIndices[uniformId];
7162
7163 if (index >= (GLuint)programBinary->getActiveUniformCount())
7164 {
Geoff Langb1196682014-07-23 13:47:29 -04007165 context->recordError(gl::Error(GL_INVALID_VALUE));
7166 return;
Geoff Langbfdea662014-07-23 14:16:32 -04007167 }
7168 }
7169
7170 for (int uniformId = 0; uniformId < uniformCount; uniformId++)
7171 {
7172 const GLuint index = uniformIndices[uniformId];
7173 params[uniformId] = programBinary->getActiveUniformi(index, pname);
7174 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007175 }
7176}
7177
Kenneth Russell67ea1902014-10-06 16:44:50 -07007178GLuint GL_APIENTRY glGetUniformBlockIndex(GLuint program, const GLchar* uniformBlockName)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007179{
7180 EVENT("(GLuint program = %u, const GLchar* uniformBlockName = 0x%0.8p)", program, uniformBlockName);
7181
Geoff Langbfdea662014-07-23 14:16:32 -04007182 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04007183 if (context)
7184 {
7185 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007186 {
Geoff Langb1196682014-07-23 13:47:29 -04007187 context->recordError(gl::Error(GL_INVALID_OPERATION));
7188 return GL_INVALID_INDEX;
Geoff Langbfdea662014-07-23 14:16:32 -04007189 }
7190
7191 gl::Program *programObject = context->getProgram(program);
7192
7193 if (!programObject)
7194 {
7195 if (context->getShader(program))
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007196 {
Geoff Langb1196682014-07-23 13:47:29 -04007197 context->recordError(gl::Error(GL_INVALID_OPERATION));
7198 return GL_INVALID_INDEX;
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007199 }
Geoff Langbfdea662014-07-23 14:16:32 -04007200 else
shannonwoods@chromium.org42766252013-05-30 00:07:12 +00007201 {
Geoff Langb1196682014-07-23 13:47:29 -04007202 context->recordError(gl::Error(GL_INVALID_VALUE));
7203 return GL_INVALID_INDEX;
shannonwoods@chromium.org42766252013-05-30 00:07:12 +00007204 }
shannonwoods@chromium.org42766252013-05-30 00:07:12 +00007205 }
Geoff Langbfdea662014-07-23 14:16:32 -04007206
7207 gl::ProgramBinary *programBinary = programObject->getProgramBinary();
7208 if (!programBinary)
7209 {
7210 return GL_INVALID_INDEX;
7211 }
7212
7213 return programBinary->getUniformBlockIndex(uniformBlockName);
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007214 }
7215
7216 return 0;
7217}
7218
Kenneth Russell67ea1902014-10-06 16:44:50 -07007219void GL_APIENTRY glGetActiveUniformBlockiv(GLuint program, GLuint uniformBlockIndex, GLenum pname, GLint* params)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007220{
7221 EVENT("(GLuint program = %u, GLuint uniformBlockIndex = %u, GLenum pname = 0x%X, GLint* params = 0x%0.8p)",
7222 program, uniformBlockIndex, pname, params);
7223
Geoff Langbfdea662014-07-23 14:16:32 -04007224 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04007225 if (context)
7226 {
7227 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007228 {
Geoff Langb1196682014-07-23 13:47:29 -04007229 context->recordError(gl::Error(GL_INVALID_OPERATION));
7230 return;
Geoff Langbfdea662014-07-23 14:16:32 -04007231 }
7232 gl::Program *programObject = context->getProgram(program);
7233
7234 if (!programObject)
7235 {
7236 if (context->getShader(program))
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007237 {
Geoff Langb1196682014-07-23 13:47:29 -04007238 context->recordError(gl::Error(GL_INVALID_OPERATION));
7239 return;
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007240 }
Geoff Langbfdea662014-07-23 14:16:32 -04007241 else
shannonwoods@chromium.orge7317ca2013-05-30 00:07:35 +00007242 {
Geoff Langb1196682014-07-23 13:47:29 -04007243 context->recordError(gl::Error(GL_INVALID_VALUE));
7244 return;
shannonwoods@chromium.orge7317ca2013-05-30 00:07:35 +00007245 }
shannonwoods@chromium.orge7317ca2013-05-30 00:07:35 +00007246 }
Geoff Langbfdea662014-07-23 14:16:32 -04007247
7248 gl::ProgramBinary *programBinary = programObject->getProgramBinary();
7249
7250 if (!programBinary || uniformBlockIndex >= programBinary->getActiveUniformBlockCount())
7251 {
Geoff Langb1196682014-07-23 13:47:29 -04007252 context->recordError(gl::Error(GL_INVALID_VALUE));
7253 return;
Geoff Langbfdea662014-07-23 14:16:32 -04007254 }
7255
7256 switch (pname)
7257 {
7258 case GL_UNIFORM_BLOCK_BINDING:
7259 *params = static_cast<GLint>(programObject->getUniformBlockBinding(uniformBlockIndex));
7260 break;
7261
7262 case GL_UNIFORM_BLOCK_DATA_SIZE:
7263 case GL_UNIFORM_BLOCK_NAME_LENGTH:
7264 case GL_UNIFORM_BLOCK_ACTIVE_UNIFORMS:
7265 case GL_UNIFORM_BLOCK_ACTIVE_UNIFORM_INDICES:
7266 case GL_UNIFORM_BLOCK_REFERENCED_BY_VERTEX_SHADER:
7267 case GL_UNIFORM_BLOCK_REFERENCED_BY_FRAGMENT_SHADER:
7268 programBinary->getActiveUniformBlockiv(uniformBlockIndex, pname, params);
7269 break;
7270
7271 default:
Geoff Langb1196682014-07-23 13:47:29 -04007272 context->recordError(gl::Error(GL_INVALID_ENUM));
7273 return;
Geoff Langbfdea662014-07-23 14:16:32 -04007274 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007275 }
7276}
7277
Kenneth Russell67ea1902014-10-06 16:44:50 -07007278void GL_APIENTRY glGetActiveUniformBlockName(GLuint program, GLuint uniformBlockIndex, GLsizei bufSize, GLsizei* length, GLchar* uniformBlockName)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007279{
7280 EVENT("(GLuint program = %u, GLuint uniformBlockIndex = %u, GLsizei bufSize = %d, GLsizei* length = 0x%0.8p, GLchar* uniformBlockName = 0x%0.8p)",
7281 program, uniformBlockIndex, bufSize, length, uniformBlockName);
7282
Geoff Langbfdea662014-07-23 14:16:32 -04007283 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04007284 if (context)
7285 {
7286 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007287 {
Geoff Langb1196682014-07-23 13:47:29 -04007288 context->recordError(gl::Error(GL_INVALID_OPERATION));
7289 return;
Geoff Langbfdea662014-07-23 14:16:32 -04007290 }
7291
7292 gl::Program *programObject = context->getProgram(program);
7293
7294 if (!programObject)
7295 {
7296 if (context->getShader(program))
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007297 {
Geoff Langb1196682014-07-23 13:47:29 -04007298 context->recordError(gl::Error(GL_INVALID_OPERATION));
7299 return;
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007300 }
Geoff Langbfdea662014-07-23 14:16:32 -04007301 else
shannonwoods@chromium.orgbeb02782013-05-30 00:07:28 +00007302 {
Geoff Langb1196682014-07-23 13:47:29 -04007303 context->recordError(gl::Error(GL_INVALID_VALUE));
7304 return;
shannonwoods@chromium.orgbeb02782013-05-30 00:07:28 +00007305 }
shannonwoods@chromium.orgbeb02782013-05-30 00:07:28 +00007306 }
Geoff Langbfdea662014-07-23 14:16:32 -04007307
7308 gl::ProgramBinary *programBinary = programObject->getProgramBinary();
7309
7310 if (!programBinary || uniformBlockIndex >= programBinary->getActiveUniformBlockCount())
7311 {
Geoff Langb1196682014-07-23 13:47:29 -04007312 context->recordError(gl::Error(GL_INVALID_VALUE));
7313 return;
Geoff Langbfdea662014-07-23 14:16:32 -04007314 }
7315
7316 programBinary->getActiveUniformBlockName(uniformBlockIndex, bufSize, length, uniformBlockName);
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007317 }
7318}
7319
Kenneth Russell67ea1902014-10-06 16:44:50 -07007320void GL_APIENTRY glUniformBlockBinding(GLuint program, GLuint uniformBlockIndex, GLuint uniformBlockBinding)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007321{
7322 EVENT("(GLuint program = %u, GLuint uniformBlockIndex = %u, GLuint uniformBlockBinding = %u)",
7323 program, uniformBlockIndex, uniformBlockBinding);
7324
Geoff Langbfdea662014-07-23 14:16:32 -04007325 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04007326 if (context)
7327 {
7328 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007329 {
Geoff Langb1196682014-07-23 13:47:29 -04007330 context->recordError(gl::Error(GL_INVALID_OPERATION));
7331 return;
Geoff Langbfdea662014-07-23 14:16:32 -04007332 }
7333
Geoff Lang3a61c322014-07-10 13:01:54 -04007334 if (uniformBlockBinding >= context->getCaps().maxUniformBufferBindings)
Geoff Langbfdea662014-07-23 14:16:32 -04007335 {
Geoff Langb1196682014-07-23 13:47:29 -04007336 context->recordError(gl::Error(GL_INVALID_VALUE));
7337 return;
Geoff Langbfdea662014-07-23 14:16:32 -04007338 }
7339
7340 gl::Program *programObject = context->getProgram(program);
7341
7342 if (!programObject)
7343 {
7344 if (context->getShader(program))
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007345 {
Geoff Langb1196682014-07-23 13:47:29 -04007346 context->recordError(gl::Error(GL_INVALID_OPERATION));
7347 return;
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007348 }
Geoff Langbfdea662014-07-23 14:16:32 -04007349 else
shannonwoods@chromium.org70eb1ea2013-05-30 00:07:20 +00007350 {
Geoff Langb1196682014-07-23 13:47:29 -04007351 context->recordError(gl::Error(GL_INVALID_VALUE));
7352 return;
shannonwoods@chromium.org70eb1ea2013-05-30 00:07:20 +00007353 }
shannonwoods@chromium.org70eb1ea2013-05-30 00:07:20 +00007354 }
Geoff Langbfdea662014-07-23 14:16:32 -04007355
7356 gl::ProgramBinary *programBinary = programObject->getProgramBinary();
7357
7358 // if never linked, there won't be any uniform blocks
7359 if (!programBinary || uniformBlockIndex >= programBinary->getActiveUniformBlockCount())
7360 {
Geoff Langb1196682014-07-23 13:47:29 -04007361 context->recordError(gl::Error(GL_INVALID_VALUE));
7362 return;
Geoff Langbfdea662014-07-23 14:16:32 -04007363 }
7364
7365 programObject->bindUniformBlock(uniformBlockIndex, uniformBlockBinding);
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007366 }
7367}
7368
Kenneth Russell67ea1902014-10-06 16:44:50 -07007369void GL_APIENTRY glDrawArraysInstanced(GLenum mode, GLint first, GLsizei count, GLsizei instanceCount)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007370{
7371 EVENT("(GLenum mode = 0x%X, GLint first = %d, GLsizei count = %d, GLsizei instanceCount = %d)",
7372 mode, first, count, instanceCount);
7373
Geoff Langbfdea662014-07-23 14:16:32 -04007374 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04007375 if (context)
7376 {
7377 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007378 {
Geoff Langb1196682014-07-23 13:47:29 -04007379 context->recordError(gl::Error(GL_INVALID_OPERATION));
7380 return;
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00007381 }
Geoff Langbfdea662014-07-23 14:16:32 -04007382
7383 // glDrawArraysInstanced
7384 UNIMPLEMENTED();
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007385 }
7386}
7387
Kenneth Russell67ea1902014-10-06 16:44:50 -07007388void GL_APIENTRY glDrawElementsInstanced(GLenum mode, GLsizei count, GLenum type, const GLvoid* indices, GLsizei instanceCount)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007389{
7390 EVENT("(GLenum mode = 0x%X, GLsizei count = %d, GLenum type = 0x%X, const GLvoid* indices = 0x%0.8p, GLsizei instanceCount = %d)",
7391 mode, count, type, indices, instanceCount);
7392
Geoff Langbfdea662014-07-23 14:16:32 -04007393 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04007394 if (context)
7395 {
7396 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007397 {
Geoff Langb1196682014-07-23 13:47:29 -04007398 context->recordError(gl::Error(GL_INVALID_OPERATION));
7399 return;
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00007400 }
Geoff Langbfdea662014-07-23 14:16:32 -04007401
7402 // glDrawElementsInstanced
7403 UNIMPLEMENTED();
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007404 }
7405}
7406
Kenneth Russell67ea1902014-10-06 16:44:50 -07007407GLsync GL_APIENTRY glFenceSync(GLenum condition, GLbitfield flags)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007408{
7409 EVENT("(GLenum condition = 0x%X, GLbitfield flags = 0x%X)", condition, flags);
7410
Geoff Langbfdea662014-07-23 14:16:32 -04007411 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04007412 if (context)
7413 {
7414 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007415 {
Geoff Langb1196682014-07-23 13:47:29 -04007416 context->recordError(gl::Error(GL_INVALID_OPERATION));
7417 return 0;
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00007418 }
Geoff Langbfdea662014-07-23 14:16:32 -04007419
7420 if (condition != GL_SYNC_GPU_COMMANDS_COMPLETE)
7421 {
Geoff Langb1196682014-07-23 13:47:29 -04007422 context->recordError(gl::Error(GL_INVALID_ENUM));
7423 return 0;
Geoff Langbfdea662014-07-23 14:16:32 -04007424 }
7425
7426 if (flags != 0)
7427 {
Geoff Langb1196682014-07-23 13:47:29 -04007428 context->recordError(gl::Error(GL_INVALID_VALUE));
7429 return 0;
Geoff Langbfdea662014-07-23 14:16:32 -04007430 }
7431
Geoff Lang882033e2014-09-30 11:26:07 -04007432 GLsync fenceSync = context->createFenceSync();
7433
7434 gl::FenceSync *fenceSyncObject = context->getFenceSync(fenceSync);
7435 gl::Error error = fenceSyncObject->set(condition);
7436 if (error.isError())
7437 {
7438 context->deleteFenceSync(fenceSync);
7439 context->recordError(error);
7440 return NULL;
7441 }
7442
7443 return fenceSync;
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007444 }
7445
7446 return NULL;
7447}
7448
Kenneth Russell67ea1902014-10-06 16:44:50 -07007449GLboolean GL_APIENTRY glIsSync(GLsync sync)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007450{
7451 EVENT("(GLsync sync = 0x%0.8p)", sync);
7452
Geoff Langbfdea662014-07-23 14:16:32 -04007453 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04007454 if (context)
7455 {
7456 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007457 {
Geoff Langb1196682014-07-23 13:47:29 -04007458 context->recordError(gl::Error(GL_INVALID_OPERATION));
7459 return GL_FALSE;
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00007460 }
Geoff Langbfdea662014-07-23 14:16:32 -04007461
7462 return (context->getFenceSync(sync) != NULL);
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007463 }
7464
7465 return GL_FALSE;
7466}
7467
Kenneth Russell67ea1902014-10-06 16:44:50 -07007468void GL_APIENTRY glDeleteSync(GLsync sync)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007469{
7470 EVENT("(GLsync sync = 0x%0.8p)", sync);
7471
Geoff Langbfdea662014-07-23 14:16:32 -04007472 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04007473 if (context)
7474 {
7475 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007476 {
Geoff Langb1196682014-07-23 13:47:29 -04007477 context->recordError(gl::Error(GL_INVALID_OPERATION));
7478 return;
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00007479 }
Geoff Langbfdea662014-07-23 14:16:32 -04007480
7481 if (sync != static_cast<GLsync>(0) && !context->getFenceSync(sync))
7482 {
Geoff Langb1196682014-07-23 13:47:29 -04007483 context->recordError(gl::Error(GL_INVALID_VALUE));
7484 return;
Geoff Langbfdea662014-07-23 14:16:32 -04007485 }
7486
7487 context->deleteFenceSync(sync);
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007488 }
7489}
7490
Kenneth Russell67ea1902014-10-06 16:44:50 -07007491GLenum GL_APIENTRY glClientWaitSync(GLsync sync, GLbitfield flags, GLuint64 timeout)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007492{
7493 EVENT("(GLsync sync = 0x%0.8p, GLbitfield flags = 0x%X, GLuint64 timeout = %llu)",
7494 sync, flags, timeout);
7495
Geoff Langbfdea662014-07-23 14:16:32 -04007496 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04007497 if (context)
7498 {
7499 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007500 {
Geoff Langb1196682014-07-23 13:47:29 -04007501 context->recordError(gl::Error(GL_INVALID_OPERATION));
7502 return GL_WAIT_FAILED;
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00007503 }
Geoff Langbfdea662014-07-23 14:16:32 -04007504
7505 if ((flags & ~(GL_SYNC_FLUSH_COMMANDS_BIT)) != 0)
7506 {
Geoff Langb1196682014-07-23 13:47:29 -04007507 context->recordError(gl::Error(GL_INVALID_VALUE));
7508 return GL_WAIT_FAILED;
Geoff Langbfdea662014-07-23 14:16:32 -04007509 }
7510
7511 gl::FenceSync *fenceSync = context->getFenceSync(sync);
7512
7513 if (!fenceSync)
7514 {
Geoff Langb1196682014-07-23 13:47:29 -04007515 context->recordError(gl::Error(GL_INVALID_VALUE));
7516 return GL_WAIT_FAILED;
Geoff Langbfdea662014-07-23 14:16:32 -04007517 }
7518
Geoff Lang882033e2014-09-30 11:26:07 -04007519 GLenum result = GL_WAIT_FAILED;
7520 gl::Error error = fenceSync->clientWait(flags, timeout, &result);
7521 if (error.isError())
7522 {
7523 context->recordError(error);
7524 return GL_WAIT_FAILED;
7525 }
7526
7527 return result;
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007528 }
7529
7530 return GL_FALSE;
7531}
7532
Kenneth Russell67ea1902014-10-06 16:44:50 -07007533void GL_APIENTRY glWaitSync(GLsync sync, GLbitfield flags, GLuint64 timeout)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007534{
7535 EVENT("(GLsync sync = 0x%0.8p, GLbitfield flags = 0x%X, GLuint64 timeout = %llu)",
7536 sync, flags, timeout);
7537
Geoff Langbfdea662014-07-23 14:16:32 -04007538 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04007539 if (context)
7540 {
7541 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007542 {
Geoff Langb1196682014-07-23 13:47:29 -04007543 context->recordError(gl::Error(GL_INVALID_OPERATION));
7544 return;
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00007545 }
Geoff Langbfdea662014-07-23 14:16:32 -04007546
7547 if (flags != 0)
7548 {
Geoff Langb1196682014-07-23 13:47:29 -04007549 context->recordError(gl::Error(GL_INVALID_VALUE));
7550 return;
Geoff Langbfdea662014-07-23 14:16:32 -04007551 }
7552
7553 if (timeout != GL_TIMEOUT_IGNORED)
7554 {
Geoff Langb1196682014-07-23 13:47:29 -04007555 context->recordError(gl::Error(GL_INVALID_VALUE));
7556 return;
Geoff Langbfdea662014-07-23 14:16:32 -04007557 }
7558
7559 gl::FenceSync *fenceSync = context->getFenceSync(sync);
7560
7561 if (!fenceSync)
7562 {
Geoff Langb1196682014-07-23 13:47:29 -04007563 context->recordError(gl::Error(GL_INVALID_VALUE));
7564 return;
Geoff Langbfdea662014-07-23 14:16:32 -04007565 }
7566
Kenneth Russellcaa549c2014-10-10 17:52:59 -07007567 gl::Error error = fenceSync->serverWait(flags, timeout);
Geoff Lang882033e2014-09-30 11:26:07 -04007568 if (error.isError())
7569 {
7570 context->recordError(error);
7571 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007572 }
7573}
7574
Kenneth Russell67ea1902014-10-06 16:44:50 -07007575void GL_APIENTRY glGetInteger64v(GLenum pname, GLint64* params)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007576{
7577 EVENT("(GLenum pname = 0x%X, GLint64* params = 0x%0.8p)",
7578 pname, params);
7579
Geoff Langbfdea662014-07-23 14:16:32 -04007580 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04007581 if (context)
7582 {
7583 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007584 {
Geoff Langb1196682014-07-23 13:47:29 -04007585 context->recordError(gl::Error(GL_INVALID_OPERATION));
7586 return;
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00007587 }
Geoff Langbfdea662014-07-23 14:16:32 -04007588
7589 GLenum nativeType;
7590 unsigned int numParams = 0;
7591 if (!ValidateStateQuery(context, pname, &nativeType, &numParams))
7592 {
7593 return;
7594 }
7595
7596 if (nativeType == GL_INT_64_ANGLEX)
7597 {
7598 context->getInteger64v(pname, params);
7599 }
7600 else
7601 {
7602 CastStateValues(context, nativeType, pname, numParams, params);
7603 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007604 }
7605}
7606
Kenneth Russell67ea1902014-10-06 16:44:50 -07007607void GL_APIENTRY glGetSynciv(GLsync sync, GLenum pname, GLsizei bufSize, GLsizei* length, GLint* values)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007608{
7609 EVENT("(GLsync sync = 0x%0.8p, GLenum pname = 0x%X, GLsizei bufSize = %d, GLsizei* length = 0x%0.8p, GLint* values = 0x%0.8p)",
7610 sync, pname, bufSize, length, values);
7611
Geoff Langbfdea662014-07-23 14:16:32 -04007612 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04007613 if (context)
7614 {
7615 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007616 {
Geoff Langb1196682014-07-23 13:47:29 -04007617 context->recordError(gl::Error(GL_INVALID_OPERATION));
7618 return;
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00007619 }
Geoff Langbfdea662014-07-23 14:16:32 -04007620
7621 if (bufSize < 0)
7622 {
Geoff Langb1196682014-07-23 13:47:29 -04007623 context->recordError(gl::Error(GL_INVALID_VALUE));
7624 return;
Geoff Langbfdea662014-07-23 14:16:32 -04007625 }
7626
7627 gl::FenceSync *fenceSync = context->getFenceSync(sync);
7628
7629 if (!fenceSync)
7630 {
Geoff Langb1196682014-07-23 13:47:29 -04007631 context->recordError(gl::Error(GL_INVALID_VALUE));
7632 return;
Geoff Langbfdea662014-07-23 14:16:32 -04007633 }
7634
7635 switch (pname)
7636 {
7637 case GL_OBJECT_TYPE: values[0] = static_cast<GLint>(GL_SYNC_FENCE); break;
Geoff Langbfdea662014-07-23 14:16:32 -04007638 case GL_SYNC_CONDITION: values[0] = static_cast<GLint>(fenceSync->getCondition()); break;
7639 case GL_SYNC_FLAGS: values[0] = 0; break;
7640
Geoff Lang882033e2014-09-30 11:26:07 -04007641 case GL_SYNC_STATUS:
7642 {
7643 gl::Error error = fenceSync->getStatus(values);
7644 if (error.isError())
7645 {
7646 context->recordError(error);
7647 return;
7648 }
7649 break;
7650 }
7651
Geoff Langbfdea662014-07-23 14:16:32 -04007652 default:
Geoff Langb1196682014-07-23 13:47:29 -04007653 context->recordError(gl::Error(GL_INVALID_ENUM));
7654 return;
Geoff Langbfdea662014-07-23 14:16:32 -04007655 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007656 }
7657}
7658
Kenneth Russell67ea1902014-10-06 16:44:50 -07007659void GL_APIENTRY glGetInteger64i_v(GLenum target, GLuint index, GLint64* data)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007660{
7661 EVENT("(GLenum target = 0x%X, GLuint index = %u, GLint64* data = 0x%0.8p)",
7662 target, index, data);
7663
Geoff Langbfdea662014-07-23 14:16:32 -04007664 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04007665 if (context)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007666 {
Geoff Langbfdea662014-07-23 14:16:32 -04007667 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007668 {
Geoff Langb1196682014-07-23 13:47:29 -04007669 context->recordError(gl::Error(GL_INVALID_OPERATION));
7670 return;
Geoff Langbfdea662014-07-23 14:16:32 -04007671 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007672
Geoff Lang3a61c322014-07-10 13:01:54 -04007673 const gl::Caps &caps = context->getCaps();
Geoff Langbfdea662014-07-23 14:16:32 -04007674 switch (target)
7675 {
7676 case GL_TRANSFORM_FEEDBACK_BUFFER_START:
7677 case GL_TRANSFORM_FEEDBACK_BUFFER_SIZE:
7678 case GL_TRANSFORM_FEEDBACK_BUFFER_BINDING:
Geoff Lang05881a02014-07-10 14:05:30 -04007679 if (index >= caps.maxTransformFeedbackSeparateAttributes)
7680 {
Geoff Langb1196682014-07-23 13:47:29 -04007681 context->recordError(gl::Error(GL_INVALID_VALUE));
7682 return;
Geoff Lang05881a02014-07-10 14:05:30 -04007683 }
Geoff Langbfdea662014-07-23 14:16:32 -04007684 break;
Geoff Langb1196682014-07-23 13:47:29 -04007685
Geoff Langbfdea662014-07-23 14:16:32 -04007686 case GL_UNIFORM_BUFFER_START:
7687 case GL_UNIFORM_BUFFER_SIZE:
7688 case GL_UNIFORM_BUFFER_BINDING:
Geoff Lang3a61c322014-07-10 13:01:54 -04007689 if (index >= caps.maxUniformBufferBindings)
7690 {
Geoff Langb1196682014-07-23 13:47:29 -04007691 context->recordError(gl::Error(GL_INVALID_VALUE));
7692 return;
Geoff Lang3a61c322014-07-10 13:01:54 -04007693 }
Geoff Langbfdea662014-07-23 14:16:32 -04007694 break;
Geoff Langb1196682014-07-23 13:47:29 -04007695
Geoff Langbfdea662014-07-23 14:16:32 -04007696 default:
Geoff Langb1196682014-07-23 13:47:29 -04007697 context->recordError(gl::Error(GL_INVALID_ENUM));
7698 return;
Geoff Langbfdea662014-07-23 14:16:32 -04007699 }
7700
7701 if (!(context->getIndexedInteger64v(target, index, data)))
7702 {
7703 GLenum nativeType;
7704 unsigned int numParams = 0;
7705 if (!context->getIndexedQueryParameterInfo(target, &nativeType, &numParams))
Geoff Langb1196682014-07-23 13:47:29 -04007706 {
7707 context->recordError(gl::Error(GL_INVALID_ENUM));
7708 return;
7709 }
Shannon Woods15934d52013-08-19 14:28:49 -04007710
Geoff Langbfdea662014-07-23 14:16:32 -04007711 if (numParams == 0)
7712 return; // it is known that pname is valid, but there are no parameters to return
7713
7714 if (nativeType == GL_INT)
Shannon Woods15934d52013-08-19 14:28:49 -04007715 {
Geoff Langbfdea662014-07-23 14:16:32 -04007716 GLint *intParams = new GLint[numParams];
Shannon Woods15934d52013-08-19 14:28:49 -04007717
Geoff Langbfdea662014-07-23 14:16:32 -04007718 context->getIndexedIntegerv(target, index, intParams);
Shannon Woods15934d52013-08-19 14:28:49 -04007719
Geoff Langbfdea662014-07-23 14:16:32 -04007720 for (unsigned int i = 0; i < numParams; ++i)
Shannon Woods15934d52013-08-19 14:28:49 -04007721 {
Geoff Langbfdea662014-07-23 14:16:32 -04007722 data[i] = static_cast<GLint64>(intParams[i]);
Shannon Woods15934d52013-08-19 14:28:49 -04007723 }
Geoff Langbfdea662014-07-23 14:16:32 -04007724
7725 delete [] intParams;
7726 }
7727 else
7728 {
7729 UNREACHABLE();
Shannon Woods15934d52013-08-19 14:28:49 -04007730 }
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00007731 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007732 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007733}
7734
Kenneth Russell67ea1902014-10-06 16:44:50 -07007735void GL_APIENTRY glGetBufferParameteri64v(GLenum target, GLenum pname, GLint64* params)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007736{
7737 EVENT("(GLenum target = 0x%X, GLenum pname = 0x%X, GLint64* params = 0x%0.8p)",
7738 target, pname, params);
7739
Geoff Langbfdea662014-07-23 14:16:32 -04007740 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04007741 if (context)
7742 {
7743 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007744 {
Geoff Langb1196682014-07-23 13:47:29 -04007745 context->recordError(gl::Error(GL_INVALID_OPERATION));
7746 return;
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00007747 }
Geoff Langbfdea662014-07-23 14:16:32 -04007748
7749 if (!gl::ValidBufferTarget(context, target))
7750 {
Geoff Langb1196682014-07-23 13:47:29 -04007751 context->recordError(gl::Error(GL_INVALID_ENUM));
7752 return;
Geoff Langbfdea662014-07-23 14:16:32 -04007753 }
7754
7755 if (!gl::ValidBufferParameter(context, pname))
7756 {
Geoff Langb1196682014-07-23 13:47:29 -04007757 context->recordError(gl::Error(GL_INVALID_ENUM));
7758 return;
Geoff Langbfdea662014-07-23 14:16:32 -04007759 }
7760
7761 gl::Buffer *buffer = context->getState().getTargetBuffer(target);
7762
7763 if (!buffer)
7764 {
7765 // A null buffer means that "0" is bound to the requested buffer target
Geoff Langb1196682014-07-23 13:47:29 -04007766 context->recordError(gl::Error(GL_INVALID_OPERATION));
7767 return;
Geoff Langbfdea662014-07-23 14:16:32 -04007768 }
7769
7770 switch (pname)
7771 {
7772 case GL_BUFFER_USAGE:
7773 *params = static_cast<GLint64>(buffer->getUsage());
7774 break;
7775 case GL_BUFFER_SIZE:
7776 *params = buffer->getSize();
7777 break;
7778 case GL_BUFFER_ACCESS_FLAGS:
7779 *params = static_cast<GLint64>(buffer->getAccessFlags());
7780 break;
7781 case GL_BUFFER_MAPPED:
7782 *params = static_cast<GLint64>(buffer->isMapped());
7783 break;
7784 case GL_BUFFER_MAP_OFFSET:
7785 *params = buffer->getMapOffset();
7786 break;
7787 case GL_BUFFER_MAP_LENGTH:
7788 *params = buffer->getMapLength();
7789 break;
7790 default: UNREACHABLE(); break;
7791 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007792 }
7793}
7794
Kenneth Russell67ea1902014-10-06 16:44:50 -07007795void GL_APIENTRY glGenSamplers(GLsizei count, GLuint* samplers)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007796{
7797 EVENT("(GLsizei count = %d, GLuint* samplers = 0x%0.8p)", count, samplers);
7798
Geoff Langbfdea662014-07-23 14:16:32 -04007799 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04007800 if (context)
7801 {
7802 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007803 {
Geoff Langb1196682014-07-23 13:47:29 -04007804 context->recordError(gl::Error(GL_INVALID_OPERATION));
7805 return;
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00007806 }
Geoff Langbfdea662014-07-23 14:16:32 -04007807
7808 if (count < 0)
7809 {
Geoff Langb1196682014-07-23 13:47:29 -04007810 context->recordError(gl::Error(GL_INVALID_VALUE));
7811 return;
Geoff Langbfdea662014-07-23 14:16:32 -04007812 }
7813
7814 for (int i = 0; i < count; i++)
7815 {
7816 samplers[i] = context->createSampler();
7817 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007818 }
7819}
7820
Kenneth Russell67ea1902014-10-06 16:44:50 -07007821void GL_APIENTRY glDeleteSamplers(GLsizei count, const GLuint* samplers)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007822{
7823 EVENT("(GLsizei count = %d, const GLuint* samplers = 0x%0.8p)", count, samplers);
7824
Geoff Langbfdea662014-07-23 14:16:32 -04007825 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04007826 if (context)
7827 {
7828 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007829 {
Geoff Langb1196682014-07-23 13:47:29 -04007830 context->recordError(gl::Error(GL_INVALID_OPERATION));
7831 return;
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00007832 }
Geoff Langbfdea662014-07-23 14:16:32 -04007833
7834 if (count < 0)
7835 {
Geoff Langb1196682014-07-23 13:47:29 -04007836 context->recordError(gl::Error(GL_INVALID_VALUE));
7837 return;
Geoff Langbfdea662014-07-23 14:16:32 -04007838 }
7839
7840 for (int i = 0; i < count; i++)
7841 {
7842 context->deleteSampler(samplers[i]);
7843 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007844 }
7845}
7846
Kenneth Russell67ea1902014-10-06 16:44:50 -07007847GLboolean GL_APIENTRY glIsSampler(GLuint sampler)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007848{
7849 EVENT("(GLuint sampler = %u)", sampler);
7850
Geoff Langbfdea662014-07-23 14:16:32 -04007851 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04007852 if (context)
7853 {
7854 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007855 {
Geoff Langb1196682014-07-23 13:47:29 -04007856 context->recordError(gl::Error(GL_INVALID_OPERATION));
7857 return GL_FALSE;
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00007858 }
Geoff Langbfdea662014-07-23 14:16:32 -04007859
7860 return context->isSampler(sampler);
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007861 }
7862
7863 return GL_FALSE;
7864}
7865
Kenneth Russell67ea1902014-10-06 16:44:50 -07007866void GL_APIENTRY glBindSampler(GLuint unit, GLuint sampler)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007867{
7868 EVENT("(GLuint unit = %u, GLuint sampler = %u)", unit, sampler);
7869
Geoff Langbfdea662014-07-23 14:16:32 -04007870 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04007871 if (context)
7872 {
7873 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007874 {
Geoff Langb1196682014-07-23 13:47:29 -04007875 context->recordError(gl::Error(GL_INVALID_OPERATION));
7876 return;
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00007877 }
Geoff Langbfdea662014-07-23 14:16:32 -04007878
7879 if (sampler != 0 && !context->isSampler(sampler))
7880 {
Geoff Langb1196682014-07-23 13:47:29 -04007881 context->recordError(gl::Error(GL_INVALID_OPERATION));
7882 return;
Geoff Langbfdea662014-07-23 14:16:32 -04007883 }
7884
Geoff Lang3a61c322014-07-10 13:01:54 -04007885 if (unit >= context->getCaps().maxCombinedTextureImageUnits)
Geoff Langbfdea662014-07-23 14:16:32 -04007886 {
Geoff Langb1196682014-07-23 13:47:29 -04007887 context->recordError(gl::Error(GL_INVALID_VALUE));
7888 return;
Geoff Langbfdea662014-07-23 14:16:32 -04007889 }
7890
7891 context->bindSampler(unit, sampler);
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007892 }
7893}
7894
Kenneth Russell67ea1902014-10-06 16:44:50 -07007895void GL_APIENTRY glSamplerParameteri(GLuint sampler, GLenum pname, GLint param)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007896{
7897 EVENT("(GLuint sampler = %u, GLenum pname = 0x%X, GLint param = %d)", sampler, pname, param);
7898
Geoff Langbfdea662014-07-23 14:16:32 -04007899 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04007900 if (context)
7901 {
7902 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007903 {
Geoff Langb1196682014-07-23 13:47:29 -04007904 context->recordError(gl::Error(GL_INVALID_OPERATION));
7905 return;
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00007906 }
Geoff Langbfdea662014-07-23 14:16:32 -04007907
Geoff Langb1196682014-07-23 13:47:29 -04007908 if (!gl::ValidateSamplerObjectParameter(context, pname))
Geoff Langbfdea662014-07-23 14:16:32 -04007909 {
7910 return;
7911 }
7912
7913 if (!gl::ValidateTexParamParameters(context, pname, param))
7914 {
7915 return;
7916 }
7917
7918 if (!context->isSampler(sampler))
7919 {
Geoff Langb1196682014-07-23 13:47:29 -04007920 context->recordError(gl::Error(GL_INVALID_OPERATION));
7921 return;
Geoff Langbfdea662014-07-23 14:16:32 -04007922 }
7923
7924 context->samplerParameteri(sampler, pname, param);
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007925 }
7926}
7927
Kenneth Russell67ea1902014-10-06 16:44:50 -07007928void GL_APIENTRY glSamplerParameteriv(GLuint sampler, GLenum pname, const GLint* param)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007929{
Jamie Madillf6cc8cc2013-07-03 12:44:15 -04007930 glSamplerParameteri(sampler, pname, *param);
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007931}
7932
Kenneth Russell67ea1902014-10-06 16:44:50 -07007933void GL_APIENTRY glSamplerParameterf(GLuint sampler, GLenum pname, GLfloat param)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007934{
7935 EVENT("(GLuint sampler = %u, GLenum pname = 0x%X, GLfloat param = %g)", sampler, pname, param);
7936
Geoff Langbfdea662014-07-23 14:16:32 -04007937 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04007938 if (context)
7939 {
7940 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007941 {
Geoff Langb1196682014-07-23 13:47:29 -04007942 context->recordError(gl::Error(GL_INVALID_OPERATION));
7943 return;
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00007944 }
Geoff Langbfdea662014-07-23 14:16:32 -04007945
Geoff Langb1196682014-07-23 13:47:29 -04007946 if (!gl::ValidateSamplerObjectParameter(context, pname))
Geoff Langbfdea662014-07-23 14:16:32 -04007947 {
7948 return;
7949 }
7950
7951 if (!gl::ValidateTexParamParameters(context, pname, static_cast<GLint>(param)))
7952 {
7953 return;
7954 }
7955
7956 if (!context->isSampler(sampler))
7957 {
Geoff Langb1196682014-07-23 13:47:29 -04007958 context->recordError(gl::Error(GL_INVALID_OPERATION));
7959 return;
Geoff Langbfdea662014-07-23 14:16:32 -04007960 }
7961
7962 context->samplerParameterf(sampler, pname, param);
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007963 }
7964}
7965
Kenneth Russell67ea1902014-10-06 16:44:50 -07007966void GL_APIENTRY glSamplerParameterfv(GLuint sampler, GLenum pname, const GLfloat* param)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007967{
Jamie Madillf6cc8cc2013-07-03 12:44:15 -04007968 glSamplerParameterf(sampler, pname, *param);
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007969}
7970
Kenneth Russell67ea1902014-10-06 16:44:50 -07007971void GL_APIENTRY glGetSamplerParameteriv(GLuint sampler, GLenum pname, GLint* params)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007972{
7973 EVENT("(GLuint sampler = %u, GLenum pname = 0x%X, GLint* params = 0x%0.8p)", sampler, pname, params);
7974
Geoff Langbfdea662014-07-23 14:16:32 -04007975 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04007976 if (context)
7977 {
7978 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007979 {
Geoff Langb1196682014-07-23 13:47:29 -04007980 context->recordError(gl::Error(GL_INVALID_OPERATION));
7981 return;
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00007982 }
Geoff Langbfdea662014-07-23 14:16:32 -04007983
Geoff Langb1196682014-07-23 13:47:29 -04007984 if (!gl::ValidateSamplerObjectParameter(context, pname))
Geoff Langbfdea662014-07-23 14:16:32 -04007985 {
7986 return;
7987 }
7988
7989 if (!context->isSampler(sampler))
7990 {
Geoff Langb1196682014-07-23 13:47:29 -04007991 context->recordError(gl::Error(GL_INVALID_OPERATION));
7992 return;
Geoff Langbfdea662014-07-23 14:16:32 -04007993 }
7994
7995 *params = context->getSamplerParameteri(sampler, pname);
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007996 }
7997}
7998
Kenneth Russell67ea1902014-10-06 16:44:50 -07007999void GL_APIENTRY glGetSamplerParameterfv(GLuint sampler, GLenum pname, GLfloat* params)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008000{
8001 EVENT("(GLuint sample = %ur, GLenum pname = 0x%X, GLfloat* params = 0x%0.8p)", sampler, pname, params);
8002
Geoff Langbfdea662014-07-23 14:16:32 -04008003 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04008004 if (context)
8005 {
8006 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008007 {
Geoff Langb1196682014-07-23 13:47:29 -04008008 context->recordError(gl::Error(GL_INVALID_OPERATION));
8009 return;
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00008010 }
Geoff Langbfdea662014-07-23 14:16:32 -04008011
Geoff Langb1196682014-07-23 13:47:29 -04008012 if (!gl::ValidateSamplerObjectParameter(context, pname))
Geoff Langbfdea662014-07-23 14:16:32 -04008013 {
8014 return;
8015 }
8016
8017 if (!context->isSampler(sampler))
8018 {
Geoff Langb1196682014-07-23 13:47:29 -04008019 context->recordError(gl::Error(GL_INVALID_OPERATION));
8020 return;
Geoff Langbfdea662014-07-23 14:16:32 -04008021 }
8022
8023 *params = context->getSamplerParameterf(sampler, pname);
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008024 }
8025}
8026
Kenneth Russell67ea1902014-10-06 16:44:50 -07008027void GL_APIENTRY glVertexAttribDivisor(GLuint index, GLuint divisor)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008028{
8029 EVENT("(GLuint index = %u, GLuint divisor = %u)", index, divisor);
8030
Geoff Langbfdea662014-07-23 14:16:32 -04008031 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04008032 if (context)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008033 {
Geoff Langbfdea662014-07-23 14:16:32 -04008034 if (context->getClientVersion() < 3)
8035 {
Geoff Langb1196682014-07-23 13:47:29 -04008036 context->recordError(gl::Error(GL_INVALID_OPERATION));
8037 return;
8038 }
8039
8040 if (index >= gl::MAX_VERTEX_ATTRIBS)
8041 {
8042 context->recordError(gl::Error(GL_INVALID_VALUE));
8043 return;
Geoff Langbfdea662014-07-23 14:16:32 -04008044 }
8045
8046 context->setVertexAttribDivisor(index, divisor);
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008047 }
8048}
8049
Kenneth Russell67ea1902014-10-06 16:44:50 -07008050void GL_APIENTRY glBindTransformFeedback(GLenum target, GLuint id)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008051{
8052 EVENT("(GLenum target = 0x%X, GLuint id = %u)", target, id);
8053
Geoff Langbfdea662014-07-23 14:16:32 -04008054 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04008055 if (context)
8056 {
8057 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008058 {
Geoff Langb1196682014-07-23 13:47:29 -04008059 context->recordError(gl::Error(GL_INVALID_OPERATION));
8060 return;
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00008061 }
Geoff Langbfdea662014-07-23 14:16:32 -04008062
8063 switch (target)
8064 {
8065 case GL_TRANSFORM_FEEDBACK:
8066 {
8067 // Cannot bind a transform feedback object if the current one is started and not paused (3.0.2 pg 85 section 2.14.1)
8068 gl::TransformFeedback *curTransformFeedback = context->getState().getCurrentTransformFeedback();
8069 if (curTransformFeedback && curTransformFeedback->isStarted() && !curTransformFeedback->isPaused())
8070 {
Geoff Langb1196682014-07-23 13:47:29 -04008071 context->recordError(gl::Error(GL_INVALID_OPERATION));
8072 return;
Geoff Langbfdea662014-07-23 14:16:32 -04008073 }
8074
8075 // Cannot bind a transform feedback object that does not exist (3.0.2 pg 85 section 2.14.1)
8076 if (context->getTransformFeedback(id) == NULL)
8077 {
Geoff Langb1196682014-07-23 13:47:29 -04008078 context->recordError(gl::Error(GL_INVALID_OPERATION));
8079 return;
Geoff Langbfdea662014-07-23 14:16:32 -04008080 }
8081
8082 context->bindTransformFeedback(id);
8083 }
8084 break;
8085
8086 default:
Geoff Langb1196682014-07-23 13:47:29 -04008087 context->recordError(gl::Error(GL_INVALID_ENUM));
8088 return;
Geoff Langbfdea662014-07-23 14:16:32 -04008089 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008090 }
8091}
8092
Kenneth Russell67ea1902014-10-06 16:44:50 -07008093void GL_APIENTRY glDeleteTransformFeedbacks(GLsizei n, const GLuint* ids)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008094{
8095 EVENT("(GLsizei n = %d, const GLuint* ids = 0x%0.8p)", n, ids);
8096
Geoff Langbfdea662014-07-23 14:16:32 -04008097 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04008098 if (context)
8099 {
8100 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008101 {
Geoff Langb1196682014-07-23 13:47:29 -04008102 context->recordError(gl::Error(GL_INVALID_OPERATION));
8103 return;
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00008104 }
Geoff Langbfdea662014-07-23 14:16:32 -04008105
8106 for (int i = 0; i < n; i++)
8107 {
8108 context->deleteTransformFeedback(ids[i]);
8109 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008110 }
8111}
8112
Kenneth Russell67ea1902014-10-06 16:44:50 -07008113void GL_APIENTRY glGenTransformFeedbacks(GLsizei n, GLuint* ids)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008114{
8115 EVENT("(GLsizei n = %d, GLuint* ids = 0x%0.8p)", n, ids);
8116
Geoff Langbfdea662014-07-23 14:16:32 -04008117 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04008118 if (context)
8119 {
8120 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008121 {
Geoff Langb1196682014-07-23 13:47:29 -04008122 context->recordError(gl::Error(GL_INVALID_OPERATION));
8123 return;
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00008124 }
Geoff Langbfdea662014-07-23 14:16:32 -04008125
8126 for (int i = 0; i < n; i++)
8127 {
8128 ids[i] = context->createTransformFeedback();
8129 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008130 }
8131}
8132
Kenneth Russell67ea1902014-10-06 16:44:50 -07008133GLboolean GL_APIENTRY glIsTransformFeedback(GLuint id)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008134{
8135 EVENT("(GLuint id = %u)", id);
8136
Geoff Langbfdea662014-07-23 14:16:32 -04008137 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04008138 if (context)
8139 {
8140 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008141 {
Geoff Langb1196682014-07-23 13:47:29 -04008142 context->recordError(gl::Error(GL_INVALID_OPERATION));
8143 return GL_FALSE;
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00008144 }
Geoff Langbfdea662014-07-23 14:16:32 -04008145
8146 return ((context->getTransformFeedback(id) != NULL) ? GL_TRUE : GL_FALSE);
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008147 }
8148
8149 return GL_FALSE;
8150}
8151
Kenneth Russell67ea1902014-10-06 16:44:50 -07008152void GL_APIENTRY glPauseTransformFeedback(void)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008153{
8154 EVENT("(void)");
8155
Geoff Langbfdea662014-07-23 14:16:32 -04008156 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04008157 if (context)
8158 {
8159 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008160 {
Geoff Langb1196682014-07-23 13:47:29 -04008161 context->recordError(gl::Error(GL_INVALID_OPERATION));
8162 return;
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00008163 }
Geoff Langbfdea662014-07-23 14:16:32 -04008164
8165 gl::TransformFeedback *transformFeedback = context->getState().getCurrentTransformFeedback();
8166 ASSERT(transformFeedback != NULL);
8167
8168 // Current transform feedback must be started and not paused in order to pause (3.0.2 pg 86)
8169 if (!transformFeedback->isStarted() || transformFeedback->isPaused())
8170 {
Geoff Langb1196682014-07-23 13:47:29 -04008171 context->recordError(gl::Error(GL_INVALID_OPERATION));
8172 return;
Geoff Langbfdea662014-07-23 14:16:32 -04008173 }
8174
8175 transformFeedback->pause();
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008176 }
8177}
8178
Kenneth Russell67ea1902014-10-06 16:44:50 -07008179void GL_APIENTRY glResumeTransformFeedback(void)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008180{
8181 EVENT("(void)");
8182
Geoff Langbfdea662014-07-23 14:16:32 -04008183 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04008184 if (context)
8185 {
8186 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008187 {
Geoff Langb1196682014-07-23 13:47:29 -04008188 context->recordError(gl::Error(GL_INVALID_OPERATION));
8189 return;
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00008190 }
Geoff Langbfdea662014-07-23 14:16:32 -04008191
8192 gl::TransformFeedback *transformFeedback = context->getState().getCurrentTransformFeedback();
8193 ASSERT(transformFeedback != NULL);
8194
8195 // Current transform feedback must be started and paused in order to resume (3.0.2 pg 86)
8196 if (!transformFeedback->isStarted() || !transformFeedback->isPaused())
8197 {
Geoff Langb1196682014-07-23 13:47:29 -04008198 context->recordError(gl::Error(GL_INVALID_OPERATION));
8199 return;
Geoff Langbfdea662014-07-23 14:16:32 -04008200 }
8201
8202 transformFeedback->resume();
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008203 }
8204}
8205
Kenneth Russell67ea1902014-10-06 16:44:50 -07008206void GL_APIENTRY glGetProgramBinary(GLuint program, GLsizei bufSize, GLsizei* length, GLenum* binaryFormat, GLvoid* binary)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008207{
8208 EVENT("(GLuint program = %u, GLsizei bufSize = %d, GLsizei* length = 0x%0.8p, GLenum* binaryFormat = 0x%0.8p, GLvoid* binary = 0x%0.8p)",
8209 program, bufSize, length, binaryFormat, binary);
8210
Geoff Langbfdea662014-07-23 14:16:32 -04008211 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04008212 if (context)
8213 {
8214 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008215 {
Geoff Langb1196682014-07-23 13:47:29 -04008216 context->recordError(gl::Error(GL_INVALID_OPERATION));
8217 return;
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00008218 }
Geoff Langbfdea662014-07-23 14:16:32 -04008219
8220 // glGetProgramBinary
8221 UNIMPLEMENTED();
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008222 }
8223}
8224
Kenneth Russell67ea1902014-10-06 16:44:50 -07008225void GL_APIENTRY glProgramBinary(GLuint program, GLenum binaryFormat, const GLvoid* binary, GLsizei length)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008226{
8227 EVENT("(GLuint program = %u, GLenum binaryFormat = 0x%X, const GLvoid* binary = 0x%0.8p, GLsizei length = %d)",
8228 program, binaryFormat, binary, length);
8229
Geoff Langbfdea662014-07-23 14:16:32 -04008230 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04008231 if (context)
8232 {
8233 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008234 {
Geoff Langb1196682014-07-23 13:47:29 -04008235 context->recordError(gl::Error(GL_INVALID_OPERATION));
8236 return;
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00008237 }
Geoff Langbfdea662014-07-23 14:16:32 -04008238
8239 // glProgramBinary
8240 UNIMPLEMENTED();
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008241 }
8242}
8243
Kenneth Russell67ea1902014-10-06 16:44:50 -07008244void GL_APIENTRY glProgramParameteri(GLuint program, GLenum pname, GLint value)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008245{
8246 EVENT("(GLuint program = %u, GLenum pname = 0x%X, GLint value = %d)",
8247 program, pname, value);
8248
Geoff Langbfdea662014-07-23 14:16:32 -04008249 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04008250 if (context)
8251 {
8252 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008253 {
Geoff Langb1196682014-07-23 13:47:29 -04008254 context->recordError(gl::Error(GL_INVALID_OPERATION));
8255 return;
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00008256 }
Geoff Langbfdea662014-07-23 14:16:32 -04008257
8258 // glProgramParameteri
8259 UNIMPLEMENTED();
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008260 }
8261}
8262
Kenneth Russell67ea1902014-10-06 16:44:50 -07008263void GL_APIENTRY glInvalidateFramebuffer(GLenum target, GLsizei numAttachments, const GLenum* attachments)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008264{
8265 EVENT("(GLenum target = 0x%X, GLsizei numAttachments = %d, const GLenum* attachments = 0x%0.8p)",
8266 target, numAttachments, attachments);
8267
Geoff Langbfdea662014-07-23 14:16:32 -04008268 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04008269 if (context)
8270 {
8271 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008272 {
Geoff Langb1196682014-07-23 13:47:29 -04008273 context->recordError(gl::Error(GL_INVALID_OPERATION));
8274 return;
shannonwoods@chromium.orgd63ef892013-05-30 00:10:56 +00008275 }
Geoff Langbfdea662014-07-23 14:16:32 -04008276
8277 if (!ValidateInvalidateFramebufferParameters(context, target, numAttachments, attachments))
8278 {
8279 return;
8280 }
8281
Jamie Madill2d96b9e2014-08-29 15:46:47 -04008282 gl::Framebuffer *framebuffer = context->getState().getTargetFramebuffer(target);
8283 if (framebuffer && framebuffer->completeness() == GL_FRAMEBUFFER_COMPLETE)
8284 {
8285 framebuffer->invalidate(context->getCaps(), numAttachments, attachments);
8286 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008287 }
8288}
8289
Kenneth Russell67ea1902014-10-06 16:44:50 -07008290void GL_APIENTRY glInvalidateSubFramebuffer(GLenum target, GLsizei numAttachments, const GLenum* attachments, GLint x, GLint y, GLsizei width, GLsizei height)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008291{
8292 EVENT("(GLenum target = 0x%X, GLsizei numAttachments = %d, const GLenum* attachments = 0x%0.8p, GLint x = %d, "
8293 "GLint y = %d, GLsizei width = %d, GLsizei height = %d)",
8294 target, numAttachments, attachments, x, y, width, height);
8295
Geoff Langbfdea662014-07-23 14:16:32 -04008296 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04008297 if (context)
8298 {
8299 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008300 {
Geoff Langb1196682014-07-23 13:47:29 -04008301 context->recordError(gl::Error(GL_INVALID_OPERATION));
8302 return;
shannonwoods@chromium.orgd63ef892013-05-30 00:10:56 +00008303 }
Geoff Langbfdea662014-07-23 14:16:32 -04008304
8305 if (!ValidateInvalidateFramebufferParameters(context, target, numAttachments, attachments))
8306 {
8307 return;
8308 }
8309
Jamie Madill2d96b9e2014-08-29 15:46:47 -04008310 gl::Framebuffer *framebuffer = context->getState().getTargetFramebuffer(target);
8311 if (framebuffer && framebuffer->completeness() == GL_FRAMEBUFFER_COMPLETE)
8312 {
8313 framebuffer->invalidateSub(context->getCaps(), numAttachments, attachments, x, y, width, height);
8314 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008315 }
8316}
8317
Kenneth Russell67ea1902014-10-06 16:44:50 -07008318void GL_APIENTRY glTexStorage2D(GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008319{
8320 EVENT("(GLenum target = 0x%X, GLsizei levels = %d, GLenum internalformat = 0x%X, GLsizei width = %d, GLsizei height = %d)",
8321 target, levels, internalformat, width, height);
8322
Geoff Langbfdea662014-07-23 14:16:32 -04008323 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04008324 if (context)
8325 {
8326 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008327 {
Geoff Langb1196682014-07-23 13:47:29 -04008328 context->recordError(gl::Error(GL_INVALID_OPERATION));
8329 return;
shannonwoods@chromium.org8757c062013-05-30 00:14:24 +00008330 }
Geoff Langbfdea662014-07-23 14:16:32 -04008331
8332 if (!ValidateES3TexStorageParameters(context, target, levels, internalformat, width, height, 1))
8333 {
8334 return;
8335 }
8336
8337 switch (target)
8338 {
8339 case GL_TEXTURE_2D:
8340 {
8341 gl::Texture2D *texture2d = context->getTexture2D();
Geoff Lang1f8532b2014-09-05 09:46:13 -04008342 gl::Error error = texture2d->storage(levels, internalformat, width, height);
8343 if (error.isError())
8344 {
8345 context->recordError(error);
8346 return;
8347 }
Geoff Langbfdea662014-07-23 14:16:32 -04008348 }
8349 break;
8350
8351 case GL_TEXTURE_CUBE_MAP:
8352 {
8353 gl::TextureCubeMap *textureCube = context->getTextureCubeMap();
Geoff Lang1f8532b2014-09-05 09:46:13 -04008354 gl::Error error = textureCube->storage(levels, internalformat, width);
8355 if (error.isError())
8356 {
8357 context->recordError(error);
8358 return;
8359 }
Geoff Langbfdea662014-07-23 14:16:32 -04008360 }
8361 break;
8362
8363 default:
Geoff Langb1196682014-07-23 13:47:29 -04008364 context->recordError(gl::Error(GL_INVALID_ENUM));
8365 return;
Geoff Langbfdea662014-07-23 14:16:32 -04008366 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008367 }
8368}
8369
Kenneth Russell67ea1902014-10-06 16:44:50 -07008370void GL_APIENTRY glTexStorage3D(GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008371{
8372 EVENT("(GLenum target = 0x%X, GLsizei levels = %d, GLenum internalformat = 0x%X, GLsizei width = %d, "
8373 "GLsizei height = %d, GLsizei depth = %d)",
8374 target, levels, internalformat, width, height, depth);
8375
Geoff Langbfdea662014-07-23 14:16:32 -04008376 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04008377 if (context)
8378 {
8379 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008380 {
Geoff Langb1196682014-07-23 13:47:29 -04008381 context->recordError(gl::Error(GL_INVALID_OPERATION));
8382 return;
shannon.woods%transgaming.com@gtempaccount.com14eb55e2013-04-13 03:35:06 +00008383 }
Geoff Langbfdea662014-07-23 14:16:32 -04008384
8385 if (!ValidateES3TexStorageParameters(context, target, levels, internalformat, width, height, depth))
8386 {
8387 return;
8388 }
8389
8390 switch (target)
8391 {
8392 case GL_TEXTURE_3D:
8393 {
8394 gl::Texture3D *texture3d = context->getTexture3D();
Geoff Lang1f8532b2014-09-05 09:46:13 -04008395 gl::Error error = texture3d->storage(levels, internalformat, width, height, depth);
8396 if (error.isError())
8397 {
8398 context->recordError(error);
8399 return;
8400 }
Geoff Langbfdea662014-07-23 14:16:32 -04008401 }
8402 break;
8403
8404 case GL_TEXTURE_2D_ARRAY:
8405 {
8406 gl::Texture2DArray *texture2darray = context->getTexture2DArray();
Geoff Lang1f8532b2014-09-05 09:46:13 -04008407 gl::Error error = texture2darray->storage(levels, internalformat, width, height, depth);
8408 if (error.isError())
8409 {
8410 context->recordError(error);
8411 return;
8412 }
Geoff Langbfdea662014-07-23 14:16:32 -04008413 }
8414 break;
8415
8416 default:
8417 UNREACHABLE();
8418 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008419 }
8420}
8421
Kenneth Russell67ea1902014-10-06 16:44:50 -07008422void GL_APIENTRY glGetInternalformativ(GLenum target, GLenum internalformat, GLenum pname, GLsizei bufSize, GLint* params)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008423{
8424 EVENT("(GLenum target = 0x%X, GLenum internalformat = 0x%X, GLenum pname = 0x%X, GLsizei bufSize = %d, "
8425 "GLint* params = 0x%0.8p)",
8426 target, internalformat, pname, bufSize, params);
8427
Geoff Langbfdea662014-07-23 14:16:32 -04008428 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04008429 if (context)
8430 {
8431 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008432 {
Geoff Langb1196682014-07-23 13:47:29 -04008433 context->recordError(gl::Error(GL_INVALID_OPERATION));
8434 return;
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00008435 }
Geoff Langbfdea662014-07-23 14:16:32 -04008436
8437 const gl::TextureCaps &formatCaps = context->getTextureCaps().get(internalformat);
8438 if (!formatCaps.renderable)
8439 {
Geoff Langb1196682014-07-23 13:47:29 -04008440 context->recordError(gl::Error(GL_INVALID_ENUM));
8441 return;
Geoff Langbfdea662014-07-23 14:16:32 -04008442 }
8443
8444 if (target != GL_RENDERBUFFER)
8445 {
Geoff Langb1196682014-07-23 13:47:29 -04008446 context->recordError(gl::Error(GL_INVALID_ENUM));
8447 return;
Geoff Langbfdea662014-07-23 14:16:32 -04008448 }
8449
8450 if (bufSize < 0)
8451 {
Geoff Langb1196682014-07-23 13:47:29 -04008452 context->recordError(gl::Error(GL_INVALID_VALUE));
8453 return;
Geoff Langbfdea662014-07-23 14:16:32 -04008454 }
8455
8456 switch (pname)
8457 {
8458 case GL_NUM_SAMPLE_COUNTS:
8459 if (bufSize != 0)
Geoff Lang5f4c4632014-07-03 13:46:52 -04008460 {
8461 *params = formatCaps.sampleCounts.size();
8462 }
Geoff Langbfdea662014-07-23 14:16:32 -04008463 break;
Geoff Langb1196682014-07-23 13:47:29 -04008464
Geoff Langbfdea662014-07-23 14:16:32 -04008465 case GL_SAMPLES:
Geoff Lang5f4c4632014-07-03 13:46:52 -04008466 std::copy_n(formatCaps.sampleCounts.rbegin(), std::min<size_t>(bufSize, formatCaps.sampleCounts.size()), params);
Geoff Langbfdea662014-07-23 14:16:32 -04008467 break;
Geoff Langb1196682014-07-23 13:47:29 -04008468
Geoff Langbfdea662014-07-23 14:16:32 -04008469 default:
Geoff Langb1196682014-07-23 13:47:29 -04008470 context->recordError(gl::Error(GL_INVALID_ENUM));
8471 return;
Geoff Langbfdea662014-07-23 14:16:32 -04008472 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008473 }
8474}
8475
8476// Extension functions
8477
Kenneth Russell67ea1902014-10-06 16:44:50 -07008478void GL_APIENTRY glBlitFramebufferANGLE(GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1,
daniel@transgaming.com4cbc5902010-08-24 19:20:26 +00008479 GLbitfield mask, GLenum filter)
8480{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00008481 EVENT("(GLint srcX0 = %d, GLint srcY0 = %d, GLint srcX1 = %d, GLint srcY1 = %d, "
daniel@transgaming.com4cbc5902010-08-24 19:20:26 +00008482 "GLint dstX0 = %d, GLint dstY0 = %d, GLint dstX1 = %d, GLint dstY1 = %d, "
8483 "GLbitfield mask = 0x%X, GLenum filter = 0x%X)",
8484 srcX0, srcY0, srcX1, srcX1, dstX0, dstY0, dstX1, dstY1, mask, filter);
8485
Geoff Langbfdea662014-07-23 14:16:32 -04008486 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04008487 if (context)
8488 {
8489 if (!ValidateBlitFramebufferParameters(context, srcX0, srcY0, srcX1, srcY1,
8490 dstX0, dstY0, dstX1, dstY1, mask, filter,
8491 true))
daniel@transgaming.com4cbc5902010-08-24 19:20:26 +00008492 {
Geoff Langbfdea662014-07-23 14:16:32 -04008493 return;
daniel@transgaming.com4cbc5902010-08-24 19:20:26 +00008494 }
Geoff Langbfdea662014-07-23 14:16:32 -04008495
Geoff Lang64839152014-08-26 16:23:25 -04008496 gl::Error error = context->blitFramebuffer(srcX0, srcY0, srcX1, srcY1, dstX0, dstY0, dstX1, dstY1,
8497 mask, filter);
8498 if (error.isError())
8499 {
8500 context->recordError(error);
8501 return;
8502 }
daniel@transgaming.com4cbc5902010-08-24 19:20:26 +00008503 }
8504}
8505
Kenneth Russell67ea1902014-10-06 16:44:50 -07008506void GL_APIENTRY glTexImage3DOES(GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth,
daniel@transgaming.comfe4b8272010-04-08 03:51:20 +00008507 GLint border, GLenum format, GLenum type, const GLvoid* pixels)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00008508{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00008509 EVENT("(GLenum target = 0x%X, GLint level = %d, GLenum internalformat = 0x%X, "
daniel@transgaming.comb5b06162010-03-21 04:31:32 +00008510 "GLsizei width = %d, GLsizei height = %d, GLsizei depth = %d, GLint border = %d, "
daniel@transgaming.comfe4b8272010-04-08 03:51:20 +00008511 "GLenum format = 0x%X, GLenum type = 0x%x, const GLvoid* pixels = 0x%0.8p)",
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00008512 target, level, internalformat, width, height, depth, border, format, type, pixels);
8513
Geoff Langbfdea662014-07-23 14:16:32 -04008514 UNIMPLEMENTED(); // FIXME
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00008515}
daniel@transgaming.comce3d0f22010-05-04 03:35:14 +00008516
Kenneth Russell67ea1902014-10-06 16:44:50 -07008517void GL_APIENTRY glGetProgramBinaryOES(GLuint program, GLsizei bufSize, GLsizei *length,
apatrick@chromium.org3ce8dbc2012-06-08 17:52:30 +00008518 GLenum *binaryFormat, void *binary)
8519{
apatrick@chromium.org90080e32012-07-09 22:15:33 +00008520 EVENT("(GLenum program = 0x%X, bufSize = %d, length = 0x%0.8p, binaryFormat = 0x%0.8p, binary = 0x%0.8p)",
apatrick@chromium.org3ce8dbc2012-06-08 17:52:30 +00008521 program, bufSize, length, binaryFormat, binary);
8522
Geoff Langbfdea662014-07-23 14:16:32 -04008523 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04008524 if (context)
8525 {
8526 gl::Program *programObject = context->getProgram(program);
8527
8528 if (!programObject || !programObject->isLinked())
apatrick@chromium.org3ce8dbc2012-06-08 17:52:30 +00008529 {
Geoff Langb1196682014-07-23 13:47:29 -04008530 context->recordError(gl::Error(GL_INVALID_OPERATION));
8531 return;
apatrick@chromium.org3ce8dbc2012-06-08 17:52:30 +00008532 }
Geoff Langbfdea662014-07-23 14:16:32 -04008533
8534 gl::ProgramBinary *programBinary = programObject->getProgramBinary();
8535
8536 if (!programBinary)
8537 {
Geoff Langb1196682014-07-23 13:47:29 -04008538 context->recordError(gl::Error(GL_INVALID_OPERATION));
8539 return;
Geoff Langbfdea662014-07-23 14:16:32 -04008540 }
8541
Geoff Langb543aff2014-09-30 14:52:54 -04008542 gl::Error error = programBinary->save(binaryFormat, binary, bufSize, length);
8543 if (error.isError())
Geoff Langbfdea662014-07-23 14:16:32 -04008544 {
Geoff Langb543aff2014-09-30 14:52:54 -04008545 context->recordError(error);
Geoff Langb1196682014-07-23 13:47:29 -04008546 return;
Geoff Langbfdea662014-07-23 14:16:32 -04008547 }
apatrick@chromium.org3ce8dbc2012-06-08 17:52:30 +00008548 }
8549}
8550
Kenneth Russell67ea1902014-10-06 16:44:50 -07008551void GL_APIENTRY glProgramBinaryOES(GLuint program, GLenum binaryFormat,
apatrick@chromium.org3ce8dbc2012-06-08 17:52:30 +00008552 const void *binary, GLint length)
8553{
8554 EVENT("(GLenum program = 0x%X, binaryFormat = 0x%x, binary = 0x%0.8p, length = %d)",
8555 program, binaryFormat, binary, length);
8556
Geoff Langbfdea662014-07-23 14:16:32 -04008557 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04008558 if (context)
8559 {
Geoff Lang900013c2014-07-07 11:32:19 -04008560 const std::vector<GLenum> &programBinaryFormats = context->getCaps().programBinaryFormats;
8561 if (std::find(programBinaryFormats.begin(), programBinaryFormats.end(), binaryFormat) == programBinaryFormats.end())
apatrick@chromium.org3ce8dbc2012-06-08 17:52:30 +00008562 {
Geoff Langb1196682014-07-23 13:47:29 -04008563 context->recordError(gl::Error(GL_INVALID_ENUM));
8564 return;
apatrick@chromium.org3ce8dbc2012-06-08 17:52:30 +00008565 }
Geoff Langbfdea662014-07-23 14:16:32 -04008566
8567 gl::Program *programObject = context->getProgram(program);
Geoff Langbfdea662014-07-23 14:16:32 -04008568 if (!programObject)
8569 {
Geoff Langb1196682014-07-23 13:47:29 -04008570 context->recordError(gl::Error(GL_INVALID_OPERATION));
8571 return;
Geoff Langbfdea662014-07-23 14:16:32 -04008572 }
8573
Geoff Langb543aff2014-09-30 14:52:54 -04008574 gl::Error error = context->setProgramBinary(program, binaryFormat, binary, length);
8575 if (error.isError())
8576 {
8577 context->recordError(error);
8578 return;
8579 }
apatrick@chromium.org3ce8dbc2012-06-08 17:52:30 +00008580 }
8581}
8582
Kenneth Russell67ea1902014-10-06 16:44:50 -07008583void GL_APIENTRY glDrawBuffersEXT(GLsizei n, const GLenum *bufs)
shannon.woods%transgaming.com@gtempaccount.com4059a382013-04-13 03:31:16 +00008584{
8585 EVENT("(GLenum n = %d, bufs = 0x%0.8p)", n, bufs);
8586
Geoff Langbfdea662014-07-23 14:16:32 -04008587 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04008588 if (context)
shannon.woods%transgaming.com@gtempaccount.com4059a382013-04-13 03:31:16 +00008589 {
Geoff Langbfdea662014-07-23 14:16:32 -04008590 if (n < 0 || static_cast<GLuint>(n) > context->getCaps().maxDrawBuffers)
shannon.woods%transgaming.com@gtempaccount.com4059a382013-04-13 03:31:16 +00008591 {
Geoff Langb1196682014-07-23 13:47:29 -04008592 context->recordError(gl::Error(GL_INVALID_VALUE));
8593 return;
Geoff Langbfdea662014-07-23 14:16:32 -04008594 }
8595
8596 if (context->getState().getDrawFramebuffer()->id() == 0)
8597 {
8598 if (n != 1)
shannon.woods%transgaming.com@gtempaccount.com4059a382013-04-13 03:31:16 +00008599 {
Geoff Langb1196682014-07-23 13:47:29 -04008600 context->recordError(gl::Error(GL_INVALID_OPERATION));
8601 return;
shannon.woods%transgaming.com@gtempaccount.com4059a382013-04-13 03:31:16 +00008602 }
8603
Geoff Langbfdea662014-07-23 14:16:32 -04008604 if (bufs[0] != GL_NONE && bufs[0] != GL_BACK)
shannon.woods%transgaming.com@gtempaccount.com4059a382013-04-13 03:31:16 +00008605 {
Geoff Langb1196682014-07-23 13:47:29 -04008606 context->recordError(gl::Error(GL_INVALID_OPERATION));
8607 return;
shannon.woods%transgaming.com@gtempaccount.com2fa73c52013-04-13 03:37:20 +00008608 }
shannon.woods%transgaming.com@gtempaccount.com4059a382013-04-13 03:31:16 +00008609 }
Geoff Langbfdea662014-07-23 14:16:32 -04008610 else
8611 {
8612 for (int colorAttachment = 0; colorAttachment < n; colorAttachment++)
8613 {
8614 const GLenum attachment = GL_COLOR_ATTACHMENT0_EXT + colorAttachment;
8615 if (bufs[colorAttachment] != GL_NONE && bufs[colorAttachment] != attachment)
8616 {
Geoff Langb1196682014-07-23 13:47:29 -04008617 context->recordError(gl::Error(GL_INVALID_OPERATION));
8618 return;
Geoff Langbfdea662014-07-23 14:16:32 -04008619 }
8620 }
8621 }
8622
8623 gl::Framebuffer *framebuffer = context->getState().getDrawFramebuffer();
8624
8625 for (unsigned int colorAttachment = 0; colorAttachment < static_cast<unsigned int>(n); colorAttachment++)
8626 {
8627 framebuffer->setDrawBufferState(colorAttachment, bufs[colorAttachment]);
8628 }
8629
8630 for (unsigned int colorAttachment = n; colorAttachment < context->getCaps().maxDrawBuffers; colorAttachment++)
8631 {
8632 framebuffer->setDrawBufferState(colorAttachment, GL_NONE);
8633 }
shannon.woods%transgaming.com@gtempaccount.com4059a382013-04-13 03:31:16 +00008634 }
8635}
8636
Kenneth Russell67ea1902014-10-06 16:44:50 -07008637void GL_APIENTRY glGetBufferPointervOES(GLenum target, GLenum pname, void** params)
Shannon Woodsb3801742014-03-27 14:59:19 -04008638{
8639 EVENT("(GLenum target = 0x%X, GLenum pname = 0x%X, GLvoid** params = 0x%0.8p)", target, pname, params);
8640
Geoff Langbfdea662014-07-23 14:16:32 -04008641 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04008642 if (context)
8643 {
8644 if (!gl::ValidBufferTarget(context, target))
Shannon Woodsb3801742014-03-27 14:59:19 -04008645 {
Geoff Langb1196682014-07-23 13:47:29 -04008646 context->recordError(gl::Error(GL_INVALID_ENUM));
8647 return;
Shannon Woodsb3801742014-03-27 14:59:19 -04008648 }
Geoff Langbfdea662014-07-23 14:16:32 -04008649
8650 if (pname != GL_BUFFER_MAP_POINTER)
8651 {
Geoff Langb1196682014-07-23 13:47:29 -04008652 context->recordError(gl::Error(GL_INVALID_ENUM));
8653 return;
Geoff Langbfdea662014-07-23 14:16:32 -04008654 }
8655
8656 gl::Buffer *buffer = context->getState().getTargetBuffer(target);
8657
8658 if (!buffer || !buffer->isMapped())
8659 {
8660 *params = NULL;
8661 }
8662 else
8663 {
8664 *params = buffer->getMapPointer();
8665 }
Shannon Woodsb3801742014-03-27 14:59:19 -04008666 }
8667}
8668
Kenneth Russell67ea1902014-10-06 16:44:50 -07008669void * GL_APIENTRY glMapBufferOES(GLenum target, GLenum access)
Shannon Woodsb3801742014-03-27 14:59:19 -04008670{
8671 EVENT("(GLenum target = 0x%X, GLbitfield access = 0x%X)", target, access);
8672
Geoff Langbfdea662014-07-23 14:16:32 -04008673 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04008674 if (context)
8675 {
8676 if (!gl::ValidBufferTarget(context, target))
Shannon Woodsb3801742014-03-27 14:59:19 -04008677 {
Geoff Langb1196682014-07-23 13:47:29 -04008678 context->recordError(gl::Error(GL_INVALID_ENUM));
8679 return NULL;
Shannon Woodsb3801742014-03-27 14:59:19 -04008680 }
Geoff Langbfdea662014-07-23 14:16:32 -04008681
8682 gl::Buffer *buffer = context->getState().getTargetBuffer(target);
8683
8684 if (buffer == NULL)
8685 {
Geoff Langb1196682014-07-23 13:47:29 -04008686 context->recordError(gl::Error(GL_INVALID_OPERATION));
8687 return NULL;
Geoff Langbfdea662014-07-23 14:16:32 -04008688 }
8689
8690 if (access != GL_WRITE_ONLY_OES)
8691 {
Geoff Langb1196682014-07-23 13:47:29 -04008692 context->recordError(gl::Error(GL_INVALID_ENUM));
8693 return NULL;
Geoff Langbfdea662014-07-23 14:16:32 -04008694 }
8695
8696 if (buffer->isMapped())
8697 {
Geoff Langb1196682014-07-23 13:47:29 -04008698 context->recordError(gl::Error(GL_INVALID_OPERATION));
8699 return NULL;
Geoff Langbfdea662014-07-23 14:16:32 -04008700 }
8701
Geoff Lang2a1c15a2014-07-25 11:43:00 -04008702 gl::Error error = buffer->mapRange(0, buffer->getSize(), GL_MAP_WRITE_BIT);
8703 if (error.isError())
8704 {
8705 context->recordError(error);
8706 return NULL;
8707 }
8708
8709 return buffer->getMapPointer();
Shannon Woodsb3801742014-03-27 14:59:19 -04008710 }
8711
8712 return NULL;
8713}
8714
Kenneth Russell67ea1902014-10-06 16:44:50 -07008715GLboolean GL_APIENTRY glUnmapBufferOES(GLenum target)
Shannon Woodsb3801742014-03-27 14:59:19 -04008716{
8717 EVENT("(GLenum target = 0x%X)", target);
8718
Geoff Langbfdea662014-07-23 14:16:32 -04008719 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04008720 if (context)
8721 {
8722 if (!gl::ValidBufferTarget(context, target))
Shannon Woodsb3801742014-03-27 14:59:19 -04008723 {
Geoff Langb1196682014-07-23 13:47:29 -04008724 context->recordError(gl::Error(GL_INVALID_ENUM));
8725 return GL_FALSE;
Shannon Woodsb3801742014-03-27 14:59:19 -04008726 }
Geoff Langbfdea662014-07-23 14:16:32 -04008727
8728 gl::Buffer *buffer = context->getState().getTargetBuffer(target);
8729
8730 if (buffer == NULL || !buffer->isMapped())
8731 {
Geoff Langb1196682014-07-23 13:47:29 -04008732 context->recordError(gl::Error(GL_INVALID_OPERATION));
8733 return GL_FALSE;
Geoff Langbfdea662014-07-23 14:16:32 -04008734 }
8735
8736 // TODO: detect if we had corruption. if so, throw an error and return false.
8737
Geoff Lang2a1c15a2014-07-25 11:43:00 -04008738 gl::Error error = buffer->unmap();
8739 if (error.isError())
8740 {
8741 context->recordError(error);
8742 return GL_FALSE;
8743 }
Geoff Langbfdea662014-07-23 14:16:32 -04008744
8745 return GL_TRUE;
Shannon Woodsb3801742014-03-27 14:59:19 -04008746 }
8747
8748 return GL_FALSE;
8749}
8750
Kenneth Russell67ea1902014-10-06 16:44:50 -07008751void* GL_APIENTRY glMapBufferRangeEXT (GLenum target, GLintptr offset, GLsizeiptr length, GLbitfield access)
Shannon Woods916e7692014-03-27 16:58:22 -04008752{
8753 EVENT("(GLenum target = 0x%X, GLintptr offset = %d, GLsizeiptr length = %d, GLbitfield access = 0x%X)",
8754 target, offset, length, access);
8755
Geoff Langbfdea662014-07-23 14:16:32 -04008756 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04008757 if (context)
8758 {
8759 if (!gl::ValidBufferTarget(context, target))
Shannon Woods916e7692014-03-27 16:58:22 -04008760 {
Geoff Langb1196682014-07-23 13:47:29 -04008761 context->recordError(gl::Error(GL_INVALID_ENUM));
8762 return NULL;
Shannon Woods916e7692014-03-27 16:58:22 -04008763 }
Geoff Langbfdea662014-07-23 14:16:32 -04008764
8765 if (offset < 0 || length < 0)
8766 {
Geoff Langb1196682014-07-23 13:47:29 -04008767 context->recordError(gl::Error(GL_INVALID_VALUE));
8768 return NULL;
Geoff Langbfdea662014-07-23 14:16:32 -04008769 }
8770
8771 gl::Buffer *buffer = context->getState().getTargetBuffer(target);
8772
8773 if (buffer == NULL)
8774 {
Geoff Langb1196682014-07-23 13:47:29 -04008775 context->recordError(gl::Error(GL_INVALID_OPERATION));
8776 return NULL;
Geoff Langbfdea662014-07-23 14:16:32 -04008777 }
8778
8779 // Check for buffer overflow
8780 size_t offsetSize = static_cast<size_t>(offset);
8781 size_t lengthSize = static_cast<size_t>(length);
8782
8783 if (!rx::IsUnsignedAdditionSafe(offsetSize, lengthSize) ||
8784 offsetSize + lengthSize > static_cast<size_t>(buffer->getSize()))
8785 {
Geoff Langb1196682014-07-23 13:47:29 -04008786 context->recordError(gl::Error(GL_INVALID_VALUE));
8787 return NULL;
Geoff Langbfdea662014-07-23 14:16:32 -04008788 }
8789
8790 // Check for invalid bits in the mask
8791 GLbitfield allAccessBits = GL_MAP_READ_BIT |
8792 GL_MAP_WRITE_BIT |
8793 GL_MAP_INVALIDATE_RANGE_BIT |
8794 GL_MAP_INVALIDATE_BUFFER_BIT |
8795 GL_MAP_FLUSH_EXPLICIT_BIT |
8796 GL_MAP_UNSYNCHRONIZED_BIT;
8797
8798 if (access & ~(allAccessBits))
8799 {
Geoff Langb1196682014-07-23 13:47:29 -04008800 context->recordError(gl::Error(GL_INVALID_VALUE));
8801 return NULL;
Geoff Langbfdea662014-07-23 14:16:32 -04008802 }
8803
8804 if (length == 0 || buffer->isMapped())
8805 {
Geoff Langb1196682014-07-23 13:47:29 -04008806 context->recordError(gl::Error(GL_INVALID_OPERATION));
8807 return NULL;
Geoff Langbfdea662014-07-23 14:16:32 -04008808 }
8809
8810 // Check for invalid bit combinations
8811 if ((access & (GL_MAP_READ_BIT | GL_MAP_WRITE_BIT)) == 0)
8812 {
Geoff Langb1196682014-07-23 13:47:29 -04008813 context->recordError(gl::Error(GL_INVALID_OPERATION));
8814 return NULL;
Geoff Langbfdea662014-07-23 14:16:32 -04008815 }
8816
8817 GLbitfield writeOnlyBits = GL_MAP_INVALIDATE_RANGE_BIT |
8818 GL_MAP_INVALIDATE_BUFFER_BIT |
8819 GL_MAP_UNSYNCHRONIZED_BIT;
8820
8821 if ((access & GL_MAP_READ_BIT) != 0 && (access & writeOnlyBits) != 0)
8822 {
Geoff Langb1196682014-07-23 13:47:29 -04008823 context->recordError(gl::Error(GL_INVALID_OPERATION));
8824 return NULL;
Geoff Langbfdea662014-07-23 14:16:32 -04008825 }
8826
8827 if ((access & GL_MAP_WRITE_BIT) == 0 && (access & GL_MAP_FLUSH_EXPLICIT_BIT) != 0)
8828 {
Geoff Langb1196682014-07-23 13:47:29 -04008829 context->recordError(gl::Error(GL_INVALID_OPERATION));
8830 return NULL;
Geoff Langbfdea662014-07-23 14:16:32 -04008831 }
8832
Geoff Lang2a1c15a2014-07-25 11:43:00 -04008833 gl::Error error = buffer->mapRange(offset, length, access);
8834 if (error.isError())
8835 {
8836 context->recordError(error);
8837 return NULL;
8838 }
8839
8840 return buffer->getMapPointer();
Shannon Woods916e7692014-03-27 16:58:22 -04008841 }
8842
8843 return NULL;
8844}
8845
Kenneth Russell67ea1902014-10-06 16:44:50 -07008846void GL_APIENTRY glFlushMappedBufferRangeEXT (GLenum target, GLintptr offset, GLsizeiptr length)
Shannon Woods916e7692014-03-27 16:58:22 -04008847{
8848 EVENT("(GLenum target = 0x%X, GLintptr offset = %d, GLsizeiptr length = %d)", target, offset, length);
8849
Geoff Langbfdea662014-07-23 14:16:32 -04008850 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04008851 if (context)
8852 {
8853 if (offset < 0 || length < 0)
Shannon Woods916e7692014-03-27 16:58:22 -04008854 {
Geoff Langb1196682014-07-23 13:47:29 -04008855 context->recordError(gl::Error(GL_INVALID_VALUE));
8856 return;
Shannon Woods916e7692014-03-27 16:58:22 -04008857 }
Geoff Langbfdea662014-07-23 14:16:32 -04008858
8859 if (!gl::ValidBufferTarget(context, target))
8860 {
Geoff Langb1196682014-07-23 13:47:29 -04008861 context->recordError(gl::Error(GL_INVALID_ENUM));
8862 return;
Geoff Langbfdea662014-07-23 14:16:32 -04008863 }
8864
8865 gl::Buffer *buffer = context->getState().getTargetBuffer(target);
8866
8867 if (buffer == NULL)
8868 {
Geoff Langb1196682014-07-23 13:47:29 -04008869 context->recordError(gl::Error(GL_INVALID_OPERATION));
8870 return;
Geoff Langbfdea662014-07-23 14:16:32 -04008871 }
8872
8873 if (!buffer->isMapped() || (buffer->getAccessFlags() & GL_MAP_FLUSH_EXPLICIT_BIT) == 0)
8874 {
Geoff Langb1196682014-07-23 13:47:29 -04008875 context->recordError(gl::Error(GL_INVALID_OPERATION));
8876 return;
Geoff Langbfdea662014-07-23 14:16:32 -04008877 }
8878
8879 // Check for buffer overflow
8880 size_t offsetSize = static_cast<size_t>(offset);
8881 size_t lengthSize = static_cast<size_t>(length);
8882
8883 if (!rx::IsUnsignedAdditionSafe(offsetSize, lengthSize) ||
8884 offsetSize + lengthSize > static_cast<size_t>(buffer->getMapLength()))
8885 {
Geoff Langb1196682014-07-23 13:47:29 -04008886 context->recordError(gl::Error(GL_INVALID_VALUE));
8887 return;
Geoff Langbfdea662014-07-23 14:16:32 -04008888 }
8889
8890 // We do not currently support a non-trivial implementation of FlushMappedBufferRange
Shannon Woods916e7692014-03-27 16:58:22 -04008891 }
8892}
8893
Kenneth Russell67ea1902014-10-06 16:44:50 -07008894__eglMustCastToProperFunctionPointerType EGLAPIENTRY glGetProcAddress(const char *procname)
daniel@transgaming.comce3d0f22010-05-04 03:35:14 +00008895{
8896 struct Extension
8897 {
8898 const char *name;
8899 __eglMustCastToProperFunctionPointerType address;
8900 };
8901
8902 static const Extension glExtensions[] =
8903 {
8904 {"glTexImage3DOES", (__eglMustCastToProperFunctionPointerType)glTexImage3DOES},
daniel@transgaming.com01868132010-08-24 19:21:17 +00008905 {"glBlitFramebufferANGLE", (__eglMustCastToProperFunctionPointerType)glBlitFramebufferANGLE},
daniel@transgaming.com1fe96c92011-01-14 15:08:44 +00008906 {"glRenderbufferStorageMultisampleANGLE", (__eglMustCastToProperFunctionPointerType)glRenderbufferStorageMultisampleANGLE},
apatrick@chromium.orgd3bd0ad2010-08-30 18:55:36 +00008907 {"glDeleteFencesNV", (__eglMustCastToProperFunctionPointerType)glDeleteFencesNV},
8908 {"glGenFencesNV", (__eglMustCastToProperFunctionPointerType)glGenFencesNV},
8909 {"glIsFenceNV", (__eglMustCastToProperFunctionPointerType)glIsFenceNV},
8910 {"glTestFenceNV", (__eglMustCastToProperFunctionPointerType)glTestFenceNV},
8911 {"glGetFenceivNV", (__eglMustCastToProperFunctionPointerType)glGetFenceivNV},
8912 {"glFinishFenceNV", (__eglMustCastToProperFunctionPointerType)glFinishFenceNV},
8913 {"glSetFenceNV", (__eglMustCastToProperFunctionPointerType)glSetFenceNV},
zmo@google.coma574f782011-10-03 21:45:23 +00008914 {"glGetTranslatedShaderSourceANGLE", (__eglMustCastToProperFunctionPointerType)glGetTranslatedShaderSourceANGLE},
daniel@transgaming.com0bd1f2f2011-11-11 04:19:03 +00008915 {"glTexStorage2DEXT", (__eglMustCastToProperFunctionPointerType)glTexStorage2DEXT},
daniel@transgaming.com709ed112011-11-12 03:18:10 +00008916 {"glGetGraphicsResetStatusEXT", (__eglMustCastToProperFunctionPointerType)glGetGraphicsResetStatusEXT},
8917 {"glReadnPixelsEXT", (__eglMustCastToProperFunctionPointerType)glReadnPixelsEXT},
8918 {"glGetnUniformfvEXT", (__eglMustCastToProperFunctionPointerType)glGetnUniformfvEXT},
8919 {"glGetnUniformivEXT", (__eglMustCastToProperFunctionPointerType)glGetnUniformivEXT},
daniel@transgaming.com86bdb822012-01-20 18:24:39 +00008920 {"glGenQueriesEXT", (__eglMustCastToProperFunctionPointerType)glGenQueriesEXT},
8921 {"glDeleteQueriesEXT", (__eglMustCastToProperFunctionPointerType)glDeleteQueriesEXT},
8922 {"glIsQueryEXT", (__eglMustCastToProperFunctionPointerType)glIsQueryEXT},
8923 {"glBeginQueryEXT", (__eglMustCastToProperFunctionPointerType)glBeginQueryEXT},
8924 {"glEndQueryEXT", (__eglMustCastToProperFunctionPointerType)glEndQueryEXT},
8925 {"glGetQueryivEXT", (__eglMustCastToProperFunctionPointerType)glGetQueryivEXT},
8926 {"glGetQueryObjectuivEXT", (__eglMustCastToProperFunctionPointerType)glGetQueryObjectuivEXT},
shannon.woods%transgaming.com@gtempaccount.com77d94722013-04-13 03:34:22 +00008927 {"glDrawBuffersEXT", (__eglMustCastToProperFunctionPointerType)glDrawBuffersEXT},
daniel@transgaming.comdce02fd2012-01-27 15:39:51 +00008928 {"glVertexAttribDivisorANGLE", (__eglMustCastToProperFunctionPointerType)glVertexAttribDivisorANGLE},
8929 {"glDrawArraysInstancedANGLE", (__eglMustCastToProperFunctionPointerType)glDrawArraysInstancedANGLE},
8930 {"glDrawElementsInstancedANGLE", (__eglMustCastToProperFunctionPointerType)glDrawElementsInstancedANGLE},
apatrick@chromium.org3ce8dbc2012-06-08 17:52:30 +00008931 {"glGetProgramBinaryOES", (__eglMustCastToProperFunctionPointerType)glGetProgramBinaryOES},
Shannon Woodsb3801742014-03-27 14:59:19 -04008932 {"glProgramBinaryOES", (__eglMustCastToProperFunctionPointerType)glProgramBinaryOES},
8933 {"glGetBufferPointervOES", (__eglMustCastToProperFunctionPointerType)glGetBufferPointervOES},
8934 {"glMapBufferOES", (__eglMustCastToProperFunctionPointerType)glMapBufferOES},
Shannon Woods916e7692014-03-27 16:58:22 -04008935 {"glUnmapBufferOES", (__eglMustCastToProperFunctionPointerType)glUnmapBufferOES},
8936 {"glMapBufferRangeEXT", (__eglMustCastToProperFunctionPointerType)glMapBufferRangeEXT},
8937 {"glFlushMappedBufferRangeEXT", (__eglMustCastToProperFunctionPointerType)glFlushMappedBufferRangeEXT}, };
daniel@transgaming.comce3d0f22010-05-04 03:35:14 +00008938
shannon.woods@transgaming.comd438fd42013-02-28 23:17:45 +00008939 for (unsigned int ext = 0; ext < ArraySize(glExtensions); ext++)
daniel@transgaming.comce3d0f22010-05-04 03:35:14 +00008940 {
8941 if (strcmp(procname, glExtensions[ext].name) == 0)
8942 {
8943 return (__eglMustCastToProperFunctionPointerType)glExtensions[ext].address;
8944 }
8945 }
8946
8947 return NULL;
8948}
8949
daniel@transgaming.com17f548c2011-11-09 17:47:02 +00008950// Non-public functions used by EGL
8951
Kenneth Russell67ea1902014-10-06 16:44:50 -07008952bool EGLAPIENTRY glBindTexImage(egl::Surface *surface)
jbauman@chromium.orgae345802011-03-30 22:04:25 +00008953{
8954 EVENT("(egl::Surface* surface = 0x%0.8p)",
8955 surface);
8956
Geoff Langbfdea662014-07-23 14:16:32 -04008957 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04008958 if (context)
8959 {
8960 gl::Texture2D *textureObject = context->getTexture2D();
8961 ASSERT(textureObject != NULL);
8962
8963 if (textureObject->isImmutable())
jbauman@chromium.orgae345802011-03-30 22:04:25 +00008964 {
Geoff Langbfdea662014-07-23 14:16:32 -04008965 return false;
jbauman@chromium.orgae345802011-03-30 22:04:25 +00008966 }
Geoff Langbfdea662014-07-23 14:16:32 -04008967
8968 textureObject->bindTexImage(surface);
jbauman@chromium.orgae345802011-03-30 22:04:25 +00008969 }
daniel@transgaming.com64a0fb22011-11-11 04:10:40 +00008970
8971 return true;
jbauman@chromium.orgae345802011-03-30 22:04:25 +00008972}
8973
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00008974}