blob: b15c44553af099fb113425ada5c7fe256f40e347 [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);
Jamie Madill48faf802014-11-06 15:27:22 -0500624
625 return framebuffer->completeness(context->getData());
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000626 }
627
628 return 0;
629}
630
Kenneth Russell67ea1902014-10-06 16:44:50 -0700631void GL_APIENTRY glClear(GLbitfield mask)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000632{
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +0000633 EVENT("(GLbitfield mask = 0x%X)", mask);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000634
Geoff Langbfdea662014-07-23 14:16:32 -0400635 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -0400636 if (context)
637 {
638 gl::Framebuffer *framebufferObject = context->getState().getDrawFramebuffer();
Jamie Madill48faf802014-11-06 15:27:22 -0500639 ASSERT(framebufferObject);
Geoff Langbfdea662014-07-23 14:16:32 -0400640
Jamie Madill48faf802014-11-06 15:27:22 -0500641 if (framebufferObject->completeness(context->getData()) != GL_FRAMEBUFFER_COMPLETE)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000642 {
Geoff Langb1196682014-07-23 13:47:29 -0400643 context->recordError(gl::Error(GL_INVALID_FRAMEBUFFER_OPERATION));
644 return;
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000645 }
Geoff Langbfdea662014-07-23 14:16:32 -0400646
647 if ((mask & ~(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT)) != 0)
648 {
Geoff Langb1196682014-07-23 13:47:29 -0400649 context->recordError(gl::Error(GL_INVALID_VALUE));
650 return;
Geoff Langbfdea662014-07-23 14:16:32 -0400651 }
652
Geoff Langcc79b8c2014-07-25 13:48:02 -0400653 gl::Error error = context->clear(mask);
654 if (error.isError())
655 {
656 context->recordError(error);
657 return;
658 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000659 }
660}
661
Kenneth Russell67ea1902014-10-06 16:44:50 -0700662void GL_APIENTRY glClearColor(GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000663{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +0000664 EVENT("(GLclampf red = %f, GLclampf green = %f, GLclampf blue = %f, GLclampf alpha = %f)",
daniel@transgaming.comb5b06162010-03-21 04:31:32 +0000665 red, green, blue, alpha);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000666
Geoff Langbfdea662014-07-23 14:16:32 -0400667 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -0400668 if (context)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000669 {
Geoff Langbfdea662014-07-23 14:16:32 -0400670 context->getState().setClearColor(red, green, blue, alpha);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000671 }
672}
673
Kenneth Russell67ea1902014-10-06 16:44:50 -0700674void GL_APIENTRY glClearDepthf(GLclampf depth)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000675{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +0000676 EVENT("(GLclampf depth = %f)", depth);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000677
Geoff Langbfdea662014-07-23 14:16:32 -0400678 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -0400679 if (context)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000680 {
Geoff Langbfdea662014-07-23 14:16:32 -0400681 context->getState().setClearDepth(depth);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000682 }
683}
684
Kenneth Russell67ea1902014-10-06 16:44:50 -0700685void GL_APIENTRY glClearStencil(GLint s)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000686{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +0000687 EVENT("(GLint s = %d)", s);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000688
Geoff Langbfdea662014-07-23 14:16:32 -0400689 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -0400690 if (context)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000691 {
Geoff Langbfdea662014-07-23 14:16:32 -0400692 context->getState().setClearStencil(s);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000693 }
694}
695
Kenneth Russell67ea1902014-10-06 16:44:50 -0700696void GL_APIENTRY glColorMask(GLboolean red, GLboolean green, GLboolean blue, GLboolean alpha)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000697{
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +0000698 EVENT("(GLboolean red = %d, GLboolean green = %u, GLboolean blue = %u, GLboolean alpha = %u)",
daniel@transgaming.comb5b06162010-03-21 04:31:32 +0000699 red, green, blue, alpha);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000700
Geoff Langbfdea662014-07-23 14:16:32 -0400701 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -0400702 if (context)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000703 {
Geoff Langbfdea662014-07-23 14:16:32 -0400704 context->getState().setColorMask(red == GL_TRUE, green == GL_TRUE, blue == GL_TRUE, alpha == GL_TRUE);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000705 }
706}
707
Kenneth Russell67ea1902014-10-06 16:44:50 -0700708void GL_APIENTRY glCompileShader(GLuint shader)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000709{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +0000710 EVENT("(GLuint shader = %d)", shader);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000711
Geoff Langbfdea662014-07-23 14:16:32 -0400712 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -0400713 if (context)
714 {
715 gl::Shader *shaderObject = context->getShader(shader);
716
717 if (!shaderObject)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000718 {
Geoff Langbfdea662014-07-23 14:16:32 -0400719 if (context->getProgram(shader))
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000720 {
Geoff Langb1196682014-07-23 13:47:29 -0400721 context->recordError(gl::Error(GL_INVALID_OPERATION));
722 return;
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000723 }
Geoff Langbfdea662014-07-23 14:16:32 -0400724 else
daniel@transgaming.com5d752f22010-10-07 13:37:20 +0000725 {
Geoff Langb1196682014-07-23 13:47:29 -0400726 context->recordError(gl::Error(GL_INVALID_VALUE));
727 return;
daniel@transgaming.com5d752f22010-10-07 13:37:20 +0000728 }
daniel@transgaming.com01868132010-08-24 19:21:17 +0000729 }
Geoff Langbfdea662014-07-23 14:16:32 -0400730
Jamie Madill245d3602014-11-13 10:03:30 -0500731 shaderObject->compile(context->getData());
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000732 }
Geoff Langbfdea662014-07-23 14:16:32 -0400733}
734
Kenneth Russell67ea1902014-10-06 16:44:50 -0700735void GL_APIENTRY glCompressedTexImage2D(GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height,
Geoff Langbfdea662014-07-23 14:16:32 -0400736 GLint border, GLsizei imageSize, const GLvoid* data)
737{
738 EVENT("(GLenum target = 0x%X, GLint level = %d, GLenum internalformat = 0x%X, GLsizei width = %d, "
739 "GLsizei height = %d, GLint border = %d, GLsizei imageSize = %d, const GLvoid* data = 0x%0.8p)",
740 target, level, internalformat, width, height, border, imageSize, data);
741
742 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -0400743 if (context)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000744 {
Geoff Langbfdea662014-07-23 14:16:32 -0400745 if (context->getClientVersion() < 3 &&
746 !ValidateES2TexImageParameters(context, target, level, internalformat, true, false,
747 0, 0, width, height, border, GL_NONE, GL_NONE, data))
748 {
749 return;
750 }
751
752 if (context->getClientVersion() >= 3 &&
753 !ValidateES3TexImageParameters(context, target, level, internalformat, true, false,
754 0, 0, 0, width, height, 1, border, GL_NONE, GL_NONE, data))
755 {
756 return;
757 }
758
Geoff Lang5d601382014-07-22 15:14:06 -0400759 const gl::InternalFormat &formatInfo = gl::GetInternalFormatInfo(internalformat);
760 if (imageSize < 0 || static_cast<GLuint>(imageSize) != formatInfo.computeBlockSize(GL_UNSIGNED_BYTE, width, height))
Geoff Langbfdea662014-07-23 14:16:32 -0400761 {
Geoff Langb1196682014-07-23 13:47:29 -0400762 context->recordError(gl::Error(GL_INVALID_VALUE));
763 return;
Geoff Langbfdea662014-07-23 14:16:32 -0400764 }
765
766 switch (target)
767 {
768 case GL_TEXTURE_2D:
769 {
770 gl::Texture2D *texture = context->getTexture2D();
Jamie Madillc751d1e2014-10-21 17:46:29 -0400771 gl::Error error = texture->setCompressedImage(level, internalformat, width, height, imageSize, context->getState().getUnpackState(), data);
Geoff Langb5348332014-09-02 13:16:34 -0400772 if (error.isError())
773 {
774 context->recordError(error);
775 return;
776 }
Geoff Langbfdea662014-07-23 14:16:32 -0400777 }
778 break;
779
780 case GL_TEXTURE_CUBE_MAP_POSITIVE_X:
781 case GL_TEXTURE_CUBE_MAP_NEGATIVE_X:
782 case GL_TEXTURE_CUBE_MAP_POSITIVE_Y:
783 case GL_TEXTURE_CUBE_MAP_NEGATIVE_Y:
784 case GL_TEXTURE_CUBE_MAP_POSITIVE_Z:
785 case GL_TEXTURE_CUBE_MAP_NEGATIVE_Z:
786 {
787 gl::TextureCubeMap *texture = context->getTextureCubeMap();
Jamie Madillc751d1e2014-10-21 17:46:29 -0400788 gl::Error error = texture->setCompressedImage(target, level, internalformat, width, height, imageSize, context->getState().getUnpackState(), data);
Geoff Langb5348332014-09-02 13:16:34 -0400789 if (error.isError())
790 {
791 context->recordError(error);
792 return;
793 }
Geoff Langbfdea662014-07-23 14:16:32 -0400794 }
795 break;
796
797 default:
Geoff Langb1196682014-07-23 13:47:29 -0400798 context->recordError(gl::Error(GL_INVALID_ENUM));
799 return;
Geoff Langbfdea662014-07-23 14:16:32 -0400800 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000801 }
802}
803
Kenneth Russell67ea1902014-10-06 16:44:50 -0700804void GL_APIENTRY glCompressedTexSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height,
daniel@transgaming.comfe4b8272010-04-08 03:51:20 +0000805 GLenum format, GLsizei imageSize, const GLvoid* data)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000806{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +0000807 EVENT("(GLenum target = 0x%X, GLint level = %d, GLint xoffset = %d, GLint yoffset = %d, "
daniel@transgaming.comb5b06162010-03-21 04:31:32 +0000808 "GLsizei width = %d, GLsizei height = %d, GLenum format = 0x%X, "
daniel@transgaming.comfe4b8272010-04-08 03:51:20 +0000809 "GLsizei imageSize = %d, const GLvoid* data = 0x%0.8p)",
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000810 target, level, xoffset, yoffset, width, height, format, imageSize, data);
811
Geoff Langbfdea662014-07-23 14:16:32 -0400812 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -0400813 if (context)
814 {
815 if (context->getClientVersion() < 3 &&
816 !ValidateES2TexImageParameters(context, target, level, GL_NONE, true, true,
817 xoffset, yoffset, width, height, 0, GL_NONE, GL_NONE, data))
daniel@transgaming.com01868132010-08-24 19:21:17 +0000818 {
Geoff Langbfdea662014-07-23 14:16:32 -0400819 return;
daniel@transgaming.com01868132010-08-24 19:21:17 +0000820 }
Geoff Langbfdea662014-07-23 14:16:32 -0400821
822 if (context->getClientVersion() >= 3 &&
823 !ValidateES3TexImageParameters(context, target, level, GL_NONE, true, true,
824 xoffset, yoffset, 0, width, height, 1, 0, GL_NONE, GL_NONE, data))
825 {
826 return;
827 }
828
Geoff Lang5d601382014-07-22 15:14:06 -0400829 const gl::InternalFormat &formatInfo = gl::GetInternalFormatInfo(format);
830 if (imageSize < 0 || static_cast<GLuint>(imageSize) != formatInfo.computeBlockSize(GL_UNSIGNED_BYTE, width, height))
Geoff Langbfdea662014-07-23 14:16:32 -0400831 {
Geoff Langb1196682014-07-23 13:47:29 -0400832 context->recordError(gl::Error(GL_INVALID_VALUE));
833 return;
Geoff Langbfdea662014-07-23 14:16:32 -0400834 }
835
836 switch (target)
837 {
838 case GL_TEXTURE_2D:
839 {
840 gl::Texture2D *texture = context->getTexture2D();
Jamie Madillc751d1e2014-10-21 17:46:29 -0400841 gl::Error error = texture->subImageCompressed(level, xoffset, yoffset, width, height, format, imageSize, context->getState().getUnpackState(), data);
Geoff Langb5348332014-09-02 13:16:34 -0400842 if (error.isError())
843 {
844 context->recordError(error);
845 return;
846 }
Geoff Langbfdea662014-07-23 14:16:32 -0400847 }
848 break;
849
850 case GL_TEXTURE_CUBE_MAP_POSITIVE_X:
851 case GL_TEXTURE_CUBE_MAP_NEGATIVE_X:
852 case GL_TEXTURE_CUBE_MAP_POSITIVE_Y:
853 case GL_TEXTURE_CUBE_MAP_NEGATIVE_Y:
854 case GL_TEXTURE_CUBE_MAP_POSITIVE_Z:
855 case GL_TEXTURE_CUBE_MAP_NEGATIVE_Z:
856 {
857 gl::TextureCubeMap *texture = context->getTextureCubeMap();
Jamie Madillc751d1e2014-10-21 17:46:29 -0400858 gl::Error error = texture->subImageCompressed(target, level, xoffset, yoffset, width, height, format, imageSize, context->getState().getUnpackState(), data);
Geoff Langb5348332014-09-02 13:16:34 -0400859 if (error.isError())
860 {
861 context->recordError(error);
862 return;
863 }
Geoff Langbfdea662014-07-23 14:16:32 -0400864 }
865 break;
866
867 default:
Geoff Langb1196682014-07-23 13:47:29 -0400868 context->recordError(gl::Error(GL_INVALID_ENUM));
869 return;
Geoff Langbfdea662014-07-23 14:16:32 -0400870 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000871 }
872}
873
Kenneth Russell67ea1902014-10-06 16:44:50 -0700874void 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 +0000875{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +0000876 EVENT("(GLenum target = 0x%X, GLint level = %d, GLenum internalformat = 0x%X, "
daniel@transgaming.comb5b06162010-03-21 04:31:32 +0000877 "GLint x = %d, GLint y = %d, GLsizei width = %d, GLsizei height = %d, GLint border = %d)",
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000878 target, level, internalformat, x, y, width, height, border);
879
Geoff Langbfdea662014-07-23 14:16:32 -0400880 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -0400881 if (context)
882 {
883 if (context->getClientVersion() < 3 &&
884 !ValidateES2CopyTexImageParameters(context, target, level, internalformat, false,
885 0, 0, x, y, width, height, border))
daniel@transgaming.comb8c28ed2010-04-13 03:26:32 +0000886 {
Geoff Langbfdea662014-07-23 14:16:32 -0400887 return;
daniel@transgaming.comb8c28ed2010-04-13 03:26:32 +0000888 }
Geoff Langbfdea662014-07-23 14:16:32 -0400889
890 if (context->getClientVersion() >= 3 &&
891 !ValidateES3CopyTexImageParameters(context, target, level, internalformat, false,
892 0, 0, 0, x, y, width, height, border))
893 {
894 return;
895 }
896
897 gl::Framebuffer *framebuffer = context->getState().getReadFramebuffer();
898
899 switch (target)
900 {
901 case GL_TEXTURE_2D:
902 {
903 gl::Texture2D *texture = context->getTexture2D();
Geoff Langef7b0162014-09-04 13:29:23 -0400904 gl::Error error = texture->copyImage(level, internalformat, x, y, width, height, framebuffer);
905 if (error.isError())
906 {
907 context->recordError(error);
908 return;
909 }
Geoff Langbfdea662014-07-23 14:16:32 -0400910 }
911 break;
912
913 case GL_TEXTURE_CUBE_MAP_POSITIVE_X:
914 case GL_TEXTURE_CUBE_MAP_NEGATIVE_X:
915 case GL_TEXTURE_CUBE_MAP_POSITIVE_Y:
916 case GL_TEXTURE_CUBE_MAP_NEGATIVE_Y:
917 case GL_TEXTURE_CUBE_MAP_POSITIVE_Z:
918 case GL_TEXTURE_CUBE_MAP_NEGATIVE_Z:
919 {
920 gl::TextureCubeMap *texture = context->getTextureCubeMap();
Geoff Langef7b0162014-09-04 13:29:23 -0400921 gl::Error error = texture->copyImage(target, level, internalformat, x, y, width, height, framebuffer);
922 if (error.isError())
923 {
924 context->recordError(error);
925 return;
926 }
Geoff Langbfdea662014-07-23 14:16:32 -0400927 }
928 break;
929
Geoff Langb1196682014-07-23 13:47:29 -0400930 default:
931 context->recordError(gl::Error(GL_INVALID_ENUM));
932 return;
Geoff Langbfdea662014-07-23 14:16:32 -0400933 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000934 }
935}
936
Kenneth Russell67ea1902014-10-06 16:44:50 -0700937void 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 +0000938{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +0000939 EVENT("(GLenum target = 0x%X, GLint level = %d, GLint xoffset = %d, GLint yoffset = %d, "
daniel@transgaming.comb5b06162010-03-21 04:31:32 +0000940 "GLint x = %d, GLint y = %d, GLsizei width = %d, GLsizei height = %d)",
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000941 target, level, xoffset, yoffset, x, y, width, height);
942
Geoff Langbfdea662014-07-23 14:16:32 -0400943 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -0400944 if (context)
945 {
946 if (context->getClientVersion() < 3 &&
947 !ValidateES2CopyTexImageParameters(context, target, level, GL_NONE, true,
948 xoffset, yoffset, x, y, width, height, 0))
daniel@transgaming.comb8c28ed2010-04-13 03:26:32 +0000949 {
Geoff Langbfdea662014-07-23 14:16:32 -0400950 return;
daniel@transgaming.comb8c28ed2010-04-13 03:26:32 +0000951 }
daniel@transgaming.comb8c28ed2010-04-13 03:26:32 +0000952
Geoff Langbfdea662014-07-23 14:16:32 -0400953 if (context->getClientVersion() >= 3 &&
954 !ValidateES3CopyTexImageParameters(context, target, level, GL_NONE, true,
955 xoffset, yoffset, 0, x, y, width, height, 0))
956 {
957 return;
958 }
959
960 gl::Framebuffer *framebuffer = context->getState().getReadFramebuffer();
961
962 switch (target)
963 {
964 case GL_TEXTURE_2D:
965 {
966 gl::Texture2D *texture = context->getTexture2D();
Geoff Langef7b0162014-09-04 13:29:23 -0400967 gl::Error error = texture->copySubImage(target, level, xoffset, yoffset, 0, x, y, width, height, framebuffer);
968 if (error.isError())
969 {
970 context->recordError(error);
971 return;
972 }
Geoff Langbfdea662014-07-23 14:16:32 -0400973 }
974 break;
975
976 case GL_TEXTURE_CUBE_MAP_POSITIVE_X:
977 case GL_TEXTURE_CUBE_MAP_NEGATIVE_X:
978 case GL_TEXTURE_CUBE_MAP_POSITIVE_Y:
979 case GL_TEXTURE_CUBE_MAP_NEGATIVE_Y:
980 case GL_TEXTURE_CUBE_MAP_POSITIVE_Z:
981 case GL_TEXTURE_CUBE_MAP_NEGATIVE_Z:
982 {
983 gl::TextureCubeMap *texture = context->getTextureCubeMap();
Geoff Langef7b0162014-09-04 13:29:23 -0400984 gl::Error error = texture->copySubImage(target, level, xoffset, yoffset, 0, x, y, width, height, framebuffer);
985 if (error.isError())
986 {
987 context->recordError(error);
988 return;
989 }
Geoff Langbfdea662014-07-23 14:16:32 -0400990 }
991 break;
992
993 default:
Geoff Langb1196682014-07-23 13:47:29 -0400994 context->recordError(gl::Error(GL_INVALID_ENUM));
995 return;
Geoff Langbfdea662014-07-23 14:16:32 -0400996 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000997 }
998}
999
Kenneth Russell67ea1902014-10-06 16:44:50 -07001000GLuint GL_APIENTRY glCreateProgram(void)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001001{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00001002 EVENT("()");
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001003
Geoff Langbfdea662014-07-23 14:16:32 -04001004 gl::Context *context = gl::getNonLostContext();
1005 if (context)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001006 {
Geoff Langbfdea662014-07-23 14:16:32 -04001007 return context->createProgram();
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001008 }
1009
1010 return 0;
1011}
1012
Kenneth Russell67ea1902014-10-06 16:44:50 -07001013GLuint GL_APIENTRY glCreateShader(GLenum type)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001014{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00001015 EVENT("(GLenum type = 0x%X)", type);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001016
Geoff Langbfdea662014-07-23 14:16:32 -04001017 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04001018 if (context)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001019 {
Geoff Langbfdea662014-07-23 14:16:32 -04001020 switch (type)
1021 {
1022 case GL_FRAGMENT_SHADER:
1023 case GL_VERTEX_SHADER:
1024 return context->createShader(type);
Geoff Langb1196682014-07-23 13:47:29 -04001025
Geoff Langbfdea662014-07-23 14:16:32 -04001026 default:
Geoff Langb1196682014-07-23 13:47:29 -04001027 context->recordError(gl::Error(GL_INVALID_ENUM));
1028 return 0;
Geoff Langbfdea662014-07-23 14:16:32 -04001029 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001030 }
1031
1032 return 0;
1033}
1034
Kenneth Russell67ea1902014-10-06 16:44:50 -07001035void GL_APIENTRY glCullFace(GLenum mode)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001036{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00001037 EVENT("(GLenum mode = 0x%X)", mode);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001038
Geoff Langb1196682014-07-23 13:47:29 -04001039 gl::Context *context = gl::getNonLostContext();
1040 if (context)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001041 {
Geoff Langb1196682014-07-23 13:47:29 -04001042 switch (mode)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001043 {
Geoff Langb1196682014-07-23 13:47:29 -04001044 case GL_FRONT:
1045 case GL_BACK:
1046 case GL_FRONT_AND_BACK:
1047 break;
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001048
Geoff Langb1196682014-07-23 13:47:29 -04001049 default:
1050 context->recordError(gl::Error(GL_INVALID_ENUM));
1051 return;
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001052 }
Geoff Langb1196682014-07-23 13:47:29 -04001053
1054 context->getState().setCullMode(mode);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001055 }
1056}
1057
Kenneth Russell67ea1902014-10-06 16:44:50 -07001058void GL_APIENTRY glDeleteBuffers(GLsizei n, const GLuint* buffers)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001059{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00001060 EVENT("(GLsizei n = %d, const GLuint* buffers = 0x%0.8p)", n, buffers);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001061
Geoff Langbfdea662014-07-23 14:16:32 -04001062 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04001063 if (context)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001064 {
Geoff Langb1196682014-07-23 13:47:29 -04001065 if (n < 0)
1066 {
1067 context->recordError(gl::Error(GL_INVALID_VALUE));
1068 return;
1069 }
1070
Geoff Langbfdea662014-07-23 14:16:32 -04001071 for (int i = 0; i < n; i++)
1072 {
1073 context->deleteBuffer(buffers[i]);
1074 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001075 }
1076}
1077
Kenneth Russell67ea1902014-10-06 16:44:50 -07001078void GL_APIENTRY glDeleteFencesNV(GLsizei n, const GLuint* fences)
apatrick@chromium.orgd3bd0ad2010-08-30 18:55:36 +00001079{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00001080 EVENT("(GLsizei n = %d, const GLuint* fences = 0x%0.8p)", n, fences);
apatrick@chromium.orgd3bd0ad2010-08-30 18:55:36 +00001081
Geoff Langbfdea662014-07-23 14:16:32 -04001082 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04001083 if (context)
apatrick@chromium.orgd3bd0ad2010-08-30 18:55:36 +00001084 {
Geoff Langb1196682014-07-23 13:47:29 -04001085 if (n < 0)
1086 {
1087 context->recordError(gl::Error(GL_INVALID_VALUE));
1088 return;
1089 }
1090
Geoff Langbfdea662014-07-23 14:16:32 -04001091 for (int i = 0; i < n; i++)
1092 {
1093 context->deleteFenceNV(fences[i]);
1094 }
apatrick@chromium.orgd3bd0ad2010-08-30 18:55:36 +00001095 }
1096}
1097
Kenneth Russell67ea1902014-10-06 16:44:50 -07001098void GL_APIENTRY glDeleteFramebuffers(GLsizei n, const GLuint* framebuffers)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001099{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00001100 EVENT("(GLsizei n = %d, const GLuint* framebuffers = 0x%0.8p)", n, framebuffers);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001101
Geoff Langbfdea662014-07-23 14:16:32 -04001102 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04001103 if (context)
1104 {
Geoff Langb1196682014-07-23 13:47:29 -04001105 if (n < 0)
1106 {
1107 context->recordError(gl::Error(GL_INVALID_VALUE));
1108 return;
1109 }
1110
Geoff Langbfdea662014-07-23 14:16:32 -04001111 for (int i = 0; i < n; i++)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001112 {
Geoff Langbfdea662014-07-23 14:16:32 -04001113 if (framebuffers[i] != 0)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001114 {
Geoff Langbfdea662014-07-23 14:16:32 -04001115 context->deleteFramebuffer(framebuffers[i]);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001116 }
1117 }
1118 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001119}
1120
Kenneth Russell67ea1902014-10-06 16:44:50 -07001121void GL_APIENTRY glDeleteProgram(GLuint program)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001122{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00001123 EVENT("(GLuint program = %d)", program);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001124
Geoff Langbfdea662014-07-23 14:16:32 -04001125 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04001126 if (context)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001127 {
Geoff Langb1196682014-07-23 13:47:29 -04001128 if (program == 0)
1129 {
1130 return;
1131 }
1132
Geoff Langbfdea662014-07-23 14:16:32 -04001133 if (!context->getProgram(program))
1134 {
1135 if(context->getShader(program))
1136 {
Geoff Langb1196682014-07-23 13:47:29 -04001137 context->recordError(gl::Error(GL_INVALID_OPERATION));
1138 return;
Geoff Langbfdea662014-07-23 14:16:32 -04001139 }
1140 else
1141 {
Geoff Langb1196682014-07-23 13:47:29 -04001142 context->recordError(gl::Error(GL_INVALID_VALUE));
1143 return;
Geoff Langbfdea662014-07-23 14:16:32 -04001144 }
1145 }
1146
1147 context->deleteProgram(program);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001148 }
1149}
1150
Kenneth Russell67ea1902014-10-06 16:44:50 -07001151void GL_APIENTRY glDeleteQueriesEXT(GLsizei n, const GLuint *ids)
daniel@transgaming.com86bdb822012-01-20 18:24:39 +00001152{
1153 EVENT("(GLsizei n = %d, const GLuint *ids = 0x%0.8p)", n, ids);
1154
Geoff Langbfdea662014-07-23 14:16:32 -04001155 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04001156 if (context)
daniel@transgaming.com86bdb822012-01-20 18:24:39 +00001157 {
Geoff Langb1196682014-07-23 13:47:29 -04001158 if (n < 0)
1159 {
1160 context->recordError(gl::Error(GL_INVALID_VALUE));
1161 return;
1162 }
1163
Geoff Langbfdea662014-07-23 14:16:32 -04001164 for (int i = 0; i < n; i++)
1165 {
1166 context->deleteQuery(ids[i]);
1167 }
daniel@transgaming.com86bdb822012-01-20 18:24:39 +00001168 }
1169}
1170
Kenneth Russell67ea1902014-10-06 16:44:50 -07001171void GL_APIENTRY glDeleteRenderbuffers(GLsizei n, const GLuint* renderbuffers)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001172{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00001173 EVENT("(GLsizei n = %d, const GLuint* renderbuffers = 0x%0.8p)", n, renderbuffers);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001174
Geoff Langbfdea662014-07-23 14:16:32 -04001175 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04001176 if (context)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001177 {
Geoff Langb1196682014-07-23 13:47:29 -04001178 if (n < 0)
1179 {
1180 context->recordError(gl::Error(GL_INVALID_VALUE));
1181 return;
1182 }
1183
Geoff Langbfdea662014-07-23 14:16:32 -04001184 for (int i = 0; i < n; i++)
1185 {
1186 context->deleteRenderbuffer(renderbuffers[i]);
1187 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001188 }
1189}
1190
Kenneth Russell67ea1902014-10-06 16:44:50 -07001191void GL_APIENTRY glDeleteShader(GLuint shader)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001192{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00001193 EVENT("(GLuint shader = %d)", shader);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001194
Geoff Langbfdea662014-07-23 14:16:32 -04001195 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04001196 if (context)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001197 {
Geoff Langb1196682014-07-23 13:47:29 -04001198 if (shader == 0)
1199 {
1200 return;
1201 }
1202
Geoff Langbfdea662014-07-23 14:16:32 -04001203 if (!context->getShader(shader))
1204 {
1205 if(context->getProgram(shader))
1206 {
Geoff Langb1196682014-07-23 13:47:29 -04001207 context->recordError(gl::Error(GL_INVALID_OPERATION));
1208 return;
Geoff Langbfdea662014-07-23 14:16:32 -04001209 }
1210 else
1211 {
Geoff Langb1196682014-07-23 13:47:29 -04001212 context->recordError(gl::Error(GL_INVALID_VALUE));
1213 return;
Geoff Langbfdea662014-07-23 14:16:32 -04001214 }
1215 }
1216
1217 context->deleteShader(shader);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001218 }
1219}
1220
Kenneth Russell67ea1902014-10-06 16:44:50 -07001221void GL_APIENTRY glDeleteTextures(GLsizei n, const GLuint* textures)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001222{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00001223 EVENT("(GLsizei n = %d, const GLuint* textures = 0x%0.8p)", n, textures);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001224
Geoff Langbfdea662014-07-23 14:16:32 -04001225 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04001226 if (context)
1227 {
Geoff Langb1196682014-07-23 13:47:29 -04001228 if (n < 0)
1229 {
1230 context->recordError(gl::Error(GL_INVALID_VALUE));
1231 return;
1232 }
1233
Geoff Langbfdea662014-07-23 14:16:32 -04001234 for (int i = 0; i < n; i++)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001235 {
Geoff Langbfdea662014-07-23 14:16:32 -04001236 if (textures[i] != 0)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001237 {
Geoff Langbfdea662014-07-23 14:16:32 -04001238 context->deleteTexture(textures[i]);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001239 }
1240 }
1241 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001242}
1243
Kenneth Russell67ea1902014-10-06 16:44:50 -07001244void GL_APIENTRY glDepthFunc(GLenum func)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001245{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00001246 EVENT("(GLenum func = 0x%X)", func);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001247
Geoff Langbfdea662014-07-23 14:16:32 -04001248 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04001249 if (context)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001250 {
Geoff Langb1196682014-07-23 13:47:29 -04001251 switch (func)
1252 {
1253 case GL_NEVER:
1254 case GL_ALWAYS:
1255 case GL_LESS:
1256 case GL_LEQUAL:
1257 case GL_EQUAL:
1258 case GL_GREATER:
1259 case GL_GEQUAL:
1260 case GL_NOTEQUAL:
1261 context->getState().setDepthFunc(func);
1262 break;
1263
1264 default:
1265 context->recordError(gl::Error(GL_INVALID_ENUM));
1266 return;
1267 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001268 }
1269}
1270
Kenneth Russell67ea1902014-10-06 16:44:50 -07001271void GL_APIENTRY glDepthMask(GLboolean flag)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001272{
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00001273 EVENT("(GLboolean flag = %u)", flag);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001274
Geoff Langbfdea662014-07-23 14:16:32 -04001275 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04001276 if (context)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001277 {
Geoff Langbfdea662014-07-23 14:16:32 -04001278 context->getState().setDepthMask(flag != GL_FALSE);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001279 }
1280}
1281
Kenneth Russell67ea1902014-10-06 16:44:50 -07001282void GL_APIENTRY glDepthRangef(GLclampf zNear, GLclampf zFar)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001283{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00001284 EVENT("(GLclampf zNear = %f, GLclampf zFar = %f)", zNear, zFar);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001285
Geoff Langbfdea662014-07-23 14:16:32 -04001286 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04001287 if (context)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001288 {
Geoff Langbfdea662014-07-23 14:16:32 -04001289 context->getState().setDepthRange(zNear, zFar);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001290 }
1291}
1292
Kenneth Russell67ea1902014-10-06 16:44:50 -07001293void GL_APIENTRY glDetachShader(GLuint program, GLuint shader)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001294{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00001295 EVENT("(GLuint program = %d, GLuint shader = %d)", program, shader);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001296
Geoff Langbfdea662014-07-23 14:16:32 -04001297 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04001298 if (context)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001299 {
Geoff Langbfdea662014-07-23 14:16:32 -04001300 gl::Program *programObject = context->getProgram(program);
1301 gl::Shader *shaderObject = context->getShader(shader);
1302
1303 if (!programObject)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001304 {
Geoff Langbfdea662014-07-23 14:16:32 -04001305 gl::Shader *shaderByProgramHandle;
1306 shaderByProgramHandle = context->getShader(program);
1307 if (!shaderByProgramHandle)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001308 {
Geoff Langb1196682014-07-23 13:47:29 -04001309 context->recordError(gl::Error(GL_INVALID_VALUE));
1310 return;
daniel@transgaming.com73c2c2e2010-04-13 03:26:11 +00001311 }
Geoff Langbfdea662014-07-23 14:16:32 -04001312 else
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001313 {
Geoff Langb1196682014-07-23 13:47:29 -04001314 context->recordError(gl::Error(GL_INVALID_OPERATION));
1315 return;
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001316 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001317 }
Geoff Langbfdea662014-07-23 14:16:32 -04001318
1319 if (!shaderObject)
1320 {
1321 gl::Program *programByShaderHandle = context->getProgram(shader);
1322 if (!programByShaderHandle)
1323 {
Geoff Langb1196682014-07-23 13:47:29 -04001324 context->recordError(gl::Error(GL_INVALID_VALUE));
1325 return;
Geoff Langbfdea662014-07-23 14:16:32 -04001326 }
1327 else
1328 {
Geoff Langb1196682014-07-23 13:47:29 -04001329 context->recordError(gl::Error(GL_INVALID_OPERATION));
1330 return;
Geoff Langbfdea662014-07-23 14:16:32 -04001331 }
1332 }
1333
1334 if (!programObject->detachShader(shaderObject))
1335 {
Geoff Langb1196682014-07-23 13:47:29 -04001336 context->recordError(gl::Error(GL_INVALID_OPERATION));
1337 return;
Geoff Langbfdea662014-07-23 14:16:32 -04001338 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001339 }
1340}
1341
Kenneth Russell67ea1902014-10-06 16:44:50 -07001342void GL_APIENTRY glDisable(GLenum cap)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001343{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00001344 EVENT("(GLenum cap = 0x%X)", cap);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001345
Geoff Langbfdea662014-07-23 14:16:32 -04001346 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04001347 if (context)
1348 {
1349 if (!ValidCap(context, cap))
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001350 {
Geoff Langb1196682014-07-23 13:47:29 -04001351 context->recordError(gl::Error(GL_INVALID_ENUM));
1352 return;
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001353 }
Geoff Langbfdea662014-07-23 14:16:32 -04001354
1355 context->getState().setEnableFeature(cap, false);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001356 }
1357}
1358
Kenneth Russell67ea1902014-10-06 16:44:50 -07001359void GL_APIENTRY glDisableVertexAttribArray(GLuint index)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001360{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00001361 EVENT("(GLuint index = %d)", index);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001362
Geoff Langbfdea662014-07-23 14:16:32 -04001363 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04001364 if (context)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001365 {
Geoff Langb1196682014-07-23 13:47:29 -04001366 if (index >= gl::MAX_VERTEX_ATTRIBS)
1367 {
1368 context->recordError(gl::Error(GL_INVALID_VALUE));
1369 return;
1370 }
1371
Geoff Langbfdea662014-07-23 14:16:32 -04001372 context->getState().setEnableVertexAttribArray(index, false);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001373 }
1374}
1375
Kenneth Russell67ea1902014-10-06 16:44:50 -07001376void GL_APIENTRY glDrawArrays(GLenum mode, GLint first, GLsizei count)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001377{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00001378 EVENT("(GLenum mode = 0x%X, GLint first = %d, GLsizei count = %d)", mode, first, count);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001379
Geoff Langbfdea662014-07-23 14:16:32 -04001380 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04001381 if (context)
1382 {
Jamie Madill2b976812014-08-25 15:47:49 -04001383 if (!ValidateDrawArrays(context, mode, first, count, 0))
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001384 {
Geoff Langbfdea662014-07-23 14:16:32 -04001385 return;
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001386 }
Geoff Langbfdea662014-07-23 14:16:32 -04001387
Geoff Langc77e8c32014-09-08 16:28:24 -04001388 gl::Error error = context->drawArrays(mode, first, count, 0);
1389 if (error.isError())
1390 {
1391 context->recordError(error);
1392 return;
1393 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001394 }
1395}
1396
Kenneth Russell67ea1902014-10-06 16:44:50 -07001397void GL_APIENTRY glDrawArraysInstancedANGLE(GLenum mode, GLint first, GLsizei count, GLsizei primcount)
daniel@transgaming.comd2820bf2012-01-27 15:38:48 +00001398{
1399 EVENT("(GLenum mode = 0x%X, GLint first = %d, GLsizei count = %d, GLsizei primcount = %d)", mode, first, count, primcount);
1400
Geoff Langbfdea662014-07-23 14:16:32 -04001401 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04001402 if (context)
1403 {
Geoff Lang87a93302014-09-16 13:29:43 -04001404 if (!ValidateDrawArraysInstancedANGLE(context, mode, first, count, primcount))
daniel@transgaming.comd2820bf2012-01-27 15:38:48 +00001405 {
Geoff Langbfdea662014-07-23 14:16:32 -04001406 return;
daniel@transgaming.comd2820bf2012-01-27 15:38:48 +00001407 }
Geoff Langbfdea662014-07-23 14:16:32 -04001408
Geoff Langc77e8c32014-09-08 16:28:24 -04001409 gl::Error error = context->drawArrays(mode, first, count, primcount);
1410 if (error.isError())
1411 {
1412 context->recordError(error);
1413 return;
1414 }
daniel@transgaming.comd2820bf2012-01-27 15:38:48 +00001415 }
1416}
1417
Kenneth Russell67ea1902014-10-06 16:44:50 -07001418void GL_APIENTRY glDrawElements(GLenum mode, GLsizei count, GLenum type, const GLvoid* indices)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001419{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00001420 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 +00001421 mode, count, type, indices);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001422
Geoff Langbfdea662014-07-23 14:16:32 -04001423 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04001424 if (context)
1425 {
Jamie Madill2b976812014-08-25 15:47:49 -04001426 rx::RangeUI indexRange;
1427 if (!ValidateDrawElements(context, mode, count, type, indices, 0, &indexRange))
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001428 {
Geoff Langbfdea662014-07-23 14:16:32 -04001429 return;
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001430 }
Geoff Langbfdea662014-07-23 14:16:32 -04001431
Geoff Langc77e8c32014-09-08 16:28:24 -04001432 gl::Error error = context->drawElements(mode, count, type, indices, 0, indexRange);
1433 if (error.isError())
1434 {
1435 context->recordError(error);
1436 return;
1437 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001438 }
1439}
1440
Kenneth Russell67ea1902014-10-06 16:44:50 -07001441void GL_APIENTRY glDrawElementsInstancedANGLE(GLenum mode, GLsizei count, GLenum type, const GLvoid *indices, GLsizei primcount)
daniel@transgaming.comd2820bf2012-01-27 15:38:48 +00001442{
1443 EVENT("(GLenum mode = 0x%X, GLsizei count = %d, GLenum type = 0x%X, const GLvoid* indices = 0x%0.8p, GLsizei primcount = %d)",
1444 mode, count, type, indices, primcount);
1445
Geoff Langbfdea662014-07-23 14:16:32 -04001446 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04001447 if (context)
1448 {
Jamie Madill2b976812014-08-25 15:47:49 -04001449 rx::RangeUI indexRange;
Geoff Lang87a93302014-09-16 13:29:43 -04001450 if (!ValidateDrawElementsInstancedANGLE(context, mode, count, type, indices, primcount, &indexRange))
daniel@transgaming.comd2820bf2012-01-27 15:38:48 +00001451 {
Geoff Langbfdea662014-07-23 14:16:32 -04001452 return;
daniel@transgaming.comd2820bf2012-01-27 15:38:48 +00001453 }
Geoff Langbfdea662014-07-23 14:16:32 -04001454
Geoff Langc77e8c32014-09-08 16:28:24 -04001455 gl::Error error = context->drawElements(mode, count, type, indices, primcount, indexRange);
1456 if (error.isError())
1457 {
1458 context->recordError(error);
1459 return;
1460 }
daniel@transgaming.comd2820bf2012-01-27 15:38:48 +00001461 }
1462}
1463
Kenneth Russell67ea1902014-10-06 16:44:50 -07001464void GL_APIENTRY glEnable(GLenum cap)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001465{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00001466 EVENT("(GLenum cap = 0x%X)", cap);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001467
Geoff Langbfdea662014-07-23 14:16:32 -04001468 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04001469 if (context)
1470 {
1471 if (!ValidCap(context, cap))
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001472 {
Geoff Langb1196682014-07-23 13:47:29 -04001473 context->recordError(gl::Error(GL_INVALID_ENUM));
1474 return;
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001475 }
Geoff Langbfdea662014-07-23 14:16:32 -04001476
1477 context->getState().setEnableFeature(cap, true);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001478 }
1479}
1480
Kenneth Russell67ea1902014-10-06 16:44:50 -07001481void GL_APIENTRY glEnableVertexAttribArray(GLuint index)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001482{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00001483 EVENT("(GLuint index = %d)", index);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001484
Geoff Langbfdea662014-07-23 14:16:32 -04001485 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04001486 if (context)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001487 {
Geoff Langb1196682014-07-23 13:47:29 -04001488 if (index >= gl::MAX_VERTEX_ATTRIBS)
1489 {
1490 context->recordError(gl::Error(GL_INVALID_VALUE));
1491 return;
1492 }
1493
Geoff Langbfdea662014-07-23 14:16:32 -04001494 context->getState().setEnableVertexAttribArray(index, true);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001495 }
1496}
1497
Kenneth Russell67ea1902014-10-06 16:44:50 -07001498void GL_APIENTRY glEndQueryEXT(GLenum target)
daniel@transgaming.com86bdb822012-01-20 18:24:39 +00001499{
1500 EVENT("GLenum target = 0x%X)", target);
1501
Geoff Langbfdea662014-07-23 14:16:32 -04001502 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04001503 if (context)
1504 {
1505 if (!ValidateEndQuery(context, target))
daniel@transgaming.com86bdb822012-01-20 18:24:39 +00001506 {
Geoff Langbfdea662014-07-23 14:16:32 -04001507 return;
daniel@transgaming.com86bdb822012-01-20 18:24:39 +00001508 }
Geoff Langbfdea662014-07-23 14:16:32 -04001509
Geoff Lang5aad9672014-09-08 11:10:42 -04001510 gl::Error error = context->endQuery(target);
1511 if (error.isError())
1512 {
1513 context->recordError(error);
1514 return;
1515 }
daniel@transgaming.com86bdb822012-01-20 18:24:39 +00001516 }
1517}
1518
Kenneth Russell67ea1902014-10-06 16:44:50 -07001519void GL_APIENTRY glFinishFenceNV(GLuint fence)
apatrick@chromium.orgd3bd0ad2010-08-30 18:55:36 +00001520{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00001521 EVENT("(GLuint fence = %d)", fence);
apatrick@chromium.orgd3bd0ad2010-08-30 18:55:36 +00001522
Geoff Langbfdea662014-07-23 14:16:32 -04001523 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04001524 if (context)
1525 {
1526 gl::FenceNV *fenceObject = context->getFenceNV(fence);
1527
1528 if (fenceObject == NULL)
apatrick@chromium.orgd3bd0ad2010-08-30 18:55:36 +00001529 {
Geoff Langb1196682014-07-23 13:47:29 -04001530 context->recordError(gl::Error(GL_INVALID_OPERATION));
1531 return;
apatrick@chromium.orgd3bd0ad2010-08-30 18:55:36 +00001532 }
Geoff Langbfdea662014-07-23 14:16:32 -04001533
1534 if (fenceObject->isFence() != GL_TRUE)
1535 {
Geoff Langb1196682014-07-23 13:47:29 -04001536 context->recordError(gl::Error(GL_INVALID_OPERATION));
1537 return;
Geoff Langbfdea662014-07-23 14:16:32 -04001538 }
1539
1540 fenceObject->finishFence();
apatrick@chromium.orgd3bd0ad2010-08-30 18:55:36 +00001541 }
1542}
1543
Kenneth Russell67ea1902014-10-06 16:44:50 -07001544void GL_APIENTRY glFinish(void)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001545{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00001546 EVENT("()");
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001547
Geoff Langbfdea662014-07-23 14:16:32 -04001548 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04001549 if (context)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001550 {
Geoff Lang26298562014-10-01 10:49:03 -04001551 gl::Error error = context->sync(true);
1552 if (error.isError())
1553 {
1554 context->recordError(error);
1555 return;
1556 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001557 }
1558}
1559
Kenneth Russell67ea1902014-10-06 16:44:50 -07001560void GL_APIENTRY glFlush(void)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001561{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00001562 EVENT("()");
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001563
Geoff Langbfdea662014-07-23 14:16:32 -04001564 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04001565 if (context)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001566 {
Geoff Lang26298562014-10-01 10:49:03 -04001567 gl::Error error = context->sync(false);
1568 if (error.isError())
1569 {
1570 context->recordError(error);
1571 return;
1572 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001573 }
1574}
1575
Kenneth Russell67ea1902014-10-06 16:44:50 -07001576void GL_APIENTRY glFramebufferRenderbuffer(GLenum target, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001577{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00001578 EVENT("(GLenum target = 0x%X, GLenum attachment = 0x%X, GLenum renderbuffertarget = 0x%X, "
daniel@transgaming.comb5b06162010-03-21 04:31:32 +00001579 "GLuint renderbuffer = %d)", target, attachment, renderbuffertarget, renderbuffer);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001580
Geoff Langbfdea662014-07-23 14:16:32 -04001581 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04001582 if (context)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001583 {
Geoff Langb1196682014-07-23 13:47:29 -04001584 if (!gl::ValidFramebufferTarget(target) || (renderbuffertarget != GL_RENDERBUFFER && renderbuffer != 0))
1585 {
1586 context->recordError(gl::Error(GL_INVALID_ENUM));
1587 return;
1588 }
1589
Geoff Langbfdea662014-07-23 14:16:32 -04001590 if (!gl::ValidateFramebufferRenderbufferParameters(context, target, attachment, renderbuffertarget, renderbuffer))
1591 {
1592 return;
1593 }
1594
1595 gl::Framebuffer *framebuffer = context->getState().getTargetFramebuffer(target);
1596 ASSERT(framebuffer);
1597
Geoff Langab75a052014-10-15 12:56:37 -04001598 if (renderbuffer != 0)
Geoff Langbfdea662014-07-23 14:16:32 -04001599 {
Geoff Langab75a052014-10-15 12:56:37 -04001600 gl::Renderbuffer *renderbufferObject = context->getRenderbuffer(renderbuffer);
1601 framebuffer->setRenderbufferAttachment(attachment, renderbufferObject);
Geoff Langbfdea662014-07-23 14:16:32 -04001602 }
1603 else
1604 {
Geoff Langab75a052014-10-15 12:56:37 -04001605 framebuffer->setNULLAttachment(attachment);
Geoff Langbfdea662014-07-23 14:16:32 -04001606 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001607 }
1608}
1609
Kenneth Russell67ea1902014-10-06 16:44:50 -07001610void GL_APIENTRY glFramebufferTexture2D(GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001611{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00001612 EVENT("(GLenum target = 0x%X, GLenum attachment = 0x%X, GLenum textarget = 0x%X, "
daniel@transgaming.comb5b06162010-03-21 04:31:32 +00001613 "GLuint texture = %d, GLint level = %d)", target, attachment, textarget, texture, level);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001614
Geoff Langbfdea662014-07-23 14:16:32 -04001615 gl::Context *context = gl::getNonLostContext();
1616 if (context)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001617 {
Geoff Langbfdea662014-07-23 14:16:32 -04001618 if (!ValidateFramebufferTexture2D(context, target, attachment, textarget, texture, level))
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001619 {
Geoff Langbfdea662014-07-23 14:16:32 -04001620 return;
1621 }
shannon.woods%transgaming.com@gtempaccount.com89ae1132013-04-13 03:28:43 +00001622
Geoff Langbfdea662014-07-23 14:16:32 -04001623 gl::Framebuffer *framebuffer = context->getState().getTargetFramebuffer(target);
Jamie Madill48faf802014-11-06 15:27:22 -05001624 ASSERT(framebuffer);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001625
Geoff Langab75a052014-10-15 12:56:37 -04001626 if (texture != 0)
Geoff Langbfdea662014-07-23 14:16:32 -04001627 {
Geoff Langab75a052014-10-15 12:56:37 -04001628 gl::Texture *textureObj = context->getTexture(texture);
1629 gl::ImageIndex index(textarget, level, gl::ImageIndex::ENTIRE_LEVEL);
1630 framebuffer->setTextureAttachment(attachment, textureObj, index);
Geoff Langbfdea662014-07-23 14:16:32 -04001631 }
1632 else
1633 {
Geoff Langab75a052014-10-15 12:56:37 -04001634 framebuffer->setNULLAttachment(attachment);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001635 }
1636 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001637}
1638
Kenneth Russell67ea1902014-10-06 16:44:50 -07001639void GL_APIENTRY glFrontFace(GLenum mode)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001640{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00001641 EVENT("(GLenum mode = 0x%X)", mode);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001642
Geoff Langb1196682014-07-23 13:47:29 -04001643 gl::Context *context = gl::getNonLostContext();
1644 if (context)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001645 {
Geoff Langb1196682014-07-23 13:47:29 -04001646 switch (mode)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001647 {
Geoff Langb1196682014-07-23 13:47:29 -04001648 case GL_CW:
1649 case GL_CCW:
1650 context->getState().setFrontFace(mode);
1651 break;
1652 default:
1653 context->recordError(gl::Error(GL_INVALID_ENUM));
1654 return;
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001655 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001656 }
1657}
1658
Kenneth Russell67ea1902014-10-06 16:44:50 -07001659void GL_APIENTRY glGenBuffers(GLsizei n, GLuint* buffers)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001660{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00001661 EVENT("(GLsizei n = %d, GLuint* buffers = 0x%0.8p)", n, buffers);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001662
Geoff Langbfdea662014-07-23 14:16:32 -04001663 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04001664 if (context)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001665 {
Geoff Langb1196682014-07-23 13:47:29 -04001666 if (n < 0)
1667 {
1668 context->recordError(gl::Error(GL_INVALID_VALUE));
1669 return;
1670 }
1671
Geoff Langbfdea662014-07-23 14:16:32 -04001672 for (int i = 0; i < n; i++)
1673 {
1674 buffers[i] = context->createBuffer();
1675 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001676 }
1677}
1678
Kenneth Russell67ea1902014-10-06 16:44:50 -07001679void GL_APIENTRY glGenerateMipmap(GLenum target)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001680{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00001681 EVENT("(GLenum target = 0x%X)", target);
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)
1685 {
1686 if (!ValidTextureTarget(context, target))
daniel@transgaming.com8fd99e22010-04-20 18:52:00 +00001687 {
Geoff Langb1196682014-07-23 13:47:29 -04001688 context->recordError(gl::Error(GL_INVALID_ENUM));
1689 return;
daniel@transgaming.com8fd99e22010-04-20 18:52:00 +00001690 }
Geoff Langbfdea662014-07-23 14:16:32 -04001691
1692 gl::Texture *texture = context->getTargetTexture(target);
1693
1694 if (texture == NULL)
1695 {
Geoff Langb1196682014-07-23 13:47:29 -04001696 context->recordError(gl::Error(GL_INVALID_OPERATION));
1697 return;
Geoff Langbfdea662014-07-23 14:16:32 -04001698 }
1699
1700 GLenum internalFormat = texture->getBaseLevelInternalFormat();
1701 const gl::TextureCaps &formatCaps = context->getTextureCaps().get(internalFormat);
Geoff Lang5d601382014-07-22 15:14:06 -04001702 const gl::InternalFormat &formatInfo = gl::GetInternalFormatInfo(internalFormat);
Geoff Langbfdea662014-07-23 14:16:32 -04001703
1704 // GenerateMipmap should not generate an INVALID_OPERATION for textures created with
1705 // unsized formats or that are color renderable and filterable. Since we do not track if
1706 // the texture was created with sized or unsized format (only sized formats are stored),
1707 // it is not possible to make sure the the LUMA formats can generate mipmaps (they should
1708 // be able to) because they aren't color renderable. Simply do a special case for LUMA
1709 // textures since they're the only texture format that can be created with unsized formats
1710 // that is not color renderable. New unsized formats are unlikely to be added, since ES2
1711 // was the last version to use add them.
1712 bool isLUMA = internalFormat == GL_LUMINANCE8_EXT ||
1713 internalFormat == GL_LUMINANCE8_ALPHA8_EXT ||
1714 internalFormat == GL_ALPHA8_EXT;
1715
Geoff Lang5d601382014-07-22 15:14:06 -04001716 if (formatInfo.depthBits > 0 || formatInfo.stencilBits > 0 || !formatCaps.filterable ||
1717 (!formatCaps.renderable && !isLUMA) || formatInfo.compressed)
Geoff Langbfdea662014-07-23 14:16:32 -04001718 {
Geoff Langb1196682014-07-23 13:47:29 -04001719 context->recordError(gl::Error(GL_INVALID_OPERATION));
1720 return;
Geoff Langbfdea662014-07-23 14:16:32 -04001721 }
1722
1723 // GL_EXT_sRGB does not support mipmap generation on sRGB textures
Geoff Lang5d601382014-07-22 15:14:06 -04001724 if (context->getClientVersion() == 2 && formatInfo.colorEncoding == GL_SRGB)
Geoff Langbfdea662014-07-23 14:16:32 -04001725 {
Geoff Langb1196682014-07-23 13:47:29 -04001726 context->recordError(gl::Error(GL_INVALID_OPERATION));
1727 return;
Geoff Langbfdea662014-07-23 14:16:32 -04001728 }
1729
1730 // Non-power of 2 ES2 check
1731 if (!context->getExtensions().textureNPOT && (!gl::isPow2(texture->getBaseLevelWidth()) || !gl::isPow2(texture->getBaseLevelHeight())))
1732 {
1733 ASSERT(context->getClientVersion() <= 2 && (target == GL_TEXTURE_2D || target == GL_TEXTURE_CUBE_MAP));
Geoff Langb1196682014-07-23 13:47:29 -04001734 context->recordError(gl::Error(GL_INVALID_OPERATION));
1735 return;
Geoff Langbfdea662014-07-23 14:16:32 -04001736 }
1737
1738 // Cube completeness check
1739 if (target == GL_TEXTURE_CUBE_MAP)
1740 {
1741 gl::TextureCubeMap *textureCube = static_cast<gl::TextureCubeMap *>(texture);
1742 if (!textureCube->isCubeComplete())
1743 {
Geoff Langb1196682014-07-23 13:47:29 -04001744 context->recordError(gl::Error(GL_INVALID_OPERATION));
1745 return;
Geoff Langbfdea662014-07-23 14:16:32 -04001746 }
1747 }
1748
Geoff Lang06ecf3d2014-09-23 16:39:50 -04001749 gl::Error error = texture->generateMipmaps();
1750 if (error.isError())
1751 {
1752 context->recordError(error);
1753 return;
1754 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001755 }
1756}
1757
Kenneth Russell67ea1902014-10-06 16:44:50 -07001758void GL_APIENTRY glGenFencesNV(GLsizei n, GLuint* fences)
apatrick@chromium.orgd3bd0ad2010-08-30 18:55:36 +00001759{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00001760 EVENT("(GLsizei n = %d, GLuint* fences = 0x%0.8p)", n, fences);
apatrick@chromium.orgd3bd0ad2010-08-30 18:55:36 +00001761
Geoff Langbfdea662014-07-23 14:16:32 -04001762 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04001763 if (context)
apatrick@chromium.orgd3bd0ad2010-08-30 18:55:36 +00001764 {
Geoff Langb1196682014-07-23 13:47:29 -04001765 if (n < 0)
1766 {
1767 context->recordError(gl::Error(GL_INVALID_VALUE));
1768 return;
1769 }
1770
Geoff Langbfdea662014-07-23 14:16:32 -04001771 for (int i = 0; i < n; i++)
1772 {
1773 fences[i] = context->createFenceNV();
1774 }
apatrick@chromium.orgd3bd0ad2010-08-30 18:55:36 +00001775 }
1776}
1777
Kenneth Russell67ea1902014-10-06 16:44:50 -07001778void GL_APIENTRY glGenFramebuffers(GLsizei n, GLuint* framebuffers)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001779{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00001780 EVENT("(GLsizei n = %d, GLuint* framebuffers = 0x%0.8p)", n, framebuffers);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001781
Geoff Langbfdea662014-07-23 14:16:32 -04001782 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04001783 if (context)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001784 {
Geoff Langb1196682014-07-23 13:47:29 -04001785 if (n < 0)
1786 {
1787 context->recordError(gl::Error(GL_INVALID_VALUE));
1788 return;
1789 }
1790
Geoff Langbfdea662014-07-23 14:16:32 -04001791 for (int i = 0; i < n; i++)
1792 {
1793 framebuffers[i] = context->createFramebuffer();
1794 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001795 }
1796}
1797
Kenneth Russell67ea1902014-10-06 16:44:50 -07001798void GL_APIENTRY glGenQueriesEXT(GLsizei n, GLuint* ids)
daniel@transgaming.com86bdb822012-01-20 18:24:39 +00001799{
1800 EVENT("(GLsizei n = %d, GLuint* ids = 0x%0.8p)", n, ids);
1801
Geoff Langbfdea662014-07-23 14:16:32 -04001802 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04001803 if (context)
1804 {
1805 if (n < 0)
daniel@transgaming.com86bdb822012-01-20 18:24:39 +00001806 {
Geoff Langb1196682014-07-23 13:47:29 -04001807 context->recordError(gl::Error(GL_INVALID_VALUE));
1808 return;
daniel@transgaming.com86bdb822012-01-20 18:24:39 +00001809 }
Geoff Langbfdea662014-07-23 14:16:32 -04001810
1811 for (GLsizei i = 0; i < n; i++)
1812 {
1813 ids[i] = context->createQuery();
1814 }
daniel@transgaming.com86bdb822012-01-20 18:24:39 +00001815 }
1816}
1817
Kenneth Russell67ea1902014-10-06 16:44:50 -07001818void GL_APIENTRY glGenRenderbuffers(GLsizei n, GLuint* renderbuffers)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001819{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00001820 EVENT("(GLsizei n = %d, GLuint* renderbuffers = 0x%0.8p)", n, renderbuffers);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001821
Geoff Langbfdea662014-07-23 14:16:32 -04001822 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04001823 if (context)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001824 {
Geoff Langb1196682014-07-23 13:47:29 -04001825 if (n < 0)
1826 {
1827 context->recordError(gl::Error(GL_INVALID_VALUE));
1828 return;
1829 }
1830
Geoff Langbfdea662014-07-23 14:16:32 -04001831 for (int i = 0; i < n; i++)
1832 {
1833 renderbuffers[i] = context->createRenderbuffer();
1834 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001835 }
1836}
1837
Kenneth Russell67ea1902014-10-06 16:44:50 -07001838void GL_APIENTRY glGenTextures(GLsizei n, GLuint* textures)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001839{
Jamie Madill1fc7e2c2014-01-21 16:47:10 -05001840 EVENT("(GLsizei n = %d, GLuint* textures = 0x%0.8p)", n, textures);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001841
Geoff Langbfdea662014-07-23 14:16:32 -04001842 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04001843 if (context)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001844 {
Geoff Langb1196682014-07-23 13:47:29 -04001845 if (n < 0)
1846 {
1847 context->recordError(gl::Error(GL_INVALID_VALUE));
1848 return;
1849 }
1850
Geoff Langbfdea662014-07-23 14:16:32 -04001851 for (int i = 0; i < n; i++)
1852 {
1853 textures[i] = context->createTexture();
1854 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001855 }
1856}
1857
Kenneth Russell67ea1902014-10-06 16:44:50 -07001858void 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 +00001859{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00001860 EVENT("(GLuint program = %d, GLuint index = %d, GLsizei bufsize = %d, GLsizei *length = 0x%0.8p, "
daniel@transgaming.com85423182010-04-22 13:35:27 +00001861 "GLint *size = 0x%0.8p, GLenum *type = %0.8p, GLchar *name = %0.8p)",
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001862 program, index, bufsize, length, size, type, name);
1863
Geoff Langbfdea662014-07-23 14:16:32 -04001864 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04001865 if (context)
1866 {
Geoff Langb1196682014-07-23 13:47:29 -04001867 if (bufsize < 0)
1868 {
1869 context->recordError(gl::Error(GL_INVALID_VALUE));
1870 return;
1871 }
1872
Geoff Langbfdea662014-07-23 14:16:32 -04001873 gl::Program *programObject = context->getProgram(program);
1874
1875 if (!programObject)
1876 {
1877 if (context->getShader(program))
1878 {
Geoff Langb1196682014-07-23 13:47:29 -04001879 context->recordError(gl::Error(GL_INVALID_OPERATION));
1880 return;
Geoff Langbfdea662014-07-23 14:16:32 -04001881 }
1882 else
1883 {
Geoff Langb1196682014-07-23 13:47:29 -04001884 context->recordError(gl::Error(GL_INVALID_VALUE));
1885 return;
Geoff Langbfdea662014-07-23 14:16:32 -04001886 }
1887 }
1888
1889 if (index >= (GLuint)programObject->getActiveAttributeCount())
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001890 {
Geoff Langb1196682014-07-23 13:47:29 -04001891 context->recordError(gl::Error(GL_INVALID_VALUE));
1892 return;
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001893 }
1894
Geoff Langbfdea662014-07-23 14:16:32 -04001895 programObject->getActiveAttribute(index, bufsize, length, size, type, name);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001896 }
1897}
1898
Kenneth Russell67ea1902014-10-06 16:44:50 -07001899void 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 +00001900{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00001901 EVENT("(GLuint program = %d, GLuint index = %d, GLsizei bufsize = %d, "
daniel@transgaming.comfe4b8272010-04-08 03:51:20 +00001902 "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 +00001903 program, index, bufsize, length, size, type, name);
1904
Geoff Langbfdea662014-07-23 14:16:32 -04001905
1906 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04001907 if (context)
1908 {
Geoff Langb1196682014-07-23 13:47:29 -04001909 if (bufsize < 0)
1910 {
1911 context->recordError(gl::Error(GL_INVALID_VALUE));
1912 return;
1913 }
1914
Geoff Langbfdea662014-07-23 14:16:32 -04001915 gl::Program *programObject = context->getProgram(program);
1916
1917 if (!programObject)
1918 {
1919 if (context->getShader(program))
1920 {
Geoff Langb1196682014-07-23 13:47:29 -04001921 context->recordError(gl::Error(GL_INVALID_OPERATION));
1922 return;
Geoff Langbfdea662014-07-23 14:16:32 -04001923 }
1924 else
1925 {
Geoff Langb1196682014-07-23 13:47:29 -04001926 context->recordError(gl::Error(GL_INVALID_VALUE));
1927 return;
Geoff Langbfdea662014-07-23 14:16:32 -04001928 }
1929 }
1930
1931 if (index >= (GLuint)programObject->getActiveUniformCount())
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001932 {
Geoff Langb1196682014-07-23 13:47:29 -04001933 context->recordError(gl::Error(GL_INVALID_VALUE));
1934 return;
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001935 }
1936
Geoff Langbfdea662014-07-23 14:16:32 -04001937 programObject->getActiveUniform(index, bufsize, length, size, type, name);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001938 }
1939}
1940
Kenneth Russell67ea1902014-10-06 16:44:50 -07001941void GL_APIENTRY glGetAttachedShaders(GLuint program, GLsizei maxcount, GLsizei* count, GLuint* shaders)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001942{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00001943 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 +00001944 program, maxcount, count, shaders);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001945
Geoff Langbfdea662014-07-23 14:16:32 -04001946 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04001947 if (context)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001948 {
Geoff Langb1196682014-07-23 13:47:29 -04001949 if (maxcount < 0)
1950 {
1951 context->recordError(gl::Error(GL_INVALID_VALUE));
1952 return;
1953 }
1954
Geoff Langbfdea662014-07-23 14:16:32 -04001955 gl::Program *programObject = context->getProgram(program);
1956
1957 if (!programObject)
1958 {
1959 if (context->getShader(program))
1960 {
Geoff Langb1196682014-07-23 13:47:29 -04001961 context->recordError(gl::Error(GL_INVALID_OPERATION));
1962 return;
Geoff Langbfdea662014-07-23 14:16:32 -04001963 }
1964 else
1965 {
Geoff Langb1196682014-07-23 13:47:29 -04001966 context->recordError(gl::Error(GL_INVALID_VALUE));
1967 return;
Geoff Langbfdea662014-07-23 14:16:32 -04001968 }
1969 }
1970
1971 return programObject->getAttachedShaders(maxcount, count, shaders);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001972 }
1973}
1974
Kenneth Russell67ea1902014-10-06 16:44:50 -07001975GLint GL_APIENTRY glGetAttribLocation(GLuint program, const GLchar* name)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001976{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00001977 EVENT("(GLuint program = %d, const GLchar* name = %s)", program, name);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001978
Geoff Langbfdea662014-07-23 14:16:32 -04001979 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04001980 if (context)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001981 {
Geoff Langbfdea662014-07-23 14:16:32 -04001982 gl::Program *programObject = context->getProgram(program);
1983
1984 if (!programObject)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001985 {
Geoff Langbfdea662014-07-23 14:16:32 -04001986 if (context->getShader(program))
daniel@transgaming.comcf4aa872010-04-13 03:26:27 +00001987 {
Geoff Langb1196682014-07-23 13:47:29 -04001988 context->recordError(gl::Error(GL_INVALID_OPERATION));
1989 return -1;
daniel@transgaming.comcf4aa872010-04-13 03:26:27 +00001990 }
Geoff Langbfdea662014-07-23 14:16:32 -04001991 else
1992 {
Geoff Langb1196682014-07-23 13:47:29 -04001993 context->recordError(gl::Error(GL_INVALID_VALUE));
1994 return -1;
Geoff Langbfdea662014-07-23 14:16:32 -04001995 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001996 }
Geoff Langbfdea662014-07-23 14:16:32 -04001997
1998 gl::ProgramBinary *programBinary = programObject->getProgramBinary();
1999 if (!programObject->isLinked() || !programBinary)
2000 {
Geoff Langb1196682014-07-23 13:47:29 -04002001 context->recordError(gl::Error(GL_INVALID_OPERATION));
2002 return -1;
Geoff Langbfdea662014-07-23 14:16:32 -04002003 }
2004
2005 return programBinary->getAttributeLocation(name);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002006 }
2007
2008 return -1;
2009}
2010
Kenneth Russell67ea1902014-10-06 16:44:50 -07002011void GL_APIENTRY glGetBooleanv(GLenum pname, GLboolean* params)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002012{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00002013 EVENT("(GLenum pname = 0x%X, GLboolean* params = 0x%0.8p)", pname, params);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002014
Geoff Langbfdea662014-07-23 14:16:32 -04002015 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04002016 if (context)
2017 {
2018 GLenum nativeType;
2019 unsigned int numParams = 0;
2020 if (!ValidateStateQuery(context, pname, &nativeType, &numParams))
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002021 {
Geoff Langbfdea662014-07-23 14:16:32 -04002022 return;
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002023 }
Geoff Langbfdea662014-07-23 14:16:32 -04002024
2025 if (nativeType == GL_BOOL)
2026 {
2027 context->getBooleanv(pname, params);
2028 }
2029 else
2030 {
2031 CastStateValues(context, nativeType, pname, numParams, params);
2032 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002033 }
2034}
2035
Kenneth Russell67ea1902014-10-06 16:44:50 -07002036void GL_APIENTRY glGetBufferParameteriv(GLenum target, GLenum pname, GLint* params)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002037{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00002038 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 +00002039
Geoff Langbfdea662014-07-23 14:16:32 -04002040 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04002041 if (context)
2042 {
2043 if (!gl::ValidBufferTarget(context, target))
daniel@transgaming.comaa0ccbd2010-04-15 20:45:05 +00002044 {
Geoff Langb1196682014-07-23 13:47:29 -04002045 context->recordError(gl::Error(GL_INVALID_ENUM));
2046 return;
daniel@transgaming.comaa0ccbd2010-04-15 20:45:05 +00002047 }
Geoff Langbfdea662014-07-23 14:16:32 -04002048
2049 if (!gl::ValidBufferParameter(context, pname))
2050 {
Geoff Langb1196682014-07-23 13:47:29 -04002051 context->recordError(gl::Error(GL_INVALID_ENUM));
2052 return;
Geoff Langbfdea662014-07-23 14:16:32 -04002053 }
2054
2055 gl::Buffer *buffer = context->getState().getTargetBuffer(target);
2056
2057 if (!buffer)
2058 {
2059 // A null buffer means that "0" is bound to the requested buffer target
Geoff Langb1196682014-07-23 13:47:29 -04002060 context->recordError(gl::Error(GL_INVALID_OPERATION));
2061 return;
Geoff Langbfdea662014-07-23 14:16:32 -04002062 }
2063
2064 switch (pname)
2065 {
2066 case GL_BUFFER_USAGE:
2067 *params = static_cast<GLint>(buffer->getUsage());
2068 break;
2069 case GL_BUFFER_SIZE:
2070 *params = gl::clampCast<GLint>(buffer->getSize());
2071 break;
2072 case GL_BUFFER_ACCESS_FLAGS:
2073 *params = buffer->getAccessFlags();
2074 break;
2075 case GL_BUFFER_MAPPED:
2076 *params = static_cast<GLint>(buffer->isMapped());
2077 break;
2078 case GL_BUFFER_MAP_OFFSET:
2079 *params = gl::clampCast<GLint>(buffer->getMapOffset());
2080 break;
2081 case GL_BUFFER_MAP_LENGTH:
2082 *params = gl::clampCast<GLint>(buffer->getMapLength());
2083 break;
2084 default: UNREACHABLE(); break;
2085 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002086 }
2087}
2088
Kenneth Russell67ea1902014-10-06 16:44:50 -07002089GLenum GL_APIENTRY glGetError(void)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002090{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00002091 EVENT("()");
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002092
2093 gl::Context *context = gl::getContext();
2094
2095 if (context)
2096 {
daniel@transgaming.com82b28912011-12-12 21:01:35 +00002097 return context->getError();
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002098 }
2099
2100 return GL_NO_ERROR;
2101}
2102
Kenneth Russell67ea1902014-10-06 16:44:50 -07002103void GL_APIENTRY glGetFenceivNV(GLuint fence, GLenum pname, GLint *params)
apatrick@chromium.orgd3bd0ad2010-08-30 18:55:36 +00002104{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00002105 EVENT("(GLuint fence = %d, GLenum pname = 0x%X, GLint *params = 0x%0.8p)", fence, pname, params);
apatrick@chromium.orgd3bd0ad2010-08-30 18:55:36 +00002106
Geoff Langbfdea662014-07-23 14:16:32 -04002107 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04002108 if (context)
2109 {
2110 gl::FenceNV *fenceObject = context->getFenceNV(fence);
2111
2112 if (fenceObject == NULL)
apatrick@chromium.orgd3bd0ad2010-08-30 18:55:36 +00002113 {
Geoff Langb1196682014-07-23 13:47:29 -04002114 context->recordError(gl::Error(GL_INVALID_OPERATION));
2115 return;
apatrick@chromium.orgd3bd0ad2010-08-30 18:55:36 +00002116 }
Geoff Langbfdea662014-07-23 14:16:32 -04002117
2118 if (fenceObject->isFence() != GL_TRUE)
2119 {
Geoff Langb1196682014-07-23 13:47:29 -04002120 context->recordError(gl::Error(GL_INVALID_OPERATION));
2121 return;
Geoff Langbfdea662014-07-23 14:16:32 -04002122 }
2123
2124 switch (pname)
2125 {
2126 case GL_FENCE_STATUS_NV:
Kenneth Russellcaa549c2014-10-10 17:52:59 -07002127 {
2128 // GL_NV_fence spec:
2129 // Once the status of a fence has been finished (via FinishFenceNV) or tested and the returned status is TRUE (via either TestFenceNV
2130 // or GetFenceivNV querying the FENCE_STATUS_NV), the status remains TRUE until the next SetFenceNV of the fence.
2131 GLboolean status = GL_TRUE;
2132 if (fenceObject->getStatus() != GL_TRUE)
2133 {
2134 gl::Error error = fenceObject->testFence(&status);
2135 if (error.isError())
2136 {
2137 context->recordError(error);
2138 return;
2139 }
2140 }
2141 *params = status;
2142 break;
2143 }
2144
Geoff Langbfdea662014-07-23 14:16:32 -04002145 case GL_FENCE_CONDITION_NV:
Kenneth Russellcaa549c2014-10-10 17:52:59 -07002146 {
2147 *params = fenceObject->getCondition();
2148 break;
2149 }
Geoff Langbfdea662014-07-23 14:16:32 -04002150
Geoff Langb1196682014-07-23 13:47:29 -04002151 default:
Kenneth Russellcaa549c2014-10-10 17:52:59 -07002152 {
2153 context->recordError(gl::Error(GL_INVALID_ENUM));
2154 return;
2155 }
Geoff Lang882033e2014-09-30 11:26:07 -04002156 }
apatrick@chromium.orgd3bd0ad2010-08-30 18:55:36 +00002157 }
2158}
2159
Kenneth Russell67ea1902014-10-06 16:44:50 -07002160void GL_APIENTRY glGetFloatv(GLenum pname, GLfloat* params)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002161{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00002162 EVENT("(GLenum pname = 0x%X, GLfloat* params = 0x%0.8p)", pname, params);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002163
Geoff Langbfdea662014-07-23 14:16:32 -04002164 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04002165 if (context)
2166 {
2167 GLenum nativeType;
2168 unsigned int numParams = 0;
2169 if (!ValidateStateQuery(context, pname, &nativeType, &numParams))
daniel@transgaming.com32e58cd2010-03-24 09:44:10 +00002170 {
Geoff Langbfdea662014-07-23 14:16:32 -04002171 return;
daniel@transgaming.com32e58cd2010-03-24 09:44:10 +00002172 }
Geoff Langbfdea662014-07-23 14:16:32 -04002173
2174 if (nativeType == GL_FLOAT)
2175 {
2176 context->getFloatv(pname, params);
2177 }
2178 else
2179 {
2180 CastStateValues(context, nativeType, pname, numParams, params);
2181 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002182 }
2183}
2184
Kenneth Russell67ea1902014-10-06 16:44:50 -07002185void GL_APIENTRY glGetFramebufferAttachmentParameteriv(GLenum target, GLenum attachment, GLenum pname, GLint* params)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002186{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00002187 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 +00002188 target, attachment, pname, params);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002189
Geoff Langbfdea662014-07-23 14:16:32 -04002190 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04002191 if (context)
2192 {
2193 if (!gl::ValidFramebufferTarget(target))
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002194 {
Geoff Langb1196682014-07-23 13:47:29 -04002195 context->recordError(gl::Error(GL_INVALID_ENUM));
2196 return;
Geoff Langbfdea662014-07-23 14:16:32 -04002197 }
2198
2199 int clientVersion = context->getClientVersion();
2200
2201 switch (pname)
2202 {
2203 case GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE:
2204 case GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME:
2205 case GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL:
2206 case GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE:
2207 break;
Geoff Langb1196682014-07-23 13:47:29 -04002208
Geoff Langbfdea662014-07-23 14:16:32 -04002209 case GL_FRAMEBUFFER_ATTACHMENT_COLOR_ENCODING:
2210 if (clientVersion < 3 && !context->getExtensions().sRGB)
daniel@transgaming.comc46c9c02010-04-23 18:34:55 +00002211 {
Geoff Langb1196682014-07-23 13:47:29 -04002212 context->recordError(gl::Error(GL_INVALID_ENUM));
2213 return;
daniel@transgaming.comc46c9c02010-04-23 18:34:55 +00002214 }
Geoff Langbfdea662014-07-23 14:16:32 -04002215 break;
Geoff Langb1196682014-07-23 13:47:29 -04002216
Geoff Langbfdea662014-07-23 14:16:32 -04002217 case GL_FRAMEBUFFER_ATTACHMENT_RED_SIZE:
2218 case GL_FRAMEBUFFER_ATTACHMENT_GREEN_SIZE:
2219 case GL_FRAMEBUFFER_ATTACHMENT_BLUE_SIZE:
2220 case GL_FRAMEBUFFER_ATTACHMENT_ALPHA_SIZE:
2221 case GL_FRAMEBUFFER_ATTACHMENT_DEPTH_SIZE:
2222 case GL_FRAMEBUFFER_ATTACHMENT_STENCIL_SIZE:
2223 case GL_FRAMEBUFFER_ATTACHMENT_COMPONENT_TYPE:
2224 case GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LAYER:
2225 if (clientVersion < 3)
2226 {
Geoff Langb1196682014-07-23 13:47:29 -04002227 context->recordError(gl::Error(GL_INVALID_ENUM));
2228 return;
Geoff Langbfdea662014-07-23 14:16:32 -04002229 }
2230 break;
Geoff Langb1196682014-07-23 13:47:29 -04002231
Geoff Langbfdea662014-07-23 14:16:32 -04002232 default:
Geoff Langb1196682014-07-23 13:47:29 -04002233 context->recordError(gl::Error(GL_INVALID_ENUM));
2234 return;
Geoff Langbfdea662014-07-23 14:16:32 -04002235 }
daniel@transgaming.comc46c9c02010-04-23 18:34:55 +00002236
Geoff Langbfdea662014-07-23 14:16:32 -04002237 // Determine if the attachment is a valid enum
2238 switch (attachment)
2239 {
2240 case GL_BACK:
2241 case GL_FRONT:
2242 case GL_DEPTH:
2243 case GL_STENCIL:
2244 case GL_DEPTH_STENCIL_ATTACHMENT:
2245 if (clientVersion < 3)
2246 {
Geoff Langb1196682014-07-23 13:47:29 -04002247 context->recordError(gl::Error(GL_INVALID_ENUM));
2248 return;
Geoff Langbfdea662014-07-23 14:16:32 -04002249 }
2250 break;
2251
2252 case GL_DEPTH_ATTACHMENT:
2253 case GL_STENCIL_ATTACHMENT:
2254 break;
2255
2256 default:
2257 if (attachment < GL_COLOR_ATTACHMENT0_EXT ||
2258 (attachment - GL_COLOR_ATTACHMENT0_EXT) >= context->getCaps().maxColorAttachments)
2259 {
Geoff Langb1196682014-07-23 13:47:29 -04002260 context->recordError(gl::Error(GL_INVALID_ENUM));
2261 return;
Geoff Langbfdea662014-07-23 14:16:32 -04002262 }
2263 break;
2264 }
2265
2266 GLuint framebufferHandle = context->getState().getTargetFramebuffer(target)->id();
2267 gl::Framebuffer *framebuffer = context->getFramebuffer(framebufferHandle);
Jamie Madill48faf802014-11-06 15:27:22 -05002268 ASSERT(framebuffer);
Geoff Langbfdea662014-07-23 14:16:32 -04002269
2270 if (framebufferHandle == 0)
2271 {
2272 if (clientVersion < 3)
2273 {
Geoff Langb1196682014-07-23 13:47:29 -04002274 context->recordError(gl::Error(GL_INVALID_OPERATION));
2275 return;
Geoff Langbfdea662014-07-23 14:16:32 -04002276 }
2277
2278 switch (attachment)
2279 {
2280 case GL_BACK:
2281 case GL_DEPTH:
2282 case GL_STENCIL:
2283 break;
Geoff Langb1196682014-07-23 13:47:29 -04002284
Geoff Langbfdea662014-07-23 14:16:32 -04002285 default:
Geoff Langb1196682014-07-23 13:47:29 -04002286 context->recordError(gl::Error(GL_INVALID_OPERATION));
2287 return;
Geoff Langbfdea662014-07-23 14:16:32 -04002288 }
2289 }
2290 else
2291 {
2292 if (attachment >= GL_COLOR_ATTACHMENT0_EXT && attachment <= GL_COLOR_ATTACHMENT15_EXT)
2293 {
2294 // Valid attachment query
2295 }
2296 else
2297 {
2298 switch (attachment)
2299 {
2300 case GL_DEPTH_ATTACHMENT:
2301 case GL_STENCIL_ATTACHMENT:
2302 break;
Geoff Langb1196682014-07-23 13:47:29 -04002303
Geoff Langbfdea662014-07-23 14:16:32 -04002304 case GL_DEPTH_STENCIL_ATTACHMENT:
2305 if (framebuffer->hasValidDepthStencil())
2306 {
Geoff Langb1196682014-07-23 13:47:29 -04002307 context->recordError(gl::Error(GL_INVALID_OPERATION));
2308 return;
Geoff Langbfdea662014-07-23 14:16:32 -04002309 }
2310 break;
Geoff Langb1196682014-07-23 13:47:29 -04002311
Geoff Langbfdea662014-07-23 14:16:32 -04002312 default:
Geoff Langb1196682014-07-23 13:47:29 -04002313 context->recordError(gl::Error(GL_INVALID_OPERATION));
2314 return;
Geoff Langbfdea662014-07-23 14:16:32 -04002315 }
2316 }
2317 }
2318
2319 GLenum attachmentType = GL_NONE;
2320 GLuint attachmentHandle = 0;
2321 GLuint attachmentLevel = 0;
2322 GLuint attachmentLayer = 0;
2323
2324 const gl::FramebufferAttachment *attachmentObject = framebuffer->getAttachment(attachment);
2325
2326 if (attachmentObject)
2327 {
2328 attachmentType = attachmentObject->type();
2329 attachmentHandle = attachmentObject->id();
2330 attachmentLevel = attachmentObject->mipLevel();
2331 attachmentLayer = attachmentObject->layer();
2332 }
2333
2334 GLenum attachmentObjectType; // Type category
2335 if (framebufferHandle == 0)
2336 {
2337 attachmentObjectType = GL_FRAMEBUFFER_DEFAULT;
2338 }
2339 else if (attachmentType == GL_NONE || attachmentType == GL_RENDERBUFFER)
2340 {
2341 attachmentObjectType = attachmentType;
2342 }
2343 else if (gl::ValidTexture2DDestinationTarget(context, attachmentType))
2344 {
2345 attachmentObjectType = GL_TEXTURE;
2346 }
2347 else
2348 {
2349 UNREACHABLE();
2350 return;
2351 }
2352
2353 if (attachmentObjectType == GL_NONE)
2354 {
2355 // ES 2.0.25 spec pg 127 states that if the value of FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE
2356 // is NONE, then querying any other pname will generate INVALID_ENUM.
2357
2358 // ES 3.0.2 spec pg 235 states that if the attachment type is none,
2359 // GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME will return zero and be an
2360 // INVALID_OPERATION for all other pnames
Jamie Madill1e3fa742014-06-16 10:34:00 -04002361
Geoff Lang646559f2013-08-15 11:08:15 -04002362 switch (pname)
daniel@transgaming.coma27ff1e2010-08-24 19:20:11 +00002363 {
Geoff Lang646559f2013-08-15 11:08:15 -04002364 case GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE:
Geoff Langbfdea662014-07-23 14:16:32 -04002365 *params = attachmentObjectType;
2366 break;
2367
Geoff Lang646559f2013-08-15 11:08:15 -04002368 case GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME:
Geoff Lang05b05022014-06-11 15:31:45 -04002369 if (clientVersion < 3)
daniel@transgaming.coma27ff1e2010-08-24 19:20:11 +00002370 {
Geoff Langb1196682014-07-23 13:47:29 -04002371 context->recordError(gl::Error(GL_INVALID_ENUM));
2372 return;
daniel@transgaming.coma27ff1e2010-08-24 19:20:11 +00002373 }
Geoff Langbfdea662014-07-23 14:16:32 -04002374 *params = 0;
Geoff Lang646559f2013-08-15 11:08:15 -04002375 break;
2376
2377 default:
Jamie Madill1e3fa742014-06-16 10:34:00 -04002378 if (clientVersion < 3)
shannon.woods%transgaming.com@gtempaccount.com89ae1132013-04-13 03:28:43 +00002379 {
Geoff Langb1196682014-07-23 13:47:29 -04002380 context->recordError(gl::Error(GL_INVALID_ENUM));
2381 return;
Geoff Lang646559f2013-08-15 11:08:15 -04002382 }
2383 else
2384 {
Geoff Langb1196682014-07-23 13:47:29 -04002385 context->recordError(gl::Error(GL_INVALID_OPERATION));
2386 return;
daniel@transgaming.comc46c9c02010-04-23 18:34:55 +00002387 }
daniel@transgaming.comc46c9c02010-04-23 18:34:55 +00002388 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002389 }
Geoff Langbfdea662014-07-23 14:16:32 -04002390 else
2391 {
2392 ASSERT(attachmentObjectType == GL_RENDERBUFFER || attachmentObjectType == GL_TEXTURE ||
2393 attachmentObjectType == GL_FRAMEBUFFER_DEFAULT);
2394 ASSERT(attachmentObject != NULL);
2395
2396 switch (pname)
2397 {
2398 case GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE:
2399 *params = attachmentObjectType;
2400 break;
2401
2402 case GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME:
2403 if (attachmentObjectType != GL_RENDERBUFFER && attachmentObjectType != GL_TEXTURE)
2404 {
Geoff Langb1196682014-07-23 13:47:29 -04002405 context->recordError(gl::Error(GL_INVALID_ENUM));
2406 return;
Geoff Langbfdea662014-07-23 14:16:32 -04002407 }
2408 *params = attachmentHandle;
2409 break;
2410
2411 case GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL:
2412 if (attachmentObjectType != GL_TEXTURE)
2413 {
Geoff Langb1196682014-07-23 13:47:29 -04002414 context->recordError(gl::Error(GL_INVALID_ENUM));
2415 return;
Geoff Langbfdea662014-07-23 14:16:32 -04002416 }
2417 *params = attachmentLevel;
2418 break;
2419
2420 case GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE:
2421 if (attachmentObjectType != GL_TEXTURE)
2422 {
Geoff Langb1196682014-07-23 13:47:29 -04002423 context->recordError(gl::Error(GL_INVALID_ENUM));
2424 return;
Geoff Langbfdea662014-07-23 14:16:32 -04002425 }
2426 *params = gl::IsCubemapTextureTarget(attachmentType) ? attachmentType : 0;
2427 break;
2428
2429 case GL_FRAMEBUFFER_ATTACHMENT_RED_SIZE:
2430 *params = attachmentObject->getRedSize();
2431 break;
2432
2433 case GL_FRAMEBUFFER_ATTACHMENT_GREEN_SIZE:
2434 *params = attachmentObject->getGreenSize();
2435 break;
2436
2437 case GL_FRAMEBUFFER_ATTACHMENT_BLUE_SIZE:
2438 *params = attachmentObject->getBlueSize();
2439 break;
2440
2441 case GL_FRAMEBUFFER_ATTACHMENT_ALPHA_SIZE:
2442 *params = attachmentObject->getAlphaSize();
2443 break;
2444
2445 case GL_FRAMEBUFFER_ATTACHMENT_DEPTH_SIZE:
2446 *params = attachmentObject->getDepthSize();
2447 break;
2448
2449 case GL_FRAMEBUFFER_ATTACHMENT_STENCIL_SIZE:
2450 *params = attachmentObject->getStencilSize();
2451 break;
2452
2453 case GL_FRAMEBUFFER_ATTACHMENT_COMPONENT_TYPE:
Jamie Madillee85d1b2014-09-17 10:35:23 -04002454 if (attachment == GL_DEPTH_STENCIL_ATTACHMENT)
Geoff Langbfdea662014-07-23 14:16:32 -04002455 {
Geoff Langb1196682014-07-23 13:47:29 -04002456 context->recordError(gl::Error(GL_INVALID_OPERATION));
2457 return;
Geoff Langbfdea662014-07-23 14:16:32 -04002458 }
2459 *params = attachmentObject->getComponentType();
2460 break;
2461
2462 case GL_FRAMEBUFFER_ATTACHMENT_COLOR_ENCODING:
2463 *params = attachmentObject->getColorEncoding();
2464 break;
2465
2466 case GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LAYER:
2467 if (attachmentObjectType != GL_TEXTURE)
2468 {
Geoff Langb1196682014-07-23 13:47:29 -04002469 context->recordError(gl::Error(GL_INVALID_ENUM));
2470 return;
Geoff Langbfdea662014-07-23 14:16:32 -04002471 }
2472 *params = attachmentLayer;
2473 break;
2474
2475 default:
2476 UNREACHABLE();
2477 break;
2478 }
2479 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002480 }
2481}
2482
Kenneth Russell67ea1902014-10-06 16:44:50 -07002483GLenum GL_APIENTRY glGetGraphicsResetStatusEXT(void)
daniel@transgaming.com17f548c2011-11-09 17:47:02 +00002484{
2485 EVENT("()");
2486
Geoff Langbfdea662014-07-23 14:16:32 -04002487 gl::Context *context = gl::getContext();
daniel@transgaming.com17f548c2011-11-09 17:47:02 +00002488
Geoff Langbfdea662014-07-23 14:16:32 -04002489 if (context)
daniel@transgaming.com17f548c2011-11-09 17:47:02 +00002490 {
Geoff Langbfdea662014-07-23 14:16:32 -04002491 return context->getResetStatus();
daniel@transgaming.com17f548c2011-11-09 17:47:02 +00002492 }
Geoff Langbfdea662014-07-23 14:16:32 -04002493
2494 return GL_NO_ERROR;
daniel@transgaming.com17f548c2011-11-09 17:47:02 +00002495}
2496
Kenneth Russell67ea1902014-10-06 16:44:50 -07002497void GL_APIENTRY glGetIntegerv(GLenum pname, GLint* params)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002498{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00002499 EVENT("(GLenum pname = 0x%X, GLint* params = 0x%0.8p)", pname, params);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002500
Geoff Langbfdea662014-07-23 14:16:32 -04002501 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04002502 if (context)
2503 {
2504 GLenum nativeType;
2505 unsigned int numParams = 0;
2506
2507 if (!ValidateStateQuery(context, pname, &nativeType, &numParams))
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002508 {
Geoff Langbfdea662014-07-23 14:16:32 -04002509 return;
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002510 }
Geoff Langbfdea662014-07-23 14:16:32 -04002511
2512 if (nativeType == GL_INT)
2513 {
2514 context->getIntegerv(pname, params);
2515 }
2516 else
2517 {
2518 CastStateValues(context, nativeType, pname, numParams, params);
2519 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002520 }
2521}
2522
Kenneth Russell67ea1902014-10-06 16:44:50 -07002523void GL_APIENTRY glGetProgramiv(GLuint program, GLenum pname, GLint* params)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002524{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00002525 EVENT("(GLuint program = %d, GLenum pname = %d, GLint* params = 0x%0.8p)", program, pname, params);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002526
Geoff Langbfdea662014-07-23 14:16:32 -04002527 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04002528 if (context)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002529 {
Geoff Langbfdea662014-07-23 14:16:32 -04002530 gl::Program *programObject = context->getProgram(program);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002531
Geoff Langbfdea662014-07-23 14:16:32 -04002532 if (!programObject)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002533 {
Geoff Langb1196682014-07-23 13:47:29 -04002534 context->recordError(gl::Error(GL_INVALID_VALUE));
2535 return;
Geoff Langbfdea662014-07-23 14:16:32 -04002536 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002537
Geoff Langbfdea662014-07-23 14:16:32 -04002538 if (context->getClientVersion() < 3)
2539 {
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002540 switch (pname)
2541 {
shannonwoods@chromium.orge684b582013-05-30 00:07:42 +00002542 case GL_ACTIVE_UNIFORM_BLOCKS:
shannonwoods@chromium.orge684b582013-05-30 00:07:42 +00002543 case GL_ACTIVE_UNIFORM_BLOCK_MAX_NAME_LENGTH:
Geoff Lang1b6edcb2014-02-03 14:27:56 -05002544 case GL_TRANSFORM_FEEDBACK_BUFFER_MODE:
Geoff Lang1b6edcb2014-02-03 14:27:56 -05002545 case GL_TRANSFORM_FEEDBACK_VARYINGS:
Geoff Lang1b6edcb2014-02-03 14:27:56 -05002546 case GL_TRANSFORM_FEEDBACK_VARYING_MAX_LENGTH:
Geoff Langb1196682014-07-23 13:47:29 -04002547 context->recordError(gl::Error(GL_INVALID_ENUM));
2548 return;
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002549 }
2550 }
Geoff Langbfdea662014-07-23 14:16:32 -04002551
2552 switch (pname)
2553 {
2554 case GL_DELETE_STATUS:
2555 *params = programObject->isFlaggedForDeletion();
2556 return;
2557 case GL_LINK_STATUS:
2558 *params = programObject->isLinked();
2559 return;
2560 case GL_VALIDATE_STATUS:
2561 *params = programObject->isValidated();
2562 return;
2563 case GL_INFO_LOG_LENGTH:
2564 *params = programObject->getInfoLogLength();
2565 return;
2566 case GL_ATTACHED_SHADERS:
2567 *params = programObject->getAttachedShadersCount();
2568 return;
2569 case GL_ACTIVE_ATTRIBUTES:
2570 *params = programObject->getActiveAttributeCount();
2571 return;
2572 case GL_ACTIVE_ATTRIBUTE_MAX_LENGTH:
2573 *params = programObject->getActiveAttributeMaxLength();
2574 return;
2575 case GL_ACTIVE_UNIFORMS:
2576 *params = programObject->getActiveUniformCount();
2577 return;
2578 case GL_ACTIVE_UNIFORM_MAX_LENGTH:
2579 *params = programObject->getActiveUniformMaxLength();
2580 return;
2581 case GL_PROGRAM_BINARY_LENGTH_OES:
2582 *params = programObject->getProgramBinaryLength();
2583 return;
2584 case GL_ACTIVE_UNIFORM_BLOCKS:
2585 *params = programObject->getActiveUniformBlockCount();
2586 return;
2587 case GL_ACTIVE_UNIFORM_BLOCK_MAX_NAME_LENGTH:
2588 *params = programObject->getActiveUniformBlockMaxLength();
2589 break;
2590 case GL_TRANSFORM_FEEDBACK_BUFFER_MODE:
2591 *params = programObject->getTransformFeedbackBufferMode();
2592 break;
2593 case GL_TRANSFORM_FEEDBACK_VARYINGS:
2594 *params = programObject->getTransformFeedbackVaryingCount();
2595 break;
2596 case GL_TRANSFORM_FEEDBACK_VARYING_MAX_LENGTH:
2597 *params = programObject->getTransformFeedbackVaryingMaxLength();
2598 break;
Geoff Langb1196682014-07-23 13:47:29 -04002599
Geoff Langbfdea662014-07-23 14:16:32 -04002600 default:
Geoff Langb1196682014-07-23 13:47:29 -04002601 context->recordError(gl::Error(GL_INVALID_ENUM));
2602 return;
Geoff Langbfdea662014-07-23 14:16:32 -04002603 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002604 }
2605}
2606
Kenneth Russell67ea1902014-10-06 16:44:50 -07002607void GL_APIENTRY glGetProgramInfoLog(GLuint program, GLsizei bufsize, GLsizei* length, GLchar* infolog)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002608{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00002609 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 +00002610 program, bufsize, length, infolog);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002611
Geoff Langbfdea662014-07-23 14:16:32 -04002612 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04002613 if (context)
2614 {
Geoff Langb1196682014-07-23 13:47:29 -04002615 if (bufsize < 0)
2616 {
2617 context->recordError(gl::Error(GL_INVALID_VALUE));
2618 return;
2619 }
2620
Geoff Langbfdea662014-07-23 14:16:32 -04002621 gl::Program *programObject = context->getProgram(program);
2622
2623 if (!programObject)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002624 {
Geoff Langb1196682014-07-23 13:47:29 -04002625 context->recordError(gl::Error(GL_INVALID_VALUE));
2626 return;
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002627 }
2628
Geoff Langbfdea662014-07-23 14:16:32 -04002629 programObject->getInfoLog(bufsize, length, infolog);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002630 }
2631}
2632
Kenneth Russell67ea1902014-10-06 16:44:50 -07002633void GL_APIENTRY glGetQueryivEXT(GLenum target, GLenum pname, GLint *params)
daniel@transgaming.com86bdb822012-01-20 18:24:39 +00002634{
2635 EVENT("GLenum target = 0x%X, GLenum pname = 0x%X, GLint *params = 0x%0.8p)", target, pname, params);
2636
Geoff Langbfdea662014-07-23 14:16:32 -04002637 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04002638 if (context)
2639 {
2640 if (!ValidQueryType(context, target))
daniel@transgaming.com86bdb822012-01-20 18:24:39 +00002641 {
Geoff Langb1196682014-07-23 13:47:29 -04002642 context->recordError(gl::Error(GL_INVALID_ENUM));
2643 return;
daniel@transgaming.com86bdb822012-01-20 18:24:39 +00002644 }
Geoff Langbfdea662014-07-23 14:16:32 -04002645
2646 switch (pname)
2647 {
2648 case GL_CURRENT_QUERY_EXT:
2649 params[0] = context->getState().getActiveQueryId(target);
2650 break;
2651
2652 default:
Geoff Langb1196682014-07-23 13:47:29 -04002653 context->recordError(gl::Error(GL_INVALID_ENUM));
2654 return;
Geoff Langbfdea662014-07-23 14:16:32 -04002655 }
daniel@transgaming.com86bdb822012-01-20 18:24:39 +00002656 }
2657}
2658
Kenneth Russell67ea1902014-10-06 16:44:50 -07002659void GL_APIENTRY glGetQueryObjectuivEXT(GLuint id, GLenum pname, GLuint *params)
daniel@transgaming.com86bdb822012-01-20 18:24:39 +00002660{
2661 EVENT("(GLuint id = %d, GLenum pname = 0x%X, GLuint *params = 0x%0.8p)", id, pname, params);
2662
Geoff Langbfdea662014-07-23 14:16:32 -04002663 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04002664 if (context)
2665 {
2666 gl::Query *queryObject = context->getQuery(id, false, GL_NONE);
2667
2668 if (!queryObject)
daniel@transgaming.com86bdb822012-01-20 18:24:39 +00002669 {
Geoff Langb1196682014-07-23 13:47:29 -04002670 context->recordError(gl::Error(GL_INVALID_OPERATION));
2671 return;
daniel@transgaming.com86bdb822012-01-20 18:24:39 +00002672 }
Geoff Langbfdea662014-07-23 14:16:32 -04002673
2674 if (context->getState().getActiveQueryId(queryObject->getType()) == id)
2675 {
Geoff Langb1196682014-07-23 13:47:29 -04002676 context->recordError(gl::Error(GL_INVALID_OPERATION));
2677 return;
Geoff Langbfdea662014-07-23 14:16:32 -04002678 }
2679
2680 switch(pname)
2681 {
2682 case GL_QUERY_RESULT_EXT:
Geoff Lang5aad9672014-09-08 11:10:42 -04002683 {
2684 gl::Error error = queryObject->getResult(params);
2685 if (error.isError())
2686 {
2687 context->recordError(error);
2688 return;
2689 }
2690 }
Geoff Langbfdea662014-07-23 14:16:32 -04002691 break;
Geoff Lang5aad9672014-09-08 11:10:42 -04002692
Geoff Langbfdea662014-07-23 14:16:32 -04002693 case GL_QUERY_RESULT_AVAILABLE_EXT:
Geoff Lang5aad9672014-09-08 11:10:42 -04002694 {
2695 gl::Error error = queryObject->isResultAvailable(params);
2696 if (error.isError())
2697 {
2698 context->recordError(error);
2699 return;
2700 }
2701 }
Geoff Langbfdea662014-07-23 14:16:32 -04002702 break;
Geoff Lang5aad9672014-09-08 11:10:42 -04002703
Geoff Langbfdea662014-07-23 14:16:32 -04002704 default:
Geoff Langb1196682014-07-23 13:47:29 -04002705 context->recordError(gl::Error(GL_INVALID_ENUM));
2706 return;
Geoff Langbfdea662014-07-23 14:16:32 -04002707 }
daniel@transgaming.com86bdb822012-01-20 18:24:39 +00002708 }
2709}
2710
Kenneth Russell67ea1902014-10-06 16:44:50 -07002711void GL_APIENTRY glGetRenderbufferParameteriv(GLenum target, GLenum pname, GLint* params)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002712{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00002713 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 +00002714
Geoff Langbfdea662014-07-23 14:16:32 -04002715 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04002716 if (context)
2717 {
2718 if (target != GL_RENDERBUFFER)
daniel@transgaming.com4901fca2010-04-20 18:52:41 +00002719 {
Geoff Langb1196682014-07-23 13:47:29 -04002720 context->recordError(gl::Error(GL_INVALID_ENUM));
2721 return;
daniel@transgaming.com4901fca2010-04-20 18:52:41 +00002722 }
Geoff Langbfdea662014-07-23 14:16:32 -04002723
2724 if (context->getState().getRenderbufferId() == 0)
2725 {
Geoff Langb1196682014-07-23 13:47:29 -04002726 context->recordError(gl::Error(GL_INVALID_OPERATION));
2727 return;
Geoff Langbfdea662014-07-23 14:16:32 -04002728 }
2729
2730 gl::Renderbuffer *renderbuffer = context->getRenderbuffer(context->getState().getRenderbufferId());
2731
2732 switch (pname)
2733 {
2734 case GL_RENDERBUFFER_WIDTH: *params = renderbuffer->getWidth(); break;
2735 case GL_RENDERBUFFER_HEIGHT: *params = renderbuffer->getHeight(); break;
2736 case GL_RENDERBUFFER_INTERNAL_FORMAT: *params = renderbuffer->getInternalFormat(); break;
2737 case GL_RENDERBUFFER_RED_SIZE: *params = renderbuffer->getRedSize(); break;
2738 case GL_RENDERBUFFER_GREEN_SIZE: *params = renderbuffer->getGreenSize(); break;
2739 case GL_RENDERBUFFER_BLUE_SIZE: *params = renderbuffer->getBlueSize(); break;
2740 case GL_RENDERBUFFER_ALPHA_SIZE: *params = renderbuffer->getAlphaSize(); break;
2741 case GL_RENDERBUFFER_DEPTH_SIZE: *params = renderbuffer->getDepthSize(); break;
2742 case GL_RENDERBUFFER_STENCIL_SIZE: *params = renderbuffer->getStencilSize(); break;
Geoff Langb1196682014-07-23 13:47:29 -04002743
Geoff Langbfdea662014-07-23 14:16:32 -04002744 case GL_RENDERBUFFER_SAMPLES_ANGLE:
2745 if (!context->getExtensions().framebufferMultisample)
2746 {
Geoff Langb1196682014-07-23 13:47:29 -04002747 context->recordError(gl::Error(GL_INVALID_ENUM));
2748 return;
Geoff Langbfdea662014-07-23 14:16:32 -04002749 }
2750 *params = renderbuffer->getSamples();
2751 break;
Geoff Langb1196682014-07-23 13:47:29 -04002752
Geoff Langbfdea662014-07-23 14:16:32 -04002753 default:
Geoff Langb1196682014-07-23 13:47:29 -04002754 context->recordError(gl::Error(GL_INVALID_ENUM));
2755 return;
Geoff Langbfdea662014-07-23 14:16:32 -04002756 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002757 }
2758}
2759
Kenneth Russell67ea1902014-10-06 16:44:50 -07002760void GL_APIENTRY glGetShaderiv(GLuint shader, GLenum pname, GLint* params)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002761{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00002762 EVENT("(GLuint shader = %d, GLenum pname = %d, GLint* params = 0x%0.8p)", shader, pname, params);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002763
Geoff Langbfdea662014-07-23 14:16:32 -04002764 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04002765 if (context)
2766 {
2767 gl::Shader *shaderObject = context->getShader(shader);
2768
2769 if (!shaderObject)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002770 {
Geoff Langb1196682014-07-23 13:47:29 -04002771 context->recordError(gl::Error(GL_INVALID_VALUE));
2772 return;
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002773 }
Geoff Langbfdea662014-07-23 14:16:32 -04002774
2775 switch (pname)
2776 {
2777 case GL_SHADER_TYPE:
2778 *params = shaderObject->getType();
2779 return;
2780 case GL_DELETE_STATUS:
2781 *params = shaderObject->isFlaggedForDeletion();
2782 return;
2783 case GL_COMPILE_STATUS:
2784 *params = shaderObject->isCompiled() ? GL_TRUE : GL_FALSE;
2785 return;
2786 case GL_INFO_LOG_LENGTH:
2787 *params = shaderObject->getInfoLogLength();
2788 return;
2789 case GL_SHADER_SOURCE_LENGTH:
2790 *params = shaderObject->getSourceLength();
2791 return;
2792 case GL_TRANSLATED_SHADER_SOURCE_LENGTH_ANGLE:
2793 *params = shaderObject->getTranslatedSourceLength();
2794 return;
Geoff Langb1196682014-07-23 13:47:29 -04002795
Geoff Langbfdea662014-07-23 14:16:32 -04002796 default:
Geoff Langb1196682014-07-23 13:47:29 -04002797 context->recordError(gl::Error(GL_INVALID_ENUM));
2798 return;
Geoff Langbfdea662014-07-23 14:16:32 -04002799 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002800 }
2801}
2802
Kenneth Russell67ea1902014-10-06 16:44:50 -07002803void GL_APIENTRY glGetShaderInfoLog(GLuint shader, GLsizei bufsize, GLsizei* length, GLchar* infolog)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002804{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00002805 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 +00002806 shader, bufsize, length, infolog);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002807
Geoff Langbfdea662014-07-23 14:16:32 -04002808 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04002809 if (context)
2810 {
Geoff Langb1196682014-07-23 13:47:29 -04002811 if (bufsize < 0)
2812 {
2813 context->recordError(gl::Error(GL_INVALID_VALUE));
2814 return;
2815 }
2816
Geoff Langbfdea662014-07-23 14:16:32 -04002817 gl::Shader *shaderObject = context->getShader(shader);
2818
2819 if (!shaderObject)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002820 {
Geoff Langb1196682014-07-23 13:47:29 -04002821 context->recordError(gl::Error(GL_INVALID_VALUE));
2822 return;
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002823 }
2824
Geoff Langbfdea662014-07-23 14:16:32 -04002825 shaderObject->getInfoLog(bufsize, length, infolog);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002826 }
2827}
2828
Kenneth Russell67ea1902014-10-06 16:44:50 -07002829void GL_APIENTRY glGetShaderPrecisionFormat(GLenum shadertype, GLenum precisiontype, GLint* range, GLint* precision)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002830{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00002831 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 +00002832 shadertype, precisiontype, range, precision);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002833
Geoff Langb1196682014-07-23 13:47:29 -04002834 gl::Context *context = gl::getNonLostContext();
2835 if (context)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002836 {
Geoff Langb1196682014-07-23 13:47:29 -04002837 switch (shadertype)
2838 {
2839 case GL_VERTEX_SHADER:
2840 case GL_FRAGMENT_SHADER:
2841 break;
Geoff Langbfdea662014-07-23 14:16:32 -04002842
Geoff Langb1196682014-07-23 13:47:29 -04002843 default:
2844 context->recordError(gl::Error(GL_INVALID_ENUM));
2845 return;
2846 }
2847
2848 switch (precisiontype)
2849 {
2850 case GL_LOW_FLOAT:
2851 case GL_MEDIUM_FLOAT:
2852 case GL_HIGH_FLOAT:
2853 // Assume IEEE 754 precision
2854 range[0] = 127;
2855 range[1] = 127;
2856 *precision = 23;
2857 break;
2858
2859 case GL_LOW_INT:
2860 case GL_MEDIUM_INT:
2861 case GL_HIGH_INT:
2862 // Some (most) hardware only supports single-precision floating-point numbers,
2863 // which can accurately represent integers up to +/-16777216
2864 range[0] = 24;
2865 range[1] = 24;
2866 *precision = 0;
2867 break;
2868
2869 default:
2870 context->recordError(gl::Error(GL_INVALID_ENUM));
2871 return;
2872 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002873 }
2874}
2875
Kenneth Russell67ea1902014-10-06 16:44:50 -07002876void GL_APIENTRY glGetShaderSource(GLuint shader, GLsizei bufsize, GLsizei* length, GLchar* source)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002877{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00002878 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 +00002879 shader, bufsize, length, source);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002880
Geoff Langbfdea662014-07-23 14:16:32 -04002881 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04002882 if (context)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002883 {
Geoff Langb1196682014-07-23 13:47:29 -04002884 if (bufsize < 0)
2885 {
2886 context->recordError(gl::Error(GL_INVALID_VALUE));
2887 return;
2888 }
2889
Geoff Langbfdea662014-07-23 14:16:32 -04002890 gl::Shader *shaderObject = context->getShader(shader);
2891
2892 if (!shaderObject)
2893 {
Geoff Langb1196682014-07-23 13:47:29 -04002894 context->recordError(gl::Error(GL_INVALID_OPERATION));
2895 return;
Geoff Langbfdea662014-07-23 14:16:32 -04002896 }
2897
2898 shaderObject->getSource(bufsize, length, source);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002899 }
2900}
2901
Kenneth Russell67ea1902014-10-06 16:44:50 -07002902void GL_APIENTRY glGetTranslatedShaderSourceANGLE(GLuint shader, GLsizei bufsize, GLsizei* length, GLchar* source)
zmo@google.coma574f782011-10-03 21:45:23 +00002903{
2904 EVENT("(GLuint shader = %d, GLsizei bufsize = %d, GLsizei* length = 0x%0.8p, GLchar* source = 0x%0.8p)",
2905 shader, bufsize, length, source);
2906
Geoff Langbfdea662014-07-23 14:16:32 -04002907 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04002908 if (context)
zmo@google.coma574f782011-10-03 21:45:23 +00002909 {
Geoff Langb1196682014-07-23 13:47:29 -04002910 if (bufsize < 0)
2911 {
2912 context->recordError(gl::Error(GL_INVALID_VALUE));
2913 return;
2914 }
2915
Geoff Langbfdea662014-07-23 14:16:32 -04002916 gl::Shader *shaderObject = context->getShader(shader);
2917
2918 if (!shaderObject)
2919 {
Geoff Langb1196682014-07-23 13:47:29 -04002920 context->recordError(gl::Error(GL_INVALID_OPERATION));
2921 return;
Geoff Langbfdea662014-07-23 14:16:32 -04002922 }
2923
Tibor den Ouden97049c62014-10-06 21:39:16 +02002924 // Only returns extra info if ANGLE_GENERATE_SHADER_DEBUG_INFO is defined
2925 shaderObject->getTranslatedSourceWithDebugInfo(bufsize, length, source);
zmo@google.coma574f782011-10-03 21:45:23 +00002926 }
2927}
2928
Kenneth Russell67ea1902014-10-06 16:44:50 -07002929const GLubyte* GL_APIENTRY glGetString(GLenum name)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002930{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00002931 EVENT("(GLenum name = 0x%X)", name);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002932
Geoff Langbfdea662014-07-23 14:16:32 -04002933 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.com3e4c6002010-05-05 18:50:13 +00002934
Geoff Langbfdea662014-07-23 14:16:32 -04002935 switch (name)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002936 {
Geoff Langbfdea662014-07-23 14:16:32 -04002937 case GL_VENDOR:
2938 return (GLubyte*)"Google Inc.";
Geoff Langb1196682014-07-23 13:47:29 -04002939
Geoff Langbfdea662014-07-23 14:16:32 -04002940 case GL_RENDERER:
2941 return (GLubyte*)((context != NULL) ? context->getRendererString().c_str() : "ANGLE");
Geoff Langb1196682014-07-23 13:47:29 -04002942
Geoff Langbfdea662014-07-23 14:16:32 -04002943 case GL_VERSION:
2944 if (context->getClientVersion() == 2)
2945 {
2946 return (GLubyte*)"OpenGL ES 2.0 (ANGLE " ANGLE_VERSION_STRING ")";
2947 }
2948 else
2949 {
2950 return (GLubyte*)"OpenGL ES 3.0 (ANGLE " ANGLE_VERSION_STRING ")";
2951 }
Geoff Langb1196682014-07-23 13:47:29 -04002952
Geoff Langbfdea662014-07-23 14:16:32 -04002953 case GL_SHADING_LANGUAGE_VERSION:
2954 if (context->getClientVersion() == 2)
2955 {
2956 return (GLubyte*)"OpenGL ES GLSL ES 1.00 (ANGLE " ANGLE_VERSION_STRING ")";
2957 }
2958 else
2959 {
2960 return (GLubyte*)"OpenGL ES GLSL ES 3.00 (ANGLE " ANGLE_VERSION_STRING ")";
2961 }
Geoff Langb1196682014-07-23 13:47:29 -04002962
Geoff Langbfdea662014-07-23 14:16:32 -04002963 case GL_EXTENSIONS:
2964 return (GLubyte*)((context != NULL) ? context->getExtensionString().c_str() : "");
Geoff Langb1196682014-07-23 13:47:29 -04002965
Geoff Langbfdea662014-07-23 14:16:32 -04002966 default:
Geoff Langb1196682014-07-23 13:47:29 -04002967 if (context)
2968 {
2969 context->recordError(gl::Error(GL_INVALID_ENUM));
2970 }
2971 return NULL;
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002972 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002973}
2974
Kenneth Russell67ea1902014-10-06 16:44:50 -07002975void GL_APIENTRY glGetTexParameterfv(GLenum target, GLenum pname, GLfloat* params)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002976{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00002977 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 +00002978
Geoff Langbfdea662014-07-23 14:16:32 -04002979 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04002980 if (context)
2981 {
2982 gl::Texture *texture = context->getTargetTexture(target);
2983
2984 if (!texture)
daniel@transgaming.com5d2bee92010-04-20 18:51:56 +00002985 {
Geoff Langb1196682014-07-23 13:47:29 -04002986 context->recordError(gl::Error(GL_INVALID_ENUM));
2987 return;
daniel@transgaming.com5d2bee92010-04-20 18:51:56 +00002988 }
Geoff Langbfdea662014-07-23 14:16:32 -04002989
2990 switch (pname)
2991 {
2992 case GL_TEXTURE_MAG_FILTER:
2993 *params = (GLfloat)texture->getSamplerState().magFilter;
2994 break;
2995 case GL_TEXTURE_MIN_FILTER:
2996 *params = (GLfloat)texture->getSamplerState().minFilter;
2997 break;
2998 case GL_TEXTURE_WRAP_S:
2999 *params = (GLfloat)texture->getSamplerState().wrapS;
3000 break;
3001 case GL_TEXTURE_WRAP_T:
3002 *params = (GLfloat)texture->getSamplerState().wrapT;
3003 break;
3004 case GL_TEXTURE_WRAP_R:
3005 if (context->getClientVersion() < 3)
3006 {
Geoff Langb1196682014-07-23 13:47:29 -04003007 context->recordError(gl::Error(GL_INVALID_ENUM));
3008 return;
Geoff Langbfdea662014-07-23 14:16:32 -04003009 }
3010 *params = (GLfloat)texture->getSamplerState().wrapR;
3011 break;
3012 case GL_TEXTURE_IMMUTABLE_FORMAT:
3013 // Exposed to ES2.0 through EXT_texture_storage, no client version validation.
3014 *params = (GLfloat)(texture->isImmutable() ? GL_TRUE : GL_FALSE);
3015 break;
3016 case GL_TEXTURE_IMMUTABLE_LEVELS:
3017 if (context->getClientVersion() < 3)
3018 {
Geoff Langb1196682014-07-23 13:47:29 -04003019 context->recordError(gl::Error(GL_INVALID_ENUM));
3020 return;
Geoff Langbfdea662014-07-23 14:16:32 -04003021 }
3022 *params = (GLfloat)texture->immutableLevelCount();
3023 break;
3024 case GL_TEXTURE_USAGE_ANGLE:
3025 *params = (GLfloat)texture->getUsage();
3026 break;
3027 case GL_TEXTURE_MAX_ANISOTROPY_EXT:
3028 if (!context->getExtensions().textureFilterAnisotropic)
3029 {
Geoff Langb1196682014-07-23 13:47:29 -04003030 context->recordError(gl::Error(GL_INVALID_ENUM));
3031 return;
Geoff Langbfdea662014-07-23 14:16:32 -04003032 }
3033 *params = (GLfloat)texture->getSamplerState().maxAnisotropy;
3034 break;
3035 case GL_TEXTURE_SWIZZLE_R:
3036 if (context->getClientVersion() < 3)
3037 {
Geoff Langb1196682014-07-23 13:47:29 -04003038 context->recordError(gl::Error(GL_INVALID_ENUM));
3039 return;
Geoff Langbfdea662014-07-23 14:16:32 -04003040 }
3041 *params = (GLfloat)texture->getSamplerState().swizzleRed;
3042 break;
3043 case GL_TEXTURE_SWIZZLE_G:
3044 if (context->getClientVersion() < 3)
3045 {
Geoff Langb1196682014-07-23 13:47:29 -04003046 context->recordError(gl::Error(GL_INVALID_ENUM));
3047 return;
Geoff Langbfdea662014-07-23 14:16:32 -04003048 }
3049 *params = (GLfloat)texture->getSamplerState().swizzleGreen;
3050 break;
3051 case GL_TEXTURE_SWIZZLE_B:
3052 if (context->getClientVersion() < 3)
3053 {
Geoff Langb1196682014-07-23 13:47:29 -04003054 context->recordError(gl::Error(GL_INVALID_ENUM));
3055 return;
Geoff Langbfdea662014-07-23 14:16:32 -04003056 }
3057 *params = (GLfloat)texture->getSamplerState().swizzleBlue;
3058 break;
3059 case GL_TEXTURE_SWIZZLE_A:
3060 if (context->getClientVersion() < 3)
3061 {
Geoff Langb1196682014-07-23 13:47:29 -04003062 context->recordError(gl::Error(GL_INVALID_ENUM));
3063 return;
Geoff Langbfdea662014-07-23 14:16:32 -04003064 }
3065 *params = (GLfloat)texture->getSamplerState().swizzleAlpha;
3066 break;
3067 case GL_TEXTURE_BASE_LEVEL:
3068 if (context->getClientVersion() < 3)
3069 {
Geoff Langb1196682014-07-23 13:47:29 -04003070 context->recordError(gl::Error(GL_INVALID_ENUM));
3071 return;
Geoff Langbfdea662014-07-23 14:16:32 -04003072 }
3073 *params = (GLfloat)texture->getSamplerState().baseLevel;
3074 break;
3075 case GL_TEXTURE_MAX_LEVEL:
3076 if (context->getClientVersion() < 3)
3077 {
Geoff Langb1196682014-07-23 13:47:29 -04003078 context->recordError(gl::Error(GL_INVALID_ENUM));
3079 return;
Geoff Langbfdea662014-07-23 14:16:32 -04003080 }
3081 *params = (GLfloat)texture->getSamplerState().maxLevel;
3082 break;
3083 case GL_TEXTURE_MIN_LOD:
3084 if (context->getClientVersion() < 3)
3085 {
Geoff Langb1196682014-07-23 13:47:29 -04003086 context->recordError(gl::Error(GL_INVALID_ENUM));
3087 return;
Geoff Langbfdea662014-07-23 14:16:32 -04003088 }
3089 *params = texture->getSamplerState().minLod;
3090 break;
3091 case GL_TEXTURE_MAX_LOD:
3092 if (context->getClientVersion() < 3)
3093 {
Geoff Langb1196682014-07-23 13:47:29 -04003094 context->recordError(gl::Error(GL_INVALID_ENUM));
3095 return;
Geoff Langbfdea662014-07-23 14:16:32 -04003096 }
3097 *params = texture->getSamplerState().maxLod;
3098 break;
Geoff Langb1196682014-07-23 13:47:29 -04003099
Geoff Langbfdea662014-07-23 14:16:32 -04003100 default:
Geoff Langb1196682014-07-23 13:47:29 -04003101 context->recordError(gl::Error(GL_INVALID_ENUM));
3102 return;
Geoff Langbfdea662014-07-23 14:16:32 -04003103 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003104 }
3105}
3106
Kenneth Russell67ea1902014-10-06 16:44:50 -07003107void GL_APIENTRY glGetTexParameteriv(GLenum target, GLenum pname, GLint* params)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003108{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00003109 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 +00003110
Geoff Langbfdea662014-07-23 14:16:32 -04003111 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04003112 if (context)
3113 {
3114 gl::Texture *texture = context->getTargetTexture(target);
3115
3116 if (!texture)
daniel@transgaming.com5d2bee92010-04-20 18:51:56 +00003117 {
Geoff Langb1196682014-07-23 13:47:29 -04003118 context->recordError(gl::Error(GL_INVALID_ENUM));
3119 return;
daniel@transgaming.com5d2bee92010-04-20 18:51:56 +00003120 }
Geoff Langbfdea662014-07-23 14:16:32 -04003121
3122 switch (pname)
3123 {
3124 case GL_TEXTURE_MAG_FILTER:
3125 *params = texture->getSamplerState().magFilter;
3126 break;
3127 case GL_TEXTURE_MIN_FILTER:
3128 *params = texture->getSamplerState().minFilter;
3129 break;
3130 case GL_TEXTURE_WRAP_S:
3131 *params = texture->getSamplerState().wrapS;
3132 break;
3133 case GL_TEXTURE_WRAP_T:
3134 *params = texture->getSamplerState().wrapT;
3135 break;
3136 case GL_TEXTURE_WRAP_R:
3137 if (context->getClientVersion() < 3)
3138 {
Geoff Langb1196682014-07-23 13:47:29 -04003139 context->recordError(gl::Error(GL_INVALID_ENUM));
3140 return;
Geoff Langbfdea662014-07-23 14:16:32 -04003141 }
3142 *params = texture->getSamplerState().wrapR;
3143 break;
3144 case GL_TEXTURE_IMMUTABLE_FORMAT:
3145 // Exposed to ES2.0 through EXT_texture_storage, no client version validation.
3146 *params = texture->isImmutable() ? GL_TRUE : GL_FALSE;
3147 break;
3148 case GL_TEXTURE_IMMUTABLE_LEVELS:
3149 if (context->getClientVersion() < 3)
3150 {
Geoff Langb1196682014-07-23 13:47:29 -04003151 context->recordError(gl::Error(GL_INVALID_ENUM));
3152 return;
Geoff Langbfdea662014-07-23 14:16:32 -04003153 }
Jamie Madill6948e302014-10-20 17:04:33 -04003154 *params = static_cast<GLint>(texture->immutableLevelCount());
Geoff Langbfdea662014-07-23 14:16:32 -04003155 break;
3156 case GL_TEXTURE_USAGE_ANGLE:
3157 *params = texture->getUsage();
3158 break;
3159 case GL_TEXTURE_MAX_ANISOTROPY_EXT:
3160 if (!context->getExtensions().textureFilterAnisotropic)
3161 {
Geoff Langb1196682014-07-23 13:47:29 -04003162 context->recordError(gl::Error(GL_INVALID_ENUM));
3163 return;
Geoff Langbfdea662014-07-23 14:16:32 -04003164 }
3165 *params = (GLint)texture->getSamplerState().maxAnisotropy;
3166 break;
3167 case GL_TEXTURE_SWIZZLE_R:
3168 if (context->getClientVersion() < 3)
3169 {
Geoff Langb1196682014-07-23 13:47:29 -04003170 context->recordError(gl::Error(GL_INVALID_ENUM));
3171 return;
Geoff Langbfdea662014-07-23 14:16:32 -04003172 }
3173 *params = texture->getSamplerState().swizzleRed;
3174 break;
3175 case GL_TEXTURE_SWIZZLE_G:
3176 if (context->getClientVersion() < 3)
3177 {
Geoff Langb1196682014-07-23 13:47:29 -04003178 context->recordError(gl::Error(GL_INVALID_ENUM));
3179 return;
Geoff Langbfdea662014-07-23 14:16:32 -04003180 }
3181 *params = texture->getSamplerState().swizzleGreen;
3182 break;
3183 case GL_TEXTURE_SWIZZLE_B:
3184 if (context->getClientVersion() < 3)
3185 {
Geoff Langb1196682014-07-23 13:47:29 -04003186 context->recordError(gl::Error(GL_INVALID_ENUM));
3187 return;
Geoff Langbfdea662014-07-23 14:16:32 -04003188 }
3189 *params = texture->getSamplerState().swizzleBlue;
3190 break;
3191 case GL_TEXTURE_SWIZZLE_A:
3192 if (context->getClientVersion() < 3)
3193 {
Geoff Langb1196682014-07-23 13:47:29 -04003194 context->recordError(gl::Error(GL_INVALID_ENUM));
3195 return;
Geoff Langbfdea662014-07-23 14:16:32 -04003196 }
3197 *params = texture->getSamplerState().swizzleAlpha;
3198 break;
3199 case GL_TEXTURE_BASE_LEVEL:
3200 if (context->getClientVersion() < 3)
3201 {
Geoff Langb1196682014-07-23 13:47:29 -04003202 context->recordError(gl::Error(GL_INVALID_ENUM));
3203 return;
Geoff Langbfdea662014-07-23 14:16:32 -04003204 }
3205 *params = texture->getSamplerState().baseLevel;
3206 break;
3207 case GL_TEXTURE_MAX_LEVEL:
3208 if (context->getClientVersion() < 3)
3209 {
Geoff Langb1196682014-07-23 13:47:29 -04003210 context->recordError(gl::Error(GL_INVALID_ENUM));
3211 return;
Geoff Langbfdea662014-07-23 14:16:32 -04003212 }
3213 *params = texture->getSamplerState().maxLevel;
3214 break;
3215 case GL_TEXTURE_MIN_LOD:
3216 if (context->getClientVersion() < 3)
3217 {
Geoff Langb1196682014-07-23 13:47:29 -04003218 context->recordError(gl::Error(GL_INVALID_ENUM));
3219 return;
Geoff Langbfdea662014-07-23 14:16:32 -04003220 }
3221 *params = (GLint)texture->getSamplerState().minLod;
3222 break;
3223 case GL_TEXTURE_MAX_LOD:
3224 if (context->getClientVersion() < 3)
3225 {
Geoff Langb1196682014-07-23 13:47:29 -04003226 context->recordError(gl::Error(GL_INVALID_ENUM));
3227 return;
Geoff Langbfdea662014-07-23 14:16:32 -04003228 }
3229 *params = (GLint)texture->getSamplerState().maxLod;
3230 break;
Geoff Langb1196682014-07-23 13:47:29 -04003231
Geoff Langbfdea662014-07-23 14:16:32 -04003232 default:
Geoff Langb1196682014-07-23 13:47:29 -04003233 context->recordError(gl::Error(GL_INVALID_ENUM));
3234 return;
Geoff Langbfdea662014-07-23 14:16:32 -04003235 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003236 }
3237}
3238
Kenneth Russell67ea1902014-10-06 16:44:50 -07003239void GL_APIENTRY glGetnUniformfvEXT(GLuint program, GLint location, GLsizei bufSize, GLfloat* params)
daniel@transgaming.com9a849122011-11-12 03:18:00 +00003240{
3241 EVENT("(GLuint program = %d, GLint location = %d, GLsizei bufSize = %d, GLfloat* params = 0x%0.8p)",
3242 program, location, bufSize, params);
3243
Geoff Langbfdea662014-07-23 14:16:32 -04003244 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04003245 if (context)
3246 {
Jamie Madill0063c512014-08-25 15:47:53 -04003247 if (!ValidateGetnUniformfvEXT(context, program, location, bufSize, params))
daniel@transgaming.com9a849122011-11-12 03:18:00 +00003248 {
Jamie Madill0063c512014-08-25 15:47:53 -04003249 return;
daniel@transgaming.com9a849122011-11-12 03:18:00 +00003250 }
3251
Jamie Madilla502c742014-08-28 17:19:13 -04003252 gl::Program *programObject = context->getProgram(program);
3253 ASSERT(programObject);
3254 gl::ProgramBinary *programBinary = programObject->getProgramBinary();
Jamie Madill0063c512014-08-25 15:47:53 -04003255 ASSERT(programBinary);
Geoff Langbfdea662014-07-23 14:16:32 -04003256
Jamie Madill99a1e982014-08-25 15:47:54 -04003257 programBinary->getUniformfv(location, params);
daniel@transgaming.com9a849122011-11-12 03:18:00 +00003258 }
3259}
3260
Kenneth Russell67ea1902014-10-06 16:44:50 -07003261void GL_APIENTRY glGetUniformfv(GLuint program, GLint location, GLfloat* params)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003262{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00003263 EVENT("(GLuint program = %d, GLint location = %d, GLfloat* params = 0x%0.8p)", program, location, params);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003264
Geoff Langbfdea662014-07-23 14:16:32 -04003265 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04003266 if (context)
3267 {
Jamie Madill0063c512014-08-25 15:47:53 -04003268 if (!ValidateGetUniformfv(context, program, location, params))
daniel@transgaming.combb3d9d02010-04-13 03:26:06 +00003269 {
Jamie Madill0063c512014-08-25 15:47:53 -04003270 return;
daniel@transgaming.com9a849122011-11-12 03:18:00 +00003271 }
Geoff Langbfdea662014-07-23 14:16:32 -04003272
Jamie Madilla502c742014-08-28 17:19:13 -04003273 gl::Program *programObject = context->getProgram(program);
3274 ASSERT(programObject);
3275 gl::ProgramBinary *programBinary = programObject->getProgramBinary();
Jamie Madill0063c512014-08-25 15:47:53 -04003276 ASSERT(programBinary);
Geoff Langbfdea662014-07-23 14:16:32 -04003277
Jamie Madill99a1e982014-08-25 15:47:54 -04003278 programBinary->getUniformfv(location, params);
daniel@transgaming.com9a849122011-11-12 03:18:00 +00003279 }
3280}
3281
Kenneth Russell67ea1902014-10-06 16:44:50 -07003282void GL_APIENTRY glGetnUniformivEXT(GLuint program, GLint location, GLsizei bufSize, GLint* params)
daniel@transgaming.com9a849122011-11-12 03:18:00 +00003283{
Geoff Langbfdea662014-07-23 14:16:32 -04003284 EVENT("(GLuint program = %d, GLint location = %d, GLsizei bufSize = %d, GLint* params = 0x%0.8p)",
daniel@transgaming.com9a849122011-11-12 03:18:00 +00003285 program, location, bufSize, params);
3286
Geoff Langbfdea662014-07-23 14:16:32 -04003287 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04003288 if (context)
3289 {
Jamie Madill0063c512014-08-25 15:47:53 -04003290 if (!ValidateGetnUniformivEXT(context, program, location, bufSize, params))
daniel@transgaming.com9a849122011-11-12 03:18:00 +00003291 {
Jamie Madill0063c512014-08-25 15:47:53 -04003292 return;
daniel@transgaming.com9a849122011-11-12 03:18:00 +00003293 }
3294
Jamie Madilla502c742014-08-28 17:19:13 -04003295 gl::Program *programObject = context->getProgram(program);
3296 ASSERT(programObject);
3297 gl::ProgramBinary *programBinary = programObject->getProgramBinary();
Jamie Madill0063c512014-08-25 15:47:53 -04003298 ASSERT(programBinary);
Geoff Langbfdea662014-07-23 14:16:32 -04003299
Jamie Madill99a1e982014-08-25 15:47:54 -04003300 programBinary->getUniformiv(location, params);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003301 }
3302}
3303
Kenneth Russell67ea1902014-10-06 16:44:50 -07003304void GL_APIENTRY glGetUniformiv(GLuint program, GLint location, GLint* params)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003305{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00003306 EVENT("(GLuint program = %d, GLint location = %d, GLint* params = 0x%0.8p)", program, location, params);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003307
Geoff Langbfdea662014-07-23 14:16:32 -04003308 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04003309 if (context)
3310 {
Jamie Madill0063c512014-08-25 15:47:53 -04003311 if (!ValidateGetUniformiv(context, program, location, params))
daniel@transgaming.combb3d9d02010-04-13 03:26:06 +00003312 {
Jamie Madill0063c512014-08-25 15:47:53 -04003313 return;
daniel@transgaming.combb3d9d02010-04-13 03:26:06 +00003314 }
Geoff Langbfdea662014-07-23 14:16:32 -04003315
Jamie Madilla502c742014-08-28 17:19:13 -04003316 gl::Program *programObject = context->getProgram(program);
3317 ASSERT(programObject);
3318 gl::ProgramBinary *programBinary = programObject->getProgramBinary();
Jamie Madill0063c512014-08-25 15:47:53 -04003319 ASSERT(programBinary);
Geoff Langbfdea662014-07-23 14:16:32 -04003320
Jamie Madill99a1e982014-08-25 15:47:54 -04003321 programBinary->getUniformiv(location, params);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003322 }
3323}
3324
Kenneth Russell67ea1902014-10-06 16:44:50 -07003325GLint GL_APIENTRY glGetUniformLocation(GLuint program, const GLchar* name)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003326{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00003327 EVENT("(GLuint program = %d, const GLchar* name = 0x%0.8p)", program, name);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003328
Geoff Langbfdea662014-07-23 14:16:32 -04003329 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04003330 if (context)
3331 {
Geoff Langb1196682014-07-23 13:47:29 -04003332 if (strstr(name, "gl_") == name)
3333 {
3334 return -1;
3335 }
3336
Geoff Langbfdea662014-07-23 14:16:32 -04003337 gl::Program *programObject = context->getProgram(program);
3338
3339 if (!programObject)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003340 {
Geoff Langbfdea662014-07-23 14:16:32 -04003341 if (context->getShader(program))
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003342 {
Geoff Langb1196682014-07-23 13:47:29 -04003343 context->recordError(gl::Error(GL_INVALID_OPERATION));
3344 return -1;
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003345 }
Geoff Langbfdea662014-07-23 14:16:32 -04003346 else
3347 {
Geoff Langb1196682014-07-23 13:47:29 -04003348 context->recordError(gl::Error(GL_INVALID_VALUE));
3349 return -1;
Geoff Langbfdea662014-07-23 14:16:32 -04003350 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003351 }
Geoff Langbfdea662014-07-23 14:16:32 -04003352
3353 gl::ProgramBinary *programBinary = programObject->getProgramBinary();
3354 if (!programObject->isLinked() || !programBinary)
3355 {
Geoff Langb1196682014-07-23 13:47:29 -04003356 context->recordError(gl::Error(GL_INVALID_OPERATION));
3357 return -1;
Geoff Langbfdea662014-07-23 14:16:32 -04003358 }
3359
3360 return programBinary->getUniformLocation(name);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003361 }
3362
3363 return -1;
3364}
3365
Kenneth Russell67ea1902014-10-06 16:44:50 -07003366void GL_APIENTRY glGetVertexAttribfv(GLuint index, GLenum pname, GLfloat* params)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003367{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00003368 EVENT("(GLuint index = %d, GLenum pname = 0x%X, GLfloat* params = 0x%0.8p)", index, pname, params);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003369
Geoff Langbfdea662014-07-23 14:16:32 -04003370 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04003371 if (context)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003372 {
Geoff Langbfdea662014-07-23 14:16:32 -04003373 if (index >= gl::MAX_VERTEX_ATTRIBS)
daniel@transgaming.come0078962010-04-15 20:45:08 +00003374 {
Geoff Langb1196682014-07-23 13:47:29 -04003375 context->recordError(gl::Error(GL_INVALID_VALUE));
3376 return;
Geoff Langbfdea662014-07-23 14:16:32 -04003377 }
daniel@transgaming.come0078962010-04-15 20:45:08 +00003378
Geoff Langbfdea662014-07-23 14:16:32 -04003379 const gl::VertexAttribute &attribState = context->getState().getVertexAttribState(index);
Geoff Langb1196682014-07-23 13:47:29 -04003380 if (!gl::ValidateGetVertexAttribParameters(context, pname))
Geoff Langbfdea662014-07-23 14:16:32 -04003381 {
3382 return;
3383 }
daniel@transgaming.com428d1582010-05-04 03:35:25 +00003384
Geoff Langbfdea662014-07-23 14:16:32 -04003385 if (pname == GL_CURRENT_VERTEX_ATTRIB)
3386 {
3387 const gl::VertexAttribCurrentValueData &currentValueData = context->getState().getVertexAttribCurrentValue(index);
3388 for (int i = 0; i < 4; ++i)
daniel@transgaming.come0078962010-04-15 20:45:08 +00003389 {
Geoff Langbfdea662014-07-23 14:16:32 -04003390 params[i] = currentValueData.FloatValues[i];
daniel@transgaming.come0078962010-04-15 20:45:08 +00003391 }
3392 }
Geoff Langbfdea662014-07-23 14:16:32 -04003393 else
3394 {
3395 *params = gl::QuerySingleVertexAttributeParameter<GLfloat>(attribState, pname);
3396 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003397 }
3398}
3399
Kenneth Russell67ea1902014-10-06 16:44:50 -07003400void GL_APIENTRY glGetVertexAttribiv(GLuint index, GLenum pname, GLint* params)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003401{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00003402 EVENT("(GLuint index = %d, GLenum pname = 0x%X, GLint* params = 0x%0.8p)", index, pname, params);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003403
Geoff Langbfdea662014-07-23 14:16:32 -04003404 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04003405 if (context)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003406 {
Geoff Langbfdea662014-07-23 14:16:32 -04003407 if (index >= gl::MAX_VERTEX_ATTRIBS)
daniel@transgaming.come0078962010-04-15 20:45:08 +00003408 {
Geoff Langb1196682014-07-23 13:47:29 -04003409 context->recordError(gl::Error(GL_INVALID_VALUE));
3410 return;
Geoff Langbfdea662014-07-23 14:16:32 -04003411 }
daniel@transgaming.come0078962010-04-15 20:45:08 +00003412
Geoff Langbfdea662014-07-23 14:16:32 -04003413 const gl::VertexAttribute &attribState = context->getState().getVertexAttribState(index);
daniel@transgaming.com428d1582010-05-04 03:35:25 +00003414
Geoff Langb1196682014-07-23 13:47:29 -04003415 if (!gl::ValidateGetVertexAttribParameters(context, pname))
Geoff Langbfdea662014-07-23 14:16:32 -04003416 {
3417 return;
3418 }
Jamie Madillaff71502013-07-02 11:57:05 -04003419
Geoff Langbfdea662014-07-23 14:16:32 -04003420 if (pname == GL_CURRENT_VERTEX_ATTRIB)
3421 {
3422 const gl::VertexAttribCurrentValueData &currentValueData = context->getState().getVertexAttribCurrentValue(index);
3423 for (int i = 0; i < 4; ++i)
Jamie Madillaff71502013-07-02 11:57:05 -04003424 {
Geoff Langbfdea662014-07-23 14:16:32 -04003425 float currentValue = currentValueData.FloatValues[i];
3426 params[i] = gl::iround<GLint>(currentValue);
daniel@transgaming.come0078962010-04-15 20:45:08 +00003427 }
3428 }
Geoff Langbfdea662014-07-23 14:16:32 -04003429 else
3430 {
3431 *params = gl::QuerySingleVertexAttributeParameter<GLint>(attribState, pname);
3432 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003433 }
3434}
3435
Kenneth Russell67ea1902014-10-06 16:44:50 -07003436void GL_APIENTRY glGetVertexAttribPointerv(GLuint index, GLenum pname, GLvoid** pointer)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003437{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00003438 EVENT("(GLuint index = %d, GLenum pname = 0x%X, GLvoid** pointer = 0x%0.8p)", index, pname, pointer);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003439
Geoff Langbfdea662014-07-23 14:16:32 -04003440 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04003441 if (context)
3442 {
3443 if (index >= gl::MAX_VERTEX_ATTRIBS)
daniel@transgaming.come0078962010-04-15 20:45:08 +00003444 {
Geoff Langb1196682014-07-23 13:47:29 -04003445 context->recordError(gl::Error(GL_INVALID_VALUE));
3446 return;
daniel@transgaming.come0078962010-04-15 20:45:08 +00003447 }
Geoff Langbfdea662014-07-23 14:16:32 -04003448
3449 if (pname != GL_VERTEX_ATTRIB_ARRAY_POINTER)
3450 {
Geoff Langb1196682014-07-23 13:47:29 -04003451 context->recordError(gl::Error(GL_INVALID_ENUM));
3452 return;
Geoff Langbfdea662014-07-23 14:16:32 -04003453 }
3454
3455 *pointer = const_cast<GLvoid*>(context->getState().getVertexAttribPointer(index));
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003456 }
3457}
3458
Kenneth Russell67ea1902014-10-06 16:44:50 -07003459void GL_APIENTRY glHint(GLenum target, GLenum mode)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003460{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00003461 EVENT("(GLenum target = 0x%X, GLenum mode = 0x%X)", target, mode);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003462
Geoff Langbfdea662014-07-23 14:16:32 -04003463 gl::Context *context = gl::getNonLostContext();
Geoff Langb1196682014-07-23 13:47:29 -04003464 if (context)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003465 {
Geoff Langb1196682014-07-23 13:47:29 -04003466 switch (mode)
3467 {
3468 case GL_FASTEST:
3469 case GL_NICEST:
3470 case GL_DONT_CARE:
3471 break;
3472
3473 default:
3474 context->recordError(gl::Error(GL_INVALID_ENUM));
3475 return;
3476 }
3477
3478 switch (target)
3479 {
3480 case GL_GENERATE_MIPMAP_HINT:
3481 context->getState().setGenerateMipmapHint(mode);
3482 break;
3483
3484 case GL_FRAGMENT_SHADER_DERIVATIVE_HINT_OES:
3485 context->getState().setFragmentShaderDerivativeHint(mode);
3486 break;
3487
3488 default:
3489 context->recordError(gl::Error(GL_INVALID_ENUM));
3490 return;
3491 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003492 }
3493}
3494
Kenneth Russell67ea1902014-10-06 16:44:50 -07003495GLboolean GL_APIENTRY glIsBuffer(GLuint buffer)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003496{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00003497 EVENT("(GLuint buffer = %d)", buffer);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003498
Geoff Langbfdea662014-07-23 14:16:32 -04003499 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04003500 if (context && buffer)
3501 {
3502 gl::Buffer *bufferObject = context->getBuffer(buffer);
3503
3504 if (bufferObject)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003505 {
Geoff Langbfdea662014-07-23 14:16:32 -04003506 return GL_TRUE;
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003507 }
3508 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003509
3510 return GL_FALSE;
3511}
3512
Kenneth Russell67ea1902014-10-06 16:44:50 -07003513GLboolean GL_APIENTRY glIsEnabled(GLenum cap)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003514{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00003515 EVENT("(GLenum cap = 0x%X)", cap);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003516
Geoff Langbfdea662014-07-23 14:16:32 -04003517 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04003518 if (context)
3519 {
3520 if (!ValidCap(context, cap))
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003521 {
Geoff Langb1196682014-07-23 13:47:29 -04003522 context->recordError(gl::Error(GL_INVALID_ENUM));
3523 return GL_FALSE;
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003524 }
Geoff Langbfdea662014-07-23 14:16:32 -04003525
3526 return context->getState().getEnableFeature(cap);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003527 }
3528
3529 return false;
3530}
3531
Kenneth Russell67ea1902014-10-06 16:44:50 -07003532GLboolean GL_APIENTRY glIsFenceNV(GLuint fence)
daniel@transgaming.comfe208882010-09-01 15:47:57 +00003533{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00003534 EVENT("(GLuint fence = %d)", fence);
apatrick@chromium.orgd3bd0ad2010-08-30 18:55:36 +00003535
Geoff Langbfdea662014-07-23 14:16:32 -04003536 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04003537 if (context)
3538 {
3539 gl::FenceNV *fenceObject = context->getFenceNV(fence);
3540
3541 if (fenceObject == NULL)
apatrick@chromium.orgd3bd0ad2010-08-30 18:55:36 +00003542 {
Geoff Langbfdea662014-07-23 14:16:32 -04003543 return GL_FALSE;
apatrick@chromium.orgd3bd0ad2010-08-30 18:55:36 +00003544 }
Geoff Langbfdea662014-07-23 14:16:32 -04003545
3546 return fenceObject->isFence();
apatrick@chromium.orgd3bd0ad2010-08-30 18:55:36 +00003547 }
3548
3549 return GL_FALSE;
daniel@transgaming.comfe208882010-09-01 15:47:57 +00003550}
apatrick@chromium.orgd3bd0ad2010-08-30 18:55:36 +00003551
Kenneth Russell67ea1902014-10-06 16:44:50 -07003552GLboolean GL_APIENTRY glIsFramebuffer(GLuint framebuffer)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003553{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00003554 EVENT("(GLuint framebuffer = %d)", framebuffer);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003555
Geoff Langbfdea662014-07-23 14:16:32 -04003556 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04003557 if (context && framebuffer)
3558 {
3559 gl::Framebuffer *framebufferObject = context->getFramebuffer(framebuffer);
3560
3561 if (framebufferObject)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003562 {
Geoff Langbfdea662014-07-23 14:16:32 -04003563 return GL_TRUE;
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003564 }
3565 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003566
3567 return GL_FALSE;
3568}
3569
Kenneth Russell67ea1902014-10-06 16:44:50 -07003570GLboolean GL_APIENTRY glIsProgram(GLuint program)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003571{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00003572 EVENT("(GLuint program = %d)", program);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003573
Geoff Langbfdea662014-07-23 14:16:32 -04003574 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04003575 if (context && program)
3576 {
3577 gl::Program *programObject = context->getProgram(program);
3578
3579 if (programObject)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003580 {
Geoff Langbfdea662014-07-23 14:16:32 -04003581 return GL_TRUE;
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003582 }
3583 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003584
3585 return GL_FALSE;
3586}
3587
Kenneth Russell67ea1902014-10-06 16:44:50 -07003588GLboolean GL_APIENTRY glIsQueryEXT(GLuint id)
daniel@transgaming.com86bdb822012-01-20 18:24:39 +00003589{
3590 EVENT("(GLuint id = %d)", id);
3591
Geoff Langbfdea662014-07-23 14:16:32 -04003592 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04003593 if (context)
daniel@transgaming.com86bdb822012-01-20 18:24:39 +00003594 {
Geoff Langbfdea662014-07-23 14:16:32 -04003595 return (context->getQuery(id, false, GL_NONE) != NULL) ? GL_TRUE : GL_FALSE;
daniel@transgaming.com86bdb822012-01-20 18:24:39 +00003596 }
3597
3598 return GL_FALSE;
3599}
3600
Kenneth Russell67ea1902014-10-06 16:44:50 -07003601GLboolean GL_APIENTRY glIsRenderbuffer(GLuint renderbuffer)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003602{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00003603 EVENT("(GLuint renderbuffer = %d)", renderbuffer);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003604
Geoff Langbfdea662014-07-23 14:16:32 -04003605 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04003606 if (context && renderbuffer)
3607 {
3608 gl::Renderbuffer *renderbufferObject = context->getRenderbuffer(renderbuffer);
3609
3610 if (renderbufferObject)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003611 {
Geoff Langbfdea662014-07-23 14:16:32 -04003612 return GL_TRUE;
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003613 }
3614 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003615
3616 return GL_FALSE;
3617}
3618
Kenneth Russell67ea1902014-10-06 16:44:50 -07003619GLboolean GL_APIENTRY glIsShader(GLuint shader)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003620{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00003621 EVENT("(GLuint shader = %d)", shader);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003622
Geoff Langbfdea662014-07-23 14:16:32 -04003623 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04003624 if (context && shader)
3625 {
3626 gl::Shader *shaderObject = context->getShader(shader);
3627
3628 if (shaderObject)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003629 {
Geoff Langbfdea662014-07-23 14:16:32 -04003630 return GL_TRUE;
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003631 }
3632 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003633
3634 return GL_FALSE;
3635}
3636
Kenneth Russell67ea1902014-10-06 16:44:50 -07003637GLboolean GL_APIENTRY glIsTexture(GLuint texture)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003638{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00003639 EVENT("(GLuint texture = %d)", texture);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003640
Geoff Langbfdea662014-07-23 14:16:32 -04003641 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04003642 if (context && texture)
3643 {
3644 gl::Texture *textureObject = context->getTexture(texture);
3645
3646 if (textureObject)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003647 {
Geoff Langbfdea662014-07-23 14:16:32 -04003648 return GL_TRUE;
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003649 }
3650 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003651
3652 return GL_FALSE;
3653}
3654
Kenneth Russell67ea1902014-10-06 16:44:50 -07003655void GL_APIENTRY glLineWidth(GLfloat width)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003656{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00003657 EVENT("(GLfloat width = %f)", width);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003658
Geoff Langbfdea662014-07-23 14:16:32 -04003659 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04003660 if (context)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003661 {
Geoff Langb1196682014-07-23 13:47:29 -04003662 if (width <= 0.0f)
3663 {
3664 context->recordError(gl::Error(GL_INVALID_VALUE));
3665 return;
3666 }
3667
Geoff Langbfdea662014-07-23 14:16:32 -04003668 context->getState().setLineWidth(width);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003669 }
3670}
3671
Kenneth Russell67ea1902014-10-06 16:44:50 -07003672void GL_APIENTRY glLinkProgram(GLuint program)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003673{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00003674 EVENT("(GLuint program = %d)", program);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003675
Geoff Langbfdea662014-07-23 14:16:32 -04003676 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04003677 if (context)
3678 {
3679 gl::Program *programObject = context->getProgram(program);
3680
3681 if (!programObject)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003682 {
Geoff Langbfdea662014-07-23 14:16:32 -04003683 if (context->getShader(program))
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003684 {
Geoff Langb1196682014-07-23 13:47:29 -04003685 context->recordError(gl::Error(GL_INVALID_OPERATION));
3686 return;
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003687 }
Geoff Langbfdea662014-07-23 14:16:32 -04003688 else
3689 {
Geoff Langb1196682014-07-23 13:47:29 -04003690 context->recordError(gl::Error(GL_INVALID_VALUE));
3691 return;
Geoff Langbfdea662014-07-23 14:16:32 -04003692 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003693 }
Geoff Langbfdea662014-07-23 14:16:32 -04003694
Geoff Langb543aff2014-09-30 14:52:54 -04003695 gl::Error error = context->linkProgram(program);
3696 if (error.isError())
3697 {
3698 context->recordError(error);
3699 return;
3700 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003701 }
3702}
3703
Kenneth Russell67ea1902014-10-06 16:44:50 -07003704void GL_APIENTRY glPixelStorei(GLenum pname, GLint param)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003705{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00003706 EVENT("(GLenum pname = 0x%X, GLint param = %d)", pname, param);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003707
Geoff Langbfdea662014-07-23 14:16:32 -04003708 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04003709 if (context)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003710 {
Geoff Langbfdea662014-07-23 14:16:32 -04003711 switch (pname)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003712 {
Geoff Langbfdea662014-07-23 14:16:32 -04003713 case GL_UNPACK_ALIGNMENT:
3714 if (param != 1 && param != 2 && param != 4 && param != 8)
daniel@transgaming.com3489e3a2010-03-21 04:31:11 +00003715 {
Geoff Langb1196682014-07-23 13:47:29 -04003716 context->recordError(gl::Error(GL_INVALID_VALUE));
3717 return;
Geoff Langbfdea662014-07-23 14:16:32 -04003718 }
daniel@transgaming.com3489e3a2010-03-21 04:31:11 +00003719
Geoff Langbfdea662014-07-23 14:16:32 -04003720 context->getState().setUnpackAlignment(param);
3721 break;
daniel@transgaming.com3489e3a2010-03-21 04:31:11 +00003722
Geoff Langbfdea662014-07-23 14:16:32 -04003723 case GL_PACK_ALIGNMENT:
3724 if (param != 1 && param != 2 && param != 4 && param != 8)
3725 {
Geoff Langb1196682014-07-23 13:47:29 -04003726 context->recordError(gl::Error(GL_INVALID_VALUE));
3727 return;
Geoff Langbfdea662014-07-23 14:16:32 -04003728 }
daniel@transgaming.com3489e3a2010-03-21 04:31:11 +00003729
Geoff Langbfdea662014-07-23 14:16:32 -04003730 context->getState().setPackAlignment(param);
3731 break;
daniel@transgaming.com3489e3a2010-03-21 04:31:11 +00003732
Geoff Langbfdea662014-07-23 14:16:32 -04003733 case GL_PACK_REVERSE_ROW_ORDER_ANGLE:
3734 context->getState().setPackReverseRowOrder(param != 0);
3735 break;
bsalomon@google.com56d46ab2011-11-23 14:53:10 +00003736
Geoff Langbfdea662014-07-23 14:16:32 -04003737 case GL_UNPACK_IMAGE_HEIGHT:
3738 case GL_UNPACK_SKIP_IMAGES:
3739 case GL_UNPACK_ROW_LENGTH:
3740 case GL_UNPACK_SKIP_ROWS:
3741 case GL_UNPACK_SKIP_PIXELS:
3742 case GL_PACK_ROW_LENGTH:
3743 case GL_PACK_SKIP_ROWS:
3744 case GL_PACK_SKIP_PIXELS:
3745 if (context->getClientVersion() < 3)
3746 {
Geoff Langb1196682014-07-23 13:47:29 -04003747 context->recordError(gl::Error(GL_INVALID_ENUM));
3748 return;
daniel@transgaming.com3489e3a2010-03-21 04:31:11 +00003749 }
Geoff Langbfdea662014-07-23 14:16:32 -04003750 UNIMPLEMENTED();
3751 break;
3752
3753 default:
Geoff Langb1196682014-07-23 13:47:29 -04003754 context->recordError(gl::Error(GL_INVALID_ENUM));
3755 return;
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003756 }
3757 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003758}
3759
Kenneth Russell67ea1902014-10-06 16:44:50 -07003760void GL_APIENTRY glPolygonOffset(GLfloat factor, GLfloat units)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003761{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00003762 EVENT("(GLfloat factor = %f, GLfloat units = %f)", factor, units);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003763
Geoff Langbfdea662014-07-23 14:16:32 -04003764 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04003765 if (context)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003766 {
Geoff Langbfdea662014-07-23 14:16:32 -04003767 context->getState().setPolygonOffsetParams(factor, units);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003768 }
3769}
3770
Kenneth Russell67ea1902014-10-06 16:44:50 -07003771void GL_APIENTRY glReadnPixelsEXT(GLint x, GLint y, GLsizei width, GLsizei height,
daniel@transgaming.comb7915a52011-11-12 03:14:20 +00003772 GLenum format, GLenum type, GLsizei bufSize,
3773 GLvoid *data)
3774{
3775 EVENT("(GLint x = %d, GLint y = %d, GLsizei width = %d, GLsizei height = %d, "
3776 "GLenum format = 0x%X, GLenum type = 0x%X, GLsizei bufSize = 0x%d, GLvoid *data = 0x%0.8p)",
3777 x, y, width, height, format, type, bufSize, data);
3778
Geoff Langbfdea662014-07-23 14:16:32 -04003779 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04003780 if (context)
daniel@transgaming.comb7915a52011-11-12 03:14:20 +00003781 {
Geoff Langb1196682014-07-23 13:47:29 -04003782 if (width < 0 || height < 0 || bufSize < 0)
3783 {
3784 context->recordError(gl::Error(GL_INVALID_VALUE));
3785 return;
3786 }
3787
Geoff Langbfdea662014-07-23 14:16:32 -04003788 if (!gl::ValidateReadPixelsParameters(context, x, y, width, height,
3789 format, type, &bufSize, data))
3790 {
3791 return;
3792 }
3793
Geoff Lang63d2fc72014-07-25 14:51:41 -04003794 gl::Error error = context->readPixels(x, y, width, height, format, type, &bufSize, data);
3795 if (error.isError())
3796 {
3797 context->recordError(error);
3798 return;
3799 }
daniel@transgaming.comb7915a52011-11-12 03:14:20 +00003800 }
3801}
3802
Kenneth Russell67ea1902014-10-06 16:44:50 -07003803void GL_APIENTRY glReadPixels(GLint x, GLint y, GLsizei width, GLsizei height,
daniel@transgaming.comb7915a52011-11-12 03:14:20 +00003804 GLenum format, GLenum type, GLvoid* pixels)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003805{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00003806 EVENT("(GLint x = %d, GLint y = %d, GLsizei width = %d, GLsizei height = %d, "
daniel@transgaming.comfe4b8272010-04-08 03:51:20 +00003807 "GLenum format = 0x%X, GLenum type = 0x%X, GLvoid* pixels = 0x%0.8p)",
daniel@transgaming.comb5b06162010-03-21 04:31:32 +00003808 x, y, width, height, format, type, pixels);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003809
Geoff Langbfdea662014-07-23 14:16:32 -04003810 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04003811 if (context)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003812 {
Geoff Langb1196682014-07-23 13:47:29 -04003813 if (width < 0 || height < 0)
3814 {
3815 context->recordError(gl::Error(GL_INVALID_VALUE));
3816 return;
3817 }
3818
Geoff Langbfdea662014-07-23 14:16:32 -04003819 if (!gl::ValidateReadPixelsParameters(context, x, y, width, height,
3820 format, type, NULL, pixels))
3821 {
3822 return;
3823 }
3824
Geoff Lang63d2fc72014-07-25 14:51:41 -04003825 gl::Error error = context->readPixels(x, y, width, height, format, type, NULL, pixels);
3826 if (error.isError())
3827 {
3828 context->recordError(error);
3829 return;
3830 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003831 }
3832}
3833
Kenneth Russell67ea1902014-10-06 16:44:50 -07003834void GL_APIENTRY glReleaseShaderCompiler(void)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003835{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00003836 EVENT("()");
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003837
Brandon Jonesf05cdee2014-08-27 15:24:07 -07003838 gl::Context *context = gl::getNonLostContext();
3839
3840 if (context)
3841 {
3842 context->releaseShaderCompiler();
3843 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003844}
3845
Kenneth Russell67ea1902014-10-06 16:44:50 -07003846void GL_APIENTRY glRenderbufferStorageMultisampleANGLE(GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003847{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00003848 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 +00003849 target, samples, internalformat, width, height);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003850
Geoff Langbfdea662014-07-23 14:16:32 -04003851 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04003852 if (context)
3853 {
Corentin Walleze0902642014-11-04 12:32:15 -08003854 if (!ValidateRenderbufferStorageParametersANGLE(context, target, samples, internalformat,
3855 width, height))
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003856 {
Geoff Langbfdea662014-07-23 14:16:32 -04003857 return;
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003858 }
Geoff Langbfdea662014-07-23 14:16:32 -04003859
Shannon Woodse2632d22014-10-17 13:08:51 -04003860 gl::Renderbuffer *renderbuffer = context->getState().getCurrentRenderbuffer();
Geoff Langbafefdf2014-10-10 14:26:35 -04003861 gl::Error error = renderbuffer->setStorage(width, height, internalformat, samples);
3862 if (error.isError())
3863 {
3864 context->recordError(error);
3865 return;
3866 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003867 }
3868}
3869
Kenneth Russell67ea1902014-10-06 16:44:50 -07003870void GL_APIENTRY glRenderbufferStorage(GLenum target, GLenum internalformat, GLsizei width, GLsizei height)
daniel@transgaming.com1f135d82010-08-24 19:20:36 +00003871{
3872 glRenderbufferStorageMultisampleANGLE(target, 0, internalformat, width, height);
3873}
3874
Kenneth Russell67ea1902014-10-06 16:44:50 -07003875void GL_APIENTRY glSampleCoverage(GLclampf value, GLboolean invert)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003876{
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00003877 EVENT("(GLclampf value = %f, GLboolean invert = %u)", value, invert);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003878
Geoff Langbfdea662014-07-23 14:16:32 -04003879 gl::Context* context = gl::getNonLostContext();
daniel@transgaming.comfab5a1a2010-03-11 19:22:30 +00003880
Geoff Langbfdea662014-07-23 14:16:32 -04003881 if (context)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003882 {
Geoff Langbfdea662014-07-23 14:16:32 -04003883 context->getState().setSampleCoverageParams(gl::clamp01(value), invert == GL_TRUE);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003884 }
3885}
3886
Kenneth Russell67ea1902014-10-06 16:44:50 -07003887void GL_APIENTRY glSetFenceNV(GLuint fence, GLenum condition)
daniel@transgaming.comfe208882010-09-01 15:47:57 +00003888{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00003889 EVENT("(GLuint fence = %d, GLenum condition = 0x%X)", fence, condition);
apatrick@chromium.orgd3bd0ad2010-08-30 18:55:36 +00003890
Geoff Langbfdea662014-07-23 14:16:32 -04003891 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04003892 if (context)
apatrick@chromium.orgd3bd0ad2010-08-30 18:55:36 +00003893 {
Geoff Langb1196682014-07-23 13:47:29 -04003894 if (condition != GL_ALL_COMPLETED_NV)
3895 {
3896 context->recordError(gl::Error(GL_INVALID_ENUM));
3897 return;
3898 }
3899
Geoff Langbfdea662014-07-23 14:16:32 -04003900 gl::FenceNV *fenceObject = context->getFenceNV(fence);
3901
3902 if (fenceObject == NULL)
3903 {
Geoff Langb1196682014-07-23 13:47:29 -04003904 context->recordError(gl::Error(GL_INVALID_OPERATION));
3905 return;
Geoff Langbfdea662014-07-23 14:16:32 -04003906 }
3907
Geoff Lang882033e2014-09-30 11:26:07 -04003908 gl::Error error = fenceObject->setFence(condition);
3909 if (error.isError())
3910 {
3911 context->recordError(error);
3912 return;
3913 }
apatrick@chromium.orgd3bd0ad2010-08-30 18:55:36 +00003914 }
daniel@transgaming.comfe208882010-09-01 15:47:57 +00003915}
apatrick@chromium.orgd3bd0ad2010-08-30 18:55:36 +00003916
Kenneth Russell67ea1902014-10-06 16:44:50 -07003917void GL_APIENTRY glScissor(GLint x, GLint y, GLsizei width, GLsizei height)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003918{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00003919 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 +00003920
Geoff Langbfdea662014-07-23 14:16:32 -04003921 gl::Context* context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04003922 if (context)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003923 {
Geoff Langb1196682014-07-23 13:47:29 -04003924 if (width < 0 || height < 0)
3925 {
3926 context->recordError(gl::Error(GL_INVALID_VALUE));
3927 return;
3928 }
3929
Geoff Langbfdea662014-07-23 14:16:32 -04003930 context->getState().setScissorParams(x, y, width, height);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003931 }
3932}
3933
Kenneth Russell67ea1902014-10-06 16:44:50 -07003934void GL_APIENTRY glShaderBinary(GLsizei n, const GLuint* shaders, GLenum binaryformat, const GLvoid* binary, GLsizei length)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003935{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00003936 EVENT("(GLsizei n = %d, const GLuint* shaders = 0x%0.8p, GLenum binaryformat = 0x%X, "
daniel@transgaming.comfe4b8272010-04-08 03:51:20 +00003937 "const GLvoid* binary = 0x%0.8p, GLsizei length = %d)",
daniel@transgaming.comb5b06162010-03-21 04:31:32 +00003938 n, shaders, binaryformat, binary, length);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003939
Geoff Lang900013c2014-07-07 11:32:19 -04003940 gl::Context* context = gl::getNonLostContext();
3941 if (context)
3942 {
3943 const std::vector<GLenum> &shaderBinaryFormats = context->getCaps().shaderBinaryFormats;
3944 if (std::find(shaderBinaryFormats.begin(), shaderBinaryFormats.end(), binaryformat) == shaderBinaryFormats.end())
3945 {
Geoff Langb1196682014-07-23 13:47:29 -04003946 context->recordError(gl::Error(GL_INVALID_ENUM));
3947 return;
Geoff Lang900013c2014-07-07 11:32:19 -04003948 }
3949
3950 // No binary shader formats are supported.
3951 UNIMPLEMENTED();
3952 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003953}
3954
Kenneth Russell67ea1902014-10-06 16:44:50 -07003955void GL_APIENTRY glShaderSource(GLuint shader, GLsizei count, const GLchar* const* string, const GLint* length)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003956{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00003957 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 +00003958 shader, count, string, length);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003959
Geoff Langbfdea662014-07-23 14:16:32 -04003960 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04003961 if (context)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003962 {
Geoff Langb1196682014-07-23 13:47:29 -04003963 if (count < 0)
3964 {
3965 context->recordError(gl::Error(GL_INVALID_VALUE));
3966 return;
3967 }
3968
Geoff Langbfdea662014-07-23 14:16:32 -04003969 gl::Shader *shaderObject = context->getShader(shader);
3970
3971 if (!shaderObject)
3972 {
3973 if (context->getProgram(shader))
3974 {
Geoff Langb1196682014-07-23 13:47:29 -04003975 context->recordError(gl::Error(GL_INVALID_OPERATION));
3976 return;
Geoff Langbfdea662014-07-23 14:16:32 -04003977 }
3978 else
3979 {
Geoff Langb1196682014-07-23 13:47:29 -04003980 context->recordError(gl::Error(GL_INVALID_VALUE));
3981 return;
Geoff Langbfdea662014-07-23 14:16:32 -04003982 }
3983 }
3984
3985 shaderObject->setSource(count, string, length);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003986 }
3987}
3988
Kenneth Russell67ea1902014-10-06 16:44:50 -07003989void GL_APIENTRY glStencilFunc(GLenum func, GLint ref, GLuint mask)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003990{
daniel@transgaming.comfab5a1a2010-03-11 19:22:30 +00003991 glStencilFuncSeparate(GL_FRONT_AND_BACK, func, ref, mask);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003992}
3993
Kenneth Russell67ea1902014-10-06 16:44:50 -07003994void GL_APIENTRY glStencilFuncSeparate(GLenum face, GLenum func, GLint ref, GLuint mask)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003995{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00003996 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 +00003997
Geoff Langbfdea662014-07-23 14:16:32 -04003998 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04003999 if (context)
4000 {
Geoff Langb1196682014-07-23 13:47:29 -04004001 switch (face)
4002 {
4003 case GL_FRONT:
4004 case GL_BACK:
4005 case GL_FRONT_AND_BACK:
4006 break;
4007
4008 default:
4009 context->recordError(gl::Error(GL_INVALID_ENUM));
4010 return;
4011 }
4012
4013 switch (func)
4014 {
4015 case GL_NEVER:
4016 case GL_ALWAYS:
4017 case GL_LESS:
4018 case GL_LEQUAL:
4019 case GL_EQUAL:
4020 case GL_GEQUAL:
4021 case GL_GREATER:
4022 case GL_NOTEQUAL:
4023 break;
4024
4025 default:
4026 context->recordError(gl::Error(GL_INVALID_ENUM));
4027 return;
4028 }
4029
Geoff Langbfdea662014-07-23 14:16:32 -04004030 if (face == GL_FRONT || face == GL_FRONT_AND_BACK)
4031 {
4032 context->getState().setStencilParams(func, ref, mask);
4033 }
4034
4035 if (face == GL_BACK || face == GL_FRONT_AND_BACK)
4036 {
4037 context->getState().setStencilBackParams(func, ref, mask);
4038 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004039 }
4040}
4041
Kenneth Russell67ea1902014-10-06 16:44:50 -07004042void GL_APIENTRY glStencilMask(GLuint mask)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004043{
4044 glStencilMaskSeparate(GL_FRONT_AND_BACK, mask);
4045}
4046
Kenneth Russell67ea1902014-10-06 16:44:50 -07004047void GL_APIENTRY glStencilMaskSeparate(GLenum face, GLuint mask)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004048{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00004049 EVENT("(GLenum face = 0x%X, GLuint mask = %d)", face, mask);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004050
Geoff Langbfdea662014-07-23 14:16:32 -04004051 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04004052 if (context)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004053 {
Geoff Langb1196682014-07-23 13:47:29 -04004054 switch (face)
4055 {
4056 case GL_FRONT:
4057 case GL_BACK:
4058 case GL_FRONT_AND_BACK:
4059 break;
4060
4061 default:
4062 context->recordError(gl::Error(GL_INVALID_ENUM));
4063 return;
4064 }
4065
Geoff Langbfdea662014-07-23 14:16:32 -04004066 if (face == GL_FRONT || face == GL_FRONT_AND_BACK)
4067 {
4068 context->getState().setStencilWritemask(mask);
4069 }
4070
4071 if (face == GL_BACK || face == GL_FRONT_AND_BACK)
4072 {
4073 context->getState().setStencilBackWritemask(mask);
4074 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004075 }
4076}
4077
Kenneth Russell67ea1902014-10-06 16:44:50 -07004078void GL_APIENTRY glStencilOp(GLenum fail, GLenum zfail, GLenum zpass)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004079{
4080 glStencilOpSeparate(GL_FRONT_AND_BACK, fail, zfail, zpass);
4081}
4082
Kenneth Russell67ea1902014-10-06 16:44:50 -07004083void GL_APIENTRY glStencilOpSeparate(GLenum face, GLenum fail, GLenum zfail, GLenum zpass)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004084{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00004085 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 +00004086 face, fail, zfail, zpass);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004087
Geoff Langbfdea662014-07-23 14:16:32 -04004088 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04004089 if (context)
4090 {
Geoff Langb1196682014-07-23 13:47:29 -04004091 switch (face)
4092 {
4093 case GL_FRONT:
4094 case GL_BACK:
4095 case GL_FRONT_AND_BACK:
4096 break;
4097
4098 default:
4099 context->recordError(gl::Error(GL_INVALID_ENUM));
4100 return;
4101 }
4102
4103 switch (fail)
4104 {
4105 case GL_ZERO:
4106 case GL_KEEP:
4107 case GL_REPLACE:
4108 case GL_INCR:
4109 case GL_DECR:
4110 case GL_INVERT:
4111 case GL_INCR_WRAP:
4112 case GL_DECR_WRAP:
4113 break;
4114
4115 default:
4116 context->recordError(gl::Error(GL_INVALID_ENUM));
4117 return;
4118 }
4119
4120 switch (zfail)
4121 {
4122 case GL_ZERO:
4123 case GL_KEEP:
4124 case GL_REPLACE:
4125 case GL_INCR:
4126 case GL_DECR:
4127 case GL_INVERT:
4128 case GL_INCR_WRAP:
4129 case GL_DECR_WRAP:
4130 break;
4131
4132 default:
4133 context->recordError(gl::Error(GL_INVALID_ENUM));
4134 return;
4135 }
4136
4137 switch (zpass)
4138 {
4139 case GL_ZERO:
4140 case GL_KEEP:
4141 case GL_REPLACE:
4142 case GL_INCR:
4143 case GL_DECR:
4144 case GL_INVERT:
4145 case GL_INCR_WRAP:
4146 case GL_DECR_WRAP:
4147 break;
4148
4149 default:
4150 context->recordError(gl::Error(GL_INVALID_ENUM));
4151 return;
4152 }
4153
Geoff Langbfdea662014-07-23 14:16:32 -04004154 if (face == GL_FRONT || face == GL_FRONT_AND_BACK)
4155 {
4156 context->getState().setStencilOperations(fail, zfail, zpass);
4157 }
4158
4159 if (face == GL_BACK || face == GL_FRONT_AND_BACK)
4160 {
4161 context->getState().setStencilBackOperations(fail, zfail, zpass);
4162 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004163 }
4164}
4165
Kenneth Russell67ea1902014-10-06 16:44:50 -07004166GLboolean GL_APIENTRY glTestFenceNV(GLuint fence)
daniel@transgaming.comfe208882010-09-01 15:47:57 +00004167{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00004168 EVENT("(GLuint fence = %d)", fence);
apatrick@chromium.orgd3bd0ad2010-08-30 18:55:36 +00004169
Geoff Langbfdea662014-07-23 14:16:32 -04004170 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04004171 if (context)
4172 {
4173 gl::FenceNV *fenceObject = context->getFenceNV(fence);
4174
4175 if (fenceObject == NULL)
apatrick@chromium.orgd3bd0ad2010-08-30 18:55:36 +00004176 {
Geoff Langb1196682014-07-23 13:47:29 -04004177 context->recordError(gl::Error(GL_INVALID_OPERATION));
4178 return GL_TRUE;
apatrick@chromium.orgd3bd0ad2010-08-30 18:55:36 +00004179 }
Geoff Langbfdea662014-07-23 14:16:32 -04004180
4181 if (fenceObject->isFence() != GL_TRUE)
4182 {
Geoff Langb1196682014-07-23 13:47:29 -04004183 context->recordError(gl::Error(GL_INVALID_OPERATION));
4184 return GL_TRUE;
Geoff Langbfdea662014-07-23 14:16:32 -04004185 }
4186
Geoff Lang882033e2014-09-30 11:26:07 -04004187 GLboolean result;
4188 gl::Error error = fenceObject->testFence(&result);
4189 if (error.isError())
4190 {
4191 context->recordError(error);
4192 return GL_TRUE;
4193 }
4194
4195 return result;
apatrick@chromium.orgd3bd0ad2010-08-30 18:55:36 +00004196 }
Geoff Langbfdea662014-07-23 14:16:32 -04004197
apatrick@chromium.orgd3bd0ad2010-08-30 18:55:36 +00004198 return GL_TRUE;
daniel@transgaming.comfe208882010-09-01 15:47:57 +00004199}
apatrick@chromium.orgd3bd0ad2010-08-30 18:55:36 +00004200
Kenneth Russell67ea1902014-10-06 16:44:50 -07004201void GL_APIENTRY glTexImage2D(GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height,
daniel@transgaming.comfe4b8272010-04-08 03:51:20 +00004202 GLint border, GLenum format, GLenum type, const GLvoid* pixels)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004203{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00004204 EVENT("(GLenum target = 0x%X, GLint level = %d, GLint internalformat = %d, GLsizei width = %d, GLsizei height = %d, "
Jamie Madill1fc7e2c2014-01-21 16:47:10 -05004205 "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 +00004206 target, level, internalformat, width, height, border, format, type, pixels);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004207
Geoff Langbfdea662014-07-23 14:16:32 -04004208 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04004209 if (context)
4210 {
4211 if (context->getClientVersion() < 3 &&
4212 !ValidateES2TexImageParameters(context, target, level, internalformat, false, false,
4213 0, 0, width, height, border, format, type, pixels))
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004214 {
Geoff Langbfdea662014-07-23 14:16:32 -04004215 return;
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004216 }
Geoff Langbfdea662014-07-23 14:16:32 -04004217
4218 if (context->getClientVersion() >= 3 &&
4219 !ValidateES3TexImageParameters(context, target, level, internalformat, false, false,
4220 0, 0, 0, width, height, 1, border, format, type, pixels))
4221 {
4222 return;
4223 }
4224
4225 switch (target)
4226 {
4227 case GL_TEXTURE_2D:
4228 {
4229 gl::Texture2D *texture = context->getTexture2D();
Geoff Lang1ba6b8d2014-08-28 10:57:31 -04004230 gl::Error error = texture->setImage(level, width, height, internalformat, format, type, context->getState().getUnpackState(), pixels);
4231 if (error.isError())
4232 {
4233 context->recordError(error);
4234 return;
4235 }
Geoff Langbfdea662014-07-23 14:16:32 -04004236 }
4237 break;
Geoff Lang8376cea2014-09-02 11:47:07 -04004238
Geoff Langbfdea662014-07-23 14:16:32 -04004239 case GL_TEXTURE_CUBE_MAP_POSITIVE_X:
Geoff Langbfdea662014-07-23 14:16:32 -04004240 case GL_TEXTURE_CUBE_MAP_NEGATIVE_X:
Geoff Langbfdea662014-07-23 14:16:32 -04004241 case GL_TEXTURE_CUBE_MAP_POSITIVE_Y:
Geoff Langbfdea662014-07-23 14:16:32 -04004242 case GL_TEXTURE_CUBE_MAP_NEGATIVE_Y:
Geoff Langbfdea662014-07-23 14:16:32 -04004243 case GL_TEXTURE_CUBE_MAP_POSITIVE_Z:
Geoff Langbfdea662014-07-23 14:16:32 -04004244 case GL_TEXTURE_CUBE_MAP_NEGATIVE_Z:
4245 {
4246 gl::TextureCubeMap *texture = context->getTextureCubeMap();
Geoff Lang8376cea2014-09-02 11:47:07 -04004247 gl::Error error = texture->setImage(target, level, width, height, internalformat, format, type, context->getState().getUnpackState(), pixels);
Geoff Lang1ba6b8d2014-08-28 10:57:31 -04004248 if (error.isError())
4249 {
4250 context->recordError(error);
4251 return;
4252 }
Geoff Langbfdea662014-07-23 14:16:32 -04004253 }
4254 break;
Geoff Lang8376cea2014-09-02 11:47:07 -04004255
Geoff Langbfdea662014-07-23 14:16:32 -04004256 default: UNREACHABLE();
4257 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004258 }
4259}
4260
Kenneth Russell67ea1902014-10-06 16:44:50 -07004261void GL_APIENTRY glTexParameterf(GLenum target, GLenum pname, GLfloat param)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004262{
daniel@transgaming.com07ab8412012-07-12 15:17:09 +00004263 EVENT("(GLenum target = 0x%X, GLenum pname = 0x%X, GLint param = %f)", target, pname, param);
4264
Geoff Langbfdea662014-07-23 14:16:32 -04004265 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04004266 if (context)
4267 {
4268 if (!ValidateTexParamParameters(context, pname, static_cast<GLint>(param)))
daniel@transgaming.com07ab8412012-07-12 15:17:09 +00004269 {
Geoff Langbfdea662014-07-23 14:16:32 -04004270 return;
daniel@transgaming.com07ab8412012-07-12 15:17:09 +00004271 }
Geoff Langbfdea662014-07-23 14:16:32 -04004272
4273 gl::Texture *texture = context->getTargetTexture(target);
4274
4275 if (!texture)
4276 {
Geoff Langb1196682014-07-23 13:47:29 -04004277 context->recordError(gl::Error(GL_INVALID_ENUM));
4278 return;
Geoff Langbfdea662014-07-23 14:16:32 -04004279 }
4280
4281 switch (pname)
4282 {
4283 case GL_TEXTURE_WRAP_S: texture->getSamplerState().wrapS = gl::uiround<GLenum>(param); break;
4284 case GL_TEXTURE_WRAP_T: texture->getSamplerState().wrapT = gl::uiround<GLenum>(param); break;
4285 case GL_TEXTURE_WRAP_R: texture->getSamplerState().wrapR = gl::uiround<GLenum>(param); break;
4286 case GL_TEXTURE_MIN_FILTER: texture->getSamplerState().minFilter = gl::uiround<GLenum>(param); break;
4287 case GL_TEXTURE_MAG_FILTER: texture->getSamplerState().magFilter = gl::uiround<GLenum>(param); break;
4288 case GL_TEXTURE_USAGE_ANGLE: texture->setUsage(gl::uiround<GLenum>(param)); break;
4289 case GL_TEXTURE_MAX_ANISOTROPY_EXT: texture->getSamplerState().maxAnisotropy = std::min(param, context->getExtensions().maxTextureAnisotropy); break;
4290 case GL_TEXTURE_COMPARE_MODE: texture->getSamplerState().compareMode = gl::uiround<GLenum>(param); break;
4291 case GL_TEXTURE_COMPARE_FUNC: texture->getSamplerState().compareFunc = gl::uiround<GLenum>(param); break;
4292 case GL_TEXTURE_SWIZZLE_R: texture->getSamplerState().swizzleRed = gl::uiround<GLenum>(param); break;
4293 case GL_TEXTURE_SWIZZLE_G: texture->getSamplerState().swizzleGreen = gl::uiround<GLenum>(param); break;
4294 case GL_TEXTURE_SWIZZLE_B: texture->getSamplerState().swizzleBlue = gl::uiround<GLenum>(param); break;
4295 case GL_TEXTURE_SWIZZLE_A: texture->getSamplerState().swizzleAlpha = gl::uiround<GLenum>(param); break;
4296 case GL_TEXTURE_BASE_LEVEL: texture->getSamplerState().baseLevel = gl::iround<GLint>(param); break;
4297 case GL_TEXTURE_MAX_LEVEL: texture->getSamplerState().maxLevel = gl::iround<GLint>(param); break;
4298 case GL_TEXTURE_MIN_LOD: texture->getSamplerState().minLod = param; break;
4299 case GL_TEXTURE_MAX_LOD: texture->getSamplerState().maxLod = param; break;
4300 default: UNREACHABLE(); break;
4301 }
daniel@transgaming.com07ab8412012-07-12 15:17:09 +00004302 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004303}
4304
Kenneth Russell67ea1902014-10-06 16:44:50 -07004305void GL_APIENTRY glTexParameterfv(GLenum target, GLenum pname, const GLfloat* params)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004306{
daniel@transgaming.com07ab8412012-07-12 15:17:09 +00004307 glTexParameterf(target, pname, (GLfloat)*params);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004308}
4309
Kenneth Russell67ea1902014-10-06 16:44:50 -07004310void GL_APIENTRY glTexParameteri(GLenum target, GLenum pname, GLint param)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004311{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00004312 EVENT("(GLenum target = 0x%X, GLenum pname = 0x%X, GLint param = %d)", target, pname, param);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004313
Geoff Langbfdea662014-07-23 14:16:32 -04004314 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04004315 if (context)
4316 {
4317 if (!ValidateTexParamParameters(context, pname, param))
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004318 {
Geoff Langbfdea662014-07-23 14:16:32 -04004319 return;
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004320 }
Geoff Langbfdea662014-07-23 14:16:32 -04004321
4322 gl::Texture *texture = context->getTargetTexture(target);
4323
4324 if (!texture)
4325 {
Geoff Langb1196682014-07-23 13:47:29 -04004326 context->recordError(gl::Error(GL_INVALID_ENUM));
4327 return;
Geoff Langbfdea662014-07-23 14:16:32 -04004328 }
4329
4330 switch (pname)
4331 {
4332 case GL_TEXTURE_WRAP_S: texture->getSamplerState().wrapS = (GLenum)param; break;
4333 case GL_TEXTURE_WRAP_T: texture->getSamplerState().wrapT = (GLenum)param; break;
4334 case GL_TEXTURE_WRAP_R: texture->getSamplerState().wrapR = (GLenum)param; break;
4335 case GL_TEXTURE_MIN_FILTER: texture->getSamplerState().minFilter = (GLenum)param; break;
4336 case GL_TEXTURE_MAG_FILTER: texture->getSamplerState().magFilter = (GLenum)param; break;
4337 case GL_TEXTURE_USAGE_ANGLE: texture->setUsage((GLenum)param); break;
4338 case GL_TEXTURE_MAX_ANISOTROPY_EXT: texture->getSamplerState().maxAnisotropy = std::min((float)param, context->getExtensions().maxTextureAnisotropy); break;
4339 case GL_TEXTURE_COMPARE_MODE: texture->getSamplerState().compareMode = (GLenum)param; break;
4340 case GL_TEXTURE_COMPARE_FUNC: texture->getSamplerState().compareFunc = (GLenum)param; break;
4341 case GL_TEXTURE_SWIZZLE_R: texture->getSamplerState().swizzleRed = (GLenum)param; break;
4342 case GL_TEXTURE_SWIZZLE_G: texture->getSamplerState().swizzleGreen = (GLenum)param; break;
4343 case GL_TEXTURE_SWIZZLE_B: texture->getSamplerState().swizzleBlue = (GLenum)param; break;
4344 case GL_TEXTURE_SWIZZLE_A: texture->getSamplerState().swizzleAlpha = (GLenum)param; break;
4345 case GL_TEXTURE_BASE_LEVEL: texture->getSamplerState().baseLevel = param; break;
4346 case GL_TEXTURE_MAX_LEVEL: texture->getSamplerState().maxLevel = param; break;
4347 case GL_TEXTURE_MIN_LOD: texture->getSamplerState().minLod = (GLfloat)param; break;
4348 case GL_TEXTURE_MAX_LOD: texture->getSamplerState().maxLod = (GLfloat)param; break;
4349 default: UNREACHABLE(); break;
4350 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004351 }
4352}
4353
Kenneth Russell67ea1902014-10-06 16:44:50 -07004354void GL_APIENTRY glTexParameteriv(GLenum target, GLenum pname, const GLint* params)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004355{
4356 glTexParameteri(target, pname, *params);
4357}
4358
Kenneth Russell67ea1902014-10-06 16:44:50 -07004359void GL_APIENTRY glTexStorage2DEXT(GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height)
daniel@transgaming.com64a0fb22011-11-11 04:10:40 +00004360{
4361 EVENT("(GLenum target = 0x%X, GLsizei levels = %d, GLenum internalformat = 0x%X, GLsizei width = %d, GLsizei height = %d)",
4362 target, levels, internalformat, width, height);
4363
Geoff Langbfdea662014-07-23 14:16:32 -04004364 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04004365 if (context)
4366 {
4367 if (!context->getExtensions().textureStorage)
daniel@transgaming.com64a0fb22011-11-11 04:10:40 +00004368 {
Geoff Langb1196682014-07-23 13:47:29 -04004369 context->recordError(gl::Error(GL_INVALID_OPERATION));
4370 return;
daniel@transgaming.com64a0fb22011-11-11 04:10:40 +00004371 }
Geoff Langbfdea662014-07-23 14:16:32 -04004372
4373 if (context->getClientVersion() < 3 &&
4374 !ValidateES2TexStorageParameters(context, target, levels, internalformat, width, height))
4375 {
4376 return;
4377 }
4378
4379 if (context->getClientVersion() >= 3 &&
4380 !ValidateES3TexStorageParameters(context, target, levels, internalformat, width, height, 1))
4381 {
4382 return;
4383 }
4384
4385 switch (target)
4386 {
4387 case GL_TEXTURE_2D:
4388 {
4389 gl::Texture2D *texture2d = context->getTexture2D();
Geoff Lang1f8532b2014-09-05 09:46:13 -04004390 gl::Error error = texture2d->storage(levels, internalformat, width, height);
4391 if (error.isError())
4392 {
4393 context->recordError(error);
4394 return;
4395 }
Geoff Langbfdea662014-07-23 14:16:32 -04004396 }
4397 break;
4398
4399 case GL_TEXTURE_CUBE_MAP:
4400 {
4401 gl::TextureCubeMap *textureCube = context->getTextureCubeMap();
Geoff Lang1f8532b2014-09-05 09:46:13 -04004402 gl::Error error = textureCube->storage(levels, internalformat, width);
4403 if (error.isError())
4404 {
4405 context->recordError(error);
4406 return;
4407 }
Geoff Langbfdea662014-07-23 14:16:32 -04004408 }
4409 break;
4410
4411 default:
Geoff Langb1196682014-07-23 13:47:29 -04004412 context->recordError(gl::Error(GL_INVALID_ENUM));
4413 return;
Geoff Langbfdea662014-07-23 14:16:32 -04004414 }
daniel@transgaming.com64a0fb22011-11-11 04:10:40 +00004415 }
4416}
4417
Kenneth Russell67ea1902014-10-06 16:44:50 -07004418void GL_APIENTRY glTexSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height,
daniel@transgaming.comfe4b8272010-04-08 03:51:20 +00004419 GLenum format, GLenum type, const GLvoid* pixels)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004420{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00004421 EVENT("(GLenum target = 0x%X, GLint level = %d, GLint xoffset = %d, GLint yoffset = %d, "
daniel@transgaming.comb5b06162010-03-21 04:31:32 +00004422 "GLsizei width = %d, GLsizei height = %d, GLenum format = 0x%X, GLenum type = 0x%X, "
daniel@transgaming.comfe4b8272010-04-08 03:51:20 +00004423 "const GLvoid* pixels = 0x%0.8p)",
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004424 target, level, xoffset, yoffset, width, height, format, type, pixels);
4425
Geoff Langbfdea662014-07-23 14:16:32 -04004426 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04004427 if (context)
4428 {
4429 if (context->getClientVersion() < 3 &&
4430 !ValidateES2TexImageParameters(context, target, level, GL_NONE, false, true,
4431 xoffset, yoffset, width, height, 0, format, type, pixels))
daniel@transgaming.com00c75962010-03-11 20:36:15 +00004432 {
Geoff Langbfdea662014-07-23 14:16:32 -04004433 return;
daniel@transgaming.com00c75962010-03-11 20:36:15 +00004434 }
Geoff Langbfdea662014-07-23 14:16:32 -04004435
4436 if (context->getClientVersion() >= 3 &&
4437 !ValidateES3TexImageParameters(context, target, level, GL_NONE, false, true,
4438 xoffset, yoffset, 0, width, height, 1, 0, format, type, pixels))
4439 {
4440 return;
4441 }
4442
4443 // Zero sized uploads are valid but no-ops
4444 if (width == 0 || height == 0)
4445 {
4446 return;
4447 }
4448
4449 switch (target)
4450 {
4451 case GL_TEXTURE_2D:
4452 {
4453 gl::Texture2D *texture = context->getTexture2D();
Geoff Lang1ba6b8d2014-08-28 10:57:31 -04004454 gl::Error error = texture->subImage(level, xoffset, yoffset, width, height, format, type, context->getState().getUnpackState(), pixels);
4455 if (error.isError())
4456 {
4457 context->recordError(error);
4458 return;
4459 }
Geoff Langbfdea662014-07-23 14:16:32 -04004460 }
4461 break;
4462
4463 case GL_TEXTURE_CUBE_MAP_POSITIVE_X:
4464 case GL_TEXTURE_CUBE_MAP_NEGATIVE_X:
4465 case GL_TEXTURE_CUBE_MAP_POSITIVE_Y:
4466 case GL_TEXTURE_CUBE_MAP_NEGATIVE_Y:
4467 case GL_TEXTURE_CUBE_MAP_POSITIVE_Z:
4468 case GL_TEXTURE_CUBE_MAP_NEGATIVE_Z:
4469 {
4470 gl::TextureCubeMap *texture = context->getTextureCubeMap();
Geoff Lang1ba6b8d2014-08-28 10:57:31 -04004471 gl::Error error = texture->subImage(target, level, xoffset, yoffset, width, height, format, type, context->getState().getUnpackState(), pixels);
4472 if (error.isError())
4473 {
4474 context->recordError(error);
4475 return;
4476 }
Geoff Langbfdea662014-07-23 14:16:32 -04004477 }
4478 break;
4479
4480 default:
4481 UNREACHABLE();
4482 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004483 }
4484}
4485
Kenneth Russell67ea1902014-10-06 16:44:50 -07004486void GL_APIENTRY glUniform1f(GLint location, GLfloat x)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004487{
4488 glUniform1fv(location, 1, &x);
4489}
4490
Kenneth Russell67ea1902014-10-06 16:44:50 -07004491void GL_APIENTRY glUniform1fv(GLint location, GLsizei count, const GLfloat* v)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004492{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00004493 EVENT("(GLint location = %d, GLsizei count = %d, const GLfloat* v = 0x%0.8p)", location, count, v);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004494
Geoff Langbfdea662014-07-23 14:16:32 -04004495 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04004496 if (context)
4497 {
4498 if (!ValidateUniform(context, GL_FLOAT, location, count))
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004499 {
Geoff Langbfdea662014-07-23 14:16:32 -04004500 return;
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004501 }
Geoff Langbfdea662014-07-23 14:16:32 -04004502
4503 gl::ProgramBinary *programBinary = context->getState().getCurrentProgramBinary();
4504 programBinary->setUniform1fv(location, count, v);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004505 }
4506}
4507
Kenneth Russell67ea1902014-10-06 16:44:50 -07004508void GL_APIENTRY glUniform1i(GLint location, GLint x)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004509{
4510 glUniform1iv(location, 1, &x);
4511}
4512
Kenneth Russell67ea1902014-10-06 16:44:50 -07004513void GL_APIENTRY glUniform1iv(GLint location, GLsizei count, const GLint* v)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004514{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00004515 EVENT("(GLint location = %d, GLsizei count = %d, const GLint* v = 0x%0.8p)", location, count, v);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004516
Geoff Langbfdea662014-07-23 14:16:32 -04004517 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04004518 if (context)
4519 {
4520 if (!ValidateUniform(context, GL_INT, location, count))
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004521 {
Geoff Langbfdea662014-07-23 14:16:32 -04004522 return;
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004523 }
Geoff Langbfdea662014-07-23 14:16:32 -04004524
4525 gl::ProgramBinary *programBinary = context->getState().getCurrentProgramBinary();
4526 programBinary->setUniform1iv(location, count, v);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004527 }
4528}
4529
Kenneth Russell67ea1902014-10-06 16:44:50 -07004530void GL_APIENTRY glUniform2f(GLint location, GLfloat x, GLfloat y)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004531{
4532 GLfloat xy[2] = {x, y};
4533
Geoff Lang3b3ad1f2014-03-05 14:35:01 -05004534 glUniform2fv(location, 1, xy);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004535}
4536
Kenneth Russell67ea1902014-10-06 16:44:50 -07004537void GL_APIENTRY glUniform2fv(GLint location, GLsizei count, const GLfloat* v)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004538{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00004539 EVENT("(GLint location = %d, GLsizei count = %d, const GLfloat* v = 0x%0.8p)", location, count, v);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004540
Geoff Langbfdea662014-07-23 14:16:32 -04004541 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04004542 if (context)
4543 {
4544 if (!ValidateUniform(context, GL_FLOAT_VEC2, location, count))
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004545 {
Geoff Langbfdea662014-07-23 14:16:32 -04004546 return;
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004547 }
Geoff Langbfdea662014-07-23 14:16:32 -04004548
4549 gl::ProgramBinary *programBinary = context->getState().getCurrentProgramBinary();
4550 programBinary->setUniform2fv(location, count, v);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004551 }
4552}
4553
Kenneth Russell67ea1902014-10-06 16:44:50 -07004554void GL_APIENTRY glUniform2i(GLint location, GLint x, GLint y)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004555{
Geoff Lang3b3ad1f2014-03-05 14:35:01 -05004556 GLint xy[2] = {x, y};
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004557
Geoff Lang3b3ad1f2014-03-05 14:35:01 -05004558 glUniform2iv(location, 1, xy);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004559}
4560
Kenneth Russell67ea1902014-10-06 16:44:50 -07004561void GL_APIENTRY glUniform2iv(GLint location, GLsizei count, const GLint* v)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004562{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00004563 EVENT("(GLint location = %d, GLsizei count = %d, const GLint* v = 0x%0.8p)", location, count, v);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004564
Geoff Langbfdea662014-07-23 14:16:32 -04004565 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04004566 if (context)
4567 {
4568 if (!ValidateUniform(context, GL_INT_VEC2, location, count))
daniel@transgaming.com9a95e2b2010-04-13 03:26:03 +00004569 {
Geoff Langbfdea662014-07-23 14:16:32 -04004570 return;
daniel@transgaming.com9a95e2b2010-04-13 03:26:03 +00004571 }
Geoff Langbfdea662014-07-23 14:16:32 -04004572
4573 gl::ProgramBinary *programBinary = context->getState().getCurrentProgramBinary();
4574 programBinary->setUniform2iv(location, count, v);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004575 }
4576}
4577
Kenneth Russell67ea1902014-10-06 16:44:50 -07004578void GL_APIENTRY glUniform3f(GLint location, GLfloat x, GLfloat y, GLfloat z)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004579{
4580 GLfloat xyz[3] = {x, y, z};
4581
Geoff Lang3b3ad1f2014-03-05 14:35:01 -05004582 glUniform3fv(location, 1, xyz);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004583}
4584
Kenneth Russell67ea1902014-10-06 16:44:50 -07004585void GL_APIENTRY glUniform3fv(GLint location, GLsizei count, const GLfloat* v)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004586{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00004587 EVENT("(GLint location = %d, GLsizei count = %d, const GLfloat* v = 0x%0.8p)", location, count, v);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004588
Geoff Langbfdea662014-07-23 14:16:32 -04004589 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04004590 if (context)
4591 {
4592 if (!ValidateUniform(context, GL_FLOAT_VEC3, location, count))
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004593 {
Geoff Langbfdea662014-07-23 14:16:32 -04004594 return;
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004595 }
Geoff Langbfdea662014-07-23 14:16:32 -04004596
4597 gl::ProgramBinary *programBinary = context->getState().getCurrentProgramBinary();
4598 programBinary->setUniform3fv(location, count, v);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004599 }
4600}
4601
Kenneth Russell67ea1902014-10-06 16:44:50 -07004602void GL_APIENTRY glUniform3i(GLint location, GLint x, GLint y, GLint z)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004603{
4604 GLint xyz[3] = {x, y, z};
4605
Geoff Lang3b3ad1f2014-03-05 14:35:01 -05004606 glUniform3iv(location, 1, xyz);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004607}
4608
Kenneth Russell67ea1902014-10-06 16:44:50 -07004609void GL_APIENTRY glUniform3iv(GLint location, GLsizei count, const GLint* v)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004610{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00004611 EVENT("(GLint location = %d, GLsizei count = %d, const GLint* v = 0x%0.8p)", location, count, v);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004612
Geoff Langbfdea662014-07-23 14:16:32 -04004613 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04004614 if (context)
4615 {
4616 if (!ValidateUniform(context, GL_INT_VEC3, location, count))
daniel@transgaming.com9a95e2b2010-04-13 03:26:03 +00004617 {
Geoff Langbfdea662014-07-23 14:16:32 -04004618 return;
daniel@transgaming.com9a95e2b2010-04-13 03:26:03 +00004619 }
Geoff Langbfdea662014-07-23 14:16:32 -04004620
4621 gl::ProgramBinary *programBinary = context->getState().getCurrentProgramBinary();
4622 programBinary->setUniform3iv(location, count, v);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004623 }
4624}
4625
Kenneth Russell67ea1902014-10-06 16:44:50 -07004626void GL_APIENTRY glUniform4f(GLint location, GLfloat x, GLfloat y, GLfloat z, GLfloat w)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004627{
4628 GLfloat xyzw[4] = {x, y, z, w};
4629
Geoff Lang3b3ad1f2014-03-05 14:35:01 -05004630 glUniform4fv(location, 1, xyzw);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004631}
4632
Kenneth Russell67ea1902014-10-06 16:44:50 -07004633void GL_APIENTRY glUniform4fv(GLint location, GLsizei count, const GLfloat* v)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004634{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00004635 EVENT("(GLint location = %d, GLsizei count = %d, const GLfloat* v = 0x%0.8p)", location, count, v);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004636
Geoff Langbfdea662014-07-23 14:16:32 -04004637 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04004638 if (context)
4639 {
4640 if (!ValidateUniform(context, GL_FLOAT_VEC4, location, count))
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004641 {
Geoff Langbfdea662014-07-23 14:16:32 -04004642 return;
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004643 }
Geoff Langbfdea662014-07-23 14:16:32 -04004644
4645 gl::ProgramBinary *programBinary = context->getState().getCurrentProgramBinary();
4646 programBinary->setUniform4fv(location, count, v);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004647 }
4648}
4649
Kenneth Russell67ea1902014-10-06 16:44:50 -07004650void GL_APIENTRY glUniform4i(GLint location, GLint x, GLint y, GLint z, GLint w)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004651{
4652 GLint xyzw[4] = {x, y, z, w};
4653
Geoff Lang3b3ad1f2014-03-05 14:35:01 -05004654 glUniform4iv(location, 1, xyzw);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004655}
4656
Kenneth Russell67ea1902014-10-06 16:44:50 -07004657void GL_APIENTRY glUniform4iv(GLint location, GLsizei count, const GLint* v)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004658{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00004659 EVENT("(GLint location = %d, GLsizei count = %d, const GLint* v = 0x%0.8p)", location, count, v);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004660
Geoff Langbfdea662014-07-23 14:16:32 -04004661 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04004662 if (context)
4663 {
4664 if (!ValidateUniform(context, GL_INT_VEC4, location, count))
daniel@transgaming.com9a95e2b2010-04-13 03:26:03 +00004665 {
Geoff Langbfdea662014-07-23 14:16:32 -04004666 return;
daniel@transgaming.com9a95e2b2010-04-13 03:26:03 +00004667 }
Geoff Langbfdea662014-07-23 14:16:32 -04004668
4669 gl::ProgramBinary *programBinary = context->getState().getCurrentProgramBinary();
4670 programBinary->setUniform4iv(location, count, v);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004671 }
4672}
4673
Kenneth Russell67ea1902014-10-06 16:44:50 -07004674void GL_APIENTRY glUniformMatrix2fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004675{
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00004676 EVENT("(GLint location = %d, GLsizei count = %d, GLboolean transpose = %u, const GLfloat* value = 0x%0.8p)",
daniel@transgaming.comb5b06162010-03-21 04:31:32 +00004677 location, count, transpose, value);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004678
Geoff Langbfdea662014-07-23 14:16:32 -04004679 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04004680 if (context)
4681 {
4682 if (!ValidateUniformMatrix(context, GL_FLOAT_MAT2, location, count, transpose))
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004683 {
Geoff Langbfdea662014-07-23 14:16:32 -04004684 return;
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004685 }
Geoff Langbfdea662014-07-23 14:16:32 -04004686
4687 gl::ProgramBinary *programBinary = context->getState().getCurrentProgramBinary();
4688 programBinary->setUniformMatrix2fv(location, count, transpose, value);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004689 }
4690}
4691
Kenneth Russell67ea1902014-10-06 16:44:50 -07004692void GL_APIENTRY glUniformMatrix3fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004693{
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00004694 EVENT("(GLint location = %d, GLsizei count = %d, GLboolean transpose = %u, const GLfloat* value = 0x%0.8p)",
daniel@transgaming.comb5b06162010-03-21 04:31:32 +00004695 location, count, transpose, value);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004696
Geoff Langbfdea662014-07-23 14:16:32 -04004697 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04004698 if (context)
4699 {
4700 if (!ValidateUniformMatrix(context, GL_FLOAT_MAT3, location, count, transpose))
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004701 {
Geoff Langbfdea662014-07-23 14:16:32 -04004702 return;
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004703 }
Geoff Langbfdea662014-07-23 14:16:32 -04004704
4705 gl::ProgramBinary *programBinary = context->getState().getCurrentProgramBinary();
4706 programBinary->setUniformMatrix3fv(location, count, transpose, value);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004707 }
4708}
4709
Kenneth Russell67ea1902014-10-06 16:44:50 -07004710void GL_APIENTRY glUniformMatrix4fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004711{
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00004712 EVENT("(GLint location = %d, GLsizei count = %d, GLboolean transpose = %u, const GLfloat* value = 0x%0.8p)",
daniel@transgaming.comb5b06162010-03-21 04:31:32 +00004713 location, count, transpose, value);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004714
Geoff Langbfdea662014-07-23 14:16:32 -04004715 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04004716 if (context)
4717 {
4718 if (!ValidateUniformMatrix(context, GL_FLOAT_MAT4, location, count, transpose))
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004719 {
Geoff Langbfdea662014-07-23 14:16:32 -04004720 return;
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004721 }
Geoff Langbfdea662014-07-23 14:16:32 -04004722
4723 gl::ProgramBinary *programBinary = context->getState().getCurrentProgramBinary();
4724 programBinary->setUniformMatrix4fv(location, count, transpose, value);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004725 }
4726}
4727
Kenneth Russell67ea1902014-10-06 16:44:50 -07004728void GL_APIENTRY glUseProgram(GLuint program)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004729{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00004730 EVENT("(GLuint program = %d)", program);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004731
Geoff Langbfdea662014-07-23 14:16:32 -04004732 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04004733 if (context)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004734 {
Geoff Langbfdea662014-07-23 14:16:32 -04004735 gl::Program *programObject = context->getProgram(program);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004736
Geoff Langbfdea662014-07-23 14:16:32 -04004737 if (!programObject && program != 0)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004738 {
Geoff Langbfdea662014-07-23 14:16:32 -04004739 if (context->getShader(program))
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004740 {
Geoff Langb1196682014-07-23 13:47:29 -04004741 context->recordError(gl::Error(GL_INVALID_OPERATION));
4742 return;
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004743 }
Geoff Langbfdea662014-07-23 14:16:32 -04004744 else
4745 {
Geoff Langb1196682014-07-23 13:47:29 -04004746 context->recordError(gl::Error(GL_INVALID_VALUE));
4747 return;
Geoff Langbfdea662014-07-23 14:16:32 -04004748 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004749 }
Geoff Langbfdea662014-07-23 14:16:32 -04004750
4751 if (program != 0 && !programObject->isLinked())
4752 {
Geoff Langb1196682014-07-23 13:47:29 -04004753 context->recordError(gl::Error(GL_INVALID_OPERATION));
4754 return;
Geoff Langbfdea662014-07-23 14:16:32 -04004755 }
4756
4757 context->useProgram(program);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004758 }
4759}
4760
Kenneth Russell67ea1902014-10-06 16:44:50 -07004761void GL_APIENTRY glValidateProgram(GLuint program)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004762{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00004763 EVENT("(GLuint program = %d)", program);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004764
Geoff Langbfdea662014-07-23 14:16:32 -04004765 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04004766 if (context)
4767 {
4768 gl::Program *programObject = context->getProgram(program);
4769
4770 if (!programObject)
daniel@transgaming.com86a7a132010-04-29 03:32:32 +00004771 {
Geoff Langbfdea662014-07-23 14:16:32 -04004772 if (context->getShader(program))
daniel@transgaming.com86a7a132010-04-29 03:32:32 +00004773 {
Geoff Langb1196682014-07-23 13:47:29 -04004774 context->recordError(gl::Error(GL_INVALID_OPERATION));
4775 return;
daniel@transgaming.com86a7a132010-04-29 03:32:32 +00004776 }
Geoff Langbfdea662014-07-23 14:16:32 -04004777 else
4778 {
Geoff Langb1196682014-07-23 13:47:29 -04004779 context->recordError(gl::Error(GL_INVALID_VALUE));
4780 return;
Geoff Langbfdea662014-07-23 14:16:32 -04004781 }
daniel@transgaming.com86a7a132010-04-29 03:32:32 +00004782 }
Geoff Langbfdea662014-07-23 14:16:32 -04004783
Brandon Jones43a53e22014-08-28 16:23:22 -07004784 programObject->validate(context->getCaps());
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004785 }
4786}
4787
Kenneth Russell67ea1902014-10-06 16:44:50 -07004788void GL_APIENTRY glVertexAttrib1f(GLuint index, GLfloat x)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004789{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00004790 EVENT("(GLuint index = %d, GLfloat x = %f)", index, x);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004791
Geoff Langbfdea662014-07-23 14:16:32 -04004792 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04004793 if (context)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004794 {
Geoff Langb1196682014-07-23 13:47:29 -04004795 if (index >= gl::MAX_VERTEX_ATTRIBS)
4796 {
4797 context->recordError(gl::Error(GL_INVALID_VALUE));
4798 return;
4799 }
4800
Geoff Langbfdea662014-07-23 14:16:32 -04004801 GLfloat vals[4] = { x, 0, 0, 1 };
4802 context->getState().setVertexAttribf(index, vals);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004803 }
4804}
4805
Kenneth Russell67ea1902014-10-06 16:44:50 -07004806void GL_APIENTRY glVertexAttrib1fv(GLuint index, const GLfloat* values)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004807{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00004808 EVENT("(GLuint index = %d, const GLfloat* values = 0x%0.8p)", index, values);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004809
Geoff Langbfdea662014-07-23 14:16:32 -04004810 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04004811 if (context)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004812 {
Geoff Langb1196682014-07-23 13:47:29 -04004813 if (index >= gl::MAX_VERTEX_ATTRIBS)
4814 {
4815 context->recordError(gl::Error(GL_INVALID_VALUE));
4816 return;
4817 }
4818
Geoff Langbfdea662014-07-23 14:16:32 -04004819 GLfloat vals[4] = { values[0], 0, 0, 1 };
4820 context->getState().setVertexAttribf(index, vals);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004821 }
4822}
4823
Kenneth Russell67ea1902014-10-06 16:44:50 -07004824void GL_APIENTRY glVertexAttrib2f(GLuint index, GLfloat x, GLfloat y)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004825{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00004826 EVENT("(GLuint index = %d, GLfloat x = %f, GLfloat y = %f)", index, x, y);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004827
Geoff Langbfdea662014-07-23 14:16:32 -04004828 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04004829 if (context)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004830 {
Geoff Langb1196682014-07-23 13:47:29 -04004831 if (index >= gl::MAX_VERTEX_ATTRIBS)
4832 {
4833 context->recordError(gl::Error(GL_INVALID_VALUE));
4834 return;
4835 }
4836
Geoff Langbfdea662014-07-23 14:16:32 -04004837 GLfloat vals[4] = { x, y, 0, 1 };
4838 context->getState().setVertexAttribf(index, vals);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004839 }
4840}
4841
Kenneth Russell67ea1902014-10-06 16:44:50 -07004842void GL_APIENTRY glVertexAttrib2fv(GLuint index, const GLfloat* values)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004843{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00004844 EVENT("(GLuint index = %d, const GLfloat* values = 0x%0.8p)", index, values);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004845
Geoff Langbfdea662014-07-23 14:16:32 -04004846 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04004847 if (context)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004848 {
Geoff Langb1196682014-07-23 13:47:29 -04004849 if (index >= gl::MAX_VERTEX_ATTRIBS)
4850 {
4851 context->recordError(gl::Error(GL_INVALID_VALUE));
4852 return;
4853 }
4854
Geoff Langbfdea662014-07-23 14:16:32 -04004855 GLfloat vals[4] = { values[0], values[1], 0, 1 };
4856 context->getState().setVertexAttribf(index, vals);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004857 }
4858}
4859
Kenneth Russell67ea1902014-10-06 16:44:50 -07004860void GL_APIENTRY glVertexAttrib3f(GLuint index, GLfloat x, GLfloat y, GLfloat z)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004861{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00004862 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 +00004863
Geoff Langbfdea662014-07-23 14:16:32 -04004864 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04004865 if (context)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004866 {
Geoff Langb1196682014-07-23 13:47:29 -04004867 if (index >= gl::MAX_VERTEX_ATTRIBS)
4868 {
4869 context->recordError(gl::Error(GL_INVALID_VALUE));
4870 return;
4871 }
4872
Geoff Langbfdea662014-07-23 14:16:32 -04004873 GLfloat vals[4] = { x, y, z, 1 };
4874 context->getState().setVertexAttribf(index, vals);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004875 }
4876}
4877
Kenneth Russell67ea1902014-10-06 16:44:50 -07004878void GL_APIENTRY glVertexAttrib3fv(GLuint index, const GLfloat* values)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004879{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00004880 EVENT("(GLuint index = %d, const GLfloat* values = 0x%0.8p)", index, values);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004881
Geoff Langbfdea662014-07-23 14:16:32 -04004882 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04004883 if (context)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004884 {
Geoff Langb1196682014-07-23 13:47:29 -04004885 if (index >= gl::MAX_VERTEX_ATTRIBS)
4886 {
4887 context->recordError(gl::Error(GL_INVALID_VALUE));
4888 return;
4889 }
4890
Geoff Langbfdea662014-07-23 14:16:32 -04004891 GLfloat vals[4] = { values[0], values[1], values[2], 1 };
4892 context->getState().setVertexAttribf(index, vals);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004893 }
4894}
4895
Kenneth Russell67ea1902014-10-06 16:44:50 -07004896void GL_APIENTRY glVertexAttrib4f(GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004897{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00004898 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 +00004899
Geoff Langbfdea662014-07-23 14:16:32 -04004900 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04004901 if (context)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004902 {
Geoff Langb1196682014-07-23 13:47:29 -04004903 if (index >= gl::MAX_VERTEX_ATTRIBS)
4904 {
4905 context->recordError(gl::Error(GL_INVALID_VALUE));
4906 return;
4907 }
4908
Geoff Langbfdea662014-07-23 14:16:32 -04004909 GLfloat vals[4] = { x, y, z, w };
4910 context->getState().setVertexAttribf(index, vals);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004911 }
4912}
4913
Kenneth Russell67ea1902014-10-06 16:44:50 -07004914void GL_APIENTRY glVertexAttrib4fv(GLuint index, const GLfloat* values)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004915{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00004916 EVENT("(GLuint index = %d, const GLfloat* values = 0x%0.8p)", index, values);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004917
Geoff Langbfdea662014-07-23 14:16:32 -04004918 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04004919 if (context)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004920 {
Geoff Langb1196682014-07-23 13:47:29 -04004921 if (index >= gl::MAX_VERTEX_ATTRIBS)
4922 {
4923 context->recordError(gl::Error(GL_INVALID_VALUE));
4924 return;
4925 }
4926
Geoff Langbfdea662014-07-23 14:16:32 -04004927 context->getState().setVertexAttribf(index, values);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004928 }
4929}
4930
Kenneth Russell67ea1902014-10-06 16:44:50 -07004931void GL_APIENTRY glVertexAttribDivisorANGLE(GLuint index, GLuint divisor)
daniel@transgaming.comd2820bf2012-01-27 15:38:48 +00004932{
4933 EVENT("(GLuint index = %d, GLuint divisor = %d)", index, divisor);
4934
Geoff Langbfdea662014-07-23 14:16:32 -04004935 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04004936 if (context)
daniel@transgaming.comd2820bf2012-01-27 15:38:48 +00004937 {
Geoff Langb1196682014-07-23 13:47:29 -04004938 if (index >= gl::MAX_VERTEX_ATTRIBS)
4939 {
4940 context->recordError(gl::Error(GL_INVALID_VALUE));
4941 return;
4942 }
4943
Geoff Langbfdea662014-07-23 14:16:32 -04004944 context->setVertexAttribDivisor(index, divisor);
daniel@transgaming.comd2820bf2012-01-27 15:38:48 +00004945 }
4946}
4947
Kenneth Russell67ea1902014-10-06 16:44:50 -07004948void GL_APIENTRY glVertexAttribPointer(GLuint index, GLint size, GLenum type, GLboolean normalized, GLsizei stride, const GLvoid* ptr)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004949{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00004950 EVENT("(GLuint index = %d, GLint size = %d, GLenum type = 0x%X, "
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00004951 "GLboolean normalized = %u, GLsizei stride = %d, const GLvoid* ptr = 0x%0.8p)",
daniel@transgaming.comb5b06162010-03-21 04:31:32 +00004952 index, size, type, normalized, stride, ptr);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004953
Geoff Langbfdea662014-07-23 14:16:32 -04004954 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04004955 if (context)
4956 {
Geoff Langb1196682014-07-23 13:47:29 -04004957 if (index >= gl::MAX_VERTEX_ATTRIBS)
4958 {
4959 context->recordError(gl::Error(GL_INVALID_VALUE));
4960 return;
4961 }
4962
4963 if (size < 1 || size > 4)
4964 {
4965 context->recordError(gl::Error(GL_INVALID_VALUE));
4966 return;
4967 }
4968
4969 switch (type)
4970 {
4971 case GL_BYTE:
4972 case GL_UNSIGNED_BYTE:
4973 case GL_SHORT:
4974 case GL_UNSIGNED_SHORT:
4975 case GL_FIXED:
4976 case GL_FLOAT:
4977 break;
4978
4979 case GL_HALF_FLOAT:
4980 case GL_INT:
4981 case GL_UNSIGNED_INT:
4982 case GL_INT_2_10_10_10_REV:
4983 case GL_UNSIGNED_INT_2_10_10_10_REV:
4984 if (context->getClientVersion() < 3)
4985 {
4986 context->recordError(gl::Error(GL_INVALID_ENUM));
4987 return;
4988 }
4989 break;
4990
4991 default:
4992 context->recordError(gl::Error(GL_INVALID_ENUM));
4993 return;
4994 }
4995
4996 if (stride < 0)
4997 {
4998 context->recordError(gl::Error(GL_INVALID_VALUE));
4999 return;
5000 }
5001
5002 if ((type == GL_INT_2_10_10_10_REV || type == GL_UNSIGNED_INT_2_10_10_10_REV) && size != 4)
5003 {
5004 context->recordError(gl::Error(GL_INVALID_OPERATION));
5005 return;
5006 }
5007
Geoff Langbfdea662014-07-23 14:16:32 -04005008 // [OpenGL ES 3.0.2] Section 2.8 page 24:
5009 // An INVALID_OPERATION error is generated when a non-zero vertex array object
5010 // is bound, zero is bound to the ARRAY_BUFFER buffer object binding point,
5011 // and the pointer argument is not NULL.
5012 if (context->getState().getVertexArray()->id() != 0 && context->getState().getArrayBufferId() == 0 && ptr != NULL)
shannon.woods%transgaming.com@gtempaccount.com1ab57be2013-04-13 03:38:39 +00005013 {
Geoff Langb1196682014-07-23 13:47:29 -04005014 context->recordError(gl::Error(GL_INVALID_OPERATION));
5015 return;
shannon.woods%transgaming.com@gtempaccount.com1ab57be2013-04-13 03:38:39 +00005016 }
5017
Geoff Langbfdea662014-07-23 14:16:32 -04005018 context->getState().setVertexAttribState(index, context->getState().getTargetBuffer(GL_ARRAY_BUFFER), size, type,
5019 normalized == GL_TRUE, false, stride, ptr);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005020 }
5021}
5022
Kenneth Russell67ea1902014-10-06 16:44:50 -07005023void GL_APIENTRY glViewport(GLint x, GLint y, GLsizei width, GLsizei height)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005024{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00005025 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 +00005026
Geoff Langbfdea662014-07-23 14:16:32 -04005027 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04005028 if (context)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005029 {
Geoff Langb1196682014-07-23 13:47:29 -04005030 if (width < 0 || height < 0)
5031 {
5032 context->recordError(gl::Error(GL_INVALID_VALUE));
5033 return;
5034 }
5035
Geoff Langbfdea662014-07-23 14:16:32 -04005036 context->getState().setViewportParams(x, y, width, height);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005037 }
5038}
5039
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005040// OpenGL ES 3.0 functions
5041
Kenneth Russell67ea1902014-10-06 16:44:50 -07005042void GL_APIENTRY glReadBuffer(GLenum mode)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005043{
5044 EVENT("(GLenum mode = 0x%X)", mode);
5045
Geoff Langbfdea662014-07-23 14:16:32 -04005046 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04005047 if (context)
5048 {
5049 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005050 {
Geoff Langb1196682014-07-23 13:47:29 -04005051 context->recordError(gl::Error(GL_INVALID_OPERATION));
5052 return;
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00005053 }
Geoff Langbfdea662014-07-23 14:16:32 -04005054
5055 // glReadBuffer
5056 UNIMPLEMENTED();
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005057 }
5058}
5059
Kenneth Russell67ea1902014-10-06 16:44:50 -07005060void 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 +00005061{
5062 EVENT("(GLenum mode = 0x%X, GLuint start = %u, GLuint end = %u, GLsizei count = %d, GLenum type = 0x%X, "
5063 "const GLvoid* indices = 0x%0.8p)", mode, start, end, count, type, indices);
5064
Geoff Langbfdea662014-07-23 14:16:32 -04005065 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04005066 if (context)
5067 {
5068 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005069 {
Geoff Langb1196682014-07-23 13:47:29 -04005070 context->recordError(gl::Error(GL_INVALID_OPERATION));
5071 return;
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00005072 }
Geoff Langbfdea662014-07-23 14:16:32 -04005073
5074 // glDrawRangeElements
5075 UNIMPLEMENTED();
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005076 }
5077}
5078
Kenneth Russell67ea1902014-10-06 16:44:50 -07005079void 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 +00005080{
5081 EVENT("(GLenum target = 0x%X, GLint level = %d, GLint internalformat = %d, GLsizei width = %d, "
5082 "GLsizei height = %d, GLsizei depth = %d, GLint border = %d, GLenum format = 0x%X, "
5083 "GLenum type = 0x%X, const GLvoid* pixels = 0x%0.8p)",
5084 target, level, internalformat, width, height, depth, border, format, type, pixels);
5085
Geoff Langbfdea662014-07-23 14:16:32 -04005086 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04005087 if (context)
5088 {
5089 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005090 {
Geoff Langb1196682014-07-23 13:47:29 -04005091 context->recordError(gl::Error(GL_INVALID_OPERATION));
5092 return;
shannon.woods%transgaming.com@gtempaccount.com875994b2013-04-13 03:45:17 +00005093 }
Geoff Langbfdea662014-07-23 14:16:32 -04005094
5095 // validateES3TexImageFormat sets the error code if there is an error
5096 if (!ValidateES3TexImageParameters(context, target, level, internalformat, false, false,
5097 0, 0, 0, width, height, depth, border, format, type, pixels))
5098 {
5099 return;
5100 }
5101
5102 switch(target)
5103 {
5104 case GL_TEXTURE_3D:
5105 {
5106 gl::Texture3D *texture = context->getTexture3D();
Geoff Lang1ba6b8d2014-08-28 10:57:31 -04005107 gl::Error error = texture->setImage(level, width, height, depth, internalformat, format, type, context->getState().getUnpackState(), pixels);
5108 if (error.isError())
5109 {
5110 context->recordError(error);
5111 return;
5112 }
Geoff Langbfdea662014-07-23 14:16:32 -04005113 }
5114 break;
5115
5116 case GL_TEXTURE_2D_ARRAY:
5117 {
5118 gl::Texture2DArray *texture = context->getTexture2DArray();
Geoff Lang1ba6b8d2014-08-28 10:57:31 -04005119 gl::Error error = texture->setImage(level, width, height, depth, internalformat, format, type, context->getState().getUnpackState(), pixels);
5120 if (error.isError())
5121 {
5122 context->recordError(error);
5123 return;
5124 }
Geoff Langbfdea662014-07-23 14:16:32 -04005125 }
5126 break;
5127
5128 default:
Geoff Langb1196682014-07-23 13:47:29 -04005129 context->recordError(gl::Error(GL_INVALID_ENUM));
5130 return;
Geoff Langbfdea662014-07-23 14:16:32 -04005131 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005132 }
5133}
5134
Kenneth Russell67ea1902014-10-06 16:44:50 -07005135void 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 +00005136{
5137 EVENT("(GLenum target = 0x%X, GLint level = %d, GLint xoffset = %d, GLint yoffset = %d, "
5138 "GLint zoffset = %d, GLsizei width = %d, GLsizei height = %d, GLsizei depth = %d, "
5139 "GLenum format = 0x%X, GLenum type = 0x%X, const GLvoid* pixels = 0x%0.8p)",
5140 target, level, xoffset, yoffset, zoffset, width, height, depth, format, type, pixels);
5141
Geoff Langbfdea662014-07-23 14:16:32 -04005142 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04005143 if (context)
5144 {
5145 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005146 {
Geoff Langb1196682014-07-23 13:47:29 -04005147 context->recordError(gl::Error(GL_INVALID_OPERATION));
5148 return;
shannon.woods%transgaming.com@gtempaccount.com875994b2013-04-13 03:45:17 +00005149 }
Geoff Langbfdea662014-07-23 14:16:32 -04005150
5151 // validateES3TexImageFormat sets the error code if there is an error
5152 if (!ValidateES3TexImageParameters(context, target, level, GL_NONE, false, true,
5153 xoffset, yoffset, zoffset, width, height, depth, 0,
5154 format, type, pixels))
5155 {
5156 return;
5157 }
5158
5159 // Zero sized uploads are valid but no-ops
5160 if (width == 0 || height == 0 || depth == 0)
5161 {
5162 return;
5163 }
5164
5165 switch(target)
5166 {
5167 case GL_TEXTURE_3D:
5168 {
5169 gl::Texture3D *texture = context->getTexture3D();
Geoff Lang1ba6b8d2014-08-28 10:57:31 -04005170 gl::Error error = texture->subImage(level, xoffset, yoffset, zoffset, width, height, depth, format, type, context->getState().getUnpackState(), pixels);
5171 if (error.isError())
5172 {
5173 context->recordError(error);
5174 return;
5175 }
Geoff Langbfdea662014-07-23 14:16:32 -04005176 }
5177 break;
5178
5179 case GL_TEXTURE_2D_ARRAY:
5180 {
5181 gl::Texture2DArray *texture = context->getTexture2DArray();
Geoff Lang1ba6b8d2014-08-28 10:57:31 -04005182 gl::Error error = texture->subImage(level, xoffset, yoffset, zoffset, width, height, depth, format, type, context->getState().getUnpackState(), pixels);
5183 if (error.isError())
5184 {
5185 context->recordError(error);
5186 return;
5187 }
Geoff Langbfdea662014-07-23 14:16:32 -04005188 }
5189 break;
5190
5191 default:
Geoff Langb1196682014-07-23 13:47:29 -04005192 context->recordError(gl::Error(GL_INVALID_ENUM));
5193 return;
Geoff Langbfdea662014-07-23 14:16:32 -04005194 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005195 }
5196}
5197
Kenneth Russell67ea1902014-10-06 16:44:50 -07005198void 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 +00005199{
5200 EVENT("(GLenum target = 0x%X, GLint level = %d, GLint xoffset = %d, GLint yoffset = %d, "
5201 "GLint zoffset = %d, GLint x = %d, GLint y = %d, GLsizei width = %d, GLsizei height = %d)",
5202 target, level, xoffset, yoffset, zoffset, x, y, width, height);
5203
Geoff Langbfdea662014-07-23 14:16:32 -04005204 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04005205 if (context)
5206 {
5207 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005208 {
Geoff Langb1196682014-07-23 13:47:29 -04005209 context->recordError(gl::Error(GL_INVALID_OPERATION));
5210 return;
shannon.woods%transgaming.com@gtempaccount.com875994b2013-04-13 03:45:17 +00005211 }
Geoff Langbfdea662014-07-23 14:16:32 -04005212
5213 if (!ValidateES3CopyTexImageParameters(context, target, level, GL_NONE, true, xoffset, yoffset, zoffset,
5214 x, y, width, height, 0))
5215 {
5216 return;
5217 }
5218
5219 gl::Framebuffer *framebuffer = context->getState().getReadFramebuffer();
5220 gl::Texture *texture = NULL;
5221 switch (target)
5222 {
5223 case GL_TEXTURE_3D:
5224 texture = context->getTexture3D();
5225 break;
5226
5227 case GL_TEXTURE_2D_ARRAY:
5228 texture = context->getTexture2DArray();
5229 break;
5230
5231 default:
Geoff Langb1196682014-07-23 13:47:29 -04005232 context->recordError(gl::Error(GL_INVALID_ENUM));
5233 return;
Geoff Langbfdea662014-07-23 14:16:32 -04005234 }
5235
Geoff Langef7b0162014-09-04 13:29:23 -04005236 gl::Error error = texture->copySubImage(target, level, xoffset, yoffset, zoffset, x, y, width, height, framebuffer);
5237 if (error.isError())
5238 {
5239 context->recordError(error);
5240 return;
5241 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005242 }
5243}
5244
Kenneth Russell67ea1902014-10-06 16:44:50 -07005245void 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 +00005246{
Geoff Langeef52cc2013-10-16 15:07:39 -04005247 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 +00005248 "GLsizei height = %d, GLsizei depth = %d, GLint border = %d, GLsizei imageSize = %d, "
5249 "const GLvoid* data = 0x%0.8p)",
5250 target, level, internalformat, width, height, depth, border, imageSize, data);
5251
Geoff Langbfdea662014-07-23 14:16:32 -04005252 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04005253 if (context)
5254 {
5255 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005256 {
Geoff Langb1196682014-07-23 13:47:29 -04005257 context->recordError(gl::Error(GL_INVALID_OPERATION));
5258 return;
shannon.woods%transgaming.com@gtempaccount.com875994b2013-04-13 03:45:17 +00005259 }
Geoff Langbfdea662014-07-23 14:16:32 -04005260
Geoff Lang5d601382014-07-22 15:14:06 -04005261 const gl::InternalFormat &formatInfo = gl::GetInternalFormatInfo(internalformat);
5262 if (imageSize < 0 || static_cast<GLuint>(imageSize) != formatInfo.computeBlockSize(GL_UNSIGNED_BYTE, width, height))
Geoff Langbfdea662014-07-23 14:16:32 -04005263 {
Geoff Langb1196682014-07-23 13:47:29 -04005264 context->recordError(gl::Error(GL_INVALID_VALUE));
5265 return;
Geoff Langbfdea662014-07-23 14:16:32 -04005266 }
5267
5268 // validateES3TexImageFormat sets the error code if there is an error
5269 if (!ValidateES3TexImageParameters(context, target, level, internalformat, true, false,
5270 0, 0, 0, width, height, depth, border, GL_NONE, GL_NONE, data))
5271 {
5272 return;
5273 }
5274
5275 switch(target)
5276 {
5277 case GL_TEXTURE_3D:
5278 {
5279 gl::Texture3D *texture = context->getTexture3D();
Jamie Madillc751d1e2014-10-21 17:46:29 -04005280 gl::Error error = texture->setCompressedImage(level, internalformat, width, height, depth, imageSize, context->getState().getUnpackState(), data);
Geoff Langb5348332014-09-02 13:16:34 -04005281 if (error.isError())
5282 {
5283 context->recordError(error);
5284 return;
5285 }
Geoff Langbfdea662014-07-23 14:16:32 -04005286 }
5287 break;
5288
5289 case GL_TEXTURE_2D_ARRAY:
5290 {
5291 gl::Texture2DArray *texture = context->getTexture2DArray();
Jamie Madillc751d1e2014-10-21 17:46:29 -04005292 gl::Error error = texture->setCompressedImage(level, internalformat, width, height, depth, imageSize, context->getState().getUnpackState(), data);
Geoff Langb5348332014-09-02 13:16:34 -04005293 if (error.isError())
5294 {
5295 context->recordError(error);
5296 return;
5297 }
Geoff Langbfdea662014-07-23 14:16:32 -04005298 }
5299 break;
5300
5301 default:
Geoff Langb1196682014-07-23 13:47:29 -04005302 context->recordError(gl::Error(GL_INVALID_ENUM));
5303 return;
Geoff Langbfdea662014-07-23 14:16:32 -04005304 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005305 }
5306}
5307
Kenneth Russell67ea1902014-10-06 16:44:50 -07005308void 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 +00005309{
5310 EVENT("(GLenum target = 0x%X, GLint level = %d, GLint xoffset = %d, GLint yoffset = %d, "
5311 "GLint zoffset = %d, GLsizei width = %d, GLsizei height = %d, GLsizei depth = %d, "
5312 "GLenum format = 0x%X, GLsizei imageSize = %d, const GLvoid* data = 0x%0.8p)",
5313 target, level, xoffset, yoffset, zoffset, width, height, depth, format, imageSize, data);
5314
Geoff Langbfdea662014-07-23 14:16:32 -04005315 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04005316 if (context)
5317 {
5318 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005319 {
Geoff Langb1196682014-07-23 13:47:29 -04005320 context->recordError(gl::Error(GL_INVALID_OPERATION));
5321 return;
shannon.woods%transgaming.com@gtempaccount.com875994b2013-04-13 03:45:17 +00005322 }
Geoff Langbfdea662014-07-23 14:16:32 -04005323
Geoff Lang5d601382014-07-22 15:14:06 -04005324 const gl::InternalFormat &formatInfo = gl::GetInternalFormatInfo(format);
5325 if (imageSize < 0 || static_cast<GLuint>(imageSize) != formatInfo.computeBlockSize(GL_UNSIGNED_BYTE, width, height))
Geoff Langbfdea662014-07-23 14:16:32 -04005326 {
Geoff Langb1196682014-07-23 13:47:29 -04005327 context->recordError(gl::Error(GL_INVALID_VALUE));
5328 return;
Geoff Langbfdea662014-07-23 14:16:32 -04005329 }
5330
5331 if (!data)
5332 {
Geoff Langb1196682014-07-23 13:47:29 -04005333 context->recordError(gl::Error(GL_INVALID_VALUE));
5334 return;
Geoff Langbfdea662014-07-23 14:16:32 -04005335 }
5336
5337 // validateES3TexImageFormat sets the error code if there is an error
5338 if (!ValidateES3TexImageParameters(context, target, level, GL_NONE, true, true,
5339 0, 0, 0, width, height, depth, 0, GL_NONE, GL_NONE, data))
5340 {
5341 return;
5342 }
5343
5344 // Zero sized uploads are valid but no-ops
5345 if (width == 0 || height == 0)
5346 {
5347 return;
5348 }
5349
5350 switch(target)
5351 {
5352 case GL_TEXTURE_3D:
5353 {
5354 gl::Texture3D *texture = context->getTexture3D();
Geoff Langb5348332014-09-02 13:16:34 -04005355 gl::Error error = texture->subImageCompressed(level, xoffset, yoffset, zoffset, width, height, depth,
Jamie Madillc751d1e2014-10-21 17:46:29 -04005356 format, imageSize, context->getState().getUnpackState(), data);
Geoff Langb5348332014-09-02 13:16:34 -04005357 if (error.isError())
5358 {
5359 context->recordError(error);
5360 return;
5361 }
Geoff Langbfdea662014-07-23 14:16:32 -04005362 }
5363 break;
5364
5365 case GL_TEXTURE_2D_ARRAY:
5366 {
5367 gl::Texture2DArray *texture = context->getTexture2DArray();
Geoff Langb5348332014-09-02 13:16:34 -04005368 gl::Error error = texture->subImageCompressed(level, xoffset, yoffset, zoffset, width, height, depth,
Jamie Madillc751d1e2014-10-21 17:46:29 -04005369 format, imageSize, context->getState().getUnpackState(), data);
Geoff Langb5348332014-09-02 13:16:34 -04005370 if (error.isError())
5371 {
5372 context->recordError(error);
5373 return;
5374 }
Geoff Langbfdea662014-07-23 14:16:32 -04005375 }
5376 break;
5377
Geoff Langb1196682014-07-23 13:47:29 -04005378 default:
5379 context->recordError(gl::Error(GL_INVALID_ENUM));
5380 return;
Geoff Langbfdea662014-07-23 14:16:32 -04005381 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005382 }
5383}
5384
Kenneth Russell67ea1902014-10-06 16:44:50 -07005385void GL_APIENTRY glGenQueries(GLsizei n, GLuint* ids)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005386{
5387 EVENT("(GLsizei n = %d, GLuint* ids = 0x%0.8p)", n, ids);
5388
Geoff Langbfdea662014-07-23 14:16:32 -04005389 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04005390 if (context)
5391 {
5392 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005393 {
Geoff Langb1196682014-07-23 13:47:29 -04005394 context->recordError(gl::Error(GL_INVALID_OPERATION));
5395 return;
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00005396 }
Geoff Langbfdea662014-07-23 14:16:32 -04005397
5398 if (n < 0)
5399 {
Geoff Langb1196682014-07-23 13:47:29 -04005400 context->recordError(gl::Error(GL_INVALID_VALUE));
5401 return;
Geoff Langbfdea662014-07-23 14:16:32 -04005402 }
5403
5404 for (GLsizei i = 0; i < n; i++)
5405 {
5406 ids[i] = context->createQuery();
5407 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005408 }
5409}
5410
Kenneth Russell67ea1902014-10-06 16:44:50 -07005411void GL_APIENTRY glDeleteQueries(GLsizei n, const GLuint* ids)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005412{
5413 EVENT("(GLsizei n = %d, GLuint* ids = 0x%0.8p)", n, ids);
5414
Geoff Langbfdea662014-07-23 14:16:32 -04005415 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04005416 if (context)
5417 {
5418 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005419 {
Geoff Langb1196682014-07-23 13:47:29 -04005420 context->recordError(gl::Error(GL_INVALID_OPERATION));
5421 return;
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00005422 }
Geoff Langbfdea662014-07-23 14:16:32 -04005423
5424 if (n < 0)
5425 {
Geoff Langb1196682014-07-23 13:47:29 -04005426 context->recordError(gl::Error(GL_INVALID_VALUE));
5427 return;
Geoff Langbfdea662014-07-23 14:16:32 -04005428 }
5429
5430 for (GLsizei i = 0; i < n; i++)
5431 {
5432 context->deleteQuery(ids[i]);
5433 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005434 }
5435}
5436
Kenneth Russell67ea1902014-10-06 16:44:50 -07005437GLboolean GL_APIENTRY glIsQuery(GLuint id)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005438{
5439 EVENT("(GLuint id = %u)", id);
5440
Geoff Langbfdea662014-07-23 14:16:32 -04005441 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04005442 if (context)
5443 {
5444 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005445 {
Geoff Langb1196682014-07-23 13:47:29 -04005446 context->recordError(gl::Error(GL_INVALID_OPERATION));
5447 return GL_FALSE;
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00005448 }
Geoff Langbfdea662014-07-23 14:16:32 -04005449
5450 return (context->getQuery(id, false, GL_NONE) != NULL) ? GL_TRUE : GL_FALSE;
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005451 }
5452
5453 return GL_FALSE;
5454}
5455
Kenneth Russell67ea1902014-10-06 16:44:50 -07005456void GL_APIENTRY glBeginQuery(GLenum target, GLuint id)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005457{
5458 EVENT("(GLenum target = 0x%X, GLuint id = %u)", target, id);
5459
Geoff Langbfdea662014-07-23 14:16:32 -04005460 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04005461 if (context)
5462 {
5463 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005464 {
Geoff Langb1196682014-07-23 13:47:29 -04005465 context->recordError(gl::Error(GL_INVALID_OPERATION));
5466 return;
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00005467 }
Geoff Langbfdea662014-07-23 14:16:32 -04005468
5469 if (!ValidateBeginQuery(context, target, id))
5470 {
5471 return;
5472 }
Geoff Lang5aad9672014-09-08 11:10:42 -04005473
5474 gl::Error error = context->beginQuery(target, id);
5475 if (error.isError())
5476 {
5477 context->recordError(error);
5478 return;
5479 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005480 }
5481}
5482
Kenneth Russell67ea1902014-10-06 16:44:50 -07005483void GL_APIENTRY glEndQuery(GLenum target)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005484{
5485 EVENT("(GLenum target = 0x%X)", target);
5486
Geoff Langbfdea662014-07-23 14:16:32 -04005487 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04005488 if (context)
5489 {
5490 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005491 {
Geoff Langb1196682014-07-23 13:47:29 -04005492 context->recordError(gl::Error(GL_INVALID_OPERATION));
5493 return;
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00005494 }
Geoff Langbfdea662014-07-23 14:16:32 -04005495
5496 if (!ValidateEndQuery(context, target))
5497 {
5498 return;
5499 }
5500
Geoff Lang5aad9672014-09-08 11:10:42 -04005501 gl::Error error = context->endQuery(target);
5502 if (error.isError())
5503 {
5504 context->recordError(error);
5505 return;
5506 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005507 }
5508}
5509
Kenneth Russell67ea1902014-10-06 16:44:50 -07005510void GL_APIENTRY glGetQueryiv(GLenum target, GLenum pname, GLint* params)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005511{
5512 EVENT("(GLenum target = 0x%X, GLenum pname = 0x%X, GLint* params = 0x%0.8p)", target, pname, params);
5513
Geoff Langbfdea662014-07-23 14:16:32 -04005514 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04005515 if (context)
5516 {
5517 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005518 {
Geoff Langb1196682014-07-23 13:47:29 -04005519 context->recordError(gl::Error(GL_INVALID_OPERATION));
5520 return;
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00005521 }
Geoff Langbfdea662014-07-23 14:16:32 -04005522
5523 if (!ValidQueryType(context, target))
5524 {
Geoff Langb1196682014-07-23 13:47:29 -04005525 context->recordError(gl::Error(GL_INVALID_ENUM));
5526 return;
Geoff Langbfdea662014-07-23 14:16:32 -04005527 }
5528
5529 switch (pname)
5530 {
5531 case GL_CURRENT_QUERY:
5532 params[0] = static_cast<GLint>(context->getState().getActiveQueryId(target));
5533 break;
5534
5535 default:
Geoff Langb1196682014-07-23 13:47:29 -04005536 context->recordError(gl::Error(GL_INVALID_ENUM));
5537 return;
Geoff Langbfdea662014-07-23 14:16:32 -04005538 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005539 }
5540}
5541
Kenneth Russell67ea1902014-10-06 16:44:50 -07005542void GL_APIENTRY glGetQueryObjectuiv(GLuint id, GLenum pname, GLuint* params)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005543{
5544 EVENT("(GLuint id = %u, GLenum pname = 0x%X, GLint* params = 0x%0.8p)", id, pname, params);
5545
Geoff Langbfdea662014-07-23 14:16:32 -04005546 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04005547 if (context)
5548 {
5549 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005550 {
Geoff Langb1196682014-07-23 13:47:29 -04005551 context->recordError(gl::Error(GL_INVALID_OPERATION));
5552 return;
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00005553 }
Geoff Langbfdea662014-07-23 14:16:32 -04005554
5555 gl::Query *queryObject = context->getQuery(id, false, GL_NONE);
5556
5557 if (!queryObject)
5558 {
Geoff Langb1196682014-07-23 13:47:29 -04005559 context->recordError(gl::Error(GL_INVALID_OPERATION));
5560 return;
Geoff Langbfdea662014-07-23 14:16:32 -04005561 }
5562
5563 if (context->getState().getActiveQueryId(queryObject->getType()) == id)
5564 {
Geoff Langb1196682014-07-23 13:47:29 -04005565 context->recordError(gl::Error(GL_INVALID_OPERATION));
5566 return;
Geoff Langbfdea662014-07-23 14:16:32 -04005567 }
5568
5569 switch(pname)
5570 {
Geoff Lang5aad9672014-09-08 11:10:42 -04005571 case GL_QUERY_RESULT_EXT:
5572 {
5573 gl::Error error = queryObject->getResult(params);
5574 if (error.isError())
5575 {
5576 context->recordError(error);
5577 return;
5578 }
5579 }
Geoff Langbfdea662014-07-23 14:16:32 -04005580 break;
Geoff Langb1196682014-07-23 13:47:29 -04005581
Geoff Lang5aad9672014-09-08 11:10:42 -04005582 case GL_QUERY_RESULT_AVAILABLE_EXT:
5583 {
5584 gl::Error error = queryObject->isResultAvailable(params);
5585 if (error.isError())
5586 {
5587 context->recordError(error);
5588 return;
5589 }
5590 }
Geoff Langbfdea662014-07-23 14:16:32 -04005591 break;
Geoff Langb1196682014-07-23 13:47:29 -04005592
Geoff Langbfdea662014-07-23 14:16:32 -04005593 default:
Geoff Langb1196682014-07-23 13:47:29 -04005594 context->recordError(gl::Error(GL_INVALID_ENUM));
5595 return;
Geoff Langbfdea662014-07-23 14:16:32 -04005596 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005597 }
5598}
5599
Kenneth Russell67ea1902014-10-06 16:44:50 -07005600GLboolean GL_APIENTRY glUnmapBuffer(GLenum target)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005601{
5602 EVENT("(GLenum target = 0x%X)", target);
5603
Geoff Langbfdea662014-07-23 14:16:32 -04005604 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04005605 if (context)
5606 {
5607 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005608 {
Geoff Langb1196682014-07-23 13:47:29 -04005609 context->recordError(gl::Error(GL_INVALID_OPERATION));
5610 return GL_FALSE;
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00005611 }
Geoff Langbfdea662014-07-23 14:16:32 -04005612
5613 return glUnmapBufferOES(target);
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005614 }
5615
5616 return GL_FALSE;
5617}
5618
Kenneth Russell67ea1902014-10-06 16:44:50 -07005619void GL_APIENTRY glGetBufferPointerv(GLenum target, GLenum pname, GLvoid** params)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005620{
5621 EVENT("(GLenum target = 0x%X, GLenum pname = 0x%X, GLvoid** params = 0x%0.8p)", target, pname, params);
5622
Geoff Langbfdea662014-07-23 14:16:32 -04005623 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04005624 if (context)
5625 {
5626 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005627 {
Geoff Langb1196682014-07-23 13:47:29 -04005628 context->recordError(gl::Error(GL_INVALID_OPERATION));
5629 return;
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00005630 }
Geoff Langbfdea662014-07-23 14:16:32 -04005631
5632 glGetBufferPointervOES(target, pname, params);
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005633 }
5634}
5635
Kenneth Russell67ea1902014-10-06 16:44:50 -07005636void GL_APIENTRY glDrawBuffers(GLsizei n, const GLenum* bufs)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005637{
Geoff Langbfdea662014-07-23 14:16:32 -04005638 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04005639 if (context)
5640 {
5641 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005642 {
Geoff Langb1196682014-07-23 13:47:29 -04005643 context->recordError(gl::Error(GL_INVALID_OPERATION));
5644 return;
shannon.woods%transgaming.com@gtempaccount.com7948c5f2013-04-13 03:38:58 +00005645 }
Geoff Langbfdea662014-07-23 14:16:32 -04005646
5647 glDrawBuffersEXT(n, bufs);
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005648 }
5649}
5650
Kenneth Russell67ea1902014-10-06 16:44:50 -07005651void GL_APIENTRY glUniformMatrix2x3fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005652{
5653 EVENT("(GLint location = %d, GLsizei count = %d, GLboolean transpose = %u, const GLfloat* value = 0x%0.8p)",
5654 location, count, transpose, value);
5655
Geoff Langbfdea662014-07-23 14:16:32 -04005656 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04005657 if (context)
5658 {
5659 if (!ValidateUniformMatrix(context, GL_FLOAT_MAT2x3, location, count, transpose))
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005660 {
Geoff Langbfdea662014-07-23 14:16:32 -04005661 return;
shannon.woods%transgaming.com@gtempaccount.comf1306162013-04-13 03:40:04 +00005662 }
Geoff Langbfdea662014-07-23 14:16:32 -04005663
5664 gl::ProgramBinary *programBinary = context->getState().getCurrentProgramBinary();
5665 programBinary->setUniformMatrix2x3fv(location, count, transpose, value);
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005666 }
5667}
5668
Kenneth Russell67ea1902014-10-06 16:44:50 -07005669void GL_APIENTRY glUniformMatrix3x2fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005670{
5671 EVENT("(GLint location = %d, GLsizei count = %d, GLboolean transpose = %u, const GLfloat* value = 0x%0.8p)",
5672 location, count, transpose, value);
5673
Geoff Langbfdea662014-07-23 14:16:32 -04005674 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04005675 if (context)
5676 {
5677 if (!ValidateUniformMatrix(context, GL_FLOAT_MAT3x2, location, count, transpose))
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005678 {
Geoff Langbfdea662014-07-23 14:16:32 -04005679 return;
shannon.woods%transgaming.com@gtempaccount.comf1306162013-04-13 03:40:04 +00005680 }
Geoff Langbfdea662014-07-23 14:16:32 -04005681
5682 gl::ProgramBinary *programBinary = context->getState().getCurrentProgramBinary();
5683 programBinary->setUniformMatrix3x2fv(location, count, transpose, value);
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005684 }
5685}
5686
Kenneth Russell67ea1902014-10-06 16:44:50 -07005687void GL_APIENTRY glUniformMatrix2x4fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005688{
5689 EVENT("(GLint location = %d, GLsizei count = %d, GLboolean transpose = %u, const GLfloat* value = 0x%0.8p)",
5690 location, count, transpose, value);
5691
Geoff Langbfdea662014-07-23 14:16:32 -04005692 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04005693 if (context)
5694 {
5695 if (!ValidateUniformMatrix(context, GL_FLOAT_MAT2x4, location, count, transpose))
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005696 {
Geoff Langbfdea662014-07-23 14:16:32 -04005697 return;
shannon.woods%transgaming.com@gtempaccount.comf1306162013-04-13 03:40:04 +00005698 }
Geoff Langbfdea662014-07-23 14:16:32 -04005699
5700 gl::ProgramBinary *programBinary = context->getState().getCurrentProgramBinary();
5701 programBinary->setUniformMatrix2x4fv(location, count, transpose, value);
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005702 }
5703}
5704
Kenneth Russell67ea1902014-10-06 16:44:50 -07005705void GL_APIENTRY glUniformMatrix4x2fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005706{
5707 EVENT("(GLint location = %d, GLsizei count = %d, GLboolean transpose = %u, const GLfloat* value = 0x%0.8p)",
5708 location, count, transpose, value);
5709
Geoff Langbfdea662014-07-23 14:16:32 -04005710 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04005711 if (context)
5712 {
5713 if (!ValidateUniformMatrix(context, GL_FLOAT_MAT4x2, location, count, transpose))
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005714 {
Geoff Langbfdea662014-07-23 14:16:32 -04005715 return;
shannon.woods%transgaming.com@gtempaccount.comf1306162013-04-13 03:40:04 +00005716 }
Geoff Langbfdea662014-07-23 14:16:32 -04005717
5718 gl::ProgramBinary *programBinary = context->getState().getCurrentProgramBinary();
5719 programBinary->setUniformMatrix4x2fv(location, count, transpose, value);
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005720 }
5721}
5722
Kenneth Russell67ea1902014-10-06 16:44:50 -07005723void GL_APIENTRY glUniformMatrix3x4fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005724{
5725 EVENT("(GLint location = %d, GLsizei count = %d, GLboolean transpose = %u, const GLfloat* value = 0x%0.8p)",
5726 location, count, transpose, value);
5727
Geoff Langbfdea662014-07-23 14:16:32 -04005728 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04005729 if (context)
5730 {
5731 if (!ValidateUniformMatrix(context, GL_FLOAT_MAT3x4, location, count, transpose))
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005732 {
Geoff Langbfdea662014-07-23 14:16:32 -04005733 return;
shannon.woods%transgaming.com@gtempaccount.comf1306162013-04-13 03:40:04 +00005734 }
Geoff Langbfdea662014-07-23 14:16:32 -04005735
5736 gl::ProgramBinary *programBinary = context->getState().getCurrentProgramBinary();
5737 programBinary->setUniformMatrix3x4fv(location, count, transpose, value);
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005738 }
5739}
5740
Kenneth Russell67ea1902014-10-06 16:44:50 -07005741void GL_APIENTRY glUniformMatrix4x3fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005742{
5743 EVENT("(GLint location = %d, GLsizei count = %d, GLboolean transpose = %u, const GLfloat* value = 0x%0.8p)",
5744 location, count, transpose, value);
5745
Geoff Langbfdea662014-07-23 14:16:32 -04005746 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04005747 if (context)
5748 {
5749 if (!ValidateUniformMatrix(context, GL_FLOAT_MAT4x3, location, count, transpose))
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005750 {
Geoff Langbfdea662014-07-23 14:16:32 -04005751 return;
shannon.woods%transgaming.com@gtempaccount.comf1306162013-04-13 03:40:04 +00005752 }
Geoff Langbfdea662014-07-23 14:16:32 -04005753
5754 gl::ProgramBinary *programBinary = context->getState().getCurrentProgramBinary();
5755 programBinary->setUniformMatrix4x3fv(location, count, transpose, value);
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005756 }
5757}
5758
Kenneth Russell67ea1902014-10-06 16:44:50 -07005759void 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 +00005760{
5761 EVENT("(GLint srcX0 = %d, GLint srcY0 = %d, GLint srcX1 = %d, GLint srcY1 = %d, GLint dstX0 = %d, "
5762 "GLint dstY0 = %d, GLint dstX1 = %d, GLint dstY1 = %d, GLbitfield mask = 0x%X, GLenum filter = 0x%X)",
5763 srcX0, srcY0, srcX1, srcY1, dstX0, dstY0, dstX1, dstY1, mask, filter);
5764
Geoff Langbfdea662014-07-23 14:16:32 -04005765 gl::Context *context = gl::getNonLostContext();
5766 if (context)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005767 {
Geoff Langbfdea662014-07-23 14:16:32 -04005768 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005769 {
Geoff Langb1196682014-07-23 13:47:29 -04005770 context->recordError(gl::Error(GL_INVALID_OPERATION));
5771 return;
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00005772 }
Geoff Langbfdea662014-07-23 14:16:32 -04005773
5774 if (!ValidateBlitFramebufferParameters(context, srcX0, srcY0, srcX1, srcY1,
5775 dstX0, dstY0, dstX1, dstY1, mask, filter,
5776 false))
5777 {
5778 return;
5779 }
5780
Geoff Lang64839152014-08-26 16:23:25 -04005781 gl::Error error = context->blitFramebuffer(srcX0, srcY0, srcX1, srcY1, dstX0, dstY0, dstX1, dstY1,
5782 mask, filter);
5783 if (error.isError())
5784 {
5785 context->recordError(error);
5786 return;
5787 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005788 }
5789}
5790
Kenneth Russell67ea1902014-10-06 16:44:50 -07005791void GL_APIENTRY glRenderbufferStorageMultisample(GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005792{
5793 EVENT("(GLenum target = 0x%X, GLsizei samples = %d, GLenum internalformat = 0x%X, GLsizei width = %d, GLsizei height = %d)",
5794 target, samples, internalformat, width, height);
5795
Geoff Langbfdea662014-07-23 14:16:32 -04005796 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04005797 if (context)
5798 {
5799 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005800 {
Geoff Langb1196682014-07-23 13:47:29 -04005801 context->recordError(gl::Error(GL_INVALID_OPERATION));
5802 return;
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00005803 }
Geoff Langbfdea662014-07-23 14:16:32 -04005804
Corentin Walleze0902642014-11-04 12:32:15 -08005805 if (!ValidateES3RenderbufferStorageParameters(context, target, samples, internalformat, width, height))
Geoff Langbfdea662014-07-23 14:16:32 -04005806 {
5807 return;
5808 }
5809
Shannon Woodse2632d22014-10-17 13:08:51 -04005810 gl::Renderbuffer *renderbuffer = context->getState().getCurrentRenderbuffer();
5811 renderbuffer->setStorage(width, height, internalformat, samples);
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005812 }
5813}
5814
Kenneth Russell67ea1902014-10-06 16:44:50 -07005815void GL_APIENTRY glFramebufferTextureLayer(GLenum target, GLenum attachment, GLuint texture, GLint level, GLint layer)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005816{
5817 EVENT("(GLenum target = 0x%X, GLenum attachment = 0x%X, GLuint texture = %u, GLint level = %d, GLint layer = %d)",
5818 target, attachment, texture, level, layer);
5819
Geoff Langbfdea662014-07-23 14:16:32 -04005820 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04005821 if (context)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005822 {
Geoff Langbfdea662014-07-23 14:16:32 -04005823 if (!ValidateFramebufferTextureLayer(context, target, attachment, texture,
5824 level, layer))
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005825 {
Geoff Langbfdea662014-07-23 14:16:32 -04005826 return;
5827 }
Geoff Lang3ed0c482013-07-25 17:03:18 -04005828
Geoff Langbfdea662014-07-23 14:16:32 -04005829 gl::Framebuffer *framebuffer = context->getState().getTargetFramebuffer(target);
5830 ASSERT(framebuffer);
Geoff Lang3ed0c482013-07-25 17:03:18 -04005831
Geoff Langab75a052014-10-15 12:56:37 -04005832 if (texture != 0)
Geoff Langbfdea662014-07-23 14:16:32 -04005833 {
Geoff Langab75a052014-10-15 12:56:37 -04005834 gl::Texture *textureObject = context->getTexture(texture);
5835 gl::ImageIndex index(textureObject->getTarget(), level, layer);
5836 framebuffer->setTextureAttachment(attachment, textureObject, index);
Geoff Langbfdea662014-07-23 14:16:32 -04005837 }
5838 else
5839 {
Geoff Langab75a052014-10-15 12:56:37 -04005840 framebuffer->setNULLAttachment(attachment);
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00005841 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005842 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005843}
5844
Kenneth Russell67ea1902014-10-06 16:44:50 -07005845GLvoid* GL_APIENTRY glMapBufferRange(GLenum target, GLintptr offset, GLsizeiptr length, GLbitfield access)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005846{
5847 EVENT("(GLenum target = 0x%X, GLintptr offset = %d, GLsizeiptr length = %d, GLbitfield access = 0x%X)",
5848 target, offset, length, access);
5849
Geoff Langbfdea662014-07-23 14:16:32 -04005850 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04005851 if (context)
5852 {
5853 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005854 {
Geoff Langb1196682014-07-23 13:47:29 -04005855 context->recordError(gl::Error(GL_INVALID_OPERATION));
5856 return NULL;
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00005857 }
Geoff Langbfdea662014-07-23 14:16:32 -04005858
5859 return glMapBufferRangeEXT(target, offset, length, access);
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005860 }
5861
5862 return NULL;
5863}
5864
Kenneth Russell67ea1902014-10-06 16:44:50 -07005865void GL_APIENTRY glFlushMappedBufferRange(GLenum target, GLintptr offset, GLsizeiptr length)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005866{
5867 EVENT("(GLenum target = 0x%X, GLintptr offset = %d, GLsizeiptr length = %d)", target, offset, length);
5868
Geoff Langbfdea662014-07-23 14:16:32 -04005869 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04005870 if (context)
5871 {
5872 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005873 {
Geoff Langb1196682014-07-23 13:47:29 -04005874 context->recordError(gl::Error(GL_INVALID_OPERATION));
5875 return;
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00005876 }
Geoff Langbfdea662014-07-23 14:16:32 -04005877
5878 glFlushMappedBufferRangeEXT(target, offset, length);
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005879 }
5880}
5881
Kenneth Russell67ea1902014-10-06 16:44:50 -07005882void GL_APIENTRY glBindVertexArray(GLuint array)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005883{
5884 EVENT("(GLuint array = %u)", array);
5885
Geoff Langbfdea662014-07-23 14:16:32 -04005886 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04005887 if (context)
5888 {
5889 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005890 {
Geoff Langb1196682014-07-23 13:47:29 -04005891 context->recordError(gl::Error(GL_INVALID_OPERATION));
5892 return;
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00005893 }
Geoff Langbfdea662014-07-23 14:16:32 -04005894
5895 gl::VertexArray *vao = context->getVertexArray(array);
5896
5897 if (!vao)
5898 {
5899 // The default VAO should always exist
5900 ASSERT(array != 0);
Geoff Langb1196682014-07-23 13:47:29 -04005901 context->recordError(gl::Error(GL_INVALID_OPERATION));
5902 return;
Geoff Langbfdea662014-07-23 14:16:32 -04005903 }
5904
5905 context->bindVertexArray(array);
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005906 }
5907}
5908
Kenneth Russell67ea1902014-10-06 16:44:50 -07005909void GL_APIENTRY glDeleteVertexArrays(GLsizei n, const GLuint* arrays)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005910{
5911 EVENT("(GLsizei n = %d, const GLuint* arrays = 0x%0.8p)", n, arrays);
5912
Geoff Langbfdea662014-07-23 14:16:32 -04005913 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04005914 if (context)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005915 {
Geoff Langbfdea662014-07-23 14:16:32 -04005916 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005917 {
Geoff Langb1196682014-07-23 13:47:29 -04005918 context->recordError(gl::Error(GL_INVALID_OPERATION));
5919 return;
Geoff Langbfdea662014-07-23 14:16:32 -04005920 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005921
Geoff Langbfdea662014-07-23 14:16:32 -04005922 if (n < 0)
5923 {
Geoff Langb1196682014-07-23 13:47:29 -04005924 context->recordError(gl::Error(GL_INVALID_VALUE));
5925 return;
Geoff Langbfdea662014-07-23 14:16:32 -04005926 }
Jamie Madilld1028542013-07-02 11:57:04 -04005927
Geoff Langbfdea662014-07-23 14:16:32 -04005928 for (int arrayIndex = 0; arrayIndex < n; arrayIndex++)
5929 {
5930 if (arrays[arrayIndex] != 0)
Jamie Madilld1028542013-07-02 11:57:04 -04005931 {
Geoff Langbfdea662014-07-23 14:16:32 -04005932 context->deleteVertexArray(arrays[arrayIndex]);
Jamie Madilld1028542013-07-02 11:57:04 -04005933 }
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00005934 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005935 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005936}
5937
Kenneth Russell67ea1902014-10-06 16:44:50 -07005938void GL_APIENTRY glGenVertexArrays(GLsizei n, GLuint* arrays)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005939{
5940 EVENT("(GLsizei n = %d, GLuint* arrays = 0x%0.8p)", n, arrays);
5941
Geoff Langbfdea662014-07-23 14:16:32 -04005942 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04005943 if (context)
5944 {
5945 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005946 {
Geoff Langb1196682014-07-23 13:47:29 -04005947 context->recordError(gl::Error(GL_INVALID_OPERATION));
5948 return;
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00005949 }
Geoff Langbfdea662014-07-23 14:16:32 -04005950
5951 if (n < 0)
5952 {
Geoff Langb1196682014-07-23 13:47:29 -04005953 context->recordError(gl::Error(GL_INVALID_VALUE));
5954 return;
Geoff Langbfdea662014-07-23 14:16:32 -04005955 }
5956
5957 for (int arrayIndex = 0; arrayIndex < n; arrayIndex++)
5958 {
5959 arrays[arrayIndex] = context->createVertexArray();
5960 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005961 }
5962}
5963
Kenneth Russell67ea1902014-10-06 16:44:50 -07005964GLboolean GL_APIENTRY glIsVertexArray(GLuint array)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005965{
5966 EVENT("(GLuint array = %u)", array);
5967
Geoff Langbfdea662014-07-23 14:16:32 -04005968 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04005969 if (context)
5970 {
5971 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005972 {
Geoff Langb1196682014-07-23 13:47:29 -04005973 context->recordError(gl::Error(GL_INVALID_OPERATION));
5974 return GL_FALSE;
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00005975 }
Geoff Langbfdea662014-07-23 14:16:32 -04005976
5977 if (array == 0)
5978 {
5979 return GL_FALSE;
5980 }
5981
5982 gl::VertexArray *vao = context->getVertexArray(array);
5983
5984 return (vao != NULL ? GL_TRUE : GL_FALSE);
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005985 }
5986
5987 return GL_FALSE;
5988}
5989
Kenneth Russell67ea1902014-10-06 16:44:50 -07005990void GL_APIENTRY glGetIntegeri_v(GLenum target, GLuint index, GLint* data)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005991{
5992 EVENT("(GLenum target = 0x%X, GLuint index = %u, GLint* data = 0x%0.8p)",
5993 target, index, data);
5994
Geoff Langbfdea662014-07-23 14:16:32 -04005995 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04005996 if (context)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005997 {
Geoff Langbfdea662014-07-23 14:16:32 -04005998 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005999 {
Geoff Langb1196682014-07-23 13:47:29 -04006000 context->recordError(gl::Error(GL_INVALID_OPERATION));
6001 return;
Geoff Langbfdea662014-07-23 14:16:32 -04006002 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006003
Geoff Lang3a61c322014-07-10 13:01:54 -04006004 const gl::Caps &caps = context->getCaps();
Geoff Langbfdea662014-07-23 14:16:32 -04006005 switch (target)
6006 {
6007 case GL_TRANSFORM_FEEDBACK_BUFFER_START:
6008 case GL_TRANSFORM_FEEDBACK_BUFFER_SIZE:
6009 case GL_TRANSFORM_FEEDBACK_BUFFER_BINDING:
Geoff Lang05881a02014-07-10 14:05:30 -04006010 if (index >= caps.maxTransformFeedbackSeparateAttributes)
6011 {
Geoff Langb1196682014-07-23 13:47:29 -04006012 context->recordError(gl::Error(GL_INVALID_VALUE));
6013 return;
Geoff Lang05881a02014-07-10 14:05:30 -04006014 }
Geoff Langbfdea662014-07-23 14:16:32 -04006015 break;
Geoff Langb1196682014-07-23 13:47:29 -04006016
Geoff Langbfdea662014-07-23 14:16:32 -04006017 case GL_UNIFORM_BUFFER_START:
6018 case GL_UNIFORM_BUFFER_SIZE:
6019 case GL_UNIFORM_BUFFER_BINDING:
Geoff Lang3a61c322014-07-10 13:01:54 -04006020 if (index >= caps.maxCombinedUniformBlocks)
6021 {
Geoff Langb1196682014-07-23 13:47:29 -04006022 context->recordError(gl::Error(GL_INVALID_VALUE));
6023 return;
Geoff Lang3a61c322014-07-10 13:01:54 -04006024 }
Geoff Langbfdea662014-07-23 14:16:32 -04006025 break;
Geoff Langb1196682014-07-23 13:47:29 -04006026
Geoff Langbfdea662014-07-23 14:16:32 -04006027 default:
Geoff Langb1196682014-07-23 13:47:29 -04006028 context->recordError(gl::Error(GL_INVALID_ENUM));
6029 return;
Geoff Langbfdea662014-07-23 14:16:32 -04006030 }
6031
6032 if (!(context->getIndexedIntegerv(target, index, data)))
6033 {
6034 GLenum nativeType;
6035 unsigned int numParams = 0;
6036 if (!context->getIndexedQueryParameterInfo(target, &nativeType, &numParams))
Geoff Langb1196682014-07-23 13:47:29 -04006037 {
6038 context->recordError(gl::Error(GL_INVALID_ENUM));
6039 return;
6040 }
Shannon Woods15934d52013-08-19 14:28:49 -04006041
Geoff Langbfdea662014-07-23 14:16:32 -04006042 if (numParams == 0)
Geoff Langb1196682014-07-23 13:47:29 -04006043 {
Geoff Langbfdea662014-07-23 14:16:32 -04006044 return; // it is known that pname is valid, but there are no parameters to return
Geoff Langb1196682014-07-23 13:47:29 -04006045 }
Geoff Langbfdea662014-07-23 14:16:32 -04006046
6047 if (nativeType == GL_INT_64_ANGLEX)
Shannon Woods15934d52013-08-19 14:28:49 -04006048 {
Geoff Langbfdea662014-07-23 14:16:32 -04006049 GLint64 minIntValue = static_cast<GLint64>(std::numeric_limits<int>::min());
6050 GLint64 maxIntValue = static_cast<GLint64>(std::numeric_limits<int>::max());
6051 GLint64 *int64Params = new GLint64[numParams];
Shannon Woods15934d52013-08-19 14:28:49 -04006052
Geoff Langbfdea662014-07-23 14:16:32 -04006053 context->getIndexedInteger64v(target, index, int64Params);
Shannon Woods15934d52013-08-19 14:28:49 -04006054
Geoff Langbfdea662014-07-23 14:16:32 -04006055 for (unsigned int i = 0; i < numParams; ++i)
Shannon Woods15934d52013-08-19 14:28:49 -04006056 {
Geoff Langbfdea662014-07-23 14:16:32 -04006057 GLint64 clampedValue = std::max(std::min(int64Params[i], maxIntValue), minIntValue);
6058 data[i] = static_cast<GLint>(clampedValue);
Shannon Woods15934d52013-08-19 14:28:49 -04006059 }
Geoff Langbfdea662014-07-23 14:16:32 -04006060
6061 delete [] int64Params;
6062 }
6063 else
6064 {
6065 UNREACHABLE();
Shannon Woods15934d52013-08-19 14:28:49 -04006066 }
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00006067 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006068 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006069}
6070
Kenneth Russell67ea1902014-10-06 16:44:50 -07006071void GL_APIENTRY glBeginTransformFeedback(GLenum primitiveMode)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006072{
6073 EVENT("(GLenum primitiveMode = 0x%X)", primitiveMode);
6074
Geoff Langbfdea662014-07-23 14:16:32 -04006075 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04006076 if (context)
6077 {
6078 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006079 {
Geoff Langb1196682014-07-23 13:47:29 -04006080 context->recordError(gl::Error(GL_INVALID_OPERATION));
6081 return;
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00006082 }
Geoff Langbfdea662014-07-23 14:16:32 -04006083
6084 switch (primitiveMode)
6085 {
6086 case GL_TRIANGLES:
6087 case GL_LINES:
6088 case GL_POINTS:
6089 break;
Geoff Langb1196682014-07-23 13:47:29 -04006090
Geoff Langbfdea662014-07-23 14:16:32 -04006091 default:
Geoff Langb1196682014-07-23 13:47:29 -04006092 context->recordError(gl::Error(GL_INVALID_ENUM));
6093 return;
Geoff Langbfdea662014-07-23 14:16:32 -04006094 }
6095
6096 gl::TransformFeedback *transformFeedback = context->getState().getCurrentTransformFeedback();
6097 ASSERT(transformFeedback != NULL);
6098
6099 if (transformFeedback->isStarted())
6100 {
Geoff Langb1196682014-07-23 13:47:29 -04006101 context->recordError(gl::Error(GL_INVALID_OPERATION));
6102 return;
Geoff Langbfdea662014-07-23 14:16:32 -04006103 }
6104
6105 if (transformFeedback->isPaused())
6106 {
6107 transformFeedback->resume();
6108 }
6109 else
6110 {
6111 transformFeedback->start(primitiveMode);
6112 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006113 }
6114}
6115
Kenneth Russell67ea1902014-10-06 16:44:50 -07006116void GL_APIENTRY glEndTransformFeedback(void)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006117{
6118 EVENT("(void)");
6119
Geoff Langbfdea662014-07-23 14:16:32 -04006120 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04006121 if (context)
6122 {
6123 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006124 {
Geoff Langb1196682014-07-23 13:47:29 -04006125 context->recordError(gl::Error(GL_INVALID_OPERATION));
6126 return;
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00006127 }
Geoff Langbfdea662014-07-23 14:16:32 -04006128
6129 gl::TransformFeedback *transformFeedback = context->getState().getCurrentTransformFeedback();
6130 ASSERT(transformFeedback != NULL);
6131
6132 if (!transformFeedback->isStarted())
6133 {
Geoff Langb1196682014-07-23 13:47:29 -04006134 context->recordError(gl::Error(GL_INVALID_OPERATION));
6135 return;
Geoff Langbfdea662014-07-23 14:16:32 -04006136 }
6137
6138 transformFeedback->stop();
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006139 }
6140}
6141
Kenneth Russell67ea1902014-10-06 16:44:50 -07006142void GL_APIENTRY glBindBufferRange(GLenum target, GLuint index, GLuint buffer, GLintptr offset, GLsizeiptr size)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006143{
6144 EVENT("(GLenum target = 0x%X, GLuint index = %u, GLuint buffer = %u, GLintptr offset = %d, GLsizeiptr size = %d)",
6145 target, index, buffer, offset, size);
6146
Geoff Langbfdea662014-07-23 14:16:32 -04006147 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04006148 if (context)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006149 {
Geoff Langbfdea662014-07-23 14:16:32 -04006150 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006151 {
Geoff Langb1196682014-07-23 13:47:29 -04006152 context->recordError(gl::Error(GL_INVALID_OPERATION));
6153 return;
Geoff Langbfdea662014-07-23 14:16:32 -04006154 }
6155
Geoff Lang3a61c322014-07-10 13:01:54 -04006156 const gl::Caps &caps = context->getCaps();
Geoff Langbfdea662014-07-23 14:16:32 -04006157 switch (target)
6158 {
6159 case GL_TRANSFORM_FEEDBACK_BUFFER:
Geoff Lang05881a02014-07-10 14:05:30 -04006160 if (index >= caps.maxTransformFeedbackSeparateAttributes)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006161 {
Geoff Langb1196682014-07-23 13:47:29 -04006162 context->recordError(gl::Error(GL_INVALID_VALUE));
6163 return;
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006164 }
Geoff Langbfdea662014-07-23 14:16:32 -04006165 break;
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006166
Geoff Langbfdea662014-07-23 14:16:32 -04006167 case GL_UNIFORM_BUFFER:
Geoff Lang3a61c322014-07-10 13:01:54 -04006168 if (index >= caps.maxUniformBufferBindings)
shannon.woods%transgaming.com@gtempaccount.comd4e61972013-04-13 03:37:04 +00006169 {
Geoff Langb1196682014-07-23 13:47:29 -04006170 context->recordError(gl::Error(GL_INVALID_VALUE));
6171 return;
shannon.woods%transgaming.com@gtempaccount.comd4e61972013-04-13 03:37:04 +00006172 }
Geoff Langbfdea662014-07-23 14:16:32 -04006173 break;
shannon.woods%transgaming.com@gtempaccount.comd4e61972013-04-13 03:37:04 +00006174
Geoff Langbfdea662014-07-23 14:16:32 -04006175 default:
Geoff Langb1196682014-07-23 13:47:29 -04006176 context->recordError(gl::Error(GL_INVALID_ENUM));
6177 return;
Geoff Langbfdea662014-07-23 14:16:32 -04006178 }
6179
6180 if (buffer != 0 && size <= 0)
6181 {
Geoff Langb1196682014-07-23 13:47:29 -04006182 context->recordError(gl::Error(GL_INVALID_VALUE));
6183 return;
Geoff Langbfdea662014-07-23 14:16:32 -04006184 }
6185
6186 switch (target)
6187 {
6188 case GL_TRANSFORM_FEEDBACK_BUFFER:
6189
6190 // size and offset must be a multiple of 4
6191 if (buffer != 0 && ((offset % 4) != 0 || (size % 4) != 0))
shannon.woods%transgaming.com@gtempaccount.comd4e61972013-04-13 03:37:04 +00006192 {
Geoff Langb1196682014-07-23 13:47:29 -04006193 context->recordError(gl::Error(GL_INVALID_VALUE));
6194 return;
shannon.woods%transgaming.com@gtempaccount.comd4e61972013-04-13 03:37:04 +00006195 }
6196
Geoff Langbfdea662014-07-23 14:16:32 -04006197 context->bindIndexedTransformFeedbackBuffer(buffer, index, offset, size);
6198 context->bindGenericTransformFeedbackBuffer(buffer);
6199 break;
6200
6201 case GL_UNIFORM_BUFFER:
6202
6203 // it is an error to bind an offset not a multiple of the alignment
Geoff Lang3a61c322014-07-10 13:01:54 -04006204 if (buffer != 0 && (offset % caps.uniformBufferOffsetAlignment) != 0)
shannon.woods%transgaming.com@gtempaccount.comd4e61972013-04-13 03:37:04 +00006205 {
Geoff Langb1196682014-07-23 13:47:29 -04006206 context->recordError(gl::Error(GL_INVALID_VALUE));
6207 return;
shannon.woods%transgaming.com@gtempaccount.comd4e61972013-04-13 03:37:04 +00006208 }
Geoff Langbfdea662014-07-23 14:16:32 -04006209
6210 context->bindIndexedUniformBuffer(buffer, index, offset, size);
6211 context->bindGenericUniformBuffer(buffer);
6212 break;
6213
6214 default:
6215 UNREACHABLE();
shannon.woods%transgaming.com@gtempaccount.comd4e61972013-04-13 03:37:04 +00006216 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006217 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006218}
6219
Kenneth Russell67ea1902014-10-06 16:44:50 -07006220void GL_APIENTRY glBindBufferBase(GLenum target, GLuint index, GLuint buffer)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006221{
6222 EVENT("(GLenum target = 0x%X, GLuint index = %u, GLuint buffer = %u)",
6223 target, index, buffer);
6224
Geoff Langbfdea662014-07-23 14:16:32 -04006225 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04006226 if (context)
6227 {
6228 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006229 {
Geoff Langb1196682014-07-23 13:47:29 -04006230 context->recordError(gl::Error(GL_INVALID_OPERATION));
6231 return;
shannon.woods%transgaming.com@gtempaccount.comd4e61972013-04-13 03:37:04 +00006232 }
Geoff Langbfdea662014-07-23 14:16:32 -04006233
Geoff Lang3a61c322014-07-10 13:01:54 -04006234 const gl::Caps &caps = context->getCaps();
Geoff Langbfdea662014-07-23 14:16:32 -04006235 switch (target)
6236 {
6237 case GL_TRANSFORM_FEEDBACK_BUFFER:
Geoff Lang05881a02014-07-10 14:05:30 -04006238 if (index >= caps.maxTransformFeedbackSeparateAttributes)
Geoff Langbfdea662014-07-23 14:16:32 -04006239 {
Geoff Langb1196682014-07-23 13:47:29 -04006240 context->recordError(gl::Error(GL_INVALID_VALUE));
6241 return;
Geoff Langbfdea662014-07-23 14:16:32 -04006242 }
6243 break;
6244
6245 case GL_UNIFORM_BUFFER:
Geoff Lang3a61c322014-07-10 13:01:54 -04006246 if (index >= caps.maxUniformBufferBindings)
Geoff Langbfdea662014-07-23 14:16:32 -04006247 {
Geoff Langb1196682014-07-23 13:47:29 -04006248 context->recordError(gl::Error(GL_INVALID_VALUE));
6249 return;
Geoff Langbfdea662014-07-23 14:16:32 -04006250 }
6251 break;
6252
6253 default:
Geoff Langb1196682014-07-23 13:47:29 -04006254 context->recordError(gl::Error(GL_INVALID_ENUM));
6255 return;
Geoff Langbfdea662014-07-23 14:16:32 -04006256 }
6257
6258 switch (target)
6259 {
6260 case GL_TRANSFORM_FEEDBACK_BUFFER:
6261 context->bindIndexedTransformFeedbackBuffer(buffer, index, 0, 0);
6262 context->bindGenericTransformFeedbackBuffer(buffer);
6263 break;
6264
6265 case GL_UNIFORM_BUFFER:
6266 context->bindIndexedUniformBuffer(buffer, index, 0, 0);
6267 context->bindGenericUniformBuffer(buffer);
6268 break;
6269
6270 default:
6271 UNREACHABLE();
6272 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006273 }
6274}
6275
Kenneth Russell67ea1902014-10-06 16:44:50 -07006276void GL_APIENTRY glTransformFeedbackVaryings(GLuint program, GLsizei count, const GLchar* const* varyings, GLenum bufferMode)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006277{
6278 EVENT("(GLuint program = %u, GLsizei count = %d, const GLchar* const* varyings = 0x%0.8p, GLenum bufferMode = 0x%X)",
6279 program, count, varyings, bufferMode);
6280
Geoff Langbfdea662014-07-23 14:16:32 -04006281 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04006282 if (context)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006283 {
Geoff Langbfdea662014-07-23 14:16:32 -04006284 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006285 {
Geoff Langb1196682014-07-23 13:47:29 -04006286 context->recordError(gl::Error(GL_INVALID_OPERATION));
6287 return;
Geoff Langbfdea662014-07-23 14:16:32 -04006288 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006289
Geoff Langbfdea662014-07-23 14:16:32 -04006290 if (count < 0)
6291 {
Geoff Langb1196682014-07-23 13:47:29 -04006292 context->recordError(gl::Error(GL_INVALID_VALUE));
6293 return;
Geoff Langbfdea662014-07-23 14:16:32 -04006294 }
6295
Geoff Lang05881a02014-07-10 14:05:30 -04006296 const gl::Caps &caps = context->getCaps();
Geoff Langbfdea662014-07-23 14:16:32 -04006297 switch (bufferMode)
6298 {
6299 case GL_INTERLEAVED_ATTRIBS:
6300 break;
6301 case GL_SEPARATE_ATTRIBS:
Geoff Lang05881a02014-07-10 14:05:30 -04006302 if (static_cast<GLuint>(count) > caps.maxTransformFeedbackSeparateAttributes)
Geoff Lang48dcae72014-02-05 16:28:24 -05006303 {
Geoff Langb1196682014-07-23 13:47:29 -04006304 context->recordError(gl::Error(GL_INVALID_VALUE));
6305 return;
Geoff Lang48dcae72014-02-05 16:28:24 -05006306 }
Geoff Langbfdea662014-07-23 14:16:32 -04006307 break;
6308 default:
Geoff Langb1196682014-07-23 13:47:29 -04006309 context->recordError(gl::Error(GL_INVALID_ENUM));
6310 return;
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00006311 }
Geoff Langbfdea662014-07-23 14:16:32 -04006312
6313 if (!gl::ValidProgram(context, program))
6314 {
6315 return;
6316 }
6317
6318 gl::Program *programObject = context->getProgram(program);
6319 ASSERT(programObject);
6320
6321 programObject->setTransformFeedbackVaryings(count, varyings, bufferMode);
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006322 }
6323}
6324
Kenneth Russell67ea1902014-10-06 16:44:50 -07006325void 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 +00006326{
6327 EVENT("(GLuint program = %u, GLuint index = %u, GLsizei bufSize = %d, GLsizei* length = 0x%0.8p, "
6328 "GLsizei* size = 0x%0.8p, GLenum* type = 0x%0.8p, GLchar* name = 0x%0.8p)",
6329 program, index, bufSize, length, size, type, name);
6330
Geoff Langbfdea662014-07-23 14:16:32 -04006331 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04006332 if (context)
6333 {
6334 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006335 {
Geoff Langb1196682014-07-23 13:47:29 -04006336 context->recordError(gl::Error(GL_INVALID_OPERATION));
6337 return;
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00006338 }
Geoff Langbfdea662014-07-23 14:16:32 -04006339
6340 if (bufSize < 0)
6341 {
Geoff Langb1196682014-07-23 13:47:29 -04006342 context->recordError(gl::Error(GL_INVALID_VALUE));
6343 return;
Geoff Langbfdea662014-07-23 14:16:32 -04006344 }
6345
6346 if (!gl::ValidProgram(context, program))
6347 {
6348 return;
6349 }
6350
6351 gl::Program *programObject = context->getProgram(program);
6352 ASSERT(programObject);
6353
6354 if (index >= static_cast<GLuint>(programObject->getTransformFeedbackVaryingCount()))
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 programObject->getTransformFeedbackVarying(index, bufSize, length, size, type, name);
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006361 }
6362}
6363
Kenneth Russell67ea1902014-10-06 16:44:50 -07006364void 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 +00006365{
6366 EVENT("(GLuint index = %u, GLint size = %d, GLenum type = 0x%X, GLsizei stride = %d, const GLvoid* pointer = 0x%0.8p)",
6367 index, size, type, stride, pointer);
6368
Geoff Langbfdea662014-07-23 14:16:32 -04006369 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04006370 if (context)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006371 {
Geoff Langbfdea662014-07-23 14:16:32 -04006372 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006373 {
Geoff Langb1196682014-07-23 13:47:29 -04006374 context->recordError(gl::Error(GL_INVALID_OPERATION));
6375 return;
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006376 }
6377
Geoff Langb1196682014-07-23 13:47:29 -04006378 if (index >= gl::MAX_VERTEX_ATTRIBS)
6379 {
6380 context->recordError(gl::Error(GL_INVALID_VALUE));
6381 return;
6382 }
shannon.woods%transgaming.com@gtempaccount.coma8885862013-04-13 03:37:53 +00006383
Geoff Langb1196682014-07-23 13:47:29 -04006384 if (size < 1 || size > 4)
6385 {
6386 context->recordError(gl::Error(GL_INVALID_VALUE));
6387 return;
6388 }
shannon.woods%transgaming.com@gtempaccount.coma8885862013-04-13 03:37:53 +00006389
Geoff Langb1196682014-07-23 13:47:29 -04006390 switch (type)
6391 {
6392 case GL_BYTE:
6393 case GL_UNSIGNED_BYTE:
6394 case GL_SHORT:
6395 case GL_UNSIGNED_SHORT:
6396 case GL_INT:
6397 case GL_UNSIGNED_INT:
6398 case GL_INT_2_10_10_10_REV:
6399 case GL_UNSIGNED_INT_2_10_10_10_REV:
6400 break;
shannon.woods%transgaming.com@gtempaccount.coma8885862013-04-13 03:37:53 +00006401
Geoff Langb1196682014-07-23 13:47:29 -04006402 default:
6403 context->recordError(gl::Error(GL_INVALID_ENUM));
6404 return;
6405 }
shannon.woods%transgaming.com@gtempaccount.coma8885862013-04-13 03:37:53 +00006406
Geoff Langb1196682014-07-23 13:47:29 -04006407 if (stride < 0)
6408 {
6409 context->recordError(gl::Error(GL_INVALID_VALUE));
6410 return;
6411 }
Geoff Langbfdea662014-07-23 14:16:32 -04006412
Geoff Langb1196682014-07-23 13:47:29 -04006413 if ((type == GL_INT_2_10_10_10_REV || type == GL_UNSIGNED_INT_2_10_10_10_REV) && size != 4)
6414 {
6415 context->recordError(gl::Error(GL_INVALID_OPERATION));
6416 return;
6417 }
6418
Geoff Langbfdea662014-07-23 14:16:32 -04006419 // [OpenGL ES 3.0.2] Section 2.8 page 24:
6420 // An INVALID_OPERATION error is generated when a non-zero vertex array object
6421 // is bound, zero is bound to the ARRAY_BUFFER buffer object binding point,
6422 // and the pointer argument is not NULL.
6423 if (context->getState().getVertexArray()->id() != 0 && context->getState().getArrayBufferId() == 0 && pointer != NULL)
shannon.woods%transgaming.com@gtempaccount.com1ab57be2013-04-13 03:38:39 +00006424 {
Geoff Langb1196682014-07-23 13:47:29 -04006425 context->recordError(gl::Error(GL_INVALID_OPERATION));
6426 return;
shannon.woods%transgaming.com@gtempaccount.com1ab57be2013-04-13 03:38:39 +00006427 }
6428
Geoff Langbfdea662014-07-23 14:16:32 -04006429 context->getState().setVertexAttribState(index, context->getState().getTargetBuffer(GL_ARRAY_BUFFER), size, type, false, true,
6430 stride, pointer);
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006431 }
6432}
6433
Kenneth Russell67ea1902014-10-06 16:44:50 -07006434void GL_APIENTRY glGetVertexAttribIiv(GLuint index, GLenum pname, GLint* params)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006435{
6436 EVENT("(GLuint index = %u, GLenum pname = 0x%X, GLint* params = 0x%0.8p)",
6437 index, pname, params);
6438
Geoff Langbfdea662014-07-23 14:16:32 -04006439 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04006440 if (context)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006441 {
Geoff Langbfdea662014-07-23 14:16:32 -04006442 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006443 {
Geoff Langb1196682014-07-23 13:47:29 -04006444 context->recordError(gl::Error(GL_INVALID_OPERATION));
6445 return;
Geoff Langbfdea662014-07-23 14:16:32 -04006446 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006447
Geoff Langbfdea662014-07-23 14:16:32 -04006448 if (index >= gl::MAX_VERTEX_ATTRIBS)
6449 {
Geoff Langb1196682014-07-23 13:47:29 -04006450 context->recordError(gl::Error(GL_INVALID_VALUE));
6451 return;
Geoff Langbfdea662014-07-23 14:16:32 -04006452 }
Jamie Madilla7d05862013-07-02 11:57:06 -04006453
Geoff Langbfdea662014-07-23 14:16:32 -04006454 const gl::VertexAttribute &attribState = context->getState().getVertexAttribState(index);
Jamie Madilla7d05862013-07-02 11:57:06 -04006455
Geoff Langb1196682014-07-23 13:47:29 -04006456 if (!gl::ValidateGetVertexAttribParameters(context, pname))
Geoff Langbfdea662014-07-23 14:16:32 -04006457 {
6458 return;
6459 }
Jamie Madilla7d05862013-07-02 11:57:06 -04006460
Geoff Langbfdea662014-07-23 14:16:32 -04006461 if (pname == GL_CURRENT_VERTEX_ATTRIB)
6462 {
6463 const gl::VertexAttribCurrentValueData &currentValueData = context->getState().getVertexAttribCurrentValue(index);
6464 for (int i = 0; i < 4; ++i)
Jamie Madilla7d05862013-07-02 11:57:06 -04006465 {
Geoff Langbfdea662014-07-23 14:16:32 -04006466 params[i] = currentValueData.IntValues[i];
Jamie Madilla7d05862013-07-02 11:57:06 -04006467 }
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00006468 }
Geoff Langbfdea662014-07-23 14:16:32 -04006469 else
6470 {
6471 *params = gl::QuerySingleVertexAttributeParameter<GLint>(attribState, pname);
6472 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006473 }
6474}
6475
Kenneth Russell67ea1902014-10-06 16:44:50 -07006476void GL_APIENTRY glGetVertexAttribIuiv(GLuint index, GLenum pname, GLuint* params)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006477{
6478 EVENT("(GLuint index = %u, GLenum pname = 0x%X, GLuint* params = 0x%0.8p)",
6479 index, pname, params);
6480
Geoff Langbfdea662014-07-23 14:16:32 -04006481 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04006482 if (context)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006483 {
Geoff Langbfdea662014-07-23 14:16:32 -04006484 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006485 {
Geoff Langb1196682014-07-23 13:47:29 -04006486 context->recordError(gl::Error(GL_INVALID_OPERATION));
6487 return;
Geoff Langbfdea662014-07-23 14:16:32 -04006488 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006489
Geoff Langbfdea662014-07-23 14:16:32 -04006490 if (index >= gl::MAX_VERTEX_ATTRIBS)
6491 {
Geoff Langb1196682014-07-23 13:47:29 -04006492 context->recordError(gl::Error(GL_INVALID_VALUE));
6493 return;
Geoff Langbfdea662014-07-23 14:16:32 -04006494 }
Jamie Madilla7d05862013-07-02 11:57:06 -04006495
Geoff Langbfdea662014-07-23 14:16:32 -04006496 const gl::VertexAttribute &attribState = context->getState().getVertexAttribState(index);
Jamie Madilla7d05862013-07-02 11:57:06 -04006497
Geoff Langb1196682014-07-23 13:47:29 -04006498 if (!gl::ValidateGetVertexAttribParameters(context, pname))
Geoff Langbfdea662014-07-23 14:16:32 -04006499 {
6500 return;
6501 }
Jamie Madilla7d05862013-07-02 11:57:06 -04006502
Geoff Langbfdea662014-07-23 14:16:32 -04006503 if (pname == GL_CURRENT_VERTEX_ATTRIB)
6504 {
6505 const gl::VertexAttribCurrentValueData &currentValueData = context->getState().getVertexAttribCurrentValue(index);
6506 for (int i = 0; i < 4; ++i)
Jamie Madilla7d05862013-07-02 11:57:06 -04006507 {
Geoff Langbfdea662014-07-23 14:16:32 -04006508 params[i] = currentValueData.UnsignedIntValues[i];
Jamie Madilla7d05862013-07-02 11:57:06 -04006509 }
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00006510 }
Geoff Langbfdea662014-07-23 14:16:32 -04006511 else
6512 {
6513 *params = gl::QuerySingleVertexAttributeParameter<GLuint>(attribState, pname);
6514 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006515 }
6516}
6517
Kenneth Russell67ea1902014-10-06 16:44:50 -07006518void GL_APIENTRY glVertexAttribI4i(GLuint index, GLint x, GLint y, GLint z, GLint w)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006519{
6520 EVENT("(GLuint index = %u, GLint x = %d, GLint y = %d, GLint z = %d, GLint w = %d)",
6521 index, x, y, z, w);
6522
Geoff Langbfdea662014-07-23 14:16:32 -04006523 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04006524 if (context)
6525 {
6526 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006527 {
Geoff Langb1196682014-07-23 13:47:29 -04006528 context->recordError(gl::Error(GL_INVALID_OPERATION));
6529 return;
shannon.woods%transgaming.com@gtempaccount.coma8885862013-04-13 03:37:53 +00006530 }
Geoff Langbfdea662014-07-23 14:16:32 -04006531
6532 if (index >= gl::MAX_VERTEX_ATTRIBS)
6533 {
Geoff Langb1196682014-07-23 13:47:29 -04006534 context->recordError(gl::Error(GL_INVALID_VALUE));
6535 return;
Geoff Langbfdea662014-07-23 14:16:32 -04006536 }
6537
6538 GLint vals[4] = { x, y, z, w };
6539 context->getState().setVertexAttribi(index, vals);
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006540 }
6541}
6542
Kenneth Russell67ea1902014-10-06 16:44:50 -07006543void GL_APIENTRY glVertexAttribI4ui(GLuint index, GLuint x, GLuint y, GLuint z, GLuint w)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006544{
6545 EVENT("(GLuint index = %u, GLuint x = %u, GLuint y = %u, GLuint z = %u, GLuint w = %u)",
6546 index, x, y, z, w);
6547
Geoff Langbfdea662014-07-23 14:16:32 -04006548 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04006549 if (context)
6550 {
6551 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006552 {
Geoff Langb1196682014-07-23 13:47:29 -04006553 context->recordError(gl::Error(GL_INVALID_OPERATION));
6554 return;
shannon.woods%transgaming.com@gtempaccount.coma8885862013-04-13 03:37:53 +00006555 }
Geoff Langbfdea662014-07-23 14:16:32 -04006556
6557 if (index >= gl::MAX_VERTEX_ATTRIBS)
6558 {
Geoff Langb1196682014-07-23 13:47:29 -04006559 context->recordError(gl::Error(GL_INVALID_VALUE));
6560 return;
Geoff Langbfdea662014-07-23 14:16:32 -04006561 }
6562
6563 GLuint vals[4] = { x, y, z, w };
6564 context->getState().setVertexAttribu(index, vals);
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006565 }
6566}
6567
Kenneth Russell67ea1902014-10-06 16:44:50 -07006568void GL_APIENTRY glVertexAttribI4iv(GLuint index, const GLint* v)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006569{
6570 EVENT("(GLuint index = %u, const GLint* v = 0x%0.8p)", index, v);
6571
Geoff Langbfdea662014-07-23 14:16:32 -04006572 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04006573 if (context)
6574 {
6575 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006576 {
Geoff Langb1196682014-07-23 13:47:29 -04006577 context->recordError(gl::Error(GL_INVALID_OPERATION));
6578 return;
shannon.woods%transgaming.com@gtempaccount.coma8885862013-04-13 03:37:53 +00006579 }
Geoff Langbfdea662014-07-23 14:16:32 -04006580
6581 if (index >= gl::MAX_VERTEX_ATTRIBS)
6582 {
Geoff Langb1196682014-07-23 13:47:29 -04006583 context->recordError(gl::Error(GL_INVALID_VALUE));
6584 return;
Geoff Langbfdea662014-07-23 14:16:32 -04006585 }
6586
6587 context->getState().setVertexAttribi(index, v);
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006588 }
6589}
6590
Kenneth Russell67ea1902014-10-06 16:44:50 -07006591void GL_APIENTRY glVertexAttribI4uiv(GLuint index, const GLuint* v)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006592{
6593 EVENT("(GLuint index = %u, const GLuint* v = 0x%0.8p)", index, v);
6594
Geoff Langbfdea662014-07-23 14:16:32 -04006595 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04006596 if (context)
6597 {
6598 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006599 {
Geoff Langb1196682014-07-23 13:47:29 -04006600 context->recordError(gl::Error(GL_INVALID_OPERATION));
6601 return;
shannon.woods%transgaming.com@gtempaccount.coma8885862013-04-13 03:37:53 +00006602 }
Geoff Langbfdea662014-07-23 14:16:32 -04006603
6604 if (index >= gl::MAX_VERTEX_ATTRIBS)
6605 {
Geoff Langb1196682014-07-23 13:47:29 -04006606 context->recordError(gl::Error(GL_INVALID_VALUE));
6607 return;
Geoff Langbfdea662014-07-23 14:16:32 -04006608 }
6609
6610 context->getState().setVertexAttribu(index, v);
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006611 }
6612}
6613
Kenneth Russell67ea1902014-10-06 16:44:50 -07006614void GL_APIENTRY glGetUniformuiv(GLuint program, GLint location, GLuint* params)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006615{
6616 EVENT("(GLuint program = %u, GLint location = %d, GLuint* params = 0x%0.8p)",
6617 program, location, params);
6618
Geoff Langbfdea662014-07-23 14:16:32 -04006619 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04006620 if (context)
6621 {
Jamie Madill0063c512014-08-25 15:47:53 -04006622 if (!ValidateGetUniformuiv(context, program, location, params))
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006623 {
Jamie Madill0063c512014-08-25 15:47:53 -04006624 return;
shannon.woods%transgaming.com@gtempaccount.come2290122013-04-13 03:41:07 +00006625 }
Geoff Langbfdea662014-07-23 14:16:32 -04006626
Jamie Madilla502c742014-08-28 17:19:13 -04006627 gl::Program *programObject = context->getProgram(program);
6628 ASSERT(programObject);
6629 gl::ProgramBinary *programBinary = programObject->getProgramBinary();
Jamie Madill0063c512014-08-25 15:47:53 -04006630 ASSERT(programBinary);
Geoff Langbfdea662014-07-23 14:16:32 -04006631
Jamie Madill99a1e982014-08-25 15:47:54 -04006632 programBinary->getUniformuiv(location, params);
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006633 }
6634}
6635
Kenneth Russell67ea1902014-10-06 16:44:50 -07006636GLint GL_APIENTRY glGetFragDataLocation(GLuint program, const GLchar *name)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006637{
6638 EVENT("(GLuint program = %u, const GLchar *name = 0x%0.8p)",
6639 program, name);
6640
Geoff Langbfdea662014-07-23 14:16:32 -04006641 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04006642 if (context)
6643 {
6644 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006645 {
Geoff Langb1196682014-07-23 13:47:29 -04006646 context->recordError(gl::Error(GL_INVALID_OPERATION));
6647 return -1;
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00006648 }
Geoff Langbfdea662014-07-23 14:16:32 -04006649
6650 if (program == 0)
6651 {
Geoff Langb1196682014-07-23 13:47:29 -04006652 context->recordError(gl::Error(GL_INVALID_VALUE));
6653 return -1;
Geoff Langbfdea662014-07-23 14:16:32 -04006654 }
6655
6656 gl::Program *programObject = context->getProgram(program);
6657
6658 if (!programObject || !programObject->isLinked())
6659 {
Geoff Langb1196682014-07-23 13:47:29 -04006660 context->recordError(gl::Error(GL_INVALID_OPERATION));
6661 return -1;
Geoff Langbfdea662014-07-23 14:16:32 -04006662 }
6663
6664 gl::ProgramBinary *programBinary = programObject->getProgramBinary();
6665 if (!programBinary)
6666 {
Geoff Langb1196682014-07-23 13:47:29 -04006667 context->recordError(gl::Error(GL_INVALID_OPERATION));
6668 return -1;
Geoff Langbfdea662014-07-23 14:16:32 -04006669 }
6670
6671 return programBinary->getFragDataLocation(name);
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006672 }
6673
6674 return 0;
6675}
6676
Kenneth Russell67ea1902014-10-06 16:44:50 -07006677void GL_APIENTRY glUniform1ui(GLint location, GLuint v0)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006678{
shannon.woods%transgaming.com@gtempaccount.com8431b9c2013-04-13 03:40:17 +00006679 glUniform1uiv(location, 1, &v0);
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006680}
6681
Kenneth Russell67ea1902014-10-06 16:44:50 -07006682void GL_APIENTRY glUniform2ui(GLint location, GLuint v0, GLuint v1)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006683{
shannon.woods%transgaming.com@gtempaccount.com8431b9c2013-04-13 03:40:17 +00006684 const GLuint xy[] = { v0, v1 };
6685 glUniform2uiv(location, 1, xy);
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006686}
6687
Kenneth Russell67ea1902014-10-06 16:44:50 -07006688void GL_APIENTRY glUniform3ui(GLint location, GLuint v0, GLuint v1, GLuint v2)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006689{
shannon.woods%transgaming.com@gtempaccount.com8431b9c2013-04-13 03:40:17 +00006690 const GLuint xyz[] = { v0, v1, v2 };
6691 glUniform3uiv(location, 1, xyz);
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006692}
6693
Kenneth Russell67ea1902014-10-06 16:44:50 -07006694void GL_APIENTRY glUniform4ui(GLint location, GLuint v0, GLuint v1, GLuint v2, GLuint v3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006695{
shannon.woods%transgaming.com@gtempaccount.com8431b9c2013-04-13 03:40:17 +00006696 const GLuint xyzw[] = { v0, v1, v2, v3 };
6697 glUniform4uiv(location, 1, xyzw);
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006698}
6699
Kenneth Russell67ea1902014-10-06 16:44:50 -07006700void GL_APIENTRY glUniform1uiv(GLint location, GLsizei count, const GLuint* value)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006701{
6702 EVENT("(GLint location = %d, GLsizei count = %d, const GLuint* value = 0x%0.8p)",
6703 location, count, value);
6704
Geoff Langbfdea662014-07-23 14:16:32 -04006705 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04006706 if (context)
6707 {
6708 if (!ValidateUniform(context, GL_UNSIGNED_INT, location, count))
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006709 {
Geoff Langbfdea662014-07-23 14:16:32 -04006710 return;
shannon.woods%transgaming.com@gtempaccount.com50ea4ab2013-04-13 03:40:36 +00006711 }
Geoff Langbfdea662014-07-23 14:16:32 -04006712
6713 gl::ProgramBinary *programBinary = context->getState().getCurrentProgramBinary();
6714 programBinary->setUniform1uiv(location, count, value);
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006715 }
6716}
6717
Kenneth Russell67ea1902014-10-06 16:44:50 -07006718void GL_APIENTRY glUniform2uiv(GLint location, GLsizei count, const GLuint* value)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006719{
6720 EVENT("(GLint location = %d, GLsizei count = %d, const GLuint* value = 0x%0.8p)",
6721 location, count, value);
6722
Geoff Langbfdea662014-07-23 14:16:32 -04006723 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04006724 if (context)
6725 {
6726 if (!ValidateUniform(context, GL_UNSIGNED_INT_VEC2, location, count))
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006727 {
Geoff Langbfdea662014-07-23 14:16:32 -04006728 return;
shannon.woods%transgaming.com@gtempaccount.com50ea4ab2013-04-13 03:40:36 +00006729 }
Geoff Langbfdea662014-07-23 14:16:32 -04006730
6731 gl::ProgramBinary *programBinary = context->getState().getCurrentProgramBinary();
6732 programBinary->setUniform2uiv(location, count, value);
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006733 }
6734}
6735
Kenneth Russell67ea1902014-10-06 16:44:50 -07006736void GL_APIENTRY glUniform3uiv(GLint location, GLsizei count, const GLuint* value)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006737{
6738 EVENT("(GLint location = %d, GLsizei count = %d, const GLuint* value)",
6739 location, count, value);
6740
Geoff Langbfdea662014-07-23 14:16:32 -04006741 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04006742 if (context)
6743 {
6744 if (!ValidateUniform(context, GL_UNSIGNED_INT_VEC3, location, count))
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006745 {
Geoff Langbfdea662014-07-23 14:16:32 -04006746 return;
shannon.woods%transgaming.com@gtempaccount.com50ea4ab2013-04-13 03:40:36 +00006747 }
Geoff Langbfdea662014-07-23 14:16:32 -04006748
6749 gl::ProgramBinary *programBinary = context->getState().getCurrentProgramBinary();
6750 programBinary->setUniform3uiv(location, count, value);
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006751 }
6752}
6753
Kenneth Russell67ea1902014-10-06 16:44:50 -07006754void GL_APIENTRY glUniform4uiv(GLint location, GLsizei count, const GLuint* value)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006755{
6756 EVENT("(GLint location = %d, GLsizei count = %d, const GLuint* value = 0x%0.8p)",
6757 location, count, value);
6758
Geoff Langbfdea662014-07-23 14:16:32 -04006759 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04006760 if (context)
6761 {
6762 if (!ValidateUniform(context, GL_UNSIGNED_INT_VEC4, location, count))
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006763 {
Geoff Langbfdea662014-07-23 14:16:32 -04006764 return;
shannon.woods%transgaming.com@gtempaccount.com50ea4ab2013-04-13 03:40:36 +00006765 }
Geoff Langbfdea662014-07-23 14:16:32 -04006766
6767 gl::ProgramBinary *programBinary = context->getState().getCurrentProgramBinary();
6768 programBinary->setUniform4uiv(location, count, value);
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006769 }
6770}
6771
Kenneth Russell67ea1902014-10-06 16:44:50 -07006772void GL_APIENTRY glClearBufferiv(GLenum buffer, GLint drawbuffer, const GLint* value)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006773{
6774 EVENT("(GLenum buffer = 0x%X, GLint drawbuffer = %d, const GLint* value = 0x%0.8p)",
6775 buffer, drawbuffer, value);
6776
Geoff Langbfdea662014-07-23 14:16:32 -04006777 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04006778 if (context)
6779 {
6780 if (!ValidateClearBuffer(context))
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006781 {
Geoff Langbfdea662014-07-23 14:16:32 -04006782 return;
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00006783 }
Geoff Langbfdea662014-07-23 14:16:32 -04006784
6785 switch (buffer)
6786 {
6787 case GL_COLOR:
6788 if (drawbuffer < 0 || static_cast<GLuint>(drawbuffer) >= context->getCaps().maxDrawBuffers)
6789 {
Geoff Langb1196682014-07-23 13:47:29 -04006790 context->recordError(gl::Error(GL_INVALID_VALUE));
6791 return;
Geoff Langbfdea662014-07-23 14:16:32 -04006792 }
6793 break;
Geoff Langb1196682014-07-23 13:47:29 -04006794
Geoff Langbfdea662014-07-23 14:16:32 -04006795 case GL_STENCIL:
6796 if (drawbuffer != 0)
6797 {
Geoff Langb1196682014-07-23 13:47:29 -04006798 context->recordError(gl::Error(GL_INVALID_VALUE));
6799 return;
Geoff Langbfdea662014-07-23 14:16:32 -04006800 }
6801 break;
Geoff Langb1196682014-07-23 13:47:29 -04006802
Geoff Langbfdea662014-07-23 14:16:32 -04006803 default:
Geoff Langb1196682014-07-23 13:47:29 -04006804 context->recordError(gl::Error(GL_INVALID_ENUM));
6805 return;
Geoff Langbfdea662014-07-23 14:16:32 -04006806 }
6807
Geoff Langcc79b8c2014-07-25 13:48:02 -04006808 gl::Error error = context->clearBufferiv(buffer, drawbuffer, value);
6809 if (error.isError())
6810 {
6811 context->recordError(error);
6812 return;
6813 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006814 }
6815}
6816
Kenneth Russell67ea1902014-10-06 16:44:50 -07006817void GL_APIENTRY glClearBufferuiv(GLenum buffer, GLint drawbuffer, const GLuint* value)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006818{
6819 EVENT("(GLenum buffer = 0x%X, GLint drawbuffer = %d, const GLuint* value = 0x%0.8p)",
6820 buffer, drawbuffer, value);
6821
Geoff Langbfdea662014-07-23 14:16:32 -04006822 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04006823 if (context)
6824 {
6825 if (!ValidateClearBuffer(context))
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006826 {
Geoff Langbfdea662014-07-23 14:16:32 -04006827 return;
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00006828 }
Geoff Langbfdea662014-07-23 14:16:32 -04006829
6830 switch (buffer)
6831 {
6832 case GL_COLOR:
6833 if (drawbuffer < 0 || static_cast<GLuint>(drawbuffer) >= context->getCaps().maxDrawBuffers)
6834 {
Geoff Langb1196682014-07-23 13:47:29 -04006835 context->recordError(gl::Error(GL_INVALID_VALUE));
6836 return;
Geoff Langbfdea662014-07-23 14:16:32 -04006837 }
6838 break;
Geoff Langb1196682014-07-23 13:47:29 -04006839
Geoff Langbfdea662014-07-23 14:16:32 -04006840 default:
Geoff Langb1196682014-07-23 13:47:29 -04006841 context->recordError(gl::Error(GL_INVALID_ENUM));
6842 return;
Geoff Langbfdea662014-07-23 14:16:32 -04006843 }
6844
Geoff Langcc79b8c2014-07-25 13:48:02 -04006845 gl::Error error = context->clearBufferuiv(buffer, drawbuffer, value);
6846 if (error.isError())
6847 {
6848 context->recordError(error);
6849 return;
6850 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006851 }
6852}
6853
Kenneth Russell67ea1902014-10-06 16:44:50 -07006854void GL_APIENTRY glClearBufferfv(GLenum buffer, GLint drawbuffer, const GLfloat* value)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006855{
6856 EVENT("(GLenum buffer = 0x%X, GLint drawbuffer = %d, const GLfloat* value = 0x%0.8p)",
6857 buffer, drawbuffer, value);
6858
Geoff Langbfdea662014-07-23 14:16:32 -04006859 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04006860 if (context)
6861 {
6862 if (!ValidateClearBuffer(context))
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006863 {
Geoff Langbfdea662014-07-23 14:16:32 -04006864 return;
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00006865 }
Geoff Langbfdea662014-07-23 14:16:32 -04006866
6867 switch (buffer)
6868 {
6869 case GL_COLOR:
6870 if (drawbuffer < 0 || static_cast<GLuint>(drawbuffer) >= context->getCaps().maxDrawBuffers)
6871 {
Geoff Langb1196682014-07-23 13:47:29 -04006872 context->recordError(gl::Error(GL_INVALID_VALUE));
6873 return;
Geoff Langbfdea662014-07-23 14:16:32 -04006874 }
6875 break;
Geoff Langb1196682014-07-23 13:47:29 -04006876
Geoff Langbfdea662014-07-23 14:16:32 -04006877 case GL_DEPTH:
6878 if (drawbuffer != 0)
6879 {
Geoff Langb1196682014-07-23 13:47:29 -04006880 context->recordError(gl::Error(GL_INVALID_VALUE));
6881 return;
Geoff Langbfdea662014-07-23 14:16:32 -04006882 }
6883 break;
Geoff Langb1196682014-07-23 13:47:29 -04006884
Geoff Langbfdea662014-07-23 14:16:32 -04006885 default:
Geoff Langb1196682014-07-23 13:47:29 -04006886 context->recordError(gl::Error(GL_INVALID_ENUM));
6887 return;
Geoff Langbfdea662014-07-23 14:16:32 -04006888 }
6889
Geoff Langcc79b8c2014-07-25 13:48:02 -04006890 gl::Error error = context->clearBufferfv(buffer, drawbuffer, value);
6891 if (error.isError())
6892 {
6893 context->recordError(error);
6894 return;
6895 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006896 }
6897}
6898
Kenneth Russell67ea1902014-10-06 16:44:50 -07006899void GL_APIENTRY glClearBufferfi(GLenum buffer, GLint drawbuffer, GLfloat depth, GLint stencil)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006900{
6901 EVENT("(GLenum buffer = 0x%X, GLint drawbuffer = %d, GLfloat depth, GLint stencil = %d)",
6902 buffer, drawbuffer, depth, stencil);
6903
Geoff Langbfdea662014-07-23 14:16:32 -04006904 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04006905 if (context)
6906 {
6907 if (!ValidateClearBuffer(context))
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006908 {
Geoff Langbfdea662014-07-23 14:16:32 -04006909 return;
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00006910 }
Geoff Langbfdea662014-07-23 14:16:32 -04006911
6912 switch (buffer)
6913 {
6914 case GL_DEPTH_STENCIL:
6915 if (drawbuffer != 0)
6916 {
Geoff Langb1196682014-07-23 13:47:29 -04006917 context->recordError(gl::Error(GL_INVALID_VALUE));
6918 return;
Geoff Langbfdea662014-07-23 14:16:32 -04006919 }
6920 break;
Geoff Langb1196682014-07-23 13:47:29 -04006921
Geoff Langbfdea662014-07-23 14:16:32 -04006922 default:
Geoff Langb1196682014-07-23 13:47:29 -04006923 context->recordError(gl::Error(GL_INVALID_ENUM));
6924 return;
Geoff Langbfdea662014-07-23 14:16:32 -04006925 }
6926
Geoff Langcc79b8c2014-07-25 13:48:02 -04006927 gl::Error error = context->clearBufferfi(buffer, drawbuffer, depth, stencil);
6928 if (error.isError())
6929 {
6930 context->recordError(error);
6931 return;
6932 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006933 }
6934}
6935
Kenneth Russell67ea1902014-10-06 16:44:50 -07006936const GLubyte* GL_APIENTRY glGetStringi(GLenum name, GLuint index)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006937{
6938 EVENT("(GLenum name = 0x%X, GLuint index = %u)", name, index);
6939
Geoff Langbfdea662014-07-23 14:16:32 -04006940 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04006941 if (context)
6942 {
6943 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006944 {
Geoff Langb1196682014-07-23 13:47:29 -04006945 context->recordError(gl::Error(GL_INVALID_OPERATION));
6946 return NULL;
shannonwoods@chromium.org302df742013-05-30 00:05:54 +00006947 }
Geoff Langbfdea662014-07-23 14:16:32 -04006948
6949 if (name != GL_EXTENSIONS)
6950 {
Geoff Langb1196682014-07-23 13:47:29 -04006951 context->recordError(gl::Error(GL_INVALID_ENUM));
6952 return NULL;
Geoff Langbfdea662014-07-23 14:16:32 -04006953 }
6954
6955 if (index >= context->getExtensionStringCount())
6956 {
Geoff Langb1196682014-07-23 13:47:29 -04006957 context->recordError(gl::Error(GL_INVALID_VALUE));
6958 return NULL;
Geoff Langbfdea662014-07-23 14:16:32 -04006959 }
6960
6961 return reinterpret_cast<const GLubyte*>(context->getExtensionString(index).c_str());
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006962 }
6963
6964 return NULL;
6965}
6966
Kenneth Russell67ea1902014-10-06 16:44:50 -07006967void GL_APIENTRY glCopyBufferSubData(GLenum readTarget, GLenum writeTarget, GLintptr readOffset, GLintptr writeOffset, GLsizeiptr size)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006968{
6969 EVENT("(GLenum readTarget = 0x%X, GLenum writeTarget = 0x%X, GLintptr readOffset = %d, GLintptr writeOffset = %d, GLsizeiptr size = %d)",
6970 readTarget, writeTarget, readOffset, writeOffset, size);
6971
Geoff Langbfdea662014-07-23 14:16:32 -04006972 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04006973 if (context)
6974 {
6975 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006976 {
Geoff Langb1196682014-07-23 13:47:29 -04006977 context->recordError(gl::Error(GL_INVALID_OPERATION));
6978 return;
shannon.woods%transgaming.com@gtempaccount.com296c3f22013-04-13 03:39:39 +00006979 }
Geoff Langbfdea662014-07-23 14:16:32 -04006980
Jamie Madill24e83192014-10-20 11:00:53 -04006981 if (!gl::ValidBufferTarget(context, readTarget) || !gl::ValidBufferTarget(context, writeTarget))
Geoff Langbfdea662014-07-23 14:16:32 -04006982 {
Geoff Langb1196682014-07-23 13:47:29 -04006983 context->recordError(gl::Error(GL_INVALID_ENUM));
6984 return;
Geoff Langbfdea662014-07-23 14:16:32 -04006985 }
6986
6987 gl::Buffer *readBuffer = context->getState().getTargetBuffer(readTarget);
6988 gl::Buffer *writeBuffer = context->getState().getTargetBuffer(writeTarget);
6989
6990 if (!readBuffer || !writeBuffer)
6991 {
Geoff Langb1196682014-07-23 13:47:29 -04006992 context->recordError(gl::Error(GL_INVALID_OPERATION));
6993 return;
Geoff Langbfdea662014-07-23 14:16:32 -04006994 }
6995
Jamie Madillcfaaf722014-07-31 10:47:54 -04006996 // Verify that readBuffer and writeBuffer are not currently mapped
Geoff Langbfdea662014-07-23 14:16:32 -04006997 if (readBuffer->isMapped() || writeBuffer->isMapped())
6998 {
Geoff Langb1196682014-07-23 13:47:29 -04006999 context->recordError(gl::Error(GL_INVALID_OPERATION));
7000 return;
Geoff Langbfdea662014-07-23 14:16:32 -04007001 }
7002
7003 if (readOffset < 0 || writeOffset < 0 || size < 0 ||
7004 static_cast<unsigned int>(readOffset + size) > readBuffer->getSize() ||
7005 static_cast<unsigned int>(writeOffset + size) > writeBuffer->getSize())
7006 {
Geoff Langb1196682014-07-23 13:47:29 -04007007 context->recordError(gl::Error(GL_INVALID_VALUE));
7008 return;
Geoff Langbfdea662014-07-23 14:16:32 -04007009 }
7010
Kenneth Russell67ea1902014-10-06 16:44:50 -07007011 if (readBuffer == writeBuffer && std::abs(readOffset - writeOffset) < size)
Geoff Langbfdea662014-07-23 14:16:32 -04007012 {
Geoff Langb1196682014-07-23 13:47:29 -04007013 context->recordError(gl::Error(GL_INVALID_VALUE));
7014 return;
Geoff Langbfdea662014-07-23 14:16:32 -04007015 }
7016
Geoff Langbfdea662014-07-23 14:16:32 -04007017 // if size is zero, the copy is a successful no-op
7018 if (size > 0)
7019 {
Geoff Lang2a1c15a2014-07-25 11:43:00 -04007020 gl::Error error = writeBuffer->copyBufferSubData(readBuffer, readOffset, writeOffset, size);
7021 if (error.isError())
7022 {
7023 context->recordError(error);
7024 return;
7025 }
Geoff Langbfdea662014-07-23 14:16:32 -04007026 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007027 }
7028}
7029
Kenneth Russell67ea1902014-10-06 16:44:50 -07007030void GL_APIENTRY glGetUniformIndices(GLuint program, GLsizei uniformCount, const GLchar* const* uniformNames, GLuint* uniformIndices)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007031{
7032 EVENT("(GLuint program = %u, GLsizei uniformCount = %d, const GLchar* const* uniformNames = 0x%0.8p, GLuint* uniformIndices = 0x%0.8p)",
7033 program, uniformCount, uniformNames, uniformIndices);
7034
Geoff Langbfdea662014-07-23 14:16:32 -04007035 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04007036 if (context)
7037 {
7038 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007039 {
Geoff Langb1196682014-07-23 13:47:29 -04007040 context->recordError(gl::Error(GL_INVALID_OPERATION));
7041 return;
Geoff Langbfdea662014-07-23 14:16:32 -04007042 }
7043
7044 if (uniformCount < 0)
7045 {
Geoff Langb1196682014-07-23 13:47:29 -04007046 context->recordError(gl::Error(GL_INVALID_VALUE));
7047 return;
Geoff Langbfdea662014-07-23 14:16:32 -04007048 }
7049
7050 gl::Program *programObject = context->getProgram(program);
7051
7052 if (!programObject)
7053 {
7054 if (context->getShader(program))
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007055 {
Geoff Langb1196682014-07-23 13:47:29 -04007056 context->recordError(gl::Error(GL_INVALID_OPERATION));
7057 return;
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007058 }
Geoff Langbfdea662014-07-23 14:16:32 -04007059 else
shannonwoods@chromium.orgc2ed9912013-05-30 00:05:33 +00007060 {
Geoff Langb1196682014-07-23 13:47:29 -04007061 context->recordError(gl::Error(GL_INVALID_VALUE));
7062 return;
shannonwoods@chromium.orgc2ed9912013-05-30 00:05:33 +00007063 }
Geoff Langbfdea662014-07-23 14:16:32 -04007064 }
shannonwoods@chromium.orgc2ed9912013-05-30 00:05:33 +00007065
Geoff Langbfdea662014-07-23 14:16:32 -04007066 gl::ProgramBinary *programBinary = programObject->getProgramBinary();
7067 if (!programObject->isLinked() || !programBinary)
7068 {
7069 for (int uniformId = 0; uniformId < uniformCount; uniformId++)
shannonwoods@chromium.orgc2ed9912013-05-30 00:05:33 +00007070 {
Geoff Langbfdea662014-07-23 14:16:32 -04007071 uniformIndices[uniformId] = GL_INVALID_INDEX;
shannonwoods@chromium.orgc2ed9912013-05-30 00:05:33 +00007072 }
7073 }
Geoff Langbfdea662014-07-23 14:16:32 -04007074 else
7075 {
7076 for (int uniformId = 0; uniformId < uniformCount; uniformId++)
7077 {
7078 uniformIndices[uniformId] = programBinary->getUniformIndex(uniformNames[uniformId]);
7079 }
7080 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007081 }
7082}
7083
Kenneth Russell67ea1902014-10-06 16:44:50 -07007084void 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 +00007085{
7086 EVENT("(GLuint program = %u, GLsizei uniformCount = %d, const GLuint* uniformIndices = 0x%0.8p, GLenum pname = 0x%X, GLint* params = 0x%0.8p)",
7087 program, uniformCount, uniformIndices, pname, params);
7088
Geoff Langbfdea662014-07-23 14:16:32 -04007089 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04007090 if (context)
7091 {
7092 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007093 {
Geoff Langb1196682014-07-23 13:47:29 -04007094 context->recordError(gl::Error(GL_INVALID_OPERATION));
7095 return;
Geoff Langbfdea662014-07-23 14:16:32 -04007096 }
7097
7098 if (uniformCount < 0)
7099 {
Geoff Langb1196682014-07-23 13:47:29 -04007100 context->recordError(gl::Error(GL_INVALID_VALUE));
7101 return;
Geoff Langbfdea662014-07-23 14:16:32 -04007102 }
7103
7104 gl::Program *programObject = context->getProgram(program);
7105
7106 if (!programObject)
7107 {
7108 if (context->getShader(program))
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007109 {
Geoff Langb1196682014-07-23 13:47:29 -04007110 context->recordError(gl::Error(GL_INVALID_OPERATION));
7111 return;
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007112 }
Geoff Langbfdea662014-07-23 14:16:32 -04007113 else
shannonwoods@chromium.org2a9a9d22013-05-30 00:05:40 +00007114 {
Geoff Langb1196682014-07-23 13:47:29 -04007115 context->recordError(gl::Error(GL_INVALID_VALUE));
7116 return;
shannonwoods@chromium.org2a9a9d22013-05-30 00:05:40 +00007117 }
shannonwoods@chromium.org2a9a9d22013-05-30 00:05:40 +00007118 }
Geoff Langbfdea662014-07-23 14:16:32 -04007119
7120 switch (pname)
7121 {
7122 case GL_UNIFORM_TYPE:
7123 case GL_UNIFORM_SIZE:
7124 case GL_UNIFORM_NAME_LENGTH:
7125 case GL_UNIFORM_BLOCK_INDEX:
7126 case GL_UNIFORM_OFFSET:
7127 case GL_UNIFORM_ARRAY_STRIDE:
7128 case GL_UNIFORM_MATRIX_STRIDE:
7129 case GL_UNIFORM_IS_ROW_MAJOR:
7130 break;
Geoff Langb1196682014-07-23 13:47:29 -04007131
Geoff Langbfdea662014-07-23 14:16:32 -04007132 default:
Geoff Langb1196682014-07-23 13:47:29 -04007133 context->recordError(gl::Error(GL_INVALID_ENUM));
7134 return;
Geoff Langbfdea662014-07-23 14:16:32 -04007135 }
7136
7137 gl::ProgramBinary *programBinary = programObject->getProgramBinary();
7138
7139 if (!programBinary && uniformCount > 0)
7140 {
Geoff Langb1196682014-07-23 13:47:29 -04007141 context->recordError(gl::Error(GL_INVALID_VALUE));
7142 return;
Geoff Langbfdea662014-07-23 14:16:32 -04007143 }
7144
7145 for (int uniformId = 0; uniformId < uniformCount; uniformId++)
7146 {
7147 const GLuint index = uniformIndices[uniformId];
7148
7149 if (index >= (GLuint)programBinary->getActiveUniformCount())
7150 {
Geoff Langb1196682014-07-23 13:47:29 -04007151 context->recordError(gl::Error(GL_INVALID_VALUE));
7152 return;
Geoff Langbfdea662014-07-23 14:16:32 -04007153 }
7154 }
7155
7156 for (int uniformId = 0; uniformId < uniformCount; uniformId++)
7157 {
7158 const GLuint index = uniformIndices[uniformId];
7159 params[uniformId] = programBinary->getActiveUniformi(index, pname);
7160 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007161 }
7162}
7163
Kenneth Russell67ea1902014-10-06 16:44:50 -07007164GLuint GL_APIENTRY glGetUniformBlockIndex(GLuint program, const GLchar* uniformBlockName)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007165{
7166 EVENT("(GLuint program = %u, const GLchar* uniformBlockName = 0x%0.8p)", program, uniformBlockName);
7167
Geoff Langbfdea662014-07-23 14:16:32 -04007168 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04007169 if (context)
7170 {
7171 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007172 {
Geoff Langb1196682014-07-23 13:47:29 -04007173 context->recordError(gl::Error(GL_INVALID_OPERATION));
7174 return GL_INVALID_INDEX;
Geoff Langbfdea662014-07-23 14:16:32 -04007175 }
7176
7177 gl::Program *programObject = context->getProgram(program);
7178
7179 if (!programObject)
7180 {
7181 if (context->getShader(program))
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007182 {
Geoff Langb1196682014-07-23 13:47:29 -04007183 context->recordError(gl::Error(GL_INVALID_OPERATION));
7184 return GL_INVALID_INDEX;
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007185 }
Geoff Langbfdea662014-07-23 14:16:32 -04007186 else
shannonwoods@chromium.org42766252013-05-30 00:07:12 +00007187 {
Geoff Langb1196682014-07-23 13:47:29 -04007188 context->recordError(gl::Error(GL_INVALID_VALUE));
7189 return GL_INVALID_INDEX;
shannonwoods@chromium.org42766252013-05-30 00:07:12 +00007190 }
shannonwoods@chromium.org42766252013-05-30 00:07:12 +00007191 }
Geoff Langbfdea662014-07-23 14:16:32 -04007192
7193 gl::ProgramBinary *programBinary = programObject->getProgramBinary();
7194 if (!programBinary)
7195 {
7196 return GL_INVALID_INDEX;
7197 }
7198
7199 return programBinary->getUniformBlockIndex(uniformBlockName);
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007200 }
7201
7202 return 0;
7203}
7204
Kenneth Russell67ea1902014-10-06 16:44:50 -07007205void GL_APIENTRY glGetActiveUniformBlockiv(GLuint program, GLuint uniformBlockIndex, GLenum pname, GLint* params)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007206{
7207 EVENT("(GLuint program = %u, GLuint uniformBlockIndex = %u, GLenum pname = 0x%X, GLint* params = 0x%0.8p)",
7208 program, uniformBlockIndex, pname, params);
7209
Geoff Langbfdea662014-07-23 14:16:32 -04007210 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04007211 if (context)
7212 {
7213 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007214 {
Geoff Langb1196682014-07-23 13:47:29 -04007215 context->recordError(gl::Error(GL_INVALID_OPERATION));
7216 return;
Geoff Langbfdea662014-07-23 14:16:32 -04007217 }
7218 gl::Program *programObject = context->getProgram(program);
7219
7220 if (!programObject)
7221 {
7222 if (context->getShader(program))
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007223 {
Geoff Langb1196682014-07-23 13:47:29 -04007224 context->recordError(gl::Error(GL_INVALID_OPERATION));
7225 return;
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007226 }
Geoff Langbfdea662014-07-23 14:16:32 -04007227 else
shannonwoods@chromium.orge7317ca2013-05-30 00:07:35 +00007228 {
Geoff Langb1196682014-07-23 13:47:29 -04007229 context->recordError(gl::Error(GL_INVALID_VALUE));
7230 return;
shannonwoods@chromium.orge7317ca2013-05-30 00:07:35 +00007231 }
shannonwoods@chromium.orge7317ca2013-05-30 00:07:35 +00007232 }
Geoff Langbfdea662014-07-23 14:16:32 -04007233
7234 gl::ProgramBinary *programBinary = programObject->getProgramBinary();
7235
7236 if (!programBinary || uniformBlockIndex >= programBinary->getActiveUniformBlockCount())
7237 {
Geoff Langb1196682014-07-23 13:47:29 -04007238 context->recordError(gl::Error(GL_INVALID_VALUE));
7239 return;
Geoff Langbfdea662014-07-23 14:16:32 -04007240 }
7241
7242 switch (pname)
7243 {
7244 case GL_UNIFORM_BLOCK_BINDING:
7245 *params = static_cast<GLint>(programObject->getUniformBlockBinding(uniformBlockIndex));
7246 break;
7247
7248 case GL_UNIFORM_BLOCK_DATA_SIZE:
7249 case GL_UNIFORM_BLOCK_NAME_LENGTH:
7250 case GL_UNIFORM_BLOCK_ACTIVE_UNIFORMS:
7251 case GL_UNIFORM_BLOCK_ACTIVE_UNIFORM_INDICES:
7252 case GL_UNIFORM_BLOCK_REFERENCED_BY_VERTEX_SHADER:
7253 case GL_UNIFORM_BLOCK_REFERENCED_BY_FRAGMENT_SHADER:
7254 programBinary->getActiveUniformBlockiv(uniformBlockIndex, pname, params);
7255 break;
7256
7257 default:
Geoff Langb1196682014-07-23 13:47:29 -04007258 context->recordError(gl::Error(GL_INVALID_ENUM));
7259 return;
Geoff Langbfdea662014-07-23 14:16:32 -04007260 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007261 }
7262}
7263
Kenneth Russell67ea1902014-10-06 16:44:50 -07007264void GL_APIENTRY glGetActiveUniformBlockName(GLuint program, GLuint uniformBlockIndex, GLsizei bufSize, GLsizei* length, GLchar* uniformBlockName)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007265{
7266 EVENT("(GLuint program = %u, GLuint uniformBlockIndex = %u, GLsizei bufSize = %d, GLsizei* length = 0x%0.8p, GLchar* uniformBlockName = 0x%0.8p)",
7267 program, uniformBlockIndex, bufSize, length, uniformBlockName);
7268
Geoff Langbfdea662014-07-23 14:16:32 -04007269 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04007270 if (context)
7271 {
7272 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007273 {
Geoff Langb1196682014-07-23 13:47:29 -04007274 context->recordError(gl::Error(GL_INVALID_OPERATION));
7275 return;
Geoff Langbfdea662014-07-23 14:16:32 -04007276 }
7277
7278 gl::Program *programObject = context->getProgram(program);
7279
7280 if (!programObject)
7281 {
7282 if (context->getShader(program))
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007283 {
Geoff Langb1196682014-07-23 13:47:29 -04007284 context->recordError(gl::Error(GL_INVALID_OPERATION));
7285 return;
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007286 }
Geoff Langbfdea662014-07-23 14:16:32 -04007287 else
shannonwoods@chromium.orgbeb02782013-05-30 00:07:28 +00007288 {
Geoff Langb1196682014-07-23 13:47:29 -04007289 context->recordError(gl::Error(GL_INVALID_VALUE));
7290 return;
shannonwoods@chromium.orgbeb02782013-05-30 00:07:28 +00007291 }
shannonwoods@chromium.orgbeb02782013-05-30 00:07:28 +00007292 }
Geoff Langbfdea662014-07-23 14:16:32 -04007293
7294 gl::ProgramBinary *programBinary = programObject->getProgramBinary();
7295
7296 if (!programBinary || uniformBlockIndex >= programBinary->getActiveUniformBlockCount())
7297 {
Geoff Langb1196682014-07-23 13:47:29 -04007298 context->recordError(gl::Error(GL_INVALID_VALUE));
7299 return;
Geoff Langbfdea662014-07-23 14:16:32 -04007300 }
7301
7302 programBinary->getActiveUniformBlockName(uniformBlockIndex, bufSize, length, uniformBlockName);
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007303 }
7304}
7305
Kenneth Russell67ea1902014-10-06 16:44:50 -07007306void GL_APIENTRY glUniformBlockBinding(GLuint program, GLuint uniformBlockIndex, GLuint uniformBlockBinding)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007307{
7308 EVENT("(GLuint program = %u, GLuint uniformBlockIndex = %u, GLuint uniformBlockBinding = %u)",
7309 program, uniformBlockIndex, uniformBlockBinding);
7310
Geoff Langbfdea662014-07-23 14:16:32 -04007311 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04007312 if (context)
7313 {
7314 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007315 {
Geoff Langb1196682014-07-23 13:47:29 -04007316 context->recordError(gl::Error(GL_INVALID_OPERATION));
7317 return;
Geoff Langbfdea662014-07-23 14:16:32 -04007318 }
7319
Geoff Lang3a61c322014-07-10 13:01:54 -04007320 if (uniformBlockBinding >= context->getCaps().maxUniformBufferBindings)
Geoff Langbfdea662014-07-23 14:16:32 -04007321 {
Geoff Langb1196682014-07-23 13:47:29 -04007322 context->recordError(gl::Error(GL_INVALID_VALUE));
7323 return;
Geoff Langbfdea662014-07-23 14:16:32 -04007324 }
7325
7326 gl::Program *programObject = context->getProgram(program);
7327
7328 if (!programObject)
7329 {
7330 if (context->getShader(program))
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007331 {
Geoff Langb1196682014-07-23 13:47:29 -04007332 context->recordError(gl::Error(GL_INVALID_OPERATION));
7333 return;
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007334 }
Geoff Langbfdea662014-07-23 14:16:32 -04007335 else
shannonwoods@chromium.org70eb1ea2013-05-30 00:07:20 +00007336 {
Geoff Langb1196682014-07-23 13:47:29 -04007337 context->recordError(gl::Error(GL_INVALID_VALUE));
7338 return;
shannonwoods@chromium.org70eb1ea2013-05-30 00:07:20 +00007339 }
shannonwoods@chromium.org70eb1ea2013-05-30 00:07:20 +00007340 }
Geoff Langbfdea662014-07-23 14:16:32 -04007341
7342 gl::ProgramBinary *programBinary = programObject->getProgramBinary();
7343
7344 // if never linked, there won't be any uniform blocks
7345 if (!programBinary || uniformBlockIndex >= programBinary->getActiveUniformBlockCount())
7346 {
Geoff Langb1196682014-07-23 13:47:29 -04007347 context->recordError(gl::Error(GL_INVALID_VALUE));
7348 return;
Geoff Langbfdea662014-07-23 14:16:32 -04007349 }
7350
7351 programObject->bindUniformBlock(uniformBlockIndex, uniformBlockBinding);
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007352 }
7353}
7354
Kenneth Russell67ea1902014-10-06 16:44:50 -07007355void GL_APIENTRY glDrawArraysInstanced(GLenum mode, GLint first, GLsizei count, GLsizei instanceCount)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007356{
7357 EVENT("(GLenum mode = 0x%X, GLint first = %d, GLsizei count = %d, GLsizei instanceCount = %d)",
7358 mode, first, count, instanceCount);
7359
Geoff Langbfdea662014-07-23 14:16:32 -04007360 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04007361 if (context)
7362 {
7363 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007364 {
Geoff Langb1196682014-07-23 13:47:29 -04007365 context->recordError(gl::Error(GL_INVALID_OPERATION));
7366 return;
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00007367 }
Geoff Langbfdea662014-07-23 14:16:32 -04007368
7369 // glDrawArraysInstanced
7370 UNIMPLEMENTED();
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007371 }
7372}
7373
Kenneth Russell67ea1902014-10-06 16:44:50 -07007374void 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 +00007375{
7376 EVENT("(GLenum mode = 0x%X, GLsizei count = %d, GLenum type = 0x%X, const GLvoid* indices = 0x%0.8p, GLsizei instanceCount = %d)",
7377 mode, count, type, indices, instanceCount);
7378
Geoff Langbfdea662014-07-23 14:16:32 -04007379 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04007380 if (context)
7381 {
7382 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007383 {
Geoff Langb1196682014-07-23 13:47:29 -04007384 context->recordError(gl::Error(GL_INVALID_OPERATION));
7385 return;
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00007386 }
Geoff Langbfdea662014-07-23 14:16:32 -04007387
7388 // glDrawElementsInstanced
7389 UNIMPLEMENTED();
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007390 }
7391}
7392
Kenneth Russell67ea1902014-10-06 16:44:50 -07007393GLsync GL_APIENTRY glFenceSync(GLenum condition, GLbitfield flags)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007394{
7395 EVENT("(GLenum condition = 0x%X, GLbitfield flags = 0x%X)", condition, flags);
7396
Geoff Langbfdea662014-07-23 14:16:32 -04007397 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04007398 if (context)
7399 {
7400 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007401 {
Geoff Langb1196682014-07-23 13:47:29 -04007402 context->recordError(gl::Error(GL_INVALID_OPERATION));
7403 return 0;
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00007404 }
Geoff Langbfdea662014-07-23 14:16:32 -04007405
7406 if (condition != GL_SYNC_GPU_COMMANDS_COMPLETE)
7407 {
Geoff Langb1196682014-07-23 13:47:29 -04007408 context->recordError(gl::Error(GL_INVALID_ENUM));
7409 return 0;
Geoff Langbfdea662014-07-23 14:16:32 -04007410 }
7411
7412 if (flags != 0)
7413 {
Geoff Langb1196682014-07-23 13:47:29 -04007414 context->recordError(gl::Error(GL_INVALID_VALUE));
7415 return 0;
Geoff Langbfdea662014-07-23 14:16:32 -04007416 }
7417
Geoff Lang882033e2014-09-30 11:26:07 -04007418 GLsync fenceSync = context->createFenceSync();
7419
7420 gl::FenceSync *fenceSyncObject = context->getFenceSync(fenceSync);
7421 gl::Error error = fenceSyncObject->set(condition);
7422 if (error.isError())
7423 {
7424 context->deleteFenceSync(fenceSync);
7425 context->recordError(error);
7426 return NULL;
7427 }
7428
7429 return fenceSync;
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007430 }
7431
7432 return NULL;
7433}
7434
Kenneth Russell67ea1902014-10-06 16:44:50 -07007435GLboolean GL_APIENTRY glIsSync(GLsync sync)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007436{
7437 EVENT("(GLsync sync = 0x%0.8p)", sync);
7438
Geoff Langbfdea662014-07-23 14:16:32 -04007439 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04007440 if (context)
7441 {
7442 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007443 {
Geoff Langb1196682014-07-23 13:47:29 -04007444 context->recordError(gl::Error(GL_INVALID_OPERATION));
7445 return GL_FALSE;
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00007446 }
Geoff Langbfdea662014-07-23 14:16:32 -04007447
7448 return (context->getFenceSync(sync) != NULL);
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007449 }
7450
7451 return GL_FALSE;
7452}
7453
Kenneth Russell67ea1902014-10-06 16:44:50 -07007454void GL_APIENTRY glDeleteSync(GLsync sync)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007455{
7456 EVENT("(GLsync sync = 0x%0.8p)", sync);
7457
Geoff Langbfdea662014-07-23 14:16:32 -04007458 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04007459 if (context)
7460 {
7461 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007462 {
Geoff Langb1196682014-07-23 13:47:29 -04007463 context->recordError(gl::Error(GL_INVALID_OPERATION));
7464 return;
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00007465 }
Geoff Langbfdea662014-07-23 14:16:32 -04007466
7467 if (sync != static_cast<GLsync>(0) && !context->getFenceSync(sync))
7468 {
Geoff Langb1196682014-07-23 13:47:29 -04007469 context->recordError(gl::Error(GL_INVALID_VALUE));
7470 return;
Geoff Langbfdea662014-07-23 14:16:32 -04007471 }
7472
7473 context->deleteFenceSync(sync);
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007474 }
7475}
7476
Kenneth Russell67ea1902014-10-06 16:44:50 -07007477GLenum GL_APIENTRY glClientWaitSync(GLsync sync, GLbitfield flags, GLuint64 timeout)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007478{
7479 EVENT("(GLsync sync = 0x%0.8p, GLbitfield flags = 0x%X, GLuint64 timeout = %llu)",
7480 sync, flags, timeout);
7481
Geoff Langbfdea662014-07-23 14:16:32 -04007482 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04007483 if (context)
7484 {
7485 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007486 {
Geoff Langb1196682014-07-23 13:47:29 -04007487 context->recordError(gl::Error(GL_INVALID_OPERATION));
7488 return GL_WAIT_FAILED;
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00007489 }
Geoff Langbfdea662014-07-23 14:16:32 -04007490
7491 if ((flags & ~(GL_SYNC_FLUSH_COMMANDS_BIT)) != 0)
7492 {
Geoff Langb1196682014-07-23 13:47:29 -04007493 context->recordError(gl::Error(GL_INVALID_VALUE));
7494 return GL_WAIT_FAILED;
Geoff Langbfdea662014-07-23 14:16:32 -04007495 }
7496
7497 gl::FenceSync *fenceSync = context->getFenceSync(sync);
7498
7499 if (!fenceSync)
7500 {
Geoff Langb1196682014-07-23 13:47:29 -04007501 context->recordError(gl::Error(GL_INVALID_VALUE));
7502 return GL_WAIT_FAILED;
Geoff Langbfdea662014-07-23 14:16:32 -04007503 }
7504
Geoff Lang882033e2014-09-30 11:26:07 -04007505 GLenum result = GL_WAIT_FAILED;
7506 gl::Error error = fenceSync->clientWait(flags, timeout, &result);
7507 if (error.isError())
7508 {
7509 context->recordError(error);
7510 return GL_WAIT_FAILED;
7511 }
7512
7513 return result;
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007514 }
7515
7516 return GL_FALSE;
7517}
7518
Kenneth Russell67ea1902014-10-06 16:44:50 -07007519void GL_APIENTRY glWaitSync(GLsync sync, GLbitfield flags, GLuint64 timeout)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007520{
7521 EVENT("(GLsync sync = 0x%0.8p, GLbitfield flags = 0x%X, GLuint64 timeout = %llu)",
7522 sync, flags, timeout);
7523
Geoff Langbfdea662014-07-23 14:16:32 -04007524 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04007525 if (context)
7526 {
7527 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007528 {
Geoff Langb1196682014-07-23 13:47:29 -04007529 context->recordError(gl::Error(GL_INVALID_OPERATION));
7530 return;
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00007531 }
Geoff Langbfdea662014-07-23 14:16:32 -04007532
7533 if (flags != 0)
7534 {
Geoff Langb1196682014-07-23 13:47:29 -04007535 context->recordError(gl::Error(GL_INVALID_VALUE));
7536 return;
Geoff Langbfdea662014-07-23 14:16:32 -04007537 }
7538
7539 if (timeout != GL_TIMEOUT_IGNORED)
7540 {
Geoff Langb1196682014-07-23 13:47:29 -04007541 context->recordError(gl::Error(GL_INVALID_VALUE));
7542 return;
Geoff Langbfdea662014-07-23 14:16:32 -04007543 }
7544
7545 gl::FenceSync *fenceSync = context->getFenceSync(sync);
7546
7547 if (!fenceSync)
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
Kenneth Russellcaa549c2014-10-10 17:52:59 -07007553 gl::Error error = fenceSync->serverWait(flags, timeout);
Geoff Lang882033e2014-09-30 11:26:07 -04007554 if (error.isError())
7555 {
7556 context->recordError(error);
7557 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007558 }
7559}
7560
Kenneth Russell67ea1902014-10-06 16:44:50 -07007561void GL_APIENTRY glGetInteger64v(GLenum pname, GLint64* params)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007562{
7563 EVENT("(GLenum pname = 0x%X, GLint64* params = 0x%0.8p)",
7564 pname, params);
7565
Geoff Langbfdea662014-07-23 14:16:32 -04007566 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04007567 if (context)
7568 {
7569 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007570 {
Geoff Langb1196682014-07-23 13:47:29 -04007571 context->recordError(gl::Error(GL_INVALID_OPERATION));
7572 return;
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00007573 }
Geoff Langbfdea662014-07-23 14:16:32 -04007574
7575 GLenum nativeType;
7576 unsigned int numParams = 0;
7577 if (!ValidateStateQuery(context, pname, &nativeType, &numParams))
7578 {
7579 return;
7580 }
7581
7582 if (nativeType == GL_INT_64_ANGLEX)
7583 {
7584 context->getInteger64v(pname, params);
7585 }
7586 else
7587 {
7588 CastStateValues(context, nativeType, pname, numParams, params);
7589 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007590 }
7591}
7592
Kenneth Russell67ea1902014-10-06 16:44:50 -07007593void GL_APIENTRY glGetSynciv(GLsync sync, GLenum pname, GLsizei bufSize, GLsizei* length, GLint* values)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007594{
7595 EVENT("(GLsync sync = 0x%0.8p, GLenum pname = 0x%X, GLsizei bufSize = %d, GLsizei* length = 0x%0.8p, GLint* values = 0x%0.8p)",
7596 sync, pname, bufSize, length, values);
7597
Geoff Langbfdea662014-07-23 14:16:32 -04007598 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04007599 if (context)
7600 {
7601 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007602 {
Geoff Langb1196682014-07-23 13:47:29 -04007603 context->recordError(gl::Error(GL_INVALID_OPERATION));
7604 return;
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00007605 }
Geoff Langbfdea662014-07-23 14:16:32 -04007606
7607 if (bufSize < 0)
7608 {
Geoff Langb1196682014-07-23 13:47:29 -04007609 context->recordError(gl::Error(GL_INVALID_VALUE));
7610 return;
Geoff Langbfdea662014-07-23 14:16:32 -04007611 }
7612
7613 gl::FenceSync *fenceSync = context->getFenceSync(sync);
7614
7615 if (!fenceSync)
7616 {
Geoff Langb1196682014-07-23 13:47:29 -04007617 context->recordError(gl::Error(GL_INVALID_VALUE));
7618 return;
Geoff Langbfdea662014-07-23 14:16:32 -04007619 }
7620
7621 switch (pname)
7622 {
7623 case GL_OBJECT_TYPE: values[0] = static_cast<GLint>(GL_SYNC_FENCE); break;
Geoff Langbfdea662014-07-23 14:16:32 -04007624 case GL_SYNC_CONDITION: values[0] = static_cast<GLint>(fenceSync->getCondition()); break;
7625 case GL_SYNC_FLAGS: values[0] = 0; break;
7626
Geoff Lang882033e2014-09-30 11:26:07 -04007627 case GL_SYNC_STATUS:
7628 {
7629 gl::Error error = fenceSync->getStatus(values);
7630 if (error.isError())
7631 {
7632 context->recordError(error);
7633 return;
7634 }
7635 break;
7636 }
7637
Geoff Langbfdea662014-07-23 14:16:32 -04007638 default:
Geoff Langb1196682014-07-23 13:47:29 -04007639 context->recordError(gl::Error(GL_INVALID_ENUM));
7640 return;
Geoff Langbfdea662014-07-23 14:16:32 -04007641 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007642 }
7643}
7644
Kenneth Russell67ea1902014-10-06 16:44:50 -07007645void GL_APIENTRY glGetInteger64i_v(GLenum target, GLuint index, GLint64* data)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007646{
7647 EVENT("(GLenum target = 0x%X, GLuint index = %u, GLint64* data = 0x%0.8p)",
7648 target, index, data);
7649
Geoff Langbfdea662014-07-23 14:16:32 -04007650 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04007651 if (context)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007652 {
Geoff Langbfdea662014-07-23 14:16:32 -04007653 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007654 {
Geoff Langb1196682014-07-23 13:47:29 -04007655 context->recordError(gl::Error(GL_INVALID_OPERATION));
7656 return;
Geoff Langbfdea662014-07-23 14:16:32 -04007657 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007658
Geoff Lang3a61c322014-07-10 13:01:54 -04007659 const gl::Caps &caps = context->getCaps();
Geoff Langbfdea662014-07-23 14:16:32 -04007660 switch (target)
7661 {
7662 case GL_TRANSFORM_FEEDBACK_BUFFER_START:
7663 case GL_TRANSFORM_FEEDBACK_BUFFER_SIZE:
7664 case GL_TRANSFORM_FEEDBACK_BUFFER_BINDING:
Geoff Lang05881a02014-07-10 14:05:30 -04007665 if (index >= caps.maxTransformFeedbackSeparateAttributes)
7666 {
Geoff Langb1196682014-07-23 13:47:29 -04007667 context->recordError(gl::Error(GL_INVALID_VALUE));
7668 return;
Geoff Lang05881a02014-07-10 14:05:30 -04007669 }
Geoff Langbfdea662014-07-23 14:16:32 -04007670 break;
Geoff Langb1196682014-07-23 13:47:29 -04007671
Geoff Langbfdea662014-07-23 14:16:32 -04007672 case GL_UNIFORM_BUFFER_START:
7673 case GL_UNIFORM_BUFFER_SIZE:
7674 case GL_UNIFORM_BUFFER_BINDING:
Geoff Lang3a61c322014-07-10 13:01:54 -04007675 if (index >= caps.maxUniformBufferBindings)
7676 {
Geoff Langb1196682014-07-23 13:47:29 -04007677 context->recordError(gl::Error(GL_INVALID_VALUE));
7678 return;
Geoff Lang3a61c322014-07-10 13:01:54 -04007679 }
Geoff Langbfdea662014-07-23 14:16:32 -04007680 break;
Geoff Langb1196682014-07-23 13:47:29 -04007681
Geoff Langbfdea662014-07-23 14:16:32 -04007682 default:
Geoff Langb1196682014-07-23 13:47:29 -04007683 context->recordError(gl::Error(GL_INVALID_ENUM));
7684 return;
Geoff Langbfdea662014-07-23 14:16:32 -04007685 }
7686
7687 if (!(context->getIndexedInteger64v(target, index, data)))
7688 {
7689 GLenum nativeType;
7690 unsigned int numParams = 0;
7691 if (!context->getIndexedQueryParameterInfo(target, &nativeType, &numParams))
Geoff Langb1196682014-07-23 13:47:29 -04007692 {
7693 context->recordError(gl::Error(GL_INVALID_ENUM));
7694 return;
7695 }
Shannon Woods15934d52013-08-19 14:28:49 -04007696
Geoff Langbfdea662014-07-23 14:16:32 -04007697 if (numParams == 0)
7698 return; // it is known that pname is valid, but there are no parameters to return
7699
7700 if (nativeType == GL_INT)
Shannon Woods15934d52013-08-19 14:28:49 -04007701 {
Geoff Langbfdea662014-07-23 14:16:32 -04007702 GLint *intParams = new GLint[numParams];
Shannon Woods15934d52013-08-19 14:28:49 -04007703
Geoff Langbfdea662014-07-23 14:16:32 -04007704 context->getIndexedIntegerv(target, index, intParams);
Shannon Woods15934d52013-08-19 14:28:49 -04007705
Geoff Langbfdea662014-07-23 14:16:32 -04007706 for (unsigned int i = 0; i < numParams; ++i)
Shannon Woods15934d52013-08-19 14:28:49 -04007707 {
Geoff Langbfdea662014-07-23 14:16:32 -04007708 data[i] = static_cast<GLint64>(intParams[i]);
Shannon Woods15934d52013-08-19 14:28:49 -04007709 }
Geoff Langbfdea662014-07-23 14:16:32 -04007710
7711 delete [] intParams;
7712 }
7713 else
7714 {
7715 UNREACHABLE();
Shannon Woods15934d52013-08-19 14:28:49 -04007716 }
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00007717 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007718 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007719}
7720
Kenneth Russell67ea1902014-10-06 16:44:50 -07007721void GL_APIENTRY glGetBufferParameteri64v(GLenum target, GLenum pname, GLint64* params)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007722{
7723 EVENT("(GLenum target = 0x%X, GLenum pname = 0x%X, GLint64* params = 0x%0.8p)",
7724 target, pname, params);
7725
Geoff Langbfdea662014-07-23 14:16:32 -04007726 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04007727 if (context)
7728 {
7729 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007730 {
Geoff Langb1196682014-07-23 13:47:29 -04007731 context->recordError(gl::Error(GL_INVALID_OPERATION));
7732 return;
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00007733 }
Geoff Langbfdea662014-07-23 14:16:32 -04007734
7735 if (!gl::ValidBufferTarget(context, target))
7736 {
Geoff Langb1196682014-07-23 13:47:29 -04007737 context->recordError(gl::Error(GL_INVALID_ENUM));
7738 return;
Geoff Langbfdea662014-07-23 14:16:32 -04007739 }
7740
7741 if (!gl::ValidBufferParameter(context, pname))
7742 {
Geoff Langb1196682014-07-23 13:47:29 -04007743 context->recordError(gl::Error(GL_INVALID_ENUM));
7744 return;
Geoff Langbfdea662014-07-23 14:16:32 -04007745 }
7746
7747 gl::Buffer *buffer = context->getState().getTargetBuffer(target);
7748
7749 if (!buffer)
7750 {
7751 // A null buffer means that "0" is bound to the requested buffer target
Geoff Langb1196682014-07-23 13:47:29 -04007752 context->recordError(gl::Error(GL_INVALID_OPERATION));
7753 return;
Geoff Langbfdea662014-07-23 14:16:32 -04007754 }
7755
7756 switch (pname)
7757 {
7758 case GL_BUFFER_USAGE:
7759 *params = static_cast<GLint64>(buffer->getUsage());
7760 break;
7761 case GL_BUFFER_SIZE:
7762 *params = buffer->getSize();
7763 break;
7764 case GL_BUFFER_ACCESS_FLAGS:
7765 *params = static_cast<GLint64>(buffer->getAccessFlags());
7766 break;
7767 case GL_BUFFER_MAPPED:
7768 *params = static_cast<GLint64>(buffer->isMapped());
7769 break;
7770 case GL_BUFFER_MAP_OFFSET:
7771 *params = buffer->getMapOffset();
7772 break;
7773 case GL_BUFFER_MAP_LENGTH:
7774 *params = buffer->getMapLength();
7775 break;
7776 default: UNREACHABLE(); break;
7777 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007778 }
7779}
7780
Kenneth Russell67ea1902014-10-06 16:44:50 -07007781void GL_APIENTRY glGenSamplers(GLsizei count, GLuint* samplers)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007782{
7783 EVENT("(GLsizei count = %d, GLuint* samplers = 0x%0.8p)", count, samplers);
7784
Geoff Langbfdea662014-07-23 14:16:32 -04007785 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04007786 if (context)
7787 {
7788 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007789 {
Geoff Langb1196682014-07-23 13:47:29 -04007790 context->recordError(gl::Error(GL_INVALID_OPERATION));
7791 return;
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00007792 }
Geoff Langbfdea662014-07-23 14:16:32 -04007793
7794 if (count < 0)
7795 {
Geoff Langb1196682014-07-23 13:47:29 -04007796 context->recordError(gl::Error(GL_INVALID_VALUE));
7797 return;
Geoff Langbfdea662014-07-23 14:16:32 -04007798 }
7799
7800 for (int i = 0; i < count; i++)
7801 {
7802 samplers[i] = context->createSampler();
7803 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007804 }
7805}
7806
Kenneth Russell67ea1902014-10-06 16:44:50 -07007807void GL_APIENTRY glDeleteSamplers(GLsizei count, const GLuint* samplers)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007808{
7809 EVENT("(GLsizei count = %d, const GLuint* samplers = 0x%0.8p)", count, samplers);
7810
Geoff Langbfdea662014-07-23 14:16:32 -04007811 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04007812 if (context)
7813 {
7814 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007815 {
Geoff Langb1196682014-07-23 13:47:29 -04007816 context->recordError(gl::Error(GL_INVALID_OPERATION));
7817 return;
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00007818 }
Geoff Langbfdea662014-07-23 14:16:32 -04007819
7820 if (count < 0)
7821 {
Geoff Langb1196682014-07-23 13:47:29 -04007822 context->recordError(gl::Error(GL_INVALID_VALUE));
7823 return;
Geoff Langbfdea662014-07-23 14:16:32 -04007824 }
7825
7826 for (int i = 0; i < count; i++)
7827 {
7828 context->deleteSampler(samplers[i]);
7829 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007830 }
7831}
7832
Kenneth Russell67ea1902014-10-06 16:44:50 -07007833GLboolean GL_APIENTRY glIsSampler(GLuint sampler)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007834{
7835 EVENT("(GLuint sampler = %u)", sampler);
7836
Geoff Langbfdea662014-07-23 14:16:32 -04007837 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04007838 if (context)
7839 {
7840 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007841 {
Geoff Langb1196682014-07-23 13:47:29 -04007842 context->recordError(gl::Error(GL_INVALID_OPERATION));
7843 return GL_FALSE;
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00007844 }
Geoff Langbfdea662014-07-23 14:16:32 -04007845
7846 return context->isSampler(sampler);
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007847 }
7848
7849 return GL_FALSE;
7850}
7851
Kenneth Russell67ea1902014-10-06 16:44:50 -07007852void GL_APIENTRY glBindSampler(GLuint unit, GLuint sampler)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007853{
7854 EVENT("(GLuint unit = %u, GLuint sampler = %u)", unit, sampler);
7855
Geoff Langbfdea662014-07-23 14:16:32 -04007856 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04007857 if (context)
7858 {
7859 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007860 {
Geoff Langb1196682014-07-23 13:47:29 -04007861 context->recordError(gl::Error(GL_INVALID_OPERATION));
7862 return;
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00007863 }
Geoff Langbfdea662014-07-23 14:16:32 -04007864
7865 if (sampler != 0 && !context->isSampler(sampler))
7866 {
Geoff Langb1196682014-07-23 13:47:29 -04007867 context->recordError(gl::Error(GL_INVALID_OPERATION));
7868 return;
Geoff Langbfdea662014-07-23 14:16:32 -04007869 }
7870
Geoff Lang3a61c322014-07-10 13:01:54 -04007871 if (unit >= context->getCaps().maxCombinedTextureImageUnits)
Geoff Langbfdea662014-07-23 14:16:32 -04007872 {
Geoff Langb1196682014-07-23 13:47:29 -04007873 context->recordError(gl::Error(GL_INVALID_VALUE));
7874 return;
Geoff Langbfdea662014-07-23 14:16:32 -04007875 }
7876
7877 context->bindSampler(unit, sampler);
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007878 }
7879}
7880
Kenneth Russell67ea1902014-10-06 16:44:50 -07007881void GL_APIENTRY glSamplerParameteri(GLuint sampler, GLenum pname, GLint param)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007882{
7883 EVENT("(GLuint sampler = %u, GLenum pname = 0x%X, GLint param = %d)", sampler, pname, param);
7884
Geoff Langbfdea662014-07-23 14:16:32 -04007885 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04007886 if (context)
7887 {
7888 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007889 {
Geoff Langb1196682014-07-23 13:47:29 -04007890 context->recordError(gl::Error(GL_INVALID_OPERATION));
7891 return;
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00007892 }
Geoff Langbfdea662014-07-23 14:16:32 -04007893
Geoff Langb1196682014-07-23 13:47:29 -04007894 if (!gl::ValidateSamplerObjectParameter(context, pname))
Geoff Langbfdea662014-07-23 14:16:32 -04007895 {
7896 return;
7897 }
7898
7899 if (!gl::ValidateTexParamParameters(context, pname, param))
7900 {
7901 return;
7902 }
7903
7904 if (!context->isSampler(sampler))
7905 {
Geoff Langb1196682014-07-23 13:47:29 -04007906 context->recordError(gl::Error(GL_INVALID_OPERATION));
7907 return;
Geoff Langbfdea662014-07-23 14:16:32 -04007908 }
7909
7910 context->samplerParameteri(sampler, pname, param);
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007911 }
7912}
7913
Kenneth Russell67ea1902014-10-06 16:44:50 -07007914void GL_APIENTRY glSamplerParameteriv(GLuint sampler, GLenum pname, const GLint* param)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007915{
Jamie Madillf6cc8cc2013-07-03 12:44:15 -04007916 glSamplerParameteri(sampler, pname, *param);
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007917}
7918
Kenneth Russell67ea1902014-10-06 16:44:50 -07007919void GL_APIENTRY glSamplerParameterf(GLuint sampler, GLenum pname, GLfloat param)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007920{
7921 EVENT("(GLuint sampler = %u, GLenum pname = 0x%X, GLfloat param = %g)", sampler, pname, param);
7922
Geoff Langbfdea662014-07-23 14:16:32 -04007923 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04007924 if (context)
7925 {
7926 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007927 {
Geoff Langb1196682014-07-23 13:47:29 -04007928 context->recordError(gl::Error(GL_INVALID_OPERATION));
7929 return;
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00007930 }
Geoff Langbfdea662014-07-23 14:16:32 -04007931
Geoff Langb1196682014-07-23 13:47:29 -04007932 if (!gl::ValidateSamplerObjectParameter(context, pname))
Geoff Langbfdea662014-07-23 14:16:32 -04007933 {
7934 return;
7935 }
7936
7937 if (!gl::ValidateTexParamParameters(context, pname, static_cast<GLint>(param)))
7938 {
7939 return;
7940 }
7941
7942 if (!context->isSampler(sampler))
7943 {
Geoff Langb1196682014-07-23 13:47:29 -04007944 context->recordError(gl::Error(GL_INVALID_OPERATION));
7945 return;
Geoff Langbfdea662014-07-23 14:16:32 -04007946 }
7947
7948 context->samplerParameterf(sampler, pname, param);
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007949 }
7950}
7951
Kenneth Russell67ea1902014-10-06 16:44:50 -07007952void GL_APIENTRY glSamplerParameterfv(GLuint sampler, GLenum pname, const GLfloat* param)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007953{
Jamie Madillf6cc8cc2013-07-03 12:44:15 -04007954 glSamplerParameterf(sampler, pname, *param);
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007955}
7956
Kenneth Russell67ea1902014-10-06 16:44:50 -07007957void GL_APIENTRY glGetSamplerParameteriv(GLuint sampler, GLenum pname, GLint* params)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007958{
7959 EVENT("(GLuint sampler = %u, GLenum pname = 0x%X, GLint* params = 0x%0.8p)", sampler, pname, params);
7960
Geoff Langbfdea662014-07-23 14:16:32 -04007961 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04007962 if (context)
7963 {
7964 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007965 {
Geoff Langb1196682014-07-23 13:47:29 -04007966 context->recordError(gl::Error(GL_INVALID_OPERATION));
7967 return;
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00007968 }
Geoff Langbfdea662014-07-23 14:16:32 -04007969
Geoff Langb1196682014-07-23 13:47:29 -04007970 if (!gl::ValidateSamplerObjectParameter(context, pname))
Geoff Langbfdea662014-07-23 14:16:32 -04007971 {
7972 return;
7973 }
7974
7975 if (!context->isSampler(sampler))
7976 {
Geoff Langb1196682014-07-23 13:47:29 -04007977 context->recordError(gl::Error(GL_INVALID_OPERATION));
7978 return;
Geoff Langbfdea662014-07-23 14:16:32 -04007979 }
7980
7981 *params = context->getSamplerParameteri(sampler, pname);
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007982 }
7983}
7984
Kenneth Russell67ea1902014-10-06 16:44:50 -07007985void GL_APIENTRY glGetSamplerParameterfv(GLuint sampler, GLenum pname, GLfloat* params)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007986{
7987 EVENT("(GLuint sample = %ur, GLenum pname = 0x%X, GLfloat* params = 0x%0.8p)", sampler, pname, params);
7988
Geoff Langbfdea662014-07-23 14:16:32 -04007989 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04007990 if (context)
7991 {
7992 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007993 {
Geoff Langb1196682014-07-23 13:47:29 -04007994 context->recordError(gl::Error(GL_INVALID_OPERATION));
7995 return;
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00007996 }
Geoff Langbfdea662014-07-23 14:16:32 -04007997
Geoff Langb1196682014-07-23 13:47:29 -04007998 if (!gl::ValidateSamplerObjectParameter(context, pname))
Geoff Langbfdea662014-07-23 14:16:32 -04007999 {
8000 return;
8001 }
8002
8003 if (!context->isSampler(sampler))
8004 {
Geoff Langb1196682014-07-23 13:47:29 -04008005 context->recordError(gl::Error(GL_INVALID_OPERATION));
8006 return;
Geoff Langbfdea662014-07-23 14:16:32 -04008007 }
8008
8009 *params = context->getSamplerParameterf(sampler, pname);
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008010 }
8011}
8012
Kenneth Russell67ea1902014-10-06 16:44:50 -07008013void GL_APIENTRY glVertexAttribDivisor(GLuint index, GLuint divisor)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008014{
8015 EVENT("(GLuint index = %u, GLuint divisor = %u)", index, divisor);
8016
Geoff Langbfdea662014-07-23 14:16:32 -04008017 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04008018 if (context)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008019 {
Geoff Langbfdea662014-07-23 14:16:32 -04008020 if (context->getClientVersion() < 3)
8021 {
Geoff Langb1196682014-07-23 13:47:29 -04008022 context->recordError(gl::Error(GL_INVALID_OPERATION));
8023 return;
8024 }
8025
8026 if (index >= gl::MAX_VERTEX_ATTRIBS)
8027 {
8028 context->recordError(gl::Error(GL_INVALID_VALUE));
8029 return;
Geoff Langbfdea662014-07-23 14:16:32 -04008030 }
8031
8032 context->setVertexAttribDivisor(index, divisor);
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008033 }
8034}
8035
Kenneth Russell67ea1902014-10-06 16:44:50 -07008036void GL_APIENTRY glBindTransformFeedback(GLenum target, GLuint id)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008037{
8038 EVENT("(GLenum target = 0x%X, GLuint id = %u)", target, id);
8039
Geoff Langbfdea662014-07-23 14:16:32 -04008040 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04008041 if (context)
8042 {
8043 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008044 {
Geoff Langb1196682014-07-23 13:47:29 -04008045 context->recordError(gl::Error(GL_INVALID_OPERATION));
8046 return;
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00008047 }
Geoff Langbfdea662014-07-23 14:16:32 -04008048
8049 switch (target)
8050 {
8051 case GL_TRANSFORM_FEEDBACK:
8052 {
8053 // Cannot bind a transform feedback object if the current one is started and not paused (3.0.2 pg 85 section 2.14.1)
8054 gl::TransformFeedback *curTransformFeedback = context->getState().getCurrentTransformFeedback();
8055 if (curTransformFeedback && curTransformFeedback->isStarted() && !curTransformFeedback->isPaused())
8056 {
Geoff Langb1196682014-07-23 13:47:29 -04008057 context->recordError(gl::Error(GL_INVALID_OPERATION));
8058 return;
Geoff Langbfdea662014-07-23 14:16:32 -04008059 }
8060
8061 // Cannot bind a transform feedback object that does not exist (3.0.2 pg 85 section 2.14.1)
8062 if (context->getTransformFeedback(id) == NULL)
8063 {
Geoff Langb1196682014-07-23 13:47:29 -04008064 context->recordError(gl::Error(GL_INVALID_OPERATION));
8065 return;
Geoff Langbfdea662014-07-23 14:16:32 -04008066 }
8067
8068 context->bindTransformFeedback(id);
8069 }
8070 break;
8071
8072 default:
Geoff Langb1196682014-07-23 13:47:29 -04008073 context->recordError(gl::Error(GL_INVALID_ENUM));
8074 return;
Geoff Langbfdea662014-07-23 14:16:32 -04008075 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008076 }
8077}
8078
Kenneth Russell67ea1902014-10-06 16:44:50 -07008079void GL_APIENTRY glDeleteTransformFeedbacks(GLsizei n, const GLuint* ids)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008080{
8081 EVENT("(GLsizei n = %d, const GLuint* ids = 0x%0.8p)", n, ids);
8082
Geoff Langbfdea662014-07-23 14:16:32 -04008083 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04008084 if (context)
8085 {
8086 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008087 {
Geoff Langb1196682014-07-23 13:47:29 -04008088 context->recordError(gl::Error(GL_INVALID_OPERATION));
8089 return;
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00008090 }
Geoff Langbfdea662014-07-23 14:16:32 -04008091
8092 for (int i = 0; i < n; i++)
8093 {
8094 context->deleteTransformFeedback(ids[i]);
8095 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008096 }
8097}
8098
Kenneth Russell67ea1902014-10-06 16:44:50 -07008099void GL_APIENTRY glGenTransformFeedbacks(GLsizei n, GLuint* ids)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008100{
8101 EVENT("(GLsizei n = %d, GLuint* ids = 0x%0.8p)", n, ids);
8102
Geoff Langbfdea662014-07-23 14:16:32 -04008103 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04008104 if (context)
8105 {
8106 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008107 {
Geoff Langb1196682014-07-23 13:47:29 -04008108 context->recordError(gl::Error(GL_INVALID_OPERATION));
8109 return;
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00008110 }
Geoff Langbfdea662014-07-23 14:16:32 -04008111
8112 for (int i = 0; i < n; i++)
8113 {
8114 ids[i] = context->createTransformFeedback();
8115 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008116 }
8117}
8118
Kenneth Russell67ea1902014-10-06 16:44:50 -07008119GLboolean GL_APIENTRY glIsTransformFeedback(GLuint id)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008120{
8121 EVENT("(GLuint id = %u)", id);
8122
Geoff Langbfdea662014-07-23 14:16:32 -04008123 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04008124 if (context)
8125 {
8126 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008127 {
Geoff Langb1196682014-07-23 13:47:29 -04008128 context->recordError(gl::Error(GL_INVALID_OPERATION));
8129 return GL_FALSE;
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00008130 }
Geoff Langbfdea662014-07-23 14:16:32 -04008131
8132 return ((context->getTransformFeedback(id) != NULL) ? GL_TRUE : GL_FALSE);
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008133 }
8134
8135 return GL_FALSE;
8136}
8137
Kenneth Russell67ea1902014-10-06 16:44:50 -07008138void GL_APIENTRY glPauseTransformFeedback(void)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008139{
8140 EVENT("(void)");
8141
Geoff Langbfdea662014-07-23 14:16:32 -04008142 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04008143 if (context)
8144 {
8145 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008146 {
Geoff Langb1196682014-07-23 13:47:29 -04008147 context->recordError(gl::Error(GL_INVALID_OPERATION));
8148 return;
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00008149 }
Geoff Langbfdea662014-07-23 14:16:32 -04008150
8151 gl::TransformFeedback *transformFeedback = context->getState().getCurrentTransformFeedback();
8152 ASSERT(transformFeedback != NULL);
8153
8154 // Current transform feedback must be started and not paused in order to pause (3.0.2 pg 86)
8155 if (!transformFeedback->isStarted() || transformFeedback->isPaused())
8156 {
Geoff Langb1196682014-07-23 13:47:29 -04008157 context->recordError(gl::Error(GL_INVALID_OPERATION));
8158 return;
Geoff Langbfdea662014-07-23 14:16:32 -04008159 }
8160
8161 transformFeedback->pause();
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008162 }
8163}
8164
Kenneth Russell67ea1902014-10-06 16:44:50 -07008165void GL_APIENTRY glResumeTransformFeedback(void)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008166{
8167 EVENT("(void)");
8168
Geoff Langbfdea662014-07-23 14:16:32 -04008169 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04008170 if (context)
8171 {
8172 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008173 {
Geoff Langb1196682014-07-23 13:47:29 -04008174 context->recordError(gl::Error(GL_INVALID_OPERATION));
8175 return;
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00008176 }
Geoff Langbfdea662014-07-23 14:16:32 -04008177
8178 gl::TransformFeedback *transformFeedback = context->getState().getCurrentTransformFeedback();
8179 ASSERT(transformFeedback != NULL);
8180
8181 // Current transform feedback must be started and paused in order to resume (3.0.2 pg 86)
8182 if (!transformFeedback->isStarted() || !transformFeedback->isPaused())
8183 {
Geoff Langb1196682014-07-23 13:47:29 -04008184 context->recordError(gl::Error(GL_INVALID_OPERATION));
8185 return;
Geoff Langbfdea662014-07-23 14:16:32 -04008186 }
8187
8188 transformFeedback->resume();
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008189 }
8190}
8191
Kenneth Russell67ea1902014-10-06 16:44:50 -07008192void GL_APIENTRY glGetProgramBinary(GLuint program, GLsizei bufSize, GLsizei* length, GLenum* binaryFormat, GLvoid* binary)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008193{
8194 EVENT("(GLuint program = %u, GLsizei bufSize = %d, GLsizei* length = 0x%0.8p, GLenum* binaryFormat = 0x%0.8p, GLvoid* binary = 0x%0.8p)",
8195 program, bufSize, length, binaryFormat, binary);
8196
Geoff Langbfdea662014-07-23 14:16:32 -04008197 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04008198 if (context)
8199 {
8200 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008201 {
Geoff Langb1196682014-07-23 13:47:29 -04008202 context->recordError(gl::Error(GL_INVALID_OPERATION));
8203 return;
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00008204 }
Geoff Langbfdea662014-07-23 14:16:32 -04008205
8206 // glGetProgramBinary
8207 UNIMPLEMENTED();
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008208 }
8209}
8210
Kenneth Russell67ea1902014-10-06 16:44:50 -07008211void GL_APIENTRY glProgramBinary(GLuint program, GLenum binaryFormat, const GLvoid* binary, GLsizei length)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008212{
8213 EVENT("(GLuint program = %u, GLenum binaryFormat = 0x%X, const GLvoid* binary = 0x%0.8p, GLsizei length = %d)",
8214 program, binaryFormat, binary, length);
8215
Geoff Langbfdea662014-07-23 14:16:32 -04008216 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04008217 if (context)
8218 {
8219 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008220 {
Geoff Langb1196682014-07-23 13:47:29 -04008221 context->recordError(gl::Error(GL_INVALID_OPERATION));
8222 return;
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00008223 }
Geoff Langbfdea662014-07-23 14:16:32 -04008224
8225 // glProgramBinary
8226 UNIMPLEMENTED();
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008227 }
8228}
8229
Kenneth Russell67ea1902014-10-06 16:44:50 -07008230void GL_APIENTRY glProgramParameteri(GLuint program, GLenum pname, GLint value)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008231{
8232 EVENT("(GLuint program = %u, GLenum pname = 0x%X, GLint value = %d)",
8233 program, pname, value);
8234
Geoff Langbfdea662014-07-23 14:16:32 -04008235 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04008236 if (context)
8237 {
8238 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008239 {
Geoff Langb1196682014-07-23 13:47:29 -04008240 context->recordError(gl::Error(GL_INVALID_OPERATION));
8241 return;
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00008242 }
Geoff Langbfdea662014-07-23 14:16:32 -04008243
8244 // glProgramParameteri
8245 UNIMPLEMENTED();
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008246 }
8247}
8248
Kenneth Russell67ea1902014-10-06 16:44:50 -07008249void GL_APIENTRY glInvalidateFramebuffer(GLenum target, GLsizei numAttachments, const GLenum* attachments)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008250{
8251 EVENT("(GLenum target = 0x%X, GLsizei numAttachments = %d, const GLenum* attachments = 0x%0.8p)",
8252 target, numAttachments, attachments);
8253
Geoff Langbfdea662014-07-23 14:16:32 -04008254 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04008255 if (context)
8256 {
8257 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008258 {
Geoff Langb1196682014-07-23 13:47:29 -04008259 context->recordError(gl::Error(GL_INVALID_OPERATION));
8260 return;
shannonwoods@chromium.orgd63ef892013-05-30 00:10:56 +00008261 }
Geoff Langbfdea662014-07-23 14:16:32 -04008262
8263 if (!ValidateInvalidateFramebufferParameters(context, target, numAttachments, attachments))
8264 {
8265 return;
8266 }
8267
Jamie Madill2d96b9e2014-08-29 15:46:47 -04008268 gl::Framebuffer *framebuffer = context->getState().getTargetFramebuffer(target);
Jamie Madill48faf802014-11-06 15:27:22 -05008269 ASSERT(framebuffer);
8270
8271 if (framebuffer->completeness(context->getData()) == GL_FRAMEBUFFER_COMPLETE)
Jamie Madill2d96b9e2014-08-29 15:46:47 -04008272 {
Geoff Lang64f23f62014-09-10 14:40:12 -04008273 gl::Error error = framebuffer->invalidate(context->getCaps(), numAttachments, attachments);
8274 if (error.isError())
8275 {
8276 context->recordError(error);
8277 return;
8278 }
Jamie Madill2d96b9e2014-08-29 15:46:47 -04008279 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008280 }
8281}
8282
Kenneth Russell67ea1902014-10-06 16:44:50 -07008283void 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 +00008284{
8285 EVENT("(GLenum target = 0x%X, GLsizei numAttachments = %d, const GLenum* attachments = 0x%0.8p, GLint x = %d, "
8286 "GLint y = %d, GLsizei width = %d, GLsizei height = %d)",
8287 target, numAttachments, attachments, x, y, width, height);
8288
Geoff Langbfdea662014-07-23 14:16:32 -04008289 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04008290 if (context)
8291 {
8292 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008293 {
Geoff Langb1196682014-07-23 13:47:29 -04008294 context->recordError(gl::Error(GL_INVALID_OPERATION));
8295 return;
shannonwoods@chromium.orgd63ef892013-05-30 00:10:56 +00008296 }
Geoff Langbfdea662014-07-23 14:16:32 -04008297
8298 if (!ValidateInvalidateFramebufferParameters(context, target, numAttachments, attachments))
8299 {
8300 return;
8301 }
8302
Jamie Madill2d96b9e2014-08-29 15:46:47 -04008303 gl::Framebuffer *framebuffer = context->getState().getTargetFramebuffer(target);
Jamie Madill48faf802014-11-06 15:27:22 -05008304 ASSERT(framebuffer);
8305
8306 if (framebuffer->completeness(context->getData()) == GL_FRAMEBUFFER_COMPLETE)
Jamie Madill2d96b9e2014-08-29 15:46:47 -04008307 {
Geoff Lang64f23f62014-09-10 14:40:12 -04008308 gl::Error error = framebuffer->invalidateSub(numAttachments, attachments, x, y, width, height);
8309 if (error.isError())
8310 {
8311 context->recordError(error);
8312 return;
8313 }
Jamie Madill2d96b9e2014-08-29 15:46:47 -04008314 }
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
Jamie Madill48faf802014-11-06 15:27:22 -05008596 ASSERT(context->getState().getDrawFramebuffer());
8597
Geoff Langbfdea662014-07-23 14:16:32 -04008598 if (context->getState().getDrawFramebuffer()->id() == 0)
8599 {
8600 if (n != 1)
shannon.woods%transgaming.com@gtempaccount.com4059a382013-04-13 03:31:16 +00008601 {
Geoff Langb1196682014-07-23 13:47:29 -04008602 context->recordError(gl::Error(GL_INVALID_OPERATION));
8603 return;
shannon.woods%transgaming.com@gtempaccount.com4059a382013-04-13 03:31:16 +00008604 }
8605
Geoff Langbfdea662014-07-23 14:16:32 -04008606 if (bufs[0] != GL_NONE && bufs[0] != GL_BACK)
shannon.woods%transgaming.com@gtempaccount.com4059a382013-04-13 03:31:16 +00008607 {
Geoff Langb1196682014-07-23 13:47:29 -04008608 context->recordError(gl::Error(GL_INVALID_OPERATION));
8609 return;
shannon.woods%transgaming.com@gtempaccount.com2fa73c52013-04-13 03:37:20 +00008610 }
shannon.woods%transgaming.com@gtempaccount.com4059a382013-04-13 03:31:16 +00008611 }
Geoff Langbfdea662014-07-23 14:16:32 -04008612 else
8613 {
8614 for (int colorAttachment = 0; colorAttachment < n; colorAttachment++)
8615 {
8616 const GLenum attachment = GL_COLOR_ATTACHMENT0_EXT + colorAttachment;
8617 if (bufs[colorAttachment] != GL_NONE && bufs[colorAttachment] != attachment)
8618 {
Geoff Langb1196682014-07-23 13:47:29 -04008619 context->recordError(gl::Error(GL_INVALID_OPERATION));
8620 return;
Geoff Langbfdea662014-07-23 14:16:32 -04008621 }
8622 }
8623 }
8624
8625 gl::Framebuffer *framebuffer = context->getState().getDrawFramebuffer();
Jamie Madill48faf802014-11-06 15:27:22 -05008626 ASSERT(framebuffer);
Geoff Langbfdea662014-07-23 14:16:32 -04008627
8628 for (unsigned int colorAttachment = 0; colorAttachment < static_cast<unsigned int>(n); colorAttachment++)
8629 {
8630 framebuffer->setDrawBufferState(colorAttachment, bufs[colorAttachment]);
8631 }
8632
8633 for (unsigned int colorAttachment = n; colorAttachment < context->getCaps().maxDrawBuffers; colorAttachment++)
8634 {
8635 framebuffer->setDrawBufferState(colorAttachment, GL_NONE);
8636 }
shannon.woods%transgaming.com@gtempaccount.com4059a382013-04-13 03:31:16 +00008637 }
8638}
8639
Kenneth Russell67ea1902014-10-06 16:44:50 -07008640void GL_APIENTRY glGetBufferPointervOES(GLenum target, GLenum pname, void** params)
Shannon Woodsb3801742014-03-27 14:59:19 -04008641{
8642 EVENT("(GLenum target = 0x%X, GLenum pname = 0x%X, GLvoid** params = 0x%0.8p)", target, pname, params);
8643
Geoff Langbfdea662014-07-23 14:16:32 -04008644 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04008645 if (context)
8646 {
8647 if (!gl::ValidBufferTarget(context, target))
Shannon Woodsb3801742014-03-27 14:59:19 -04008648 {
Geoff Langb1196682014-07-23 13:47:29 -04008649 context->recordError(gl::Error(GL_INVALID_ENUM));
8650 return;
Shannon Woodsb3801742014-03-27 14:59:19 -04008651 }
Geoff Langbfdea662014-07-23 14:16:32 -04008652
8653 if (pname != GL_BUFFER_MAP_POINTER)
8654 {
Geoff Langb1196682014-07-23 13:47:29 -04008655 context->recordError(gl::Error(GL_INVALID_ENUM));
8656 return;
Geoff Langbfdea662014-07-23 14:16:32 -04008657 }
8658
8659 gl::Buffer *buffer = context->getState().getTargetBuffer(target);
8660
8661 if (!buffer || !buffer->isMapped())
8662 {
8663 *params = NULL;
8664 }
8665 else
8666 {
8667 *params = buffer->getMapPointer();
8668 }
Shannon Woodsb3801742014-03-27 14:59:19 -04008669 }
8670}
8671
Kenneth Russell67ea1902014-10-06 16:44:50 -07008672void * GL_APIENTRY glMapBufferOES(GLenum target, GLenum access)
Shannon Woodsb3801742014-03-27 14:59:19 -04008673{
8674 EVENT("(GLenum target = 0x%X, GLbitfield access = 0x%X)", target, access);
8675
Geoff Langbfdea662014-07-23 14:16:32 -04008676 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04008677 if (context)
8678 {
8679 if (!gl::ValidBufferTarget(context, target))
Shannon Woodsb3801742014-03-27 14:59:19 -04008680 {
Geoff Langb1196682014-07-23 13:47:29 -04008681 context->recordError(gl::Error(GL_INVALID_ENUM));
8682 return NULL;
Shannon Woodsb3801742014-03-27 14:59:19 -04008683 }
Geoff Langbfdea662014-07-23 14:16:32 -04008684
8685 gl::Buffer *buffer = context->getState().getTargetBuffer(target);
8686
8687 if (buffer == NULL)
8688 {
Geoff Langb1196682014-07-23 13:47:29 -04008689 context->recordError(gl::Error(GL_INVALID_OPERATION));
8690 return NULL;
Geoff Langbfdea662014-07-23 14:16:32 -04008691 }
8692
8693 if (access != GL_WRITE_ONLY_OES)
8694 {
Geoff Langb1196682014-07-23 13:47:29 -04008695 context->recordError(gl::Error(GL_INVALID_ENUM));
8696 return NULL;
Geoff Langbfdea662014-07-23 14:16:32 -04008697 }
8698
8699 if (buffer->isMapped())
8700 {
Geoff Langb1196682014-07-23 13:47:29 -04008701 context->recordError(gl::Error(GL_INVALID_OPERATION));
8702 return NULL;
Geoff Langbfdea662014-07-23 14:16:32 -04008703 }
8704
Geoff Lang2a1c15a2014-07-25 11:43:00 -04008705 gl::Error error = buffer->mapRange(0, buffer->getSize(), GL_MAP_WRITE_BIT);
8706 if (error.isError())
8707 {
8708 context->recordError(error);
8709 return NULL;
8710 }
8711
8712 return buffer->getMapPointer();
Shannon Woodsb3801742014-03-27 14:59:19 -04008713 }
8714
8715 return NULL;
8716}
8717
Kenneth Russell67ea1902014-10-06 16:44:50 -07008718GLboolean GL_APIENTRY glUnmapBufferOES(GLenum target)
Shannon Woodsb3801742014-03-27 14:59:19 -04008719{
8720 EVENT("(GLenum target = 0x%X)", target);
8721
Geoff Langbfdea662014-07-23 14:16:32 -04008722 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04008723 if (context)
8724 {
8725 if (!gl::ValidBufferTarget(context, target))
Shannon Woodsb3801742014-03-27 14:59:19 -04008726 {
Geoff Langb1196682014-07-23 13:47:29 -04008727 context->recordError(gl::Error(GL_INVALID_ENUM));
8728 return GL_FALSE;
Shannon Woodsb3801742014-03-27 14:59:19 -04008729 }
Geoff Langbfdea662014-07-23 14:16:32 -04008730
8731 gl::Buffer *buffer = context->getState().getTargetBuffer(target);
8732
8733 if (buffer == NULL || !buffer->isMapped())
8734 {
Geoff Langb1196682014-07-23 13:47:29 -04008735 context->recordError(gl::Error(GL_INVALID_OPERATION));
8736 return GL_FALSE;
Geoff Langbfdea662014-07-23 14:16:32 -04008737 }
8738
8739 // TODO: detect if we had corruption. if so, throw an error and return false.
8740
Geoff Lang2a1c15a2014-07-25 11:43:00 -04008741 gl::Error error = buffer->unmap();
8742 if (error.isError())
8743 {
8744 context->recordError(error);
8745 return GL_FALSE;
8746 }
Geoff Langbfdea662014-07-23 14:16:32 -04008747
8748 return GL_TRUE;
Shannon Woodsb3801742014-03-27 14:59:19 -04008749 }
8750
8751 return GL_FALSE;
8752}
8753
Kenneth Russell67ea1902014-10-06 16:44:50 -07008754void* GL_APIENTRY glMapBufferRangeEXT (GLenum target, GLintptr offset, GLsizeiptr length, GLbitfield access)
Shannon Woods916e7692014-03-27 16:58:22 -04008755{
8756 EVENT("(GLenum target = 0x%X, GLintptr offset = %d, GLsizeiptr length = %d, GLbitfield access = 0x%X)",
8757 target, offset, length, access);
8758
Geoff Langbfdea662014-07-23 14:16:32 -04008759 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04008760 if (context)
8761 {
8762 if (!gl::ValidBufferTarget(context, target))
Shannon Woods916e7692014-03-27 16:58:22 -04008763 {
Geoff Langb1196682014-07-23 13:47:29 -04008764 context->recordError(gl::Error(GL_INVALID_ENUM));
8765 return NULL;
Shannon Woods916e7692014-03-27 16:58:22 -04008766 }
Geoff Langbfdea662014-07-23 14:16:32 -04008767
8768 if (offset < 0 || length < 0)
8769 {
Geoff Langb1196682014-07-23 13:47:29 -04008770 context->recordError(gl::Error(GL_INVALID_VALUE));
8771 return NULL;
Geoff Langbfdea662014-07-23 14:16:32 -04008772 }
8773
8774 gl::Buffer *buffer = context->getState().getTargetBuffer(target);
8775
8776 if (buffer == NULL)
8777 {
Geoff Langb1196682014-07-23 13:47:29 -04008778 context->recordError(gl::Error(GL_INVALID_OPERATION));
8779 return NULL;
Geoff Langbfdea662014-07-23 14:16:32 -04008780 }
8781
8782 // Check for buffer overflow
8783 size_t offsetSize = static_cast<size_t>(offset);
8784 size_t lengthSize = static_cast<size_t>(length);
8785
8786 if (!rx::IsUnsignedAdditionSafe(offsetSize, lengthSize) ||
8787 offsetSize + lengthSize > static_cast<size_t>(buffer->getSize()))
8788 {
Geoff Langb1196682014-07-23 13:47:29 -04008789 context->recordError(gl::Error(GL_INVALID_VALUE));
8790 return NULL;
Geoff Langbfdea662014-07-23 14:16:32 -04008791 }
8792
8793 // Check for invalid bits in the mask
8794 GLbitfield allAccessBits = GL_MAP_READ_BIT |
8795 GL_MAP_WRITE_BIT |
8796 GL_MAP_INVALIDATE_RANGE_BIT |
8797 GL_MAP_INVALIDATE_BUFFER_BIT |
8798 GL_MAP_FLUSH_EXPLICIT_BIT |
8799 GL_MAP_UNSYNCHRONIZED_BIT;
8800
8801 if (access & ~(allAccessBits))
8802 {
Geoff Langb1196682014-07-23 13:47:29 -04008803 context->recordError(gl::Error(GL_INVALID_VALUE));
8804 return NULL;
Geoff Langbfdea662014-07-23 14:16:32 -04008805 }
8806
8807 if (length == 0 || buffer->isMapped())
8808 {
Geoff Langb1196682014-07-23 13:47:29 -04008809 context->recordError(gl::Error(GL_INVALID_OPERATION));
8810 return NULL;
Geoff Langbfdea662014-07-23 14:16:32 -04008811 }
8812
8813 // Check for invalid bit combinations
8814 if ((access & (GL_MAP_READ_BIT | GL_MAP_WRITE_BIT)) == 0)
8815 {
Geoff Langb1196682014-07-23 13:47:29 -04008816 context->recordError(gl::Error(GL_INVALID_OPERATION));
8817 return NULL;
Geoff Langbfdea662014-07-23 14:16:32 -04008818 }
8819
8820 GLbitfield writeOnlyBits = GL_MAP_INVALIDATE_RANGE_BIT |
8821 GL_MAP_INVALIDATE_BUFFER_BIT |
8822 GL_MAP_UNSYNCHRONIZED_BIT;
8823
8824 if ((access & GL_MAP_READ_BIT) != 0 && (access & writeOnlyBits) != 0)
8825 {
Geoff Langb1196682014-07-23 13:47:29 -04008826 context->recordError(gl::Error(GL_INVALID_OPERATION));
8827 return NULL;
Geoff Langbfdea662014-07-23 14:16:32 -04008828 }
8829
8830 if ((access & GL_MAP_WRITE_BIT) == 0 && (access & GL_MAP_FLUSH_EXPLICIT_BIT) != 0)
8831 {
Geoff Langb1196682014-07-23 13:47:29 -04008832 context->recordError(gl::Error(GL_INVALID_OPERATION));
8833 return NULL;
Geoff Langbfdea662014-07-23 14:16:32 -04008834 }
8835
Geoff Lang2a1c15a2014-07-25 11:43:00 -04008836 gl::Error error = buffer->mapRange(offset, length, access);
8837 if (error.isError())
8838 {
8839 context->recordError(error);
8840 return NULL;
8841 }
8842
8843 return buffer->getMapPointer();
Shannon Woods916e7692014-03-27 16:58:22 -04008844 }
8845
8846 return NULL;
8847}
8848
Kenneth Russell67ea1902014-10-06 16:44:50 -07008849void GL_APIENTRY glFlushMappedBufferRangeEXT (GLenum target, GLintptr offset, GLsizeiptr length)
Shannon Woods916e7692014-03-27 16:58:22 -04008850{
8851 EVENT("(GLenum target = 0x%X, GLintptr offset = %d, GLsizeiptr length = %d)", target, offset, length);
8852
Geoff Langbfdea662014-07-23 14:16:32 -04008853 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04008854 if (context)
8855 {
8856 if (offset < 0 || length < 0)
Shannon Woods916e7692014-03-27 16:58:22 -04008857 {
Geoff Langb1196682014-07-23 13:47:29 -04008858 context->recordError(gl::Error(GL_INVALID_VALUE));
8859 return;
Shannon Woods916e7692014-03-27 16:58:22 -04008860 }
Geoff Langbfdea662014-07-23 14:16:32 -04008861
8862 if (!gl::ValidBufferTarget(context, target))
8863 {
Geoff Langb1196682014-07-23 13:47:29 -04008864 context->recordError(gl::Error(GL_INVALID_ENUM));
8865 return;
Geoff Langbfdea662014-07-23 14:16:32 -04008866 }
8867
8868 gl::Buffer *buffer = context->getState().getTargetBuffer(target);
8869
8870 if (buffer == NULL)
8871 {
Geoff Langb1196682014-07-23 13:47:29 -04008872 context->recordError(gl::Error(GL_INVALID_OPERATION));
8873 return;
Geoff Langbfdea662014-07-23 14:16:32 -04008874 }
8875
8876 if (!buffer->isMapped() || (buffer->getAccessFlags() & GL_MAP_FLUSH_EXPLICIT_BIT) == 0)
8877 {
Geoff Langb1196682014-07-23 13:47:29 -04008878 context->recordError(gl::Error(GL_INVALID_OPERATION));
8879 return;
Geoff Langbfdea662014-07-23 14:16:32 -04008880 }
8881
8882 // Check for buffer overflow
8883 size_t offsetSize = static_cast<size_t>(offset);
8884 size_t lengthSize = static_cast<size_t>(length);
8885
8886 if (!rx::IsUnsignedAdditionSafe(offsetSize, lengthSize) ||
8887 offsetSize + lengthSize > static_cast<size_t>(buffer->getMapLength()))
8888 {
Geoff Langb1196682014-07-23 13:47:29 -04008889 context->recordError(gl::Error(GL_INVALID_VALUE));
8890 return;
Geoff Langbfdea662014-07-23 14:16:32 -04008891 }
8892
8893 // We do not currently support a non-trivial implementation of FlushMappedBufferRange
Shannon Woods916e7692014-03-27 16:58:22 -04008894 }
8895}
8896
Kenneth Russell67ea1902014-10-06 16:44:50 -07008897__eglMustCastToProperFunctionPointerType EGLAPIENTRY glGetProcAddress(const char *procname)
daniel@transgaming.comce3d0f22010-05-04 03:35:14 +00008898{
8899 struct Extension
8900 {
8901 const char *name;
8902 __eglMustCastToProperFunctionPointerType address;
8903 };
8904
8905 static const Extension glExtensions[] =
8906 {
8907 {"glTexImage3DOES", (__eglMustCastToProperFunctionPointerType)glTexImage3DOES},
daniel@transgaming.com01868132010-08-24 19:21:17 +00008908 {"glBlitFramebufferANGLE", (__eglMustCastToProperFunctionPointerType)glBlitFramebufferANGLE},
daniel@transgaming.com1fe96c92011-01-14 15:08:44 +00008909 {"glRenderbufferStorageMultisampleANGLE", (__eglMustCastToProperFunctionPointerType)glRenderbufferStorageMultisampleANGLE},
apatrick@chromium.orgd3bd0ad2010-08-30 18:55:36 +00008910 {"glDeleteFencesNV", (__eglMustCastToProperFunctionPointerType)glDeleteFencesNV},
8911 {"glGenFencesNV", (__eglMustCastToProperFunctionPointerType)glGenFencesNV},
8912 {"glIsFenceNV", (__eglMustCastToProperFunctionPointerType)glIsFenceNV},
8913 {"glTestFenceNV", (__eglMustCastToProperFunctionPointerType)glTestFenceNV},
8914 {"glGetFenceivNV", (__eglMustCastToProperFunctionPointerType)glGetFenceivNV},
8915 {"glFinishFenceNV", (__eglMustCastToProperFunctionPointerType)glFinishFenceNV},
8916 {"glSetFenceNV", (__eglMustCastToProperFunctionPointerType)glSetFenceNV},
zmo@google.coma574f782011-10-03 21:45:23 +00008917 {"glGetTranslatedShaderSourceANGLE", (__eglMustCastToProperFunctionPointerType)glGetTranslatedShaderSourceANGLE},
daniel@transgaming.com0bd1f2f2011-11-11 04:19:03 +00008918 {"glTexStorage2DEXT", (__eglMustCastToProperFunctionPointerType)glTexStorage2DEXT},
daniel@transgaming.com709ed112011-11-12 03:18:10 +00008919 {"glGetGraphicsResetStatusEXT", (__eglMustCastToProperFunctionPointerType)glGetGraphicsResetStatusEXT},
8920 {"glReadnPixelsEXT", (__eglMustCastToProperFunctionPointerType)glReadnPixelsEXT},
8921 {"glGetnUniformfvEXT", (__eglMustCastToProperFunctionPointerType)glGetnUniformfvEXT},
8922 {"glGetnUniformivEXT", (__eglMustCastToProperFunctionPointerType)glGetnUniformivEXT},
daniel@transgaming.com86bdb822012-01-20 18:24:39 +00008923 {"glGenQueriesEXT", (__eglMustCastToProperFunctionPointerType)glGenQueriesEXT},
8924 {"glDeleteQueriesEXT", (__eglMustCastToProperFunctionPointerType)glDeleteQueriesEXT},
8925 {"glIsQueryEXT", (__eglMustCastToProperFunctionPointerType)glIsQueryEXT},
8926 {"glBeginQueryEXT", (__eglMustCastToProperFunctionPointerType)glBeginQueryEXT},
8927 {"glEndQueryEXT", (__eglMustCastToProperFunctionPointerType)glEndQueryEXT},
8928 {"glGetQueryivEXT", (__eglMustCastToProperFunctionPointerType)glGetQueryivEXT},
8929 {"glGetQueryObjectuivEXT", (__eglMustCastToProperFunctionPointerType)glGetQueryObjectuivEXT},
shannon.woods%transgaming.com@gtempaccount.com77d94722013-04-13 03:34:22 +00008930 {"glDrawBuffersEXT", (__eglMustCastToProperFunctionPointerType)glDrawBuffersEXT},
daniel@transgaming.comdce02fd2012-01-27 15:39:51 +00008931 {"glVertexAttribDivisorANGLE", (__eglMustCastToProperFunctionPointerType)glVertexAttribDivisorANGLE},
8932 {"glDrawArraysInstancedANGLE", (__eglMustCastToProperFunctionPointerType)glDrawArraysInstancedANGLE},
8933 {"glDrawElementsInstancedANGLE", (__eglMustCastToProperFunctionPointerType)glDrawElementsInstancedANGLE},
apatrick@chromium.org3ce8dbc2012-06-08 17:52:30 +00008934 {"glGetProgramBinaryOES", (__eglMustCastToProperFunctionPointerType)glGetProgramBinaryOES},
Shannon Woodsb3801742014-03-27 14:59:19 -04008935 {"glProgramBinaryOES", (__eglMustCastToProperFunctionPointerType)glProgramBinaryOES},
8936 {"glGetBufferPointervOES", (__eglMustCastToProperFunctionPointerType)glGetBufferPointervOES},
8937 {"glMapBufferOES", (__eglMustCastToProperFunctionPointerType)glMapBufferOES},
Shannon Woods916e7692014-03-27 16:58:22 -04008938 {"glUnmapBufferOES", (__eglMustCastToProperFunctionPointerType)glUnmapBufferOES},
8939 {"glMapBufferRangeEXT", (__eglMustCastToProperFunctionPointerType)glMapBufferRangeEXT},
8940 {"glFlushMappedBufferRangeEXT", (__eglMustCastToProperFunctionPointerType)glFlushMappedBufferRangeEXT}, };
daniel@transgaming.comce3d0f22010-05-04 03:35:14 +00008941
shannon.woods@transgaming.comd438fd42013-02-28 23:17:45 +00008942 for (unsigned int ext = 0; ext < ArraySize(glExtensions); ext++)
daniel@transgaming.comce3d0f22010-05-04 03:35:14 +00008943 {
8944 if (strcmp(procname, glExtensions[ext].name) == 0)
8945 {
8946 return (__eglMustCastToProperFunctionPointerType)glExtensions[ext].address;
8947 }
8948 }
8949
8950 return NULL;
8951}
8952
daniel@transgaming.com17f548c2011-11-09 17:47:02 +00008953// Non-public functions used by EGL
8954
Kenneth Russell67ea1902014-10-06 16:44:50 -07008955bool EGLAPIENTRY glBindTexImage(egl::Surface *surface)
jbauman@chromium.orgae345802011-03-30 22:04:25 +00008956{
8957 EVENT("(egl::Surface* surface = 0x%0.8p)",
8958 surface);
8959
Geoff Langbfdea662014-07-23 14:16:32 -04008960 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04008961 if (context)
8962 {
8963 gl::Texture2D *textureObject = context->getTexture2D();
8964 ASSERT(textureObject != NULL);
8965
8966 if (textureObject->isImmutable())
jbauman@chromium.orgae345802011-03-30 22:04:25 +00008967 {
Geoff Langbfdea662014-07-23 14:16:32 -04008968 return false;
jbauman@chromium.orgae345802011-03-30 22:04:25 +00008969 }
Geoff Langbfdea662014-07-23 14:16:32 -04008970
8971 textureObject->bindTexImage(surface);
jbauman@chromium.orgae345802011-03-30 22:04:25 +00008972 }
daniel@transgaming.com64a0fb22011-11-11 04:10:40 +00008973
8974 return true;
jbauman@chromium.orgae345802011-03-30 22:04:25 +00008975}
8976
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00008977}